0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / BRepMesh / BRepMesh_FastDiscretFace.hxx
CommitLineData
fc9b36d6 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_FastDiscretFace_HeaderFile
15#define _BRepMesh_FastDiscretFace_HeaderFile
16
17#include <Standard.hxx>
ec357c5c 18#include <Standard_Type.hxx>
fc9b36d6 19#include <BRepMesh_FastDiscretFace.hxx>
20#include <BRepMesh_DataStructureOfDelaun.hxx>
848fa7e3 21#include <BRepMesh.hxx>
fc9b36d6 22#include <BRepMesh_FaceAttribute.hxx>
23#include <Standard_Transient.hxx>
24#include <TopTools_MutexForShapeProvider.hxx>
b7c077b9 25#include <TopTools_DataMapOfShapeReal.hxx>
fc9b36d6 26#include <BRepMesh_Delaun.hxx>
27#include <BRepMesh_Triangle.hxx>
ceb418e1 28#include <BRepMesh_Classifier.hxx>
29#include <ElSLib.hxx>
fc9b36d6 30
31class BRepMesh_DataStructureOfDelaun;
32class BRepMesh_FaceAttribute;
33class TopoDS_Face;
fc9b36d6 34class TopoDS_Vertex;
35class BRepAdaptor_HSurface;
36class TopoDS_Edge;
37class Poly_Triangulation;
38class TopLoc_Location;
39class gp_XY;
40class gp_Pnt2d;
41class BRepMesh_Edge;
42class BRepMesh_Vertex;
43class gp_Pnt;
44
45//! Algorithm to mesh a face with respect of the frontier
ceb418e1 46//! the deflection and by option the shared components.
fc9b36d6 47class BRepMesh_FastDiscretFace : public Standard_Transient
48{
49public:
848fa7e3 50
a319f03f 51 //! Constructor.
52 //! @param theAngle deviation angle to be used for surface tessellation.
53 //! @param isInternalVerticesMode flag enabling/disabling internal
54 //! vertices mode.
f43eff9f 55 //! @param isControlSurfaceDeflection enables/disables adaptive
56 //! reconfiguration of mesh.
848fa7e3 57 Standard_EXPORT BRepMesh_FastDiscretFace(
a319f03f 58 const Standard_Real theAngle,
74da0216 59 const Standard_Real theMinSize,
f43eff9f 60 const Standard_Boolean isInternalVerticesMode,
61 const Standard_Boolean isControlSurfaceDeflection);
ceb418e1 62
fcf15f5c 63 Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute);
fc9b36d6 64
92efcf78 65 DEFINE_STANDARD_RTTIEXT(BRepMesh_FastDiscretFace,Standard_Transient)
fc9b36d6 66
ceb418e1 67private:
fc9b36d6 68
2caff0b3 69 void add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
ceb418e1 70 void add(const TopoDS_Vertex& theVertex);
fc9b36d6 71
848fa7e3 72 Standard_Real control(BRepMesh::ListOfVertex& theNewVertices,
73 BRepMesh_Delaun& theMeshBuilder,
74 const Standard_Boolean theIsFirst);
fc9b36d6 75
ceb418e1 76 //! Registers the given nodes in mesh data structure and
77 //! performs refinement of existing mesh.
78 //! @param theVertices nodes to be inserted.
79 //! @param theMeshBuilder initialized tool refining mesh
80 //! in respect to inserting nodes.
81 //! @return TRUE if vertices were been inserted, FALSE elewhere.
82 Standard_Boolean addVerticesToMesh(
848fa7e3 83 const BRepMesh::ListOfVertex& theVertices,
84 BRepMesh_Delaun& theMeshBuilder);
ceb418e1 85
86 //! Calculates nodes lying on face's surface and inserts them to a mesh.
87 //! @param theNewVertices list of vertices to be extended and added to mesh.
88 //! @param theMeshBuilder initialized tool refining mesh
89 //! in respect to inserting nodes.
848fa7e3 90 void insertInternalVertices(BRepMesh::ListOfVertex& theNewVertices,
91 BRepMesh_Delaun& theMeshBuilder);
ceb418e1 92
93 //! Calculates nodes lying on spherical surface.
94 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 95 void insertInternalVerticesSphere(BRepMesh::ListOfVertex& theNewVertices);
ceb418e1 96
97 //! Calculates nodes lying on cylindrical surface.
98 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 99 void insertInternalVerticesCylinder(BRepMesh::ListOfVertex& theNewVertices);
ceb418e1 100
101 //! Calculates nodes lying on conical surface.
102 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 103 void insertInternalVerticesCone(BRepMesh::ListOfVertex& theNewVertices);
ceb418e1 104
105 //! Calculates nodes lying on toroidal surface.
106 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 107 void insertInternalVerticesTorus(BRepMesh::ListOfVertex& theNewVertices);
ceb418e1 108
109 //! Calculates nodes lying on Bezier/BSpline surface.
110 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 111 void insertInternalVerticesBSpline(BRepMesh::ListOfVertex& theNewVertices);
ceb418e1 112
113 //! Calculates nodes lying on custom-type surface.
114 //! @param theNewVertices list of vertices to be extended and added to mesh.
848fa7e3 115 void insertInternalVerticesOther(BRepMesh::ListOfVertex& theNewVertices);
fc9b36d6 116
ceb418e1 117 //! Template method trying to insert new internal vertex corresponded to
118 //! the given 2d point. Calculates 3d position analytically using the given
119 //! surface.
120 //! @param thePnt2d 2d point to be inserted to the list.
121 //! @param theAnalyticSurface analytic surface to calculate 3d point.
122 //! @param[out] theVertices list of vertices to be updated.
123 template<class AnalyticSurface>
848fa7e3 124 void tryToInsertAnalyticVertex(const gp_Pnt2d& thePnt2d,
125 const AnalyticSurface& theAnalyticSurface,
126 BRepMesh::ListOfVertex& theVertices)
ceb418e1 127 {
2caff0b3 128 const BRepMesh::HClassifier& aClassifier = myAttribute->ChangeClassifier();
129 if (aClassifier->Perform(thePnt2d) != TopAbs_IN)
ceb418e1 130 return;
131
132 gp_Pnt aPnt;
133 ElSLib::D0(thePnt2d.X(), thePnt2d.Y(), theAnalyticSurface, aPnt);
134 insertVertex(aPnt, thePnt2d.Coord(), theVertices);
135 }
136
137 //! Creates new vertex with the given parameters.
138 //! @param thePnt3d 3d point corresponded to the vertex.
139 //! @param theUV UV point corresponded to the vertex.
140 //! @param[out] theVertices list of vertices to be updated.
848fa7e3 141 void insertVertex(const gp_Pnt& thePnt3d,
142 const gp_XY& theUV,
143 BRepMesh::ListOfVertex& theVertices);
fc9b36d6 144
fcf15f5c 145 //! Stores mesh into the face (without internal edges).
146 void commitSurfaceTriangulation();
147
2caff0b3 148 //! Performs initialization of data structure using existing data.
149 void initDataStructure();
150
151 //! Adds new link to the mesh data structure.
152 //! Movability of the link and order of nodes depend on orientation parameter.
153 void addLinkToMesh(const Standard_Integer theFirstNodeId,
154 const Standard_Integer theLastNodeId,
155 const TopAbs_Orientation theOrientation);
156
74da0216 157 //! Inserts new node into a mesh in case if smoothed region build
158 //! using the given node has better deflection metrics than source state.
159 //! @param thePnt3d 3d point corresponded to the vertex.
160 //! @param theUV UV point corresponded to the vertex.
161 //! @param isDeflectionCheckOnly if TRUE new node will not be added to a mesh
162 //! even if deflection parameter is better.
163 //! @param theTriangleDeflection deflection of a triangle from real geometry.
164 //! @param theFaceDeflection deflection to be achieved.
165 //! @param theCircleTool tool used for fast extraction of triangles
166 //! touched by the given point.
167 //! @param[out] theVertices list of vertices to be updated.
168 //! @param[in out] theMaxTriangleDeflection maximal deflection of a mesh.
169 //! @return TRUE in case if the given deflection of triangle is fine and
170 //! there is no necessity to insert new node or new node was being inserted
171 //! successfully, FALSE in case if new configuration is better but
172 //! isDeflectionCheckOnly flag is set.
173 Standard_Boolean checkDeflectionAndInsert(
174 const gp_Pnt& thePnt3d,
175 const gp_XY& theUV,
176 const Standard_Boolean isDeflectionCheckOnly,
177 const Standard_Real theTriangleDeflection,
178 const Standard_Real theFaceDeflection,
179 const BRepMesh_CircleTool& theCircleTool,
180 BRepMesh::ListOfVertex& theVertices,
181 Standard_Real& theMaxTriangleDeflection);
182
fc9b36d6 183private:
ceb418e1 184
848fa7e3 185 Standard_Real myAngle;
848fa7e3 186 Standard_Boolean myInternalVerticesMode;
187 BRepMesh::IMapOfReal myUParam;
188 BRepMesh::IMapOfReal myVParam;
ceb418e1 189
190 // Fast access to attributes of current face
848fa7e3 191 Handle(BRepMesh_FaceAttribute) myAttribute;
192 Handle(BRepMesh_DataStructureOfDelaun) myStructure;
74da0216 193
194 Standard_Real myMinSize;
f43eff9f 195 Standard_Boolean myIsControlSurfaceDeflection;
fc9b36d6 196};
197
198DEFINE_STANDARD_HANDLE (BRepMesh_FastDiscretFace, Standard_Transient)
199
200#endif