0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPTools / BOPTools_AlgoTools.hxx
CommitLineData
42cf5bc1 1// Created by: Peter KURNEV
2// Copyright (c) 2010-2014 OPEN CASCADE SAS
3// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6//
7// This file is part of Open CASCADE Technology software library.
8//
9// This library is free software; you can redistribute it and/or modify it under
10// the terms of the GNU Lesser General Public License version 2.1 as published
11// by the Free Software Foundation, with special exception defined in the file
12// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13// distribution for complete text of the license and disclaimer of any warranty.
14//
15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
17
18#ifndef _BOPTools_AlgoTools_HeaderFile
19#define _BOPTools_AlgoTools_HeaderFile
20
21#include <Standard.hxx>
22#include <Standard_DefineAlloc.hxx>
23#include <Standard_Handle.hxx>
24
25#include <Standard_Integer.hxx>
26#include <Standard_Real.hxx>
27#include <BOPCol_ListOfShape.hxx>
28#include <Standard_Boolean.hxx>
29#include <TopAbs_ShapeEnum.hxx>
30#include <BOPTools_ListOfCoupleOfShape.hxx>
31#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
32#include <TopAbs_State.hxx>
33#include <BOPCol_IndexedMapOfShape.hxx>
34#include <BOPCol_BaseAllocator.hxx>
35class TopoDS_Vertex;
36class gp_Pnt;
37class IntTools_Curve;
38class TopoDS_Edge;
39class TopoDS_Face;
40class TopoDS_Shape;
41class IntTools_Context;
42class TopoDS_Solid;
43class IntTools_Range;
44class TopoDS_Shell;
45
46
47
48class BOPTools_AlgoTools
49{
50public:
51
52 DEFINE_STANDARD_ALLOC
53
54
55 Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& aV1, const gp_Pnt& aP2, const Standard_Real aTolP2);
56
57 Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& aV1, const TopoDS_Vertex& aV2);
58
59 Standard_EXPORT static void MakeVertex (BOPCol_ListOfShape& aLV, TopoDS_Vertex& aV);
60
61 Standard_EXPORT static void MakeEdge (const IntTools_Curve& theCurve, const TopoDS_Vertex& theV1, const Standard_Real theT1, const TopoDS_Vertex& theV2, const Standard_Real theT2, const Standard_Real theTolR3D, TopoDS_Edge& theE);
62
63 Standard_EXPORT static void MakePCurve (const TopoDS_Edge& theE, const TopoDS_Face& theF1, const TopoDS_Face& theF2, const IntTools_Curve& theCurve, const Standard_Boolean thePC1, const Standard_Boolean thePC2);
64
65 Standard_EXPORT static void MakeContainer (const TopAbs_ShapeEnum theType, TopoDS_Shape& theShape);
66
67 Standard_EXPORT static Standard_Boolean IsHole (const TopoDS_Shape& aW, const TopoDS_Shape& aF);
68
69 //! Returns True if the shape theSplit has opposite
70 //! direction than theShape
71 //! theContext - cashed geometrical tools
72 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Shape& theSplit, const TopoDS_Shape& theShape, Handle(IntTools_Context)& theContext);
73
74 //! Returns True if normal direction of the face
75 //! theShape is not the same as for the face
76 //! theSplit
77 //! theContext - cashed geometrical tools
78 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Face& theSplit, const TopoDS_Face& theShape, Handle(IntTools_Context)& theContext);
79
80 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Edge& aE1, const TopoDS_Edge& aE2, Handle(IntTools_Context)& aContext);
81
82 Standard_EXPORT static Standard_Boolean AreFacesSameDomain (const TopoDS_Face& theF1, const TopoDS_Face& theF2, Handle(IntTools_Context)& theContext);
83
84 Standard_EXPORT static Standard_Boolean CheckSameGeom (const TopoDS_Face& theF1, const TopoDS_Face& theF2, Handle(IntTools_Context)& theContext);
85
86 Standard_EXPORT static Standard_Integer Sense (const TopoDS_Face& theF1, const TopoDS_Face& theF2);
87
88 //! Returns True if the face theFace contains
89 //! the edge theEdge but with opposite orientation.
90 //! If the method returns True theEdgeOff is the
91 //! edge founded
92 Standard_EXPORT static Standard_Boolean GetEdgeOff (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, TopoDS_Edge& theEdgeOff);
93
94 //! For the face theFace and its edge theEdge
95 //! finds the face suitable to produce shell.
96 //! theLCEF - set of faces to search. All faces
97 //! from theLCEF must share edge theEdge
98 Standard_EXPORT static Standard_Boolean GetFaceOff (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, BOPTools_ListOfCoupleOfShape& theLCEF, TopoDS_Face& theFaceOff, Handle(IntTools_Context)& theContext);
99
100 //! Returns True if the face theFace is inside of the
101 //! couple of faces theFace1, theFace2.
102 //! The faces theFace, theFace1, theFace2 must
103 //! share the edge theEdge
104 Standard_EXPORT static Standard_Integer IsInternalFace (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, const TopoDS_Face& theFace1, const TopoDS_Face& theFace2, Handle(IntTools_Context)& theContext);
105
106 //! Returns True if the face theFace is inside of the
107 //! appropriate couple of faces (from the set theLF) .
108 //! The faces of the set theLF and theFace must
109 //! share the edge theEdge
110 Standard_EXPORT static Standard_Integer IsInternalFace (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, BOPCol_ListOfShape& theLF, Handle(IntTools_Context)& theContext);
111
112 //! Returns True if the face theFace is inside the
113 //! solid theSolid.
114 //! theMEF - Map Edge/Faces for theSolid
115 //! theTol - value of precision of computation
116 //! theContext- cahed geometrical tools
117 Standard_EXPORT static Standard_Integer IsInternalFace (const TopoDS_Face& theFace, const TopoDS_Solid& theSolid, BOPCol_IndexedDataMapOfShapeListOfShape& theMEF, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
118
119 //! For the face theFace gets the edge theEdgeOnF
120 //! that is the same as theEdge
121 //! Returns True if such edge exists
122 //! Returns False if there is no such edge
123 Standard_EXPORT static Standard_Boolean GetEdgeOnFace (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, TopoDS_Edge& theEdgeOnF);
124
125 //! Computes the 3-D state of the point thePoint
126 //! toward solid theSolid.
127 //! theTol - value of precision of computation
128 //! theContext- cahed geometrical tools
129 //! Returns 3-D state.
130 Standard_EXPORT static TopAbs_State ComputeState (const gp_Pnt& thePoint, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
131
132 //! Computes the 3-D state of the vertex theVertex
133 //! toward solid theSolid.
134 //! theTol - value of precision of computation
135 //! theContext- cahed geometrical tools
136 //! Returns 3-D state.
137 Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Vertex& theVertex, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
138
139 //! Computes the 3-D state of the edge theEdge
140 //! toward solid theSolid.
141 //! theTol - value of precision of computation
142 //! theContext- cahed geometrical tools
143 //! Returns 3-D state.
144 Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Edge& theEdge, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
145
146 //! Computes the 3-D state of the face theFace
147 //! toward solid theSolid.
148 //! theTol - value of precision of computation
149 //! theBounds - set of edges of theFace to avoid
150 //! theContext- cahed geometrical tools
151 //! Returns 3-D state.
152 Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Face& theFace, const TopoDS_Solid& theSolid, const Standard_Real theTol, BOPCol_IndexedMapOfShape& theBounds, Handle(IntTools_Context)& theContext);
153
154 //! Computes the 3-D state of the shape theShape
155 //! toward solid theSolid.
156 //! theTol - value of precision of computation
157 //! theContext- cahed geometrical tools
158 //! Returns 3-D state.
159 Standard_EXPORT static TopAbs_State ComputeStateByOnePoint (const TopoDS_Shape& theShape, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
160
161 //! For the list of faces theLS build block
162 //! theLSCB in terms of connexity by edges
163 //! theMapAvoid - set of edges to avoid for
164 //! the treatment
165 Standard_EXPORT static void MakeConnexityBlock (BOPCol_ListOfShape& theLS, BOPCol_IndexedMapOfShape& theMapAvoid, BOPCol_ListOfShape& theLSCB, const BOPCol_BaseAllocator& theAllocator);
166
167 //! For the compound theS build the blocks
168 //! theLCB (as list of compounds)
169 //! in terms of connexity by the shapes of theType
170 Standard_EXPORT static void MakeConnexityBlocks (const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2, BOPCol_ListOfShape& theLCB);
171
172 Standard_EXPORT static void OrientFacesOnShell (TopoDS_Shape& theS);
173
174
175 //! Provides valid values of tolerances for the shape <theS>
176 //! <theTolMax> is max value of the tolerance that can be
177 //! accepted for correction. If real value of the tolerance
178 //! will be greater than <aTolMax>, the correction does not
179 //! perform.
180 Standard_EXPORT static void CorrectTolerances (const TopoDS_Shape& theS, const Standard_Real theTolMax = 0.0001, const Standard_Boolean theRunParallel = Standard_False);
181
182
183 //! Provides valid values of tolerances for the shape <theS>
184 //! in terms of BRepCheck_InvalidCurveOnSurface.
185 Standard_EXPORT static void CorrectCurveOnSurface (const TopoDS_Shape& theS, const Standard_Real theTolMax = 0.0001, const Standard_Boolean theRunParallel = Standard_False);
186
187
188 //! Provides valid values of tolerances for the shape <theS>
189 //! in terms of BRepCheck_InvalidPointOnCurve.
190 Standard_EXPORT static void CorrectPointOnCurve (const TopoDS_Shape& theS, const Standard_Real theTolMax = 0.0001, const Standard_Boolean theRunParallel = Standard_False);
191
192
193 //! Make a vertex using 3D-point <aP1> and 3D-tolerance value <aTol>
194 Standard_EXPORT static void MakeNewVertex (const gp_Pnt& aP1, const Standard_Real aTol, TopoDS_Vertex& aNewVertex);
195
196
197 //! Make a vertex using couple of vertices <aV1, aV2>
198 Standard_EXPORT static void MakeNewVertex (const TopoDS_Vertex& aV1, const TopoDS_Vertex& aV2, TopoDS_Vertex& aNewVertex);
199
200
201 //! Make a vertex in place of intersection between two edges
202 //! <aE1, aE2> with parameters <aP1, aP2>
203 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Edge& aE2, const Standard_Real aP2, TopoDS_Vertex& aNewVertex);
204
205
206 //! Make a vertex in place of intersection between the edge <aE1>
207 //! with parameter <aP1> and the face <aF2>
208 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Face& aF2, TopoDS_Vertex& aNewVertex);
209
210
211 //! Compute a 3D-point on the edge <aEdge> at parameter <aPrm>
212 Standard_EXPORT static void PointOnEdge (const TopoDS_Edge& aEdge, const Standard_Real aPrm, gp_Pnt& aP);
213
214
215 //! Make the edge from base edge <aE1> and two vertices <aV1,aV2>
216 //! at parameters <aP1,aP2>
217 Standard_EXPORT static void MakeSplitEdge (const TopoDS_Edge& aE1, const TopoDS_Vertex& aV1, const Standard_Real aP1, const TopoDS_Vertex& aV2, const Standard_Real aP2, TopoDS_Edge& aNewEdge);
218
219
220 //! Make the edge from 3D-Curve <aIC> and two vertices <aV1,aV2>
221 //! at parameters <aP1,aP2>
222 Standard_EXPORT static void MakeSectEdge (const IntTools_Curve& aIC, const TopoDS_Vertex& aV1, const Standard_Real aP1, const TopoDS_Vertex& aV2, const Standard_Real aP2, TopoDS_Edge& aNewEdge);
223
224
225 //! Update the tolerance value for vertex <aV>
226 //! taking into account the fact that <aV> lays on
227 //! the curve <aIC>
228 Standard_EXPORT static void UpdateVertex (const IntTools_Curve& aIC, const Standard_Real aT, const TopoDS_Vertex& aV);
229
230
231 //! Update the tolerance value for vertex <aV>
232 //! taking into account the fact that <aV> lays on
233 //! the edge <aE>
234 Standard_EXPORT static void UpdateVertex (const TopoDS_Edge& aE, const Standard_Real aT, const TopoDS_Vertex& aV);
235
236
237 //! Update the tolerance value for vertex <aVN>
238 //! taking into account the fact that <aVN> should
239 //! cover tolerance zone of <aVF>
240 Standard_EXPORT static void UpdateVertex (const TopoDS_Vertex& aVF, const TopoDS_Vertex& aVN);
241
242
243 //! Correct shrunk range <aSR> taking into account 3D-curve
244 //! resolution and corresp. tolerances' values of <aE1>, <aE2>
245 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE1, const TopoDS_Edge& aE2, const IntTools_Range& aSR, IntTools_Range& aNewSR);
246
247
248 //! Correct shrunk range <aSR> taking into account 3D-curve
249 //! resolution and corresp. tolerances' values of <aE>, <aF>
250 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE, const TopoDS_Face& aF, const IntTools_Range& aSR, IntTools_Range& aNewSR);
251
252
253 //! Returns TRUE if PaveBlock <aPB> lays on the face <aF>, i.e
254 //! the <PB> is IN or ON in 2D of <aF>
255 Standard_EXPORT static Standard_Boolean IsBlockInOnFace (const IntTools_Range& aShR, const TopoDS_Face& aF, const TopoDS_Edge& aE, Handle(IntTools_Context)& aContext);
256
257
258 //! Checks if it is possible to compute shrunk range for the edge <aE>.
259 Standard_EXPORT static Standard_Boolean IsMicroEdge (const TopoDS_Edge& theEdge, const Handle(IntTools_Context)& theContext);
260
261
262 //! Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
263 Standard_EXPORT static void CorrectShapeTolerances (const TopoDS_Shape& theS, const Standard_Boolean theRunParallel = Standard_False);
264
265
266 //! Retutns dimension of the shape <theS>.
267 Standard_EXPORT static Standard_Integer Dimension (const TopoDS_Shape& theS);
268
269 //! Returns true if the shell <theShell> is open
270 Standard_EXPORT static Standard_Boolean IsOpenShell (const TopoDS_Shell& theShell);
271
272 //! Returns true if the solid <theSolid> is inverted
273 Standard_EXPORT static Standard_Boolean IsInvertedSolid (const TopoDS_Solid& theSolid);
274
275
276 //! Computes the necessary value of the tolerance for the edge
277 Standard_EXPORT static Standard_Boolean ComputeTolerance (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, Standard_Real& theMaxDist, Standard_Real& theMaxPar);
278
279
280
281
282protected:
283
284
285
286
287
288private:
289
290
291
292
293
294};
295
296
297
298
299
300
301
302#endif // _BOPTools_AlgoTools_HeaderFile