0028786: Refactoring of the Warning/Error reporting system of Boolean Operations...
[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>
33ba8565 21#include <BOPAlgo_Alerts.hxx>
42cf5bc1 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>
42cf5bc1 29#include <BOPDS_DS.hxx>
30#include <BOPDS_Interf.hxx>
31#include <BOPDS_Iterator.hxx>
32#include <BOPDS_MapOfPaveBlock.hxx>
33#include <BOPDS_Pave.hxx>
34#include <BOPDS_PaveBlock.hxx>
35#include <BOPTools_AlgoTools.hxx>
36#include <BRep_Builder.hxx>
4e57c75e 37#include <BRep_Tool.hxx>
e30616a7 38#include <BRepAdaptor_Curve.hxx>
42cf5bc1 39#include <gp_Pnt.hxx>
40#include <IntTools_CommonPrt.hxx>
41#include <IntTools_Context.hxx>
4e57c75e 42#include <IntTools_EdgeFace.hxx>
43#include <IntTools_Range.hxx>
44#include <IntTools_SequenceOfCommonPrts.hxx>
42cf5bc1 45#include <IntTools_Tools.hxx>
8ae442a8 46#include <Precision.hxx>
3510db62 47#include <TopoDS.hxx>
42cf5bc1 48#include <TopoDS_Edge.hxx>
49#include <TopoDS_Face.hxx>
50#include <TopoDS_Vertex.hxx>
51
4e57c75e 52//=======================================================================
e30616a7 53//class : BOPAlgo_EdgeFace
54//purpose :
55//=======================================================================
36f4947b 56class BOPAlgo_EdgeFace :
57 public IntTools_EdgeFace,
58 public BOPAlgo_Algo {
59
e30616a7 60 public:
36f4947b 61 DEFINE_STANDARD_ALLOC
62
63 BOPAlgo_EdgeFace() :
64 IntTools_EdgeFace(),
65 BOPAlgo_Algo(),
66 myIE(-1), myIF(-1) {
e30616a7 67 };
68 //
36f4947b 69 virtual ~BOPAlgo_EdgeFace(){
e30616a7 70 };
71 //
72 void SetIndices(const Standard_Integer nE,
73 const Standard_Integer nF) {
74 myIE=nE;
75 myIF=nF;
76 }
77 //
78 void Indices(Standard_Integer& nE,
79 Standard_Integer& nF) {
80 nE=myIE;
81 nF=myIF;
82 }
83 //
84 void SetNewSR(const IntTools_Range& aR){
85 myNewSR=aR;
86 }
87 //
88 IntTools_Range& NewSR(){
89 return myNewSR;
90 }
91 //
92 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
93 myPB=aPB;
94 }
95 //
96 Handle(BOPDS_PaveBlock)& PaveBlock() {
97 return myPB;
98 }
99 //
0d0481c7 100 void SetFuzzyValue(const Standard_Real theFuzz) {
101 IntTools_EdgeFace::SetFuzzyValue(theFuzz);
102 }
103 //
36f4947b 104 virtual void Perform() {
105 BOPAlgo_Algo::UserBreak();
106 IntTools_EdgeFace::Perform();
107 }
108 //
e30616a7 109 protected:
110 Standard_Integer myIE;
111 Standard_Integer myIF;
112 IntTools_Range myNewSR;
113 Handle(BOPDS_PaveBlock) myPB;
114};
115//
116//=======================================================================
117typedef BOPCol_NCVector<BOPAlgo_EdgeFace> BOPAlgo_VectorOfEdgeFace;
118//
c7b59798 119typedef BOPCol_ContextFunctor
e30616a7 120 <BOPAlgo_EdgeFace,
121 BOPAlgo_VectorOfEdgeFace,
1e143abb 122 Handle(IntTools_Context),
123 IntTools_Context> BOPAlgo_EdgeFaceFunctor;
e30616a7 124//
c7b59798 125typedef BOPCol_ContextCnt
e30616a7 126 <BOPAlgo_EdgeFaceFunctor,
127 BOPAlgo_VectorOfEdgeFace,
1e143abb 128 Handle(IntTools_Context)> BOPAlgo_EdgeFaceCnt;
e30616a7 129//
130//=======================================================================
4e57c75e 131//function : PerformEF
132//purpose :
133//=======================================================================
e30616a7 134void BOPAlgo_PaveFiller::PerformEF()
4e57c75e 135{
e30616a7 136 FillShrunkData(TopAbs_EDGE, TopAbs_FACE);
137 //
4e57c75e 138 myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
483ce1bd 139 Standard_Integer iSize = myIterator->ExpectedLength();
4e57c75e 140 if (!iSize) {
141 return;
142 }
e30616a7 143 //
483ce1bd 144 Standard_Integer nE, nF;
145 //
146 if (myGlue == BOPAlgo_GlueFull) {
147 // there is no need to intersect edges with faces in this mode
148 // just initialize FaceInfo for faces
149 for (; myIterator->More(); myIterator->Next()) {
25dfc507 150 myIterator->Value(nE, nF);
151 if (!myDS->ShapeInfo(nE).HasFlag()) {
483ce1bd 152 myDS->ChangeFaceInfo(nF);
153 }
154 }
155 return;
156 }
157 //
158 Standard_Boolean bV[2], bIsPBSplittable;
6dc83e21 159 Standard_Boolean bV1, bV2, bExpressCompute;
160 Standard_Integer nV1, nV2;
483ce1bd 161 Standard_Integer aDiscretize, i, aNbCPrts, iX, nV[2];
e30616a7 162 Standard_Integer aNbEdgeFace, k;
b4109929 163 Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection;
488e5b9d 164 Handle(NCollection_BaseAllocator) aAllocator;
4e57c75e 165 TopAbs_ShapeEnum aType;
166 BOPDS_ListIteratorOfListOfPaveBlock aIt;
e30616a7 167 BOPAlgo_VectorOfEdgeFace aVEdgeFace;
e30616a7 168 //-----------------------------------------------------scope f
4e57c75e 169 //
488e5b9d 170 aAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
171 //
4e57c75e 172 BOPCol_MapOfInteger aMIEFC(100, aAllocator);
173 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
174 BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator);
01b5b3df 175 BOPAlgo_DataMapOfPaveBlockBndBox aDMPBBox(100, aAllocator);
4e57c75e 176 //
177 aDiscretize=35;
178 aDeflection=0.01;
179 //
180 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
4e57c75e 181 aEFs.SetIncrement(iSize);
4e57c75e 182 //
183 for (; myIterator->More(); myIterator->Next()) {
25dfc507 184 myIterator->Value(nE, nF);
4e57c75e 185 //
186 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
187 if (aSIE.HasFlag()){//degenerated
188 continue;
189 }
190 //
191 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
192 const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
193 const Bnd_Box& aBBF=myDS->ShapeInfo(nF).Box();
194 //
195 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
196 const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
4e57c75e 197 //
6dc83e21 198 const BOPCol_MapOfInteger& aMVIn=aFI.VerticesIn();
199 const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn();
200 //
4e57c75e 201 aTolE=BRep_Tool::Tolerance(aE);
202 aTolF=BRep_Tool::Tolerance(aF);
203 //
204 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
205 aIt.Initialize(aLPB);
206 for (; aIt.More(); aIt.Next()) {
207 Handle(BOPDS_PaveBlock)& aPB=aIt.ChangeValue();
208 //
5a77460e 209 const Handle(BOPDS_PaveBlock) aPBR=myDS->RealPaveBlock(aPB);
4e57c75e 210 if (aMPBF.Contains(aPBR)) {
211 continue;
212 }
213 //
01b5b3df 214 Bnd_Box aBBE;
215 if (!GetPBBox(aE, aPB, aDMPBBox, aT1, aT2, aTS1, aTS2, aBBE)) {
e30616a7 216 continue;
4e57c75e 217 }
218 //
4e57c75e 219 if (aBBF.IsOut (aBBE)) {
220 continue;
221 }
222 //
6dc83e21 223 aPBR->Indices(nV1, nV2);
224 bV1=aMVIn.Contains(nV1) || aMVOn.Contains(nV1);
225 bV2=aMVIn.Contains(nV2) || aMVOn.Contains(nV2);
226 bExpressCompute=bV1 && bV2;
227 //
e30616a7 228 BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace.Append1();
229 //
230 aEdgeFace.SetIndices(nE, nF);
231 aEdgeFace.SetPaveBlock(aPB);
4e57c75e 232 //
233 aEdgeFace.SetEdge (aE);
234 aEdgeFace.SetFace (aF);
0d0481c7 235 aEdgeFace.SetFuzzyValue(myFuzzyValue);
4e57c75e 236 aEdgeFace.SetDiscretize (aDiscretize);
237 aEdgeFace.SetDeflection (aDeflection);
6dc83e21 238 aEdgeFace.UseQuickCoincidenceCheck(bExpressCompute);
4e57c75e 239 //
240 IntTools_Range aSR(aTS1, aTS2);
241 IntTools_Range anewSR=aSR;
4e57c75e 242 BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR);
e30616a7 243 aEdgeFace.SetNewSR(anewSR);
b4109929 244 //
b4109929 245 IntTools_Range aPBRange(aT1, aT2);
246 aSR = aPBRange;
247 BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange);
b4109929 248 aEdgeFace.SetRange (aPBRange);
36f4947b 249 aEdgeFace.SetProgressIndicator(myProgressIndicator);
4e57c75e 250 //
e30616a7 251 }//for (; aIt.More(); aIt.Next()) {
252 }//for (; myIterator->More(); myIterator->Next()) {
253 //
254 aNbEdgeFace=aVEdgeFace.Extent();
255 //=================================================================
256 BOPAlgo_EdgeFaceCnt::Perform(myRunParallel, aVEdgeFace, myContext);
257 //=================================================================
258 //
259 for (k=0; k < aNbEdgeFace; ++k) {
260 BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace(k);
261 if (!aEdgeFace.IsDone()) {
262 continue;
263 }
51db0179 264 //
265 const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts();
266 aNbCPrts = aCPrts.Length();
267 if (!aNbCPrts) {
268 continue;
269 }
270 //
e30616a7 271 aEdgeFace.Indices(nE, nF);
272 //
273 const TopoDS_Edge& aE=aEdgeFace.Edge();
274 const TopoDS_Face& aF=aEdgeFace.Face();
275 //
0d0481c7 276 aTolE=BRep_Tool::Tolerance(aE);
277 aTolF=BRep_Tool::Tolerance(aF);
e30616a7 278 const IntTools_Range& anewSR=aEdgeFace.NewSR();
279 Handle(BOPDS_PaveBlock)& aPB=aEdgeFace.PaveBlock();
280 //
281 aPB->Range(aT1, aT2);
282 aPB->Indices(nV[0], nV[1]);
01b5b3df 283 bIsPBSplittable = aPB->IsSplittable();
284 //
01b5b3df 285 anewSR.Range(aTS1, aTS2);
286 //
51db0179 287 if (aCPrts(1).Type() == TopAbs_VERTEX) {
288 // for the intersection type VERTEX
289 // extend vertices ranges using Edge/Edge intersections
290 // between the edge aE and the edges of the face aF.
291 // thereby the edge's intersection range is reduced
292 ReduceIntersectionRange(nV[0], nV[1], nE, nF, aTS1, aTS2);
293 }
01b5b3df 294 //
295 IntTools_Range aR1(aT1, aTS1), aR2(aTS2, aT2);
e30616a7 296 //
297 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
e30616a7 298 const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
299 const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
3510db62 300 //
301 Standard_Boolean bLinePlane = Standard_False;
302 if (aNbCPrts) {
303 BRepAdaptor_Curve aBAC(aE);
3510db62 304 bLinePlane = (aBAC.GetType() == GeomAbs_Line &&
51db0179 305 myContext->SurfaceAdaptor(aF).GetType() == GeomAbs_Plane);
3510db62 306 }
51db0179 307 //
e30616a7 308 for (i=1; i<=aNbCPrts; ++i) {
309 const IntTools_CommonPrt& aCPart=aCPrts(i);
310 aType=aCPart.Type();
311 switch (aType) {
01b5b3df 312 case TopAbs_VERTEX: {
b4109929 313 Standard_Boolean bIsOnPave[2];
314 Standard_Integer j;
4e57c75e 315 Standard_Real aT, aTolToDecide;
316 TopoDS_Vertex aVnew;
e30616a7 317 //
1e143abb 318 IntTools_Tools::VertexParameter(aCPart, aT);
4e57c75e 319 BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew);
320 //
321 const IntTools_Range& aR=aCPart.Range1();
322 aTolToDecide=5.e-8;
4e57c75e 323 //
1e143abb 324 bIsOnPave[0]=IntTools_Tools::IsInRange(aR1, aR, aTolToDecide);
325 bIsOnPave[1]=IntTools_Tools::IsInRange(aR2, aR, aTolToDecide);
b4109929 326 //
3510db62 327 if ((bIsOnPave[0] && bIsOnPave[1]) ||
328 (bLinePlane && (bIsOnPave[0] || bIsOnPave[1]))) {
b4109929 329 bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn);
330 bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn);
331 if (bV[0] && bV[1]) {
4e57c75e 332 IntTools_CommonPrt aCP = aCPart;
333 aCP.SetType(TopAbs_EDGE);
402bfe81 334 BOPDS_InterfEF& aEF=aEFs.Append1();
335 iX=aEFs.Extent()-1;
4e57c75e 336 aEF.SetIndices(nE, nF);
337 aEF.SetCommonPart(aCP);
338 myDS->AddInterf(nE, nF);
ceb31c61 339 //
340 aMIEFC.Add(nF);
341 //
4e57c75e 342 BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
343 break;
344 }
345 }
01b5b3df 346 //
347 if (!bIsPBSplittable) {
348 continue;
349 }
350 //
b4109929 351 for (j=0; j<2; ++j) {
352 if (bIsOnPave[j]) {
353 bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn);
354 if (bV[j]) {
e30616a7 355 const TopoDS_Vertex& aV=
356 (*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
3510db62 357 //
358 Standard_Real f, l, aTolVnew, aDistPP, aTolPC, aTolV;
359 //
360 const Handle(Geom_Curve)& aCur = BRep_Tool::Curve(aE, f, l);
361 //
362 gp_Pnt aP1 = BRep_Tool::Pnt(aV);
363 gp_Pnt aP2 = aCur->Value(aT);
364 //
3510db62 365 aDistPP=aP1.Distance(aP2);
01b5b3df 366 //
3510db62 367 aTolPC=Precision::PConfusion();
368 aTolV=BRep_Tool::Tolerance(aV);
369 if (aDistPP > (aTolV+aTolPC)) {
370 aTolVnew=Max(aTolE, aDistPP);
371 UpdateVertex(nV[j], aTolVnew);
01b5b3df 372 }
b4109929 373 }
374 else {
375 bIsOnPave[j] = ForceInterfVF(nV[j], nF);
376 }
4e57c75e 377 }
4e57c75e 378 }
379 //
b4109929 380 if (!bIsOnPave[0] && !bIsOnPave[1]) {
381 if (CheckFacePaves(aVnew, aMIFOn)) {
4e57c75e 382 continue;
383 }
b4109929 384 //
3510db62 385 Standard_Real aTolVnew = BRep_Tool::Tolerance(aVnew);
386 aTolVnew = Max(aTolVnew, Max(aTolE, aTolF));
387 BRep_Builder().UpdateVertex(aVnew, aTolVnew);
388 if (bLinePlane) {
389 // increase tolerance for Line/Plane intersection, but do not update
390 // the vertex till its intersection with some other shape
391 IntTools_Range aCR = aCPart.Range1();
392 aTolVnew = Max(aTolVnew, (aCR.Last() - aCR.First()) / 2.);
393 }
394 //
b4109929 395 const gp_Pnt& aPnew = BRep_Tool::Pnt(aVnew);
bd28b2af 396 //
3510db62 397 if (!myContext->IsPointInFace(aPnew, aF, aTolVnew)) {
4e57c75e 398 continue;
399 }
b4109929 400 //
4e57c75e 401 aMIEFC.Add(nF);
402 // 1
402bfe81 403 BOPDS_InterfEF& aEF=aEFs.Append1();
404 iX=aEFs.Extent()-1;
4e57c75e 405 aEF.SetIndices(nE, nF);
406 aEF.SetCommonPart(aCPart);
407 // 2
408 myDS->AddInterf(nE, nF);
409 // 3
410 BOPDS_CoupleOfPaveBlocks aCPB;
411 //
412 aCPB.SetPaveBlocks(aPB, aPB);
413 aCPB.SetIndexInterf(iX);
3510db62 414 aCPB.SetTolerance(aTolVnew);
4e57c75e 415 aMVCPB.Add(aVnew, aCPB);
416 }
417 }
418 break;
419 case TopAbs_EDGE: {
420 aMIEFC.Add(nF);
421 //
422 // 1
402bfe81 423 BOPDS_InterfEF& aEF=aEFs.Append1();
424 iX=aEFs.Extent()-1;
4e57c75e 425 aEF.SetIndices(nE, nF);
426 //
b4109929 427 bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn);
428 bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn);
429 if (!bV[0] || !bV[1]) {
4e57c75e 430 myDS->AddInterf(nE, nF);
431 break;
432 }
4e57c75e 433 aEF.SetCommonPart(aCPart);
434 // 2
435 myDS->AddInterf(nE, nF);
436 // 3
437 BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
438
439 }
440 break;
441 default:
442 break;
e30616a7 443 }//switch (aType) {
444 }//for (i=1; i<=aNbCPrts; ++i) {
445 }// for (k=0; k < aNbEdgeEdge; ++k) {
4e57c75e 446 //
447 //=========================================
448 // post treatment
449 //=========================================
5a77460e 450 BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator, myDS);
8ae442a8 451 PerformNewVertices(aMVCPB, aAllocator, Standard_False);
4e57c75e 452 //
453 // Update FaceInfoIn for all faces having EF common parts
454 BOPCol_MapIteratorOfMapOfInteger aItMI;
455 aItMI.Initialize(aMIEFC);
456 for (; aItMI.More(); aItMI.Next()) {
457 nF=aItMI.Value();
458 myDS->UpdateFaceInfoIn(nF);
459 }
4e57c75e 460 //-----------------------------------------------------scope t
461 aMIEFC.Clear();
462 aMVCPB.Clear();
463 aMPBLI.Clear();
e30616a7 464 ////aAllocator.Nullify();
4e57c75e 465}
466//=======================================================================
4e57c75e 467// function: CheckFacePaves
468// purpose:
469//=======================================================================
e30616a7 470Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
471 (const Standard_Integer nVx,
472 const BOPCol_MapOfInteger& aMIFOn,
473 const BOPCol_MapOfInteger& aMIFIn)
4e57c75e 474{
475 Standard_Boolean bRet;
476 Standard_Integer nV;
477 BOPCol_MapIteratorOfMapOfInteger aIt;
478 //
479 bRet=Standard_False;
480 //
481 aIt.Initialize(aMIFOn);
482 for (; aIt.More(); aIt.Next()) {
483 nV=aIt.Value();
484 if (nV==nVx) {
485 bRet=!bRet;
486 return bRet;
487 }
488 }
489 aIt.Initialize(aMIFIn);
490 for (; aIt.More(); aIt.Next()) {
491 nV=aIt.Value();
492 if (nV==nVx) {
493 bRet=!bRet;
494 return bRet;
495 }
496 }
497 //
498 return bRet;
499}
500//=======================================================================
501// function: CheckFacePaves
502// purpose:
503//=======================================================================
e30616a7 504Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
505 (const TopoDS_Vertex& aVnew,
506 const BOPCol_MapOfInteger& aMIF)
4e57c75e 507{
508 Standard_Boolean bRet;
509 Standard_Integer nV, iFlag;
510 BOPCol_MapIteratorOfMapOfInteger aIt;
511 //
512 bRet=Standard_True;
513 //
514 aIt.Initialize(aMIF);
515 for (; aIt.More(); aIt.Next()) {
516 nV=aIt.Value();
517 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
518 iFlag=BOPTools_AlgoTools::ComputeVV(aVnew, aV);
519 if (!iFlag) {
520 return bRet;
521 }
522 }
523 //
524 return !bRet;
525}
b4109929 526//=======================================================================
527//function : ForceInterfVF
528//purpose :
529//=======================================================================
e30616a7 530Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF
531 (const Standard_Integer nV,
532 const Standard_Integer nF)
b4109929 533{
534 Standard_Boolean bRet;
3510db62 535 Standard_Integer iFlag, nVx;
536 Standard_Real U, V, aTolVNew;
b4109929 537 //
538 bRet = Standard_False;
539 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
540 const TopoDS_Face& aF = *(TopoDS_Face*) &myDS->Shape(nF);
541 //
0d0481c7 542 iFlag = myContext->ComputeVF(aV, aF, U, V, aTolVNew, myFuzzyValue);
3510db62 543 if (iFlag == 0 || iFlag == -2) {
544 bRet=!bRet;
b4109929 545 //
b4109929 546 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
a3476a9f 547 aVFs.SetIncrement(10);
3510db62 548 // 1
402bfe81 549 BOPDS_InterfVF& aVF=aVFs.Append1();
3510db62 550 //
b4109929 551 aVF.SetIndices(nV, nF);
552 aVF.SetUV(U, V);
3510db62 553 // 2
b4109929 554 myDS->AddInterf(nV, nF);
555 //
3510db62 556 // 3 update vertex V/F if necessary
557 nVx=UpdateVertex(nV, aTolVNew);
558 // 4
559 if (myDS->IsNewShape(nVx)) {
560 aVF.SetIndexNew(nVx);
561 }
b4109929 562 //
563 BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
564 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
3510db62 565 aMVIn.Add(nVx);
33ba8565 566 //
567 // check for self-interference
568 Standard_Integer iRV = myDS->Rank(nV);
569 if (iRV >= 0 && iRV == myDS->Rank(nF)) {
570 // add warning status
571 TopoDS_Compound aWC;
572 BRep_Builder().MakeCompound(aWC);
573 BRep_Builder().Add(aWC, aV);
574 BRep_Builder().Add(aWC, aF);
575 AddWarning (new BOPAlgo_AlertSelfInterferingShape (aWC));
576 }
577
b4109929 578 }
b4109929 579 return bRet;
580}
01b5b3df 581//=======================================================================
582//function : ReduceIntersectionRange
583//purpose :
584//=======================================================================
585void BOPAlgo_PaveFiller::ReduceIntersectionRange(const Standard_Integer theV1,
586 const Standard_Integer theV2,
587 const Standard_Integer theE,
588 const Standard_Integer theF,
589 Standard_Real& theTS1,
590 Standard_Real& theTS2)
591{
592 if (!myDS->IsNewShape(theV1) &&
593 !myDS->IsNewShape(theV2)) {
594 return;
595 }
596 //
51db0179 597 if (!myDS->HasInterfShapeSubShapes(theE, theF)) {
598 return;
599 }
600 //
01b5b3df 601 BOPDS_VectorOfInterfEE& aEEs = myDS->InterfEE();
602 Standard_Integer aNbEEs = aEEs.Extent();
603 if (!aNbEEs) {
604 return;
605 }
606 //
607 Standard_Integer i, nV, nE1, nE2;
608 Standard_Real aTR1, aTR2;
609 //
610 // get face's edges to check that E/E contains the edge from the face
611 BOPCol_MapOfInteger aMFE;
612 const BOPCol_ListOfInteger& aLI = myDS->ShapeInfo(theF).SubShapes();
613 BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
614 for (; aItLI.More(); aItLI.Next()) {
615 nE1 = aItLI.Value();
616 if (myDS->ShapeInfo(nE1).ShapeType() == TopAbs_EDGE) {
617 aMFE.Add(nE1);
618 }
619 }
620 //
621 for (i = 0; i < aNbEEs; ++i) {
622 BOPDS_InterfEE& aEE = aEEs(i);
623 if (!aEE.HasIndexNew()) {
624 continue;
625 }
626 //
627 // check the vertex
628 nV = aEE.IndexNew();
629 if (nV != theV1 && nV != theV2) {
630 continue;
631 }
632 //
633 // check that the intersection is between the edge
634 // and one of the face's edge
635 aEE.Indices(nE1, nE2);
636 if (((theE != nE1) && (theE != nE2)) ||
637 (!aMFE.Contains(nE1) && !aMFE.Contains(nE2))) {
638 continue;
639 }
640 //
641 // update the intersection range
642 const IntTools_CommonPrt& aCPart = aEE.CommonPart();
643 const IntTools_Range& aCRange =
644 (theE == nE1) ? aCPart.Range1() : aCPart.Ranges2().First();
645 aCRange.Range(aTR1, aTR2);
646 //
647 if (nV == theV1) {
648 if (theTS1 < aTR2) {
649 theTS1 = aTR2;
650 }
651 }
652 else {
653 if (theTS2 > aTR1) {
654 theTS2 = aTR1;
655 }
656 }
657 }
658}