Warnings on vc14 were eliminated
[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>
0d0481c7 35#include <Precision.hxx>
42cf5bc1 36class TopoDS_Vertex;
37class gp_Pnt;
38class IntTools_Curve;
39class TopoDS_Edge;
40class TopoDS_Face;
41class TopoDS_Shape;
42class IntTools_Context;
43class TopoDS_Solid;
44class IntTools_Range;
45class TopoDS_Shell;
46
47
42cf5bc1 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
0d0481c7 57 Standard_EXPORT static Standard_Integer ComputeVV (const TopoDS_Vertex& aV1,
58 const TopoDS_Vertex& aV2,
59 const Standard_Real theFuzz = Precision::Confusion());
42cf5bc1 60
3510db62 61 Standard_EXPORT static void MakeVertex (const BOPCol_ListOfShape& aLV, TopoDS_Vertex& aV);
42cf5bc1 62
63 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);
64
51db0179 65 //! Makes 2d curve of the edge <theE> on the faces <theF1> and <theF2>.<br>
66 //! <theContext> - storage for caching the geometrical tools
67 Standard_EXPORT static void MakePCurve (const TopoDS_Edge& theE,
68 const TopoDS_Face& theF1,
69 const TopoDS_Face& theF2,
70 const IntTools_Curve& theCurve,
71 const Standard_Boolean thePC1,
72 const Standard_Boolean thePC2,
73 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
42cf5bc1 74
75 Standard_EXPORT static void MakeContainer (const TopAbs_ShapeEnum theType, TopoDS_Shape& theShape);
76
77 Standard_EXPORT static Standard_Boolean IsHole (const TopoDS_Shape& aW, const TopoDS_Shape& aF);
78
79 //! Returns True if the shape theSplit has opposite
80 //! direction than theShape
81 //! theContext - cashed geometrical tools
82 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Shape& theSplit, const TopoDS_Shape& theShape, Handle(IntTools_Context)& theContext);
83
84 //! Returns True if normal direction of the face
85 //! theShape is not the same as for the face
86 //! theSplit
87 //! theContext - cashed geometrical tools
88 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Face& theSplit, const TopoDS_Face& theShape, Handle(IntTools_Context)& theContext);
89
90 Standard_EXPORT static Standard_Boolean IsSplitToReverse (const TopoDS_Edge& aE1, const TopoDS_Edge& aE2, Handle(IntTools_Context)& aContext);
91
0d0481c7 92 Standard_EXPORT static Standard_Boolean AreFacesSameDomain (const TopoDS_Face& theF1,
93 const TopoDS_Face& theF2,
94 Handle(IntTools_Context)& theContext,
95 const Standard_Real theFuzz = Precision::Confusion());
42cf5bc1 96
97 Standard_EXPORT static Standard_Boolean CheckSameGeom (const TopoDS_Face& theF1, const TopoDS_Face& theF2, Handle(IntTools_Context)& theContext);
98
51db0179 99 //! Basing on the normals directions of the faces the method
100 //! Defines whether to reverse the second face or not.<br>
101 //! <theContext> - storage for caching the geometrical tools
102 Standard_EXPORT static Standard_Integer Sense (const TopoDS_Face& theF1,
103 const TopoDS_Face& theF2,
104 const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
42cf5bc1 105
106 //! Returns True if the face theFace contains
107 //! the edge theEdge but with opposite orientation.
108 //! If the method returns True theEdgeOff is the
109 //! edge founded
110 Standard_EXPORT static Standard_Boolean GetEdgeOff (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, TopoDS_Edge& theEdgeOff);
111
112 //! For the face theFace and its edge theEdge
113 //! finds the face suitable to produce shell.
114 //! theLCEF - set of faces to search. All faces
115 //! from theLCEF must share edge theEdge
116 Standard_EXPORT static Standard_Boolean GetFaceOff (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, BOPTools_ListOfCoupleOfShape& theLCEF, TopoDS_Face& theFaceOff, Handle(IntTools_Context)& theContext);
117
118 //! Returns True if the face theFace is inside of the
119 //! couple of faces theFace1, theFace2.
120 //! The faces theFace, theFace1, theFace2 must
121 //! share the edge theEdge
dde68833 122 //! Return values:
123 //! * 0 state is not IN
124 //! * 1 state is IN
125 //! * 2 state can not be found by the method of angles
42cf5bc1 126 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);
127
128 //! Returns True if the face theFace is inside of the
129 //! appropriate couple of faces (from the set theLF) .
130 //! The faces of the set theLF and theFace must
131 //! share the edge theEdge
dde68833 132 //! * 0 state is not IN
133 //! * 1 state is IN
134 //! * 2 state can not be found by the method of angles
42cf5bc1 135 Standard_EXPORT static Standard_Integer IsInternalFace (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, BOPCol_ListOfShape& theLF, Handle(IntTools_Context)& theContext);
136
137 //! Returns True if the face theFace is inside the
138 //! solid theSolid.
139 //! theMEF - Map Edge/Faces for theSolid
140 //! theTol - value of precision of computation
141 //! theContext- cahed geometrical tools
dde68833 142 Standard_EXPORT static Standard_Boolean IsInternalFace (const TopoDS_Face& theFace, const TopoDS_Solid& theSolid, BOPCol_IndexedDataMapOfShapeListOfShape& theMEF, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
42cf5bc1 143
144 //! For the face theFace gets the edge theEdgeOnF
145 //! that is the same as theEdge
146 //! Returns True if such edge exists
147 //! Returns False if there is no such edge
148 Standard_EXPORT static Standard_Boolean GetEdgeOnFace (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, TopoDS_Edge& theEdgeOnF);
149
150 //! Computes the 3-D state of the point thePoint
151 //! toward solid theSolid.
152 //! theTol - value of precision of computation
153 //! theContext- cahed geometrical tools
154 //! Returns 3-D state.
155 Standard_EXPORT static TopAbs_State ComputeState (const gp_Pnt& thePoint, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
156
157 //! Computes the 3-D state of the vertex theVertex
158 //! toward solid theSolid.
159 //! theTol - value of precision of computation
160 //! theContext- cahed geometrical tools
161 //! Returns 3-D state.
162 Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Vertex& theVertex, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
163
164 //! Computes the 3-D state of the edge theEdge
165 //! toward solid theSolid.
166 //! theTol - value of precision of computation
167 //! theContext- cahed geometrical tools
168 //! Returns 3-D state.
169 Standard_EXPORT static TopAbs_State ComputeState (const TopoDS_Edge& theEdge, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
170
171 //! Computes the 3-D state of the face theFace
172 //! toward solid theSolid.
173 //! theTol - value of precision of computation
174 //! theBounds - set of edges of theFace to avoid
175 //! theContext- cahed geometrical tools
176 //! Returns 3-D state.
177 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);
178
179 //! Computes the 3-D state of the shape theShape
180 //! toward solid theSolid.
181 //! theTol - value of precision of computation
182 //! theContext- cahed geometrical tools
183 //! Returns 3-D state.
184 Standard_EXPORT static TopAbs_State ComputeStateByOnePoint (const TopoDS_Shape& theShape, const TopoDS_Solid& theSolid, const Standard_Real theTol, Handle(IntTools_Context)& theContext);
185
186 //! For the list of faces theLS build block
187 //! theLSCB in terms of connexity by edges
188 //! theMapAvoid - set of edges to avoid for
189 //! the treatment
190 Standard_EXPORT static void MakeConnexityBlock (BOPCol_ListOfShape& theLS, BOPCol_IndexedMapOfShape& theMapAvoid, BOPCol_ListOfShape& theLSCB, const BOPCol_BaseAllocator& theAllocator);
191
192 //! For the compound theS build the blocks
193 //! theLCB (as list of compounds)
194 //! in terms of connexity by the shapes of theType
195 Standard_EXPORT static void MakeConnexityBlocks (const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2, BOPCol_ListOfShape& theLCB);
77a11d3d 196
197 //! Correctly orients edges on the wire
198 Standard_EXPORT static void OrientEdgesOnWire (TopoDS_Shape& theWire);
199
200 //! Correctly orients faces on the shell
201 Standard_EXPORT static void OrientFacesOnShell (TopoDS_Shape& theShell);
42cf5bc1 202
203
204 //! Provides valid values of tolerances for the shape <theS>
205 //! <theTolMax> is max value of the tolerance that can be
206 //! accepted for correction. If real value of the tolerance
207 //! will be greater than <aTolMax>, the correction does not
208 //! perform.
3510db62 209 Standard_EXPORT static void CorrectTolerances
210 (const TopoDS_Shape& theS,
211 const BOPCol_IndexedMapOfShape& theMapToAvoid,
212 const Standard_Real theTolMax = 0.0001,
213 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 214
215 //! Provides valid values of tolerances for the shape <theS>
216 //! in terms of BRepCheck_InvalidCurveOnSurface.
3510db62 217 Standard_EXPORT static void CorrectCurveOnSurface
218 (const TopoDS_Shape& theS,
219 const BOPCol_IndexedMapOfShape& theMapToAvoid,
220 const Standard_Real theTolMax = 0.0001,
221 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 222
223 //! Provides valid values of tolerances for the shape <theS>
224 //! in terms of BRepCheck_InvalidPointOnCurve.
3510db62 225 Standard_EXPORT static void CorrectPointOnCurve
226 (const TopoDS_Shape& theS,
227 const BOPCol_IndexedMapOfShape& theMapToAvoid,
228 const Standard_Real theTolMax = 0.0001,
229 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 230
231 //! Make a vertex using 3D-point <aP1> and 3D-tolerance value <aTol>
232 Standard_EXPORT static void MakeNewVertex (const gp_Pnt& aP1, const Standard_Real aTol, TopoDS_Vertex& aNewVertex);
233
234
235 //! Make a vertex using couple of vertices <aV1, aV2>
236 Standard_EXPORT static void MakeNewVertex (const TopoDS_Vertex& aV1, const TopoDS_Vertex& aV2, TopoDS_Vertex& aNewVertex);
237
238
239 //! Make a vertex in place of intersection between two edges
240 //! <aE1, aE2> with parameters <aP1, aP2>
241 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Edge& aE2, const Standard_Real aP2, TopoDS_Vertex& aNewVertex);
242
243
244 //! Make a vertex in place of intersection between the edge <aE1>
245 //! with parameter <aP1> and the face <aF2>
246 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Face& aF2, TopoDS_Vertex& aNewVertex);
247
248
249 //! Compute a 3D-point on the edge <aEdge> at parameter <aPrm>
250 Standard_EXPORT static void PointOnEdge (const TopoDS_Edge& aEdge, const Standard_Real aPrm, gp_Pnt& aP);
251
252
253 //! Make the edge from base edge <aE1> and two vertices <aV1,aV2>
254 //! at parameters <aP1,aP2>
255 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);
256
257
258 //! Make the edge from 3D-Curve <aIC> and two vertices <aV1,aV2>
259 //! at parameters <aP1,aP2>
260 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);
261
262
263 //! Update the tolerance value for vertex <aV>
264 //! taking into account the fact that <aV> lays on
265 //! the curve <aIC>
266 Standard_EXPORT static void UpdateVertex (const IntTools_Curve& aIC, const Standard_Real aT, const TopoDS_Vertex& aV);
267
268
269 //! Update the tolerance value for vertex <aV>
270 //! taking into account the fact that <aV> lays on
271 //! the edge <aE>
272 Standard_EXPORT static void UpdateVertex (const TopoDS_Edge& aE, const Standard_Real aT, const TopoDS_Vertex& aV);
273
274
275 //! Update the tolerance value for vertex <aVN>
276 //! taking into account the fact that <aVN> should
277 //! cover tolerance zone of <aVF>
278 Standard_EXPORT static void UpdateVertex (const TopoDS_Vertex& aVF, const TopoDS_Vertex& aVN);
279
280
281 //! Correct shrunk range <aSR> taking into account 3D-curve
282 //! resolution and corresp. tolerances' values of <aE1>, <aE2>
283 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE1, const TopoDS_Edge& aE2, const IntTools_Range& aSR, IntTools_Range& aNewSR);
284
285
286 //! Correct shrunk range <aSR> taking into account 3D-curve
287 //! resolution and corresp. tolerances' values of <aE>, <aF>
288 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE, const TopoDS_Face& aF, const IntTools_Range& aSR, IntTools_Range& aNewSR);
289
290
291 //! Returns TRUE if PaveBlock <aPB> lays on the face <aF>, i.e
292 //! the <PB> is IN or ON in 2D of <aF>
293 Standard_EXPORT static Standard_Boolean IsBlockInOnFace (const IntTools_Range& aShR, const TopoDS_Face& aF, const TopoDS_Edge& aE, Handle(IntTools_Context)& aContext);
294
295
01b5b3df 296 //! Checks if it is possible to compute shrunk range for the edge <aE>
297 //! Flag <theCheckSplittable> defines whether to take into account
298 //! the possiblity to split the edge or not.
299 Standard_EXPORT static Standard_Boolean IsMicroEdge (const TopoDS_Edge& theEdge,
300 const Handle(IntTools_Context)& theContext,
301 const Standard_Boolean theCheckSplittable = Standard_True);
42cf5bc1 302
303
304 //! Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
3510db62 305 Standard_EXPORT static void CorrectShapeTolerances
306 (const TopoDS_Shape& theS,
307 const BOPCol_IndexedMapOfShape& theMapToAvoid,
308 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 309
310 //! Retutns dimension of the shape <theS>.
311 Standard_EXPORT static Standard_Integer Dimension (const TopoDS_Shape& theS);
312
313 //! Returns true if the shell <theShell> is open
314 Standard_EXPORT static Standard_Boolean IsOpenShell (const TopoDS_Shell& theShell);
315
316 //! Returns true if the solid <theSolid> is inverted
317 Standard_EXPORT static Standard_Boolean IsInvertedSolid (const TopoDS_Solid& theSolid);
318
319
320 //! Computes the necessary value of the tolerance for the edge
321 Standard_EXPORT static Standard_Boolean ComputeTolerance (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, Standard_Real& theMaxDist, Standard_Real& theMaxPar);
322
323
42cf5bc1 324protected:
325
326
42cf5bc1 327private:
328
42cf5bc1 329};
330
42cf5bc1 331#endif // _BOPTools_AlgoTools_HeaderFile