1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _BRepMesh_FastDiscretFace_HeaderFile
15 #define _BRepMesh_FastDiscretFace_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_DefineHandle.hxx>
19 #include <BRepMesh_FastDiscretFace.hxx>
20 #include <BRepMesh_DataStructureOfDelaun.hxx>
21 #include <BRepMesh.hxx>
22 #include <BRepMesh_FaceAttribute.hxx>
23 #include <Standard_Transient.hxx>
24 #include <TopTools_MutexForShapeProvider.hxx>
25 #include <Handle_BRepAdaptor_HSurface.hxx>
26 #include <Handle_Poly_Triangulation.hxx>
27 #include <BRepMesh_Delaun.hxx>
28 #include <BRepMesh_Triangle.hxx>
29 #include <BRepMesh_Classifier.hxx>
32 class BRepMesh_DataStructureOfDelaun;
33 class BRepMesh_FaceAttribute;
35 class TopTools_DataMapOfShapeReal;
37 class BRepAdaptor_HSurface;
39 class Poly_Triangulation;
40 class TopLoc_Location;
44 class BRepMesh_Vertex;
47 //! Algorithm to mesh a face with respect of the frontier
48 //! the deflection and by option the shared components.
49 class BRepMesh_FastDiscretFace : public Standard_Transient
53 Standard_EXPORT BRepMesh_FastDiscretFace(
54 const Standard_Real theAngle,
55 const Standard_Boolean theWithShare = Standard_True);
57 Standard_EXPORT void Add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
58 Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute);
60 DEFINE_STANDARD_RTTI(BRepMesh_FastDiscretFace)
64 void add(const TopoDS_Vertex& theVertex);
66 Standard_Real control(BRepMesh::ListOfVertex& theNewVertices,
67 BRepMesh_Delaun& theMeshBuilder,
68 const Standard_Boolean theIsFirst);
70 //! Registers the given nodes in mesh data structure and
71 //! performs refinement of existing mesh.
72 //! @param theVertices nodes to be inserted.
73 //! @param theMeshBuilder initialized tool refining mesh
74 //! in respect to inserting nodes.
75 //! @return TRUE if vertices were been inserted, FALSE elewhere.
76 Standard_Boolean addVerticesToMesh(
77 const BRepMesh::ListOfVertex& theVertices,
78 BRepMesh_Delaun& theMeshBuilder);
80 //! Calculates nodes lying on face's surface and inserts them to a mesh.
81 //! @param theNewVertices list of vertices to be extended and added to mesh.
82 //! @param theMeshBuilder initialized tool refining mesh
83 //! in respect to inserting nodes.
84 void insertInternalVertices(BRepMesh::ListOfVertex& theNewVertices,
85 BRepMesh_Delaun& theMeshBuilder);
87 //! Calculates nodes lying on spherical surface.
88 //! @param theNewVertices list of vertices to be extended and added to mesh.
89 void insertInternalVerticesSphere(BRepMesh::ListOfVertex& theNewVertices);
91 //! Calculates nodes lying on cylindrical surface.
92 //! @param theNewVertices list of vertices to be extended and added to mesh.
93 void insertInternalVerticesCylinder(BRepMesh::ListOfVertex& theNewVertices);
95 //! Calculates nodes lying on conical surface.
96 //! @param theNewVertices list of vertices to be extended and added to mesh.
97 void insertInternalVerticesCone(BRepMesh::ListOfVertex& theNewVertices);
99 //! Calculates nodes lying on toroidal surface.
100 //! @param theNewVertices list of vertices to be extended and added to mesh.
101 void insertInternalVerticesTorus(BRepMesh::ListOfVertex& theNewVertices);
103 //! Calculates nodes lying on Bezier/BSpline surface.
104 //! @param theNewVertices list of vertices to be extended and added to mesh.
105 void insertInternalVerticesBSpline(BRepMesh::ListOfVertex& theNewVertices);
107 //! Calculates nodes lying on custom-type surface.
108 //! @param theNewVertices list of vertices to be extended and added to mesh.
109 void insertInternalVerticesOther(BRepMesh::ListOfVertex& theNewVertices);
111 //! Template method trying to insert new internal vertex corresponded to
112 //! the given 2d point. Calculates 3d position analytically using the given
114 //! @param thePnt2d 2d point to be inserted to the list.
115 //! @param theAnalyticSurface analytic surface to calculate 3d point.
116 //! @param[out] theVertices list of vertices to be updated.
117 template<class AnalyticSurface>
118 void tryToInsertAnalyticVertex(const gp_Pnt2d& thePnt2d,
119 const AnalyticSurface& theAnalyticSurface,
120 BRepMesh::ListOfVertex& theVertices)
122 if (!myClassifier->Perform(thePnt2d) == TopAbs_IN)
126 ElSLib::D0(thePnt2d.X(), thePnt2d.Y(), theAnalyticSurface, aPnt);
127 insertVertex(aPnt, thePnt2d.Coord(), theVertices);
130 //! Creates new vertex with the given parameters.
131 //! @param thePnt3d 3d point corresponded to the vertex.
132 //! @param theUV UV point corresponded to the vertex.
133 //! @param[out] theVertices list of vertices to be updated.
134 void insertVertex(const gp_Pnt& thePnt3d,
136 BRepMesh::ListOfVertex& theVertices);
138 //! Stores mesh into the face (without internal edges).
139 void commitSurfaceTriangulation();
143 Standard_Real myAngle;
144 Standard_Boolean myWithShare;
145 Standard_Boolean myInternalVerticesMode;
146 BRepMesh::IMapOfReal myUParam;
147 BRepMesh::IMapOfReal myVParam;
148 Handle(NCollection_IncAllocator) myAllocator;
150 // Fast access to attributes of current face
151 Handle(BRepMesh_FaceAttribute) myAttribute;
152 Handle(BRepMesh_DataStructureOfDelaun) myStructure;
153 BRepMesh::HIMapOfInteger myVertexEdgeMap;
154 BRepMesh::HClassifier myClassifier;
155 BRepMesh::HDMapOfIntegerPnt mySurfacePoints;
158 DEFINE_STANDARD_HANDLE (BRepMesh_FastDiscretFace, Standard_Transient)