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