SALOME - SMESH
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 <Geom_Surface.hxx>
36 #include <TopoDS_Face.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <gp_Pnt2d.hxx>
39 
40 #include <map>
41 
42 typedef std::map<SMESH_TLink, const SMDS_MeshNode*> TLinkNodeMap;
43 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode;
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 TopoDS_Shape GetSubShapeByNode(const SMDS_MeshNode* node,
95  SMESHDS_Mesh* meshDS);
96 
103  static int WrapIndex(const int ind, const int nbNodes) {
104  if ( ind < 0 ) return nbNodes + ind % nbNodes;
105  if ( ind >= nbNodes ) return ind % nbNodes;
106  return ind;
107  }
108 
112  static int NbAncestors(const TopoDS_Shape& shape,
113  const SMESH_Mesh& mesh,
114  TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
115 
116 public:
117  // ---------- PUBLIC INSTANCE METHODS ----------
118 
119  // constructor
120  SMESH_MesherHelper(SMESH_Mesh& theMesh);
121 
122  SMESH_Mesh* GetMesh() const { return myMesh; }
123 
124  SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); }
125 
130  bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
134  void SetIsQuadratic(const bool theBuildQuadratic)
135  { myCreateQuadratic = theBuildQuadratic; }
139  bool GetIsQuadratic() const { return myCreateQuadratic; }
140 
145  void FixQuadraticElements(bool volumeOnly=true);
146 
152  void SetElementsOnShape(bool toSet) { mySetElemOnShape = toSet; }
153 
157  void SetSubShape(const int subShapeID);
158  void SetSubShape(const TopoDS_Shape& subShape);
163  int GetSubShapeID() const { return myShapeID; }
167  TopoDS_Shape GetSubShape() const { return myShape; }
168 
172  SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0);
176  SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1,
177  const SMDS_MeshNode* n2,
178  const int id = 0,
179  const bool force3d = true);
183  SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
184  const SMDS_MeshNode* n2,
185  const SMDS_MeshNode* n3,
186  const int id=0,
187  const bool force3d = false);
191  SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
192  const SMDS_MeshNode* n2,
193  const SMDS_MeshNode* n3,
194  const SMDS_MeshNode* n4,
195  const int id = 0,
196  const bool force3d = false);
200  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
201  const SMDS_MeshNode* n2,
202  const SMDS_MeshNode* n3,
203  const SMDS_MeshNode* n4,
204  const int id = 0,
205  const bool force3d = true);
209  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
210  const SMDS_MeshNode* n2,
211  const SMDS_MeshNode* n3,
212  const SMDS_MeshNode* n4,
213  const SMDS_MeshNode* n5,
214  const int id = 0,
215  const bool force3d = true);
219  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
220  const SMDS_MeshNode* n2,
221  const SMDS_MeshNode* n3,
222  const SMDS_MeshNode* n4,
223  const SMDS_MeshNode* n5,
224  const SMDS_MeshNode* n6,
225  const int id = 0,
226  const bool force3d = true);
230  SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
231  const SMDS_MeshNode* n2,
232  const SMDS_MeshNode* n3,
233  const SMDS_MeshNode* n4,
234  const SMDS_MeshNode* n5,
235  const SMDS_MeshNode* n6,
236  const SMDS_MeshNode* n7,
237  const SMDS_MeshNode* n8,
238  const int id = 0,
239  bool force3d = true);
243  double GetNodeU(const TopoDS_Edge& theEdge,
244  const SMDS_MeshNode* theNode,
245  bool* check=0);
250  gp_XY GetNodeUV(const TopoDS_Face& F,
251  const SMDS_MeshNode* n,
252  const SMDS_MeshNode* inFaceNode=0,
253  bool* check=0) const;
258  bool CheckNodeUV(const TopoDS_Face& F,
259  const SMDS_MeshNode* n,
260  gp_XY& uv,
261  const double tol) const;
265  static gp_XY GetMiddleUV(const Handle(Geom_Surface)& surface,
266  const gp_XY& uv1,
267  const gp_XY& uv2);
275  bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const;
276 
284  bool IsDegenShape(const int subShape) const
285  { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
294  bool IsSeamShape(const int subShape) const
295  { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
304  bool IsSeamShape(const TopoDS_Shape& subShape) const
305  { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); }
310  bool IsRealSeam(const int subShape) const
311  { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
316  bool IsRealSeam(const TopoDS_Shape& subShape) const
317  { return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); }
323  bool HasSeam() const { return !mySeamShapeIds.empty(); }
328  int GetPeriodicIndex() const { return myParIndex; }
332  double GetOtherParam(const double param) const;
333 
337  const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
338  const SMDS_MeshNode* n2,
339  const bool force3d);
343  void AddTLinkNode(const SMDS_MeshNode* n1,
344  const SMDS_MeshNode* n2,
345  const SMDS_MeshNode* n12);
349  void AddTLinkNodeMap(const TLinkNodeMap& aMap)
350  { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
351 
355  const TLinkNodeMap& GetTLinkNodeMap() const { return myTLinkNodeMap; }
356 
362  enum MType{ LINEAR, QUADRATIC, COMP };
363  MType IsQuadraticMesh();
364 
365 protected:
366 
373  gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
374 
375  private:
376 
377  // Forbiden copy constructor
379 
380  // special map for using during creation of quadratic elements
381  TLinkNodeMap myTLinkNodeMap;
382 
383  std::set< int > myDegenShapeIds;
384  std::set< int > mySeamShapeIds;
385  double myPar1, myPar2; // bounds of a closed periodic surface
386  int myParIndex; // bounds' index (1-U, 2-V)
387 
388  TopoDS_Shape myShape;
391 
392  // to create quadratic elements
395  std::set< int > myOkNodePosShapes;
396 
397 };
398 
399 
400 #endif
SMESH_MesherHelper
Definition: SMESH_MesherHelper.hxx:57
SMESH_MesherHelper::AddTLinkNodeMap
void AddTLinkNodeMap(const TLinkNodeMap &aMap)
Auxilary function for filling myTLinkNodeMap.
Definition: SMESH_MesherHelper.hxx:349
SMESH_MesherHelper::myCreateQuadratic
bool myCreateQuadratic
Definition: SMESH_MesherHelper.hxx:393
SMESH_MesherHelper::IsSeamShape
bool IsSeamShape(const TopoDS_Shape &subShape) const
Check if shape is a seam edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:304
SMESH_MeshEditor.hxx
SMDS_QuadraticEdge.hxx
SMDS_MeshVolume
Definition: SMDS_MeshVolume.hxx:33
SMDSAbs_All
Definition: SMDSAbs_ElementType.hxx:34
SMESH_MesherHelper::myShapeID
int myShapeID
Definition: SMESH_MesherHelper.hxx:390
SMESH_MesherHelper::myDegenShapeIds
std::set< int > myDegenShapeIds
Definition: SMESH_MesherHelper.hxx:383
SMESH_MesherHelper::GetSubShapeID
int GetSubShapeID() const
Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape()
Definition: SMESH_MesherHelper.hxx:163
TLinkNodeMap
std::map< SMESH_TLink, const SMDS_MeshNode * > TLinkNodeMap
Definition: SMESH_MesherHelper.hxx:42
SMDS_MeshEdge
Definition: SMDS_MeshEdge.hxx:34
SMESH_MesherHelper::GetMeshDS
SMESHDS_Mesh * GetMeshDS() const
Definition: SMESH_MesherHelper.hxx:124
SMESH_MesherHelper::GetSubShape
TopoDS_Shape GetSubShape() const
Return the shape set by IsQuadraticSubMesh() or SetSubShape()
Definition: SMESH_MesherHelper.hxx:167
ItTLinkNode
std::map< SMESH_TLink, const SMDS_MeshNode * >::iterator ItTLinkNode
Definition: SMESH_MesherHelper.hxx:43
SMESH_MesherHelper::myOkNodePosShapes
std::set< int > myOkNodePosShapes
Definition: SMESH_MesherHelper.hxx:395
SMDS_MeshNode.hxx
SMESH_MesherHelper::HasSeam
bool HasSeam() const
Check if the shape set through IsQuadraticSubMesh() or SetSubShape() has a seam edge.
Definition: SMESH_MesherHelper.hxx:323
SMESHDS_Mesh
Definition: SMESHDS_Mesh.hxx:59
SMESH_MesherHelper::IsDegenShape
bool IsDegenShape(const int subShape) const
Check if shape is a degenerated edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:284
TNodeColumn
std::vector< const SMDS_MeshNode * > TNodeColumn
It helps meshers to add elements.
Definition: SMESH_MesherHelper.hxx:54
SMESH_MesherHelper::QUADRATIC
Definition: SMESH_MesherHelper.hxx:362
SMESH_MesherHelper::IsRealSeam
bool IsRealSeam(const int subShape) const
Return true if an edge or a vertex encounters twice in face wire.
Definition: SMESH_MesherHelper.hxx:310
SMESH_MesherHelper::GetTLinkNodeMap
const TLinkNodeMap & GetTLinkNodeMap() const
Returns myTLinkNodeMap.
Definition: SMESH_MesherHelper.hxx:355
SMESH_MesherHelper::myShape
TopoDS_Shape myShape
Definition: SMESH_MesherHelper.hxx:388
SMESH_MesherHelper::mySeamShapeIds
std::set< int > mySeamShapeIds
Definition: SMESH_MesherHelper.hxx:384
SMESH_MesherHelper::IsRealSeam
bool IsRealSeam(const TopoDS_Shape &subShape) const
Return true if an edge or a vertex encounters twice in face wire.
Definition: SMESH_MesherHelper.hxx:316
SMESH_MesherHelper::SMESH_MesherHelper
SMESH_MesherHelper(const SMESH_MesherHelper &theOther)
Definition: SMESH_MesherHelper.hxx:378
SMESH_MesherHelper::SetIsQuadratic
void SetIsQuadratic(const bool theBuildQuadratic)
Set order of elements to create without calling IsQuadraticSubMesh()
Definition: SMESH_MesherHelper.hxx:134
SMESH_SMESH.hxx
SMESH_MesherHelper::MType
MType
Check mesh without geometry for: if all elements on this shape are quadratic, quadratic elements will...
Definition: SMESH_MesherHelper.hxx:362
SMESH_Mesh
Definition: SMESH_Mesh.hxx:54
SMESH_MesherHelper::GetIsQuadratic
bool GetIsQuadratic() const
Return myCreateQuadratic flag.
Definition: SMESH_MesherHelper.hxx:139
SMESH_MesherHelper::GetMesh
SMESH_Mesh * GetMesh() const
Definition: SMESH_MesherHelper.hxx:122
SMDSAbs_ElementType
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:32
SMESH_MesherHelper::myMesh
SMESH_Mesh * myMesh
Definition: SMESH_MesherHelper.hxx:389
SMESH_MesherHelper::WrapIndex
static int WrapIndex(const int ind, const int nbNodes)
Return a valid node index, fixing the given one if necessary.
Definition: SMESH_MesherHelper.hxx:103
SMESH_MesherHelper::SetElementsOnShape
void SetElementsOnShape(bool toSet)
To set created elements on the shape set by IsQuadraticSubMesh() or the next methods....
Definition: SMESH_MesherHelper.hxx:152
SMDS_MeshNode
Definition: SMDS_MeshNode.hxx:35
SMESH_MesherHelper::IsSeamShape
bool IsSeamShape(const int subShape) const
Check if shape is a seam edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:294
SMESH_MesherHelper::GetPeriodicIndex
int GetPeriodicIndex() const
Return index of periodic parametric direction of a closed face.
Definition: SMESH_MesherHelper.hxx:328
TParam2ColumnMap
std::map< double, TNodeColumn > TParam2ColumnMap
Definition: SMESH_MesherHelper.hxx:55
SMESH_MesherHelper::myParIndex
int myParIndex
Definition: SMESH_MesherHelper.hxx:386
SMESH_MesherHelper::mySetElemOnShape
bool mySetElemOnShape
Definition: SMESH_MesherHelper.hxx:394
SMDS_MeshFace
Definition: SMDS_MeshFace.hxx:33
SMESH_MesherHelper::myPar2
double myPar2
Definition: SMESH_MesherHelper.hxx:385
SMESH_EXPORT
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:36