0024646: Wrong result done by Boolean Operation algorithm
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_5.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_PaveFiller.ixx>
19
20#include <NCollection_IncAllocator.hxx>
e30616a7 21//
22#include <GeomAPI_ProjectPointOnSurf.hxx>
23//
4e57c75e 24#include <Bnd_Box.hxx>
e30616a7 25//
4e57c75e 26#include <TopoDS_Vertex.hxx>
27#include <TopoDS_Edge.hxx>
28#include <TopoDS_Face.hxx>
29#include <BRep_Tool.hxx>
e30616a7 30#include <BRepBndLib.hxx>
31#include <BRepAdaptor_Curve.hxx>
32#include <BRep_Builder.hxx>
33//
4e57c75e 34#include <IntTools_EdgeFace.hxx>
35#include <IntTools_Range.hxx>
36#include <IntTools_SequenceOfCommonPrts.hxx>
37#include <IntTools_CommonPrt.hxx>
e30616a7 38//
4e57c75e 39#include <BOPCol_MapOfInteger.hxx>
e30616a7 40#include <BOPCol_NCVector.hxx>
c7b59798 41#include <BOPCol_Parallel.hxx>
e30616a7 42//
1e143abb 43#include <IntTools_Context.hxx>
44#include <IntTools_Tools.hxx>
e30616a7 45//
4e57c75e 46#include <BOPDS_Interf.hxx>
47#include <BOPDS_Iterator.hxx>
48#include <BOPDS_PaveBlock.hxx>
49#include <BOPDS_MapOfPaveBlock.hxx>
50#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
51#include <BOPDS_CommonBlock.hxx>
52#include <BOPDS_Pave.hxx>
4e57c75e 53#include <BOPDS_CoupleOfPaveBlocks.hxx>
e30616a7 54//
55#include <BOPTools_AlgoTools.hxx>
56//
4e57c75e 57#include <BOPAlgo_Tools.hxx>
4e57c75e 58
59//=======================================================================
e30616a7 60//class : BOPAlgo_EdgeFace
61//purpose :
62//=======================================================================
36f4947b 63class BOPAlgo_EdgeFace :
64 public IntTools_EdgeFace,
65 public BOPAlgo_Algo {
66
e30616a7 67 public:
36f4947b 68 DEFINE_STANDARD_ALLOC
69
70 BOPAlgo_EdgeFace() :
71 IntTools_EdgeFace(),
72 BOPAlgo_Algo(),
73 myIE(-1), myIF(-1) {
e30616a7 74 };
75 //
36f4947b 76 virtual ~BOPAlgo_EdgeFace(){
e30616a7 77 };
78 //
79 void SetIndices(const Standard_Integer nE,
80 const Standard_Integer nF) {
81 myIE=nE;
82 myIF=nF;
83 }
84 //
85 void Indices(Standard_Integer& nE,
86 Standard_Integer& nF) {
87 nE=myIE;
88 nF=myIF;
89 }
90 //
91 void SetNewSR(const IntTools_Range& aR){
92 myNewSR=aR;
93 }
94 //
95 IntTools_Range& NewSR(){
96 return myNewSR;
97 }
98 //
99 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
100 myPB=aPB;
101 }
102 //
103 Handle(BOPDS_PaveBlock)& PaveBlock() {
104 return myPB;
105 }
106 //
36f4947b 107 virtual void Perform() {
108 BOPAlgo_Algo::UserBreak();
109 IntTools_EdgeFace::Perform();
110 }
111 //
e30616a7 112 protected:
113 Standard_Integer myIE;
114 Standard_Integer myIF;
115 IntTools_Range myNewSR;
116 Handle(BOPDS_PaveBlock) myPB;
117};
118//
119//=======================================================================
120typedef BOPCol_NCVector<BOPAlgo_EdgeFace> BOPAlgo_VectorOfEdgeFace;
121//
c7b59798 122typedef BOPCol_ContextFunctor
e30616a7 123 <BOPAlgo_EdgeFace,
124 BOPAlgo_VectorOfEdgeFace,
1e143abb 125 Handle(IntTools_Context),
126 IntTools_Context> BOPAlgo_EdgeFaceFunctor;
e30616a7 127//
c7b59798 128typedef BOPCol_ContextCnt
e30616a7 129 <BOPAlgo_EdgeFaceFunctor,
130 BOPAlgo_VectorOfEdgeFace,
1e143abb 131 Handle(IntTools_Context)> BOPAlgo_EdgeFaceCnt;
e30616a7 132//
133//=======================================================================
4e57c75e 134//function : PerformEF
135//purpose :
136//=======================================================================
e30616a7 137void BOPAlgo_PaveFiller::PerformEF()
4e57c75e 138{
139 Standard_Integer iSize;
140 //
141 myErrorStatus=0;
142 //
e30616a7 143 FillShrunkData(TopAbs_EDGE, TopAbs_FACE);
144 //
4e57c75e 145 myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
146 iSize=myIterator->ExpectedLength();
147 if (!iSize) {
148 return;
149 }
e30616a7 150 //
b4109929 151 Standard_Boolean bJustAdd, bV[2];
152 Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX, nV[2];
e30616a7 153 Standard_Integer aNbEdgeFace, k;
b4109929 154 Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection;
4e57c75e 155 Handle(NCollection_IncAllocator) aAllocator;
156 TopAbs_ShapeEnum aType;
157 BOPDS_ListIteratorOfListOfPaveBlock aIt;
e30616a7 158 BOPAlgo_VectorOfEdgeFace aVEdgeFace;
4e57c75e 159 BRep_Builder aBB;
e30616a7 160 //-----------------------------------------------------scope f
4e57c75e 161 //
e30616a7 162 ////aAllocator=new NCollection_IncAllocator();
4e57c75e 163
164 BOPCol_MapOfInteger aMIEFC(100, aAllocator);
165 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
166 BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator);
167 //
168 aDiscretize=35;
169 aDeflection=0.01;
170 //
171 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
4e57c75e 172 aEFs.SetIncrement(iSize);
4e57c75e 173 //
174 for (; myIterator->More(); myIterator->Next()) {
175 myIterator->Value(nE, nF, bJustAdd);
176 if(bJustAdd) {
177 continue;
178 }
179 //
180 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
181 if (aSIE.HasFlag()){//degenerated
182 continue;
183 }
184 //
185 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
186 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
187 const Bnd_Box& aBBF=myDS->ShapeInfo(nF).Box();
188 //
189 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
190 const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
4e57c75e 191 //
192 aTolE=BRep_Tool::Tolerance(aE);
193 aTolF=BRep_Tool::Tolerance(aF);
194 //
195 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
196 aIt.Initialize(aLPB);
197 for (; aIt.More(); aIt.Next()) {
198 Handle(BOPDS_PaveBlock)& aPB=aIt.ChangeValue();
199 //
5a77460e 200 const Handle(BOPDS_PaveBlock) aPBR=myDS->RealPaveBlock(aPB);
4e57c75e 201 if (aMPBF.Contains(aPBR)) {
202 continue;
203 }
204 //
205 if (!aPB->HasShrunkData()) {
e30616a7 206 continue;
4e57c75e 207 }
208 //
209 Bnd_Box aBBE;
210 aPB->ShrunkData(aTS1, aTS2, aBBE);
211 //
212 if (aBBF.IsOut (aBBE)) {
213 continue;
214 }
215 //
e30616a7 216 BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace.Append1();
217 //
218 aEdgeFace.SetIndices(nE, nF);
219 aEdgeFace.SetPaveBlock(aPB);
4e57c75e 220 //
221 aEdgeFace.SetEdge (aE);
222 aEdgeFace.SetFace (aF);
223 aEdgeFace.SetTolE (aTolE);
224 aEdgeFace.SetTolF (aTolF);
225 aEdgeFace.SetDiscretize (aDiscretize);
226 aEdgeFace.SetDeflection (aDeflection);
4e57c75e 227 //
228 IntTools_Range aSR(aTS1, aTS2);
229 IntTools_Range anewSR=aSR;
4e57c75e 230 BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR);
e30616a7 231 aEdgeFace.SetNewSR(anewSR);
b4109929 232 //
233 aPB->Range(aT1, aT2);
234 IntTools_Range aPBRange(aT1, aT2);
235 aSR = aPBRange;
236 BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange);
b4109929 237 aEdgeFace.SetRange (aPBRange);
36f4947b 238 aEdgeFace.SetProgressIndicator(myProgressIndicator);
4e57c75e 239 //
e30616a7 240 }//for (; aIt.More(); aIt.Next()) {
241 }//for (; myIterator->More(); myIterator->Next()) {
242 //
243 aNbEdgeFace=aVEdgeFace.Extent();
244 //=================================================================
245 BOPAlgo_EdgeFaceCnt::Perform(myRunParallel, aVEdgeFace, myContext);
246 //=================================================================
247 //
248 for (k=0; k < aNbEdgeFace; ++k) {
249 BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace(k);
250 if (!aEdgeFace.IsDone()) {
251 continue;
252 }
253 //~~~
254 aEdgeFace.Indices(nE, nF);
255 //
256 const TopoDS_Edge& aE=aEdgeFace.Edge();
257 const TopoDS_Face& aF=aEdgeFace.Face();
258 //
259 aTolE=aEdgeFace.TolE();
260 aTolF=aEdgeFace.TolF();
261 const IntTools_Range& anewSR=aEdgeFace.NewSR();
262 Handle(BOPDS_PaveBlock)& aPB=aEdgeFace.PaveBlock();
263 //
264 aPB->Range(aT1, aT2);
265 aPB->Indices(nV[0], nV[1]);
266 //
267 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
e30616a7 268 const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
269 const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
270 //~~~
271 const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts();
272 aNbCPrts=aCPrts.Length();
273 for (i=1; i<=aNbCPrts; ++i) {
274 const IntTools_CommonPrt& aCPart=aCPrts(i);
275 aType=aCPart.Type();
276 switch (aType) {
4e57c75e 277 case TopAbs_VERTEX: {
b4109929 278 Standard_Boolean bIsOnPave[2];
279 Standard_Integer j;
4e57c75e 280 Standard_Real aT, aTolToDecide;
281 TopoDS_Vertex aVnew;
e30616a7 282 //
1e143abb 283 IntTools_Tools::VertexParameter(aCPart, aT);
4e57c75e 284 BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew);
285 //
286 const IntTools_Range& aR=aCPart.Range1();
287 aTolToDecide=5.e-8;
4e57c75e 288 //
e30616a7 289 IntTools_Range aR1(aT1,anewSR.First()),aR2(anewSR.Last(), aT2);
4e57c75e 290 //
1e143abb 291 bIsOnPave[0]=IntTools_Tools::IsInRange(aR1, aR, aTolToDecide);
292 bIsOnPave[1]=IntTools_Tools::IsInRange(aR2, aR, aTolToDecide);
b4109929 293 //
294 if (bIsOnPave[0] && bIsOnPave[1]) {
295 bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn);
296 bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn);
297 if (bV[0] && bV[1]) {
4e57c75e 298 IntTools_CommonPrt aCP = aCPart;
299 aCP.SetType(TopAbs_EDGE);
402bfe81 300 BOPDS_InterfEF& aEF=aEFs.Append1();
301 iX=aEFs.Extent()-1;
4e57c75e 302 aEF.SetIndices(nE, nF);
303 aEF.SetCommonPart(aCP);
304 myDS->AddInterf(nE, nF);
ceb31c61 305 //
306 aMIEFC.Add(nF);
307 //
4e57c75e 308 BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
309 break;
310 }
311 }
b4109929 312 for (j=0; j<2; ++j) {
313 if (bIsOnPave[j]) {
314 bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn);
315 if (bV[j]) {
e30616a7 316 const TopoDS_Vertex& aV=
317 (*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
b4109929 318 BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
319 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]);
320 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
321 BRepBndLib::Add(aV, aBoxDS);
322 }
323 else {
324 bIsOnPave[j] = ForceInterfVF(nV[j], nF);
325 }
4e57c75e 326 }
4e57c75e 327 }
328 //
b4109929 329 if (!bIsOnPave[0] && !bIsOnPave[1]) {
330 if (CheckFacePaves(aVnew, aMIFOn)) {
4e57c75e 331 continue;
332 }
b4109929 333 //
334 const gp_Pnt& aPnew = BRep_Tool::Pnt(aVnew);
bd28b2af 335 Standard_Real aTolV = BRep_Tool::Tolerance(aVnew);
336 aTolV = Max(aTolV, Max(aTolE, aTolF));
337 //
338 if (!myContext->IsPointInFace(aPnew, aF, aTolV)) {
4e57c75e 339 continue;
340 }
b4109929 341 //
bd28b2af 342 aBB.UpdateVertex(aVnew, aTolV);
4e57c75e 343 //
344 aMIEFC.Add(nF);
345 // 1
402bfe81 346 BOPDS_InterfEF& aEF=aEFs.Append1();
347 iX=aEFs.Extent()-1;
4e57c75e 348 aEF.SetIndices(nE, nF);
349 aEF.SetCommonPart(aCPart);
350 // 2
351 myDS->AddInterf(nE, nF);
352 // 3
353 BOPDS_CoupleOfPaveBlocks aCPB;
354 //
355 aCPB.SetPaveBlocks(aPB, aPB);
356 aCPB.SetIndexInterf(iX);
357 aMVCPB.Add(aVnew, aCPB);
358 }
359 }
360 break;
361 case TopAbs_EDGE: {
362 aMIEFC.Add(nF);
363 //
364 // 1
402bfe81 365 BOPDS_InterfEF& aEF=aEFs.Append1();
366 iX=aEFs.Extent()-1;
4e57c75e 367 aEF.SetIndices(nE, nF);
368 //
b4109929 369 bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn);
370 bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn);
371 if (!bV[0] || !bV[1]) {
4e57c75e 372 myDS->AddInterf(nE, nF);
373 break;
374 }
375 //update tolerance of edge if needed
376 if (aTolE < aTolF) {
377 myDS->UpdateEdgeTolerance(nE, aTolF);
378 aTolE = aTolF;
379 }
380 aEF.SetCommonPart(aCPart);
381 // 2
382 myDS->AddInterf(nE, nF);
383 // 3
384 BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
385
386 }
387 break;
388 default:
389 break;
e30616a7 390 }//switch (aType) {
391 }//for (i=1; i<=aNbCPrts; ++i) {
392 }// for (k=0; k < aNbEdgeEdge; ++k) {
4e57c75e 393 //
394 //=========================================
395 // post treatment
396 //=========================================
5a77460e 397 BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator, myDS);
4e57c75e 398 PerformVerticesEF(aMVCPB, aAllocator);
399 //
400 // Update FaceInfoIn for all faces having EF common parts
401 BOPCol_MapIteratorOfMapOfInteger aItMI;
402 aItMI.Initialize(aMIEFC);
403 for (; aItMI.More(); aItMI.Next()) {
404 nF=aItMI.Value();
405 myDS->UpdateFaceInfoIn(nF);
406 }
407 // Refine FaceInfoOn to remove all formal pave blocks
408 // made during EF processing
409 //myDS->RefineFaceInfoOn();
410 //-----------------------------------------------------scope t
411 aMIEFC.Clear();
412 aMVCPB.Clear();
413 aMPBLI.Clear();
e30616a7 414 ////aAllocator.Nullify();
4e57c75e 415}
416//=======================================================================
417//function : PerformVertices1
418//purpose :
419//=======================================================================
e30616a7 420Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF
421 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
422 Handle(NCollection_BaseAllocator)& theAllocator)
4e57c75e 423{
424 Standard_Integer aNbV, iRet;
425 //
426 iRet=0;
427 aNbV=theMVCPB.Extent();
428 if (!aNbV) {
429 return iRet;
430 }
431 //
432 Standard_Integer nVx, nVSD, iV, iErr, nE, iFlag, iX, i, aNbPBLI;
433 Standard_Real aT;
434 TopoDS_Shape aV;
435 BOPCol_ListIteratorOfListOfShape aItLS;
436 BOPCol_ListIteratorOfListOfInteger aItLI;
437 BOPDS_PDS aPDS;
438 BOPDS_ShapeInfo aSI;
439 BOPDS_Pave aPave;
440 //
441 BOPCol_ListOfShape aLS(theAllocator);
442 BOPCol_DataMapOfShapeInteger aMVI(100, theAllocator);
443 BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator);
444 BOPAlgo_PaveFiller aPF(theAllocator);
445 //
446 aSI.SetShapeType(TopAbs_VERTEX);
447 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
448 //
449 // 1 prepare arguments
450 for (i=1; i<=aNbV; ++i) {
451 const TopoDS_Shape& aS=theMVCPB.FindKey(i);
452 aLS.Append(aS);
453 }
454 //
455 // 2 Fuse vertices
456 aPF.SetArguments(aLS);
457 aPF.Perform();
458 iErr=aPF.ErrorStatus();
459 if (iErr) {
460 iRet=1;
461 return iRet;
462 }
463 aPDS=aPF.PDS();
464 //
465 // 3 Add new vertices to theDS;
466 // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI
467 aItLS.Initialize(aLS);
468 for (; aItLS.More(); aItLS.Next()) {
469 const TopoDS_Shape& aVx=aItLS.Value();
470 nVx=aPDS->Index(aVx);
471 //
472 if (aPDS->HasShapeSD(nVx, nVSD)) {
473 aV=aPDS->Shape(nVSD);
474 }
475 else {
476 aV=aVx;
477 }
478 // index of new vertex in theDS -> iV
479 if (!aMVI.IsBound(aV)) {
480 aSI.SetShape(aV);
481 iV=myDS->Append(aSI);
482 //
483 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
484 Bnd_Box& aBox=aSIDS.ChangeBox();
485 BRepBndLib::Add(aV, aBox);
486 //
487 aMVI.Bind(aV, iV);
488 }
489 else {
490 iV=aMVI.Find(aV);
491 }
492 //
493 BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx);
494 aCPB.SetIndex(iV);
495 // update EF interference
496 iX=aCPB.IndexInterf();
497 BOPDS_InterfEF& aEF=aEFs(iX);
498 aEF.SetIndexNew(iV);
499 // map aMPBLI
500 const Handle(BOPDS_PaveBlock)& aPB=aCPB.PaveBlock1();
501 if (aMPBLI.Contains(aPB)) {
502 BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB);
503 aLI.Append(iV);
504 }
505 else {
506 BOPCol_ListOfInteger aLI(theAllocator);
507 aLI.Append(iV);
508 aMPBLI.Add(aPB, aLI);
509 }
510 }
511 //
512 // 5
513 // 5.1 Compute Extra Paves and
514 // 5.2. Add Extra Paves to the PaveBlocks
515 aNbPBLI=aMPBLI.Extent();
516 for (i=1; i<=aNbPBLI; ++i) {
517 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
518 const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i);
519 nE=aPB->OriginalEdge();
520 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
521 //
522 aItLI.Initialize(aLI);
523 for (; aItLI.More(); aItLI.Next()) {
524 nVx=aItLI.Value();
525 const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
526 //
527 iFlag=myContext->ComputeVE (aVx, aE, aT);
528 if (!iFlag) {
529 aPave.SetIndex(nVx);
530 aPave.SetParameter(aT);
531 aPB->AppendExtPave(aPave);
532 }
533 }
534 }
535 // 6 Split PaveBlocksa
536 for (i=1; i<=aNbPBLI; ++i) {
537 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
538 nE=aPB->OriginalEdge();
539 // 3
5a77460e 540 if (!myDS->IsCommonBlock(aPB)) {
4e57c75e 541 myDS->UpdatePaveBlock(aPB);
542 }
543 else {
5a77460e 544 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
4e57c75e 545 myDS->UpdateCommonBlock(aCB);
546 }
547 }//for (; aItMPBLI.More(); aItMPBLI.Next()) {
548 //
549 return iRet;
550}
551//=======================================================================
552// function: CheckFacePaves
553// purpose:
554//=======================================================================
e30616a7 555Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
556 (const Standard_Integer nVx,
557 const BOPCol_MapOfInteger& aMIFOn,
558 const BOPCol_MapOfInteger& aMIFIn)
4e57c75e 559{
560 Standard_Boolean bRet;
561 Standard_Integer nV;
562 BOPCol_MapIteratorOfMapOfInteger aIt;
563 //
564 bRet=Standard_False;
565 //
566 aIt.Initialize(aMIFOn);
567 for (; aIt.More(); aIt.Next()) {
568 nV=aIt.Value();
569 if (nV==nVx) {
570 bRet=!bRet;
571 return bRet;
572 }
573 }
574 aIt.Initialize(aMIFIn);
575 for (; aIt.More(); aIt.Next()) {
576 nV=aIt.Value();
577 if (nV==nVx) {
578 bRet=!bRet;
579 return bRet;
580 }
581 }
582 //
583 return bRet;
584}
585//=======================================================================
586// function: CheckFacePaves
587// purpose:
588//=======================================================================
e30616a7 589Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
590 (const TopoDS_Vertex& aVnew,
591 const BOPCol_MapOfInteger& aMIF)
4e57c75e 592{
593 Standard_Boolean bRet;
594 Standard_Integer nV, iFlag;
595 BOPCol_MapIteratorOfMapOfInteger aIt;
596 //
597 bRet=Standard_True;
598 //
599 aIt.Initialize(aMIF);
600 for (; aIt.More(); aIt.Next()) {
601 nV=aIt.Value();
602 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
603 iFlag=BOPTools_AlgoTools::ComputeVV(aVnew, aV);
604 if (!iFlag) {
605 return bRet;
606 }
607 }
608 //
609 return !bRet;
610}
b4109929 611//=======================================================================
612//function : ForceInterfVF
613//purpose :
614//=======================================================================
e30616a7 615Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF
616 (const Standard_Integer nV,
617 const Standard_Integer nF)
b4109929 618{
619 Standard_Boolean bRet;
620 //
621 bRet = Standard_False;
622 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
623 const TopoDS_Face& aF = *(TopoDS_Face*) &myDS->Shape(nF);
624 //
625 GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aF);
626 const gp_Pnt& aP = BRep_Tool::Pnt(aV);
627 aProj.Perform(aP);
628 if (!aProj.IsDone()) {
629 return bRet;
630 }
631 Standard_Real aDist, U, V;
632 //
633 aDist=aProj.LowerDistance();
634 aProj.LowerDistanceParameters(U, V);
635 //
636 gp_Pnt2d aP2d(U, V);
637 bRet = myContext->IsPointInFace (aF, aP2d);
638 if (bRet) {
402bfe81 639 //Standard_Integer i;
b4109929 640 BRep_Builder aBB;
641 //
642 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
402bfe81 643 BOPDS_InterfVF& aVF=aVFs.Append1();
b4109929 644 aVF.SetIndices(nV, nF);
645 aVF.SetUV(U, V);
646 //
647 myDS->AddInterf(nV, nF);
648 //
649 aBB.UpdateVertex(aV, aDist);
650 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
651 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
652 BRepBndLib::Add(aV, aBoxDS);
653 //
654 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
655 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
656 aMVIn.Add(nV);
657 }
658 //
659 return bRet;
660}
661