00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SMESH_MesherHelper_HeaderFile
00027 #define SMESH_MesherHelper_HeaderFile
00028
00029 #include "SMESH_SMESH.hxx"
00030
00031 #include "SMESH_MeshEditor.hxx"
00032 #include <SMDS_MeshNode.hxx>
00033 #include <SMDS_QuadraticEdge.hxx>
00034
00035 #include <Geom_Surface.hxx>
00036 #include <TopoDS_Face.hxx>
00037 #include <TopoDS_Shape.hxx>
00038 #include <gp_Pnt2d.hxx>
00039
00040 #include <map>
00041
00042 typedef std::map<SMESH_TLink, const SMDS_MeshNode*> TLinkNodeMap;
00043 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode;
00044
00054 typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
00055 typedef std::map< double, TNodeColumn > TParam2ColumnMap;
00056
00057 class SMESH_EXPORT SMESH_MesherHelper
00058 {
00059 public:
00060
00061
00068 static bool IsMedium(const SMDS_MeshNode* node,
00069 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
00070
00084 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
00085 const TopoDS_Face& theFace,
00086 const TopoDS_Edge& theBaseEdge,
00087 SMESHDS_Mesh* theMesh);
00094 static TopoDS_Shape GetSubShapeByNode(const SMDS_MeshNode* node,
00095 SMESHDS_Mesh* meshDS);
00096
00103 static int WrapIndex(const int ind, const int nbNodes) {
00104 if ( ind < 0 ) return nbNodes + ind % nbNodes;
00105 if ( ind >= nbNodes ) return ind % nbNodes;
00106 return ind;
00107 }
00108
00112 static int NbAncestors(const TopoDS_Shape& shape,
00113 const SMESH_Mesh& mesh,
00114 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
00115
00116 public:
00117
00118
00119
00120 SMESH_MesherHelper(SMESH_Mesh& theMesh);
00121
00122 SMESH_Mesh* GetMesh() const { return myMesh; }
00123
00124 SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); }
00125
00130 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
00134 void SetIsQuadratic(const bool theBuildQuadratic)
00135 { myCreateQuadratic = theBuildQuadratic; }
00139 bool GetIsQuadratic() const { return myCreateQuadratic; }
00140
00145 void FixQuadraticElements(bool volumeOnly=true);
00146
00152 void SetElementsOnShape(bool toSet) { mySetElemOnShape = toSet; }
00153
00157 void SetSubShape(const int subShapeID);
00158 void SetSubShape(const TopoDS_Shape& subShape);
00163 int GetSubShapeID() const { return myShapeID; }
00167 TopoDS_Shape GetSubShape() const { return myShape; }
00168
00172 SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0);
00176 SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1,
00177 const SMDS_MeshNode* n2,
00178 const int id = 0,
00179 const bool force3d = true);
00183 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
00184 const SMDS_MeshNode* n2,
00185 const SMDS_MeshNode* n3,
00186 const int id=0,
00187 const bool force3d = false);
00191 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
00192 const SMDS_MeshNode* n2,
00193 const SMDS_MeshNode* n3,
00194 const SMDS_MeshNode* n4,
00195 const int id = 0,
00196 const bool force3d = false);
00200 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
00201 const SMDS_MeshNode* n2,
00202 const SMDS_MeshNode* n3,
00203 const SMDS_MeshNode* n4,
00204 const int id = 0,
00205 const bool force3d = true);
00209 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
00210 const SMDS_MeshNode* n2,
00211 const SMDS_MeshNode* n3,
00212 const SMDS_MeshNode* n4,
00213 const SMDS_MeshNode* n5,
00214 const int id = 0,
00215 const bool force3d = true);
00219 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
00220 const SMDS_MeshNode* n2,
00221 const SMDS_MeshNode* n3,
00222 const SMDS_MeshNode* n4,
00223 const SMDS_MeshNode* n5,
00224 const SMDS_MeshNode* n6,
00225 const int id = 0,
00226 const bool force3d = true);
00230 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
00231 const SMDS_MeshNode* n2,
00232 const SMDS_MeshNode* n3,
00233 const SMDS_MeshNode* n4,
00234 const SMDS_MeshNode* n5,
00235 const SMDS_MeshNode* n6,
00236 const SMDS_MeshNode* n7,
00237 const SMDS_MeshNode* n8,
00238 const int id = 0,
00239 bool force3d = true);
00243 double GetNodeU(const TopoDS_Edge& theEdge,
00244 const SMDS_MeshNode* theNode,
00245 bool* check=0);
00250 gp_XY GetNodeUV(const TopoDS_Face& F,
00251 const SMDS_MeshNode* n,
00252 const SMDS_MeshNode* inFaceNode=0,
00253 bool* check=0) const;
00258 bool CheckNodeUV(const TopoDS_Face& F,
00259 const SMDS_MeshNode* n,
00260 gp_XY& uv,
00261 const double tol) const;
00265 static gp_XY GetMiddleUV(const Handle(Geom_Surface)& surface,
00266 const gp_XY& uv1,
00267 const gp_XY& uv2);
00275 bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const;
00276
00284 bool IsDegenShape(const int subShape) const
00285 { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
00294 bool IsSeamShape(const int subShape) const
00295 { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
00304 bool IsSeamShape(const TopoDS_Shape& subShape) const
00305 { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); }
00310 bool IsRealSeam(const int subShape) const
00311 { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
00316 bool IsRealSeam(const TopoDS_Shape& subShape) const
00317 { return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); }
00323 bool HasSeam() const { return !mySeamShapeIds.empty(); }
00328 int GetPeriodicIndex() const { return myParIndex; }
00332 double GetOtherParam(const double param) const;
00333
00337 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
00338 const SMDS_MeshNode* n2,
00339 const bool force3d);
00343 void AddTLinkNode(const SMDS_MeshNode* n1,
00344 const SMDS_MeshNode* n2,
00345 const SMDS_MeshNode* n12);
00349 void AddTLinkNodeMap(const TLinkNodeMap& aMap)
00350 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
00351
00355 const TLinkNodeMap& GetTLinkNodeMap() const { return myTLinkNodeMap; }
00356
00362 enum MType{ LINEAR, QUADRATIC, COMP };
00363 MType IsQuadraticMesh();
00364
00365 protected:
00366
00373 gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
00374
00375 private:
00376
00377
00378 SMESH_MesherHelper (const SMESH_MesherHelper& theOther) {};
00379
00380
00381 TLinkNodeMap myTLinkNodeMap;
00382
00383 std::set< int > myDegenShapeIds;
00384 std::set< int > mySeamShapeIds;
00385 double myPar1, myPar2;
00386 int myParIndex;
00387
00388 TopoDS_Shape myShape;
00389 SMESH_Mesh* myMesh;
00390 int myShapeID;
00391
00392
00393 bool myCreateQuadratic;
00394 bool mySetElemOnShape;
00395 std::set< int > myOkNodePosShapes;
00396
00397 };
00398
00399
00400 #endif