#pragma once #include "item.h" #include "GridAlgoInterpolator.h" namespace NItem { #define MESH_DEFAULT 0 #define MESH_CREATE_CONTOUR 1 #define MESH_EDIT_NODE 2 //网格节点编辑 #define MESH_HISTOGRAM 3 //统计图 #define MESH_GET_RANGE 4 //获得Z值范围,用户可以指定无效值 #define MESH_GRID_SMOOTH 5 //对网格进行平滑 class CItemMesh : public CItem { public: CItemMesh(CSigmaDoc* ppDoc); virtual ~CItemMesh(void); //CDC* m_pDrawDC; //virtual void OnDraw(CXyDC* pDC); void OnLButtonDown(CDC * pDC, UINT nFlags, CPoint point, int vk) override; int OnMouseMove(CDC * pDC, UINT nFlags, CPoint point) override; void SetPos(POSITION pos) override; CMesh* GetMesh(void); void SaveAs(COne* pOne, LPCTSTR filePath, int index); void SaveAsOnlyData(COne* pOne, LPCTSTR filePath); wchar_t * GetInformationForGeneratingContour(); bool CreateContour(COne* pOne, char * infoString); //BOOL InitPropertyGridMesh(CXTPPropertyGrid& grid); bool GridPointNoExist(UINT nFlags, CPoint point); CString GetGridValue(UINT nFlags, CPoint point); //平滑操作 bool GridSmooth(COne* pOne, double coefficient, int smoothNumber); void OnDraw(CXyDC* pDC) override; void OnDraw(CXyDC* pXyDC, CDC* pDC) override; void EditNode(CSigmaView* pView, CDC *pDC, CRect rt); bool FindNodeLocation(CDC *pDC, CPoint point, int& locationX, int& locationY); void Histogram(void); void ConfirmGridBtn(); int GetEditMode(void); //归一化 bool GridNormalization(COne* pOne); bool GridGenerationBoundary(COne* pOne); //网格外扩 bool RBFGridExpansion(COne* pOne, int dx_left, int dx_right, int dy_top, int dy_bottom, int maskRadius, double smoothing, int neighbors, int type, int numStep); bool IDWGridExpansion(COne* pOne, int dx_left, int dx_right, int dy_top, int dy_bottom, int maskRadius, int k, int p, int numStep); CPositionList m_posAddList; //for histogram void SetHistogramRange(double zmin, double zmax); int DeleteSelected(void); void DrawNode(CXyDC* pDC); void DrawNode(CXyDC* pDC, CRect rect); void SetZValueOfNodeSelected(double v); bool SetZOfGridPoint(double z, int row, int column); void GetAreaAndValueForSelected(double minZ, double maxZ, double * areaOut, double * volumeOut); private: struct ExpContext { int oldNx, oldNy; double oldX0, oldY0, dX, dY; int newNx, newNy; double newX0, newY0; int dx_left, dx_right, dy_top, dy_bottom; double zmin, zmax; }; // 初始化网格 & 拷贝数据 bool PrepareGrid(COne* pOne, int dx_l, int dx_r, int dy_t, int dy_b, ExpContext& ctx, CDimension2D*& pDfgNew, std::vector& baseMask, std::vector& validPoints); // 辅助函数 2: 计算 Mask 并收集目标点 void CollectTargets(const ExpContext& ctx, int maskRadius, const std::vector& baseMask, std::vector& xq, std::vector& yq, std::vector& tIdx); // 一维膨胀逻辑 (分离轴算法,由 ComputeDilatedMask 调用) void Dilate1D_Line(const std::vector& in, std::vector& out, int width, int height, int radius, bool is_horizontal); // 主膨胀函数:计算允许插值的区域 Mask void ComputeDilatedMask(int nx, int ny, int radius, const std::vector& input, std::vector& output); protected: CDC * pDrawerDC; //for histogram void DrawHistogram(CXyDC* pDC); bool ParseInformationOfCreatingContour(char * infoStr); CSize8 m_zrange; //Z值范围 BOOL m_bDrawRangeZ; //CDlgHistogram *m_pHistogramDlg; CColorBase color; int typeIndex; //背景显示类型:透明等 long m_levelAlpha; //透明度设置(0-255) CString name; int modeFun; //偏导等 int GetFunctionIdea(DWORD nFunMode); DWORD GetFunctionMode(int nFunIdea); int m_nDimensionSel; //维数,0=2D,1=3D BOOL m_bReversal = FALSE; BOOL m_bRuler = FALSE; BOOL m_bUpdateRuler = FALSE; CPoint2D m_point; BOOL m_bShowColorPane; int m_RulerIdea; //如水平平滑,水平方格,垂直平滑,垂直方格 int GetRulerIdea(DWORD nMode); DWORD GetRulerMode(int nIdea); int m_nSelect; //for create contour double m_contourStep; long m_contourMarkStep; CString m_strLayerMark; CString m_strLayerOther; int m_nFaultageMode; CString m_strFaultageFile; CString m_strFaultageLayer; //for node edit BOOL m_bDrawPrevPoint; CPoint2D m_ptPrevPoint; void DrawFocus(CPoint2D point); //for get Z range CSize8 m_szInvalidateValueZ; BOOL m_bResetZ = FALSE; //for smooth double m_smoothcoef; //平滑系数 long m_smthtimes; //平滑次数 CRect clientRect; }; };