1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 // File: SMESH_MesherHelper.hxx
21 // Created: 15.02.06 14:48:09
22 // Author: Sergey KUUL
23 // Copyright: Open CASCADE 2006
26 #ifndef SMESH_MesherHelper_HeaderFile
27 #define SMESH_MesherHelper_HeaderFile
29 #include <SMESH_Mesh.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <SMDS_MeshNode.hxx>
32 #include <TopoDS_Face.hxx>
33 #include <gp_Pnt2d.hxx>
34 #include <SMDS_QuadraticEdge.hxx>
38 typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
39 typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
40 typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
43 * \brief It helps meshers to add elements
45 * It allow meshers not to care about creation of medium nodes
46 * when filling a quadratic mesh. Helper does it itself.
47 * It defines degree of elements to create when IsQuadraticSubMesh()
51 class SMESH_MesherHelper
54 // ---------- PUBLIC METHODS ----------
57 SMESH_MesherHelper(SMESH_Mesh& theMesh)
58 { myMesh=(void *)&theMesh; myCreateQuadratic = false; }
60 SMESH_Mesh* GetMesh() const
61 { return (SMESH_Mesh*)myMesh; }
64 //Standard_EXPORT SMESH_MesherHelper (const SMESH_MesherHelper& theOther);
67 //Standard_EXPORT virtual ~SMESH_MesherHelper ();
70 * Check submesh for given shape
71 * Check if all elements on this shape
72 * are quadratic, if yes => set true to myCreateQuadratic
73 * (default value is false). Also fill myNLinkNodeMap
74 * Returns myCreateQuadratic
76 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
79 * \brief Returns true if given node is medium
80 * \param n - node to check
81 * \param typeToCheck - type of elements containing the node to ask about node status
82 * \retval bool - check result
84 static bool IsMedium(const SMDS_MeshNode* node,
85 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
88 * Auxilary function for filling myNLinkNodeMap
90 void AddNLinkNode(const SMDS_MeshNode* n1,
91 const SMDS_MeshNode* n2,
92 const SMDS_MeshNode* n12);
95 * Auxilary function for filling myNLinkNodeMap
97 void AddNLinkNodeMap(const NLinkNodeMap& aMap)
98 { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
101 * Returns myNLinkNodeMap
103 const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; }
106 * \brief Return node UV on face
107 * \param F - the face
108 * \param n - the node
109 * \param n2 - a medium node will be placed between n and n2
110 * \retval gp_XY - resulting UV
112 * Auxilary function called form GetMediumNode()
114 gp_XY GetNodeUV(const TopoDS_Face& F,
115 const SMDS_MeshNode* n,
116 const SMDS_MeshNode* n2=0);
119 * \brief Return U on edge
120 * \param F - the edge
121 * \param n - the node
122 * \retval double - resulting U
124 * Auxilary function called from GetMediumNode()
126 double GetNodeU(const TopoDS_Edge& E,
127 const SMDS_MeshNode* n);
131 * Special function for search or creation medium node
133 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
134 const SMDS_MeshNode* n2,
138 * Special function for creation quadratic edge
140 SMDS_QuadraticEdge* AddQuadraticEdge(const SMDS_MeshNode* n1,
141 const SMDS_MeshNode* n2,
143 const bool force3d = true);
146 * Special function for creation quadratic triangle
148 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
149 const SMDS_MeshNode* n2,
150 const SMDS_MeshNode* n3,
152 const bool force3d = false);
155 * Special function for creation quadratic quadrangle
157 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
158 const SMDS_MeshNode* n2,
159 const SMDS_MeshNode* n3,
160 const SMDS_MeshNode* n4,
162 const bool force3d = false);
165 * Special function for creation quadratic tetraahedron
167 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
168 const SMDS_MeshNode* n2,
169 const SMDS_MeshNode* n3,
170 const SMDS_MeshNode* n4,
172 const bool force3d = true);
175 * Special function for creation quadratic pentahedron
177 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
178 const SMDS_MeshNode* n2,
179 const SMDS_MeshNode* n3,
180 const SMDS_MeshNode* n4,
181 const SMDS_MeshNode* n5,
182 const SMDS_MeshNode* n6,
184 const bool force3d = true);
187 * Special function for creation quadratic hexahedron
189 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
190 const SMDS_MeshNode* n2,
191 const SMDS_MeshNode* n3,
192 const SMDS_MeshNode* n4,
193 const SMDS_MeshNode* n5,
194 const SMDS_MeshNode* n6,
195 const SMDS_MeshNode* n7,
196 const SMDS_MeshNode* n8,
198 bool force3d = true);
201 void SetKeyIsQuadratic(const bool theKey)
202 {myCreateQuadratic = theKey;};
204 void SetSubShape(const TopoDS_Shape& subShape);
209 * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
210 * \param uv1 - UV on the seam
211 * \param uv2 - UV within a face
212 * \retval gp_Pnt2d - selected UV
214 gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
222 // Key for creation quadratic faces
223 bool myCreateQuadratic;
225 // special map for using during creation quadratic faces
226 NLinkNodeMap myNLinkNodeMap;
228 std::set< int > mySeamShapeIds;
229 double myPar1, myPar2; // bounds of a closed periodic surface
230 int myParIndex; // bounds' index (1-U, 2-V)
231 TopoDS_Shape myShape;