0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_6.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
4e57c75e 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//
973c2be1 7// This file is part of Open CASCADE Technology software library.
4e57c75e 8//
d5f74e42 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
973c2be1 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.
4e57c75e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
4e57c75e 17
4e57c75e 18
42cf5bc1 19#include <Bnd_Box.hxx>
20#include <BOPAlgo_PaveFiller.hxx>
21#include <BOPAlgo_SectionAttribute.hxx>
22#include <BOPAlgo_Tools.hxx>
23#include <BOPCol_DataMapOfIntegerReal.hxx>
4e57c75e 24#include <BOPCol_DataMapOfShapeInteger.hxx>
4e57c75e 25#include <BOPCol_IndexedMapOfInteger.hxx>
42cf5bc1 26#include <BOPCol_ListOfInteger.hxx>
27#include <BOPCol_ListOfShape.hxx>
28#include <BOPCol_MapOfInteger.hxx>
a2098360 29#include <BOPCol_NCVector.hxx>
c7b59798 30#include <BOPCol_Parallel.hxx>
42cf5bc1 31#include <BOPDS_CommonBlock.hxx>
32#include <BOPDS_CoupleOfPaveBlocks.hxx>
4e57c75e 33#include <BOPDS_Curve.hxx>
42cf5bc1 34#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
35#include <BOPDS_DS.hxx>
4e57c75e 36#include <BOPDS_FaceInfo.hxx>
42cf5bc1 37#include <BOPDS_Interf.hxx>
38#include <BOPDS_Iterator.hxx>
39#include <BOPDS_ListOfPave.hxx>
40#include <BOPDS_ListOfPaveBlock.hxx>
4e57c75e 41#include <BOPDS_MapOfPaveBlock.hxx>
42#include <BOPDS_PaveBlock.hxx>
42cf5bc1 43#include <BOPDS_Point.hxx>
44#include <BOPDS_ShapeInfo.hxx>
4e57c75e 45#include <BOPDS_VectorOfCurve.hxx>
46#include <BOPDS_VectorOfPoint.hxx>
42cf5bc1 47#include <BOPTools_AlgoTools.hxx>
48#include <BOPTools_AlgoTools3D.hxx>
49#include <BRep_Builder.hxx>
50#include <BRep_Tool.hxx>
51#include <BRepAdaptor_Curve.hxx>
52#include <BRepAdaptor_Surface.hxx>
53#include <BRepBndLib.hxx>
54#include <BRepBuilderAPI_MakeVertex.hxx>
55#include <BRepTools.hxx>
56#include <Geom2d_Curve.hxx>
57#include <Geom_Curve.hxx>
58#include <GeomAPI_ProjectPointOnCurve.hxx>
59#include <GeomAPI_ProjectPointOnSurf.hxx>
60#include <gp_Pnt.hxx>
61#include <IntSurf_ListOfPntOn2S.hxx>
62#include <IntSurf_PntOn2S.hxx>
63#include <IntTools_Context.hxx>
64#include <IntTools_Curve.hxx>
65#include <IntTools_EdgeFace.hxx>
66#include <IntTools_FaceFace.hxx>
67#include <IntTools_PntOn2Faces.hxx>
68#include <IntTools_SequenceOfCurves.hxx>
69#include <IntTools_SequenceOfPntOn2Faces.hxx>
70#include <IntTools_ShrunkRange.hxx>
71#include <IntTools_Tools.hxx>
72#include <NCollection_IncAllocator.hxx>
73#include <Precision.hxx>
74#include <TopExp.hxx>
75#include <TopExp_Explorer.hxx>
76#include <TopoDS_Compound.hxx>
77#include <TopoDS_Edge.hxx>
78#include <TopoDS_Face.hxx>
79#include <TopoDS_Vertex.hxx>
4e57c75e 80
42cf5bc1 81//
b4109929 82static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
83 const BRepAdaptor_Surface& aBAS2,
4e57c75e 84 Standard_Real& aTolFF);
85
a2098360 86/////////////////////////////////////////////////////////////////////////
87//=======================================================================
88//class : BOPAlgo_FaceFace
89//purpose :
90//=======================================================================
36f4947b 91class BOPAlgo_FaceFace :
92 public IntTools_FaceFace,
93 public BOPAlgo_Algo {
94
a2098360 95 public:
36f4947b 96 DEFINE_STANDARD_ALLOC
97
98 BOPAlgo_FaceFace() :
99 IntTools_FaceFace(),
100 BOPAlgo_Algo(),
101 myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
a2098360 102 }
103 //
36f4947b 104 virtual ~BOPAlgo_FaceFace() {
a2098360 105 }
106 //
107 void SetIndices(const Standard_Integer nF1,
108 const Standard_Integer nF2) {
109 myIF1=nF1;
110 myIF2=nF2;
111 }
112 //
113 void Indices(Standard_Integer& nF1,
114 Standard_Integer& nF2) const {
115 nF1=myIF1;
116 nF2=myIF2;
117 }
118 //
119 void SetFaces(const TopoDS_Face& aF1,
120 const TopoDS_Face& aF2) {
121 myF1=aF1;
122 myF2=aF2;
123 }
124 //
125 const TopoDS_Face& Face1()const {
126 return myF1;
127 }
128 //
129 const TopoDS_Face& Face2()const {
130 return myF2;
131 }
132 //
133 void SetTolFF(const Standard_Real aTolFF) {
134 myTolFF=aTolFF;
135 }
136 //
137 Standard_Real TolFF() const{
138 return myTolFF;
139 }
140 //
36f4947b 141 virtual void Perform() {
142 BOPAlgo_Algo::UserBreak();
a2098360 143 IntTools_FaceFace::Perform(myF1, myF2);
144 }
145 //
146 protected:
147 Standard_Integer myIF1;
148 Standard_Integer myIF2;
149 Standard_Real myTolFF;
150 TopoDS_Face myF1;
151 TopoDS_Face myF2;
152};
153//
154//=======================================================================
155typedef BOPCol_NCVector
156 <BOPAlgo_FaceFace> BOPAlgo_VectorOfFaceFace;
157//
c7b59798 158typedef BOPCol_Functor
a2098360 159 <BOPAlgo_FaceFace,
160 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceFunctor;
161//
c7b59798 162typedef BOPCol_Cnt
a2098360 163 <BOPAlgo_FaceFaceFunctor,
164 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceCnt;
165/////////////////////////////////////////////////////////////////////////
4e57c75e 166//=======================================================================
167//function : PerformFF
168//purpose :
169//=======================================================================
7ff8f019 170void BOPAlgo_PaveFiller::PerformFF()
4e57c75e 171{
172 Standard_Integer iSize;
173 Standard_Boolean bValid;
174 //
175 myErrorStatus=0;
176 //
177 myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
178 iSize=myIterator->ExpectedLength();
179 if (!iSize) {
180 return;
181 }
182 //
183 Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone;
7ff8f019 184 Standard_Boolean bToSplit, bTangentFaces;
402bfe81 185 Standard_Integer nF1, nF2, aNbCurves, aNbPoints, i, aNbLP;
a2098360 186 Standard_Integer aNbFaceFace, k;
4e57c75e 187 Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF;
b4109929 188 BRepAdaptor_Surface aBAS1, aBAS2;
af4e6dab 189 BOPCol_MapOfInteger aMI;
a2098360 190 BOPAlgo_VectorOfFaceFace aVFaceFace;
4e57c75e 191 //
192 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
4e57c75e 193 aFFs.SetIncrement(iSize);
4e57c75e 194 //
195 bApp=mySectionAttribute.Approximation();
196 bCompC2D1=mySectionAttribute.PCurveOnS1();
197 bCompC2D2=mySectionAttribute.PCurveOnS2();
198 aApproxTol=1.e-7;
199 bToSplit = Standard_False;
200 //
201 for (; myIterator->More(); myIterator->Next()) {
202 myIterator->Value(nF1, nF2, bJustAdd);
203 if(bJustAdd) {
204 continue;
205 }
206 //
207 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
208 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
209 //
b4109929 210 aBAS1.Initialize(aF1, Standard_False);
211 aBAS2.Initialize(aF2, Standard_False);
212 //
213 if (aBAS1.GetType() == GeomAbs_Plane &&
214 aBAS2.GetType() == GeomAbs_Plane) {
215 Standard_Boolean bToIntersect;
216 //
af4e6dab 217 if (aMI.Add(nF1)) {
78c66ef1 218 myDS->UpdateFaceInfoOn(nF1);
219 myDS->UpdateFaceInfoIn(nF1);
af4e6dab 220 }
221 if (aMI.Add(nF2)) {
78c66ef1 222 myDS->UpdateFaceInfoOn(nF2);
223 myDS->UpdateFaceInfoIn(nF2);
af4e6dab 224 }
225 //
b4109929 226 bToIntersect = CheckPlanes(nF1, nF2);
227 if (!bToIntersect) {
228 myDS->AddInterf(nF1, nF2);
402bfe81 229 BOPDS_InterfFF& aFF=aFFs.Append1();
b4109929 230 aFF.SetIndices(nF1, nF2);
231 aFF.Init(0, 0);
232 continue;
233 }
234 }
235 //
a2098360 236 ToleranceFF(aBAS1, aBAS2, aTolFF);
237 //
238 BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1();
239 //
240 aFaceFace.SetIndices(nF1, nF2);
241 aFaceFace.SetFaces(aF1, aF2);
242 aFaceFace.SetTolFF(aTolFF);
4e57c75e 243 //
244 IntSurf_ListOfPntOn2S aListOfPnts;
245 GetEFPnts(nF1, nF2, aListOfPnts);
246 aNbLP = aListOfPnts.Extent();
247 if (aNbLP) {
248 aFaceFace.SetList(aListOfPnts);
249 }
a2098360 250 //
4e57c75e 251 aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol);
36f4947b 252 aFaceFace.SetProgressIndicator(myProgressIndicator);
a2098360 253 }//for (; myIterator->More(); myIterator->Next()) {
254 //
255 aNbFaceFace=aVFaceFace.Extent();
256 //======================================================
257 BOPAlgo_FaceFaceCnt::Perform(myRunParallel, aVFaceFace);
258 //======================================================
259 //
260 for (k=0; k < aNbFaceFace; ++k) {
261 BOPAlgo_FaceFace& aFaceFace=aVFaceFace(k);
262 //
263 aFaceFace.Indices(nF1, nF2);
264 aTolFF=aFaceFace.TolFF();
4e57c75e 265 //
266 bIsDone=aFaceFace.IsDone();
267 if (bIsDone) {
268 aTolR3D=aFaceFace.TolReached3d();
269 aTolR2D=aFaceFace.TolReached2d();
7ff8f019 270 bTangentFaces=aFaceFace.TangentFaces();
4e57c75e 271 //
4e57c75e 272 if (aTolR3D < aTolFF){
273 aTolR3D=aTolFF;
274 }
275 if (aTolR2D < 1.e-7){
276 aTolR2D=1.e-7;
277 }
278 //
279 aFaceFace.PrepareLines3D(bToSplit);
280 //
281 const IntTools_SequenceOfCurves& aCvsX=aFaceFace.Lines();
282 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFaceFace.Points();
283 //
284 aNbCurves=aCvsX.Length();
285 aNbPoints=aPntsX.Length();
286 //
955b3e71 287 if (aNbCurves || aNbPoints) {
288 myDS->AddInterf(nF1, nF2);
289 }
4e57c75e 290 //
402bfe81 291 BOPDS_InterfFF& aFF=aFFs.Append1();
4e57c75e 292 aFF.SetIndices(nF1, nF2);
293 //
294 aFF.SetTolR3D(aTolR3D);
295 aFF.SetTolR2D(aTolR2D);
7ff8f019 296 aFF.SetTangentFaces(bTangentFaces);
4e57c75e 297 //
298 // Curves, Points
299 aFF.Init(aNbCurves, aNbPoints);
300 //
301 // Curves
302 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
303 for (i=1; i<=aNbCurves; ++i) {
304 Bnd_Box aBox;
305 //
306 const IntTools_Curve& aIC=aCvsX(i);
307 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1e143abb 308 bValid=IntTools_Tools::CheckCurve(aC3D, aTolR3D, aBox);
4e57c75e 309 if (bValid) {
402bfe81 310 BOPDS_Curve& aNC=aVNC.Append1();
4e57c75e 311 aNC.SetCurve(aIC);
312 aNC.SetBox(aBox);
313 }
314 }
315 //
316 // Points
317 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
318 for (i=1; i<=aNbPoints; ++i) {
319 const IntTools_PntOn2Faces& aPi=aPntsX(i);
320 const gp_Pnt& aP=aPi.P1().Pnt();
321 //
402bfe81 322 BOPDS_Point& aNP=aVNP.Append1();
4e57c75e 323 aNP.SetPnt(aP);
324 }
325 //}// if (aNbCs || aNbPs)
326 }// if (bIsDone) {
327 else {// 904/L1
402bfe81 328 BOPDS_InterfFF& aFF=aFFs.Append1();
4e57c75e 329 aFF.SetIndices(nF1, nF2);
330 aNbCurves=0;
331 aNbPoints=0;
332 aFF.Init(aNbCurves, aNbPoints);
333 }
a2098360 334 }// for (k=0; k < aNbFaceFace; ++k) {
4e57c75e 335}
336//=======================================================================
337//function : MakeBlocks
338//purpose :
339//=======================================================================
78c66ef1 340void BOPAlgo_PaveFiller::MakeBlocks()
4e57c75e 341{
342 Standard_Integer aNbFF;
343 //
344 myErrorStatus=0;
345 //
346 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
347 aNbFF=aFFs.Extent();
348 if (!aNbFF) {
349 return;
350 }
351 //
352 Standard_Boolean bExist, bValid2D;
353 Standard_Integer i, nF1, nF2, aNbC, aNbP, j;
354 Standard_Integer nV1, nV2;
96a95605 355 Standard_Real aTolR3D, aT1, aT2, aTol;
4e57c75e 356 Handle(NCollection_IncAllocator) aAllocator;
357 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
358 TopoDS_Edge aES;
359 Handle(BOPDS_PaveBlock) aPBOut;
360 //
361 //-----------------------------------------------------scope f
362 aAllocator=new NCollection_IncAllocator();
363 //
3285a59a 364 BOPCol_ListOfInteger aLSE(aAllocator), aLBV(aAllocator);
4e57c75e 365 BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator),
366 aMVStick(100,aAllocator), aMVEF(100, aAllocator),
3285a59a 367 aMI(100, aAllocator);
decdfc94 368 BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
369 BOPDS_MapOfPaveBlock aMPBAdd(100, aAllocator);
4e57c75e 370 BOPDS_ListOfPaveBlock aLPB(aAllocator);
371 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMSCPB(100, aAllocator);
372 BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator);
78c66ef1 373 BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
b4109929 374 BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
78c66ef1 375 BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
3285a59a 376 BOPCol_DataMapOfIntegerListOfInteger aDMBV(100, aAllocator);
377 BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
4e57c75e 378 //
379 for (i=0; i<aNbFF; ++i) {
36f4947b 380 //
381 UserBreak();
382 //
4e57c75e 383 BOPDS_InterfFF& aFF=aFFs(i);
384 aFF.Indices(nF1, nF2);
385 //
386 BOPDS_VectorOfPoint& aVP=aFF.ChangePoints();
387 aNbP=aVP.Extent();
388 BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
389 aNbC=aVC.Extent();
390 if (!aNbP && !aNbC) {
391 continue;
392 }
393 //
394 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
395 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
396 //
397 aTolR3D=aFF.TolR3D();
4e57c75e 398 //
399 // Update face info
400 if (aMF.Add(nF1)) {
401 myDS->UpdateFaceInfoOn(nF1);
3285a59a 402 myDS->UpdateFaceInfoIn(nF1);
4e57c75e 403 }
404 if (aMF.Add(nF2)) {
405 myDS->UpdateFaceInfoOn(nF2);
3285a59a 406 myDS->UpdateFaceInfoIn(nF2);
4e57c75e 407 }
3285a59a 408 //
4e57c75e 409 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
410 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
411 //
412 aMVOnIn.Clear();
413 aMPBOnIn.Clear();
3285a59a 414 aDMBV.Clear();
b4109929 415 aMVTol.Clear();
4e57c75e 416 //
417 myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn);
418 myDS->SharedEdges(nF1, nF2, aLSE, aAllocator);
419
420 // 1. Treat Points
421 for (j=0; j<aNbP; ++j) {
422 TopoDS_Vertex aV;
423 BOPDS_CoupleOfPaveBlocks aCPB;
424 //
425 BOPDS_Point& aNP=aVP.ChangeValue(j);
426 const gp_Pnt& aP=aNP.Pnt();
427 //
428 bExist=IsExistingVertex(aP, aTolR3D, aMVOnIn);
429 if (!bExist) {
430 BOPTools_AlgoTools::MakeNewVertex(aP, aTolR3D, aV);
431 //
432 aCPB.SetIndexInterf(i);
433 aCPB.SetIndex(j);
434 aMSCPB.Add(aV, aCPB);
435 }
436 }
437 //
438 // 2. Treat Curves
439 aMVStick.Clear();
440 aMVEF.Clear();
78c66ef1 441 GetStickVertices(nF1, nF2, aMVStick, aMVEF, aMI);
4e57c75e 442 //
443 for (j=0; j<aNbC; ++j) {
444 BOPDS_Curve& aNC=aVC.ChangeValue(j);
445 const IntTools_Curve& aIC=aNC.Curve();
4e57c75e 446 // DEBt
447 aNC.InitPaveBlock1();
448 //
78c66ef1 449 PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol);
4e57c75e 450 //
78c66ef1 451 PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol);
7ff8f019 452 //904/F7
4e57c75e 453 if (aNbC == 1) {
78c66ef1 454 PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol);
4e57c75e 455 }
456 //
457 if (aIC.HasBounds()) {
3285a59a 458 aLBV.Clear();
459 //
460 PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aLBV);
461 //
462 if (!aLBV.IsEmpty()) {
463 aDMBV.Bind(j, aLBV);
464 }
4e57c75e 465 }
466 }//for (j=0; j<aNbC; ++j) {
467 //
468 // Put closing pave if needed
469 for (j=0; j<aNbC; ++j) {
470 BOPDS_Curve& aNC=aVC.ChangeValue(j);
471 PutClosingPaveOnCurve (aNC);
472 }
473 //
474 // 3. Make section edges
475 for (j=0; j<aNbC; ++j) {
476 BOPDS_Curve& aNC=aVC.ChangeValue(j);
477 const IntTools_Curve& aIC=aNC.Curve();
478 //
479 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
480 Handle(BOPDS_PaveBlock)& aPB1=aNC.ChangePaveBlock1();
481 //
482 aLPB.Clear();
483 aPB1->Update(aLPB, Standard_False);
484 //
485 aItLPB.Initialize(aLPB);
486 for (; aItLPB.More(); aItLPB.Next()) {
487 Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue();
488 aPB->Indices(nV1, nV2);
489 aPB->Range (aT1, aT2);
490 //
491 if (fabs(aT1 - aT2) < Precision::PConfusion()) {
492 continue;
493 }
494 //
465d1fba 495 bValid2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC,
496 aF1, aF2, aTolR3D);
4e57c75e 497 if (!bValid2D) {
498 continue;
499 }
500 //
501 bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aLSE);
502 if (bExist) {
503 continue;
504 }
505 //
506 bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aMPBOnIn, aPBOut);
507 if (bExist) {
508 if (aMPBAdd.Add(aPBOut)) {
509 Standard_Boolean bInBothFaces = Standard_True;
5a77460e 510 if (!myDS->IsCommonBlock(aPBOut)) {
4e57c75e 511 Standard_Integer nE;
512 Standard_Real aTolE;
513 //
514 nE = aPBOut->Edge();
515 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
516 aTolE = BRep_Tool::Tolerance(aE);
517 if (aTolR3D > aTolE) {
518 myDS->UpdateEdgeTolerance(nE, aTolR3D);
519 }
520 bInBothFaces = Standard_False;
521 } else {
522 bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) ||
523 aFI1.PaveBlocksIn().Contains(aPBOut))&&
524 (aFI2.PaveBlocksOn().Contains(aPBOut) ||
525 aFI2.PaveBlocksIn().Contains(aPBOut));
526 }
527 if (!bInBothFaces) {
3285a59a 528 PreparePostTreatFF(i, j, aPBOut, aMSCPB, aMVI, aLPBC);
4e57c75e 529 }
530 }
531 continue;
532 }
533 //
534 // Make Edge
535 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
536 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
537 //
465d1fba 538 BOPTools_AlgoTools::MakeEdge (aIC, aV1, aT1,
539 aV2, aT2, aTolR3D, aES);
4e57c75e 540 BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC,
541 mySectionAttribute.PCurveOnS1(),
542 mySectionAttribute.PCurveOnS2());
543 //
544 if (BOPTools_AlgoTools::IsMicroEdge(aES, myContext)) {
545 continue;
546 }
547 //
548 // Append the Pave Block to the Curve j
549 aLPBC.Append(aPB);
550 //
551 // Keep info for post treatment
552 BOPDS_CoupleOfPaveBlocks aCPB;
553 aCPB.SetIndexInterf(i);
554 aCPB.SetIndex(j);
555 aCPB.SetPaveBlock1(aPB);
556 //
557 aMSCPB.Add(aES, aCPB);
558 aMVI.Bind(aV1, nV1);
559 aMVI.Bind(aV2, nV2);
b4109929 560 //
561 aMVTol.UnBind(nV1);
562 aMVTol.UnBind(nV2);
4e57c75e 563 }
564 //
565 aLPBC.RemoveFirst();
566 }//for (j=0; j<aNbC; ++j) {
b4109929 567 //back to previous tolerance values for unused vertices
568 aItMV.Initialize(aMVTol);
569 for (; aItMV.More(); aItMV.Next()) {
570 nV1 = aItMV.Key();
571 aTol = aItMV.Value();
572 //
573 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
465d1fba 574 const Handle(BRep_TVertex)& TV =
575 *((Handle(BRep_TVertex)*)&aV.TShape());
b4109929 576 TV->Tolerance(aTol);
577 }
578 //
3285a59a 579 ProcessExistingPaveBlocks(i, aMPBOnIn, aDMBV, aMSCPB, aMVI, aMPBAdd);
4e57c75e 580 }//for (i=0; i<aNbFF; ++i) {
581 //
582 // post treatment
78c66ef1 583 myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator);
4e57c75e 584 if (myErrorStatus) {
585 return;
586 }
587 //
588 // update face info
1b7ae951 589 UpdateFaceInfo(aDMExEdges, aDMI);
78c66ef1 590 //Update all pave blocks
591 UpdatePaveBlocks(aDMI);
4e57c75e 592 //-----------------------------------------------------scope t
593 aMF.Clear();
594 aMVStick.Clear();
595 aMPBOnIn.Clear();
596 aMVOnIn.Clear();
597 aDMExEdges.Clear();
78c66ef1 598 aMI.Clear();
599 aDMI.Clear();
4e57c75e 600 aAllocator.Nullify();
601}
602
603//=======================================================================
604//function : PostTreatFF
605//purpose :
606//=======================================================================
a942f2da 607Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
4e57c75e 608 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
609 BOPCol_DataMapOfShapeInteger& aMVI,
610 BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
78c66ef1 611 BOPCol_DataMapOfIntegerInteger& aDMI,
4e57c75e 612 Handle(NCollection_BaseAllocator)& theAllocator)
613{
614 Standard_Integer iRet, aNbS;
615 //
616 iRet=0;
617 aNbS=theMSCPB.Extent();
618 if (!aNbS) {
619 return iRet;
620 }
621 //
622 Standard_Boolean bHasPaveBlocks, bOld;
1d47d8d0 623 Standard_Integer iErr, nSx, nVSD, iX, iP, iC, j, nV, iV = 0, iE, k;
af4e6dab 624 Standard_Integer jx, aNbLPBx;
4e57c75e 625 Standard_Real aT;
4e57c75e 626 TopAbs_ShapeEnum aType;
627 TopoDS_Shape aV, aE;
628 BOPCol_ListIteratorOfListOfShape aItLS;
629 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
630 BOPDS_PDS aPDS;
631 Handle(BOPDS_PaveBlock) aPB1;
632 BOPDS_Pave aPave[2], aPave1[2];
633 BOPDS_ShapeInfo aSI;
634 //
635 BOPCol_ListOfShape aLS(theAllocator);
636 BOPAlgo_PaveFiller aPF(theAllocator);
637 //
638 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
639 //
4e57c75e 640 // 0
641 if (aNbS==1) {
642 const TopoDS_Shape& aS=theMSCPB.FindKey(1);
643 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromIndex(1);
644
645 //
646 aType=aS.ShapeType();
647 if (aType==TopAbs_VERTEX) {
648 aSI.SetShapeType(aType);
649 aSI.SetShape(aS);
650 iV=myDS->Append(aSI);
651 //
652 iX=aCPB.IndexInterf();
653 iP=aCPB.Index();
654 BOPDS_InterfFF& aFF=aFFs(iX);
655 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
656 BOPDS_Point& aNP=aVNP(iP);
657 aNP.SetIndex(iV);
658 }
659 else if (aType==TopAbs_EDGE) {
660 aPB1=aCPB.PaveBlock1();
661 //
662 if (aPB1->HasEdge()) {
663 BOPDS_ListOfPaveBlock aLPBx;
664 aLPBx.Append(aPB1);
665 aDMExEdges.Bind(aPB1, aLPBx);
666 } else {
667 aSI.SetShapeType(aType);
668 aSI.SetShape(aS);
669 iE=myDS->Append(aSI);
670 //
671 aPB1->SetEdge(iE);
672 }
673 }
674 return iRet;
675 }
676 //
677 // 1 prepare arguments
678 for (k=1; k<=aNbS; ++k) {
679 const TopoDS_Shape& aS=theMSCPB.FindKey(k);
680 aLS.Append(aS);
681 }
682 //
683 // 2 Fuse shapes
36f4947b 684 aPF.SetProgressIndicator(myProgressIndicator);
a942f2da 685 aPF.SetRunParallel(myRunParallel);
4e57c75e 686 aPF.SetArguments(aLS);
687 aPF.Perform();
688 iErr=aPF.ErrorStatus();
689 if (iErr) {
4e57c75e 690 return iRet;
691 }
692 aPDS=aPF.PDS();
693 //
694 aItLS.Initialize(aLS);
695 for (; aItLS.More(); aItLS.Next()) {
696 const TopoDS_Shape& aSx=aItLS.Value();
697 nSx=aPDS->Index(aSx);
698 const BOPDS_ShapeInfo& aSIx=aPDS->ShapeInfo(nSx);
699 //
700 aType=aSIx.ShapeType();
701 //
702 if (aType==TopAbs_VERTEX) {
703 if (aPDS->HasShapeSD(nSx, nVSD)) {
704 aV=aPDS->Shape(nVSD);
705 }
706 else {
707 aV=aSx;
708 }
709 // index of new vertex in theDS -> iV
710 if (!aMVI.IsBound(aV)) {
711 aSI.SetShapeType(aType);
712 aSI.SetShape(aV);
713 iV=myDS->Append(aSI);
714 //
715 aMVI.Bind(aV, iV);
716 }
717 else {
718 iV=aMVI.Find(aV);
719 }
720 // update FF interference
721 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
722 iX=aCPB.IndexInterf();
723 iP=aCPB.Index();
724 BOPDS_InterfFF& aFF=aFFs(iX);
725 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
726 BOPDS_Point& aNP=aVNP(iP);
727 aNP.SetIndex(iV);
728 }//if (aType==TopAbs_VERTEX) {
729 //
730 else if (aType==TopAbs_EDGE) {
731 bHasPaveBlocks=aPDS->HasPaveBlocks(nSx);
732 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
733 iX=aCPB.IndexInterf();
734 iC=aCPB.Index();
735 aPB1=aCPB.PaveBlock1();
736 //
737 bOld = aPB1->HasEdge();
738 if (bOld) {
739 BOPDS_ListOfPaveBlock aLPBx;
740 aDMExEdges.Bind(aPB1, aLPBx);
741 }
742 //
743 if (!bHasPaveBlocks) {
744 if (bOld) {
745 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
1b7ae951 746 }
747 else {
4e57c75e 748 aSI.SetShapeType(aType);
749 aSI.SetShape(aSx);
750 iE=myDS->Append(aSI);
751 //
752 aPB1->SetEdge(iE);
753 }
754 }
755 else {
756 BOPDS_InterfFF& aFF=aFFs(iX);
757 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
758 BOPDS_Curve& aNC=aVNC(iC);
759 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
760 //
761 const BOPDS_ListOfPaveBlock& aLPBx=aPDS->PaveBlocks(nSx);
762 aNbLPBx=aLPBx.Extent();
763 //
764 if (bOld && !aNbLPBx) {
765 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
766 continue;
767 }
768 //
769 if (!bOld) {
770 aItLPB.Initialize(aLPBC);
771 for (; aItLPB.More(); aItLPB.Next()) {
772 const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value();
773 if (aPBC==aPB1) {
774 aLPBC.Remove(aItLPB);
775 break;
776 }
777 }
778 }
779 //
780 if (!aNbLPBx) {
781 aE=aSx;
782 //
783 if (!aMVI.IsBound(aE)) {
784 aSI.SetShapeType(aType);
785 aSI.SetShape(aE);
786 iE=myDS->Append(aSI);
787 aMVI.Bind(aE, iE);
788 }
789 else {
790 iE=aMVI.Find(aE);
791 }
792 // append new PaveBlock to aLPBC
4e57c75e 793 aPB1->SetEdge(iE);
794 aLPBC.Append(aPB1);
795 } // if (!aNbLPBx) {
796 //
797 else {
798 aItLPB.Initialize(aLPBx);
799 if (bOld) {
800 aPave1[0] = aPB1->Pave1();
801 aPave1[1] = aPB1->Pave2();
802 }
803 for (; aItLPB.More(); aItLPB.Next()) {
804 const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
5a77460e 805 const Handle(BOPDS_PaveBlock) aPBRx=aPDS->RealPaveBlock(aPBx);
4e57c75e 806 //
807 // update vertices of paves
808 aPave[0]=aPBx->Pave1();
809 aPave[1]=aPBx->Pave2();
810 for (j=0; j<2; ++j) {
811 jx = 0;
812 if (bOld) {
813 aT = aPave[j].Parameter();
814 if (aT == aPave1[0].Parameter()) {
815 jx = 1;
816 } else if (aT == aPave1[1].Parameter()) {
817 jx = 2;
818 }
819 //
820 if (jx) {
821 iV = aPave1[jx-1].Index();
822 }
823 }
824 if (!jx) {
825 nV=aPave[j].Index();
826 aV=aPDS->Shape(nV);
827 //
465d1fba 828 if (!aMVI.IsBound(aV)) {
829 // index of new vertex in theDS -> iV
4e57c75e 830 aSI.SetShapeType(TopAbs_VERTEX);
831 aSI.SetShape(aV);
832 iV=myDS->Append(aSI);
833 aMVI.Bind(aV, iV);
834 }
835 else {
836 iV=aMVI.Find(aV);
837 }
838 }
78c66ef1 839 const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
465d1fba 840 if (aP1.Parameter() == aPave[j].Parameter() &&
841 aP1.Index() != iV) {
78c66ef1 842 aDMI.Bind(aP1.Index(), iV);
6a43d224 843 myDS->AddShapeSD(aP1.Index(), iV);
78c66ef1 844 }
845 //
4e57c75e 846 aPave[j].SetIndex(iV);
847 }
848 //
849 // add edge
850 aE=aPDS->Shape(aPBRx->Edge());
851 //
852 if (!aMVI.IsBound(aE)) {
853 aSI.SetShapeType(aType);
854 aSI.SetShape(aE);
855 iE=myDS->Append(aSI);
856 aMVI.Bind(aE, iE);
857 }
858 else {
859 iE=aMVI.Find(aE);
860 }
861 // append new PaveBlock to aLPBC
862 Handle(BOPDS_PaveBlock) aPBC=new BOPDS_PaveBlock();
863 //
864 aPBC->SetPave1(aPave[0]);
865 aPBC->SetPave2(aPave[1]);
866 aPBC->SetEdge(iE);
867 if (bOld) {
868 aPBC->SetOriginalEdge(aPB1->OriginalEdge());
869 aDMExEdges.ChangeFind(aPB1).Append(aPBC);
870 }
871 else {
872 aLPBC.Append(aPBC);
873 }
874 }
875 }
876 }
877 }//else if (aType==TopAbs_EDGE)
878 }//for (; aItLS.More(); aItLS.Next()) {
879 return iRet;
880}
881
882//=======================================================================
883//function : UpdateFaceInfo
884//purpose :
885//=======================================================================
465d1fba 886void BOPAlgo_PaveFiller::UpdateFaceInfo
1b7ae951 887 (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME,
888 const BOPCol_DataMapOfIntegerInteger& theDMV)
4e57c75e 889{
890 Standard_Integer i, j, nV1, nF1, nF2,
1b7ae951 891 aNbFF, aNbC, aNbP;
4e57c75e 892 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1b7ae951 893 BOPCol_MapOfInteger aMF;
4e57c75e 894 //
895 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
896 aNbFF=aFFs.Extent();
897 //
898 //1. Sections (curves, points);
899 for (i=0; i<aNbFF; ++i) {
900 BOPDS_InterfFF& aFF=aFFs(i);
901 aFF.Indices(nF1, nF2);
902 //
903 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
904 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
905 //
1b7ae951 906 // 1.1. Section edges
4e57c75e 907 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
908 aNbC=aVNC.Extent();
909 for (j=0; j<aNbC; ++j) {
910 BOPDS_Curve& aNC=aVNC(j);
911 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
4e57c75e 912 //
1b7ae951 913 // Add section edges to face info
3285a59a 914 aItLPB.Initialize(aLPBC);
915 for (; aItLPB.More(); ) {
4e57c75e 916 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
3285a59a 917 //
918 // Treat existing pave blocks
919 if (theDME.IsBound(aPB)) {
920 BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
921 UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
922 aLPBC.Remove(aItLPB);
923 continue;
924 }
925 //
4e57c75e 926 aFI1.ChangePaveBlocksSc().Add(aPB);
927 aFI2.ChangePaveBlocksSc().Add(aPB);
3285a59a 928 aItLPB.Next();
4e57c75e 929 }
930 }
1b7ae951 931 //
932 // 1.2. Section vertices
4e57c75e 933 const BOPDS_VectorOfPoint& aVNP=aFF.Points();
934 aNbP=aVNP.Extent();
935 for (j=0; j<aNbP; ++j) {
936 const BOPDS_Point& aNP=aVNP(j);
937 nV1=aNP.Index();
85915310 938 if (nV1<0) {
939 continue;
940 }
4e57c75e 941 aFI1.ChangeVerticesSc().Add(nV1);
942 aFI2.ChangeVerticesSc().Add(nV1);
943 }
1b7ae951 944 //
945 aMF.Add(nF1);
946 aMF.Add(nF2);
4e57c75e 947 }
948 //
1b7ae951 949 Standard_Boolean bVerts, bEdges;
950 //
951 bVerts = theDMV.Extent() > 0;
952 bEdges = theDME.Extent() > 0;
953 //
954 if (!bVerts && !bEdges) {
4e57c75e 955 return;
956 }
957 //
1b7ae951 958 // 2. Update Face Info information with new vertices and new
959 // pave blocks created in PostTreatFF from existing ones
960 Standard_Integer nV2, aNbPB;
961 BOPCol_MapIteratorOfMapOfInteger aItMF;
962 BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItMV;
963 //
964 aItMF.Initialize(aMF);
965 for (; aItMF.More(); aItMF.Next()) {
966 nF1 = aItMF.Value();
4e57c75e 967 //
1b7ae951 968 BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(nF1);
4e57c75e 969 //
1b7ae951 970 // 2.1. Update information about vertices
971 if (bVerts) {
972 BOPCol_MapOfInteger& aMVOn = aFI.ChangeVerticesOn();
973 BOPCol_MapOfInteger& aMVIn = aFI.ChangeVerticesIn();
974 //
975 aItMV.Initialize(theDMV);
976 for (; aItMV.More(); aItMV.Next()) {
977 nV1 = aItMV.Key();
978 nV2 = aItMV.Value();
979 //
980 if (aMVOn.Remove(nV1)) {
981 aMVOn.Add(nV2);
4e57c75e 982 }
1b7ae951 983 //
984 if (aMVIn.Remove(nV1)) {
985 aMVIn.Add(nV2);
986 }
987 } // for (; aItMV.More(); aItMV.Next()) {
988 } // if (bVerts) {
989 //
990 // 2.2. Update information about pave blocks
991 if (bEdges) {
992 BOPDS_IndexedMapOfPaveBlock& aMPBOn = aFI.ChangePaveBlocksOn();
993 BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.ChangePaveBlocksIn();
994 //
995 BOPDS_IndexedMapOfPaveBlock aMPBCopy;
996 for (i = 0; i < 2; ++i) {
997 BOPDS_IndexedMapOfPaveBlock& aMPBOnIn = !i ? aMPBOn : aMPBIn;
998 aMPBCopy = aMPBOnIn;
999 aMPBOnIn.Clear();
1000 //
1001 aNbPB = aMPBCopy.Extent();
1002 for (j = 1; j <= aNbPB; ++j) {
1003 const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
1004 if (theDME.IsBound(aPB)) {
1005 const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
3285a59a 1006 if (aLPB.IsEmpty()) {
1007 aMPBOnIn.Add(aPB);
1008 continue;
1009 }
1010 //
1b7ae951 1011 aItLPB.Initialize(aLPB);
1012 for (; aItLPB.More(); aItLPB.Next()) {
1013 const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
1014 aMPBOnIn.Add(aPB1);
1015 }
1016 }
1017 else {
1018 aMPBOnIn.Add(aPB);
1019 }
1020 } // for (j = 1; j <= aNbPB; ++j) {
1021 } // for (i = 0; i < 2; ++i) {
1022 } // if (bEdges) {
1023 }
4e57c75e 1024}
4e57c75e 1025//=======================================================================
1026//function : IsExistingVertex
1027//purpose :
1028//=======================================================================
1029 Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
1030 (const gp_Pnt& aP,
1031 const Standard_Real theTolR3D,
1032 const BOPCol_MapOfInteger& aMVOnIn)const
1033{
1034 Standard_Boolean bRet;
1035 Standard_Integer nV, iFlag;
1036 Standard_Real aTolV;
1037 gp_Pnt aPV;
1038 Bnd_Box aBoxP;
1039 BOPCol_MapIteratorOfMapOfInteger aIt;
1040 //
1041 bRet=Standard_True;
1042 //
1043 aBoxP.Add(aP);
1044 aBoxP.Enlarge(theTolR3D);
1045 //
1046 aIt.Initialize(aMVOnIn);
1047 for (; aIt.More(); aIt.Next()) {
1048 Bnd_Box aBoxV;
1049 //
1050 nV=aIt.Value();
1051 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1052 aPV=BRep_Tool::Pnt(aV);
1053 aTolV=BRep_Tool::Tolerance(aV);
1054 aBoxV.Add(aP);
1055 aBoxV.Enlarge(aTolV);
1056 //
1057 if (!aBoxP.IsOut(aBoxV)) {
1058 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP, theTolR3D);
1059 if (!iFlag) {
1060 return bRet;
1061 }
1062 }
1063 }
1064 return !bRet;
1065}
1066//=======================================================================
1067//function : IsExistingPaveBlock
1068//purpose :
1069//=======================================================================
1070 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1071 (const Handle(BOPDS_PaveBlock)& thePB,
1072 const BOPDS_Curve& theNC,
1073 const Standard_Real theTolR3D,
1074 const BOPCol_ListOfInteger& theLSE)
1075{
1076 Standard_Boolean bRet=Standard_True;
1077 //
1078 if (theLSE.IsEmpty()) {
1079 return !bRet;
1080 }
1081 //
1082 Standard_Real aT1, aT2, aTm, aTx, aTol;
1083 Standard_Integer nE, iFlag;
1084 gp_Pnt aPm;
1085 Bnd_Box aBoxPm;
1086 BOPCol_ListIteratorOfListOfInteger aItLI;
1087 //
1088 thePB->Range(aT1, aT2);
1089 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1090 theNC.Curve().D0(aTm, aPm);
1091 aBoxPm.Add(aPm);
1092 aBoxPm.Enlarge(theTolR3D);
1093 //
1094 aItLI.Initialize(theLSE);
1095 for (; aItLI.More(); aItLI.Next()) {
1096 nE=aItLI.Value();
1097 const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
1098 const Bnd_Box& aBoxE=aSIE.Box();
1099 if (!aBoxE.IsOut(aBoxPm)) {
1100 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
1101 aTol = BRep_Tool::Tolerance(aE);
1102 aTol = aTol > theTolR3D ? aTol : theTolR3D;
1103 iFlag=myContext->ComputePE(aPm, aTol, aE, aTx);
1104 if (!iFlag) {
1105 return bRet;
1106 }
1107 }
1108 }
1109 return !bRet;
1110}
1111
1112//=======================================================================
1113//function : IsExistingPaveBlock
1114//purpose :
1115//=======================================================================
1116 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1117 (const Handle(BOPDS_PaveBlock)& thePB,
1118 const BOPDS_Curve& theNC,
1119 const Standard_Real theTolR3D,
decdfc94 1120 const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn,
c04c30b3 1121 Handle(BOPDS_PaveBlock)& aPBOut)
4e57c75e 1122{
1123 Standard_Boolean bRet;
1124 Standard_Real aT1, aT2, aTm, aTx;
decdfc94 1125 Standard_Integer nSp, iFlag1, iFlag2, nV11, nV12, nV21, nV22, i, aNbPB;
4e57c75e 1126 gp_Pnt aP1, aPm, aP2;
1127 Bnd_Box aBoxP1, aBoxPm, aBoxP2;
4e57c75e 1128 //
78c66ef1 1129 bRet=Standard_False;
4e57c75e 1130 const IntTools_Curve& aIC=theNC.Curve();
1131 //
1132 thePB->Range(aT1, aT2);
1133 thePB->Indices(nV11, nV12);
1134 //first point
1135 aIC.D0(aT1, aP1);
1136 aBoxP1.Add(aP1);
1137 aBoxP1.Enlarge(theTolR3D);
1138 //intermediate point
1139 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1140 aIC.D0(aTm, aPm);
1141 aBoxPm.Add(aPm);
1142 aBoxPm.Enlarge(theTolR3D);
1143 //last point
1144 aIC.D0(aT2, aP2);
1145 aBoxP2.Add(aP2);
1146 aBoxP2.Enlarge(theTolR3D);
1147 //
decdfc94 1148 aNbPB = theMPBOnIn.Extent();
1149 for (i = 1; i <= aNbPB; ++i) {
1150 const Handle(BOPDS_PaveBlock)& aPB = theMPBOnIn(i);
4e57c75e 1151 aPB->Indices(nV21, nV22);
1152 nSp=aPB->Edge();
1153 const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp);
78c66ef1 1154 const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape()));
4e57c75e 1155 const Bnd_Box& aBoxSp=aSISp.Box();
78c66ef1 1156 //
465d1fba 1157 iFlag1 = (nV11 == nV21 || nV11 == nV22) ? 2 :
1158 (!aBoxSp.IsOut(aBoxP1) ? 1 : 0);
1159 iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 :
1160 (!aBoxSp.IsOut(aBoxP2) ? 1 : 0);
78c66ef1 1161 if (iFlag1 && iFlag2) {
465d1fba 1162 if (aBoxSp.IsOut(aBoxPm) || myContext->ComputePE(aPm,
1163 theTolR3D,
1164 aSp,
1165 aTx)) {
78c66ef1 1166 continue;
1167 }
1168 //
1169 if (iFlag1 == 1) {
1170 iFlag1 = !myContext->ComputePE(aP1, theTolR3D, aSp, aTx);
1171 }
1172 //
1173 if (iFlag2 == 1) {
1174 iFlag2 = !myContext->ComputePE(aP2, theTolR3D, aSp, aTx);
1175 }
1176 //
1177 if (iFlag1 && iFlag2) {
1178 aPBOut = aPB;
1179 bRet=Standard_True;
1180 break;
4e57c75e 1181 }
1182 }
1183 }
78c66ef1 1184 return bRet;
4e57c75e 1185}
4e57c75e 1186//=======================================================================
1187//function : PutBoundPaveOnCurve
1188//purpose :
1189//=======================================================================
1190 void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
1191 const TopoDS_Face& aF2,
1192 const Standard_Real aTolR3D,
1193 BOPDS_Curve& aNC,
3285a59a 1194 BOPCol_ListOfInteger& aLVB)
4e57c75e 1195{
1196 Standard_Boolean bVF;
1197 Standard_Integer nV, iFlag, nVn, j, aNbEP;
1198 Standard_Real aT[2], aTmin, aTmax, aTV, aTol, aTolVnew;
1199 gp_Pnt aP[2];
1200 TopoDS_Vertex aVn;
1201 BOPDS_ListIteratorOfListOfPave aItLP;
1202 BOPDS_Pave aPn, aPMM[2];
1203 //
1204 aTolVnew = Precision::Confusion();
1205 //
1206 const IntTools_Curve& aIC=aNC.Curve();
1207 aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
1208 //
1209 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1210 const BOPDS_ListOfPave& aLP=aPB->ExtPaves();
1211 //
1212 aNbEP=aLP.Extent();
1213 if (aNbEP) {
1214 aTmin=1.e10;
1215 aTmax=-aTmin;
1216 //
1217 aItLP.Initialize(aLP);
1218 for (; aItLP.More(); aItLP.Next()) {
1219 const BOPDS_Pave& aPv=aItLP.Value();
1220 aPv.Contents(nV, aTV);
1221 if (aTV<aTmin) {
1222 aPMM[0]=aPv;
1223 aTmin=aTV;
1224 }
1225 if (aTV>aTmax) {
1226 aPMM[1]=aPv;
1227 aTmax=aTV;
1228 }
1229 }
1230 }
1231 //
1232 for (j=0; j<2; ++j) {
1233 //if curve is closed, process only one bound
1234 if (j && aP[1].IsEqual(aP[0], aTolVnew)) {
1235 continue;
1236 }
1237 //
1238 iFlag=1;
1239 //
1240 if (aNbEP) {
1241 Bnd_Box aBoxP;
1242 //
1243 aBoxP.Set(aP[j]);
1244 aTol = aTolR3D+Precision::Confusion();
1245 aBoxP.Enlarge(aTol);
1246 const BOPDS_Pave& aPV=aPMM[j];
1247 nV=aPV.Index();
1248 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1249 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape()));
1250 const Bnd_Box& aBoxV=aSIV.Box();
1251 if (!aBoxP.IsOut(aBoxV)){
1252 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol);
1253 }
1254 }
1255 if (iFlag) {
1256 // 900/L5
1257 bVF=myContext->IsValidPointForFaces (aP[j], aF1, aF2, aTolR3D);
1258 if (!bVF) {
1259 continue;
1260 }
1261 //
1262 BOPDS_ShapeInfo aSIVn;
1263 //
1264 BOPTools_AlgoTools::MakeNewVertex(aP[j], aTolR3D, aVn);
1265 aSIVn.SetShapeType(TopAbs_VERTEX);
1266 aSIVn.SetShape(aVn);
1267 //
1268 nVn=myDS->Append(aSIVn);
1269 //
1270 aPn.SetIndex(nVn);
1271 aPn.SetParameter(aT[j]);
1272 aPB->AppendExtPave(aPn);
1273 //
1274 aVn=(*(TopoDS_Vertex *)(&myDS->Shape(nVn)));
1275 BOPTools_AlgoTools::UpdateVertex (aIC, aT[j], aVn);
1276 //
1277 aTolVnew = BRep_Tool::Tolerance(aVn);
1278 //
1279 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
1280 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
1281 BRepBndLib::Add(aVn, aBoxDS);
3285a59a 1282 //
1283 aLVB.Append(nVn);
4e57c75e 1284 }
1285 }
1286}
1287
1288//=======================================================================
78c66ef1 1289//function : PutPavesOnCurve
4e57c75e 1290//purpose :
1291//=======================================================================
465d1fba 1292 void BOPAlgo_PaveFiller::PutPavesOnCurve
1293 (const BOPCol_MapOfInteger& aMVOnIn,
1294 const Standard_Real aTolR3D,
1295 BOPDS_Curve& aNC,
1296 const Standard_Integer nF1,
1297 const Standard_Integer nF2,
1298 const BOPCol_MapOfInteger& aMI,
1299 const BOPCol_MapOfInteger& aMVEF,
1300 BOPCol_DataMapOfIntegerReal& aMVTol)
4e57c75e 1301{
78c66ef1 1302 Standard_Boolean bInBothFaces;
4e57c75e 1303 Standard_Integer nV;
4e57c75e 1304 BOPCol_MapIteratorOfMapOfInteger aIt;
1305 //
4e57c75e 1306 const Bnd_Box& aBoxC=aNC.Box();
1307 //
78c66ef1 1308 //Put EF vertices first
1309 aIt.Initialize(aMVEF);
1310 for (; aIt.More(); aIt.Next()) {
1311 nV=aIt.Value();
1312 PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2);
1313 }
1314 //Put all other vertices
4e57c75e 1315 aIt.Initialize(aMVOnIn);
1316 for (; aIt.More(); aIt.Next()) {
1317 nV=aIt.Value();
78c66ef1 1318 if (aMVEF.Contains(nV)) {
1319 continue;
4e57c75e 1320 }
1321 //
78c66ef1 1322 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1323 const Bnd_Box& aBoxV=aSIV.Box();
4e57c75e 1324 //
78c66ef1 1325 if (aBoxC.IsOut(aBoxV)){
1326 continue;
1327 }
1328 if (!myDS->IsNewShape(nV)) {
1329 const BOPDS_FaceInfo& aFI1 = myDS->FaceInfo(nF1);
1330 const BOPDS_FaceInfo& aFI2 = myDS->FaceInfo(nF2);
b4109929 1331 //
78c66ef1 1332 bInBothFaces = (aFI1.VerticesOn().Contains(nV) ||
1333 aFI1.VerticesIn().Contains(nV))&&
1334 (aFI2.VerticesOn().Contains(nV) ||
1335 aFI2.VerticesIn().Contains(nV));
1336 if (!bInBothFaces) {
1337 continue;
b4109929 1338 }
4e57c75e 1339 }
78c66ef1 1340 //
1341 PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1);
4e57c75e 1342 }
1343}
1344
1345//=======================================================================
1346//function : ExtendedTolerance
1347//purpose :
1348//=======================================================================
465d1fba 1349Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance
1350 (const Standard_Integer nV,
1351 const BOPCol_MapOfInteger& aMI,
1352 Standard_Real& aTolVExt,
1353 const Standard_Integer aType)
4e57c75e 1354{
1355 Standard_Boolean bFound = Standard_False;
1356 if (!(myDS->IsNewShape(nV))) {
1357 return bFound;
1358 }
78c66ef1 1359 //
1360 Standard_Integer i, k, aNbLines, aNbInt;
4e57c75e 1361 Standard_Real aT11, aT12, aD1, aD2, aD;
1362 TopoDS_Vertex aV;
1363 gp_Pnt aPV, aP11, aP12;
78c66ef1 1364 //
1365 k = 0;
1366 aNbInt = 2;
1367 if (aType == 1) {
1368 aNbInt = 1;
1369 } else if (aType == 2) {
1370 k = 1;
1371 }
1372 //
4e57c75e 1373 aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1374 aPV=BRep_Tool::Pnt(aV);
1375 //
1376 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
1377 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
78c66ef1 1378 //
1379 for (; k<aNbInt; ++k) {
4e57c75e 1380 aNbLines = !k ? aEEs.Extent() : aEFs.Extent();
1381 for (i = 0; i < aNbLines; ++i) {
1382 BOPDS_Interf *aInt = !k ? (BOPDS_Interf*) (&aEEs(i)) :
78c66ef1 1383 (BOPDS_Interf*) (&aEFs(i));
4e57c75e 1384 if (aInt->IndexNew() == nV) {
465d1fba 1385 if (aMI.Contains(aInt->Index1()) &&
1386 aMI.Contains(aInt->Index2())) {
4e57c75e 1387 const IntTools_CommonPrt& aComPrt = !k ? aEEs(i).CommonPart() :
78c66ef1 1388 aEFs(i).CommonPart();
4e57c75e 1389 //
1390 const TopoDS_Edge& aE1=aComPrt.Edge1();
1391 aComPrt.Range1(aT11, aT12);
1392 BOPTools_AlgoTools::PointOnEdge(aE1, aT11, aP11);
1393 BOPTools_AlgoTools::PointOnEdge(aE1, aT12, aP12);
1394 aD1=aPV.Distance(aP11);
1395 aD2=aPV.Distance(aP12);
1396 aD=(aD1>aD2)? aD1 : aD2;
1397 if (aD>aTolVExt) {
1398 aTolVExt=aD;
1399 }
1400 return !bFound;
1401 }//if (aMI.Contains(aEF.Index1()) && aMI.Contains(aEF.Index2())) {
1402 }//if (aInt->IndexNew() == nV) {
1403 }//for (i = 0; i < aNbLines; ++i) {
1404 }//for (k=0; k<2; ++k) {
4e57c75e 1405 return bFound;
1406}
1407
1408//=======================================================================
1409//function : GetEFPnts
1410//purpose :
1411//=======================================================================
1412 void BOPAlgo_PaveFiller::GetEFPnts(const Standard_Integer nF1,
1413 const Standard_Integer nF2,
1414 IntSurf_ListOfPntOn2S& aListOfPnts)
1415{
1416 Standard_Integer nE, nF, nFOpposite, aNbEFs, i;
1417 Standard_Real U1, U2, V1, V2, f, l;
78c66ef1 1418 BOPCol_MapOfInteger aMI;
4e57c75e 1419 //
1420 //collect indexes of all shapes from nF1 and nF2.
78c66ef1 1421 GetFullShapeMap(nF1, aMI);
1422 GetFullShapeMap(nF2, aMI);
4e57c75e 1423 //
1424 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1425 aNbEFs = aEFs.Extent();
1426 //
1427 for(i = 0; i < aNbEFs; ++i) {
1428 const BOPDS_InterfEF& aEF = aEFs(i);
78c66ef1 1429 if (aEF.HasIndexNew()) {
1430 aEF.Indices(nE, nFOpposite);
1431 if(aMI.Contains(nE) && aMI.Contains(nFOpposite)) {
1432 const IntTools_CommonPrt& aCP = aEF.CommonPart();
4e57c75e 1433 Standard_Real aPar = aCP.VertexParameter1();
1434 const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE)));
465d1fba 1435 const TopoDS_Face& aFOpposite =
1436 (*(TopoDS_Face*)(&myDS->Shape(nFOpposite)));
4e57c75e 1437 //
1438 const Handle(Geom_Curve)& aCurve = BRep_Tool::Curve(aE, f, l);
1439 //
1440 nF = (nFOpposite == nF1) ? nF2 : nF1;
1441 const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF)));
465d1fba 1442 Handle(Geom2d_Curve) aPCurve =
1443 BRep_Tool::CurveOnSurface(aE, aF, f, l);
4e57c75e 1444 //
465d1fba 1445 GeomAPI_ProjectPointOnSurf& aProj=myContext->ProjPS(aFOpposite);
4e57c75e 1446 //
1447 gp_Pnt aPoint;
1448 aCurve->D0(aPar, aPoint);
1449 IntSurf_PntOn2S aPnt;
1450 if(!aPCurve.IsNull()) {
1451 gp_Pnt2d aP2d = aPCurve->Value(aPar);
1452 aProj.Perform(aPoint);
1453 if(aProj.IsDone()) {
1454 aProj.LowerDistanceParameters(U1,V1);
1455 if (nF == nF1) {
1456 aPnt.SetValue(aP2d.X(),aP2d.Y(),U1,V1);
1457 } else {
1458 aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y());
1459 }
1460 aListOfPnts.Append(aPnt);
1461 }
1462 }
1463 else {
1464 GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF);
1465 aProj1.Perform(aPoint);
1466 aProj.Perform(aPoint);
1467 if(aProj1.IsDone() && aProj.IsDone()){
1468 aProj1.LowerDistanceParameters(U1,V1);
1469 aProj.LowerDistanceParameters(U2,V2);
1470 if (nF == nF1) {
1471 aPnt.SetValue(U1,V1,U2,V2);
1472 } else {
1473 aPnt.SetValue(U2,V2,U1,V1);
1474 }
1475 aListOfPnts.Append(aPnt);
1476 }
1477 }
1478 }
1479 }
1480 }
1481}
1482
1483//=======================================================================
1484//function : ProcessUnUsedVertices
1485//purpose :
1486//=======================================================================
465d1fba 1487 void BOPAlgo_PaveFiller::PutEFPavesOnCurve
1488 (BOPDS_Curve& aNC,
1489 const BOPCol_MapOfInteger& aMI,
1490 const BOPCol_MapOfInteger& aMVEF,
1491 BOPCol_DataMapOfIntegerReal& aMVTol)
4e57c75e 1492{
1493 if (!aMVEF.Extent()) {
1494 return;
1495 }
1496 //
1497 const IntTools_Curve& aIC=aNC.Curve();
1498 GeomAbs_CurveType aTypeC;
1499 aTypeC=aIC.Type();
1500 if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) {
1501 return;
1502 }
1503 //
1504 Standard_Integer nV;
1505 BOPCol_MapOfInteger aMV;
1506 //
1507 aMV.Assign(aMVEF);
1508 RemoveUsedVertices(aNC, aMV);
1509 if (!aMV.Extent()) {
1510 return;
1511 }
1512 //
1513 Standard_Real aDist;
1514 BOPDS_Pave aPave;
1515 //
1516 const Handle(Geom_Curve)& aC3D=aIC.Curve();
4e57c75e 1517 GeomAPI_ProjectPointOnCurve& aProjPT = myContext->ProjPT(aC3D);
78c66ef1 1518 //
4e57c75e 1519 BOPCol_MapIteratorOfMapOfInteger aItMI;
1520 aItMI.Initialize(aMV);
1521 for (; aItMI.More(); aItMI.Next()) {
1522 nV = aItMI.Value();
1523 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1524 gp_Pnt aPV = BRep_Tool::Pnt(aV);
1525 aProjPT.Perform(aPV);
1526 Standard_Integer aNbPoints = aProjPT.NbPoints();
1527 if (aNbPoints) {
1528 aDist = aProjPT.LowerDistance();
78c66ef1 1529 PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol);
4e57c75e 1530 }
1531 }
1532}
1533
1534//=======================================================================
1535//function : ProcessUnUsedVertices
1536//purpose :
1537//=======================================================================
465d1fba 1538 void BOPAlgo_PaveFiller::PutStickPavesOnCurve
1539 (const TopoDS_Face& aF1,
1540 const TopoDS_Face& aF2,
1541 const BOPCol_MapOfInteger& aMI,
1542 BOPDS_Curve& aNC,
1543 const BOPCol_MapOfInteger& aMVStick,
1544 BOPCol_DataMapOfIntegerReal& aMVTol)
4e57c75e 1545{
1546 BOPCol_MapOfInteger aMV;
1547 aMV.Assign(aMVStick);
1548 RemoveUsedVertices(aNC, aMV);
1549 //
1550 if (!aMV.Extent()) {
1551 return;
1552 }
1553 //
4e57c75e 1554 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
1555 Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
ec0cdc0e 1556 //
1557 const IntTools_Curve& aIC=aNC.Curve();
ec0cdc0e 1558 //if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1559 Handle(Geom2d_Curve) aC2D[2];
1560 //
1561 aC2D[0]=aIC.FirstCurve2d();
1562 aC2D[1]=aIC.SecondCurve2d();
1563 if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) {
1564 Standard_Integer nV, m, n;
1565 Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr;
1566 gp_Pnt aPC[2], aPV;
1567 gp_Dir aDN[2];
1568 gp_Pnt2d aP2D;
1569 BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1;
1570 //
1571 aDT2=2e-7; // the rich criteria
1572 aDScPr=5.e-9; // the creasing criteria
1573 aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
4e57c75e 1574 //
ec0cdc0e 1575 aItMI.Initialize(aMV);
1576 for (; aItMI.More(); aItMI.Next()) {
1577 nV = aItMI.Value();
1578 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV));
1579 aPV=BRep_Tool::Pnt(aV);
4e57c75e 1580 //
ec0cdc0e 1581 for (m=0; m<2; ++m) {
1582 aD2=aPC[m].SquareDistance(aPV);
1583 if (aD2>aDT2) {// no rich
1584 continue;
1585 }
78c66ef1 1586 //
ec0cdc0e 1587 for (n=0; n<2; ++n) {
1588 Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
1589 aC2D[n]->D0(aTC[m], aP2D);
1590 aP2D.Coord(u, v);
1591 BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]);
1592 }
1593 //
1594 aScPr=aDN[0]*aDN[1];
1595 if (aScPr<0.) {
1596 aScPr=-aScPr;
1597 }
1598 aScPr=1.-aScPr;
78c66ef1 1599 //
ec0cdc0e 1600 if (aScPr>aDScPr) {
1601 continue;
1602 }
1603 //
1604 // The intersection curve aIC is vanishing curve (the crease)
1605 aD=sqrt(aD2);
1606 //
1607 PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
4e57c75e 1608 }
ec0cdc0e 1609 }//for (jVU=1; jVU=aNbVU; ++jVU) {
1610 }
1611 //}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1612 //}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
4e57c75e 1613}
1614
1615//=======================================================================
1616//function : GetStickVertices
1617//purpose :
1618//=======================================================================
1619 void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
1620 const Standard_Integer nF2,
1621 BOPCol_MapOfInteger& aMVStick,
78c66ef1 1622 BOPCol_MapOfInteger& aMVEF,
1623 BOPCol_MapOfInteger& aMI)
4e57c75e 1624{
78c66ef1 1625 Standard_Integer nS1, nS2, nVNew, aTypeInt, i;
4e57c75e 1626 //
1627 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
1628 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
1629 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
1630 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
1631 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1632 //
465d1fba 1633 Standard_Integer aNbLines[5] = {
1634 aVVs.Extent(), aVEs.Extent(), aEEs.Extent(),
1635 aVFs.Extent(), aEFs.Extent()
1636 };
78c66ef1 1637 //collect indices of all shapes from nF1 and nF2.
1638 aMI.Clear();
1639 GetFullShapeMap(nF1, aMI);
1640 GetFullShapeMap(nF2, aMI);
1641 //
1642 //collect VV, VE, EE, VF interferences
1643 for (aTypeInt = 0; aTypeInt < 4; ++aTypeInt) {
1644 for (i = 0; i < aNbLines[aTypeInt]; ++i) {
1645 BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
1646 ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
465d1fba 1647 ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
1648 (BOPDS_Interf*)(&aVFs(i))));
78c66ef1 1649 if (aInt->HasIndexNew()) {
1650 aInt->Indices(nS1, nS2);
1651 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
1652 nVNew = aInt->IndexNew();
1653 aMVStick.Add(nVNew);
1654 }
4e57c75e 1655 }
1656 }
1657 }
4e57c75e 1658 //collect EF interferences
78c66ef1 1659 for (i = 0; i < aNbLines[4]; ++i) {
1660 const BOPDS_InterfEF& aInt = aEFs(i);
1661 if (aInt.HasIndexNew()) {
1662 aInt.Indices(nS1, nS2);
1663 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
1664 nVNew = aInt.IndexNew();
4e57c75e 1665 aMVStick.Add(nVNew);
1666 aMVEF.Add(nVNew);
1667 }
1668 }
1669 }
1670}
1671
1672//=======================================================================
78c66ef1 1673// function: GetFullShapeMap
4e57c75e 1674// purpose:
1675//=======================================================================
78c66ef1 1676void BOPAlgo_PaveFiller::GetFullShapeMap(const Standard_Integer nF,
1677 BOPCol_MapOfInteger& aMI)
4e57c75e 1678{
78c66ef1 1679 BOPCol_ListIteratorOfListOfInteger aIt;
1680 Standard_Integer nS;
1681 //
1682 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
1683 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1684 //
4e57c75e 1685 aMI.Add(nF);
78c66ef1 1686 aIt.Initialize(aLI);
1687 for (; aIt.More(); aIt.Next()) {
1688 nS = aIt.Value();
1689 aMI.Add(nS);
4e57c75e 1690 }
1691}
1692
1693//=======================================================================
1694// function: RemoveUsedVertices
1695// purpose:
1696//=======================================================================
1697void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
1698 BOPCol_MapOfInteger& aMV)
1699{
1700 if (!aMV.Extent()) {
1701 return;
1702 }
1703 Standard_Integer nV;
1704 BOPDS_Pave aPave;
1705 BOPDS_ListIteratorOfListOfPave aItLP;
1706 //
1707 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1708 const BOPDS_ListOfPave& aLP = aPB->ExtPaves();
1709 aItLP.Initialize(aLP);
1710 for (;aItLP.More();aItLP.Next()) {
1711 aPave = aItLP.Value();
1712 nV = aPave.Index();
1713 aMV.Remove(nV);
1714 }
1715}
1716
1717//=======================================================================
1718//function : PutPaveOnCurve
1719//purpose :
1720//=======================================================================
465d1fba 1721 void BOPAlgo_PaveFiller::PutPaveOnCurve
1722 (const Standard_Integer nV,
1723 const Standard_Real aTolR3D,
1724 BOPDS_Curve& aNC,
1725 const BOPCol_MapOfInteger& aMI,
1726 BOPCol_DataMapOfIntegerReal& aMVTol,
1727 const Standard_Integer iCheckExtend)
4e57c75e 1728{
1729 Standard_Boolean bIsVertexOnLine;
b4109929 1730 Standard_Real aT, aTol, aTolNew;
4e57c75e 1731 BOPDS_Pave aPave;
1732 //
1733 const TopoDS_Vertex aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
78c66ef1 1734 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
4e57c75e 1735 const IntTools_Curve& aIC = aNC.Curve();
1736 //
1737 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
78c66ef1 1738 if (!bIsVertexOnLine && iCheckExtend) {
1739 aTol = BRep_Tool::Tolerance(aV);
1740 //
1741 ExtendedTolerance(nV, aMI, aTol, iCheckExtend);
1742 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTol, aIC, aTolR3D, aT);
1743 }
1744 //
4e57c75e 1745 if (bIsVertexOnLine) {
1746 aPave.SetIndex(nV);
1747 aPave.SetParameter(aT);
1748 //
1749 aPB->AppendExtPave(aPave);
1750 //
b4109929 1751 aTol = BRep_Tool::Tolerance(aV);
1752 //
4e57c75e 1753 BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV);
b4109929 1754 //
1755 if (!aMVTol.IsBound(nV)) {
1756 aTolNew = BRep_Tool::Tolerance(aV);
1757 if (aTolNew > aTol) {
1758 aMVTol.Bind(nV, aTol);
1759 }
1760 }
4e57c75e 1761 //
1762 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
1763 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
1764 BRepBndLib::Add(aV, aBoxDS);
1765 }
1766}
1767
1768//=======================================================================
1769//function : ProcessOldPaveBlocks
1770//purpose :
1771//=======================================================================
1772 void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
1773 (const Standard_Integer theInt,
decdfc94 1774 const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
3285a59a 1775 const BOPCol_DataMapOfIntegerListOfInteger& aDMBV,
4e57c75e 1776 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
1777 BOPCol_DataMapOfShapeInteger& aMVI,
4e57c75e 1778 BOPDS_MapOfPaveBlock& aMPB)
1779{
3285a59a 1780 if (aDMBV.IsEmpty()) {
1781 return;
1782 }
1783 //
4e57c75e 1784 Standard_Real aT;
3285a59a 1785 Standard_Integer i, nV, nE, iC, aNbPB, iFlag;
1786 BOPCol_ListIteratorOfListOfInteger aItLI;
1787 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItBV;
4e57c75e 1788 //
3285a59a 1789 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
4e57c75e 1790 BOPDS_InterfFF& aFF = aFFs(theInt);
3285a59a 1791 BOPDS_VectorOfCurve& aVC = aFF.ChangeCurves();
1792 //
1793 aNbPB = aMPBOnIn.Extent();
1794 //
1795 aItBV.Initialize(aDMBV);
1796 for (; aItBV.More(); aItBV.Next()) {
1797 iC = aItBV.Key();
1798 const BOPCol_ListOfInteger& aLBV = aItBV.Value();
4e57c75e 1799 //
3285a59a 1800 BOPDS_Curve& aNC = aVC.ChangeValue(iC);
1801 BOPDS_ListOfPaveBlock& aLPBC = aNC.ChangePaveBlocks();
1802 //
1803 aItLI.Initialize(aLBV);
1804 for (; aItLI.More(); aItLI.Next()) {
1805 nV = aItLI.Value();
1806 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1807 const Bnd_Box& aBoxV=aSIV.Box();
1808 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape();
1809 if (!aMVI.IsBound(aV)) {
4e57c75e 1810 continue;
1811 }
4e57c75e 1812 //
3285a59a 1813 for (i = 1; i <= aNbPB; ++i) {
1814 const Handle(BOPDS_PaveBlock)& aPB = aMPBOnIn(i);
1815 if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
1816 continue;
1817 }
1818 //
1819 if (aMPB.Contains(aPB)) {
1820 continue;
1821 }
1822 //
1823 nE = aPB->Edge();
1824 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
1825 const Bnd_Box& aBoxE = aSIE.Box();
1826 //
1827 if (aBoxV.IsOut(aBoxE)) {
1828 continue;
1829 }
1830 //
4e57c75e 1831 const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape();
1832 //
3285a59a 1833 iFlag = myContext->ComputeVE(aV, aE, aT);
4e57c75e 1834 if (!iFlag) {
1835 aMPB.Add(aPB);
3285a59a 1836 PreparePostTreatFF(theInt, iC, aPB, aMSCPB, aMVI, aLPBC);
4e57c75e 1837 }
1838 }
1839 }
1840 }
1841}
4e57c75e 1842//=======================================================================
1843//function : UpdateExistingPaveBlocks
1844//purpose :
1845//=======================================================================
1846 void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
1847 (const Handle(BOPDS_PaveBlock)& aPBf,
1848 BOPDS_ListOfPaveBlock& aLPB,
1849 const Standard_Integer nF1,
1850 const Standard_Integer nF2)
1851{
1852 Standard_Integer nE;
1853 Standard_Boolean bCB;
1854 Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n;
1855 Handle(BOPDS_CommonBlock) aCB;
1856 BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2;
4e57c75e 1857 //
1b7ae951 1858 // 1. Remove micro edges from aLPB
4e57c75e 1859 aIt.Initialize(aLPB);
1860 for (; aIt.More();) {
1861 aPB = aIt.Value();
1862 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
1863 if (BOPTools_AlgoTools::IsMicroEdge(aE, myContext)) {
1864 aLPB.Remove(aIt);
1865 continue;
1866 }
1867 aIt.Next();
1868 }
1869 //
1870 if (!aLPB.Extent()) {
1871 return;
1872 }
4e57c75e 1873 //
1874 BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
1875 BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
1876 //
1877 BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.ChangePaveBlocksOn();
1878 BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.ChangePaveBlocksIn();
1879 BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.ChangePaveBlocksOn();
1880 BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.ChangePaveBlocksIn();
1881 //
1b7ae951 1882 // 2. Remove old pave blocks
5a77460e 1883 const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPBf);
4e57c75e 1884 bCB = !aCB1.IsNull();
1885 BOPDS_ListOfPaveBlock aLPB1;
1886 //
1887 if (bCB) {
1888 aLPB1.Assign(aCB1->PaveBlocks());
1889 } else {
1890 aLPB1.Append(aPBf);
1891 }
1892 aIt1.Initialize(aLPB1);
1893 for (; aIt1.More(); aIt1.Next()) {
1894 aPB1 = aIt1.Value();
1895 nE = aPB1->OriginalEdge();
1896 //
1897 BOPDS_ListOfPaveBlock& aLPB2 = myDS->ChangePaveBlocks(nE);
1898 aIt2.Initialize(aLPB2);
1899 for (; aIt2.More(); aIt2.Next()) {
1900 aPB2 = aIt2.Value();
1901 if (aPB1 == aPB2) {
1902 aLPB2.Remove(aIt2);
1903 break;
1904 }
1905 }
1906 }
1907 //
1b7ae951 1908 // 3. Update pave blocks
4e57c75e 1909 if (bCB) {
1b7ae951 1910 //create new common blocks
3285a59a 1911 BOPDS_ListOfPaveBlock aLPBNew;
4e57c75e 1912 const BOPCol_ListOfInteger& aFaces = aCB1->Faces();
1913 aIt.Initialize(aLPB);
1914 for (; aIt.More(); aIt.Next()) {
3285a59a 1915 const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
4e57c75e 1916 //
1917 aCB = new BOPDS_CommonBlock;
1918 aIt1.Initialize(aLPB1);
1919 for (; aIt1.More(); aIt1.Next()) {
1920 aPB2 = aIt1.Value();
1921 nE = aPB2->OriginalEdge();
1922 //
1923 aPB2n = new BOPDS_PaveBlock;
1924 aPB2n->SetPave1(aPB->Pave1());
1925 aPB2n->SetPave2(aPB->Pave2());
1926 aPB2n->SetEdge(aPB->Edge());
1927 aPB2n->SetOriginalEdge(nE);
1928 aCB->AddPaveBlock(aPB2n);
5a77460e 1929 myDS->SetCommonBlock(aPB2n, aCB);
4e57c75e 1930 myDS->ChangePaveBlocks(nE).Append(aPB2n);
1931 }
1932 aCB->AddFaces(aFaces);
1933 myDS->SortPaveBlocks(aCB);
1934 //
3285a59a 1935 const Handle(BOPDS_PaveBlock)& aPBNew = aCB->PaveBlocks().First();
1936 aLPBNew.Append(aPBNew);
4e57c75e 1937 }
3285a59a 1938 //
1939 aLPB = aLPBNew;
4e57c75e 1940 }
1b7ae951 1941 else {
1942 nE = aPBf->OriginalEdge();
1943 BOPDS_ListOfPaveBlock& aLPBE = myDS->ChangePaveBlocks(nE);
1944 aIt.Initialize(aLPB);
1945 for (; aIt.More(); aIt.Next()) {
1946 aPB = aIt.Value();
1947 aLPBE.Append(aPB);
4e57c75e 1948 }
1949 }
1950 //
4e57c75e 1951 Standard_Boolean bIn1, bIn2;
1952 //
1953 bIn1 = aMPBOn1.Contains(aPBf) || aMPBIn1.Contains(aPBf);
1954 bIn2 = aMPBOn2.Contains(aPBf) || aMPBIn2.Contains(aPBf);
1955 //
1b7ae951 1956 if (bIn1 && bIn2) {
1957 return;
1958 }
1959 //
1960 // 4. Check new pave blocks for coincidence
1961 // with the opposite face.
1962 // In case of coincidence create common blocks
1963 Standard_Integer nF;
1964 Standard_Real aTolE, aTolF;
1965 //
1966 nF = bIn1 ? nF2 : nF1;
1967 const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
1968 BOPDS_IndexedMapOfPaveBlock& aMPBIn = bIn1 ? aMPBIn2 : aMPBIn1;
1969 aTolF = BRep_Tool::Tolerance(aF);
1970 //
1971 aIt.Initialize(aLPB);
1972 for (; aIt.More(); aIt.Next()) {
1973 Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue();
1974 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
1975 aTolE = BRep_Tool::Tolerance(aE);
1976 //
1977 IntTools_EdgeFace anEF;
1978 anEF.SetEdge(aE);
1979 anEF.SetFace(aF);
1980 anEF.SetTolE(aTolE);
1981 anEF.SetTolF(aTolF);
1982 anEF.SetRange(aPB->Pave1().Parameter(), aPB->Pave2().Parameter());
1983 anEF.SetContext(myContext);
1984 anEF.Perform();
4e57c75e 1985 //
1b7ae951 1986 const IntTools_SequenceOfCommonPrts& aCPrts=anEF.CommonParts();
1987 if (aCPrts.Length() == 1) {
1988 Standard_Boolean bCoinc = (aCPrts(1).Type() == TopAbs_EDGE);
1989 if (bCoinc) {
1990 if (bCB) {
1991 aCB = myDS->CommonBlock(aPB);
1992 } else {
1993 aCB = new BOPDS_CommonBlock;
1994 aCB->AddPaveBlock(aPB);
1995 myDS->SetCommonBlock(aPB, aCB);
1996 }
1997 aCB->AddFace(nF);
1998 //
1999 aMPBIn.Add(aPB);
2000 }
4e57c75e 2001 }
2002 }
2003}
4e57c75e 2004//=======================================================================
2005// function: PutClosingPaveOnCurve
2006// purpose:
2007//=======================================================================
2008 void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
2009{
2010 Standard_Boolean bIsClosed, bHasBounds, bAdded;
2011 Standard_Integer nVC, j;
2012 Standard_Real aT[2], aTC, dT, aTx;
2013 gp_Pnt aP[2] ;
2014 BOPDS_Pave aPVx;
2015 BOPDS_ListIteratorOfListOfPave aItLP;
2016 //
2017 const IntTools_Curve& aIC=aNC.Curve();
2018 const Handle(Geom_Curve)& aC3D=aIC.Curve();
2019 if(aC3D.IsNull()) {
2020 return;
2021 }
2022 //
2023 bIsClosed=IntTools_Tools::IsClosed(aC3D);
2024 if (!bIsClosed) {
2025 return;
2026 }
2027 //
2028 bHasBounds=aIC.HasBounds ();
2029 if (!bHasBounds){
2030 return;
2031 }
2032 //
2033 bAdded=Standard_False;
2034 dT=Precision::PConfusion();
2035 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
2036 //
2037 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
2038 BOPDS_ListOfPave& aLP=aPB->ChangeExtPaves();
2039 //
2040 aItLP.Initialize(aLP);
2041 for (; aItLP.More() && !bAdded; aItLP.Next()) {
2042 const BOPDS_Pave& aPC=aItLP.Value();
2043 nVC=aPC.Index();
2044 aTC=aPC.Parameter();
2045 //
2046 for (j=0; j<2; ++j) {
2047 if (fabs(aTC-aT[j]) < dT) {
2048 aTx=(!j) ? aT[1] : aT[0];
2049 aPVx.SetIndex(nVC);
2050 aPVx.SetParameter(aTx);
2051 aLP.Append(aPVx);
2052 //
2053 bAdded=Standard_True;
2054 break;
2055 }
2056 }
2057 }
2058}
4e57c75e 2059//=======================================================================
2060//function : PreparePostTreatFF
2061//purpose :
2062//=======================================================================
2063 void BOPAlgo_PaveFiller::PreparePostTreatFF
2064 (const Standard_Integer aInt,
3285a59a 2065 const Standard_Integer aCur,
4e57c75e 2066 const Handle(BOPDS_PaveBlock)& aPB,
2067 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
2068 BOPCol_DataMapOfShapeInteger& aMVI,
3285a59a 2069 BOPDS_ListOfPaveBlock& aLPBC)
4e57c75e 2070{
3285a59a 2071 Standard_Integer nV1, nV2;
4e57c75e 2072 //
4e57c75e 2073 aLPBC.Append(aPB);
2074 //
2075 aPB->Indices(nV1, nV2);
2076 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
2077 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
2078 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
2079 // Keep info for post treatment
2080 BOPDS_CoupleOfPaveBlocks aCPB;
2081 aCPB.SetIndexInterf(aInt);
3285a59a 2082 aCPB.SetIndex(aCur);
4e57c75e 2083 aCPB.SetPaveBlock1(aPB);
2084 //
2085 aMSCPB.Add(aE, aCPB);
2086 aMVI.Bind(aV1, nV1);
2087 aMVI.Bind(aV2, nV2);
2088}
2089
2090//=======================================================================
b4109929 2091//function : CheckPlanes
2092//purpose :
2093//=======================================================================
465d1fba 2094Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes
2095 (const Standard_Integer nF1,
2096 const Standard_Integer nF2)const
b4109929 2097{
2098 Standard_Boolean bToIntersect;
af4e6dab 2099 Standard_Integer i, nV2, iCnt;
b4109929 2100 BOPCol_MapIteratorOfMapOfInteger aIt;
2101 //
af4e6dab 2102 bToIntersect=Standard_False;
b4109929 2103 //
af4e6dab 2104 const BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
2105 const BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
b4109929 2106 //
af4e6dab 2107 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
2108 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
b4109929 2109 //
af4e6dab 2110 iCnt=0;
2111 for (i=0; (i<2 && !bToIntersect); ++i) {
2112 const BOPCol_MapOfInteger& aMV2=(!i) ? aFI2.VerticesIn()
2113 : aFI2.VerticesOn();
2114 //
2115 aIt.Initialize(aMV2);
b4109929 2116 for (; aIt.More(); aIt.Next()) {
af4e6dab 2117 nV2=aIt.Value();
2118 if (aMVIn1.Contains(nV2) || aMVOn1.Contains(nV2)) {
78c66ef1 2119 ++iCnt;
2120 if (iCnt>1) {
2121 bToIntersect=!bToIntersect;
2122 break;
2123 }
b4109929 2124 }
2125 }
2126 }
b4109929 2127 //
2128 return bToIntersect;
2129}
b4109929 2130//=======================================================================
78c66ef1 2131//function : UpdatePaveBlocks
2132//purpose :
2133//=======================================================================
465d1fba 2134void BOPAlgo_PaveFiller::UpdatePaveBlocks
2135 (const BOPCol_DataMapOfIntegerInteger& aDMI)
78c66ef1 2136{
2137 if (aDMI.IsEmpty()) {
2138 return;
2139 }
2140 //
2141 Standard_Integer nSp, aNbPBP, nV[2], i, j;
2142 Standard_Real aT[2];
2143 Standard_Boolean bCB, bRebuild;
2144 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
2145 BOPDS_MapOfPaveBlock aMPB;
2146 //
2147 BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
2148 aNbPBP = aPBP.Extent();
2149 for (i=0; i<aNbPBP; ++i) {
2150 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
2151 //
2152 aItPB.Initialize(aLPB);
2153 for (; aItPB.More(); aItPB.Next()) {
2154 Handle(BOPDS_PaveBlock) aPB=aItPB.Value();
2155 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
2156 bCB = !aCB.IsNull();
2157 if (bCB) {
2158 aPB=aCB->PaveBlock1();
2159 }
2160 //
2161 if (aMPB.Add(aPB)) {
2162 bRebuild = Standard_False;
2163 aPB->Indices(nV[0], nV[1]);
2164 aPB->Range(aT[0], aT[1]);
2165 //
2166 for (j = 0; j < 2; ++j) {
2167 if (aDMI.IsBound(nV[j])) {
2168 BOPDS_Pave aPave;
2169 //
2170 nV[j] = aDMI.Find(nV[j]);
2171 aPave.SetIndex(nV[j]);
2172 aPave.SetParameter(aT[j]);
2173 //
2174 bRebuild = Standard_True;
2175 if (!j) {
2176 aPB->SetPave1(aPave);
2177 } else {
2178 aPB->SetPave2(aPave);
2179 }
2180 }
2181 }
2182 //
2183 if (bRebuild) {
2184 nSp = SplitEdge(aPB->Edge(), nV[0], aT[0], nV[1], aT[1]);
2185 if (bCB) {
2186 aCB->SetEdge(nSp);
2187 }
2188 else {
2189 aPB->SetEdge(nSp);
2190 }
2191 }// if (bRebuild) {
2192 }// if (aMPB.Add(aPB)) {
2193 }// for (; aItPB.More(); aItPB.Next()) {
2194 }// for (i=0; i<aNbPBP; ++i) {
2195 aMPB.Clear();
2196}
2197//=======================================================================
4e57c75e 2198//function : ToleranceFF
2199//purpose : Computes the TolFF according to the tolerance value and
2200// types of the faces.
2201//=======================================================================
b4109929 2202 void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
2203 const BRepAdaptor_Surface& aBAS2,
4e57c75e 2204 Standard_Real& aTolFF)
2205{
2206 Standard_Real aTol1, aTol2;
2207 Standard_Boolean isAna1, isAna2;
2208 //
b4109929 2209 aTol1 = aBAS1.Tolerance();
2210 aTol2 = aBAS2.Tolerance();
4e57c75e 2211 aTolFF = Max(aTol1, aTol2);
2212 //
b4109929 2213 isAna1 = (aBAS1.GetType() == GeomAbs_Plane ||
2214 aBAS1.GetType() == GeomAbs_Cylinder ||
2215 aBAS1.GetType() == GeomAbs_Cone ||
2216 aBAS1.GetType() == GeomAbs_Sphere ||
2217 aBAS1.GetType() == GeomAbs_Torus);
4e57c75e 2218 //
b4109929 2219 isAna2 = (aBAS2.GetType() == GeomAbs_Plane ||
2220 aBAS2.GetType() == GeomAbs_Cylinder ||
2221 aBAS2.GetType() == GeomAbs_Cone ||
2222 aBAS2.GetType() == GeomAbs_Sphere ||
2223 aBAS2.GetType() == GeomAbs_Torus);
4e57c75e 2224 //
b4109929 2225 if (!isAna1 || !isAna2) {
2226 aTolFF = Max(aTolFF, 5.e-6);
2227 }
4e57c75e 2228}