0030008: BRepMesh does not respect angular deflection in internal area of bspline...
[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.DeflectionInterior < Precision::Confusion())
89     {
90       myParameters.DeflectionInterior = myParameters.Deflection;
91     }
92
93     if (myParameters.MinSize < Precision::Confusion())
94     {
95       myParameters.MinSize =
96         Max(IMeshTools_Parameters::RelMinSize() * Min(myParameters.Deflection,
97                                                       myParameters.DeflectionInterior),
98             Precision::Confusion());
99     }
100
101     if (myParameters.AngleInterior < Precision::Angular())
102     {
103       myParameters.AngleInterior = 2.0 * myParameters.Angle;
104     }
105   }
106
107 public: //! @name plugin API
108
109   //! Plugin interface for the Mesh Factories.
110   //! Initializes meshing algorithm with the given parameters.
111   //! @param theShape shape to be meshed.
112   //! @param theLinDeflection linear deflection.
113   //! @param theAngDeflection angular deflection.
114   //! @param[out] theAlgo pointer to initialized algorithm.
115   Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape&    theShape,
116                                                   const Standard_Real    theLinDeflection,
117                                                   const Standard_Real    theAngDeflection,
118                                                   BRepMesh_DiscretRoot* &theAlgo);
119   
120   //! Returns multi-threading usage flag set by default in 
121   //! Discret() static method (thus applied only to Mesh Factories).
122   Standard_EXPORT static Standard_Boolean IsParallelDefault();
123   
124   //! Setup multi-threading usage flag set by default in 
125   //! Discret() static method (thus applied only to Mesh Factories).
126   Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel);
127
128   DEFINE_STANDARD_RTTI_INLINE(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
129
130 protected:
131
132   IMeshTools_Parameters myParameters;
133   Standard_Boolean      myModified;
134   Standard_Integer      myStatus;
135 };
136
137 #endif