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_IncrementalMesh_HeaderFile
15 #define _BRepMesh_IncrementalMesh_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_Type.hxx>
20 #include <BRepMesh_FastDiscret.hxx>
21 #include <TopTools_MapOfShape.hxx>
22 #include <TopTools_DataMapOfShapeReal.hxx>
23 #include <BRepMesh_DiscretRoot.hxx>
24 #include <BRepMesh.hxx>
28 class Poly_Triangulation;
33 //! Builds the mesh of a shape with respect of their
34 //! correctly triangulated parts
35 class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot
37 public: //! @name mesher API
39 //! Default constructor
40 Standard_EXPORT BRepMesh_IncrementalMesh();
43 Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();
46 //! Automatically calls method Perform.
47 //! @param theShape shape to be meshed.
48 //! @param theLinDeflection linear deflection.
49 //! @param isRelative if TRUE deflection used for discretization of
50 //! each edge will be <theLinDeflection> * <size of edge>. Deflection
51 //! used for the faces will be the maximum deflection of their edges.
52 //! @param theAngDeflection angular deflection.
53 //! @param isInParallel if TRUE shape will be meshed in parallel.
54 Standard_EXPORT BRepMesh_IncrementalMesh(
55 const TopoDS_Shape& theShape,
56 const Standard_Real theLinDeflection,
57 const Standard_Boolean isRelative = Standard_False,
58 const Standard_Real theAngDeflection = 0.5,
59 const Standard_Boolean isInParallel = Standard_False,
60 const Standard_Boolean adaptiveMin = Standard_False);
63 //! Automatically calls method Perform.
64 //! @param theShape shape to be meshed.
65 //! @param theParameters - parameters of meshing
66 Standard_EXPORT BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
67 const BRepMesh_FastDiscret::Parameters& theParameters);
69 //! Performs meshing ot the shape.
70 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
72 public: //! @name accessing to parameters.
74 //! Returns meshing parameters
75 inline const BRepMesh_FastDiscret::Parameters& Parameters() const
80 //! Returns modifiable meshing parameters
81 inline BRepMesh_FastDiscret::Parameters& ChangeParameters()
86 //! Returns modified flag.
87 inline Standard_Boolean IsModified() const
92 //! Returns accumulated status flags faced during meshing.
93 inline Standard_Integer GetStatusFlags() const
99 public: //! @name plugin API
101 //! Plugin interface for the Mesh Factories.
102 //! Initializes meshing algorithm with the given parameters.
103 //! @param theShape shape to be meshed.
104 //! @param theLinDeflection linear deflection.
105 //! @param theAngDeflection angular deflection.
106 //! @param[out] theAlgo pointer to initialized algorithm.
107 Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape& theShape,
108 const Standard_Real theLinDeflection,
109 const Standard_Real theAngDeflection,
110 BRepMesh_DiscretRoot* &theAlgo);
112 //! Returns multi-threading usage flag set by default in
113 //! Discret() static method (thus applied only to Mesh Factories).
114 Standard_EXPORT static Standard_Boolean IsParallelDefault();
116 //! Setup multi-threading usage flag set by default in
117 //! Discret() static method (thus applied only to Mesh Factories).
118 Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel);
120 DEFINE_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
124 Standard_EXPORT virtual void init() Standard_OVERRIDE;
128 //! Builds the incremental mesh for the shape.
131 //! Checks triangulation of the given face for consistency
132 //! with the chosen tolerance. If some edge of face has no
133 //! discrete representation triangulation will be calculated.
134 //! @param theFace face to be checked.
135 void update(const TopoDS_Face& theFace);
137 //! Checks discretization of the given edge for consistency
138 //! with the chosen tolerance.
139 //! @param theEdge edge to be checked.
140 void update(const TopoDS_Edge& theEdge);
142 //! Collects faces suitable for meshing.
145 //! Discretizes edges that have no associations with faces.
146 void discretizeFreeEdges();
148 //! Returns deflection of the given edge.
149 //! @param theEdge edge which tolerance should be taken.
150 Standard_Real edgeDeflection(const TopoDS_Edge& theEdge);
152 //! Returns deflection of the given face.
153 //! If relative flag is set, calculates relative deflection of the face
154 //! as an average value of relative deflection regarding face's edges.
155 //! Returns value of deflection set by user elsewhere.
156 Standard_Real faceDeflection(const TopoDS_Face& theFace);
158 //! Prepares the given face for meshing.
159 //! Nullifies triangulation of face and polygons of face's edges.
160 //! @param theFace face to be checked.
161 //! @param isWithCheck if TRUE, checks parameters of triangulation
162 //! existing in face. If its deflection satisfies the given value and
163 //! each edge of face has polygon corresponded to this triangulation,
164 //! method return FALSE.
165 //! @return TRUE in case if the given face should be meshed.
166 Standard_Boolean toBeMeshed(const TopoDS_Face& theFace,
167 const Standard_Boolean isWithCheck);
169 //! Stores mesh to the shape.
172 //! Stores mesh of internal edges to the face.
173 void commitEdges(const TopoDS_Face& theFace);
175 //! Clears internal data structures.
180 BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
181 Handle(BRepMesh_FastDiscret) myMesh;
182 TopTools_DataMapOfShapeReal myEdgeDeflection;
183 NCollection_Vector<TopoDS_Face> myFaces;
185 BRepMesh_FastDiscret::Parameters myParameters;
187 Standard_Real myMaxShapeSize;
188 Standard_Boolean myModified;
189 Standard_Integer myStatus;
192 DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)