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 | |
9bdafcbe |
17 | #include <BRepMesh_DiscretRoot.hxx> |
7bd071ed |
18 | #include <IMeshTools_Parameters.hxx> |
4c04741d |
19 | #include <IMeshTools_Context.hxx> |
9bdafcbe |
20 | |
fc9b36d6 |
21 | //! Builds the mesh of a shape with respect of their |
22 | //! correctly triangulated parts |
23 | class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot |
24 | { |
848fa7e3 |
25 | public: //! @name mesher API |
9bdafcbe |
26 | |
fc9b36d6 |
27 | //! Default constructor |
28 | Standard_EXPORT BRepMesh_IncrementalMesh(); |
9bdafcbe |
29 | |
fc9b36d6 |
30 | //! Destructor |
9bdafcbe |
31 | Standard_EXPORT virtual ~BRepMesh_IncrementalMesh(); |
32 | |
fc9b36d6 |
33 | //! Constructor. |
34 | //! Automatically calls method Perform. |
848fa7e3 |
35 | //! @param theShape shape to be meshed. |
36 | //! @param theLinDeflection linear deflection. |
37 | //! @param isRelative if TRUE deflection used for discretization of |
fc9b36d6 |
38 | //! each edge will be <theLinDeflection> * <size of edge>. Deflection |
39 | //! used for the faces will be the maximum deflection of their edges. |
848fa7e3 |
40 | //! @param theAngDeflection angular deflection. |
41 | //! @param isInParallel if TRUE shape will be meshed in parallel. |
7bd071ed |
42 | Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape, |
43 | const Standard_Real theLinDeflection, |
44 | const Standard_Boolean isRelative = Standard_False, |
45 | const Standard_Real theAngDeflection = 0.5, |
46 | const Standard_Boolean isInParallel = Standard_False); |
e71669c6 |
47 | |
48 | //! Constructor. |
49 | //! Automatically calls method Perform. |
50 | //! @param theShape shape to be meshed. |
51 | //! @param theParameters - parameters of meshing |
7bd071ed |
52 | Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape, |
53 | const IMeshTools_Parameters& theParameters); |
fc9b36d6 |
54 | |
4c04741d |
55 | //! Performs meshing ot the shape. |
79104795 |
56 | Standard_EXPORT virtual void Perform() Standard_OVERRIDE; |
4c04741d |
57 | |
58 | //! Performs meshing using custom context; |
59 | Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext); |
9bdafcbe |
60 | |
848fa7e3 |
61 | public: //! @name accessing to parameters. |
fc9b36d6 |
62 | |
e71669c6 |
63 | //! Returns meshing parameters |
7bd071ed |
64 | inline const IMeshTools_Parameters& Parameters() const |
fc9b36d6 |
65 | { |
e71669c6 |
66 | return myParameters; |
fc9b36d6 |
67 | } |
e71669c6 |
68 | |
69 | //! Returns modifiable meshing parameters |
7bd071ed |
70 | inline IMeshTools_Parameters& ChangeParameters() |
fc9b36d6 |
71 | { |
e71669c6 |
72 | return myParameters; |
fc9b36d6 |
73 | } |
7bd071ed |
74 | |
fc9b36d6 |
75 | //! Returns modified flag. |
76 | inline Standard_Boolean IsModified() const |
77 | { |
78 | return myModified; |
79 | } |
9bdafcbe |
80 | |
fc9b36d6 |
81 | //! Returns accumulated status flags faced during meshing. |
82 | inline Standard_Integer GetStatusFlags() const |
83 | { |
84 | return myStatus; |
85 | } |
9bdafcbe |
86 | |
7bd071ed |
87 | private: |
88 | |
89 | //! Initializes specific parameters |
90 | inline void initParameters() |
91 | { |
46478ffe |
92 | if (myParameters.DeflectionInterior < Precision::Confusion()) |
93 | { |
94 | myParameters.DeflectionInterior = myParameters.Deflection; |
95 | } |
96 | |
7bd071ed |
97 | if (myParameters.MinSize < Precision::Confusion()) |
98 | { |
99 | myParameters.MinSize = |
46478ffe |
100 | Max(IMeshTools_Parameters::RelMinSize() * Min(myParameters.Deflection, |
101 | myParameters.DeflectionInterior), |
7bd071ed |
102 | Precision::Confusion()); |
103 | } |
46478ffe |
104 | |
105 | if (myParameters.AngleInterior < Precision::Angular()) |
106 | { |
107 | myParameters.AngleInterior = 2.0 * myParameters.Angle; |
108 | } |
7bd071ed |
109 | } |
f43eff9f |
110 | |
848fa7e3 |
111 | public: //! @name plugin API |
fc9b36d6 |
112 | |
113 | //! Plugin interface for the Mesh Factories. |
114 | //! Initializes meshing algorithm with the given parameters. |
848fa7e3 |
115 | //! @param theShape shape to be meshed. |
116 | //! @param theLinDeflection linear deflection. |
117 | //! @param theAngDeflection angular deflection. |
118 | //! @param[out] theAlgo pointer to initialized algorithm. |
9bdafcbe |
119 | Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape& theShape, |
120 | const Standard_Real theLinDeflection, |
121 | const Standard_Real theAngDeflection, |
ceb418e1 |
122 | BRepMesh_DiscretRoot* &theAlgo); |
9bdafcbe |
123 | |
fc9b36d6 |
124 | //! Returns multi-threading usage flag set by default in |
125 | //! Discret() static method (thus applied only to Mesh Factories). |
9bdafcbe |
126 | Standard_EXPORT static Standard_Boolean IsParallelDefault(); |
127 | |
fc9b36d6 |
128 | //! Setup multi-threading usage flag set by default in |
129 | //! Discret() static method (thus applied only to Mesh Factories). |
130 | Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel); |
9bdafcbe |
131 | |
7bd071ed |
132 | DEFINE_STANDARD_RTTI_INLINE(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot) |
9bdafcbe |
133 | |
134 | protected: |
135 | |
7bd071ed |
136 | IMeshTools_Parameters myParameters; |
137 | Standard_Boolean myModified; |
138 | Standard_Integer myStatus; |
9bdafcbe |
139 | }; |
140 | |
9bdafcbe |
141 | #endif |