Version: 9.12.0
SMESH_Delaunay.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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, or (at your option) any later version.
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_Delaunay.hxx
23 // Created : Wed Apr 19 15:42:54 2017
24 // Author : Edward AGAPOV (eap)
25 
26 
27 #ifndef __SMESH_Delaunay_HXX__
28 #define __SMESH_Delaunay_HXX__
29 
30 #include "SMESH_TypeDefs.hxx"
31 
32 #include <TopoDS_Face.hxx>
33 #include <BRepMesh_DataStructureOfDelaun.hxx>
34 
46 {
47  public:
48 
49  // construct a Delaunay triangulation of given boundary nodes
50  SMESH_Delaunay(const std::vector< const UVPtStructVec* > & boundaryNodes,
51  const TopoDS_Face& face,
52  const int faceID);
53 
54  virtual ~SMESH_Delaunay() {}
55 
56  // prepare to the exploration of nodes
57  void InitTraversal(const int nbNodesToVisit = -1);
58 
59  // return a node with its Barycentric Coordinates within the triangle
60  // defined by its node indices (zero based)
61  const SMDS_MeshNode* NextNode( double bc[3], int triaNodes[3] );
62 
63  // return nb of nodes returned by NextNode()
64  size_t NbVisitedNodes() const { return _nbVisitedNodes; }
65 
66 
67  // find a triangle containing an UV, starting from a given triangle;
68  // return barycentric coordinates of the UV and the found triangle (indices are zero based).
69  const BRepMesh_Triangle* FindTriangle( const gp_XY& uv,
70  const BRepMesh_Triangle* bmTria,
71  double bc[3],
72  int triaNodes[3]);
73 
74  // return any Delaunay triangle neighboring a given boundary node (zero based)
75  const BRepMesh_Triangle* GetTriangleNear( int iBndNode );
76 
77  // return source boundary nodes
78  const std::vector< const SMDS_MeshNode* >& GetBndNodes() const { return _bndNodes; }
79 
80  // return UV of the i-th source boundary node (zero based)
81  gp_XY GetBndUV(const int iNode) const;
82 
83  // return scale factor to convert real UV to/from UV used for Delaunay meshing:
84  // delaunay_UV = real_UV * scale
85  const gp_XY& GetScale() const { return _scale; }
86 
87  void ToPython() const;
88 
89  Handle(BRepMesh_DataStructureOfDelaun) GetDS() { return _triaDS; }
90 
91  protected:
92 
93  // container of a node and a triangle serving as a start while searching a
94  // triangle including the node UV
95  typedef std::list< std::pair< const SMDS_MeshNode*, const BRepMesh_Triangle* > > TNodeTriaList;
96 
97  // return UV of a node on the face
98  virtual gp_XY getNodeUV( const TopoDS_Face& face, const SMDS_MeshNode* node ) const = 0;
99 
100  // add non-marked nodes surrounding a given one to a queue
101  static void addCloseNodes( const SMDS_MeshNode* node,
102  const BRepMesh_Triangle* bmTria,
103  const int faceID,
104  TNodeTriaList & noTriQueue );
105 
106  const TopoDS_Face& _face;
107  int _faceID;
108  std::vector< const SMDS_MeshNode* > _bndNodes;
109  gp_XY _scale;
110  Handle(BRepMesh_DataStructureOfDelaun) _triaDS;
111  size_t _nbNodesToVisit, _nbVisitedNodes, _iBndNode;
113 
114 };
115 
116 #endif
#define SMESHUtils_EXPORT
Definition: SMESH_Utils.hxx:37
Definition: SMDS_MeshNode.hxx:36
Create a Delaunay triangulation of nodes on a face boundary and provide exploration of nodes shared b...
Definition: SMESH_Delaunay.hxx:46
Handle(BRepMesh_DataStructureOfDelaun) _triaDS
size_t _iBndNode
Definition: SMESH_Delaunay.hxx:111
virtual ~SMESH_Delaunay()
Definition: SMESH_Delaunay.hxx:54
const std::vector< const SMDS_MeshNode * > & GetBndNodes() const
Definition: SMESH_Delaunay.hxx:78
const TopoDS_Face & _face
Definition: SMESH_Delaunay.hxx:106
std::vector< const SMDS_MeshNode * > _bndNodes
Definition: SMESH_Delaunay.hxx:108
std::list< std::pair< const SMDS_MeshNode *, const BRepMesh_Triangle * > > TNodeTriaList
Definition: SMESH_Delaunay.hxx:95
size_t NbVisitedNodes() const
Definition: SMESH_Delaunay.hxx:64
const gp_XY & GetScale() const
Definition: SMESH_Delaunay.hxx:85
Handle(BRepMesh_DataStructureOfDelaun) GetDS()
Definition: SMESH_Delaunay.hxx:89
int _faceID
Definition: SMESH_Delaunay.hxx:107
virtual gp_XY getNodeUV(const TopoDS_Face &face, const SMDS_MeshNode *node) const =0
TNodeTriaList _noTriQueue
Definition: SMESH_Delaunay.hxx:112
gp_XY _scale
Definition: SMESH_Delaunay.hxx:109