0024624: Lost word in license statement in source files
[occt.git] / src / BOPAlgo / BOPAlgo_Builder_2.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
18#include <BOPAlgo_Builder.ixx>
19
20#include <NCollection_IncAllocator.hxx>
21
22#include <TopoDS_Shape.hxx>
23#include <TopoDS_Face.hxx>
24#include <TopoDS_Edge.hxx>
25#include <TopoDS_Vertex.hxx>
26#include <TopoDS_Compound.hxx>
27
28#include <BRep_Tool.hxx>
29#include <BRep_Builder.hxx>
30
31#include <TopExp_Explorer.hxx>
32
33#include <BOPCol_ListOfShape.hxx>
34#include <BOPCol_ListOfInteger.hxx>
35#include <BOPCol_MapOfInteger.hxx>
36#include <BOPCol_DataMapOfIntegerListOfShape.hxx>
37#include <BOPCol_DataMapOfShapeShape.hxx>
38
39#include <BOPInt_Context.hxx>
40
41#include <BOPDS_PaveBlock.hxx>
42#include <BOPDS_ShapeInfo.hxx>
43#include <BOPDS_DS.hxx>
44#include <BOPDS_FaceInfo.hxx>
45#include <BOPDS_MapOfPaveBlock.hxx>
46#include <BOPDS_VectorOfInterfFF.hxx>
47#include <BOPDS_Interf.hxx>
48#include <BOPDS_VectorOfCurve.hxx>
49#include <BOPDS_VectorOfPoint.hxx>
50
51#include <BOPTools.hxx>
52#include <BOPTools_AlgoTools.hxx>
acccace3 53#include <BOPTools_AlgoTools2D.hxx>
4e57c75e 54#include <BOPTools_AlgoTools3D.hxx>
55#include <BOPAlgo_BuilderFace.hxx>
56#include <BOPTools_CoupleOfShape.hxx>
57#include <BOPTools_ListOfCoupleOfShape.hxx>
58#include <BOPTools_MapOfSet.hxx>
59#include <BOPTools_DataMapOfShapeSet.hxx>
acccace3 60#include <BOPAlgo_Builder_2Cnt.hxx>
4e57c75e 61
62static
63 Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
64 const BOPDS_FaceInfo& aFI2);
65static
66 void FillMap(const TopoDS_Shape& aS1,
67 const TopoDS_Shape& aS2,
68 BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
69 Handle(NCollection_IncAllocator)& aAllocator);
70static
71 void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
72 BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
73 Handle(NCollection_IncAllocator)& aAllocator);
74
acccace3 75
4e57c75e 76//=======================================================================
77//function : FillImagesFaces
78//purpose :
79//=======================================================================
acccace3 80void BOPAlgo_Builder::FillImagesFaces()
4e57c75e 81{
82 myErrorStatus=0;
83 //
84 BuildSplitFaces();
85 FillSameDomainFaces();
86 FillImagesFaces1();
87}
88//=======================================================================
89//function : BuildSplitFaces
90//purpose :
91//=======================================================================
acccace3 92void BOPAlgo_Builder::BuildSplitFaces()
4e57c75e 93{
94 Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
37e640d5 95 Standard_Integer i, j, k, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
37e640d5 96 Standard_Size aNbBF;
4e57c75e 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;
acccace3 104 Handle(NCollection_BaseAllocator) aAllocator;
4e57c75e 105 BOPCol_ListOfShape aLFIm(myAllocator);
106 BOPCol_MapIteratorOfMapOfShape aItMS;
acccace3 107 BOPAlgo_VectorOfBuilderFace aVBF;
4e57c75e 108 //
109 myErrorStatus=0;
110 //
111 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f
112 aAllocator=new NCollection_IncAllocator();
113 //
114 BOPCol_ListOfShape aLE(aAllocator);
115 BOPCol_MapOfShape aMDE(100, aAllocator);
116 //
117 aNbS=myDS->NbSourceShapes();
acccace3 118 //
4e57c75e 119 for (i=0; i<aNbS; ++i) {
120 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
121 if (aSI.ShapeType()!=TopAbs_FACE) {
122 continue;
123 }
124 //
125 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
126 //
127 bHasFaceInfo=myDS->HasFaceInfo(i);
128 if(!bHasFaceInfo) {
129 continue;
130 }
131 //
4e57c75e 132 const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
133 //
134 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
135 const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
136 const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
137 aLIAV.Clear();
138 myDS->AloneVertices(i, aLIAV);
139
140 aNbPBIn=aMPBIn.Extent();
141 aNbPBOn=aMPBOn.Extent();
142 aNbPBSc=aMPBSc.Extent();
143 aNbAV=aLIAV.Extent();
144 if (!aNbPBIn && !aNbPBOn && !aNbPBSc && !aNbAV) { // not compete
145 continue;
146 }
147 //
148 aMFence.Clear();
149 //
150 anOriF=aF.Orientation();
151 aFF=aF;
152 aFF.Orientation(TopAbs_FORWARD);
153 //
154
155 //
156 // 1. Fill the egdes set for the face aFF -> LE
157 aLE.Clear();
158 //
159 //
160 // 1.1 Bounding edges
161 aExp.Init(aFF, TopAbs_EDGE);
162 for (; aExp.More(); aExp.Next()) {
163 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
164 anOriE=aE.Orientation();
165 bIsDegenerated=BRep_Tool::Degenerated(aE);
166 bIsClosed=BRep_Tool::IsClosed(aE, aF);
167 //
168 if (!myImages.IsBound(aE)) {
169 if (anOriE==TopAbs_INTERNAL) {
170 aEE=aE;
171 aEE.Orientation(TopAbs_FORWARD);
172 aLE.Append(aEE);
173 aEE.Orientation(TopAbs_REVERSED);
174 aLE.Append(aEE);
175 }
176 else {
177 aLE.Append(aE);
178 }
179 }
180 else {//else 1
181 const BOPCol_ListOfShape& aLIE=myImages.Find(aE);
182 aIt.Initialize(aLIE);
183 for (; aIt.More(); aIt.Next()) {
184 aSp=(*(TopoDS_Edge*)(&aIt.Value()));
185 if (bIsDegenerated) {
186 aSp.Orientation(anOriE);
187 aLE.Append(aSp);
188 continue;
189 }
190 //
191 if (anOriE==TopAbs_INTERNAL) {
192 aSp.Orientation(TopAbs_FORWARD);
193 aLE.Append(aSp);
194 aSp.Orientation(TopAbs_REVERSED);
195 aLE.Append(aSp);
196 continue;
197 }
198 //
199 if (bIsClosed) {
200 if (aMFence.Add(aSp)) {
201 if (!BRep_Tool::IsClosed(aSp, aF)){
202 BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aF);
203 }
204 //
205 aSp.Orientation(TopAbs_FORWARD);
206 aLE.Append(aSp);
207 aSp.Orientation(TopAbs_REVERSED);
208 aLE.Append(aSp);
209 }// if (aMFence.Add(aSp))
210 continue;
211 }// if (bIsClosed){
212 //
213 aSp.Orientation(anOriE);
214 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
215 if (bToReverse) {
216 aSp.Reverse();
217 }
218 aLE.Append(aSp);
219 }// for (; aIt.More(); aIt.Next()) {
220 }// else 1
221 }// for (; aExp.More(); aExp.Next()) {
222 //
223 //
224 // 1.2 In edges
225 for (j=1; j<=aNbPBIn; ++j) {
226 const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
227 nSp=aPB->Edge();
228 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
229 //
230 aSp.Orientation(TopAbs_FORWARD);
231 aLE.Append(aSp);
232 aSp.Orientation(TopAbs_REVERSED);
233 aLE.Append(aSp);
234 }
235 //
236 //
237 // 1.3 Section edges
238 for (j=1; j<=aNbPBSc; ++j) {
239 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
240 nSp=aPB->Edge();
241 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
242 //
243 aSp.Orientation(TopAbs_FORWARD);
244 aLE.Append(aSp);
245 aSp.Orientation(TopAbs_REVERSED);
246 aLE.Append(aSp);
247 }
248 //
acccace3 249 BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF);
4e57c75e 250 //
acccace3 251 // 3 Build split faces
252 BOPAlgo_BuilderFace& aBF=aVBF.Append1();
253 aBF.SetFace(aF);
4e57c75e 254 aBF.SetShapes(aLE);
db8e4b9a 255 aBF.SetRunParallel(myRunParallel);
4e57c75e 256 //
acccace3 257 }// for (i=0; i<aNbS; ++i) {
258 //
259 aNbBF=aVBF.Extent();
260 //
261 //===================================================
796a784d 262 BOPAlgo_BuilderFaceCnt::Perform(myRunParallel, aVBF);
acccace3 263 //===================================================
264 //
37e640d5 265 for (k=0; k<(Standard_Integer)aNbBF; ++k) {
acccace3 266 aLFIm.Clear();
267 //
268 BOPAlgo_BuilderFace& aBF=aVBF(k);
269 TopoDS_Face aF=aBF.Face();
270 anOriF=aBF.Orientation();
271 aF.Orientation(anOriF);
4e57c75e 272 //
273 const BOPCol_ListOfShape& aLFR=aBF.Areas();
274 aIt.Initialize(aLFR);
275 for (; aIt.More(); aIt.Next()) {
276 TopoDS_Shape& aFR=aIt.ChangeValue();
277 if (anOriF==TopAbs_REVERSED) {
278 aFR.Orientation(TopAbs_REVERSED);
279 }
280 //aFR.Orientation(anOriF);
281 aLFIm.Append(aFR);
4e57c75e 282 }
283 //
284 mySplits.Bind(aF, aLFIm);
acccace3 285 }// for (k=0; k<aNbBF; ++k) {
4e57c75e 286 //
287 aAllocator.Nullify();
288 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope t
289}
290//=======================================================================
291//function : FillSameDomainFaces
292//purpose :
293//=======================================================================
acccace3 294void BOPAlgo_Builder::FillSameDomainFaces()
4e57c75e 295{
296 Standard_Boolean bFlag;
19941687 297 Standard_Integer i, j, k, aNbFFs, aNbCurves, aNbPoints, nF1, nF2, aNbS;
4e57c75e 298 Handle(NCollection_IncAllocator) aAllocator;
19941687 299 BOPCol_ListIteratorOfListOfShape aItF;
300 BOPCol_MapOfShape aMFence;
301 BOPAlgo_IndexedDataMapOfSetInteger aIDMSS;
302 BOPAlgo_VectorOfVectorOfShape aVVS;
303//
4e57c75e 304 myErrorStatus=0;
305 //
306 const BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
307 //
308 aNbFFs=aFFs.Extent();
309 if (!aNbFFs) {
310 return;
311 }
4e57c75e 312 //
313 for (i=0; i<aNbFFs; ++i) {
314 const BOPDS_InterfFF& aFF=aFFs(i);
315 aFF.Indices(nF1, nF2);
316 //
317 const BOPDS_VectorOfCurve& aCurves=aFF.Curves();
318 aNbCurves=aCurves.Extent();
319 if (aNbCurves) {
320 //
321 bFlag=Standard_False;
322 for (j=0; j<aNbCurves; ++j) {
323 const BOPDS_Curve& aNC=aCurves.Value(j);
324 bFlag=aNC.HasEdge();
325 if (bFlag) {
326 break;
327 }
328 }
329 if (bFlag) {
330 continue;
331 }
332 //continue;
333 }
334 //
335 const BOPDS_VectorOfPoint& aPoints=aFF.Points();
336 aNbPoints=aPoints.Extent();
337 if (aNbPoints) {
338 continue;
339 }
340 //
341 if (!myDS->HasFaceInfo(nF1) || !myDS->HasFaceInfo(nF2) ) {
342 continue;
343 }
344 //
345 const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
346 const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
4e57c75e 347 //
19941687 348 const TopoDS_Shape& aF1=myDS->Shape(nF1);
349 const TopoDS_Shape& aF2=myDS->Shape(nF2);
350 //
351 bFlag=HasPaveBlocksOnIn(aFI1, aFI2);
c209782c 352 bFlag=bFlag && (mySplits.IsBound(aF1) && mySplits.IsBound(aF2));
353 //
19941687 354 if (bFlag) {
355 for (k=0; k<2; ++k) {
356 const TopoDS_Shape& aF=(!k) ? aF1 : aF2;
357 const BOPCol_ListOfShape& aLF=mySplits.Find(aF);
358 //
359 aItF.Initialize(aLF);
360 for (; aItF.More(); aItF.Next()) {
361 const TopoDS_Shape& aFx=aItF.Value();
362 //
363 if (aMFence.Add(aFx)) {
364 BOPTools_Set aSTx;
365 //
366 aSTx.AddEdges(aFx);
367 //
368 if (!aIDMSS.Contains(aSTx)) {
369 BOPAlgo_VectorOfShape& aVS=aVVS.Append1();
370 aVS.Append(aFx);
371 //
372 j=aVVS.Extent()-1;
373 aIDMSS.Add (aSTx, j);
374 }
375 else {
376 j=aIDMSS.ChangeFromKey(aSTx);
377 BOPAlgo_VectorOfShape& aVS=aVVS(j);
378 aVS.Append(aFx);
379 }
380 }
381 }
c209782c 382 }
19941687 383 }// if (bFlag) {
384 else {// if (!bFlag)
385 BOPTools_Set aST1, aST2;
c209782c 386 //
19941687 387 aST1.AddEdges(aF1);
388 aST2.AddEdges(aF2);
c209782c 389 //
c209782c 390 if (aST1.IsEqual(aST2)) {
19941687 391 if (!aIDMSS.Contains(aST1)) {
392 BOPAlgo_VectorOfShape& aVS=aVVS.Append1();
393 if (aMFence.Add(aF1)) {
394 aVS.Append(aF1);
395 }
396 if (aMFence.Add(aF2)) {
397 aVS.Append(aF2);
398 }
399 //
400 k=aVVS.Extent()-1;
401 aIDMSS.Add (aST1, k);
402 }
403 else {
404 k=aIDMSS.ChangeFromKey(aST1);
405 BOPAlgo_VectorOfShape& aVS=aVVS(k);
406 if (aMFence.Add(aF1)) {
407 aVS.Append(aF1);
408 }
409 if (aMFence.Add(aF2)) {
410 aVS.Append(aF2);
411 }
412 }
413 }//if (aST1.IsEqual(aST2)) {
414 }// else {// if (!bFlag)
415 //
416 }// for (i=0; i<aNbFFs; ++i) {
417 //
418 aIDMSS.Clear();
419 //
796a784d 420 Standard_Boolean bFlagSD;
19941687 421 Standard_Integer aNbVPSB, aNbVVS, aNbF, aNbF1;
422 BOPAlgo_VectorOfPairOfShapeBoolean aVPSB;
423 //
424 aNbVVS=aVVS.Extent();
425 for (i=0; i<aNbVVS; ++i) {
426 const BOPAlgo_VectorOfShape& aVS=aVVS(i);
427 aNbF=aVS.Extent();
428 if (aNbF<2) {
4e57c75e 429 continue;
430 }
431 //
19941687 432 aNbF1=aNbF-1;
433 for (j=0; j<aNbF1; ++j) {
434 const TopoDS_Shape& aFj=aVS(j);
435 for (k=j+1; k<aNbF; ++k) {
436 const TopoDS_Shape& aFk=aVS(k);
437 BOPAlgo_PairOfShapeBoolean& aPSB=aVPSB.Append1();
438 aPSB.Shape1()=aFj;
439 aPSB.Shape2()=aFk;
4e57c75e 440 }
19941687 441 }
442 }
443 //====================================================
796a784d 444 BOPAlgo_BuilderSDFaceCnt::Perform(myRunParallel, aVPSB);
19941687 445 //====================================================
446 aAllocator=new NCollection_IncAllocator();
447 BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(100, aAllocator);
448 BOPCol_DataMapOfIntegerListOfShape aMBlocks(100, aAllocator);
449 //
450 aNbVPSB=aVPSB.Extent();
451 for (i=0; i<aNbVPSB; ++i) {
452 BOPAlgo_PairOfShapeBoolean& aPSB=aVPSB(i);
453 bFlagSD=aPSB.Flag();
454 if (bFlagSD) {
455 const TopoDS_Shape& aFj=aPSB.Shape1();
456 const TopoDS_Shape& aFk=aPSB.Shape2();
457 FillMap(aFj, aFk, aDMSLS, aAllocator);
458 }
459 }
460 aVPSB.Clear();
4e57c75e 461 //
462 // 2. Make blocks
463 MakeBlocksCnx(aDMSLS, aMBlocks, aAllocator);
464 //
465 // 3. Fill same domain faces map -> aMSDF
466 aNbS = aMBlocks.Extent();
467 for (i=0; i<aNbS; ++i) {
468 const BOPCol_ListOfShape& aLSD=aMBlocks.Find(i);
19941687 469 if (aLSD.IsEmpty()) {
470 continue;
4e57c75e 471 }
c209782c 472 //
19941687 473 const TopoDS_Shape& aFSD1=aLSD.First();
474 aItF.Initialize(aLSD);
475 for (; aItF.More(); aItF.Next()) {
476 const TopoDS_Shape& aFSD=aItF.Value();
477 myShapesSD.Bind(aFSD, aFSD1);
478 //
479 // If the face has no splits but are SD face,
480 // it is considered as splitted face
481 if (!mySplits.IsBound(aFSD)) {
482 BOPCol_ListOfShape aLS;
483 aLS.Append(aFSD);
484 mySplits.Bind(aFSD, aLS);
485 }
486 }
c209782c 487 }
4e57c75e 488 aMBlocks.Clear();
489 aDMSLS.Clear();
490 aAllocator.Nullify();
491}
492//=======================================================================
493// function: FillImagesFaces1
494// purpose:
495//=======================================================================
acccace3 496void BOPAlgo_Builder::FillImagesFaces1()
4e57c75e 497{
498 Standard_Integer i, aNbS, iSense;
499 TopoDS_Face aFSD;
500 BOPCol_ListOfInteger aLIAV;
501 BOPCol_ListOfShape aLFIm;
502 BOPCol_ListIteratorOfListOfShape aItLS;
503 //
504 aNbS=myDS->NbSourceShapes();
505 for (i=0; i<aNbS; ++i) {
506 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
507 if (aSI.ShapeType()!=TopAbs_FACE) {
508 continue;
509 }
510 //
511 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
512 //
513 if (!mySplits.IsBound(aF)) {
514 continue;
515 }
516 //
517 aLIAV.Clear();
518 myDS->AloneVertices(i, aLIAV);
519 aLFIm.Clear();
520 //
521 const BOPCol_ListOfShape& aLSp=mySplits.Find(aF);
522 aItLS.Initialize(aLSp);
523 for (; aItLS.More(); aItLS.Next()) {
524 const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
525 if (!myShapesSD.IsBound(aFSp)) {
526 aLFIm.Append(aFSp);
527 }
528 else {
529 aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp)));
530 iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD);
531 if (iSense<0) {
532 aFSD.Reverse();
533 }
534 aLFIm.Append(aFSD);
535 }
536 }
537 //
538 FillInternalVertices(aLFIm, aLIAV);
539 //
540 myImages.Bind(aF, aLFIm);
c209782c 541 //
542 //fill myOrigins
543 aItLS.Initialize(aLFIm);
544 for (; aItLS.More(); aItLS.Next()) {
545 const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
546 myOrigins.Bind(aFSp, aF);
547 }
4e57c75e 548 }// for (i=0; i<aNbS; ++i) {
549}
550//=======================================================================
551// function: FillInternalVertices
552// purpose:
553//=======================================================================
acccace3 554void BOPAlgo_Builder::FillInternalVertices(BOPCol_ListOfShape& aLFIm,
555 BOPCol_ListOfInteger& aLIAV)
4e57c75e 556{
557 Standard_Integer nV, iFlag;
558 Standard_Real aU1, aU2;
559 TopoDS_Vertex aV;
560 BRep_Builder aBB;
561 BOPCol_ListIteratorOfListOfInteger aItV;
562 BOPCol_ListIteratorOfListOfShape aItF;
563 //
564 aItV.Initialize(aLIAV);
565 for (; aItV.More(); aItV.Next()) {
566 nV=aItV.Value();
567 aV=(*(TopoDS_Vertex*)(&myDS->Shape(nV)));
568 aV.Orientation(TopAbs_INTERNAL);
569 //
570 aItF.Initialize(aLFIm);
571 for (; aItF.More(); aItF.Next()) {
572 TopoDS_Face& aF=(*(TopoDS_Face*)(&aItF.Value()));
573 iFlag=myContext->ComputeVF(aV, aF, aU1, aU2);
574 if (!iFlag) {
575 aBB.Add(aF, aV);
576 break;
577 }
578 }
579 }
580}
581//=======================================================================
582//function : MakeBlocksCnx
583//purpose :
584//=======================================================================
585void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI,
586 BOPCol_DataMapOfIntegerListOfShape& aMBlocks,
587 Handle(NCollection_IncAllocator)& aAllocator)
588{
589 Standard_Integer aNbV, aNbVS, aNbVP, aNbEC, k, i, j;
590 BOPCol_ListIteratorOfListOfShape aItLI;
591 //
592 BOPCol_MapOfShape aMVS(100, aAllocator);
593 BOPCol_IndexedMapOfShape aMEC(100, aAllocator);
594 BOPCol_IndexedMapOfShape aMVP(100, aAllocator);
595 BOPCol_IndexedMapOfShape aMVAdd(100, aAllocator);
596 //
597 aNbV=aMILI.Extent();
598 //
599 for (k=0,i=1; i<=aNbV; ++i) {
600 aNbVS=aMVS.Extent();
601 if (aNbVS==aNbV) {
602 break;
603 }
604 //
605 const TopoDS_Shape& nV=aMILI.FindKey(i);
606 if (aMVS.Contains(nV)){
607 continue;
608 }
609 aMVS.Add(nV);
610 //
611 aMEC.Clear();
612 aMVP.Clear();
613 aMVAdd.Clear();
614 //
615 aMVP.Add(nV);
302f96fb 616 for(;;) {
4e57c75e 617 aNbVP=aMVP.Extent();
618 for (j=1; j<=aNbVP; ++j) {
619 const TopoDS_Shape& nVP=aMVP(j);
620 const BOPCol_ListOfShape& aLV=aMILI.FindFromKey(nVP);
621 aItLI.Initialize(aLV);
622 for (; aItLI.More(); aItLI.Next()) {
623 const TopoDS_Shape& nVx=aItLI.Value();
624 if (aMEC.Contains(nVx)) {
625 continue;
626 }
627 //
628 aMVS.Add(nVx);
629 aMEC.Add(nVx);
630 aMVAdd.Add(nVx);
631 }
632 }
633 //
634 aNbVP=aMVAdd.Extent();
635 if (!aNbVP) {
636 break; // from while(1)
637 }
638 //
639 aMVP.Clear();
640 for (j=1; j<=aNbVP; ++j) {
641 aMVP.Add(aMVAdd(j));
642 }
643 aMVAdd.Clear();
644 }//while(1) {
645 //
646 BOPCol_ListOfShape aLIx(aAllocator);
647 //
648 aNbEC = aMEC.Extent();
649 for (j=1; j<=aNbEC; ++j) {
650 const TopoDS_Shape& nVx=aMEC(j);
651 aLIx.Append(nVx);
652 }
653 //
654 aMBlocks.Bind(k, aLIx);
655 ++k;
656 }//for (k=0,i=1; i<=aNbV; ++i)
657 aMVAdd.Clear();
658 aMVP.Clear();
659 aMEC.Clear();
660 aMVS.Clear();
661}
662
663//=======================================================================
664//function : FillMap
665//purpose :
666//=======================================================================
667void FillMap(const TopoDS_Shape& aS1,
668 const TopoDS_Shape& aS2,
669 BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS,
670 Handle(NCollection_IncAllocator)& aAllocator)
671{
672 if (aDMSLS.Contains(aS1)) {
673 BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS1);
674 aLS.Append(aS2);
675 }
676 else {
677 BOPCol_ListOfShape aLS(aAllocator);
678 aLS.Append(aS2);
679 aDMSLS.Add(aS1, aLS);
680 }
681 //
682 if (aDMSLS.Contains(aS2)) {
683 BOPCol_ListOfShape& aLS=aDMSLS.ChangeFromKey(aS2);
684 aLS.Append(aS1);
685 }
686 else {
687 BOPCol_ListOfShape aLS(aAllocator);
688 aLS.Append(aS1);
689 aDMSLS.Add(aS2, aLS);
690 }
691}
692//=======================================================================
693//function :HasPaveBlocksOnIn
694//purpose :
695//=======================================================================
696Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
697 const BOPDS_FaceInfo& aFI2)
698{
699 Standard_Boolean bRet;
700 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
701 //
702 bRet=Standard_False;
703 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
704 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
705 //
706 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
707 aItMPB.Initialize(aMPBOn2);
708 for (; aItMPB.More(); aItMPB.Next()) {
709 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
710 bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
711 if (bRet) {
712 return bRet;
713 }
714 }
715 //
716 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
717 aItMPB.Initialize(aMPBIn2);
718 for (; aItMPB.More(); aItMPB.Next()) {
719 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
720 bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
721 if (bRet) {
722 return bRet;
723 }
724 }
725 return bRet;
726}
4e57c75e 727/*
728//DEBf
729 {
730 TopoDS_Compound aCx;
731 BRep_Builder aBBx;
732 BOPCol_ListIteratorOfListOfShape aItx;
733 //
734 aBBx.MakeCompound(aCx);
735 aBBx.Add(aCx, aFF);
736 aItx.Initialize(aLE);
737 for (; aItx.More(); aItx.Next()) {
738 const TopoDS_Shape& aEx=aItx.Value();
739 aBBx.Add(aCx, aEx);
740 }
741 int a=0;
742 }
743 //DEBt
744*/