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_Collections.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
54 Standard_EXPORT BRepMesh_FastDiscretFace(const Standard_Real theAngle,
55 const Standard_Boolean theWithShare = Standard_True);
57 Standard_EXPORT void Add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
59 //! Gives the triangle of <Index>. <br>
60 Standard_EXPORT const BRepMesh_Triangle& Triangle(const Standard_Integer theIndex) const;
62 DEFINE_STANDARD_RTTI(BRepMesh_FastDiscretFace)
66 void add(const TopoDS_Vertex& theVertex);
68 Standard_Real control(BRepMeshCol::ListOfVertex& theNewVertices,
69 BRepMesh_Delaun& theMeshBuilder,
70 const Standard_Boolean theIsFirst);
72 //! Registers the given nodes in mesh data structure and
73 //! performs refinement of existing mesh.
74 //! @param theVertices nodes to be inserted.
75 //! @param theMeshBuilder initialized tool refining mesh
76 //! in respect to inserting nodes.
77 //! @return TRUE if vertices were been inserted, FALSE elewhere.
78 Standard_Boolean addVerticesToMesh(
79 const BRepMeshCol::ListOfVertex& theVertices,
80 BRepMesh_Delaun& theMeshBuilder);
82 //! Calculates nodes lying on face's surface and inserts them to a mesh.
83 //! @param theNewVertices list of vertices to be extended and added to mesh.
84 //! @param theMeshBuilder initialized tool refining mesh
85 //! in respect to inserting nodes.
86 void insertInternalVertices(BRepMeshCol::ListOfVertex& theNewVertices,
87 BRepMesh_Delaun& theMeshBuilder);
89 //! Calculates nodes lying on spherical surface.
90 //! @param theNewVertices list of vertices to be extended and added to mesh.
91 void insertInternalVerticesSphere(BRepMeshCol::ListOfVertex& theNewVertices);
93 //! Calculates nodes lying on cylindrical surface.
94 //! @param theNewVertices list of vertices to be extended and added to mesh.
95 void insertInternalVerticesCylinder(BRepMeshCol::ListOfVertex& theNewVertices);
97 //! Calculates nodes lying on conical surface.
98 //! @param theNewVertices list of vertices to be extended and added to mesh.
99 void insertInternalVerticesCone(BRepMeshCol::ListOfVertex& theNewVertices);
101 //! Calculates nodes lying on toroidal surface.
102 //! @param theNewVertices list of vertices to be extended and added to mesh.
103 void insertInternalVerticesTorus(BRepMeshCol::ListOfVertex& theNewVertices);
105 //! Calculates nodes lying on Bezier/BSpline surface.
106 //! @param theNewVertices list of vertices to be extended and added to mesh.
107 void insertInternalVerticesBSpline(BRepMeshCol::ListOfVertex& theNewVertices);
109 //! Calculates nodes lying on custom-type surface.
110 //! @param theNewVertices list of vertices to be extended and added to mesh.
111 void insertInternalVerticesOther(BRepMeshCol::ListOfVertex& theNewVertices);
113 //! Template method trying to insert new internal vertex corresponded to
114 //! the given 2d point. Calculates 3d position analytically using the given
116 //! @param thePnt2d 2d point to be inserted to the list.
117 //! @param theAnalyticSurface analytic surface to calculate 3d point.
118 //! @param[out] theVertices list of vertices to be updated.
119 template<class AnalyticSurface>
120 void tryToInsertAnalyticVertex(const gp_Pnt2d& thePnt2d,
121 const AnalyticSurface& theAnalyticSurface,
122 BRepMeshCol::ListOfVertex& theVertices)
124 if (!myClassifier->Perform(thePnt2d) == TopAbs_IN)
128 ElSLib::D0(thePnt2d.X(), thePnt2d.Y(), theAnalyticSurface, aPnt);
129 insertVertex(aPnt, thePnt2d.Coord(), theVertices);
132 //! Creates new vertex with the given parameters.
133 //! @param thePnt3d 3d point corresponded to the vertex.
134 //! @param theUV UV point corresponded to the vertex.
135 //! @param[out] theVertices list of vertices to be updated.
136 void insertVertex(const gp_Pnt& thePnt3d,
138 BRepMeshCol::ListOfVertex& theVertices);
142 Standard_Real myAngle;
143 Standard_Boolean myWithShare;
144 Standard_Boolean myInternalVerticesMode;
145 BRepMeshCol::IMapOfReal myUParam;
146 BRepMeshCol::IMapOfReal myVParam;
147 BRepMeshCol::Allocator myAllocator;
149 // Fast access to attributes of current face
150 Handle(BRepMesh_FaceAttribute) myAttribute;
151 Handle(BRepMesh_DataStructureOfDelaun) myStructure;
152 BRepMeshCol::HIMapOfInteger myVertexEdgeMap;
153 BRepMeshCol::HClassifier myClassifier;
154 BRepMeshCol::HDMapOfIntegerPnt mySurfacePoints;
157 DEFINE_STANDARD_HANDLE (BRepMesh_FastDiscretFace, Standard_Transient)