1 // File: StdMeshers_Helper.hxx
2 // Created: 15.02.06 14:48:09
4 // Copyright: Open CASCADE 2006
7 #ifndef StdMeshers_Helper_HeaderFile
8 #define StdMeshers_Helper_HeaderFile
10 #include <SMESH_Mesh.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <SMDS_MeshNode.hxx>
13 #include <TopoDS_Face.hxx>
14 #include <gp_Pnt2d.hxx>
18 typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
19 typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
20 typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
23 * \brief It helps meshers to add elements
25 * It allow meshers not to care about creation of medium nodes
26 * when filling a quadratic mesh. Helper does it itself.
27 * It defines degree of elements to create when IsQuadraticSubMesh()
31 class StdMeshers_Helper
34 // ---------- PUBLIC METHODS ----------
37 StdMeshers_Helper(SMESH_Mesh& theMesh)
38 { myMesh=(void *)&theMesh; myCreateQuadratic = false; }
40 SMESH_Mesh* GetMesh() const
41 { return (SMESH_Mesh*)myMesh; }
44 //Standard_EXPORT StdMeshers_Helper (const StdMeshers_Helper& theOther);
47 //Standard_EXPORT virtual ~StdMeshers_Helper ();
50 * Check submesh for given shape
51 * Check if all elements on this shape
52 * are quadratic, if yes => set true to myCreateQuadratic
53 * (default value is false). Also fill myNLinkNodeMap
54 * Returns myCreateQuadratic
56 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
59 * \brief Returns true if given node is medium
60 * \param n - node to check
61 * \param typeToCheck - type of elements containing the node to ask about node status
62 * \retval bool - check result
64 static bool IsMedium(const SMDS_MeshNode* node,
65 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
68 * Auxilary function for filling myNLinkNodeMap
70 void AddNLinkNode(const SMDS_MeshNode* n1,
71 const SMDS_MeshNode* n2,
72 const SMDS_MeshNode* n12);
75 * Auxilary function for filling myNLinkNodeMap
77 void AddNLinkNodeMap(const NLinkNodeMap& aMap)
78 { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
81 * Returns myNLinkNodeMap
83 const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; }
86 * \brief Return node UV on face
89 * \param n2 - a medium node will be placed between n and n2
90 * \retval gp_XY - resulting UV
92 * Auxilary function called form GetMediumNode()
94 gp_XY GetNodeUV(const TopoDS_Face& F,
95 const SMDS_MeshNode* n,
96 const SMDS_MeshNode* n2=0);
99 * Special function for search or creation medium node
101 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
102 const SMDS_MeshNode* n2,
105 * Special function for creation quadratic triangle
107 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
108 const SMDS_MeshNode* n2,
109 const SMDS_MeshNode* n3);
112 * Special function for creation quadratic quadrangle
114 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
115 const SMDS_MeshNode* n2,
116 const SMDS_MeshNode* n3,
117 const SMDS_MeshNode* n4);
120 * Special function for creation quadratic tetraahedron
122 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
123 const SMDS_MeshNode* n2,
124 const SMDS_MeshNode* n3,
125 const SMDS_MeshNode* n4);
128 * Special function for creation quadratic pentahedron
130 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
131 const SMDS_MeshNode* n2,
132 const SMDS_MeshNode* n3,
133 const SMDS_MeshNode* n4,
134 const SMDS_MeshNode* n5,
135 const SMDS_MeshNode* n6);
138 * Special function for creation quadratic hexahedron
140 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
141 const SMDS_MeshNode* n2,
142 const SMDS_MeshNode* n3,
143 const SMDS_MeshNode* n4,
144 const SMDS_MeshNode* n5,
145 const SMDS_MeshNode* n6,
146 const SMDS_MeshNode* n7,
147 const SMDS_MeshNode* n8);
153 * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
154 * \param uv1 - UV on the seam
155 * \param uv2 - UV within a face
156 * \retval gp_Pnt2d - selected UV
158 gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
166 // Key for creation quadratic faces
167 bool myCreateQuadratic;
169 // special map for using during creation quadratic faces
170 NLinkNodeMap myNLinkNodeMap;
172 std::set< int > mySeamShapeIds;
173 double myPar1, myPar2; // bounds of a closed periodic surface
174 int myParIndex; // bounds' index (1-U, 2-V)