0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_7.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 <BOPAlgo_PaveFiller.hxx>
20#include <BOPAlgo_SectionAttribute.hxx>
21#include <BOPCol_MapOfShape.hxx>
505abfb8 22#include <BOPCol_NCVector.hxx>
c7b59798 23#include <BOPCol_Parallel.hxx>
4e57c75e 24#include <BOPDS_CommonBlock.hxx>
42cf5bc1 25#include <BOPDS_Curve.hxx>
26#include <BOPDS_DS.hxx>
27#include <BOPDS_FaceInfo.hxx>
28#include <BOPDS_Interf.hxx>
29#include <BOPDS_Iterator.hxx>
30#include <BOPDS_ListOfPaveBlock.hxx>
31#include <BOPDS_MapOfPaveBlock.hxx>
4e57c75e 32#include <BOPDS_Pave.hxx>
42cf5bc1 33#include <BOPDS_PaveBlock.hxx>
4e57c75e 34#include <BOPDS_ShapeInfo.hxx>
4e57c75e 35#include <BOPDS_VectorOfCurve.hxx>
36#include <BOPDS_VectorOfFaceInfo.hxx>
42cf5bc1 37#include <BOPDS_VectorOfInterfFF.hxx>
38#include <BOPDS_VectorOfListOfPaveBlock.hxx>
f1baf495 39#include <BOPTools_AlgoTools.hxx>
40#include <BOPTools_AlgoTools2D.hxx>
42cf5bc1 41#include <BRep_Builder.hxx>
42#include <BRep_Tool.hxx>
43#include <BRepBndLib.hxx>
44#include <Geom2d_Curve.hxx>
45#include <Geom_Curve.hxx>
46#include <Geom_Plane.hxx>
47#include <Geom_RectangularTrimmedSurface.hxx>
48#include <Geom_Surface.hxx>
49#include <gp_Pnt.hxx>
50#include <IntTools_Context.hxx>
51#include <NCollection_IncAllocator.hxx>
52#include <TopExp.hxx>
53#include <TopExp_Explorer.hxx>
54#include <TopoDS_Edge.hxx>
55#include <TopoDS_Face.hxx>
56#include <TopoDS_Vertex.hxx>
f1baf495 57
58static
59 Standard_Boolean IsBasedOnPlane(const TopoDS_Face& aF);
4e57c75e 60
505abfb8 61
4e57c75e 62static void UpdateVertices(const TopoDS_Edge& aE,
63 const TopoDS_Face& aF);
64
65//=======================================================================
505abfb8 66//class : BOPAlgo_SplitEdge
67//purpose :
68//=======================================================================
36f4947b 69class BOPAlgo_SplitEdge : public BOPAlgo_Algo {
70
505abfb8 71 public:
36f4947b 72 DEFINE_STANDARD_ALLOC
73
74 BOPAlgo_SplitEdge() :
75 BOPAlgo_Algo() {
505abfb8 76 myT1=0.;
77 myT2=0.;
78 }
79 //
36f4947b 80 virtual ~BOPAlgo_SplitEdge() {
505abfb8 81 }
82 //
83 void SetData(const TopoDS_Edge& aE,
84 const TopoDS_Vertex& aV1,
85 const Standard_Real aT1,
86 const TopoDS_Vertex& aV2,
87 const Standard_Real aT2) {
88 myE=aE;
89 myV1=aV1;
90 myT1=aT1;
91 myV2=aV2;
92 myT2=aT2;
93 myESp=aE;
94 }
95 //
96 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
97 myPB=aPB;
98 }
99 //
100 Handle(BOPDS_PaveBlock)& PaveBlock() {
101 return myPB;
102 }
103 //
104 void SetCommonBlock(const Handle(BOPDS_CommonBlock)& aCB) {
105 myCB=aCB;
106 }
107 //
108 Handle(BOPDS_CommonBlock)& CommonBlock() {
109 return myCB;
110 }
111 //
112 const TopoDS_Edge& SplitEdge() const {
113 return myESp;
114 }
115 //
116 const Bnd_Box Box() {
117 return myBox;
118 }
119 //
36f4947b 120 virtual void Perform () {
121 BOPAlgo_Algo::UserBreak();
505abfb8 122 BOPTools_AlgoTools::MakeSplitEdge(myE,
123 myV1, myT1,
124 myV2, myT2,
125 myESp);
126 BRepBndLib::Add(myESp, myBox);
127 }
128 //
129 protected:
130 // ->
131 TopoDS_Edge myE;
132 TopoDS_Vertex myV1;
133 Standard_Real myT1;
134 TopoDS_Vertex myV2;
135 Standard_Real myT2;
136 // <->
137 Handle(BOPDS_PaveBlock) myPB;
138 Handle(BOPDS_CommonBlock) myCB;
139 // <-
140 TopoDS_Edge myESp;
141 Bnd_Box myBox;
142};
143//
144//=======================================================================
145typedef BOPCol_NCVector
146 <BOPAlgo_SplitEdge> BOPAlgo_VectorOfSplitEdge;
147//
c7b59798 148typedef BOPCol_Functor
505abfb8 149 <BOPAlgo_SplitEdge,
150 BOPAlgo_VectorOfSplitEdge> BOPAlgo_SplitEdgeFunctor;
151//
c7b59798 152typedef BOPCol_Cnt
505abfb8 153 <BOPAlgo_SplitEdgeFunctor,
154 BOPAlgo_VectorOfSplitEdge> BOPAlgo_SplitEdgeCnt;
155//
156//=======================================================================
f1baf495 157//class : BOPAlgo_MPC
158//purpose :
159//=======================================================================
36f4947b 160class BOPAlgo_MPC : public BOPAlgo_Algo {
161
f1baf495 162 public:
36f4947b 163 DEFINE_STANDARD_ALLOC
164
165 BOPAlgo_MPC() :
166 BOPAlgo_Algo(),
167 myFlag(Standard_False) {
f1baf495 168 };
169 //
36f4947b 170 virtual ~BOPAlgo_MPC(){
f1baf495 171 };
172 //
173 void SetEdge(const TopoDS_Edge& aE) {
174 myE=aE;
175 }
176 //
177 const TopoDS_Edge& Edge() const {
178 return myE;
179 }
180 //
181 void SetFace(const TopoDS_Face& aF) {
182 myF=aF;
183 }
184 //
185 const TopoDS_Face& Face() const {
186 return myF;
187 }
188 //
189 void SetFlag(const Standard_Boolean bFlag) {
190 myFlag=bFlag;
191 }
192 //
193 Standard_Boolean Flag() const {
194 return myFlag;
195 }
196 //
905522ee 197 void SetData(const TopoDS_Edge& aEz,
198 const TopoDS_Vertex& aV1,
199 const Standard_Real aT1,
200 const TopoDS_Vertex& aV2,
201 const Standard_Real aT2) {
202 myEz=aEz;
203 myV1=aV1;
204 myT1=aT1;
205 myV2=aV2;
206 myT2=aT2;
207 }
208 //
209 void SetContext(const Handle(IntTools_Context)& aContext) {
210 myContext=aContext;
211 }
212 //
213 const Handle(IntTools_Context)& Context()const {
214 return myContext;
215 }
216 //
36f4947b 217 virtual void Perform() {
905522ee 218 Standard_Integer iErr;
219 //
220 iErr=1;
221 if (!myEz.IsNull()) {
222 TopoDS_Edge aSpz;
223 //
224 BOPTools_AlgoTools::MakeSplitEdge(myEz,myV1, myT1,
225 myV2, myT2, aSpz);
226 //
227 iErr=
228 BOPTools_AlgoTools2D::AttachExistingPCurve(aSpz,
229 myE,
230 myF,
231 myContext);
232 }
233 //
234 if (iErr) {
235 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF);
236 }
237 //
f1baf495 238 if (myFlag) {
239 UpdateVertices(myE, myF);
240 }
241 }
242 //
243 protected:
244 Standard_Boolean myFlag;
245 TopoDS_Edge myE;
246 TopoDS_Face myF;
905522ee 247 TopoDS_Edge myEz;
248 TopoDS_Vertex myV1;
249 Standard_Real myT1;
250 TopoDS_Vertex myV2;
251 Standard_Real myT2;
252 //
253 Handle(IntTools_Context) myContext;
f1baf495 254};
255//
256//=======================================================================
257typedef BOPCol_NCVector
258 <BOPAlgo_MPC> BOPAlgo_VectorOfMPC;
259//
905522ee 260typedef BOPCol_ContextFunctor
f1baf495 261 <BOPAlgo_MPC,
905522ee 262 BOPAlgo_VectorOfMPC,
263 Handle(IntTools_Context),
264 IntTools_Context> BOPAlgo_MPCFunctor;
f1baf495 265//
905522ee 266typedef BOPCol_ContextCnt
f1baf495 267 <BOPAlgo_MPCFunctor,
905522ee 268 BOPAlgo_VectorOfMPC,
269 Handle(IntTools_Context)> BOPAlgo_MPCCnt;
f1baf495 270//
271//=======================================================================
272//class : BOPAlgo_BPC
273//purpose :
274//=======================================================================
275class BOPAlgo_BPC {
276 public:
277 BOPAlgo_BPC(){
278 };
279 //
280 ~BOPAlgo_BPC(){
281 };
282 //
283 void SetFace(const TopoDS_Face& aF) {
284 myF=aF;
285 }
286 //
287 void SetEdge(const TopoDS_Edge& aE) {
288 myE=aE;
289 }
290 //
291 void Perform() {
292 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF);
293 };
294 //
295 protected:
296 TopoDS_Edge myE;
297 TopoDS_Face myF;
298};
299//=======================================================================
300typedef BOPCol_NCVector
301 <BOPAlgo_BPC> BOPAlgo_VectorOfBPC;
302//
c7b59798 303typedef BOPCol_Functor
f1baf495 304 <BOPAlgo_BPC,
305 BOPAlgo_VectorOfBPC> BOPAlgo_BPCFunctor;
306//
c7b59798 307typedef BOPCol_Cnt
f1baf495 308 <BOPAlgo_BPCFunctor,
309 BOPAlgo_VectorOfBPC> BOPAlgo_BPCCnt;
310//
311//
312//=======================================================================
4e57c75e 313// function: MakeSplitEdges
314// purpose:
315//=======================================================================
505abfb8 316void BOPAlgo_PaveFiller::MakeSplitEdges()
4e57c75e 317{
318 Standard_Integer aNbPBP;
319 //
320 myErrorStatus=0;
321 //
322 BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
323 aNbPBP=aPBP.Extent();
324 if(!aNbPBP) {
325 return;
326 }
327 //
78c66ef1 328 Standard_Boolean bCB, bV1, bV2;
505abfb8 329 Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, aNbVBSE, k;
4e57c75e 330 Standard_Real aT1, aT2;
4e57c75e 331 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB;
505abfb8 332 Handle(BOPDS_PaveBlock) aPB;
333 BOPDS_MapOfPaveBlock aMPB(100);
334 TopoDS_Vertex aV1, aV2;
335 TopoDS_Edge aE;
336 BOPAlgo_VectorOfSplitEdge aVBSE;
337
4e57c75e 338 //
339 for (i=0; i<aNbPBP; ++i) {
340 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
341 //
342 aNbPB=aLPB.Extent();
4e57c75e 343 if (aNbPB==1) {
344 aPB=aLPB.First();
345 aPB->Indices(nV1, nV2);
346 bV1=myDS->IsNewShape(nV1);
347 bV2=myDS->IsNewShape(nV2);
348 //
349 if (!(bV1 || bV2)) {
350 nE=aPB->OriginalEdge();
351 aPB->SetEdge(nE);
352 continue;
353 }
354 }
355 //
356 aItPB.Initialize(aLPB);
357 for (; aItPB.More(); aItPB.Next()) {
358 aPB=aItPB.Value();
5a77460e 359 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
4e57c75e 360 bCB=!aCB.IsNull();
361 if (bCB) {
362 myDS->SortPaveBlocks(aCB);
363 aPB=aCB->PaveBlock1();
364 }
365 //
366 if (aMPB.Add(aPB)) {
367 nE=aPB->OriginalEdge();
78c66ef1 368 aPB->Indices(nV1, nV2);
369 aPB->Range(aT1, aT2);
4e57c75e 370 //
505abfb8 371 aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
372 aE.Orientation(TopAbs_FORWARD);
373 //
374 aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
375 aV1.Orientation(TopAbs_FORWARD);
4e57c75e 376 //
505abfb8 377 aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
378 aV2.Orientation(TopAbs_REVERSED);
379 //
380 BOPAlgo_SplitEdge& aBSE=aVBSE.Append1();
381 //
382 aBSE.SetData(aE, aV1, aT1, aV2, aT2);
383 aBSE.SetPaveBlock(aPB);
4e57c75e 384 if (bCB) {
505abfb8 385 aBSE.SetCommonBlock(aCB);
4e57c75e 386 }
36f4947b 387 aBSE.SetProgressIndicator(myProgressIndicator);
505abfb8 388 }
389 } // for (; aItPB.More(); aItPB.Next()) {
390 } // for (i=0; i<aNbPBP; ++i) {
391 //
392 aNbVBSE=aVBSE.Extent();
393 //======================================================
394 BOPAlgo_SplitEdgeCnt::Perform(myRunParallel, aVBSE);
395 //======================================================
396 //
397 BOPDS_ShapeInfo aSI;
4e57c75e 398 //
505abfb8 399 aSI.SetShapeType(TopAbs_EDGE);
400 //
401 for (k=0; k < aNbVBSE; ++k) {
402 BOPAlgo_SplitEdge& aBSE=aVBSE(k);
403 //
404 const TopoDS_Edge& aSp=aBSE.SplitEdge();
405 const Bnd_Box& aBox=aBSE.Box();
406 //
407 Handle(BOPDS_PaveBlock) aPBk=aBSE.PaveBlock();
408 Handle(BOPDS_CommonBlock)& aCBk=aBSE.CommonBlock();
409 //
410 aSI.SetShape(aSp);
411 aSI.ChangeBox()=aBox;
412 //
413 nSp=myDS->Append(aSI);
414 //
415 if (!aCBk.IsNull()) {
416 aCBk->SetEdge(nSp);
417 }
418 else {
419 aPBk->SetEdge(nSp);
420 }
421 }
4e57c75e 422}
4e57c75e 423//=======================================================================
78c66ef1 424// function: SplitEdge
425// purpose:
426//=======================================================================
427Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE,
428 const Standard_Integer nV1,
429 const Standard_Real aT1,
430 const Standard_Integer nV2,
431 const Standard_Real aT2)
432{
433 Standard_Integer nSp;
434 TopoDS_Vertex aV1, aV2;
435 TopoDS_Edge aE, aSp;
436 BOPDS_ShapeInfo aSI;
437 //
438 aSI.SetShapeType(TopAbs_EDGE);
439 //
440 aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
441 aE.Orientation(TopAbs_FORWARD);
442 //
443 aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
444 aV1.Orientation(TopAbs_FORWARD);
445 //
446 aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
447 aV2.Orientation(TopAbs_REVERSED);
448 //
449 BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
450 //
451 aSI.SetShape(aSp);
452 //
453 Bnd_Box& aBox=aSI.ChangeBox();
454 BRepBndLib::Add(aSp, aBox);
455 //
456 nSp=myDS->Append(aSI);
457 return nSp;
458}
78c66ef1 459//=======================================================================
4e57c75e 460// function: MakePCurves
461// purpose:
462//=======================================================================
505abfb8 463void BOPAlgo_PaveFiller::MakePCurves()
4e57c75e 464{
905522ee 465 Standard_Boolean bHasPC;
466 Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI, nEx;
4e57c75e 467 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
468 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
469 TopoDS_Face aF1F, aF2F;
f1baf495 470 BOPAlgo_VectorOfMPC aVMPC;
4e57c75e 471 //
472 myErrorStatus=0;
473 //
474 // 1. Process Common Blocks
475 const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool();
476 //
477 aNbFI=aFIP.Extent();
478 for (i=0; i<aNbFI; ++i) {
479 const BOPDS_FaceInfo& aFI=aFIP(i);
480 nF1=aFI.Index();
481 //
482 aF1F=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
483 aF1F.Orientation(TopAbs_FORWARD);
484 // In
485 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
486 aItMPB.Initialize(aMPBIn);
487 for(; aItMPB.More(); aItMPB.Next()) {
488 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
489 nE=aPB->Edge();
490 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
491 //
f1baf495 492 BOPAlgo_MPC& aMPC=aVMPC.Append1();
493 aMPC.SetEdge(aE);
494 aMPC.SetFace(aF1F);
36f4947b 495 aMPC.SetProgressIndicator(myProgressIndicator);
4e57c75e 496 }
f1baf495 497 //
4e57c75e 498 // On
499 const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
500 aItMPB.Initialize(aMPBOn);
501 for(; aItMPB.More(); aItMPB.Next()) {
502 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
905522ee 503 nE=aPB->Edge();
504 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
505 bHasPC=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF1F);
506 if (bHasPC) {
507 continue;
508 }
509 //
510 Handle(BOPDS_CommonBlock) aCB=myDS->CommonBlock(aPB);
c04c30b3 511 if (aCB.IsNull()) {
905522ee 512 continue;
513 }
514 //
515 const BOPDS_ListOfPaveBlock& aLPB=aCB->PaveBlocks();
516 if (aLPB.Extent()<2) {
517 continue;
518 }
519 //
520 BOPAlgo_MPC& aMPC=aVMPC.Append1();
521 //
522 aItLPB.Initialize(aLPB);
523 for(; aItLPB.More(); aItLPB.Next()) {
524 const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
525 if (aPBx==aPB) {
526 continue;
527 }
528 //
529 nEx=aPBx->OriginalEdge();
530 const TopoDS_Edge& aEx=(*(TopoDS_Edge *)(&myDS->Shape(nEx)));
531 bHasPC=BOPTools_AlgoTools2D::HasCurveOnSurface (aEx, aF1F);
532 if (!bHasPC) {
533 continue;
534 }
535 //
536 Standard_Integer nV1x, nV2x;
537 Standard_Real aT1x, aT2x;
538 TopoDS_Vertex aV1x, aV2x;
539 TopoDS_Edge aEz;
540 //
541 aEz=aEx;
542 aEz.Orientation(TopAbs_FORWARD);
543 //
544 aPBx->Indices(nV1x, nV2x);
545 aPBx->Range(aT1x, aT2x);
546 //
547 aV1x=(*(TopoDS_Vertex *)(&myDS->Shape(nV1x)));
548 aV1x.Orientation(TopAbs_FORWARD);
4e57c75e 549 //
905522ee 550 aV2x=(*(TopoDS_Vertex *)(&myDS->Shape(nV2x)));
551 aV2x.Orientation(TopAbs_REVERSED);
552 //
553 aMPC.SetData(aEz, aV1x, aT1x, aV2x, aT2x);
554 //
555 break;
4e57c75e 556 }
905522ee 557 //
558 aMPC.SetEdge(aE);
559 aMPC.SetFace(aF1F);
560 aMPC.SetProgressIndicator(myProgressIndicator);
4e57c75e 561 }
f1baf495 562 }// for (i=0; i<aNbFI; ++i) {
4e57c75e 563 //
564 // 2. Process section edges
f1baf495 565 Standard_Boolean bPCurveOnS[2];
566 Standard_Integer m;
567 TopoDS_Face aFf[2];
568 //
569 bPCurveOnS[0]=mySectionAttribute.PCurveOnS1();
570 bPCurveOnS[1]=mySectionAttribute.PCurveOnS2();
571 //
572 if (bPCurveOnS[0] || bPCurveOnS[1]) {
573 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
574 aNbFF=aFFs.Extent();
575 for (i=0; i<aNbFF; ++i) {
576 const BOPDS_InterfFF& aFF=aFFs(i);
577 aFF.Indices(nF1, nF2);
578 //
579 aFf[0]=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
580 aFf[0].Orientation(TopAbs_FORWARD);
581 //
582 aFf[1]=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
583 aFf[1].Orientation(TopAbs_FORWARD);
584 //
585 const BOPDS_VectorOfCurve& aVNC=aFF.Curves();
586 aNbC=aVNC.Extent();
587 for (k=0; k<aNbC; ++k) {
588 const BOPDS_Curve& aNC=aVNC(k);
589 const BOPDS_ListOfPaveBlock& aLPB=aNC.PaveBlocks();
590 aItLPB.Initialize(aLPB);
591 for(; aItLPB.More(); aItLPB.Next()) {
592 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
593 nE=aPB->Edge();
594 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
595 //
596 for (m=0; m<2; ++m) {
597 if (bPCurveOnS[m]) {
598 BOPAlgo_MPC& aMPC=aVMPC.Append1();
599 aMPC.SetEdge(aE);
600 aMPC.SetFace(aFf[m]);
601 aMPC.SetFlag(bPCurveOnS[m]);
36f4947b 602 aMPC.SetProgressIndicator(myProgressIndicator);
f1baf495 603 }
604 }
4e57c75e 605 }
606 }
f1baf495 607 }// for (i=0; i<aNbFF; ++i) {
608 }//if (bPCurveOnS1 || bPCurveOnS2 ) {
609 //
610 //======================================================
905522ee 611 BOPAlgo_MPCCnt::Perform(myRunParallel, aVMPC, myContext);
f1baf495 612 //======================================================
4e57c75e 613}
4e57c75e 614//=======================================================================
615// function: RefineFaceInfoOn
616// purpose:
617//=======================================================================
505abfb8 618void BOPAlgo_PaveFiller::RefineFaceInfoOn()
4e57c75e 619{
620 Standard_Integer aNbPBP;
621 //
622 myErrorStatus=0;
623 //
624 BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
625 aNbPBP=aPBP.Extent();
626 if(!aNbPBP) {
627 return;
628 }
629 //
630 Standard_Boolean bV1, bV2;
631 Standard_Integer i, nV1, nV2, aNbPB;
632 Handle(BOPDS_PaveBlock) aPB;
633 //
634 for (i=0; i<aNbPBP; ++i) {
635 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
636 //
637 aNbPB=aLPB.Extent();
638 if (aNbPB==1) {
639 aPB=aLPB.First();
640 aPB->Indices(nV1, nV2);
641 bV1=myDS->IsNewShape(nV1);
642 bV2=myDS->IsNewShape(nV2);
643 //
644 if (!(bV1 || bV2)) {
5a77460e 645 if (!myDS->IsCommonBlock(aPB)) {
4e57c75e 646 // the PB seems to be untouced
647 aLPB.Clear();
648 continue;
649 }
650 }//if (!(bV1 || bV2)) {
651 }//if (aNbPB==1) {
652 }//for (i=0; i<aNbPBP; ++i) {
653 myDS->RefineFaceInfoOn();
654}
4e57c75e 655//=======================================================================
656//function : UpdateVertices
657//purpose : update tolerances of vertices comparing extremities of
658// 3d and 2d curves
659//=======================================================================
505abfb8 660void UpdateVertices(const TopoDS_Edge& aE,
661 const TopoDS_Face& aF)
4e57c75e 662{
663 Standard_Integer j;
664 Standard_Real aT[2], aUx, aVx, aTolV2, aD2, aD;
665 gp_Pnt aP3D, aP3Dx;
666 gp_Pnt2d aP2Dx;
667 Handle(Geom_Surface) aS;
668 Handle(Geom_Curve) aC3D;
669 Handle(Geom2d_Curve) aC2D;
670 TopoDS_Edge aEf;
671 TopoDS_Vertex aV[2];
672 BRep_Builder aBB;
673 //
674 aEf=aE;
675 aEf.Orientation(TopAbs_FORWARD);
676 //
677 TopExp::Vertices(aEf, aV[0], aV[1]);
678 //
679 aS=BRep_Tool::Surface(aF);
680 aC3D=BRep_Tool::Curve(aEf, aT[0], aT[1]);
681 aC2D=BRep_Tool::CurveOnSurface(aEf, aF, aT[0], aT[1]);
682 //
683 for (j=0; j<2; ++j) {
684 aTolV2=BRep_Tool::Tolerance(aV[j]);
685 aTolV2=aTolV2*aTolV2;
686 //
687 aC3D->D0(aT[j], aP3D);
688 aC2D->D0(aT[j], aP2Dx);
689 aP2Dx.Coord(aUx, aVx);
690 aS->D0(aUx, aVx, aP3Dx);
691 aD2=aP3D.SquareDistance(aP3Dx);
692 if (aD2>aTolV2) {
693 aD=sqrt(aD2);
694 aBB.UpdateVertex(aV[j], aD);
695 }
696 }
697}
f1baf495 698//=======================================================================
699// function: Prepare
700// purpose:
701//=======================================================================
702void BOPAlgo_PaveFiller::Prepare()
703{
704 TopAbs_ShapeEnum aType[] = {
705 TopAbs_VERTEX,
706 TopAbs_EDGE,
707 TopAbs_FACE
708 };
709 Standard_Boolean bJustAdd, bIsBasedOnPlane;
710 Standard_Integer i, aNb, n1, nF;
711 TopExp_Explorer aExp;
712 BOPCol_MapOfShape aMF;
713 BOPCol_MapIteratorOfMapOfShape aItMF;
714 //
715 myErrorStatus=0;
716 //
717 aNb=3;
718 for(i=0; i<aNb; ++i) {
719 myIterator->Initialize(aType[i], aType[2]);
720 for (; myIterator->More(); myIterator->Next()) {
721 myIterator->Value(n1, nF, bJustAdd);
722 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
723 //
724 bIsBasedOnPlane=IsBasedOnPlane(aF);
725 if (bIsBasedOnPlane) {
726 aMF.Add(aF);
727 }
728 }
729 }
730 //
731 if (aMF.IsEmpty()) {
732 return;
733 }
734 //
735 BOPAlgo_VectorOfBPC aVBPC;
736 //
737 aItMF.Initialize(aMF);
738 for (; aItMF.More(); aItMF.Next()) {
739 const TopoDS_Face& aF=*((TopoDS_Face *)&aItMF.Key());
740 aExp.Init(aF, aType[1]);
741 for (; aExp.More(); aExp.Next()) {
742 const TopoDS_Edge& aE=*((TopoDS_Edge *)&aExp.Current());
743 BOPAlgo_BPC& aBPC=aVBPC.Append1();
744 aBPC.SetEdge(aE);
745 aBPC.SetFace(aF);
746 }
747 }
748 //
749 //======================================================
750 BOPAlgo_BPCCnt::Perform(myRunParallel, aVBPC);
751 //======================================================
752}
753//=======================================================================
754//function : IsBasedOnPlane
755//purpose :
756//=======================================================================
757Standard_Boolean IsBasedOnPlane(const TopoDS_Face& aF)
758{
759 TopLoc_Location aLoc;
760 Handle(Geom_RectangularTrimmedSurface) aGRTS;
761 Handle(Geom_Plane) aGP;
762
763 const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aF, aLoc);
764 aGRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
765 if(!aGRTS.IsNull()) {
766 aGP = Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
767 }
768 else {
769 aGP = Handle(Geom_Plane)::DownCast(aS);
770 }
771 //
772 return (!aGP.IsNull());
773}