0026619: Tolerances of operands are modified using bop
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller.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 _BOPAlgo_PaveFiller_HeaderFile
19#define _BOPAlgo_PaveFiller_HeaderFile
20
21#include <Standard.hxx>
22#include <Standard_DefineAlloc.hxx>
23#include <Standard_Handle.hxx>
24
25#include <BOPCol_ListOfShape.hxx>
26#include <BOPDS_PDS.hxx>
27#include <BOPDS_PIterator.hxx>
28#include <BOPAlgo_SectionAttribute.hxx>
29#include <Standard_Real.hxx>
30#include <BOPAlgo_Algo.hxx>
31#include <BOPCol_BaseAllocator.hxx>
32#include <TopAbs_ShapeEnum.hxx>
33#include <Standard_Integer.hxx>
34#include <BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks.hxx>
35#include <Standard_Boolean.hxx>
36#include <BOPCol_MapOfInteger.hxx>
37#include <BOPCol_DataMapOfIntegerReal.hxx>
38#include <BOPCol_ListOfInteger.hxx>
39#include <BOPDS_IndexedMapOfPaveBlock.hxx>
40#include <BOPCol_DataMapOfShapeInteger.hxx>
41#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
42#include <BOPCol_DataMapOfIntegerInteger.hxx>
43#include <BOPDS_ListOfPaveBlock.hxx>
44#include <IntSurf_ListOfPntOn2S.hxx>
45#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
46#include <BOPDS_MapOfPaveBlock.hxx>
47#include <BOPCol_IndexedDataMapOfShapeInteger.hxx>
48#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
49class IntTools_Context;
50class BOPDS_DS;
51class BOPAlgo_SectionAttribute;
52class BOPDS_PaveBlock;
3510db62 53class BOPDS_CommonBlock;
42cf5bc1 54class TopoDS_Vertex;
55class gp_Pnt;
56class BOPDS_Curve;
57class TopoDS_Face;
58
59
42cf5bc1 60class BOPAlgo_PaveFiller : public BOPAlgo_Algo
61{
62public:
63
64 DEFINE_STANDARD_ALLOC
65
66
67 Standard_EXPORT BOPAlgo_PaveFiller();
3510db62 68
69 Standard_EXPORT virtual ~BOPAlgo_PaveFiller();
42cf5bc1 70
71 Standard_EXPORT BOPAlgo_PaveFiller(const BOPCol_BaseAllocator& theAllocator);
72
73 Standard_EXPORT const BOPDS_DS& DS();
74
75 Standard_EXPORT BOPDS_PDS PDS();
76
77 Standard_EXPORT const BOPDS_PIterator& Iterator();
78
79 Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
80
81 Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
82
83 Standard_EXPORT Handle(IntTools_Context) Context();
84
85 Standard_EXPORT void SetSectionAttribute (const BOPAlgo_SectionAttribute& theSecAttr);
86
3510db62 87 //! Sets the flag that defines the mode of treatment.
88 //! In non-destructive mode the argument shapes are not modified. Instead
89 //! a copy of a sub-shape is created in the result if it is needed to be updated.
90 Standard_EXPORT void SetNonDestructive(const Standard_Boolean theFlag);
91
92 //! Returns the flag that defines the mode of treatment.
93 //! In non-destructive mode the argument shapes are not modified. Instead
94 //! a copy of a sub-shape is created in the result if it is needed to be updated.
95 Standard_EXPORT Standard_Boolean NonDestructive() const;
96
42cf5bc1 97 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
98
99 //! Sets the additional tolerance
100 Standard_EXPORT void SetFuzzyValue (const Standard_Real theFuzz);
101
102 //! Returns the additional tolerance
103 Standard_EXPORT Standard_Real FuzzyValue() const;
104
105
106
107
108protected:
109
3510db62 110 //! Sets non-destructive mode automatically if an argument
111 //! contains a locked sub-shape (see TopoDS_Shape::Locked()).
112 Standard_EXPORT void SetNonDestructive();
113
114 Standard_EXPORT void SetIsPrimary(const Standard_Boolean theFlag);
115
116 Standard_EXPORT Standard_Boolean IsPrimary() const;
117
42cf5bc1 118 Standard_EXPORT virtual void PerformInternal();
119
120 Standard_EXPORT virtual void Clear();
121
122 Standard_EXPORT virtual void Init();
123
124 Standard_EXPORT void Prepare();
125
126 Standard_EXPORT virtual void PerformVV();
127
128 Standard_EXPORT virtual void PerformVE();
129
130 Standard_EXPORT virtual void PerformVF();
131
132 Standard_EXPORT virtual void PerformEE();
133
134 Standard_EXPORT virtual void PerformEF();
135
136 Standard_EXPORT virtual void PerformFF();
137
138 Standard_EXPORT virtual void PerformVZ();
139
140 Standard_EXPORT virtual void PerformEZ();
141
142 Standard_EXPORT virtual void PerformFZ();
143
144 Standard_EXPORT virtual void PerformZZ();
488e5b9d 145
146 Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
42cf5bc1 147
148 Standard_EXPORT void TreatVerticesEE();
149
150 Standard_EXPORT void MakeSplitEdges();
151
152 Standard_EXPORT void MakeBlocks();
153
154 Standard_EXPORT void MakePCurves();
3510db62 155
156 Standard_EXPORT void MakeSDVertices(const BOPCol_ListOfInteger& theVertIndices);
42cf5bc1 157
158 Standard_EXPORT void ProcessDE();
159
160 Standard_EXPORT void FillShrunkData (Handle(BOPDS_PaveBlock)& thePB);
161
162 Standard_EXPORT void FillShrunkData (const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2);
163
7f22979e 164 Standard_EXPORT Standard_Integer PerformVerticesEE (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
42cf5bc1 165
7f22979e 166 Standard_EXPORT Standard_Integer PerformVerticesEF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
42cf5bc1 167
168 Standard_EXPORT Standard_Boolean CheckFacePaves (const TopoDS_Vertex& theVnew, const BOPCol_MapOfInteger& theMIF);
169
170 Standard_EXPORT static Standard_Boolean CheckFacePaves (const Standard_Integer theN, const BOPCol_MapOfInteger& theMIFOn, const BOPCol_MapOfInteger& theMIFIn);
171
172 Standard_EXPORT Standard_Boolean IsExistingVertex (const gp_Pnt& theP, const Standard_Real theTol, const BOPCol_MapOfInteger& theMVOn) const;
173
174
175 //! Checks and puts paves from <theMVOn> on the curve <theNC>.
176 Standard_EXPORT void PutPavesOnCurve (const BOPCol_MapOfInteger& theMVOn, const Standard_Real theTolR3D, BOPDS_Curve& theNC, const Standard_Integer nF1, const Standard_Integer nF2, const BOPCol_MapOfInteger& theMI, const BOPCol_MapOfInteger& theMVEF, BOPCol_DataMapOfIntegerReal& theMVTol);
177
178
179 //! Depending on the parameter aType it checks whether
180 //! the vertex nV was created in EE or EF intersections.
181 //! If so, it increases aTolVExt from tolerance value of vertex to
182 //! the max distance from vertex nV to the ends of the range of common part.
183 //! Possible values of aType:
184 //! 1 - checks only EE;
185 //! 2 - checks only EF;
186 //! other - checks both types of intersections.
187 Standard_EXPORT Standard_Boolean ExtendedTolerance (const Standard_Integer nV, const BOPCol_MapOfInteger& aMI, Standard_Real& aTolVExt, const Standard_Integer aType = 0);
188
189 Standard_EXPORT void PutBoundPaveOnCurve (const TopoDS_Face& theF1, const TopoDS_Face& theF2, const Standard_Real theTolR3D, BOPDS_Curve& theNC, BOPCol_ListOfInteger& theLBV);
190
191 Standard_EXPORT Standard_Boolean IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, const Standard_Real theTolR3D, const BOPDS_IndexedMapOfPaveBlock& theMPB, Handle(BOPDS_PaveBlock)& thePBOut);
192
193 Standard_EXPORT Standard_Boolean IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, const Standard_Real theTolR3D, const BOPCol_ListOfInteger& theLSE);
194
195
196 //! Treatment of section edges.
7f22979e 197 Standard_EXPORT Standard_Integer PostTreatFF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, BOPCol_DataMapOfShapeInteger& theMVI, BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDMExEdges, BOPCol_DataMapOfIntegerInteger& theDMI, const BOPCol_BaseAllocator& theAllocator);
42cf5bc1 198
199 Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV, const Standard_Integer theF, BOPDS_ListOfPaveBlock& theLPB);
200
201 Standard_EXPORT void FillPaves (const Standard_Integer theV, const Standard_Integer theE, const Standard_Integer theF, const BOPDS_ListOfPaveBlock& theLPB, const Handle(BOPDS_PaveBlock)& thePB);
202
203 Standard_EXPORT void MakeSplitEdge (const Standard_Integer theV, const Standard_Integer theF);
204
205 Standard_EXPORT void GetEFPnts (const Standard_Integer nF1, const Standard_Integer nF2, IntSurf_ListOfPntOn2S& aListOfPnts);
206
207
208 //! Checks and puts paves created in EF intersections on the curve <theNC>.
209 Standard_EXPORT void PutEFPavesOnCurve (BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMI, const BOPCol_MapOfInteger& theMVEF, BOPCol_DataMapOfIntegerReal& theMVTol);
210
211
212 //! Puts stick paves on the curve <theNC>
213 Standard_EXPORT void PutStickPavesOnCurve (const TopoDS_Face& aF1, const TopoDS_Face& aF2, const BOPCol_MapOfInteger& theMI, BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMVStick, BOPCol_DataMapOfIntegerReal& theMVTol);
214
215
216 //! Collects indices of vertices created in all intersections between
217 //! two faces (<nF1> and <nF2>) to the map <theMVStick>.
218 //! Also, it collects indices of EF vertices to the <theMVEF> map
219 //! and indices of all subshapes of these two faces to the <theMI> map.
220 Standard_EXPORT void GetStickVertices (const Standard_Integer nF1, const Standard_Integer nF2, BOPCol_MapOfInteger& theMVStick, BOPCol_MapOfInteger& theMVEF, BOPCol_MapOfInteger& theMI);
221
222
223 //! Collects index nF and indices of all subshapes of the shape with index <nF>
224 //! to the map <theMI>.
225 Standard_EXPORT void GetFullShapeMap (const Standard_Integer nF, BOPCol_MapOfInteger& theMI);
226
227
228 //! Removes indices of vertices that are already on the
229 //! curve <theNC> from the map <theMV>.
230 //! It is used in PutEFPavesOnCurve and PutStickPavesOnCurve methods.
231 Standard_EXPORT void RemoveUsedVertices (BOPDS_Curve& theNC, BOPCol_MapOfInteger& theMV);
232
233
234 //! Puts the pave nV on the curve theNC.
235 //! Parameter aType defines whether to check the pave with
236 //! extended tolerance:
237 //! 0 - do not perform the check;
238 //! other - perform the check (aType goes to ExtendedTolerance).
239 Standard_EXPORT void PutPaveOnCurve (const Standard_Integer nV, const Standard_Real theTolR3D, BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMI, BOPCol_DataMapOfIntegerReal& theMVTol, const Standard_Integer aType = 0);
240
241
242 //! Adds the existing edges from the map <theMPBOnIn> which interfere
243 //! with the vertices from <theMVB> map to the post treatment of section edges.
244 Standard_EXPORT void ProcessExistingPaveBlocks (const Standard_Integer theInt, const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn, const BOPCol_DataMapOfIntegerListOfInteger& theDMBV, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, BOPCol_DataMapOfShapeInteger& theMVI, BOPDS_MapOfPaveBlock& theMPB);
245
246
247 //! Replaces existing pave block <thePB> with new pave blocks <theLPB>.
248 //! The list <theLPB> contains images of <thePB> which were created in
249 //! the post treatment of section edges.
250 Standard_EXPORT void UpdateExistingPaveBlocks (const Handle(BOPDS_PaveBlock)& thePB, BOPDS_ListOfPaveBlock& theLPB, const Standard_Integer nF1, const Standard_Integer nF2);
251
252
253 //! Treatment of vertices that were created in EE intersections.
3510db62 254 Standard_EXPORT void TreatNewVertices(const BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, BOPCol_IndexedDataMapOfShapeListOfShape& theImages);
42cf5bc1 255
256
257 //! Put paves on the curve <aBC> in case when <aBC>
258 //! is closed 3D-curve
259 Standard_EXPORT void PutClosingPaveOnCurve (BOPDS_Curve& aNC);
260
261
262 //! Keeps data for post treatment
263 Standard_EXPORT void PreparePostTreatFF (const Standard_Integer aInt, const Standard_Integer aCur, const Handle(BOPDS_PaveBlock)& aPB, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, BOPCol_DataMapOfShapeInteger& aMVI, BOPDS_ListOfPaveBlock& aLPB);
264
265
266 //! Refines the state On for the all faces having
267 //! state information
268 Standard_EXPORT void RefineFaceInfoOn();
269
270
271 //! Updates the information about faces
272 Standard_EXPORT void UpdateFaceInfo (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME, const BOPCol_DataMapOfIntegerInteger& theDMV);
273
274
275 //! Updates tolerance of vertex with index <nV>
276 //! to make it interfere with edge
277 Standard_EXPORT void ForceInterfVE (const Standard_Integer nV, Handle(BOPDS_PaveBlock)& aPB, BOPDS_MapOfPaveBlock& aMPB);
278
279
280 //! Updates tolerance of vertex with index <nV>
281 //! to make it interfere with face with index <nF>
282 Standard_EXPORT Standard_Boolean ForceInterfVF (const Standard_Integer nV, const Standard_Integer nF);
283
284
285 //! Checks if there are any common or intersecting sub shapes
286 //! between two planar faces.
287 Standard_EXPORT Standard_Boolean CheckPlanes (const Standard_Integer nF1, const Standard_Integer nF2) const;
288
289
290 //! Creates new edge from the edge nE with vertices nV1 and nV2
291 //! and returns the index of that new edge in the DS.
292 Standard_EXPORT Standard_Integer SplitEdge (const Standard_Integer nE, const Standard_Integer nV1, const Standard_Real aT1, const Standard_Integer nV2, const Standard_Real aT2);
293
294
295 //! Updates pave blocks which have the paves with indices contained
296 //! in the map <theDMI>.
297 Standard_EXPORT void UpdatePaveBlocks (const BOPCol_DataMapOfIntegerInteger& theDMI);
298
3510db62 299 //! Updates tolerance vertex nV due to V/E interference.
300 //! It always creates new vertex if nV is from arguments.
301 //! @return DS index of updated vertex.
302 Standard_EXPORT Standard_Integer UpdateVertex(const Standard_Integer nV,
303 const Standard_Real aTolNew);
304
305 Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
306
307 Standard_EXPORT void UpdateCommonBlocksWithSDVertices();
308
309 Standard_EXPORT void UpdateBlocksWithSharedVertices();
310
311 Standard_EXPORT Standard_Boolean EstimatePaveOnCurve(const Standard_Integer nV,
312 const BOPDS_Curve& theNC,
313 const Standard_Real theTolR3D);
314
315 Standard_EXPORT void UpdateEdgeTolerance(const Standard_Integer nE,
316 const Standard_Real aTolNew);
317
318 Standard_EXPORT void RemovePaveBlocks(const BOPCol_MapOfInteger theEdges);
319
320 Standard_EXPORT void CorrectToleranceOfSE();
42cf5bc1 321
322 BOPCol_ListOfShape myArguments;
323 BOPDS_PDS myDS;
324 BOPDS_PIterator myIterator;
325 Handle(IntTools_Context) myContext;
326 BOPAlgo_SectionAttribute mySectionAttribute;
327 Standard_Real myFuzzyValue;
3510db62 328 Standard_Boolean myNonDestructive;
329 Standard_Boolean myIsPrimary;
42cf5bc1 330
331
332private:
333
334
335
336
337
338};
339
340
341
342
343
344
345
346#endif // _BOPAlgo_PaveFiller_HeaderFile