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