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 <Precision.hxx> |
21 | #include <NCollection_IncAllocator.hxx> |
22 | #include <Bnd_Box.hxx> |
23 | |
24 | #include <Geom_Curve.hxx> |
25 | #include <Geom2d_Curve.hxx> |
26 | |
27 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
28 | #include <GeomAPI_ProjectPointOnSurf.hxx> |
29 | |
30 | #include <TopoDS_Edge.hxx> |
31 | #include <TopoDS_Face.hxx> |
32 | #include <TopoDS_Vertex.hxx> |
33 | #include <TopoDS_Compound.hxx> |
34 | |
35 | #include <TopExp_Explorer.hxx> |
36 | |
37 | #include <BRep_Builder.hxx> |
38 | #include <BRep_Tool.hxx> |
39 | |
40 | #include <BRepBndLib.hxx> |
41 | #include <BRepTools.hxx> |
42 | |
43 | #include <BRepAdaptor_Curve.hxx> |
44 | #include <BRepAdaptor_Surface.hxx> |
45 | |
46 | #include <IntTools_FaceFace.hxx> |
47 | #include <IntTools_SequenceOfCurves.hxx> |
48 | #include <IntTools_SequenceOfPntOn2Faces.hxx> |
49 | #include <IntTools_Curve.hxx> |
50 | #include <IntTools_PntOn2Faces.hxx> |
51 | #include <IntTools_Tools.hxx> |
52 | |
53 | #include <IntSurf_ListOfPntOn2S.hxx> |
54 | #include <IntSurf_PntOn2S.hxx> |
55 | |
56 | #include <BOPTools_AlgoTools.hxx> |
57 | #include <BOPTools_AlgoTools3D.hxx> |
58 | |
59 | #include <BOPCol_MapOfInteger.hxx> |
60 | #include <BOPCol_ListOfShape.hxx> |
61 | #include <BOPCol_DataMapOfShapeInteger.hxx> |
62 | #include <BOPCol_ListOfInteger.hxx> |
63 | #include <BOPCol_IndexedMapOfInteger.hxx> |
b4109929 |
64 | #include <BOPCol_DataMapOfIntegerReal.hxx> |
4e57c75e |
65 | |
66 | #include <BOPInt_Context.hxx> |
67 | #include <BOPInt_Tools.hxx> |
68 | |
69 | #include <BOPDS_Interf.hxx> |
70 | #include <BOPDS_Iterator.hxx> |
71 | #include <BOPDS_Curve.hxx> |
72 | #include <BOPDS_Point.hxx> |
73 | #include <BOPDS_FaceInfo.hxx> |
74 | #include <BOPDS_Curve.hxx> |
75 | #include <BOPDS_MapOfPaveBlock.hxx> |
76 | #include <BOPDS_PaveBlock.hxx> |
77 | #include <BOPDS_VectorOfCurve.hxx> |
78 | #include <BOPDS_VectorOfPoint.hxx> |
79 | #include <BOPDS_ShapeInfo.hxx> |
80 | #include <BOPDS_PaveBlock.hxx> |
81 | #include <BOPDS_ListOfPave.hxx> |
82 | #include <BOPDS_ListOfPaveBlock.hxx> |
83 | #include <BOPDS_CoupleOfPaveBlocks.hxx> |
84 | #include <BOPDS_FaceInfo.hxx> |
85 | #include <BOPDS_CommonBlock.hxx> |
86 | |
87 | #include <BOPAlgo_Tools.hxx> |
88 | #include <BRepBuilderAPI_MakeVertex.hxx> |
89 | #include <TopExp.hxx> |
90 | #include <BOPInt_ShrunkRange.hxx> |
91 | #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx> |
92 | |
b4109929 |
93 | static void ToleranceFF(const BRepAdaptor_Surface& aBAS1, |
94 | const BRepAdaptor_Surface& aBAS2, |
4e57c75e |
95 | Standard_Real& aTolFF); |
96 | |
97 | //======================================================================= |
98 | //function : PerformFF |
99 | //purpose : |
100 | //======================================================================= |
7ff8f019 |
101 | void BOPAlgo_PaveFiller::PerformFF() |
4e57c75e |
102 | { |
103 | Standard_Integer iSize; |
104 | Standard_Boolean bValid; |
105 | // |
106 | myErrorStatus=0; |
107 | // |
108 | myIterator->Initialize(TopAbs_FACE, TopAbs_FACE); |
109 | iSize=myIterator->ExpectedLength(); |
110 | if (!iSize) { |
111 | return; |
112 | } |
113 | // |
114 | Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone; |
7ff8f019 |
115 | Standard_Boolean bToSplit, bTangentFaces; |
4e57c75e |
116 | Standard_Integer nF1, nF2, aNbCurves, aNbPoints, iX, i, iP, iC, aNbLP; |
117 | Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF; |
b4109929 |
118 | BRepAdaptor_Surface aBAS1, aBAS2; |
af4e6dab |
119 | BOPCol_MapOfInteger aMI; |
4e57c75e |
120 | // |
121 | BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); |
122 | aFFs.SetStartSize(iSize); |
123 | aFFs.SetIncrement(iSize); |
124 | aFFs.Init(); |
125 | // |
126 | bApp=mySectionAttribute.Approximation(); |
127 | bCompC2D1=mySectionAttribute.PCurveOnS1(); |
128 | bCompC2D2=mySectionAttribute.PCurveOnS2(); |
129 | aApproxTol=1.e-7; |
130 | bToSplit = Standard_False; |
131 | // |
132 | for (; myIterator->More(); myIterator->Next()) { |
133 | myIterator->Value(nF1, nF2, bJustAdd); |
134 | if(bJustAdd) { |
135 | continue; |
136 | } |
137 | // |
138 | const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1))); |
139 | const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2))); |
140 | // |
b4109929 |
141 | aBAS1.Initialize(aF1, Standard_False); |
142 | aBAS2.Initialize(aF2, Standard_False); |
143 | // |
144 | if (aBAS1.GetType() == GeomAbs_Plane && |
145 | aBAS2.GetType() == GeomAbs_Plane) { |
146 | Standard_Boolean bToIntersect; |
147 | // |
af4e6dab |
148 | if (aMI.Add(nF1)) { |
78c66ef1 |
149 | myDS->UpdateFaceInfoOn(nF1); |
150 | myDS->UpdateFaceInfoIn(nF1); |
af4e6dab |
151 | } |
152 | if (aMI.Add(nF2)) { |
78c66ef1 |
153 | myDS->UpdateFaceInfoOn(nF2); |
154 | myDS->UpdateFaceInfoIn(nF2); |
af4e6dab |
155 | } |
156 | // |
b4109929 |
157 | bToIntersect = CheckPlanes(nF1, nF2); |
158 | if (!bToIntersect) { |
159 | myDS->AddInterf(nF1, nF2); |
160 | iX=aFFs.Append()-1; |
161 | BOPDS_InterfFF& aFF=aFFs(iX); |
162 | aFF.SetIndices(nF1, nF2); |
163 | aFF.Init(0, 0); |
164 | continue; |
165 | } |
166 | } |
167 | // |
4e57c75e |
168 | IntTools_FaceFace aFaceFace; |
169 | // |
170 | IntSurf_ListOfPntOn2S aListOfPnts; |
171 | GetEFPnts(nF1, nF2, aListOfPnts); |
172 | aNbLP = aListOfPnts.Extent(); |
173 | if (aNbLP) { |
174 | aFaceFace.SetList(aListOfPnts); |
175 | } |
176 | |
177 | aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol); |
178 | // |
179 | aFaceFace.Perform(aF1, aF2); |
180 | // |
181 | bIsDone=aFaceFace.IsDone(); |
182 | if (bIsDone) { |
183 | aTolR3D=aFaceFace.TolReached3d(); |
184 | aTolR2D=aFaceFace.TolReached2d(); |
7ff8f019 |
185 | bTangentFaces=aFaceFace.TangentFaces(); |
4e57c75e |
186 | // |
b4109929 |
187 | ToleranceFF(aBAS1, aBAS2, aTolFF); |
4e57c75e |
188 | // |
189 | if (aTolR3D < aTolFF){ |
190 | aTolR3D=aTolFF; |
191 | } |
192 | if (aTolR2D < 1.e-7){ |
193 | aTolR2D=1.e-7; |
194 | } |
195 | // |
196 | aFaceFace.PrepareLines3D(bToSplit); |
197 | // |
198 | const IntTools_SequenceOfCurves& aCvsX=aFaceFace.Lines(); |
199 | const IntTools_SequenceOfPntOn2Faces& aPntsX=aFaceFace.Points(); |
200 | // |
201 | aNbCurves=aCvsX.Length(); |
202 | aNbPoints=aPntsX.Length(); |
203 | // |
204 | myDS->AddInterf(nF1, nF2); |
205 | // |
206 | iX=aFFs.Append()-1; |
207 | BOPDS_InterfFF& aFF=aFFs(iX); |
208 | aFF.SetIndices(nF1, nF2); |
209 | // |
210 | aFF.SetTolR3D(aTolR3D); |
211 | aFF.SetTolR2D(aTolR2D); |
7ff8f019 |
212 | aFF.SetTangentFaces(bTangentFaces); |
4e57c75e |
213 | // |
214 | // Curves, Points |
215 | aFF.Init(aNbCurves, aNbPoints); |
216 | // |
217 | // Curves |
218 | BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); |
219 | for (i=1; i<=aNbCurves; ++i) { |
220 | Bnd_Box aBox; |
221 | // |
222 | const IntTools_Curve& aIC=aCvsX(i); |
223 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); |
224 | bValid=BOPInt_Tools::CheckCurve(aC3D, aTolR3D, aBox); |
225 | if (bValid) { |
226 | iC=aVNC.Append()-1; |
227 | BOPDS_Curve& aNC=aVNC(iC); |
228 | aNC.SetCurve(aIC); |
229 | aNC.SetBox(aBox); |
230 | } |
231 | } |
232 | // |
233 | // Points |
234 | BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); |
235 | for (i=1; i<=aNbPoints; ++i) { |
236 | const IntTools_PntOn2Faces& aPi=aPntsX(i); |
237 | const gp_Pnt& aP=aPi.P1().Pnt(); |
238 | // |
239 | iP=aVNP.Append()-1; |
240 | BOPDS_Point& aNP=aVNP(iP); |
241 | aNP.SetPnt(aP); |
242 | } |
243 | //}// if (aNbCs || aNbPs) |
244 | }// if (bIsDone) { |
245 | else {// 904/L1 |
246 | iX=aFFs.Append()-1; |
247 | BOPDS_InterfFF& aFF=aFFs(iX); |
248 | aFF.SetIndices(nF1, nF2); |
249 | aNbCurves=0; |
250 | aNbPoints=0; |
251 | aFF.Init(aNbCurves, aNbPoints); |
252 | } |
253 | }// for (; myIterator->More(); myIterator->Next()) { |
254 | } |
255 | //======================================================================= |
256 | //function : MakeBlocks |
257 | //purpose : |
258 | //======================================================================= |
78c66ef1 |
259 | void BOPAlgo_PaveFiller::MakeBlocks() |
4e57c75e |
260 | { |
261 | Standard_Integer aNbFF; |
262 | // |
263 | myErrorStatus=0; |
264 | // |
265 | BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); |
266 | aNbFF=aFFs.Extent(); |
267 | if (!aNbFF) { |
268 | return; |
269 | } |
270 | // |
271 | Standard_Boolean bExist, bValid2D; |
272 | Standard_Integer i, nF1, nF2, aNbC, aNbP, j; |
273 | Standard_Integer nV1, nV2; |
96a95605 |
274 | Standard_Real aTolR3D, aT1, aT2, aTol; |
4e57c75e |
275 | Handle(NCollection_IncAllocator) aAllocator; |
276 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
277 | TopoDS_Edge aES; |
278 | Handle(BOPDS_PaveBlock) aPBOut; |
279 | // |
280 | //-----------------------------------------------------scope f |
281 | aAllocator=new NCollection_IncAllocator(); |
282 | // |
283 | BOPCol_ListOfInteger aLSE(aAllocator); |
284 | BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator), |
285 | aMVStick(100,aAllocator), aMVEF(100, aAllocator), |
78c66ef1 |
286 | aMVB(100, aAllocator), aMI(100, aAllocator); |
4e57c75e |
287 | BOPDS_MapOfPaveBlock aMPBOnIn(100, aAllocator), |
288 | aMPBAdd(100, aAllocator); |
289 | BOPDS_ListOfPaveBlock aLPB(aAllocator); |
290 | BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMSCPB(100, aAllocator); |
291 | BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator); |
78c66ef1 |
292 | BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator); |
b4109929 |
293 | BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator); |
294 | BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV; |
78c66ef1 |
295 | BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator); |
4e57c75e |
296 | // |
297 | for (i=0; i<aNbFF; ++i) { |
298 | BOPDS_InterfFF& aFF=aFFs(i); |
299 | aFF.Indices(nF1, nF2); |
300 | // |
301 | BOPDS_VectorOfPoint& aVP=aFF.ChangePoints(); |
302 | aNbP=aVP.Extent(); |
303 | BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); |
304 | aNbC=aVC.Extent(); |
305 | if (!aNbP && !aNbC) { |
306 | continue; |
307 | } |
308 | // |
309 | const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1))); |
310 | const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2))); |
311 | // |
312 | aTolR3D=aFF.TolR3D(); |
4e57c75e |
313 | // |
314 | // Update face info |
315 | if (aMF.Add(nF1)) { |
316 | myDS->UpdateFaceInfoOn(nF1); |
317 | } |
318 | if (aMF.Add(nF2)) { |
319 | myDS->UpdateFaceInfoOn(nF2); |
320 | } |
321 | |
322 | BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1); |
323 | BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); |
324 | // |
325 | aMVOnIn.Clear(); |
326 | aMPBOnIn.Clear(); |
327 | aMVB.Clear(); |
b4109929 |
328 | aMVTol.Clear(); |
4e57c75e |
329 | // |
330 | myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn); |
331 | myDS->SharedEdges(nF1, nF2, aLSE, aAllocator); |
332 | |
333 | // 1. Treat Points |
334 | for (j=0; j<aNbP; ++j) { |
335 | TopoDS_Vertex aV; |
336 | BOPDS_CoupleOfPaveBlocks aCPB; |
337 | // |
338 | BOPDS_Point& aNP=aVP.ChangeValue(j); |
339 | const gp_Pnt& aP=aNP.Pnt(); |
340 | // |
341 | bExist=IsExistingVertex(aP, aTolR3D, aMVOnIn); |
342 | if (!bExist) { |
343 | BOPTools_AlgoTools::MakeNewVertex(aP, aTolR3D, aV); |
344 | // |
345 | aCPB.SetIndexInterf(i); |
346 | aCPB.SetIndex(j); |
347 | aMSCPB.Add(aV, aCPB); |
348 | } |
349 | } |
350 | // |
351 | // 2. Treat Curves |
352 | aMVStick.Clear(); |
353 | aMVEF.Clear(); |
78c66ef1 |
354 | GetStickVertices(nF1, nF2, aMVStick, aMVEF, aMI); |
4e57c75e |
355 | // |
356 | for (j=0; j<aNbC; ++j) { |
357 | BOPDS_Curve& aNC=aVC.ChangeValue(j); |
358 | const IntTools_Curve& aIC=aNC.Curve(); |
4e57c75e |
359 | // DEBt |
360 | aNC.InitPaveBlock1(); |
361 | // |
78c66ef1 |
362 | PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol); |
4e57c75e |
363 | // |
78c66ef1 |
364 | PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol); |
7ff8f019 |
365 | //904/F7 |
4e57c75e |
366 | if (aNbC == 1) { |
78c66ef1 |
367 | PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol); |
4e57c75e |
368 | } |
369 | // |
370 | if (aIC.HasBounds()) { |
371 | PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aMVOnIn, aMVB); |
372 | } |
373 | }//for (j=0; j<aNbC; ++j) { |
374 | // |
375 | // Put closing pave if needed |
376 | for (j=0; j<aNbC; ++j) { |
377 | BOPDS_Curve& aNC=aVC.ChangeValue(j); |
378 | PutClosingPaveOnCurve (aNC); |
379 | } |
380 | // |
381 | // 3. Make section edges |
382 | for (j=0; j<aNbC; ++j) { |
383 | BOPDS_Curve& aNC=aVC.ChangeValue(j); |
384 | const IntTools_Curve& aIC=aNC.Curve(); |
385 | // |
386 | BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); |
387 | Handle(BOPDS_PaveBlock)& aPB1=aNC.ChangePaveBlock1(); |
388 | // |
389 | aLPB.Clear(); |
390 | aPB1->Update(aLPB, Standard_False); |
391 | // |
392 | aItLPB.Initialize(aLPB); |
393 | for (; aItLPB.More(); aItLPB.Next()) { |
394 | Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue(); |
395 | aPB->Indices(nV1, nV2); |
396 | aPB->Range (aT1, aT2); |
397 | // |
398 | if (fabs(aT1 - aT2) < Precision::PConfusion()) { |
399 | continue; |
400 | } |
401 | // |
402 | bValid2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTolR3D); |
403 | if (!bValid2D) { |
404 | continue; |
405 | } |
406 | // |
407 | bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aLSE); |
408 | if (bExist) { |
409 | continue; |
410 | } |
411 | // |
412 | bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aMPBOnIn, aPBOut); |
413 | if (bExist) { |
414 | if (aMPBAdd.Add(aPBOut)) { |
415 | Standard_Boolean bInBothFaces = Standard_True; |
5a77460e |
416 | if (!myDS->IsCommonBlock(aPBOut)) { |
4e57c75e |
417 | Standard_Integer nE; |
418 | Standard_Real aTolE; |
419 | // |
420 | nE = aPBOut->Edge(); |
421 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE); |
422 | aTolE = BRep_Tool::Tolerance(aE); |
423 | if (aTolR3D > aTolE) { |
424 | myDS->UpdateEdgeTolerance(nE, aTolR3D); |
425 | } |
426 | bInBothFaces = Standard_False; |
427 | } else { |
428 | bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) || |
429 | aFI1.PaveBlocksIn().Contains(aPBOut))&& |
430 | (aFI2.PaveBlocksOn().Contains(aPBOut) || |
431 | aFI2.PaveBlocksIn().Contains(aPBOut)); |
432 | } |
433 | if (!bInBothFaces) { |
434 | PreparePostTreatFF(i, aPBOut, aMSCPB, aMVI, aVC); |
435 | } |
436 | } |
437 | continue; |
438 | } |
439 | // |
440 | // Make Edge |
441 | const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); |
442 | const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); |
443 | // |
444 | BOPTools_AlgoTools::MakeEdge (aIC, aV1, aT1, aV2, aT2, aTolR3D, aES); |
445 | BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC, |
446 | mySectionAttribute.PCurveOnS1(), |
447 | mySectionAttribute.PCurveOnS2()); |
448 | // |
449 | if (BOPTools_AlgoTools::IsMicroEdge(aES, myContext)) { |
450 | continue; |
451 | } |
452 | // |
453 | // Append the Pave Block to the Curve j |
454 | aLPBC.Append(aPB); |
455 | // |
456 | // Keep info for post treatment |
457 | BOPDS_CoupleOfPaveBlocks aCPB; |
458 | aCPB.SetIndexInterf(i); |
459 | aCPB.SetIndex(j); |
460 | aCPB.SetPaveBlock1(aPB); |
461 | // |
462 | aMSCPB.Add(aES, aCPB); |
463 | aMVI.Bind(aV1, nV1); |
464 | aMVI.Bind(aV2, nV2); |
b4109929 |
465 | // |
466 | aMVTol.UnBind(nV1); |
467 | aMVTol.UnBind(nV2); |
4e57c75e |
468 | } |
469 | // |
470 | aLPBC.RemoveFirst(); |
471 | }//for (j=0; j<aNbC; ++j) { |
b4109929 |
472 | //back to previous tolerance values for unused vertices |
473 | aItMV.Initialize(aMVTol); |
474 | for (; aItMV.More(); aItMV.Next()) { |
475 | nV1 = aItMV.Key(); |
476 | aTol = aItMV.Value(); |
477 | // |
478 | const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1); |
479 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*)&aV.TShape()); |
480 | TV->Tolerance(aTol); |
481 | } |
482 | // |
4e57c75e |
483 | ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd); |
484 | }//for (i=0; i<aNbFF; ++i) { |
485 | // |
486 | // post treatment |
78c66ef1 |
487 | myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator); |
4e57c75e |
488 | if (myErrorStatus) { |
489 | return; |
490 | } |
491 | // |
492 | // update face info |
493 | UpdateFaceInfo(aDMExEdges); |
78c66ef1 |
494 | //Update all pave blocks |
495 | UpdatePaveBlocks(aDMI); |
4e57c75e |
496 | //-----------------------------------------------------scope t |
497 | aMF.Clear(); |
498 | aMVStick.Clear(); |
499 | aMPBOnIn.Clear(); |
500 | aMVOnIn.Clear(); |
501 | aDMExEdges.Clear(); |
78c66ef1 |
502 | aMI.Clear(); |
503 | aDMI.Clear(); |
4e57c75e |
504 | aAllocator.Nullify(); |
505 | } |
506 | |
507 | //======================================================================= |
508 | //function : PostTreatFF |
509 | //purpose : |
510 | //======================================================================= |
511 | Standard_Integer BOPAlgo_PaveFiller::PostTreatFF |
512 | (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, |
513 | BOPCol_DataMapOfShapeInteger& aMVI, |
514 | BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges, |
78c66ef1 |
515 | BOPCol_DataMapOfIntegerInteger& aDMI, |
4e57c75e |
516 | Handle(NCollection_BaseAllocator)& theAllocator) |
517 | { |
518 | Standard_Integer iRet, aNbS; |
519 | // |
520 | iRet=0; |
521 | aNbS=theMSCPB.Extent(); |
522 | if (!aNbS) { |
523 | return iRet; |
524 | } |
525 | // |
526 | Standard_Boolean bHasPaveBlocks, bOld; |
1d47d8d0 |
527 | Standard_Integer iErr, nSx, nVSD, iX, iP, iC, j, nV, iV = 0, iE, k; |
af4e6dab |
528 | Standard_Integer jx, aNbLPBx; |
4e57c75e |
529 | Standard_Real aT; |
4e57c75e |
530 | TopAbs_ShapeEnum aType; |
531 | TopoDS_Shape aV, aE; |
532 | BOPCol_ListIteratorOfListOfShape aItLS; |
533 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
534 | BOPDS_PDS aPDS; |
535 | Handle(BOPDS_PaveBlock) aPB1; |
536 | BOPDS_Pave aPave[2], aPave1[2]; |
537 | BOPDS_ShapeInfo aSI; |
538 | // |
539 | BOPCol_ListOfShape aLS(theAllocator); |
540 | BOPAlgo_PaveFiller aPF(theAllocator); |
541 | // |
542 | BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); |
543 | // |
544 | // <-DEB f |
545 | // |
546 | // 0 |
547 | if (aNbS==1) { |
548 | const TopoDS_Shape& aS=theMSCPB.FindKey(1); |
549 | const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromIndex(1); |
550 | |
551 | // |
552 | aType=aS.ShapeType(); |
553 | if (aType==TopAbs_VERTEX) { |
554 | aSI.SetShapeType(aType); |
555 | aSI.SetShape(aS); |
556 | iV=myDS->Append(aSI); |
557 | // |
558 | iX=aCPB.IndexInterf(); |
559 | iP=aCPB.Index(); |
560 | BOPDS_InterfFF& aFF=aFFs(iX); |
561 | BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); |
562 | BOPDS_Point& aNP=aVNP(iP); |
563 | aNP.SetIndex(iV); |
564 | } |
565 | else if (aType==TopAbs_EDGE) { |
566 | aPB1=aCPB.PaveBlock1(); |
567 | // |
568 | if (aPB1->HasEdge()) { |
569 | BOPDS_ListOfPaveBlock aLPBx; |
570 | aLPBx.Append(aPB1); |
571 | aDMExEdges.Bind(aPB1, aLPBx); |
572 | } else { |
573 | aSI.SetShapeType(aType); |
574 | aSI.SetShape(aS); |
575 | iE=myDS->Append(aSI); |
576 | // |
577 | aPB1->SetEdge(iE); |
578 | } |
579 | } |
580 | return iRet; |
581 | } |
582 | // |
583 | // 1 prepare arguments |
584 | for (k=1; k<=aNbS; ++k) { |
585 | const TopoDS_Shape& aS=theMSCPB.FindKey(k); |
586 | aLS.Append(aS); |
587 | } |
588 | // |
589 | // 2 Fuse shapes |
590 | aPF.SetArguments(aLS); |
591 | aPF.Perform(); |
592 | iErr=aPF.ErrorStatus(); |
593 | if (iErr) { |
594 | iRet=1; |
595 | return iRet; |
596 | } |
597 | aPDS=aPF.PDS(); |
598 | // |
599 | aItLS.Initialize(aLS); |
600 | for (; aItLS.More(); aItLS.Next()) { |
601 | const TopoDS_Shape& aSx=aItLS.Value(); |
602 | nSx=aPDS->Index(aSx); |
603 | const BOPDS_ShapeInfo& aSIx=aPDS->ShapeInfo(nSx); |
604 | // |
605 | aType=aSIx.ShapeType(); |
606 | // |
607 | if (aType==TopAbs_VERTEX) { |
608 | if (aPDS->HasShapeSD(nSx, nVSD)) { |
609 | aV=aPDS->Shape(nVSD); |
610 | } |
611 | else { |
612 | aV=aSx; |
613 | } |
614 | // index of new vertex in theDS -> iV |
615 | if (!aMVI.IsBound(aV)) { |
616 | aSI.SetShapeType(aType); |
617 | aSI.SetShape(aV); |
618 | iV=myDS->Append(aSI); |
619 | // |
620 | aMVI.Bind(aV, iV); |
621 | } |
622 | else { |
623 | iV=aMVI.Find(aV); |
624 | } |
625 | // update FF interference |
626 | const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx); |
627 | iX=aCPB.IndexInterf(); |
628 | iP=aCPB.Index(); |
629 | BOPDS_InterfFF& aFF=aFFs(iX); |
630 | BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); |
631 | BOPDS_Point& aNP=aVNP(iP); |
632 | aNP.SetIndex(iV); |
633 | }//if (aType==TopAbs_VERTEX) { |
634 | // |
635 | else if (aType==TopAbs_EDGE) { |
636 | bHasPaveBlocks=aPDS->HasPaveBlocks(nSx); |
637 | const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx); |
638 | iX=aCPB.IndexInterf(); |
639 | iC=aCPB.Index(); |
640 | aPB1=aCPB.PaveBlock1(); |
641 | // |
642 | bOld = aPB1->HasEdge(); |
643 | if (bOld) { |
644 | BOPDS_ListOfPaveBlock aLPBx; |
645 | aDMExEdges.Bind(aPB1, aLPBx); |
646 | } |
647 | // |
648 | if (!bHasPaveBlocks) { |
649 | if (bOld) { |
650 | aDMExEdges.ChangeFind(aPB1).Append(aPB1); |
651 | } else { |
652 | aSI.SetShapeType(aType); |
653 | aSI.SetShape(aSx); |
654 | iE=myDS->Append(aSI); |
655 | // |
656 | aPB1->SetEdge(iE); |
657 | } |
658 | } |
659 | else { |
660 | BOPDS_InterfFF& aFF=aFFs(iX); |
661 | BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); |
662 | BOPDS_Curve& aNC=aVNC(iC); |
663 | BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); |
664 | // |
665 | const BOPDS_ListOfPaveBlock& aLPBx=aPDS->PaveBlocks(nSx); |
666 | aNbLPBx=aLPBx.Extent(); |
667 | // |
668 | if (bOld && !aNbLPBx) { |
669 | aDMExEdges.ChangeFind(aPB1).Append(aPB1); |
670 | continue; |
671 | } |
672 | // |
673 | if (!bOld) { |
674 | aItLPB.Initialize(aLPBC); |
675 | for (; aItLPB.More(); aItLPB.Next()) { |
676 | const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value(); |
677 | if (aPBC==aPB1) { |
678 | aLPBC.Remove(aItLPB); |
679 | break; |
680 | } |
681 | } |
682 | } |
683 | // |
684 | if (!aNbLPBx) { |
685 | aE=aSx; |
686 | // |
687 | if (!aMVI.IsBound(aE)) { |
688 | aSI.SetShapeType(aType); |
689 | aSI.SetShape(aE); |
690 | iE=myDS->Append(aSI); |
691 | aMVI.Bind(aE, iE); |
692 | } |
693 | else { |
694 | iE=aMVI.Find(aE); |
695 | } |
696 | // append new PaveBlock to aLPBC |
4e57c75e |
697 | aPB1->SetEdge(iE); |
698 | aLPBC.Append(aPB1); |
699 | } // if (!aNbLPBx) { |
700 | // |
701 | else { |
702 | aItLPB.Initialize(aLPBx); |
703 | if (bOld) { |
704 | aPave1[0] = aPB1->Pave1(); |
705 | aPave1[1] = aPB1->Pave2(); |
706 | } |
707 | for (; aItLPB.More(); aItLPB.Next()) { |
708 | const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value(); |
5a77460e |
709 | const Handle(BOPDS_PaveBlock) aPBRx=aPDS->RealPaveBlock(aPBx); |
4e57c75e |
710 | // |
711 | // update vertices of paves |
712 | aPave[0]=aPBx->Pave1(); |
713 | aPave[1]=aPBx->Pave2(); |
714 | for (j=0; j<2; ++j) { |
715 | jx = 0; |
716 | if (bOld) { |
717 | aT = aPave[j].Parameter(); |
718 | if (aT == aPave1[0].Parameter()) { |
719 | jx = 1; |
720 | } else if (aT == aPave1[1].Parameter()) { |
721 | jx = 2; |
722 | } |
723 | // |
724 | if (jx) { |
725 | iV = aPave1[jx-1].Index(); |
726 | } |
727 | } |
728 | if (!jx) { |
729 | nV=aPave[j].Index(); |
730 | aV=aPDS->Shape(nV); |
731 | // |
732 | if (!aMVI.IsBound(aV)) {// index of new vertex in theDS -> iV |
733 | aSI.SetShapeType(TopAbs_VERTEX); |
734 | aSI.SetShape(aV); |
735 | iV=myDS->Append(aSI); |
736 | aMVI.Bind(aV, iV); |
737 | } |
738 | else { |
739 | iV=aMVI.Find(aV); |
740 | } |
741 | } |
78c66ef1 |
742 | const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2(); |
743 | if (aP1.Parameter() == aPave[j].Parameter() && aP1.Index() != iV) { |
744 | aDMI.Bind(aP1.Index(), iV); |
745 | } |
746 | // |
4e57c75e |
747 | aPave[j].SetIndex(iV); |
748 | } |
749 | // |
750 | // add edge |
751 | aE=aPDS->Shape(aPBRx->Edge()); |
752 | // |
753 | if (!aMVI.IsBound(aE)) { |
754 | aSI.SetShapeType(aType); |
755 | aSI.SetShape(aE); |
756 | iE=myDS->Append(aSI); |
757 | aMVI.Bind(aE, iE); |
758 | } |
759 | else { |
760 | iE=aMVI.Find(aE); |
761 | } |
762 | // append new PaveBlock to aLPBC |
763 | Handle(BOPDS_PaveBlock) aPBC=new BOPDS_PaveBlock(); |
764 | // |
765 | aPBC->SetPave1(aPave[0]); |
766 | aPBC->SetPave2(aPave[1]); |
767 | aPBC->SetEdge(iE); |
768 | if (bOld) { |
769 | aPBC->SetOriginalEdge(aPB1->OriginalEdge()); |
770 | aDMExEdges.ChangeFind(aPB1).Append(aPBC); |
771 | } |
772 | else { |
773 | aLPBC.Append(aPBC); |
774 | } |
775 | } |
776 | } |
777 | } |
778 | }//else if (aType==TopAbs_EDGE) |
779 | }//for (; aItLS.More(); aItLS.Next()) { |
780 | return iRet; |
781 | } |
782 | |
783 | //======================================================================= |
784 | //function : UpdateFaceInfo |
785 | //purpose : |
786 | //======================================================================= |
78c66ef1 |
787 | void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME) |
4e57c75e |
788 | { |
789 | Standard_Integer i, j, nV1, nF1, nF2, |
790 | aNbFF, aNbC, aNbP, aNbS, aNbPBIn; |
791 | BOPDS_IndexedMapOfPaveBlock aMPBCopy; |
792 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
793 | // |
794 | BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); |
795 | aNbFF=aFFs.Extent(); |
796 | // |
797 | //1. Sections (curves, points); |
798 | for (i=0; i<aNbFF; ++i) { |
799 | BOPDS_InterfFF& aFF=aFFs(i); |
800 | aFF.Indices(nF1, nF2); |
801 | // |
802 | BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1); |
803 | BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); |
804 | // |
805 | BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); |
806 | aNbC=aVNC.Extent(); |
807 | for (j=0; j<aNbC; ++j) { |
808 | BOPDS_Curve& aNC=aVNC(j); |
809 | BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); |
810 | aItLPB.Initialize(aLPBC); |
811 | // |
812 | if (aItLPB.More() && theDME.IsBound(aLPBC.First())) { |
813 | const Handle(BOPDS_PaveBlock)& aPB=aLPBC.First(); |
814 | BOPDS_ListOfPaveBlock& aLPB = theDME.ChangeFind(aPB); |
815 | UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2); |
816 | aLPBC.Clear(); |
817 | continue; |
818 | } |
819 | // |
820 | for(; aItLPB.More(); aItLPB.Next()) { |
821 | const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value(); |
822 | aFI1.ChangePaveBlocksSc().Add(aPB); |
823 | aFI2.ChangePaveBlocksSc().Add(aPB); |
824 | } |
825 | } |
826 | // VerticesSc |
827 | const BOPDS_VectorOfPoint& aVNP=aFF.Points(); |
828 | aNbP=aVNP.Extent(); |
829 | for (j=0; j<aNbP; ++j) { |
830 | const BOPDS_Point& aNP=aVNP(j); |
831 | nV1=aNP.Index(); |
832 | aFI1.ChangeVerticesSc().Add(nV1); |
833 | aFI2.ChangeVerticesSc().Add(nV1); |
834 | } |
835 | } |
836 | // |
837 | //2. PaveBlocksIn |
838 | if (theDME.IsEmpty()) { |
839 | return; |
840 | } |
841 | // |
842 | aNbS=myDS->NbSourceShapes(); |
843 | for (i=0; i<aNbS; ++i) { |
844 | const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); |
845 | if (aSI.ShapeType()!=TopAbs_FACE) { |
846 | continue; |
847 | } |
4e57c75e |
848 | if(!myDS->HasFaceInfo(i)) { |
849 | continue; |
850 | } |
851 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(i); |
852 | // |
853 | BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn(); |
854 | aMPBCopy.Assign(aMPBIn); |
855 | aMPBIn.Clear(); |
856 | // |
857 | aNbPBIn=aMPBCopy.Extent(); |
858 | for (j=1; j<=aNbPBIn; ++j) { |
859 | const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j); |
860 | if (theDME.IsBound(aPB)) { |
861 | const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB); |
862 | aItLPB.Initialize(aLPB); |
863 | for (; aItLPB.More(); aItLPB.Next()) { |
864 | const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value(); |
865 | aMPBIn.Add(aPB1); |
866 | } |
867 | } else { |
868 | aMPBIn.Add(aPB); |
869 | } |
870 | }//for (j=1; j<=aNbPBIn; ++j) { |
871 | }//for (i=0; i<aNbS; ++i) { |
872 | } |
4e57c75e |
873 | //======================================================================= |
874 | //function : IsExistingVertex |
875 | //purpose : |
876 | //======================================================================= |
877 | Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex |
878 | (const gp_Pnt& aP, |
879 | const Standard_Real theTolR3D, |
880 | const BOPCol_MapOfInteger& aMVOnIn)const |
881 | { |
882 | Standard_Boolean bRet; |
883 | Standard_Integer nV, iFlag; |
884 | Standard_Real aTolV; |
885 | gp_Pnt aPV; |
886 | Bnd_Box aBoxP; |
887 | BOPCol_MapIteratorOfMapOfInteger aIt; |
888 | // |
889 | bRet=Standard_True; |
890 | // |
891 | aBoxP.Add(aP); |
892 | aBoxP.Enlarge(theTolR3D); |
893 | // |
894 | aIt.Initialize(aMVOnIn); |
895 | for (; aIt.More(); aIt.Next()) { |
896 | Bnd_Box aBoxV; |
897 | // |
898 | nV=aIt.Value(); |
899 | const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
900 | aPV=BRep_Tool::Pnt(aV); |
901 | aTolV=BRep_Tool::Tolerance(aV); |
902 | aBoxV.Add(aP); |
903 | aBoxV.Enlarge(aTolV); |
904 | // |
905 | if (!aBoxP.IsOut(aBoxV)) { |
906 | iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP, theTolR3D); |
907 | if (!iFlag) { |
908 | return bRet; |
909 | } |
910 | } |
911 | } |
912 | return !bRet; |
913 | } |
914 | //======================================================================= |
915 | //function : IsExistingPaveBlock |
916 | //purpose : |
917 | //======================================================================= |
918 | Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock |
919 | (const Handle(BOPDS_PaveBlock)& thePB, |
920 | const BOPDS_Curve& theNC, |
921 | const Standard_Real theTolR3D, |
922 | const BOPCol_ListOfInteger& theLSE) |
923 | { |
924 | Standard_Boolean bRet=Standard_True; |
925 | // |
926 | if (theLSE.IsEmpty()) { |
927 | return !bRet; |
928 | } |
929 | // |
930 | Standard_Real aT1, aT2, aTm, aTx, aTol; |
931 | Standard_Integer nE, iFlag; |
932 | gp_Pnt aPm; |
933 | Bnd_Box aBoxPm; |
934 | BOPCol_ListIteratorOfListOfInteger aItLI; |
935 | // |
936 | thePB->Range(aT1, aT2); |
937 | aTm=IntTools_Tools::IntermediatePoint (aT1, aT2); |
938 | theNC.Curve().D0(aTm, aPm); |
939 | aBoxPm.Add(aPm); |
940 | aBoxPm.Enlarge(theTolR3D); |
941 | // |
942 | aItLI.Initialize(theLSE); |
943 | for (; aItLI.More(); aItLI.Next()) { |
944 | nE=aItLI.Value(); |
945 | const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE); |
946 | const Bnd_Box& aBoxE=aSIE.Box(); |
947 | if (!aBoxE.IsOut(aBoxPm)) { |
948 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); |
949 | aTol = BRep_Tool::Tolerance(aE); |
950 | aTol = aTol > theTolR3D ? aTol : theTolR3D; |
951 | iFlag=myContext->ComputePE(aPm, aTol, aE, aTx); |
952 | if (!iFlag) { |
953 | return bRet; |
954 | } |
955 | } |
956 | } |
957 | return !bRet; |
958 | } |
959 | |
960 | //======================================================================= |
961 | //function : IsExistingPaveBlock |
962 | //purpose : |
963 | //======================================================================= |
964 | Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock |
965 | (const Handle(BOPDS_PaveBlock)& thePB, |
966 | const BOPDS_Curve& theNC, |
967 | const Standard_Real theTolR3D, |
968 | const BOPDS_MapOfPaveBlock& theMPBOnIn, |
969 | Handle(BOPDS_PaveBlock&) aPBOut) |
970 | { |
971 | Standard_Boolean bRet; |
972 | Standard_Real aT1, aT2, aTm, aTx; |
78c66ef1 |
973 | Standard_Integer nSp, iFlag1, iFlag2, nV11, nV12, nV21, nV22; |
4e57c75e |
974 | gp_Pnt aP1, aPm, aP2; |
975 | Bnd_Box aBoxP1, aBoxPm, aBoxP2; |
976 | BOPDS_MapIteratorOfMapOfPaveBlock aIt; |
977 | // |
78c66ef1 |
978 | bRet=Standard_False; |
4e57c75e |
979 | const IntTools_Curve& aIC=theNC.Curve(); |
980 | // |
981 | thePB->Range(aT1, aT2); |
982 | thePB->Indices(nV11, nV12); |
983 | //first point |
984 | aIC.D0(aT1, aP1); |
985 | aBoxP1.Add(aP1); |
986 | aBoxP1.Enlarge(theTolR3D); |
987 | //intermediate point |
988 | aTm=IntTools_Tools::IntermediatePoint (aT1, aT2); |
989 | aIC.D0(aTm, aPm); |
990 | aBoxPm.Add(aPm); |
991 | aBoxPm.Enlarge(theTolR3D); |
992 | //last point |
993 | aIC.D0(aT2, aP2); |
994 | aBoxP2.Add(aP2); |
995 | aBoxP2.Enlarge(theTolR3D); |
996 | // |
997 | aIt.Initialize(theMPBOnIn); |
998 | for (; aIt.More(); aIt.Next()) { |
999 | const Handle(BOPDS_PaveBlock)& aPB=aIt.Value(); |
1000 | aPB->Indices(nV21, nV22); |
1001 | nSp=aPB->Edge(); |
1002 | const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp); |
78c66ef1 |
1003 | const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape())); |
4e57c75e |
1004 | const Bnd_Box& aBoxSp=aSISp.Box(); |
78c66ef1 |
1005 | // |
1006 | iFlag1 = (nV11 == nV21 || nV11 == nV22) ? 2 : (!aBoxSp.IsOut(aBoxP1) ? 1 : 0); |
1007 | iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 : (!aBoxSp.IsOut(aBoxP2) ? 1 : 0); |
1008 | if (iFlag1 && iFlag2) { |
1009 | if (aBoxSp.IsOut(aBoxPm) || myContext->ComputePE(aPm, theTolR3D, aSp, aTx)) { |
1010 | continue; |
1011 | } |
1012 | // |
1013 | if (iFlag1 == 1) { |
1014 | iFlag1 = !myContext->ComputePE(aP1, theTolR3D, aSp, aTx); |
1015 | } |
1016 | // |
1017 | if (iFlag2 == 1) { |
1018 | iFlag2 = !myContext->ComputePE(aP2, theTolR3D, aSp, aTx); |
1019 | } |
1020 | // |
1021 | if (iFlag1 && iFlag2) { |
1022 | aPBOut = aPB; |
1023 | bRet=Standard_True; |
1024 | break; |
4e57c75e |
1025 | } |
1026 | } |
1027 | } |
78c66ef1 |
1028 | return bRet; |
4e57c75e |
1029 | } |
1030 | |
1031 | //======================================================================= |
1032 | //function : PutBoundPaveOnCurve |
1033 | //purpose : |
1034 | //======================================================================= |
1035 | void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1, |
1036 | const TopoDS_Face& aF2, |
1037 | const Standard_Real aTolR3D, |
1038 | BOPDS_Curve& aNC, |
1039 | BOPCol_MapOfInteger& aMVOnIn, |
1040 | BOPCol_MapOfInteger& aMVB) |
1041 | { |
1042 | Standard_Boolean bVF; |
1043 | Standard_Integer nV, iFlag, nVn, j, aNbEP; |
1044 | Standard_Real aT[2], aTmin, aTmax, aTV, aTol, aTolVnew; |
1045 | gp_Pnt aP[2]; |
1046 | TopoDS_Vertex aVn; |
1047 | BOPDS_ListIteratorOfListOfPave aItLP; |
1048 | BOPDS_Pave aPn, aPMM[2]; |
1049 | // |
1050 | aTolVnew = Precision::Confusion(); |
1051 | // |
1052 | const IntTools_Curve& aIC=aNC.Curve(); |
1053 | aIC.Bounds(aT[0], aT[1], aP[0], aP[1]); |
1054 | // |
1055 | Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); |
1056 | const BOPDS_ListOfPave& aLP=aPB->ExtPaves(); |
1057 | // |
1058 | aNbEP=aLP.Extent(); |
1059 | if (aNbEP) { |
1060 | aTmin=1.e10; |
1061 | aTmax=-aTmin; |
1062 | // |
1063 | aItLP.Initialize(aLP); |
1064 | for (; aItLP.More(); aItLP.Next()) { |
1065 | const BOPDS_Pave& aPv=aItLP.Value(); |
1066 | aPv.Contents(nV, aTV); |
1067 | if (aTV<aTmin) { |
1068 | aPMM[0]=aPv; |
1069 | aTmin=aTV; |
1070 | } |
1071 | if (aTV>aTmax) { |
1072 | aPMM[1]=aPv; |
1073 | aTmax=aTV; |
1074 | } |
1075 | } |
1076 | } |
1077 | // |
1078 | for (j=0; j<2; ++j) { |
1079 | //if curve is closed, process only one bound |
1080 | if (j && aP[1].IsEqual(aP[0], aTolVnew)) { |
1081 | continue; |
1082 | } |
1083 | // |
1084 | iFlag=1; |
1085 | // |
1086 | if (aNbEP) { |
1087 | Bnd_Box aBoxP; |
1088 | // |
1089 | aBoxP.Set(aP[j]); |
1090 | aTol = aTolR3D+Precision::Confusion(); |
1091 | aBoxP.Enlarge(aTol); |
1092 | const BOPDS_Pave& aPV=aPMM[j]; |
1093 | nV=aPV.Index(); |
1094 | const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); |
1095 | const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape())); |
1096 | const Bnd_Box& aBoxV=aSIV.Box(); |
1097 | if (!aBoxP.IsOut(aBoxV)){ |
1098 | iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol); |
1099 | } |
1100 | } |
1101 | if (iFlag) { |
1102 | // 900/L5 |
1103 | bVF=myContext->IsValidPointForFaces (aP[j], aF1, aF2, aTolR3D); |
1104 | if (!bVF) { |
1105 | continue; |
1106 | } |
1107 | // |
1108 | BOPDS_ShapeInfo aSIVn; |
1109 | // |
1110 | BOPTools_AlgoTools::MakeNewVertex(aP[j], aTolR3D, aVn); |
1111 | aSIVn.SetShapeType(TopAbs_VERTEX); |
1112 | aSIVn.SetShape(aVn); |
1113 | // |
1114 | nVn=myDS->Append(aSIVn); |
1115 | // |
1116 | aPn.SetIndex(nVn); |
1117 | aPn.SetParameter(aT[j]); |
1118 | aPB->AppendExtPave(aPn); |
1119 | // |
1120 | aVn=(*(TopoDS_Vertex *)(&myDS->Shape(nVn))); |
1121 | BOPTools_AlgoTools::UpdateVertex (aIC, aT[j], aVn); |
1122 | // |
1123 | aTolVnew = BRep_Tool::Tolerance(aVn); |
1124 | // |
1125 | BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn); |
1126 | Bnd_Box& aBoxDS=aSIDS.ChangeBox(); |
1127 | BRepBndLib::Add(aVn, aBoxDS); |
1128 | aMVOnIn.Add(nVn); |
1129 | aMVB.Add(nVn); |
1130 | } |
1131 | } |
1132 | } |
1133 | |
1134 | //======================================================================= |
78c66ef1 |
1135 | //function : PutPavesOnCurve |
4e57c75e |
1136 | //purpose : |
1137 | //======================================================================= |
78c66ef1 |
1138 | void BOPAlgo_PaveFiller::PutPavesOnCurve(const BOPCol_MapOfInteger& aMVOnIn, |
1139 | const Standard_Real aTolR3D, |
1140 | BOPDS_Curve& aNC, |
1141 | const Standard_Integer nF1, |
1142 | const Standard_Integer nF2, |
1143 | const BOPCol_MapOfInteger& aMI, |
1144 | const BOPCol_MapOfInteger& aMVEF, |
1145 | BOPCol_DataMapOfIntegerReal& aMVTol) |
4e57c75e |
1146 | { |
78c66ef1 |
1147 | Standard_Boolean bInBothFaces; |
4e57c75e |
1148 | Standard_Integer nV; |
4e57c75e |
1149 | BOPCol_MapIteratorOfMapOfInteger aIt; |
1150 | // |
4e57c75e |
1151 | const Bnd_Box& aBoxC=aNC.Box(); |
1152 | // |
78c66ef1 |
1153 | //Put EF vertices first |
1154 | aIt.Initialize(aMVEF); |
1155 | for (; aIt.More(); aIt.Next()) { |
1156 | nV=aIt.Value(); |
1157 | PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2); |
1158 | } |
1159 | //Put all other vertices |
4e57c75e |
1160 | aIt.Initialize(aMVOnIn); |
1161 | for (; aIt.More(); aIt.Next()) { |
1162 | nV=aIt.Value(); |
78c66ef1 |
1163 | if (aMVEF.Contains(nV)) { |
1164 | continue; |
4e57c75e |
1165 | } |
1166 | // |
78c66ef1 |
1167 | const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); |
1168 | const Bnd_Box& aBoxV=aSIV.Box(); |
4e57c75e |
1169 | // |
78c66ef1 |
1170 | if (aBoxC.IsOut(aBoxV)){ |
1171 | continue; |
1172 | } |
1173 | if (!myDS->IsNewShape(nV)) { |
1174 | const BOPDS_FaceInfo& aFI1 = myDS->FaceInfo(nF1); |
1175 | const BOPDS_FaceInfo& aFI2 = myDS->FaceInfo(nF2); |
b4109929 |
1176 | // |
78c66ef1 |
1177 | bInBothFaces = (aFI1.VerticesOn().Contains(nV) || |
1178 | aFI1.VerticesIn().Contains(nV))&& |
1179 | (aFI2.VerticesOn().Contains(nV) || |
1180 | aFI2.VerticesIn().Contains(nV)); |
1181 | if (!bInBothFaces) { |
1182 | continue; |
b4109929 |
1183 | } |
4e57c75e |
1184 | } |
78c66ef1 |
1185 | // |
1186 | PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1); |
4e57c75e |
1187 | } |
1188 | } |
1189 | |
1190 | //======================================================================= |
1191 | //function : ExtendedTolerance |
1192 | //purpose : |
1193 | //======================================================================= |
78c66ef1 |
1194 | Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV, |
1195 | const BOPCol_MapOfInteger& aMI, |
1196 | Standard_Real& aTolVExt, |
1197 | const Standard_Integer aType) |
4e57c75e |
1198 | { |
1199 | Standard_Boolean bFound = Standard_False; |
1200 | if (!(myDS->IsNewShape(nV))) { |
1201 | return bFound; |
1202 | } |
78c66ef1 |
1203 | // |
1204 | Standard_Integer i, k, aNbLines, aNbInt; |
4e57c75e |
1205 | Standard_Real aT11, aT12, aD1, aD2, aD; |
1206 | TopoDS_Vertex aV; |
1207 | gp_Pnt aPV, aP11, aP12; |
78c66ef1 |
1208 | // |
1209 | k = 0; |
1210 | aNbInt = 2; |
1211 | if (aType == 1) { |
1212 | aNbInt = 1; |
1213 | } else if (aType == 2) { |
1214 | k = 1; |
1215 | } |
1216 | // |
4e57c75e |
1217 | aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
1218 | aPV=BRep_Tool::Pnt(aV); |
1219 | // |
1220 | BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); |
1221 | BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); |
78c66ef1 |
1222 | // |
1223 | for (; k<aNbInt; ++k) { |
4e57c75e |
1224 | aNbLines = !k ? aEEs.Extent() : aEFs.Extent(); |
1225 | for (i = 0; i < aNbLines; ++i) { |
1226 | BOPDS_Interf *aInt = !k ? (BOPDS_Interf*) (&aEEs(i)) : |
78c66ef1 |
1227 | (BOPDS_Interf*) (&aEFs(i)); |
4e57c75e |
1228 | if (aInt->IndexNew() == nV) { |
1229 | if (aMI.Contains(aInt->Index1()) && aMI.Contains(aInt->Index2())) { |
1230 | const IntTools_CommonPrt& aComPrt = !k ? aEEs(i).CommonPart() : |
78c66ef1 |
1231 | aEFs(i).CommonPart(); |
4e57c75e |
1232 | // |
1233 | const TopoDS_Edge& aE1=aComPrt.Edge1(); |
1234 | aComPrt.Range1(aT11, aT12); |
1235 | BOPTools_AlgoTools::PointOnEdge(aE1, aT11, aP11); |
1236 | BOPTools_AlgoTools::PointOnEdge(aE1, aT12, aP12); |
1237 | aD1=aPV.Distance(aP11); |
1238 | aD2=aPV.Distance(aP12); |
1239 | aD=(aD1>aD2)? aD1 : aD2; |
1240 | if (aD>aTolVExt) { |
1241 | aTolVExt=aD; |
1242 | } |
1243 | return !bFound; |
1244 | }//if (aMI.Contains(aEF.Index1()) && aMI.Contains(aEF.Index2())) { |
1245 | }//if (aInt->IndexNew() == nV) { |
1246 | }//for (i = 0; i < aNbLines; ++i) { |
1247 | }//for (k=0; k<2; ++k) { |
4e57c75e |
1248 | return bFound; |
1249 | } |
1250 | |
1251 | //======================================================================= |
1252 | //function : GetEFPnts |
1253 | //purpose : |
1254 | //======================================================================= |
1255 | void BOPAlgo_PaveFiller::GetEFPnts(const Standard_Integer nF1, |
1256 | const Standard_Integer nF2, |
1257 | IntSurf_ListOfPntOn2S& aListOfPnts) |
1258 | { |
1259 | Standard_Integer nE, nF, nFOpposite, aNbEFs, i; |
1260 | Standard_Real U1, U2, V1, V2, f, l; |
78c66ef1 |
1261 | BOPCol_MapOfInteger aMI; |
4e57c75e |
1262 | // |
1263 | //collect indexes of all shapes from nF1 and nF2. |
78c66ef1 |
1264 | GetFullShapeMap(nF1, aMI); |
1265 | GetFullShapeMap(nF2, aMI); |
4e57c75e |
1266 | // |
1267 | BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); |
1268 | aNbEFs = aEFs.Extent(); |
1269 | // |
1270 | for(i = 0; i < aNbEFs; ++i) { |
1271 | const BOPDS_InterfEF& aEF = aEFs(i); |
78c66ef1 |
1272 | if (aEF.HasIndexNew()) { |
1273 | aEF.Indices(nE, nFOpposite); |
1274 | if(aMI.Contains(nE) && aMI.Contains(nFOpposite)) { |
1275 | const IntTools_CommonPrt& aCP = aEF.CommonPart(); |
4e57c75e |
1276 | Standard_Real aPar = aCP.VertexParameter1(); |
1277 | const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE))); |
1278 | const TopoDS_Face& aFOpposite = (*(TopoDS_Face*)(&myDS->Shape(nFOpposite))); |
1279 | // |
1280 | const Handle(Geom_Curve)& aCurve = BRep_Tool::Curve(aE, f, l); |
1281 | // |
1282 | nF = (nFOpposite == nF1) ? nF2 : nF1; |
1283 | const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF))); |
1284 | Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(aE, aF, f, l); |
1285 | // |
1286 | GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aFOpposite); |
1287 | // |
1288 | gp_Pnt aPoint; |
1289 | aCurve->D0(aPar, aPoint); |
1290 | IntSurf_PntOn2S aPnt; |
1291 | if(!aPCurve.IsNull()) { |
1292 | gp_Pnt2d aP2d = aPCurve->Value(aPar); |
1293 | aProj.Perform(aPoint); |
1294 | if(aProj.IsDone()) { |
1295 | aProj.LowerDistanceParameters(U1,V1); |
1296 | if (nF == nF1) { |
1297 | aPnt.SetValue(aP2d.X(),aP2d.Y(),U1,V1); |
1298 | } else { |
1299 | aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y()); |
1300 | } |
1301 | aListOfPnts.Append(aPnt); |
1302 | } |
1303 | } |
1304 | else { |
1305 | GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF); |
1306 | aProj1.Perform(aPoint); |
1307 | aProj.Perform(aPoint); |
1308 | if(aProj1.IsDone() && aProj.IsDone()){ |
1309 | aProj1.LowerDistanceParameters(U1,V1); |
1310 | aProj.LowerDistanceParameters(U2,V2); |
1311 | if (nF == nF1) { |
1312 | aPnt.SetValue(U1,V1,U2,V2); |
1313 | } else { |
1314 | aPnt.SetValue(U2,V2,U1,V1); |
1315 | } |
1316 | aListOfPnts.Append(aPnt); |
1317 | } |
1318 | } |
1319 | } |
1320 | } |
1321 | } |
1322 | } |
1323 | |
1324 | //======================================================================= |
1325 | //function : ProcessUnUsedVertices |
1326 | //purpose : |
1327 | //======================================================================= |
78c66ef1 |
1328 | void BOPAlgo_PaveFiller::PutEFPavesOnCurve(BOPDS_Curve& aNC, |
1329 | const BOPCol_MapOfInteger& aMI, |
b4109929 |
1330 | const BOPCol_MapOfInteger& aMVEF, |
1331 | BOPCol_DataMapOfIntegerReal& aMVTol) |
4e57c75e |
1332 | { |
1333 | if (!aMVEF.Extent()) { |
1334 | return; |
1335 | } |
1336 | // |
1337 | const IntTools_Curve& aIC=aNC.Curve(); |
1338 | GeomAbs_CurveType aTypeC; |
1339 | aTypeC=aIC.Type(); |
1340 | if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) { |
1341 | return; |
1342 | } |
1343 | // |
1344 | Standard_Integer nV; |
1345 | BOPCol_MapOfInteger aMV; |
1346 | // |
1347 | aMV.Assign(aMVEF); |
1348 | RemoveUsedVertices(aNC, aMV); |
1349 | if (!aMV.Extent()) { |
1350 | return; |
1351 | } |
1352 | // |
1353 | Standard_Real aDist; |
1354 | BOPDS_Pave aPave; |
1355 | // |
1356 | const Handle(Geom_Curve)& aC3D=aIC.Curve(); |
4e57c75e |
1357 | GeomAPI_ProjectPointOnCurve& aProjPT = myContext->ProjPT(aC3D); |
78c66ef1 |
1358 | // |
4e57c75e |
1359 | BOPCol_MapIteratorOfMapOfInteger aItMI; |
1360 | aItMI.Initialize(aMV); |
1361 | for (; aItMI.More(); aItMI.Next()) { |
1362 | nV = aItMI.Value(); |
1363 | const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
1364 | gp_Pnt aPV = BRep_Tool::Pnt(aV); |
1365 | aProjPT.Perform(aPV); |
1366 | Standard_Integer aNbPoints = aProjPT.NbPoints(); |
1367 | if (aNbPoints) { |
1368 | aDist = aProjPT.LowerDistance(); |
78c66ef1 |
1369 | PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol); |
4e57c75e |
1370 | } |
1371 | } |
1372 | } |
1373 | |
1374 | //======================================================================= |
1375 | //function : ProcessUnUsedVertices |
1376 | //purpose : |
1377 | //======================================================================= |
78c66ef1 |
1378 | void BOPAlgo_PaveFiller::PutStickPavesOnCurve(const TopoDS_Face& aF1, |
1379 | const TopoDS_Face& aF2, |
1380 | const BOPCol_MapOfInteger& aMI, |
4e57c75e |
1381 | BOPDS_Curve& aNC, |
b4109929 |
1382 | const BOPCol_MapOfInteger& aMVStick, |
1383 | BOPCol_DataMapOfIntegerReal& aMVTol) |
4e57c75e |
1384 | { |
1385 | BOPCol_MapOfInteger aMV; |
1386 | aMV.Assign(aMVStick); |
1387 | RemoveUsedVertices(aNC, aMV); |
1388 | // |
1389 | if (!aMV.Extent()) { |
1390 | return; |
1391 | } |
1392 | // |
1393 | GeomAbs_SurfaceType aType1, aType2; |
4e57c75e |
1394 | Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); |
1395 | Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2); |
1396 | GeomAdaptor_Surface aGAS1(aS1); |
1397 | GeomAdaptor_Surface aGAS2(aS2); |
4e57c75e |
1398 | // |
1399 | aType1=aGAS1.GetType(); |
1400 | aType2=aGAS2.GetType(); |
1401 | // |
ec0cdc0e |
1402 | //if (aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { |
1403 | GeomAbs_CurveType aTypeC; |
1404 | // |
1405 | const IntTools_Curve& aIC=aNC.Curve(); |
1406 | aTypeC=aIC.Type(); |
1407 | //if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) { |
1408 | Handle(Geom2d_Curve) aC2D[2]; |
1409 | // |
1410 | aC2D[0]=aIC.FirstCurve2d(); |
1411 | aC2D[1]=aIC.SecondCurve2d(); |
1412 | if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) { |
1413 | Standard_Integer nV, m, n; |
1414 | Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr; |
1415 | gp_Pnt aPC[2], aPV; |
1416 | gp_Dir aDN[2]; |
1417 | gp_Pnt2d aP2D; |
1418 | BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1; |
1419 | // |
1420 | aDT2=2e-7; // the rich criteria |
1421 | aDScPr=5.e-9; // the creasing criteria |
1422 | aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]); |
4e57c75e |
1423 | // |
ec0cdc0e |
1424 | aItMI.Initialize(aMV); |
1425 | for (; aItMI.More(); aItMI.Next()) { |
1426 | nV = aItMI.Value(); |
1427 | const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV)); |
1428 | aPV=BRep_Tool::Pnt(aV); |
4e57c75e |
1429 | // |
ec0cdc0e |
1430 | for (m=0; m<2; ++m) { |
1431 | aD2=aPC[m].SquareDistance(aPV); |
1432 | if (aD2>aDT2) {// no rich |
1433 | continue; |
1434 | } |
78c66ef1 |
1435 | // |
ec0cdc0e |
1436 | for (n=0; n<2; ++n) { |
1437 | Handle(Geom_Surface)& aS=(!n)? aS1 : aS2; |
1438 | aC2D[n]->D0(aTC[m], aP2D); |
1439 | aP2D.Coord(u, v); |
1440 | BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]); |
1441 | } |
1442 | // |
1443 | aScPr=aDN[0]*aDN[1]; |
1444 | if (aScPr<0.) { |
1445 | aScPr=-aScPr; |
1446 | } |
1447 | aScPr=1.-aScPr; |
78c66ef1 |
1448 | // |
ec0cdc0e |
1449 | if (aScPr>aDScPr) { |
1450 | continue; |
1451 | } |
1452 | // |
1453 | // The intersection curve aIC is vanishing curve (the crease) |
1454 | aD=sqrt(aD2); |
1455 | // |
1456 | PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol); |
4e57c75e |
1457 | } |
ec0cdc0e |
1458 | }//for (jVU=1; jVU=aNbVU; ++jVU) { |
1459 | } |
1460 | //}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) { |
1461 | //}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { |
4e57c75e |
1462 | } |
1463 | |
1464 | //======================================================================= |
1465 | //function : GetStickVertices |
1466 | //purpose : |
1467 | //======================================================================= |
1468 | void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1, |
1469 | const Standard_Integer nF2, |
1470 | BOPCol_MapOfInteger& aMVStick, |
78c66ef1 |
1471 | BOPCol_MapOfInteger& aMVEF, |
1472 | BOPCol_MapOfInteger& aMI) |
4e57c75e |
1473 | { |
78c66ef1 |
1474 | Standard_Integer nS1, nS2, nVNew, aTypeInt, i; |
4e57c75e |
1475 | // |
1476 | BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV(); |
1477 | BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE(); |
1478 | BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); |
1479 | BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); |
1480 | BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); |
1481 | // |
78c66ef1 |
1482 | Standard_Integer aNbLines[5] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), |
1483 | aVFs.Extent(), aEFs.Extent()}; |
1484 | //collect indices of all shapes from nF1 and nF2. |
1485 | aMI.Clear(); |
1486 | GetFullShapeMap(nF1, aMI); |
1487 | GetFullShapeMap(nF2, aMI); |
1488 | // |
1489 | //collect VV, VE, EE, VF interferences |
1490 | for (aTypeInt = 0; aTypeInt < 4; ++aTypeInt) { |
1491 | for (i = 0; i < aNbLines[aTypeInt]; ++i) { |
1492 | BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) : |
1493 | ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) : |
1494 | ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) : (BOPDS_Interf*)(&aVFs(i)))); |
1495 | if (aInt->HasIndexNew()) { |
1496 | aInt->Indices(nS1, nS2); |
1497 | if(aMI.Contains(nS1) && aMI.Contains(nS2)) { |
1498 | nVNew = aInt->IndexNew(); |
1499 | aMVStick.Add(nVNew); |
1500 | } |
4e57c75e |
1501 | } |
1502 | } |
1503 | } |
4e57c75e |
1504 | //collect EF interferences |
78c66ef1 |
1505 | for (i = 0; i < aNbLines[4]; ++i) { |
1506 | const BOPDS_InterfEF& aInt = aEFs(i); |
1507 | if (aInt.HasIndexNew()) { |
1508 | aInt.Indices(nS1, nS2); |
1509 | if(aMI.Contains(nS1) && aMI.Contains(nS2)) { |
1510 | nVNew = aInt.IndexNew(); |
4e57c75e |
1511 | aMVStick.Add(nVNew); |
1512 | aMVEF.Add(nVNew); |
1513 | } |
1514 | } |
1515 | } |
1516 | } |
1517 | |
1518 | //======================================================================= |
78c66ef1 |
1519 | // function: GetFullShapeMap |
4e57c75e |
1520 | // purpose: |
1521 | //======================================================================= |
78c66ef1 |
1522 | void BOPAlgo_PaveFiller::GetFullShapeMap(const Standard_Integer nF, |
1523 | BOPCol_MapOfInteger& aMI) |
4e57c75e |
1524 | { |
78c66ef1 |
1525 | BOPCol_ListIteratorOfListOfInteger aIt; |
1526 | Standard_Integer nS; |
1527 | // |
1528 | const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF); |
1529 | const BOPCol_ListOfInteger& aLI = aSI.SubShapes(); |
1530 | // |
4e57c75e |
1531 | aMI.Add(nF); |
78c66ef1 |
1532 | aIt.Initialize(aLI); |
1533 | for (; aIt.More(); aIt.Next()) { |
1534 | nS = aIt.Value(); |
1535 | aMI.Add(nS); |
4e57c75e |
1536 | } |
1537 | } |
1538 | |
1539 | //======================================================================= |
1540 | // function: RemoveUsedVertices |
1541 | // purpose: |
1542 | //======================================================================= |
1543 | void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, |
1544 | BOPCol_MapOfInteger& aMV) |
1545 | { |
1546 | if (!aMV.Extent()) { |
1547 | return; |
1548 | } |
1549 | Standard_Integer nV; |
1550 | BOPDS_Pave aPave; |
1551 | BOPDS_ListIteratorOfListOfPave aItLP; |
1552 | // |
1553 | Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); |
1554 | const BOPDS_ListOfPave& aLP = aPB->ExtPaves(); |
1555 | aItLP.Initialize(aLP); |
1556 | for (;aItLP.More();aItLP.Next()) { |
1557 | aPave = aItLP.Value(); |
1558 | nV = aPave.Index(); |
1559 | aMV.Remove(nV); |
1560 | } |
1561 | } |
1562 | |
1563 | //======================================================================= |
1564 | //function : PutPaveOnCurve |
1565 | //purpose : |
1566 | //======================================================================= |
1567 | void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV, |
1568 | const Standard_Real aTolR3D, |
78c66ef1 |
1569 | BOPDS_Curve& aNC, |
1570 | const BOPCol_MapOfInteger& aMI, |
1571 | BOPCol_DataMapOfIntegerReal& aMVTol, |
1572 | const Standard_Integer iCheckExtend) |
4e57c75e |
1573 | { |
1574 | Standard_Boolean bIsVertexOnLine; |
b4109929 |
1575 | Standard_Real aT, aTol, aTolNew; |
4e57c75e |
1576 | BOPDS_Pave aPave; |
1577 | // |
1578 | const TopoDS_Vertex aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
78c66ef1 |
1579 | Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); |
4e57c75e |
1580 | const IntTools_Curve& aIC = aNC.Curve(); |
1581 | // |
1582 | bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT); |
78c66ef1 |
1583 | if (!bIsVertexOnLine && iCheckExtend) { |
1584 | aTol = BRep_Tool::Tolerance(aV); |
1585 | // |
1586 | ExtendedTolerance(nV, aMI, aTol, iCheckExtend); |
1587 | bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTol, aIC, aTolR3D, aT); |
1588 | } |
1589 | // |
4e57c75e |
1590 | if (bIsVertexOnLine) { |
1591 | aPave.SetIndex(nV); |
1592 | aPave.SetParameter(aT); |
1593 | // |
1594 | aPB->AppendExtPave(aPave); |
1595 | // |
b4109929 |
1596 | aTol = BRep_Tool::Tolerance(aV); |
1597 | // |
4e57c75e |
1598 | BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV); |
b4109929 |
1599 | // |
1600 | if (!aMVTol.IsBound(nV)) { |
1601 | aTolNew = BRep_Tool::Tolerance(aV); |
1602 | if (aTolNew > aTol) { |
1603 | aMVTol.Bind(nV, aTol); |
1604 | } |
1605 | } |
4e57c75e |
1606 | // |
1607 | BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV); |
1608 | Bnd_Box& aBoxDS=aSIDS.ChangeBox(); |
1609 | BRepBndLib::Add(aV, aBoxDS); |
1610 | } |
1611 | } |
1612 | |
1613 | //======================================================================= |
1614 | //function : ProcessOldPaveBlocks |
1615 | //purpose : |
1616 | //======================================================================= |
1617 | void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks |
1618 | (const Standard_Integer theInt, |
1619 | const BOPDS_MapOfPaveBlock& aMPBOnIn, |
1620 | BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, |
1621 | BOPCol_DataMapOfShapeInteger& aMVI, |
1622 | const BOPCol_MapOfInteger& aMVB, |
1623 | BOPDS_MapOfPaveBlock& aMPB) |
1624 | { |
1625 | Standard_Integer nV, nE, iFlag; |
1626 | Standard_Real aT; |
1627 | BOPCol_MapIteratorOfMapOfInteger aItB; |
1628 | BOPDS_MapIteratorOfMapOfPaveBlock aItPB; |
1629 | // |
1630 | BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); |
1631 | BOPDS_InterfFF& aFF = aFFs(theInt); |
1632 | BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); |
1633 | // |
1634 | aItB.Initialize(aMVB); |
1635 | for (; aItB.More(); aItB.Next()) { |
1636 | nV = aItB.Value(); |
1637 | const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); |
1638 | const Bnd_Box& aBoxV=aSIV.Box(); |
1639 | const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape(); |
1640 | if (!aMVI.IsBound(aV)) { |
1641 | continue; |
1642 | } |
1643 | // |
1644 | aItPB.Initialize(aMPBOnIn); |
1645 | for (; aItPB.More(); aItPB.Next()) { |
1646 | const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); |
1647 | if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) { |
1648 | continue; |
1649 | } |
1650 | // |
1651 | if (aMPB.Contains(aPB)) { |
1652 | continue; |
1653 | } |
1654 | nE=aPB->Edge(); |
1655 | const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); |
1656 | const Bnd_Box& aBoxE=aSIE.Box(); |
1657 | // |
1658 | if (!aBoxV.IsOut(aBoxE)) { |
1659 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape(); |
1660 | // |
1661 | iFlag=myContext->ComputeVE (aV, aE, aT); |
1662 | if (!iFlag) { |
1663 | aMPB.Add(aPB); |
1664 | // |
1665 | PreparePostTreatFF(theInt, aPB, aMSCPB, aMVI, aVC); |
1666 | } |
1667 | } |
1668 | } |
1669 | } |
1670 | } |
1671 | |
1672 | //======================================================================= |
1673 | //function : UpdateExistingPaveBlocks |
1674 | //purpose : |
1675 | //======================================================================= |
1676 | void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks |
1677 | (const Handle(BOPDS_PaveBlock)& aPBf, |
1678 | BOPDS_ListOfPaveBlock& aLPB, |
1679 | const Standard_Integer nF1, |
1680 | const Standard_Integer nF2) |
1681 | { |
1682 | Standard_Integer nE; |
1683 | Standard_Boolean bCB; |
1684 | Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n; |
1685 | Handle(BOPDS_CommonBlock) aCB; |
1686 | BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2; |
1687 | BOPDS_IndexedMapOfPaveBlock aMPB; |
1688 | // |
1689 | //remove micro edges from aLPB |
1690 | aIt.Initialize(aLPB); |
1691 | for (; aIt.More();) { |
1692 | aPB = aIt.Value(); |
1693 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); |
1694 | if (BOPTools_AlgoTools::IsMicroEdge(aE, myContext)) { |
1695 | aLPB.Remove(aIt); |
1696 | continue; |
1697 | } |
1698 | aIt.Next(); |
1699 | } |
1700 | // |
1701 | if (!aLPB.Extent()) { |
1702 | return; |
1703 | } |
1704 | //update face info |
1705 | myDS->UpdateFaceInfoOn(nF1); |
1706 | // |
1707 | myDS->UpdateFaceInfoOn(nF2); |
1708 | // |
1709 | BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1); |
1710 | BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2); |
1711 | // |
1712 | BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.ChangePaveBlocksOn(); |
1713 | BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.ChangePaveBlocksIn(); |
1714 | BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.ChangePaveBlocksOn(); |
1715 | BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.ChangePaveBlocksIn(); |
1716 | // |
1717 | // remove old pave blocks |
5a77460e |
1718 | const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPBf); |
4e57c75e |
1719 | bCB = !aCB1.IsNull(); |
1720 | BOPDS_ListOfPaveBlock aLPB1; |
1721 | // |
1722 | if (bCB) { |
1723 | aLPB1.Assign(aCB1->PaveBlocks()); |
1724 | } else { |
1725 | aLPB1.Append(aPBf); |
1726 | } |
1727 | aIt1.Initialize(aLPB1); |
1728 | for (; aIt1.More(); aIt1.Next()) { |
1729 | aPB1 = aIt1.Value(); |
1730 | nE = aPB1->OriginalEdge(); |
1731 | // |
1732 | BOPDS_ListOfPaveBlock& aLPB2 = myDS->ChangePaveBlocks(nE); |
1733 | aIt2.Initialize(aLPB2); |
1734 | for (; aIt2.More(); aIt2.Next()) { |
1735 | aPB2 = aIt2.Value(); |
1736 | if (aPB1 == aPB2) { |
1737 | aLPB2.Remove(aIt2); |
1738 | break; |
1739 | } |
1740 | } |
1741 | } |
1742 | // |
1743 | if (bCB) { |
1744 | //create new pave blocks |
1745 | const BOPCol_ListOfInteger& aFaces = aCB1->Faces(); |
1746 | aIt.Initialize(aLPB); |
1747 | for (; aIt.More(); aIt.Next()) { |
1748 | Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue(); |
1749 | // |
1750 | aCB = new BOPDS_CommonBlock; |
1751 | aIt1.Initialize(aLPB1); |
1752 | for (; aIt1.More(); aIt1.Next()) { |
1753 | aPB2 = aIt1.Value(); |
1754 | nE = aPB2->OriginalEdge(); |
1755 | // |
1756 | aPB2n = new BOPDS_PaveBlock; |
1757 | aPB2n->SetPave1(aPB->Pave1()); |
1758 | aPB2n->SetPave2(aPB->Pave2()); |
1759 | aPB2n->SetEdge(aPB->Edge()); |
1760 | aPB2n->SetOriginalEdge(nE); |
1761 | aCB->AddPaveBlock(aPB2n); |
5a77460e |
1762 | myDS->SetCommonBlock(aPB2n, aCB); |
4e57c75e |
1763 | myDS->ChangePaveBlocks(nE).Append(aPB2n); |
1764 | } |
1765 | aCB->AddFaces(aFaces); |
1766 | myDS->SortPaveBlocks(aCB); |
1767 | // |
1768 | aPB=aCB->PaveBlocks().First(); |
1769 | } |
1770 | } |
1771 | // |
1772 | aIt.Initialize(aLPB); |
1773 | for (; aIt.More(); aIt.Next()) { |
1774 | Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue(); |
1775 | nE = aPB->OriginalEdge(); |
1776 | // |
1777 | Standard_Integer nF = (aMPBOn1.Contains(aPBf) || |
1778 | aMPBIn1.Contains(aPBf)) ? nF2 : nF1; |
1779 | const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF); |
1780 | IntTools_Range aShrR(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()); |
1781 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); |
1782 | // |
1783 | Standard_Boolean bCom = BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext); |
1784 | if (bCom) { |
1785 | if (bCB) { |
5a77460e |
1786 | aCB = myDS->CommonBlock(aPB); |
4e57c75e |
1787 | aCB->AddFace(nF); |
1788 | } else { |
1789 | aCB = new BOPDS_CommonBlock; |
1790 | aCB->AddPaveBlock(aPB); |
1791 | aCB->AddFace(nF1); |
1792 | aCB->AddFace(nF2); |
1793 | // |
5a77460e |
1794 | myDS->SetCommonBlock(aPB, aCB); |
4e57c75e |
1795 | } |
1796 | aMPB.Add(aPB); |
1797 | } |
1798 | if (!bCB) { |
1799 | myDS->ChangePaveBlocks(nE).Append(aPB); |
1800 | } |
1801 | } |
1802 | // |
1803 | Standard_Integer i, aNbPB; |
1804 | Standard_Boolean bIn1, bIn2; |
1805 | // |
1806 | bIn1 = aMPBOn1.Contains(aPBf) || aMPBIn1.Contains(aPBf); |
1807 | bIn2 = aMPBOn2.Contains(aPBf) || aMPBIn2.Contains(aPBf); |
1808 | // |
1809 | aNbPB=aMPB.Extent(); |
1810 | for (i=1; i<=aNbPB; ++i) { |
1811 | aPB = aMPB(i); |
1812 | if (!bIn1) { |
1813 | aMPBIn1.Add(aPB); |
1814 | } |
1815 | // |
1816 | if (!bIn2) { |
1817 | aMPBIn2.Add(aPB); |
1818 | } |
1819 | } |
1820 | } |
1821 | |
1822 | //======================================================================= |
1823 | // function: PutClosingPaveOnCurve |
1824 | // purpose: |
1825 | //======================================================================= |
1826 | void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC) |
1827 | { |
1828 | Standard_Boolean bIsClosed, bHasBounds, bAdded; |
1829 | Standard_Integer nVC, j; |
1830 | Standard_Real aT[2], aTC, dT, aTx; |
1831 | gp_Pnt aP[2] ; |
1832 | BOPDS_Pave aPVx; |
1833 | BOPDS_ListIteratorOfListOfPave aItLP; |
1834 | // |
1835 | const IntTools_Curve& aIC=aNC.Curve(); |
1836 | const Handle(Geom_Curve)& aC3D=aIC.Curve(); |
1837 | if(aC3D.IsNull()) { |
1838 | return; |
1839 | } |
1840 | // |
1841 | bIsClosed=IntTools_Tools::IsClosed(aC3D); |
1842 | if (!bIsClosed) { |
1843 | return; |
1844 | } |
1845 | // |
1846 | bHasBounds=aIC.HasBounds (); |
1847 | if (!bHasBounds){ |
1848 | return; |
1849 | } |
1850 | // |
1851 | bAdded=Standard_False; |
1852 | dT=Precision::PConfusion(); |
1853 | aIC.Bounds (aT[0], aT[1], aP[0], aP[1]); |
1854 | // |
1855 | Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); |
1856 | BOPDS_ListOfPave& aLP=aPB->ChangeExtPaves(); |
1857 | // |
1858 | aItLP.Initialize(aLP); |
1859 | for (; aItLP.More() && !bAdded; aItLP.Next()) { |
1860 | const BOPDS_Pave& aPC=aItLP.Value(); |
1861 | nVC=aPC.Index(); |
1862 | aTC=aPC.Parameter(); |
1863 | // |
1864 | for (j=0; j<2; ++j) { |
1865 | if (fabs(aTC-aT[j]) < dT) { |
1866 | aTx=(!j) ? aT[1] : aT[0]; |
1867 | aPVx.SetIndex(nVC); |
1868 | aPVx.SetParameter(aTx); |
1869 | aLP.Append(aPVx); |
1870 | // |
1871 | bAdded=Standard_True; |
1872 | break; |
1873 | } |
1874 | } |
1875 | } |
1876 | } |
1877 | |
1878 | //======================================================================= |
1879 | //function : PreparePostTreatFF |
1880 | //purpose : |
1881 | //======================================================================= |
1882 | void BOPAlgo_PaveFiller::PreparePostTreatFF |
1883 | (const Standard_Integer aInt, |
1884 | const Handle(BOPDS_PaveBlock)& aPB, |
1885 | BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, |
1886 | BOPCol_DataMapOfShapeInteger& aMVI, |
1887 | BOPDS_VectorOfCurve& aVC) |
1888 | { |
1889 | Standard_Integer nV1, nV2; |
1890 | // |
1891 | Standard_Integer iC=aVC.Append()-1; |
1892 | BOPDS_ListOfPaveBlock& aLPBC = aVC(iC).ChangePaveBlocks(); |
1893 | aLPBC.Append(aPB); |
1894 | // |
1895 | aPB->Indices(nV1, nV2); |
1896 | const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); |
1897 | const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); |
1898 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); |
1899 | // Keep info for post treatment |
1900 | BOPDS_CoupleOfPaveBlocks aCPB; |
1901 | aCPB.SetIndexInterf(aInt); |
1902 | aCPB.SetIndex(iC); |
1903 | aCPB.SetPaveBlock1(aPB); |
1904 | // |
1905 | aMSCPB.Add(aE, aCPB); |
1906 | aMVI.Bind(aV1, nV1); |
1907 | aMVI.Bind(aV2, nV2); |
1908 | } |
1909 | |
b4109929 |
1910 | //======================================================================= |
1911 | //function : CheckPlanes |
1912 | //purpose : |
1913 | //======================================================================= |
af4e6dab |
1914 | Standard_Boolean |
1915 | BOPAlgo_PaveFiller::CheckPlanes(const Standard_Integer nF1, |
78c66ef1 |
1916 | const Standard_Integer nF2)const |
b4109929 |
1917 | { |
1918 | Standard_Boolean bToIntersect; |
af4e6dab |
1919 | Standard_Integer i, nV2, iCnt; |
b4109929 |
1920 | BOPCol_MapIteratorOfMapOfInteger aIt; |
1921 | // |
af4e6dab |
1922 | bToIntersect=Standard_False; |
b4109929 |
1923 | // |
af4e6dab |
1924 | const BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1); |
1925 | const BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); |
b4109929 |
1926 | // |
af4e6dab |
1927 | const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn(); |
1928 | const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn(); |
b4109929 |
1929 | // |
af4e6dab |
1930 | iCnt=0; |
1931 | for (i=0; (i<2 && !bToIntersect); ++i) { |
1932 | const BOPCol_MapOfInteger& aMV2=(!i) ? aFI2.VerticesIn() |
1933 | : aFI2.VerticesOn(); |
1934 | // |
1935 | aIt.Initialize(aMV2); |
b4109929 |
1936 | for (; aIt.More(); aIt.Next()) { |
af4e6dab |
1937 | nV2=aIt.Value(); |
1938 | if (aMVIn1.Contains(nV2) || aMVOn1.Contains(nV2)) { |
78c66ef1 |
1939 | ++iCnt; |
1940 | if (iCnt>1) { |
1941 | bToIntersect=!bToIntersect; |
1942 | break; |
1943 | } |
b4109929 |
1944 | } |
1945 | } |
1946 | } |
b4109929 |
1947 | // |
1948 | return bToIntersect; |
1949 | } |
4e57c75e |
1950 | //======================================================================= |
78c66ef1 |
1951 | //function : UpdatePaveBlocks |
1952 | //purpose : |
1953 | //======================================================================= |
1954 | void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger& aDMI) |
1955 | { |
1956 | if (aDMI.IsEmpty()) { |
1957 | return; |
1958 | } |
1959 | // |
1960 | Standard_Integer nSp, aNbPBP, nV[2], i, j; |
1961 | Standard_Real aT[2]; |
1962 | Standard_Boolean bCB, bRebuild; |
1963 | BOPDS_ListIteratorOfListOfPaveBlock aItPB; |
1964 | BOPDS_MapOfPaveBlock aMPB; |
1965 | // |
1966 | BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool(); |
1967 | aNbPBP = aPBP.Extent(); |
1968 | for (i=0; i<aNbPBP; ++i) { |
1969 | BOPDS_ListOfPaveBlock& aLPB=aPBP(i); |
1970 | // |
1971 | aItPB.Initialize(aLPB); |
1972 | for (; aItPB.More(); aItPB.Next()) { |
1973 | Handle(BOPDS_PaveBlock) aPB=aItPB.Value(); |
1974 | const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB); |
1975 | bCB = !aCB.IsNull(); |
1976 | if (bCB) { |
1977 | aPB=aCB->PaveBlock1(); |
1978 | } |
1979 | // |
1980 | if (aMPB.Add(aPB)) { |
1981 | bRebuild = Standard_False; |
1982 | aPB->Indices(nV[0], nV[1]); |
1983 | aPB->Range(aT[0], aT[1]); |
1984 | // |
1985 | for (j = 0; j < 2; ++j) { |
1986 | if (aDMI.IsBound(nV[j])) { |
1987 | BOPDS_Pave aPave; |
1988 | // |
1989 | nV[j] = aDMI.Find(nV[j]); |
1990 | aPave.SetIndex(nV[j]); |
1991 | aPave.SetParameter(aT[j]); |
1992 | // |
1993 | bRebuild = Standard_True; |
1994 | if (!j) { |
1995 | aPB->SetPave1(aPave); |
1996 | } else { |
1997 | aPB->SetPave2(aPave); |
1998 | } |
1999 | } |
2000 | } |
2001 | // |
2002 | if (bRebuild) { |
2003 | nSp = SplitEdge(aPB->Edge(), nV[0], aT[0], nV[1], aT[1]); |
2004 | if (bCB) { |
2005 | aCB->SetEdge(nSp); |
2006 | } |
2007 | else { |
2008 | aPB->SetEdge(nSp); |
2009 | } |
2010 | }// if (bRebuild) { |
2011 | }// if (aMPB.Add(aPB)) { |
2012 | }// for (; aItPB.More(); aItPB.Next()) { |
2013 | }// for (i=0; i<aNbPBP; ++i) { |
2014 | aMPB.Clear(); |
2015 | } |
2016 | //======================================================================= |
4e57c75e |
2017 | //function : ToleranceFF |
2018 | //purpose : Computes the TolFF according to the tolerance value and |
2019 | // types of the faces. |
2020 | //======================================================================= |
b4109929 |
2021 | void ToleranceFF(const BRepAdaptor_Surface& aBAS1, |
2022 | const BRepAdaptor_Surface& aBAS2, |
4e57c75e |
2023 | Standard_Real& aTolFF) |
2024 | { |
2025 | Standard_Real aTol1, aTol2; |
2026 | Standard_Boolean isAna1, isAna2; |
2027 | // |
b4109929 |
2028 | aTol1 = aBAS1.Tolerance(); |
2029 | aTol2 = aBAS2.Tolerance(); |
4e57c75e |
2030 | aTolFF = Max(aTol1, aTol2); |
2031 | // |
b4109929 |
2032 | isAna1 = (aBAS1.GetType() == GeomAbs_Plane || |
2033 | aBAS1.GetType() == GeomAbs_Cylinder || |
2034 | aBAS1.GetType() == GeomAbs_Cone || |
2035 | aBAS1.GetType() == GeomAbs_Sphere || |
2036 | aBAS1.GetType() == GeomAbs_Torus); |
4e57c75e |
2037 | // |
b4109929 |
2038 | isAna2 = (aBAS2.GetType() == GeomAbs_Plane || |
2039 | aBAS2.GetType() == GeomAbs_Cylinder || |
2040 | aBAS2.GetType() == GeomAbs_Cone || |
2041 | aBAS2.GetType() == GeomAbs_Sphere || |
2042 | aBAS2.GetType() == GeomAbs_Torus); |
4e57c75e |
2043 | // |
b4109929 |
2044 | if (!isAna1 || !isAna2) { |
2045 | aTolFF = Max(aTolFF, 5.e-6); |
2046 | } |
4e57c75e |
2047 | } |