0023779: New Boolean Operation algorithm produces incorrect result of CUT operation...
[occt.git] / src / BOPAlgo / BOPAlgo_Builder_2.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
2// Copyright (c) 2010-2012 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// The content of this file is subject to the Open CASCADE Technology Public
8// License Version 6.5 (the "License"). You may not use the content of this file
9// except in compliance with the License. Please obtain a copy of the License
10// at http://www.opencascade.org and read it completely before using this file.
11//
12// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
13// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14//
15// The Original Code and all software distributed under the License is
16// distributed on an "AS IS" basis, without warranty of any kind, and the
17// Initial Developer hereby disclaims all such warranties, including without
18// limitation, any warranties of merchantability, fitness for a particular
19// purpose or non-infringement. Please see the License for the specific terms
20// and conditions governing the rights and limitations under the License.
21
22#include <BOPAlgo_Builder.ixx>
23
24#include <NCollection_IncAllocator.hxx>
25
26#include <TopoDS_Shape.hxx>
27#include <TopoDS_Face.hxx>
28#include <TopoDS_Edge.hxx>
29#include <TopoDS_Vertex.hxx>
30#include <TopoDS_Compound.hxx>
31
32#include <BRep_Tool.hxx>
33#include <BRep_Builder.hxx>
34
35#include <TopExp_Explorer.hxx>
36
37#include <BOPCol_ListOfShape.hxx>
38#include <BOPCol_ListOfInteger.hxx>
39#include <BOPCol_MapOfInteger.hxx>
40#include <BOPCol_DataMapOfIntegerListOfShape.hxx>
41#include <BOPCol_DataMapOfShapeShape.hxx>
42
43#include <BOPInt_Context.hxx>
44
45#include <BOPDS_PaveBlock.hxx>
46#include <BOPDS_ShapeInfo.hxx>
47#include <BOPDS_DS.hxx>
48#include <BOPDS_FaceInfo.hxx>
49#include <BOPDS_MapOfPaveBlock.hxx>
50#include <BOPDS_VectorOfInterfFF.hxx>
51#include <BOPDS_Interf.hxx>
52#include <BOPDS_VectorOfCurve.hxx>
53#include <BOPDS_VectorOfPoint.hxx>
54
55#include <BOPTools.hxx>
56#include <BOPTools_AlgoTools.hxx>
57#include <BOPTools_AlgoTools3D.hxx>
58#include <BOPAlgo_BuilderFace.hxx>
59#include <BOPTools_CoupleOfShape.hxx>
60#include <BOPTools_ListOfCoupleOfShape.hxx>
61#include <BOPTools_MapOfSet.hxx>
62#include <BOPTools_DataMapOfShapeSet.hxx>
63
64static
65 Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
66 const BOPDS_FaceInfo& aFI2);
67static
68 void FillMap(const TopoDS_Shape& aS1,
69 const TopoDS_Shape& aS2,
70 BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
71 Handle(NCollection_IncAllocator)& aAllocator);
72static
73 void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
74 BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
75 Handle(NCollection_IncAllocator)& aAllocator);
76
77//=======================================================================
78//function : FillImagesFaces
79//purpose :
80//=======================================================================
81 void BOPAlgo_Builder::FillImagesFaces()
82{
83 myErrorStatus=0;
84 //
85 BuildSplitFaces();
86 FillSameDomainFaces();
87 FillImagesFaces1();
88}
89//=======================================================================
90//function : BuildSplitFaces
91//purpose :
92//=======================================================================
93 void BOPAlgo_Builder::BuildSplitFaces()
94{
95 Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
96 Standard_Integer i, j, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
97 TopoDS_Face aFF, aFSD;
98 TopoDS_Edge aSp, aEE;
99 TopAbs_Orientation anOriF, anOriE;
100 TopExp_Explorer aExp;
101 BOPCol_ListIteratorOfListOfShape aIt;
102 BOPCol_ListOfInteger aLIAV;
103 BOPCol_MapOfShape aMFence;
104 Handle(NCollection_IncAllocator) aAllocator;
105 BOPCol_ListOfShape aLFIm(myAllocator);
106 BOPCol_MapIteratorOfMapOfShape aItMS;
107 //
108 myErrorStatus=0;
109 //
110 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f
111 aAllocator=new NCollection_IncAllocator();
112 //
113 BOPCol_ListOfShape aLE(aAllocator);
114 BOPCol_MapOfShape aMDE(100, aAllocator);
115 //
116 aNbS=myDS->NbSourceShapes();
117 for (i=0; i<aNbS; ++i) {
118 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
119 if (aSI.ShapeType()!=TopAbs_FACE) {
120 continue;
121 }
122 //
123 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
124 //
125 bHasFaceInfo=myDS->HasFaceInfo(i);
126 if(!bHasFaceInfo) {
127 continue;
128 }
129 //
130 // aLFIm will contain images of aF
131 aLFIm.Clear();
132 //
133 const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
134 //
135 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
136 const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
137 const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
138 aLIAV.Clear();
139 myDS->AloneVertices(i, aLIAV);
140
141 aNbPBIn=aMPBIn.Extent();
142 aNbPBOn=aMPBOn.Extent();
143 aNbPBSc=aMPBSc.Extent();
144 aNbAV=aLIAV.Extent();
145 if (!aNbPBIn && !aNbPBOn && !aNbPBSc && !aNbAV) { // not compete
146 continue;
147 }
148 //
149 aMFence.Clear();
150 //
151 anOriF=aF.Orientation();
152 aFF=aF;
153 aFF.Orientation(TopAbs_FORWARD);
154 //
155
156 //
157 // 1. Fill the egdes set for the face aFF -> LE
158 aLE.Clear();
159 //
160 //
161 // 1.1 Bounding edges
162 aExp.Init(aFF, TopAbs_EDGE);
163 for (; aExp.More(); aExp.Next()) {
164 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
165 anOriE=aE.Orientation();
166 bIsDegenerated=BRep_Tool::Degenerated(aE);
167 bIsClosed=BRep_Tool::IsClosed(aE, aF);
168 //
169 if (!myImages.IsBound(aE)) {
170 if (anOriE==TopAbs_INTERNAL) {
171 aEE=aE;
172 aEE.Orientation(TopAbs_FORWARD);
173 aLE.Append(aEE);
174 aEE.Orientation(TopAbs_REVERSED);
175 aLE.Append(aEE);
176 }
177 else {
178 aLE.Append(aE);
179 }
180 }
181 else {//else 1
182 const BOPCol_ListOfShape& aLIE=myImages.Find(aE);
183 aIt.Initialize(aLIE);
184 for (; aIt.More(); aIt.Next()) {
185 aSp=(*(TopoDS_Edge*)(&aIt.Value()));
186 if (bIsDegenerated) {
187 aSp.Orientation(anOriE);
188 aLE.Append(aSp);
189 continue;
190 }
191 //
192 if (anOriE==TopAbs_INTERNAL) {
193 aSp.Orientation(TopAbs_FORWARD);
194 aLE.Append(aSp);
195 aSp.Orientation(TopAbs_REVERSED);
196 aLE.Append(aSp);
197 continue;
198 }
199 //
200 if (bIsClosed) {
201 if (aMFence.Add(aSp)) {
202 if (!BRep_Tool::IsClosed(aSp, aF)){
203 BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aF);
204 }
205 //
206 aSp.Orientation(TopAbs_FORWARD);
207 aLE.Append(aSp);
208 aSp.Orientation(TopAbs_REVERSED);
209 aLE.Append(aSp);
210 }// if (aMFence.Add(aSp))
211 continue;
212 }// if (bIsClosed){
213 //
214 aSp.Orientation(anOriE);
215 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
216 if (bToReverse) {
217 aSp.Reverse();
218 }
219 aLE.Append(aSp);
220 }// for (; aIt.More(); aIt.Next()) {
221 }// else 1
222 }// for (; aExp.More(); aExp.Next()) {
223 //
224 //
225 // 1.2 In edges
226 for (j=1; j<=aNbPBIn; ++j) {
227 const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
228 nSp=aPB->Edge();
229 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
230 //
231 aSp.Orientation(TopAbs_FORWARD);
232 aLE.Append(aSp);
233 aSp.Orientation(TopAbs_REVERSED);
234 aLE.Append(aSp);
235 }
236 //
237 //
238 // 1.3 Section edges
239 for (j=1; j<=aNbPBSc; ++j) {
240 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
241 nSp=aPB->Edge();
242 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
243 //
244 aSp.Orientation(TopAbs_FORWARD);
245 aLE.Append(aSp);
246 aSp.Orientation(TopAbs_REVERSED);
247 aLE.Append(aSp);
248 }
249 //
250 // 3 Build split faces
251 BOPAlgo_BuilderFace aBF(aAllocator);
252 //
253 aBF.SetFace(aFF);
254 //aBF.SetContext(myContext);
255 //
256 // <-DEB ft
257 //
258 aBF.SetShapes(aLE);
259 //
260 aBF.Perform();
261 //
262 const BOPCol_ListOfShape& aLFR=aBF.Areas();
263 aIt.Initialize(aLFR);
264 for (; aIt.More(); aIt.Next()) {
265 TopoDS_Shape& aFR=aIt.ChangeValue();
266 if (anOriF==TopAbs_REVERSED) {
267 aFR.Orientation(TopAbs_REVERSED);
268 }
269 //aFR.Orientation(anOriF);
270 aLFIm.Append(aFR);
4e57c75e 271 }
272 //
273 mySplits.Bind(aF, aLFIm);
274 }// for (i=0; i<aNbS; ++i) {
275 //
276 aAllocator.Nullify();
277 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope t
278}
279//=======================================================================
280//function : FillSameDomainFaces
281//purpose :
282//=======================================================================
283 void BOPAlgo_Builder::FillSameDomainFaces()
284{
285 Standard_Boolean bFlag;
286 Standard_Integer i, aNbFFs, aNbCurves, aNbPoints, nF1, nF2, aNbS;
287 Standard_Integer j;
288 Handle(NCollection_IncAllocator) aAllocator;
289 BOPCol_ListIteratorOfListOfShape aItF1, aItF2;
290 BOPTools_ListOfCoupleOfShape aLCS;
291 BOPCol_ListIteratorOfListOfShape aItLS;
c209782c 292 BOPCol_MapOfShape aMF;
293 BOPCol_MapIteratorOfMapOfShape aItMF;
4e57c75e 294 //
295 myErrorStatus=0;
296 //
297 const BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
298 //
299 aNbFFs=aFFs.Extent();
300 if (!aNbFFs) {
301 return;
302 }
303 //-----------------------------------------------------scope f
304 aAllocator=new NCollection_IncAllocator();
305 BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(100, aAllocator);
306 BOPCol_DataMapOfIntegerListOfShape aMBlocks(100, aAllocator);
307 BOPTools_DataMapOfShapeSet aMSST(100, aAllocator);
308 //
309 BOPCol_ListOfShape aLFIm;
310 //
311 for (i=0; i<aNbFFs; ++i) {
312 const BOPDS_InterfFF& aFF=aFFs(i);
313 aFF.Indices(nF1, nF2);
314 //
315 const BOPDS_VectorOfCurve& aCurves=aFF.Curves();
316 aNbCurves=aCurves.Extent();
317 if (aNbCurves) {
318 //
319 bFlag=Standard_False;
320 for (j=0; j<aNbCurves; ++j) {
321 const BOPDS_Curve& aNC=aCurves.Value(j);
322 bFlag=aNC.HasEdge();
323 if (bFlag) {
324 break;
325 }
326 }
327 if (bFlag) {
328 continue;
329 }
330 //continue;
331 }
332 //
333 const BOPDS_VectorOfPoint& aPoints=aFF.Points();
334 aNbPoints=aPoints.Extent();
335 if (aNbPoints) {
336 continue;
337 }
338 //
339 if (!myDS->HasFaceInfo(nF1) || !myDS->HasFaceInfo(nF2) ) {
340 continue;
341 }
342 //
343 const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
344 const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
345 bFlag=HasPaveBlocksOnIn(aFI1, aFI2);
4e57c75e 346 //
347 const TopoDS_Face& aF1=(*(TopoDS_Face*)(&myDS->Shape(nF1)));
348 const TopoDS_Face& aF2=(*(TopoDS_Face*)(&myDS->Shape(nF2)));
c209782c 349 bFlag=bFlag && (mySplits.IsBound(aF1) && mySplits.IsBound(aF2));
350 //
4e57c75e 351 if (!bFlag) {
c209782c 352 //case when the faces have shared bounds
353 if (!aMSST.IsBound(aF1)) {
354 BOPTools_Set aST1(aAllocator);
355 aMSST.Bind(aF1, aST1);
356 BOPTools_Set& aST=aMSST.ChangeFind(aF1);
357 aST.AddEdges(aF1);
358 }
359 //
360 if (!aMSST.IsBound(aF2)) {
361 BOPTools_Set aST2(aAllocator);
362 aMSST.Bind(aF2, aST2);
363 BOPTools_Set& aST=aMSST.ChangeFind(aF2);
364 aST.AddEdges(aF2);
365 }
366 //
367 const BOPTools_Set& aST1=aMSST.Find(aF1);
368 const BOPTools_Set& aST2=aMSST.Find(aF2);
369 if (aST1.IsEqual(aST2)) {
370 bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1, aF2, myContext);
371 if (bFlag) {
372 FillMap(aF1, aF2, aDMSLS, aAllocator);
373 aMF.Add(aF1);
374 aMF.Add(aF2);
375 }
376 }
4e57c75e 377 continue;
378 }
379 //
380 const BOPCol_ListOfShape& aLF1=mySplits.Find(aF1);
381 const BOPCol_ListOfShape& aLF2=mySplits.Find(aF2);
382 //
383 aItF1.Initialize(aLF1);
384 for (; aItF1.More(); aItF1.Next()) {
385 const TopoDS_Face& aF1x=(*(TopoDS_Face*)(&aItF1.Value()));
386 if (!aMSST.IsBound(aF1x)) {
387 BOPTools_Set aST1(aAllocator);
388 //
389 aMSST.Bind(aF1x, aST1);
390 BOPTools_Set& aST=aMSST.ChangeFind(aF1x);
391 aST.AddEdges(aF1x);
392 }
393 //
394 aItF2.Initialize(aLF2);
395 for (; aItF2.More(); aItF2.Next()) {
396 const TopoDS_Face& aF2y=(*(TopoDS_Face*)(&aItF2.Value()));
397 if (!aMSST.IsBound(aF2y)) {
398 BOPTools_Set aST2(aAllocator);
399 //
400 aMSST.Bind(aF2y, aST2);
401 BOPTools_Set& aST=aMSST.ChangeFind(aF2y);
402 aST.AddEdges(aF2y);
403 }
404 //
405 const BOPTools_Set& aST1=aMSST.Find(aF1x);
406 const BOPTools_Set& aST2=aMSST.Find(aF2y);
407 //
408 if (aST1.IsEqual(aST2)) {
409 bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1x, aF2y, myContext);
410 if (bFlag) {
411 FillMap(aF1x, aF2y, aDMSLS, aAllocator);
412 }
413 }
414 }
415 }
416 } // for (i=0; i<aNbFFs; ++i) {
417 //
418 // 2. Make blocks
419 MakeBlocksCnx(aDMSLS, aMBlocks, aAllocator);
420 //
421 // 3. Fill same domain faces map -> aMSDF
422 aNbS = aMBlocks.Extent();
423 for (i=0; i<aNbS; ++i) {
424 const BOPCol_ListOfShape& aLSD=aMBlocks.Find(i);
425 if (aLSD.Extent()) {
426 const TopoDS_Shape& aFSD1=aLSD.First();
427 aItLS.Initialize(aLSD);
428 for (; aItLS.More(); aItLS.Next()) {
429 const TopoDS_Shape& aFSD=aItLS.Value();
430 myShapesSD.Bind(aFSD, aFSD1);
431 }
432 }
433 }
434 //
c209782c 435 aItMF.Initialize(aMF);
436 for (; aItMF.More(); aItMF.Next()){
437 const TopoDS_Shape& aF = aItMF.Value();
438 //
439 BOPCol_ListOfShape aLS;
440 aLS.Append(aF);
441 mySplits.Bind(aF, aLS);
442 }
4e57c75e 443 //-----------------------------------------------------scope t
444 aMSST.Clear();
445 aMBlocks.Clear();
446 aDMSLS.Clear();
447 aAllocator.Nullify();
448}
449//=======================================================================
450// function: FillImagesFaces1
451// purpose:
452//=======================================================================
453 void BOPAlgo_Builder::FillImagesFaces1()
454{
455 Standard_Integer i, aNbS, iSense;
456 TopoDS_Face aFSD;
457 BOPCol_ListOfInteger aLIAV;
458 BOPCol_ListOfShape aLFIm;
459 BOPCol_ListIteratorOfListOfShape aItLS;
460 //
461 aNbS=myDS->NbSourceShapes();
462 for (i=0; i<aNbS; ++i) {
463 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
464 if (aSI.ShapeType()!=TopAbs_FACE) {
465 continue;
466 }
467 //
468 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
469 //
470 if (!mySplits.IsBound(aF)) {
471 continue;
472 }
473 //
474 aLIAV.Clear();
475 myDS->AloneVertices(i, aLIAV);
476 aLFIm.Clear();
477 //
478 const BOPCol_ListOfShape& aLSp=mySplits.Find(aF);
479 aItLS.Initialize(aLSp);
480 for (; aItLS.More(); aItLS.Next()) {
481 const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
482 if (!myShapesSD.IsBound(aFSp)) {
483 aLFIm.Append(aFSp);
484 }
485 else {
486 aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp)));
487 iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD);
488 if (iSense<0) {
489 aFSD.Reverse();
490 }
491 aLFIm.Append(aFSD);
492 }
493 }
494 //
495 FillInternalVertices(aLFIm, aLIAV);
496 //
497 myImages.Bind(aF, aLFIm);
c209782c 498 //
499 //fill myOrigins
500 aItLS.Initialize(aLFIm);
501 for (; aItLS.More(); aItLS.Next()) {
502 const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
503 myOrigins.Bind(aFSp, aF);
504 }
4e57c75e 505 }// for (i=0; i<aNbS; ++i) {
506}
507//=======================================================================
508// function: FillInternalVertices
509// purpose:
510//=======================================================================
511 void BOPAlgo_Builder::FillInternalVertices(BOPCol_ListOfShape& aLFIm,
512 BOPCol_ListOfInteger& aLIAV)
513{
514 Standard_Integer nV, iFlag;
515 Standard_Real aU1, aU2;
516 TopoDS_Vertex aV;
517 BRep_Builder aBB;
518 BOPCol_ListIteratorOfListOfInteger aItV;
519 BOPCol_ListIteratorOfListOfShape aItF;
520 //
521 aItV.Initialize(aLIAV);
522 for (; aItV.More(); aItV.Next()) {
523 nV=aItV.Value();
524 aV=(*(TopoDS_Vertex*)(&myDS->Shape(nV)));
525 aV.Orientation(TopAbs_INTERNAL);
526 //
527 aItF.Initialize(aLFIm);
528 for (; aItF.More(); aItF.Next()) {
529 TopoDS_Face& aF=(*(TopoDS_Face*)(&aItF.Value()));
530 iFlag=myContext->ComputeVF(aV, aF, aU1, aU2);
531 if (!iFlag) {
532 aBB.Add(aF, aV);
533 break;
534 }
535 }
536 }
537}
538//=======================================================================
539//function : MakeBlocksCnx
540//purpose :
541//=======================================================================
542void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
543 BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
544 Handle(NCollection_IncAllocator)& aAllocator)
545{
546 Standard_Integer aNbV, aNbVS, aNbVP, aNbEC, k, i, j;
547 BOPCol_ListIteratorOfListOfShape aItLI;
548 //
549 BOPCol_MapOfShape aMVS(100, aAllocator);
550 BOPCol_IndexedMapOfShape aMEC(100, aAllocator);
551 BOPCol_IndexedMapOfShape aMVP(100, aAllocator);
552 BOPCol_IndexedMapOfShape aMVAdd(100, aAllocator);
553 //
554 aNbV=aMILI.Extent();
555 //
556 for (k=0,i=1; i<=aNbV; ++i) {
557 aNbVS=aMVS.Extent();
558 if (aNbVS==aNbV) {
559 break;
560 }
561 //
562 const TopoDS_Shape& nV=aMILI.FindKey(i);
563 if (aMVS.Contains(nV)){
564 continue;
565 }
566 aMVS.Add(nV);
567 //
568 aMEC.Clear();
569 aMVP.Clear();
570 aMVAdd.Clear();
571 //
572 aMVP.Add(nV);
573 while(1) {
574 aNbVP=aMVP.Extent();
575 for (j=1; j<=aNbVP; ++j) {
576 const TopoDS_Shape& nVP=aMVP(j);
577 const BOPCol_ListOfShape& aLV=aMILI.FindFromKey(nVP);
578 aItLI.Initialize(aLV);
579 for (; aItLI.More(); aItLI.Next()) {
580 const TopoDS_Shape& nVx=aItLI.Value();
581 if (aMEC.Contains(nVx)) {
582 continue;
583 }
584 //
585 aMVS.Add(nVx);
586 aMEC.Add(nVx);
587 aMVAdd.Add(nVx);
588 }
589 }
590 //
591 aNbVP=aMVAdd.Extent();
592 if (!aNbVP) {
593 break; // from while(1)
594 }
595 //
596 aMVP.Clear();
597 for (j=1; j<=aNbVP; ++j) {
598 aMVP.Add(aMVAdd(j));
599 }
600 aMVAdd.Clear();
601 }//while(1) {
602 //
603 BOPCol_ListOfShape aLIx(aAllocator);
604 //
605 aNbEC = aMEC.Extent();
606 for (j=1; j<=aNbEC; ++j) {
607 const TopoDS_Shape& nVx=aMEC(j);
608 aLIx.Append(nVx);
609 }
610 //
611 aMBlocks.Bind(k, aLIx);
612 ++k;
613 }//for (k=0,i=1; i<=aNbV; ++i)
614 aMVAdd.Clear();
615 aMVP.Clear();
616 aMEC.Clear();
617 aMVS.Clear();
618}
619
620//=======================================================================
621//function : FillMap
622//purpose :
623//=======================================================================
624void FillMap(const TopoDS_Shape& aS1,
625 const TopoDS_Shape& aS2,
626 BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
627 Handle(NCollection_IncAllocator)& aAllocator)
628{
629 if (aDMSLS.Contains(aS1)) {
630 BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS1);
631 aLS.Append(aS2);
632 }
633 else {
634 BOPCol_ListOfShape aLS(aAllocator);
635 aLS.Append(aS2);
636 aDMSLS.Add(aS1, aLS);
637 }
638 //
639 if (aDMSLS.Contains(aS2)) {
640 BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS2);
641 aLS.Append(aS1);
642 }
643 else {
644 BOPCol_ListOfShape aLS(aAllocator);
645 aLS.Append(aS1);
646 aDMSLS.Add(aS2, aLS);
647 }
648}
649//=======================================================================
650//function :HasPaveBlocksOnIn
651//purpose :
652//=======================================================================
653Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
654 const BOPDS_FaceInfo& aFI2)
655{
656 Standard_Boolean bRet;
657 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
658 //
659 bRet=Standard_False;
660 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
661 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
662 //
663 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
664 aItMPB.Initialize(aMPBOn2);
665 for (; aItMPB.More(); aItMPB.Next()) {
666 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
667 bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
668 if (bRet) {
669 return bRet;
670 }
671 }
672 //
673 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
674 aItMPB.Initialize(aMPBIn2);
675 for (; aItMPB.More(); aItMPB.Next()) {
676 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
677 bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
678 if (bRet) {
679 return bRet;
680 }
681 }
682 return bRet;
683}
684
685/*
686//DEBf
687 {
688 TopoDS_Compound aCx;
689 BRep_Builder aBBx;
690 BOPCol_ListIteratorOfListOfShape aItx;
691 //
692 aBBx.MakeCompound(aCx);
693 aBBx.Add(aCx, aFF);
694 aItx.Initialize(aLE);
695 for (; aItx.More(); aItx.Next()) {
696 const TopoDS_Shape& aEx=aItx.Value();
697 aBBx.Add(aCx, aEx);
698 }
699 int a=0;
700 }
701 //DEBt
702*/