1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESH_Delaunay.hxx
23 // Created : Wed Apr 19 15:42:54 2017
24 // Author : Edward AGAPOV (eap)
27 #ifndef __SMESH_Delaunay_HXX__
28 #define __SMESH_Delaunay_HXX__
30 #include "SMESH_TypeDefs.hxx"
32 #include <TopoDS_Face.hxx>
33 #include <BRepMesh_DataStructureOfDelaun.hxx>
36 * \brief Create a Delaunay triangulation of nodes on a face boundary
37 * and provide exploration of nodes shared by elements lying on
38 * the face. For a returned node, also return a Delaunay triangle
39 * the node lies in and its Barycentric Coordinates within the triangle.
40 * Only non-marked nodes are visited. Boundary nodes given at the construction
43 * For usage, this class needs to be subclassed to implement getNodeUV();
45 class SMESHUtils_EXPORT SMESH_Delaunay
49 // construct a Delaunay triangulation of given boundary nodes
50 SMESH_Delaunay(const std::vector< const UVPtStructVec* > & boundaryNodes,
51 const TopoDS_Face& face,
54 virtual ~SMESH_Delaunay() {}
56 // prepare to the exploration of nodes
57 void InitTraversal(const int nbNodesToVisit = -1);
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] );
63 // return nb of nodes returned by NextNode()
64 size_t NbVisitedNodes() const { return _nbVisitedNodes; }
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,
74 // return any Delaunay triangle neighboring a given boundary node (zero based)
75 const BRepMesh_Triangle* GetTriangleNear( int iBndNode );
77 // return source boundary nodes
78 const std::vector< const SMDS_MeshNode* >& GetBndNodes() const { return _bndNodes; }
80 // return UV of the i-th source boundary node (zero based)
81 gp_XY GetBndUV(const int iNode) const;
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; }
87 void ToPython() const;
89 Handle(BRepMesh_DataStructureOfDelaun) GetDS() { return _triaDS; }
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;
97 // return UV of a node on the face
98 virtual gp_XY getNodeUV( const TopoDS_Face& face, const SMDS_MeshNode* node ) const = 0;
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,
104 TNodeTriaList & noTriQueue );
106 const TopoDS_Face& _face;
108 std::vector< const SMDS_MeshNode* > _bndNodes;
110 Handle(BRepMesh_DataStructureOfDelaun) _triaDS;
111 size_t _nbNodesToVisit, _nbVisitedNodes, _iBndNode;
112 TNodeTriaList _noTriQueue;