0026619: Tolerances of operands are modified using bop
[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
3510db62 59 Standard_EXPORT static void MakeVertex (const BOPCol_ListOfShape& aLV, TopoDS_Vertex& aV);
42cf5bc1 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.
3510db62 180 Standard_EXPORT static void CorrectTolerances
181 (const TopoDS_Shape& theS,
182 const BOPCol_IndexedMapOfShape& theMapToAvoid,
183 const Standard_Real theTolMax = 0.0001,
184 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 185
186 //! Provides valid values of tolerances for the shape <theS>
187 //! in terms of BRepCheck_InvalidCurveOnSurface.
3510db62 188 Standard_EXPORT static void CorrectCurveOnSurface
189 (const TopoDS_Shape& theS,
190 const BOPCol_IndexedMapOfShape& theMapToAvoid,
191 const Standard_Real theTolMax = 0.0001,
192 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 193
194 //! Provides valid values of tolerances for the shape <theS>
195 //! in terms of BRepCheck_InvalidPointOnCurve.
3510db62 196 Standard_EXPORT static void CorrectPointOnCurve
197 (const TopoDS_Shape& theS,
198 const BOPCol_IndexedMapOfShape& theMapToAvoid,
199 const Standard_Real theTolMax = 0.0001,
200 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 201
202 //! Make a vertex using 3D-point <aP1> and 3D-tolerance value <aTol>
203 Standard_EXPORT static void MakeNewVertex (const gp_Pnt& aP1, const Standard_Real aTol, TopoDS_Vertex& aNewVertex);
204
205
206 //! Make a vertex using couple of vertices <aV1, aV2>
207 Standard_EXPORT static void MakeNewVertex (const TopoDS_Vertex& aV1, const TopoDS_Vertex& aV2, TopoDS_Vertex& aNewVertex);
208
209
210 //! Make a vertex in place of intersection between two edges
211 //! <aE1, aE2> with parameters <aP1, aP2>
212 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Edge& aE2, const Standard_Real aP2, TopoDS_Vertex& aNewVertex);
213
214
215 //! Make a vertex in place of intersection between the edge <aE1>
216 //! with parameter <aP1> and the face <aF2>
217 Standard_EXPORT static void MakeNewVertex (const TopoDS_Edge& aE1, const Standard_Real aP1, const TopoDS_Face& aF2, TopoDS_Vertex& aNewVertex);
218
219
220 //! Compute a 3D-point on the edge <aEdge> at parameter <aPrm>
221 Standard_EXPORT static void PointOnEdge (const TopoDS_Edge& aEdge, const Standard_Real aPrm, gp_Pnt& aP);
222
223
224 //! Make the edge from base edge <aE1> and two vertices <aV1,aV2>
225 //! at parameters <aP1,aP2>
226 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);
227
228
229 //! Make the edge from 3D-Curve <aIC> and two vertices <aV1,aV2>
230 //! at parameters <aP1,aP2>
231 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);
232
233
234 //! Update the tolerance value for vertex <aV>
235 //! taking into account the fact that <aV> lays on
236 //! the curve <aIC>
237 Standard_EXPORT static void UpdateVertex (const IntTools_Curve& aIC, const Standard_Real aT, const TopoDS_Vertex& aV);
238
239
240 //! Update the tolerance value for vertex <aV>
241 //! taking into account the fact that <aV> lays on
242 //! the edge <aE>
243 Standard_EXPORT static void UpdateVertex (const TopoDS_Edge& aE, const Standard_Real aT, const TopoDS_Vertex& aV);
244
245
246 //! Update the tolerance value for vertex <aVN>
247 //! taking into account the fact that <aVN> should
248 //! cover tolerance zone of <aVF>
249 Standard_EXPORT static void UpdateVertex (const TopoDS_Vertex& aVF, const TopoDS_Vertex& aVN);
250
251
252 //! Correct shrunk range <aSR> taking into account 3D-curve
253 //! resolution and corresp. tolerances' values of <aE1>, <aE2>
254 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE1, const TopoDS_Edge& aE2, const IntTools_Range& aSR, IntTools_Range& aNewSR);
255
256
257 //! Correct shrunk range <aSR> taking into account 3D-curve
258 //! resolution and corresp. tolerances' values of <aE>, <aF>
259 Standard_EXPORT static void CorrectRange (const TopoDS_Edge& aE, const TopoDS_Face& aF, const IntTools_Range& aSR, IntTools_Range& aNewSR);
260
261
262 //! Returns TRUE if PaveBlock <aPB> lays on the face <aF>, i.e
263 //! the <PB> is IN or ON in 2D of <aF>
264 Standard_EXPORT static Standard_Boolean IsBlockInOnFace (const IntTools_Range& aShR, const TopoDS_Face& aF, const TopoDS_Edge& aE, Handle(IntTools_Context)& aContext);
265
266
267 //! Checks if it is possible to compute shrunk range for the edge <aE>.
268 Standard_EXPORT static Standard_Boolean IsMicroEdge (const TopoDS_Edge& theEdge, const Handle(IntTools_Context)& theContext);
269
270
271 //! Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
3510db62 272 Standard_EXPORT static void CorrectShapeTolerances
273 (const TopoDS_Shape& theS,
274 const BOPCol_IndexedMapOfShape& theMapToAvoid,
275 const Standard_Boolean theRunParallel = Standard_False);
42cf5bc1 276
277 //! Retutns dimension of the shape <theS>.
278 Standard_EXPORT static Standard_Integer Dimension (const TopoDS_Shape& theS);
279
280 //! Returns true if the shell <theShell> is open
281 Standard_EXPORT static Standard_Boolean IsOpenShell (const TopoDS_Shell& theShell);
282
283 //! Returns true if the solid <theSolid> is inverted
284 Standard_EXPORT static Standard_Boolean IsInvertedSolid (const TopoDS_Solid& theSolid);
285
286
287 //! Computes the necessary value of the tolerance for the edge
288 Standard_EXPORT static Standard_Boolean ComputeTolerance (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge, Standard_Real& theMaxDist, Standard_Real& theMaxPar);
289
290
291
292
293protected:
294
295
296
297
298
299private:
300
301
302
303
304
305};
306
307
308
309
310
311
312
313#endif // _BOPTools_AlgoTools_HeaderFile