SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SMESH_MesherHelper.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File: SMESH_MesherHelper.hxx
23 // Created: 15.02.06 14:48:09
24 // Author: Sergey KUUL
25 //
26 #ifndef SMESH_MesherHelper_HeaderFile
27 #define SMESH_MesherHelper_HeaderFile
28 
29 #include "SMESH_SMESH.hxx"
30 
31 #include "SMESH_MeshEditor.hxx" // needed for many meshers
32 #include <SMDS_MeshNode.hxx>
33 #include <SMDS_QuadraticEdge.hxx>
34 
35 #include <TopoDS_Face.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <gp_Pnt2d.hxx>
38 
39 #include <map>
40 
41 typedef std::pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
42 typedef std::map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
43 typedef std::map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
44 
54 typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
55 typedef std::map< double, TNodeColumn > TParam2ColumnMap;
56 
58 {
59 public:
60  // ---------- PUBLIC UTILITIES ----------
61 
68  static bool IsMedium(const SMDS_MeshNode* node,
69  const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
70 
84  static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
85  const TopoDS_Face& theFace,
86  const TopoDS_Edge& theBaseEdge,
87  SMESHDS_Mesh* theMesh);
94  static const TopoDS_Shape& GetSubShapeByNode(const SMDS_MeshNode* node,
95  SMESHDS_Mesh* meshDS)
96  { return meshDS->IndexToShape( node->GetPosition()->GetShapeId() ); }
97 
104  static int WrapIndex(const int ind, const int nbNodes) {
105  if ( ind < 0 ) return nbNodes + ind % nbNodes;
106  if ( ind >= nbNodes ) return ind % nbNodes;
107  return ind;
108  }
109 
113  static int NbAncestors(const TopoDS_Shape& shape,
114  const SMESH_Mesh& mesh,
115  TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
116 
117 public:
118  // ---------- PUBLIC INSTANCE METHODS ----------
119 
120  // constructor
121  SMESH_MesherHelper(SMESH_Mesh& theMesh);
122 
123  SMESH_Mesh* GetMesh() const { return myMesh; }
124 
125  SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); }
126 
131  bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
135  void SetIsQuadratic(const bool theBuildQuadratic)
136  { myCreateQuadratic = theBuildQuadratic; }
140  bool GetIsQuadratic() const { return myCreateQuadratic; }
141 
147  void SetElementsOnShape(bool toSet) { mySetElemOnShape = toSet; }
148 
152  void SetSubShape(const int subShapeID);
153  void SetSubShape(const TopoDS_Shape& subShape);
158  int GetSubShapeID() const { return myShapeID; }
162  TopoDS_Shape GetSubShape() const { return myShape; }
163 
167  SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0);
171  SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1,
172  const SMDS_MeshNode* n2,
173  const int id = 0,
174  const bool force3d = true);
178  SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
179  const SMDS_MeshNode* n2,
180  const SMDS_MeshNode* n3,
181  const int id=0,
182  const bool force3d = false);
186  SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
187  const SMDS_MeshNode* n2,
188  const SMDS_MeshNode* n3,
189  const SMDS_MeshNode* n4,
190  const int id = 0,
191  const bool force3d = false);
195  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
196  const SMDS_MeshNode* n2,
197  const SMDS_MeshNode* n3,
198  const SMDS_MeshNode* n4,
199  const int id = 0,
200  const bool force3d = true);
204  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
205  const SMDS_MeshNode* n2,
206  const SMDS_MeshNode* n3,
207  const SMDS_MeshNode* n4,
208  const SMDS_MeshNode* n5,
209  const int id = 0,
210  const bool force3d = true);
214  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
215  const SMDS_MeshNode* n2,
216  const SMDS_MeshNode* n3,
217  const SMDS_MeshNode* n4,
218  const SMDS_MeshNode* n5,
219  const SMDS_MeshNode* n6,
220  const int id = 0,
221  const bool force3d = true);
225  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
226  const SMDS_MeshNode* n2,
227  const SMDS_MeshNode* n3,
228  const SMDS_MeshNode* n4,
229  const SMDS_MeshNode* n5,
230  const SMDS_MeshNode* n6,
231  const SMDS_MeshNode* n7,
232  const SMDS_MeshNode* n8,
233  const int id = 0,
234  bool force3d = true);
238  double GetNodeU(const TopoDS_Edge& theEdge,
239  const SMDS_MeshNode* theNode);
244  gp_XY GetNodeUV(const TopoDS_Face& F,
245  const SMDS_MeshNode* n,
246  const SMDS_MeshNode* inFaceNode=0) const;
254  bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const;
255 
263  bool IsDegenShape(const int subShape) const
264  { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
273  bool IsSeamShape(const int subShape) const
274  { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
283  bool IsSeamShape(const TopoDS_Shape& subShape) const
284  { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); }
289  bool IsRealSeam(const int subShape) const
290  { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
295  bool IsRealSeam(const TopoDS_Shape& subShape) const
296  { return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); }
302  bool HasSeam() const { return !mySeamShapeIds.empty(); }
307  int GetPeriodicIndex() const { return myParIndex; }
311  double GetOtherParam(const double param) const;
312 
316  const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
317  const SMDS_MeshNode* n2,
318  const bool force3d);
322  void AddNLinkNode(const SMDS_MeshNode* n1,
323  const SMDS_MeshNode* n2,
324  const SMDS_MeshNode* n12);
328  void AddNLinkNodeMap(const NLinkNodeMap& aMap)
329  { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
330 
334  const NLinkNodeMap& GetNLinkNodeMap() const { return myNLinkNodeMap; }
335 
341  enum MType{ LINEAR, QUADRATIC, COMP };
342  MType IsQuadraticMesh();
343 
344 protected:
345 
352  gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
353 
354  private:
355 
356  // Forbiden copy constructor
358 
359  // special map for using during creation of quadratic elements
360  NLinkNodeMap myNLinkNodeMap;
361 
362  std::set< int > myDegenShapeIds;
363  std::set< int > mySeamShapeIds;
364  double myPar1, myPar2; // bounds of a closed periodic surface
365  int myParIndex; // bounds' index (1-U, 2-V)
366 
370 
371  // to create quadratic elements
374 
375 };
376 
377 
378 #endif
void SetIsQuadratic(const bool theBuildQuadratic)
Set order of elements to create without calling IsQuadraticSubMesh()
const SMDS_PositionPtr & GetPosition() const
bool IsRealSeam(const TopoDS_Shape &subShape) const
Return true if an edge or a vertex encounters twice in face wire.
static const TopoDS_Shape & GetSubShapeByNode(const SMDS_MeshNode *node, SMESHDS_Mesh *meshDS)
Return support shape of a node.
std::set< int > myDegenShapeIds
std::set< int > mySeamShapeIds
const TopoDS_Shape & IndexToShape(int ShapeIndex) const
MType
Check mesh without geometry for: if all elements on this shape are quadratic, quadratic elements will...
bool IsSeamShape(const TopoDS_Shape &subShape) const
Check if shape is a seam edge or it's vertex.
int GetSubShapeID() const
Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape()
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
SMESH_Mesh * GetMesh() const
TopoDS_Shape GetSubShape() const
Return the shape set by IsQuadraticSubMesh() or SetSubShape()
const NLinkNodeMap & GetNLinkNodeMap() const
Returns myNLinkNodeMap.
SMESHDS_Mesh * GetMeshDS() const
void SetElementsOnShape(bool toSet)
To set created elements on the shape set by IsQuadraticSubMesh() or the next methods. By defaul elements are set on the shape if a mesh has no shape to be meshed.
std::map< double, TNodeColumn > TParam2ColumnMap
void AddNLinkNodeMap(const NLinkNodeMap &aMap)
Auxilary function for filling myNLinkNodeMap.
static int WrapIndex(const int ind, const int nbNodes)
Return a valid node index, fixing the given one if necessary.
SMESH_MesherHelper(const SMESH_MesherHelper &theOther)
bool IsDegenShape(const int subShape) const
Check if shape is a degenerated edge or it's vertex.
bool GetIsQuadratic() const
Return myCreateQuadratic flag.
std::map< NLink, const SMDS_MeshNode * >::iterator ItNLinkNode
std::map< NLink, const SMDS_MeshNode * > NLinkNodeMap
bool IsSeamShape(const int subShape) const
Check if shape is a seam edge or it's vertex.
std::pair< const SMDS_MeshNode *, const SMDS_MeshNode * > NLink
bool IsRealSeam(const int subShape) const
Return true if an edge or a vertex encounters twice in face wire.
int GetPeriodicIndex() const
Return index of periodic parametric direction of a closed face.
bool HasSeam() const
Check if the shape set through IsQuadraticSubMesh() or SetSubShape() has a seam edge.
std::vector< const SMDS_MeshNode * > TNodeColumn
It helps meshers to add elements.
#define SMESH_EXPORT