9bdafcbe |
1 | // Copyright (c) 2013 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _BRepMesh_IncrementalMesh_HeaderFile |
15 | #define _BRepMesh_IncrementalMesh_HeaderFile |
16 | |
17 | #include <Standard.hxx> |
ec357c5c |
18 | #include <Standard_Type.hxx> |
9bdafcbe |
19 | |
fc9b36d6 |
20 | #include <BRepMesh_FastDiscret.hxx> |
9bdafcbe |
21 | #include <TopTools_MapOfShape.hxx> |
22 | #include <TopTools_DataMapOfShapeReal.hxx> |
9bdafcbe |
23 | #include <BRepMesh_DiscretRoot.hxx> |
848fa7e3 |
24 | #include <BRepMesh.hxx> |
9bdafcbe |
25 | |
26 | #include <vector> |
27 | |
fc9b36d6 |
28 | class Poly_Triangulation; |
9bdafcbe |
29 | class TopoDS_Shape; |
30 | class TopoDS_Edge; |
31 | class TopoDS_Face; |
32 | |
fc9b36d6 |
33 | //! Builds the mesh of a shape with respect of their |
34 | //! correctly triangulated parts |
35 | class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot |
36 | { |
848fa7e3 |
37 | public: //! @name mesher API |
9bdafcbe |
38 | |
fc9b36d6 |
39 | //! Default constructor |
40 | Standard_EXPORT BRepMesh_IncrementalMesh(); |
9bdafcbe |
41 | |
fc9b36d6 |
42 | //! Destructor |
9bdafcbe |
43 | Standard_EXPORT virtual ~BRepMesh_IncrementalMesh(); |
44 | |
fc9b36d6 |
45 | //! Constructor. |
46 | //! Automatically calls method Perform. |
848fa7e3 |
47 | //! @param theShape shape to be meshed. |
48 | //! @param theLinDeflection linear deflection. |
49 | //! @param isRelative if TRUE deflection used for discretization of |
fc9b36d6 |
50 | //! each edge will be <theLinDeflection> * <size of edge>. Deflection |
51 | //! used for the faces will be the maximum deflection of their edges. |
848fa7e3 |
52 | //! @param theAngDeflection angular deflection. |
53 | //! @param isInParallel if TRUE shape will be meshed in parallel. |
fc9b36d6 |
54 | Standard_EXPORT BRepMesh_IncrementalMesh( |
55 | const TopoDS_Shape& theShape, |
56 | const Standard_Real theLinDeflection, |
e71669c6 |
57 | const Standard_Boolean isRelative = Standard_False, |
14434f3e |
58 | const Standard_Real theAngDeflection = 0.5, |
e71669c6 |
59 | const Standard_Boolean isInParallel = Standard_False, |
60 | const Standard_Boolean adaptiveMin = Standard_False); |
61 | |
62 | //! Constructor. |
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); |
fc9b36d6 |
68 | |
69 | //! Performs meshing ot the shape. |
79104795 |
70 | Standard_EXPORT virtual void Perform() Standard_OVERRIDE; |
9bdafcbe |
71 | |
848fa7e3 |
72 | public: //! @name accessing to parameters. |
fc9b36d6 |
73 | |
e71669c6 |
74 | //! Returns meshing parameters |
75 | inline const BRepMesh_FastDiscret::Parameters& Parameters() const |
fc9b36d6 |
76 | { |
e71669c6 |
77 | return myParameters; |
fc9b36d6 |
78 | } |
e71669c6 |
79 | |
80 | //! Returns modifiable meshing parameters |
81 | inline BRepMesh_FastDiscret::Parameters& ChangeParameters() |
fc9b36d6 |
82 | { |
e71669c6 |
83 | return myParameters; |
fc9b36d6 |
84 | } |
9bdafcbe |
85 | |
fc9b36d6 |
86 | //! Returns modified flag. |
87 | inline Standard_Boolean IsModified() const |
88 | { |
89 | return myModified; |
90 | } |
9bdafcbe |
91 | |
fc9b36d6 |
92 | //! Returns accumulated status flags faced during meshing. |
93 | inline Standard_Integer GetStatusFlags() const |
94 | { |
95 | return myStatus; |
96 | } |
9bdafcbe |
97 | |
f43eff9f |
98 | |
848fa7e3 |
99 | public: //! @name plugin API |
fc9b36d6 |
100 | |
101 | //! Plugin interface for the Mesh Factories. |
102 | //! Initializes meshing algorithm with the given parameters. |
848fa7e3 |
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. |
9bdafcbe |
107 | Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape& theShape, |
108 | const Standard_Real theLinDeflection, |
109 | const Standard_Real theAngDeflection, |
ceb418e1 |
110 | BRepMesh_DiscretRoot* &theAlgo); |
9bdafcbe |
111 | |
fc9b36d6 |
112 | //! Returns multi-threading usage flag set by default in |
113 | //! Discret() static method (thus applied only to Mesh Factories). |
9bdafcbe |
114 | Standard_EXPORT static Standard_Boolean IsParallelDefault(); |
115 | |
fc9b36d6 |
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); |
9bdafcbe |
119 | |
ec357c5c |
120 | DEFINE_STANDARD_RTTI(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot) |
9bdafcbe |
121 | |
122 | protected: |
123 | |
79104795 |
124 | Standard_EXPORT virtual void init() Standard_OVERRIDE; |
9bdafcbe |
125 | |
fc9b36d6 |
126 | private: |
9bdafcbe |
127 | |
fc9b36d6 |
128 | //! Builds the incremental mesh for the shape. |
129 | void update(); |
9bdafcbe |
130 | |
fc9b36d6 |
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. |
848fa7e3 |
134 | //! @param theFace face to be checked. |
fc9b36d6 |
135 | void update(const TopoDS_Face& theFace); |
136 | |
137 | //! Checks discretization of the given edge for consistency |
138 | //! with the chosen tolerance. |
848fa7e3 |
139 | //! @param theEdge edge to be checked. |
fc9b36d6 |
140 | void update(const TopoDS_Edge& theEdge); |
9bdafcbe |
141 | |
fc9b36d6 |
142 | //! Collects faces suitable for meshing. |
143 | void collectFaces(); |
144 | |
145 | //! Discretizes edges that have no associations with faces. |
146 | void discretizeFreeEdges(); |
147 | |
148 | //! Returns deflection of the given edge. |
848fa7e3 |
149 | //! @param theEdge edge which tolerance should be taken. |
fc9b36d6 |
150 | Standard_Real edgeDeflection(const TopoDS_Edge& theEdge); |
151 | |
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); |
157 | |
158 | //! Prepares the given face for meshing. |
159 | //! Nullifies triangulation of face and polygons of face's edges. |
848fa7e3 |
160 | //! @param theFace face to be checked. |
161 | //! @param isWithCheck if TRUE, checks parameters of triangulation |
fc9b36d6 |
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. |
848fa7e3 |
165 | //! @return TRUE in case if the given face should be meshed. |
fc9b36d6 |
166 | Standard_Boolean toBeMeshed(const TopoDS_Face& theFace, |
167 | const Standard_Boolean isWithCheck); |
168 | |
ceb418e1 |
169 | //! Stores mesh to the shape. |
170 | void commit(); |
171 | |
fcf15f5c |
172 | //! Stores mesh of internal edges to the face. |
173 | void commitEdges(const TopoDS_Face& theFace); |
2caff0b3 |
174 | |
175 | //! Clears internal data structures. |
176 | void clear(); |
ceb418e1 |
177 | |
fc9b36d6 |
178 | protected: |
9bdafcbe |
179 | |
4a913f21 |
180 | BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges; |
181 | Handle(BRepMesh_FastDiscret) myMesh; |
4a913f21 |
182 | TopTools_DataMapOfShapeReal myEdgeDeflection; |
e71669c6 |
183 | NCollection_Vector<TopoDS_Face> myFaces; |
184 | |
185 | BRepMesh_FastDiscret::Parameters myParameters; |
186 | |
4a913f21 |
187 | Standard_Real myMaxShapeSize; |
e71669c6 |
188 | Standard_Boolean myModified; |
4a913f21 |
189 | Standard_Integer myStatus; |
9bdafcbe |
190 | }; |
191 | |
192 | DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot) |
193 | |
9bdafcbe |
194 | #endif |