1 // File: SMESH_MesherHelper.hxx
2 // Created: 15.02.06 14:48:09
4 // Copyright: Open CASCADE 2006
7 #ifndef SMESH_MesherHelper_HeaderFile
8 #define SMESH_MesherHelper_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>
15 #include <SMDS_QuadraticEdge.hxx>
19 typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
20 typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
21 typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
24 * \brief It helps meshers to add elements
26 * It allow meshers not to care about creation of medium nodes
27 * when filling a quadratic mesh. Helper does it itself.
28 * It defines degree of elements to create when IsQuadraticSubMesh()
32 class SMESH_MesherHelper
35 // ---------- PUBLIC METHODS ----------
38 SMESH_MesherHelper(SMESH_Mesh& theMesh)
39 { myMesh=(void *)&theMesh; myCreateQuadratic = false; }
41 SMESH_Mesh* GetMesh() const
42 { return (SMESH_Mesh*)myMesh; }
45 //Standard_EXPORT SMESH_MesherHelper (const SMESH_MesherHelper& theOther);
48 //Standard_EXPORT virtual ~SMESH_MesherHelper ();
51 * Check submesh for given shape
52 * Check if all elements on this shape
53 * are quadratic, if yes => set true to myCreateQuadratic
54 * (default value is false). Also fill myNLinkNodeMap
55 * Returns myCreateQuadratic
57 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
60 * \brief Returns true if given node is medium
61 * \param n - node to check
62 * \param typeToCheck - type of elements containing the node to ask about node status
63 * \retval bool - check result
65 static bool IsMedium(const SMDS_MeshNode* node,
66 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
69 * Auxilary function for filling myNLinkNodeMap
71 void AddNLinkNode(const SMDS_MeshNode* n1,
72 const SMDS_MeshNode* n2,
73 const SMDS_MeshNode* n12);
76 * Auxilary function for filling myNLinkNodeMap
78 void AddNLinkNodeMap(const NLinkNodeMap& aMap)
79 { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
82 * Returns myNLinkNodeMap
84 const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; }
87 * \brief Return node UV on face
90 * \param n2 - a medium node will be placed between n and n2
91 * \retval gp_XY - resulting UV
93 * Auxilary function called form GetMediumNode()
95 gp_XY GetNodeUV(const TopoDS_Face& F,
96 const SMDS_MeshNode* n,
97 const SMDS_MeshNode* n2=0);
100 * \brief Return U on edge
101 * \param F - the edge
102 * \param n - the node
103 * \retval double - resulting U
105 * Auxilary function called from GetMediumNode()
107 double GetNodeU(const TopoDS_Edge& E,
108 const SMDS_MeshNode* n);
112 * Special function for search or creation medium node
114 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
115 const SMDS_MeshNode* n2,
119 * Special function for creation quadratic edge
121 SMDS_QuadraticEdge* AddQuadraticEdge(const SMDS_MeshNode* n1,
122 const SMDS_MeshNode* n2,
124 const bool force3d = true);
127 * Special function for creation quadratic triangle
129 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
130 const SMDS_MeshNode* n2,
131 const SMDS_MeshNode* n3,
133 const bool force3d = false);
136 * Special function for creation quadratic quadrangle
138 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
139 const SMDS_MeshNode* n2,
140 const SMDS_MeshNode* n3,
141 const SMDS_MeshNode* n4,
143 const bool force3d = false);
146 * Special function for creation quadratic tetraahedron
148 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
149 const SMDS_MeshNode* n2,
150 const SMDS_MeshNode* n3,
151 const SMDS_MeshNode* n4,
153 const bool force3d = true);
156 * Special function for creation quadratic pentahedron
158 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
159 const SMDS_MeshNode* n2,
160 const SMDS_MeshNode* n3,
161 const SMDS_MeshNode* n4,
162 const SMDS_MeshNode* n5,
163 const SMDS_MeshNode* n6,
165 const bool force3d = true);
168 * Special function for creation quadratic hexahedron
170 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
171 const SMDS_MeshNode* n2,
172 const SMDS_MeshNode* n3,
173 const SMDS_MeshNode* n4,
174 const SMDS_MeshNode* n5,
175 const SMDS_MeshNode* n6,
176 const SMDS_MeshNode* n7,
177 const SMDS_MeshNode* n8,
179 bool force3d = true);
182 void SetKeyIsQuadratic(const bool theKey)
183 {myCreateQuadratic = theKey;};
185 void SetSubShape(const TopoDS_Shape& subShape)
186 {myShape = subShape;};
191 * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
192 * \param uv1 - UV on the seam
193 * \param uv2 - UV within a face
194 * \retval gp_Pnt2d - selected UV
196 gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
204 // Key for creation quadratic faces
205 bool myCreateQuadratic;
207 // special map for using during creation quadratic faces
208 NLinkNodeMap myNLinkNodeMap;
210 std::set< int > mySeamShapeIds;
211 double myPar1, myPar2; // bounds of a closed periodic surface
212 int myParIndex; // bounds' index (1-U, 2-V)
213 TopoDS_Shape myShape;