1 // Copyright (C) 2007-2016 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 <BRepMesh_DataStructureOfDelaun.hxx>
35 * \brief Create a Delaunay triangulation of nodes on a face boundary
36 * and provide exploration of nodes shared by elements lying on
37 * the face. For a returned node, also return a Delaunay triangle
38 * the node lies in and its Barycentric Coordinates within the triangle.
39 * Only non-marked nodes are visited. Boundary nodes given at the construction
42 * For usage, this class needs to be subclassed to implement getNodeUV();
44 class SMESHUtils_EXPORT SMESH_Delaunay
48 // construct a Delaunay triangulation of given boundary nodes
49 SMESH_Delaunay(const std::vector< const UVPtStructVec* > & boundaryNodes,
50 const TopoDS_Face& face,
53 virtual ~SMESH_Delaunay() {}
55 // prepare to the exploration of nodes
56 void InitTraversal(const int nbNodesToVisit = -1);
58 // return a node with its Barycentric Coordinates within the triangle
59 // defined by its node indices (zero based)
60 const SMDS_MeshNode* NextNode( double bc[3], int triaNodes[3] );
62 // return nb of nodes returned by NextNode()
63 int NbVisitedNodes() const { return _nbVisitedNodes; }
66 // find a triangle containing an UV, starting from a given triangle;
67 // return barycentric coordinates of the UV and the found triangle (indices are zero based).
68 const BRepMesh_Triangle* FindTriangle( const gp_XY& uv,
69 const BRepMesh_Triangle* bmTria,
73 // return any Delaunay triangle neighboring a given boundary node (zero based)
74 const BRepMesh_Triangle* GetTriangleNear( int iBndNode );
76 // return source boundary nodes
77 const std::vector< const SMDS_MeshNode* >& GetBndNodes() const { return _bndNodes; }
79 // return UV of the i-th source boundary node (zero based)
80 gp_XY GetBndUV(const int iNode) const;
82 // return scale factor to convert real UV to/from UV used for Delauney meshing:
83 // delauney_UV = real_UV * scale
84 const gp_XY& GetScale() const { return _scale; }
86 void ToPython() const;
88 Handle(BRepMesh_DataStructureOfDelaun) GetDS() { return _triaDS; }
92 // container of a node and a triangle serving as a start while searching a
93 // triangle including the node UV
94 typedef std::list< std::pair< const SMDS_MeshNode*, const BRepMesh_Triangle* > > TNodeTriaList;
96 // return UV of a node on the face
97 virtual gp_XY getNodeUV( const TopoDS_Face& face, const SMDS_MeshNode* node ) const = 0;
99 // add non-marked nodes surrounding a given one to a queue
100 static void addCloseNodes( const SMDS_MeshNode* node,
101 const BRepMesh_Triangle* bmTria,
103 TNodeTriaList & noTriQueue );
105 const TopoDS_Face& _face;
107 std::vector< const SMDS_MeshNode* > _bndNodes;
109 Handle(BRepMesh_DataStructureOfDelaun) _triaDS;
110 size_t _nbNodesToVisit, _nbVisitedNodes, _iBndNode;
111 TNodeTriaList _noTriQueue;