You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1447 lines
35 KiB
C++

1 month ago
#include "pch.h"
#include "AppFunc.h"
#include "Interface.h"
1 month ago
#include "contourfillmap.h"
1 month ago
typedef void(*CPPCallbackMousePos)(double mouseX, double mouseY);
typedef void(*CPPCallbackViewStatus)(double pX, double pY, double scale);
CPPCallbackMousePos mouseMoveEvent = nullptr;
CPPCallbackViewStatus viewStatusEvent = nullptr;
extern "C" __declspec(dllexport)
void SetMouseMoveEvent(CPPCallbackMousePos callback) {
mouseMoveEvent = callback;
}
extern "C" __declspec(dllexport)
void SetViewStatusEvent(CPPCallbackViewStatus callback) {
viewStatusEvent = callback;
}
extern "C" __declspec(dllexport)
void Editor_InitView(void* hwnd, LPCTSTR imagePath)
{
char caImagePath[256];
memset(caImagePath, 0, sizeof(char) * 256);
CString strImgPath(imagePath);
if (!strImgPath.IsEmpty()) {
strncpy_s(caImagePath, imagePath, strImgPath.GetLength());
}
Func_InitView(hwnd, caImagePath);
}
extern "C" __declspec(dllexport)
void Editor_InitViewWithColor(void* hwnd, int r, int g, int b)
{
Func_InitViewWithColor(hwnd, r, g, b);
}
extern "C" __declspec(dllexport)
void Editor_RenderView()
{
Func_RenderView();
}
extern "C" __declspec(dllexport)
void Editor_ZoomView()
{
Func_ZoomView();
}
extern "C" __declspec(dllexport)
1 month ago
int Editor_CreateMesh(CXy* pXy, LPCTSTR contourLayer, LPCTSTR faultLayer, LPCTSTR pointLayer, LPCTSTR otherLineLayer, int type)
{
1 month ago
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> z ֵС<D6B5><D0A1> 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0
POSITION meshPos = pXy->FindFirstElement(DOUBLEFOX_MESH);
if (meshPos == nullptr)
{
return 0;
}
COne *pOne = pXy->GetAt(meshPos);
CMesh* pMesh = (CMesh*)(pOne->GetValue());
CDimension3D* pDimension = pMesh->GetDfg();
int numx = pDimension->xnum();
int numy = pDimension->ynum();
double dx0 = pDimension->xmin();
double dy0 = pDimension->ymin();
double dStepX = pDimension->dx();
double dStepY = pDimension->dy();
double* pU = pDimension->u;
// <20><><EFBFBD><EFBFBD><5A><D6B5>Χ
Func_SetZRange(pDimension->range[0], pDimension->range[1]);
//int nReturn = Func_LoadFile("C:\\temp\\k12.kev");
1 month ago
int nReturn = Func_CreateMesh(numx, numy, dx0, dy0, dStepX, dStepY, pU, type);
1 month ago
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
vector<ColorItem> colors;
int nColorCount = pMesh->color.GetCount();
for (int i = 0; i < nColorCount; i++) {
CColorItem colorMesh = pMesh->color.GetColorItem(i);
ColorItem colorItem;
colorItem.r = colorMesh.R();
colorItem.g = colorMesh.G();
colorItem.b = colorMesh.B();
colorItem.a = 1;
colorItem.c = colorMesh.m_bContinue;
colorItem.val = colorMesh.z;
colors.push_back(colorItem);
}
Func_SetColorList(colors);
1 month ago
if (type == 0)
1 month ago
{
1 month ago
// <20><><EFBFBD>öϲ<C3B6><>ֶ<EFBFBD>ѡ)
std::vector<PlineList> vecFault; // <20>ܶϲ<DCB6><CFB2>б<EFBFBD>
if (faultLayer && lstrlen(faultLayer) > 0)
{
CString strFaultLayers = faultLayer;
int nPos = 0;
CString strSingleLayer = strFaultLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
{
std::vector<PlineList> vecTemp;
TakeLayerLines(pXy, strSingleLayer, vecTemp, false, false);
if (vecTemp.size() > 0)
{
vecFault.insert(vecFault.end(), vecTemp.begin(), vecTemp.end());
}
strSingleLayer = strFaultLayers.Tokenize(_T(";"), nPos);
}
}
1 month ago
1 month ago
if (vecFault.size() > 0)
{
Func_SetFaultList(vecFault, false);
}
// <20><><EFBFBD>õ<EFBFBD>ֵ<EFBFBD><D6B5>
std::vector<PlineList> vecContour;
TakeLayerLines(pXy, contourLayer, vecContour, true, true);
if (vecContour.size() > 0) {
Func_SetContourList(vecContour);
}
1 month ago
}
1 month ago
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֶ<EFBFBD>ѡ)
1 month ago
std::vector<PlineList> vecOtherLines;
1 month ago
if (otherLineLayer && lstrlen(otherLineLayer) > 0)
{
CString strOtherLayers = otherLineLayer;
int nPos = 0;
CString strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
{
std::vector<PlineList> vecTemp;
TakeLayerLines(pXy, strSingleLayer, vecTemp, false, false);
if (vecTemp.size() > 0)
{
vecOtherLines.insert(vecOtherLines.end(), vecTemp.begin(), vecTemp.end());
}
strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
}
}
1 month ago
if (vecOtherLines.size() > 0)
{
1 month ago
Func_SetOtherLines(vecOtherLines);
1 month ago
}
// <20><><EFBFBD>ÿ<EFBFBD><C3BF>Ƶ<EFBFBD>
if (pointLayer && lstrlen(pointLayer) > 0)
{
1 month ago
std::vector<ControlPoint2d> ptControl; // <20>ܵĿ<DCB5><C4BF>Ƶ㼯<C6B5><E3BCAF>
CString strPointLayers = pointLayer;
int nPos = 0;
CString strSingleLayer = strPointLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
1 month ago
{
1 month ago
NBase::CPositionList lstPoint;
pXy->GetElement(strSingleLayer, lstPoint, false, false);
if (lstPoint.GetCount() > 0)
{
POSITION pos = lstPoint.GetHeadPosition();
POSITION pt;
std::string strLayer;
while (pos) {
pt = lstPoint.GetNext(pos);
COne* pOne = (COne*)pXy->GetAt(pt);
if (pOne->GetType() != DOUBLEFOX_POINT)
{
continue;
}
CPointNameEx* pPoint = (CPointNameEx*)(pOne->GetValue());
Point2D pt2d(pPoint->x0, pPoint->y0);
CString cstrName = pPoint->GetName();
std::string strName;
strName.assign(cstrName.GetBuffer(), cstrName.GetLength());
cstrName.ReleaseBuffer();
ControlPoint2d cpt2d(pt2d, pPoint->z0, strName);
ptControl.push_back(cpt2d); // <20><><EFBFBD>ӵ<EFBFBD><D3B5>ܼ<EFBFBD><DCBC><EFBFBD>
1 month ago
}
}
1 month ago
// <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
strSingleLayer = strPointLayers.Tokenize(_T(";"), nPos);
1 month ago
}
1 month ago
// <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>˿<EFBFBD><CBBF>Ƶ㣬ͳһ<CDB3><D2BB><EFBFBD><EFBFBD>
1 month ago
if (ptControl.size() > 0)
{
Func_SetControlPoint(ptControl);
}
}
Func_ShowMesh(true);
Func_ShowMeshVertex(false);
Func_ZoomView();
return nReturn;
}
extern "C" __declspec(dllexport)
void Editor_StartCommand() {
Func_StartCommand();
}
extern "C" __declspec(dllexport)
void Editor_EndCommand() {
Func_EndCommand();
}
extern "C" __declspec(dllexport)
void Editor_StrechUp(int ipx, int ipy, float rad, float per, int type, float wellrad =0) {
Func_StrechUp(ipx, ipy, rad, per, type, wellrad);
}
extern "C" __declspec(dllexport)
void Editor_StrechDown(int ipx, int ipy, float rad, float per, int type, float wellrad = 0) {
Func_PushDown(ipx, ipy, rad, per, type, wellrad);
}
extern "C" __declspec(dllexport)
void Editor_DragAway(int startx, int starty, int endx, int endy, float rad, float per, int type, float wellrad = 0)
{
Func_DragAway(startx, starty, endx, endy, rad, per, type, wellrad);
}
extern "C" __declspec(dllexport)
void Editor_Smooth(int ipx, int ipy, float rad, float per, int type, float wellrad = 0)
{
Func_Smooth(ipx, ipy, rad, per, type, wellrad);
}
extern "C" __declspec(dllexport)
void Editor_DrawCircle(int ipx, int ipy, float rad) {
Func_DrawCircle(ipx, ipy, rad);
}
extern "C" __declspec(dllexport)
void Editor_ClearCircle() {
Func_ClearCircle();
}
extern "C" __declspec(dllexport)
void Editor_OffsetFault()
{
Func_OffsetFault();
}
extern "C" __declspec(dllexport)
void Editor_FreeAll() {
Func_FreeAll();
}
extern "C" __declspec(dllexport)
bool Editor_CanUndo()
{
return Func_CanUndo();
}
extern "C" __declspec(dllexport)
bool Editor_CanRedo()
{
return Func_CanRedo();
}
extern "C" __declspec(dllexport)
void Editor_Undo() {
Func_Undo();
}
extern "C" __declspec(dllexport)
void Editor_Redo() {
Func_Redo();
}
bool HaveCurveViewName(CLayer* pLayer) {
CHowToViewCurve* pHowToView = pLayer->HowToViewCurve;
if (pHowToView == nullptr || pHowToView->GetCount() == 0) {
return false;
}
for (int i = 0; i < pHowToView->GetCount(); i++) {
CCurveView* pView = pHowToView->GetAt(i);
if (pView->GetType() == CurveInName || pView->GetType() == CurveInNameAny) {
return true;
}
}
return false;
}
extern "C" __declspec(dllexport)
void Editor_DeleteArray(int64_t* array)
{
delete[] array;
}
1 month ago
1 month ago
/**
* <EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD>д
*
* \param pXy ͼ<EFBFBD><EFBFBD>
* \param curveLayer Ҫд<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
* \param destroyArray Ҫ<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>ͼԪ POSITION<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼԪ<EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Editor_DeleteArray <EFBFBD>ͷ<EFBFBD><EFBFBD>ڴ<EFBFBD>
* \param destroyLength Ҫ<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>
* \param insertedArray <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼԪ POSITION<EFBFBD><EFBFBD>ͼԪ<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Editor_DeleteArray <EFBFBD>ͷ<EFBFBD><EFBFBD>ڴ<EFBFBD>
* \param insertedLength
* \param layerName <EFBFBD><EFBFBD>ֵ<EFBFBD>߱<EFBFBD>עͼ<EFBFBD><EFBFBD>
* \param layerNoName <EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ޱ<EFBFBD>עͼ<EFBFBD><EFBFBD>
1 month ago
* \param type <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
1 month ago
* \return
*/
extern "C" __declspec(dllexport)
bool Editor_PushbackData(CXy * pXy, LPCTSTR curveLayer, int64_t** destroyArray, int64_t& destroyLength, int64_t** insertedArray, int64_t& insertedLength,
1 month ago
LPCTSTR layerName, LPCTSTR layerNoName, int type) {
1 month ago
double* pValues = Func_GetValue();
double zMin = Func_GetZMin();
double zMax = Func_GetZMax();
1 month ago
1 month ago
POSITION meshPos = pXy->FindFirstElement(DOUBLEFOX_MESH);
if (meshPos == nullptr)
{
return false;
}
COne *pOne = pXy->GetAt(meshPos);
CMesh* pMesh = (CMesh*)(pOne->GetValue());
//CDimension3D* pDimension = pMesh->GetDfg();
CSize size = pMesh->size();
for (int i = 0; i < size.cx; i++) {
for (int j = 0; j < size.cy; j++)
{
((CMeshBase *)pMesh)->SetValue(i, j, pValues[i + j * size.cx]);
}
}
pMesh->SetM(zMin, zMax);
1 month ago
if (!type)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
// <20><>ȡ<EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>ɫ<EFBFBD><C9AB>Χ
double dZMinOld = 0;
double dZMaxOld = 0;
pMesh->color.GetZRange(dZMinOld, dZMaxOld);
// <20><><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD>·<EFBFBD>Χ<EFBFBD><CEA7>ͬ<EFBFBD><CDAC>ֻ<EFBFBD><D6BB><EFBFBD>·<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>ɫ
if (fabs(dZMinOld - zMin) > 1e-6 || fabs(dZMaxOld - zMax) > 1e-6)
{
pMesh->color.SetZRange(zMin, zMax);
}
pMesh->GetBitmap();
}
else
1 month ago
{
1 month ago
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
vector<ColorItem> colors;
Func_GetColorList(colors);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
double dZMinOld = 0;
double dZMaxOld = 0;
pMesh->color.GetZRange(dZMinOld, dZMaxOld);
CArray<CColorItem, CColorItem> ColorList;
int nColorCount = colors.size();
for (int i = 0; i < nColorCount; i++) {
const ColorItem& src = colors[i];
CColorItem colorMesh;
// <20><><EFBFBD><EFBFBD> RGB + Alpha
colorMesh.SetColor(
(BYTE)src.r,
(BYTE)src.g,
(BYTE)src.b,
(BYTE)(src.a * 255.0f) // float alpha ת 0-255
);
colorMesh.z = src.val;
colorMesh.m_bContinue = src.c ? TRUE : FALSE;
ColorList.Add(colorMesh);
}
1 month ago
pMesh->color.SetZRange(zMin, zMax);
1 month ago
pMesh->color.SetColor(ColorList);
pMesh->UpdateColorRuler();
pMesh->GetBitmap();
1 month ago
}
// <20><>ֵ<EFBFBD><D6B5>
CLayer* pLayerName = nullptr;
CLayer* pLayerNoName = nullptr;
pLayerName = pXy->FindLayer(layerName);
pLayerNoName = pXy->FindLayer(layerNoName);
if (pLayerName == nullptr || pLayerNoName == nullptr)
{
CPtrList lstLayer;
pXy->FindLayers(curveLayer, lstLayer, true);
POSITION posPos = lstLayer.GetHeadPosition();
while (posPos != nullptr)
{
CLayer* pLayerFind = (CLayer*)lstLayer.GetNext(posPos);
bool bViewName = HaveCurveViewName(pLayerFind);
if (bViewName)
{
pLayerName = pLayerFind;
}
else
{
pLayerNoName = pLayerFind;
}
}
}
if (pLayerNoName == nullptr&& pLayerName == nullptr) {
pLayerNoName = pXy->FindAddLayer(curveLayer);
pLayerName = pLayerNoName;
}
else if (pLayerName == nullptr) {
pLayerName = pLayerNoName;
}
else if (pLayerNoName == nullptr) {
pLayerNoName = pLayerName;
}
NBase::CPositionList lstPos;
pXy->GetElement(curveLayer, lstPos, true, false);
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
POSITION posInsert = pXy->GetValueList()->GetTailPosition();
if (lstPos.GetCount() > 0) {
posInsert = lstPos.GetHead();
//POSITION pos = lstPos.GetHeadPosition();
//POSITION pt;
//while (pos) {
// pt = lstPos.GetNext(pos);
// pXy->RemoveAt(pt);
//}
}
std::vector<PlineList> contourList;
Func_GetContourList(contourList);
std::vector<POSITION> insertedPositions;
insertedPositions.clear();
for (int i = 0; i < contourList.size(); i++) {
PlineList lstLine = contourList[i];
std::string strLayerName = lstLine.GetName();
//CLayer * pLayer = pXy->FindAddLayer(strLayerName.c_str());
double dLayerValue = lstLine.GetValue();
CString strValue;
strValue.Format("%lg", dLayerValue);
vector<PlineList::Polyline2d> vctLine = lstLine.GetPaths();
for (int j = 0; j < vctLine.size(); j++) {
PlineList::Polyline2d line = vctLine[j];
1 month ago
NBase::CPointList pointList;
1 month ago
for (int k = 0; k < line.size(); k++)
{
1 month ago
NBase::dfPoint point;
1 month ago
point.x0 = line[k].x();
point.y0 = line[k].y();
pointList.AddTail(point);
}
CCurveEx* pCurve = new CCurveEx();
pCurve->SetPoints(pointList, 2);
pCurve->SetName(strValue);
//POSITION pos = pXy->AddElement(pCurve, DOUBLEFOX_CURVE);
POSITION pos = pXy->InsertElementAfter(posInsert, pCurve, DOUBLEFOX_CURVE);
insertedPositions.push_back(pos);
COne* pOne = pXy->GetAt(pos);
CLayer * pLayer = pLayerName;
if (strLayerName == "<EFBFBD>ޱ<EFBFBD>ע") {
pLayer = pLayerNoName;
}
pOne->SetLayer(pLayer);
posInsert = pos;
}
}
// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ͼԪ
destroyLength = lstPos.GetCount();
*destroyArray = new int64_t[destroyLength];
int32_t destroyIndex = 0;
for (POSITION pos = lstPos.GetHeadPosition(); pos != nullptr; lstPos.GetNext(pos))
{
POSITION pt = lstPos.GetAt(pos);
(*destroyArray)[destroyIndex++] = reinterpret_cast<int64_t>(pt);
}
// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD>ͼԪ
insertedLength = insertedPositions.size();
*insertedArray = new int64_t[insertedLength];
int32_t insertedIndex = 0;
for (POSITION pos : insertedPositions)
{
(*insertedArray)[insertedIndex++] = reinterpret_cast<int64_t>(pos);
}
return true;
}
extern "C" __declspec(dllexport)
void Editor_ShowMesh(bool visible)
{
Func_ShowMesh(visible);
}
extern "C" __declspec(dllexport)
void Editor_ShowMeshVertex(bool bShow)
{
Func_ShowMeshVertex(bShow);
}
extern "C" __declspec(dllexport)
void Editor_ShowIsopleth(bool visible)
{
Func_ShowIsopleth(visible);
}
extern "C" __declspec(dllexport)
void Editor_ShowControlPoint(bool visible) {
Func_ShowControlPoint(visible);
}
extern "C" __declspec(dllexport)
void Editor_ShowFault(bool visible)
{
Func_ShowFault(visible);
}
extern "C" __declspec(dllexport)
void Editor_ShowBound(bool visible) {
Func_ShowBound(visible);
}
extern "C" __declspec(dllexport)
void Editor_ShowOtherLines(bool visible) {
Func_ShowOtherLines(visible);
}
extern "C" __declspec(dllexport)
void Editor_GetProperty(double& isopStep, int& markStep, double& minIsop, double& maxIsop,
double& zMin, double& zMax) {
Func_GetProperty(isopStep, markStep, minIsop, maxIsop, zMin, zMax);
}
extern "C" __declspec(dllexport)
void Editor_SetProperty(double isopStep, int markStep, double minIsop, double maxIsop,
double zMin, double zMax)
{
Func_SetProperty(isopStep, markStep, minIsop, maxIsop, zMin, zMax);
}
bool HaveCurveViewName(CXy* pxy, COne* pOne) {
CHowToViewCurve* pHowToView = pOne->GetLayer()->HowToViewCurve;
if (pHowToView == nullptr || pHowToView->GetCount()==0) {
return false;
}
for (int i = 0; i < pHowToView->GetCount(); i++) {
CCurveView* pView = pHowToView->GetAt(i);
if (pView->GetType() == CurveInName || pView->GetType() == CurveInNameAny) {
return true;
}
}
return false;
}
1 month ago
//bWithSubLayer <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD>
void TakeLayerLines(CXy * pXy, const LPCTSTR &layerName, std::vector<PlineList> &vecPline, bool isContour, bool bWithSubLayer)
1 month ago
{
if (layerName == nullptr || lstrlen(layerName) == 0)
{
return;
}
NBase::CPositionList lstFault;
1 month ago
pXy->GetElement(layerName, lstFault, bWithSubLayer, false);
1 month ago
if (lstFault.GetCount() > 0) {
POSITION pos = lstFault.GetHeadPosition();
POSITION pt;
std::string strLayer;
while (pos) {
pt = lstFault.GetNext(pos);
COne *pOne = (COne *)pXy->GetAt(pt);
if (pOne->GetType() != DOUBLEFOX_CURVE) {
continue;
}
bool bViewName = HaveCurveViewName(pXy, pOne);
if (bViewName == true) {
strLayer = "<EFBFBD><EFBFBD>ע";
}
else {
strLayer = "<EFBFBD>ޱ<EFBFBD>ע";
}
CCurveEx* pCurve = (CCurveEx*)(pOne->GetValue());
CString cstrName = pCurve->GetName();
PlineList::Polyline2d pline2D;
if (isContour)
{ // <20><>ֵ<EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD><EFBFBD><5A><D6B5>ͼ<EFBFBD><CDBC>
if (cstrName.IsEmpty())
{
continue;
}
double z = _tcstod(cstrName, nullptr);
bool bFind = false;
for (size_t i = 0; i < vecPline.size(); i++) {
auto contourList = vecPline[i];
if (abs(contourList.GetValue() - z) < 1E-5) {
contourList.AddPath(pline2D);
bFind = true;
break;
}
}
if (bFind == false) {
CString cstrLayer = pOne->GetLayer()->GetName();
//std::string strLayer = CT2A(cstrLayer);
PlineList lineList;
lineList.AddPath(pline2D);
lineList.SetValue(z);
lineList.SetName(strLayer);
vecPline.push_back(lineList);
}
}
else {
for (int i = 0; i < pCurve->num; i++)
{
Point2D point{ pCurve->x[i], pCurve->y[i] };
pline2D.push_back(point);
}
if (vecPline.size() == 0) {
PlineList lineList;
vecPline.push_back(lineList);
}
PlineList& lineList = vecPline[0];
lineList.AddPath(pline2D);
//lineList.SetName(strLayer);
}
}
}
}
#pragma region <20><><EFBFBD>ڹ<EFBFBD><DAB9>ܽӿ<DCBD>
//<2F><><EFBFBD><EFBFBD><5A>󶨹<EFBFBD><F3B6A8B9><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
1 month ago
void Editor_WellAdaptiveAdjust(int correctionType, int gridNum, float rad, float range, float miu)
1 month ago
{
1 month ago
Func_WellAdaptiveAdjust(correctionType, gridNum, rad, range, miu);
1 month ago
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>鿴Zֵ
extern "C" __declspec(dllexport)
void Editor_EnablePickMeshZ(bool bEnable)
{
Func_EnablePickMeshZ(bEnable);
}
//<2F><><EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
extern "C" __declspec(dllexport)
void Editor_SetWellColor(int r = 255, int g = 255, int b = 255)
{
Func_SetWellColor(r, g, b);
}
extern "C" __declspec(dllexport)
void Editor_SetWellTxtSize(float size)
{
Func_SetWellTxtSize(size);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD>
extern "C" __declspec(dllexport)
void Editor_EnableFillFault(bool bEnable)
{
Func_EnableFillFault(bEnable);
}
//<2F><><EFBFBD>˵<EFBFBD>ֵ<EFBFBD><D6B5>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
void Editor_FilterMesh(float throld)
{
Func_FilterMesh(throld);
}
//<2F><><EFBFBD><EFBFBD>/<2F>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>򿪣<EFBFBD><F2BFAAA3><EFBFBD><EFBFBD>ڹرյ<D8B1>ʱ<EFBFBD><CAB1><EFBFBD>˳<EFBFBD>)
extern "C" __declspec(dllexport)
void Editor_EnableDrawPolygon(bool bEnable)
{
Func_EnableDrawPolygon(bEnable);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F>պ϶<D5BA><CFB6><EFBFBD><EFBFBD>κ󣬾Ϳ<F3A3ACBE><CDBF>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD>
//per:ǿ<>ȣ<EFBFBD>wellRad:<3A><><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EBBEB6>Ĭ<EFBFBD><C4AC>Ϊ0<CEAA><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Լ<EFBFBD><D4BC>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
void Editor_StretchUpPolygon(float per, bool state, float wellRad = 0)
{
Func_StretchlUpPolygon(per, state, wellRad);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>÷<EFBFBD>ͬ<EFBFBD><CDAC>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
void Editor_PushDownPolygon(float per, bool state, float wellRad = 0)
{
Func_PushDownPolygon(per, state, wellRad);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>ͬ<EFBFBD><CDAC>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
void Editor_SmoothPolygon(float per, bool state, float wellRad = 0)
{
Func_SmoothPolygon(per, state, wellRad);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>÷<EFBFBD>ͬFunc_StrechUp
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>undo/redo,<2C><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>֮ǰ<D6AE><C7B0>Func_StartCommand<6E><64><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Func_EndCommand
extern "C" __declspec(dllexport)
void Editor_OptimizeMesh(int startx, int starty, int endx, int endy, float rad, float per)
{
Func_OptimizeMesh(startx, starty, endx, endy, rad, per);
}
//<2F><>ȡ<EFBFBD><C8A1>ʾλ<CABE><CEBB>
//<2F><>px,py<70><79><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϽǶ<CFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
// scale<6C><65>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD>ף<EFBFBD>
extern "C" __declspec(dllexport)
void Editor_GetViewPos(double& px, double& py, double& scale)
{
Func_GetViewPos(px, py, scale);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
extern "C" __declspec(dllexport)
void Editor_SetViewPos(double px, double py, double scale)
{
Func_SetViewPos(px, py, scale);
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
extern "C" __declspec(dllexport)
void Editor_GetMousePos(double& px, double& py)
{
Func_GetMousePos(px, py);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
extern "C" __declspec(dllexport)
void Editor_SetMousePos(double px, double py)
{
Func_SetMousePos(px, py);
}
1 month ago
extern "C" __declspec(dllexport)
void Editor_SetMouseWheelState(bool state)
{
Func_SetMouseWheelState(state);
}
1 month ago
#pragma endregion
1 month ago
//<2F><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
bool Editor_CompileExpressionZ(LPCTSTR expressionString)
{
char expressionStr[256];
memset(expressionStr, 0, sizeof(char) * 256);
CString str(expressionString);
if (!str.IsEmpty()) {
strncpy_s(expressionStr, expressionString, str.GetLength());
}
bool state = Func_CompileExpressionZ(expressionStr);
return state;
}
1 month ago
//Zֵ<5A><D6B5><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
bool Editor_CalculateZByExpression(LPCTSTR expressionString)
{
char expressionStr[256];
memset(expressionStr, 0, sizeof(char) * 256);
CString str(expressionString);
if (!str.IsEmpty()) {
strncpy_s(expressionStr, expressionString, str.GetLength());
}
bool state = Func_CalculateZByExpression(expressionStr);
return state;
}
//<2F><>ȡ<EFBFBD><C8A1>С
extern "C" __declspec(dllexport)
double Editor_GetZMin()
{
return Func_GetZMin();
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
double Editor_GetZMax()
{
return Func_GetZMax();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾС<CABE><D0A1>λ<EFBFBD><CEBB>
extern "C" __declspec(dllexport)
void Editor_SetDecimalNumber(int num)
{
Func_SetDecimalNumber(num);
}
//<2F><>ȡ<EFBFBD><C8A1>ʾ<EFBFBD><CABE>С<EFBFBD><D0A1>λ<EFBFBD><CEBB>
extern "C" __declspec(dllexport)
int Editor_GetDecimalNumber()
{
return Func_GetDecimalNumber();
}
//<2F><><EFBFBD>öϲ<C3B6><CFB2><EFBFBD><EFBFBD><EFBFBD>״̬
extern "C" __declspec(dllexport)
void Editor_SetFaultControlState(bool state)
{
Func_SetFaultControlState(state);
}
//<2F><>ȡ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>״̬
extern "C" __declspec(dllexport)
bool Editor_GetFaultControlState()
{
return Func_GetFaultControlState();
}
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
extern "C" __declspec(dllexport)
1 month ago
bool Editor_RectificationMeshWellCompute(double deltaz, int correctionType, int gridNum, int type, double factor)
1 month ago
{
1 month ago
return Func_RectificationMeshWellCompute(deltaz, correctionType, gridNum, type, factor);
1 month ago
}
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3> <20>߳<EFBFBD><DFB3><EFBFBD>ֹ
extern "C" __declspec(dllexport)
void Editor_MeshWellThreadStop()
{
Func_MeshWellThreadStop();
}
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3> <20><><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
int Editor_GetWellRectificationProgress()
{
return Func_GetWellRectificationProgress();
}
//ˢ<>½<EFBFBD><C2BD><EFBFBD>
extern "C" __declspec(dllexport)
void Editor_UpdateObjectView()
{
return Func_UpdateObjectView();
}
1 month ago
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ
extern "C" __declspec(dllexport)
void Editor_DrawCircleStampClone(int ipx, int ipy, float rad, bool state)
{
Func_DrawCircleStampClone(ipx, ipy, rad, state);
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
extern "C" __declspec(dllexport)
void Editor_StampClone(int ipx, int ipy, float rad)
{
return Func_StampClone(ipx, ipy, rad);
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
void Editor_StampCloneSample(int ipx, int ipy, float rad)
{
//Func_DrawCircleName("Circle1", ipx, ipy, rad);
Func_DrawCircleStampClone(ipx, ipy, rad, true);
return Func_StampCloneSample(ipx, ipy, rad);
}
//<2F><><EFBFBD>Ƽ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
void Editor_DrawTrendArrowOnWindow(LPCTSTR arrowName, int ipx, int ipy,
float angle, float ratio)
{
Func_DrawTrendArrowOnWindow(arrowName, ipx, ipy, angle, ratio);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ(<28><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>)
extern "C" __declspec(dllexport)
void Editor_ClearTrendArrow(LPCTSTR arrowName)
{
Func_ClearTrendArrow(arrowName);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>ͷ(<28><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>)
extern "C" __declspec(dllexport)
void Editor_ClearAllTrendArrows()
{
Func_ClearAllTrendArrows();
}
struct PointDataInterop
{
double X;
double Y;
double Z;
double TZ;
char Name[256];
};
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>Ƶ<EFBFBD>
extern "C" __declspec(dllexport)
int Editor_GetPointList(CXy* pXy, LPCTSTR pointLayer, PointDataInterop* outArray, int capacity)
{
int validCount = 0;
if (pointLayer && lstrlen(pointLayer) > 0)
{
CString strPointLayers = pointLayer;
int nPos = 0;
CString strSingleLayer = strPointLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
{
NBase::CPositionList lstPoint;
pXy->GetElement(strSingleLayer, lstPoint, true, false);
if (lstPoint.GetCount() > 0)
{
POSITION pos = lstPoint.GetHeadPosition();
POSITION pt;
while (pos) {
pt = lstPoint.GetNext(pos);
COne* pOne = (COne*)pXy->GetAt(pt);
if (pOne->GetType() != DOUBLEFOX_POINT) {
continue;
}
CPointNameEx* pPoint = (CPointNameEx*)(pOne->GetValue());
if (outArray != nullptr && validCount < capacity)
{
outArray[validCount].X = pPoint->x0;
outArray[validCount].Y = pPoint->y0;
outArray[validCount].Z = pPoint->z0;
double z1 = 0;
Func_GetPonitZ(pPoint->x0, pPoint->y0, z1);
outArray[validCount].TZ = z1;
CString cstrName = pPoint->GetName();
CT2A asciiName(cstrName);
strncpy_s(outArray[validCount].Name, 256, asciiName, _TRUNCATE);
}
validCount++;
}
}
strSingleLayer = strPointLayers.Tokenize(_T(";"), nPos);
}
}
return validCount;
}
extern "C" __declspec(dllexport)
int Editor_SetWellPointList(PointDataInterop* inArray, int count)
{
if (!inArray || count <= 0) return 0;
std::vector<ControlPoint2d> pointList;
pointList.reserve(count);
for (int i = 0; i < count; ++i)
{
Point2D pt(inArray[i].X, inArray[i].Y);
std::string strName = inArray[i].Name;
ControlPoint2d cp(pt, inArray[i].Z, strName);
pointList.push_back(cp);
}
Func_SetWellControlPoint(pointList);
return 1;
}
extern "C" __declspec(dllexport)
bool Editor_FittingCorrectionOperation(LPCTSTR expressionString)
{
char expressionStr[256];
memset(expressionStr, 0, sizeof(char) * 256);
CString str(expressionString);
if (!str.IsEmpty()) {
strncpy_s(expressionStr, expressionString, str.GetLength());
}
bool state = Func_FittingCorrectionOperation(expressionStr);
return state;
}
//ȫͼƽ<CDBC><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><CBB9>
extern "C" __declspec(dllexport)
void Editor_FullSmoothIterativeGaussian(int type, double sigma, int iter, int gridNum)
{
Func_FullSmoothIterativeGaussian(type, sigma, iter, gridNum);
}
//ȫͼƽ<CDBC><C6BD>
extern "C" __declspec(dllexport)
void Editor_FullSmoothIDWMesh(int type, double smoothCoefficient, int smoothTimes, int gridNum)
{
Func_FullSmoothIDWMesh(type, smoothCoefficient, smoothTimes, gridNum);
}
struct LineVolumnData
{
char Name[256];
double Area;
double Volumn;
double AreaVolumn;
};
// <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> (<28>ݻ<EFBFBD><DDBB><EFBFBD>)
extern "C" __declspec(dllexport)
int Editor_StatisVolumn(CXy* pXy, LPCTSTR otherLineLayer, LineVolumnData* outArray, int count, int volumeMode)
{
// <20><><EFBFBD><EFBFBD> outArray Ϊ<>գ<EFBFBD>˵<EFBFBD><CBB5>ֻ<EFBFBD><D6BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> Mesh <20>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool bCalculate = (outArray != nullptr);
CMesh* pOriginMesh = NULL;
POSITION pos = pXy->FindFirstElement(DOUBLEFOX_MESH);
if (pos)
{
pOriginMesh = (CMesh*)pXy->GetAtValue(pos);
}
if (pOriginMesh == NULL)
{
return 0;
}
CMesh* pWorkMesh = NULL;
if (bCalculate)
{
pWorkMesh = new CMesh();
if (pWorkMesh)
{
*pWorkMesh = *pOriginMesh;
double* pValues = Func_GetValue();
double zMin = Func_GetZMin();
double zMax = Func_GetZMax();
CSize size = pWorkMesh->size(); // <20><>ȡ<EFBFBD>ߴ<EFBFBD>
for (int i = 0; i < size.cx; i++)
{
for (int j = 0; j < size.cy; j++)
{
((CMeshBase*)pWorkMesh)->SetValue(i, j, pValues[i + j * size.cx]);
}
}
pWorkMesh->SetM(zMin, zMax);
}
if (pWorkMesh == NULL)
{
return 0;
}
}
int outputIndex = 0;
// <20><>ȡÿ<C8A1><C3BF><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
if (otherLineLayer && lstrlen(otherLineLayer) > 0)
{
CString strOtherLayers = otherLineLayer;
int nPos = 0;
CString strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
{
NBase::CPositionList lstFault;
pXy->GetElement(strSingleLayer, lstFault, true, false);
if (lstFault.GetCount() > 0)
{
POSITION pos = lstFault.GetHeadPosition();
POSITION pt;
while (pos)
{
pt = lstFault.GetNext(pos);
COne* pOne = (COne*)pXy->GetAt(pt);
if (pOne->GetType() != DOUBLEFOX_CURVE)
{
continue;
}
if (!bCalculate)
{
outputIndex++;
continue;
}
CCurveEx* pCurve = (CCurveEx*)(pOne->GetValue());
double area = pCurve->Area();
double areaVolumn = 0;
double volumn = 0;
CString strName = pCurve->GetName();
// <20><>ʱ pWorkMesh һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><C7B0><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD>)
if (pWorkMesh)
{
if (volumeMode == 0) //<2F><><EFBFBD><EFBFBD>ͼ
{
NBase::CPoint3D point;
if (pWorkMesh->GetHightPoint(pCurve, point) > 0) //<2F><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>
{
double cz = pWorkMesh->GetClosedZ(*pCurve, point.z0); //<2F><><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD>
areaVolumn = pWorkMesh->TradeArea(*pCurve, cz);
if (std::isnan(areaVolumn))
{
areaVolumn = 0;
}
volumn = areaVolumn * area;
}
}
else if (volumeMode == 1) //<2F>Ⱥ<EFBFBD>ͼ
{
areaVolumn = pWorkMesh->TradeArea(*pCurve, 0);
if (std::isnan(areaVolumn))
{
areaVolumn = 0;
}
volumn = areaVolumn * area;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>
if (outArray != nullptr && outputIndex < count)
{
outArray[outputIndex].Area = area;
outArray[outputIndex].Volumn = volumn;
outArray[outputIndex].AreaVolumn = areaVolumn;
CT2A asciiName(strName);
strcpy_s(outArray[outputIndex].Name, 256, asciiName);
}
outputIndex++;
}
}
strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
if (pWorkMesh)
{
delete pWorkMesh;
pWorkMesh = NULL;
}
return outputIndex;
}
double TakeZFromName(LPCTSTR curveName) {
vector<CString> vecString;
CString strTmp;
int iPos = 0;
double dZ = 0;
int nCount = 0;
while (AfxExtractSubString(strTmp, curveName, iPos, ','))
{
iPos++;
dZ += atof(strTmp);
nCount++;
}
return dZ / nCount;
}
// <20><><EFBFBD><EFBFBD> CMyCurve ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ClearMyCurveVector(vector<CMyCurve*>& vec)
{
for (size_t i = 0; i < vec.size(); i++)
{
if (vec[i] != NULL)
delete vec[i];
}
vec.clear();
}
// <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> (<28><>ֵ<EFBFBD>߷<EFBFBD>)
extern "C" __declspec(dllexport)
int Editor_ContourStatisVolumn(CXy* pXy, LPCTSTR otherLineLayer, LPCTSTR faultLayer, LineVolumnData* outArray, int count)
{
if (!otherLineLayer || lstrlen(otherLineLayer) == 0) return 0;
//outArray<61>ǿ<EFBFBD><C7BF><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool bCalculate = (outArray != nullptr);
std::vector<PlineList> rawContourList;
std::vector<CCurveEx*> rawFaults;
if (bCalculate)
{
Func_GetContourList(rawContourList);
if (faultLayer && lstrlen(faultLayer) > 0)
{
POSITION pos, pt;
CList<POSITION, POSITION> lstFault;
pXy->GetElement(faultLayer, lstFault, TRUE);
if (lstFault.GetCount() > 0) {
pos = lstFault.GetHeadPosition();
while (pos)
{
pt = lstFault.GetNext(pos);
COne* pOne = pXy->GetAt(pt);
if (pOne->GetType() == DOUBLEFOX_CURVE) {
rawFaults.push_back((CCurveEx*)pOne->value);
}
}
}
}
}
int outputIndex = 0;
CString strOtherLayers = otherLineLayer;
int nPos = 0;
CString strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
while (strSingleLayer != _T(""))
{
NBase::CPositionList lstPolygons;
pXy->GetElement(strSingleLayer, lstPolygons, true, false);
if (lstPolygons.GetCount() > 0)
{
POSITION pos = lstPolygons.GetHeadPosition();
POSITION pt;
while (pos)
{
pt = lstPolygons.GetNext(pos);
COne* pOne = (COne*)pXy->GetAt(pt);
if (pOne->GetType() != DOUBLEFOX_CURVE)
continue;
if (!bCalculate)
{
outputIndex++;
continue;
}
CCurveEx* pBoundaryCurve = (CCurveEx*)(pOne->GetValue());
CString strName = pBoundaryCurve->GetName();
CContourFillMap cfmp;
vector<CMyCurve*> contours;
vector<CMyCurve*> flts;
CMyCurve curBorder;
curBorder.Create(pBoundaryCurve->num);
for (int i = 0; i < pBoundaryCurve->num; i++) {
curBorder.SetPoint(i, pBoundaryCurve->x[i], pBoundaryCurve->y[i], pBoundaryCurve->z[i]);
}
for (int i = 0; i < rawContourList.size(); i++)
{
// (<28><><EFBFBD><EFBFBD>ԭ<EFBFBD>еĹ<D0B5><C4B9><EFBFBD><EFBFBD>߼<EFBFBD>)
PlineList lstLine = rawContourList[i];
double dLayerValue = lstLine.GetValue();
CString strValue;
strValue.Format("%lg", dLayerValue);
vector<PlineList::Polyline2d> vctLine = lstLine.GetPaths();
for (int j = 0; j < vctLine.size(); j++)
{
const PlineList::Polyline2d& line = vctLine[j];
CMyCurve* curve = new CMyCurve();
curve->Create(line.size());
for (int k = 0; k < line.size(); k++) curve->SetPoint(k, line[k].x(), line[k].y(), dLayerValue);
curve->SetName(strValue);
curve->GetLocation();
contours.push_back(curve);
}
}
cfmp.SetContours(contours);
// ... <20><><EFBFBD><EFBFBD> flts ...
for (size_t i = 0; i < rawFaults.size(); i++)
{
CCurveEx* pF = rawFaults[i];
CMyCurve* curve = new CMyCurve();
curve->Create(pF->num);
for (int k = 0; k < pF->num; k++) curve->SetPoint(k, pF->x[k], pF->y[k], pF->z[k]);
curve->SetName(pF->GetName());
curve->GetLocation();
flts.push_back(curve);
}
cfmp.SetFlts(flts);
// ... <20><><EFBFBD><EFBFBD> ...
cfmp.SetBorder(curBorder);
cfmp.SetExtensivePara(1.1);
cfmp.CreatePolygons();
double dAreaTotal = 0;
double dVolumTotal = 0;
std::vector<CMyCurve*> resultAreas = cfmp.GetResultPolygons();
for (size_t i = 0; i < resultAreas.size(); i++)
{
CMyCurve* pResultCurve = resultAreas[i];
double dArea = pResultCurve->Area();
double dZ = TakeZFromName(pResultCurve->GetName());
dAreaTotal += dArea;
dVolumTotal += dZ * dArea;
}
ClearMyCurveVector(contours);
ClearMyCurveVector(flts);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (outputIndex < count)
{
outArray[outputIndex].Area = dAreaTotal;
outArray[outputIndex].Volumn = fabs(dVolumTotal);
if (dAreaTotal != 0)
outArray[outputIndex].AreaVolumn = fabs(dVolumTotal / dAreaTotal);
else
outArray[outputIndex].AreaVolumn = 0;
CT2A asciiName(strName);
strcpy_s(outArray[outputIndex].Name, 256, asciiName);
}
outputIndex++;
}
}
strSingleLayer = strOtherLayers.Tokenize(_T(";"), nPos);
}
return outputIndex;
}
extern "C" __declspec(dllexport)
void Editor_DragShape(int ipx, int ipy, int isx, int isy, float rad, float per)
{
Func_DragShape(ipx, ipy, isx, isy, rad, per);
}
extern "C" __declspec(dllexport)
void Editor_DragShapeChangeData()
{
Func_DragShapeChangeData();
}
#pragma region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
void Editor_SetFaciesTypeZ(int zValue)
{
Func_SetFaciesType(zValue);
}
extern "C" __declspec(dllexport)
void Editor_GetFaciesTypeZ(int px, int py, int &colorZ)
{
Func_GetFaciesTypeZ(px, py, colorZ);
}
extern "C" __declspec(dllexport)
void Editor_BrushSetZInCircle(int ipx, int ipy, float rad, int zValue)
{
Func_BrushSetZInCircle(ipx, ipy, rad, zValue);
}
extern "C" __declspec(dllexport)
void Editor_FeatherBrushInCircle(int ipx, int ipy, float rad, float per)
{
Func_FeatherBrushInCircle(ipx, ipy, rad, per);
}
extern "C" __declspec(dllexport)
void Editor_BrushSmoothZInCircle(int ipx, int ipy, float rad, float per)
{
Func_BrushSmoothZInCircle(ipx, ipy, rad, per);
}
extern "C" __declspec(dllexport)
void Editor_BrushEraseInCircle(int ipx, int ipy, float rad)
{
Func_BrushEraseInCircle(ipx, ipy, rad);
}
extern "C" __declspec(dllexport)
void Editor_MagicWandSetZ(int ipx, int ipy, int zVaule)
{
Func_MagicWandSetZ(ipx, ipy, zVaule);
}
extern "C" __declspec(dllexport)
void Editor_FaciesPolygonLassoZ(int zVaule)
{
Func_FaciesPolygonLassoZ(zVaule);
}
extern "C" __declspec(dllexport)
void Editor_FaciesPolygonLassoSmooth(float per)
{
Func_FaciesPolygonLassoSmooth(per);
}
extern "C" __declspec(dllexport)
void Editor_FaciesFullImageSmooth(float per)
{
Func_FaciesFullImageSmooth(per);
}
extern "C" __declspec(dllexport)
int * Editor_GetFaciesList(int& count)
{
std::vector<int> faciesList;
Func_GetFaciesList(faciesList);
count = faciesList.size();
if (count == 0)
{
return nullptr;
}
// <20><><EFBFBD><EFBFBD> COM <20><><EFBFBD>ͷŵ<CDB7><C5B5>ڴ棨C# <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> CoTaskMemFree<65><65>
int* result = static_cast<int*>(CoTaskMemAlloc(count * sizeof(int)));
if (!result)
{
return nullptr;
}
std::memcpy(result, faciesList.data(), count * sizeof(int));
return result;
}
extern "C" __declspec(dllexport)
void Editor_GetColorByZ(double z, int& r, int& g, int& b)
{
Func_GetColorByZ(z, r, g, b);
}
extern "C" __declspec(dllexport)
void Editor_SetColorByZ(double z, int r, int g, int b)
{
Func_SetColorByZ(z, r, g, b);
}
#pragma endregion