////////////////////////////////////////////////////////////////////////////// //文件: 曲面文件操作类,主要是为了封装CDimension3D与CFunction2D两个曲面类 //主要功能: // 用于保存网格类 //程序编写: 2011-12-8 // // ///////////////////////////////////////////////////////////////////////////// #pragma once #include "Dimension3D.h" #include "Function2D.h" namespace NContour { class AFX_EXT_CLASS CMeshBase { public: CMeshBase(void); ~CMeshBase(void); CGrid* GetMesh() { return m_pMesh; } CDimension3D* GetDfg() { return (CDimension3D*)m_pMesh; } CFunction2D* GetFun() { return (CFunction2D*) m_pMesh; } CSize size(); //获得曲面的行列数 int GetDimension(void) { return GetMesh()->n; } //获得曲面的维数 double x(int i) { return GetMesh()->x(i); } double y(int j) { return GetMesh()->y(j); } CRect8 GetRect() { return GetMesh()->GetRect(); } void operator =(CMeshBase& mb); double GetValue(double x0, double y0) { return m_pMesh->Value(x0, y0); } inline double GetValue(int i, int j) { return m_pMesh->Value(i, j); } inline void SetValue(int i, int j, double v) { return m_pMesh->SetValue(i, j, v);} virtual void ClearMesh(); //仅删除网格文件 virtual void Empty(); virtual void Serialize(CArchive& ar, const short &ver); enum EMeshType { typeERR = 0, typeDFG = 1, //CDimension3D对象,可以是体网格 typeFXY = 2 //CFunction2D对象 }; bool CreateMesh(EMeshType mt); //生成对应的指针对象,并绑定 void Attach(CGrid* pMesh, EMeshType mt); CGrid* Detach(); EMeshType GetMeshType() { return m_eMeshType; } void SetMeshType(EMeshType mt) { m_eMeshType = mt; } BOOL m_bRealTimeDraw; protected: //为了支持体网格,并与CMesh类中的对象统一,内部生成的CDimension3D对象,但使用时仅为CDimension2D //另外还可以是CFunction2D对象 CGrid* m_pMesh; EMeshType m_eMeshType; }; }//namespace