4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
4e57c75e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
4e57c75e |
14 | |
4e57c75e |
15 | |
4e57c75e |
16 | #include <Bnd_Box.hxx> |
b1d15f53 |
17 | #include <BOPCol_DataMapOfIntegerMapOfInteger.hxx> |
42cf5bc1 |
18 | #include <BOPCol_DataMapOfShapeInteger.hxx> |
19 | #include <BOPCol_ListOfInteger.hxx> |
20 | #include <BOPCol_MapOfInteger.hxx> |
21 | #include <BOPDS_CommonBlock.hxx> |
42cf5bc1 |
22 | #include <BOPDS_DS.hxx> |
23 | #include <BOPDS_FaceInfo.hxx> |
24 | #include <BOPDS_IndexRange.hxx> |
decdfc94 |
25 | #include <BOPDS_MapOfPave.hxx> |
26 | #include <BOPDS_MapOfPaveBlock.hxx> |
25dfc507 |
27 | #include <BOPDS_Pair.hxx> |
42cf5bc1 |
28 | #include <BOPDS_PaveBlock.hxx> |
29 | #include <BOPDS_ShapeInfo.hxx> |
7a76337e |
30 | #include <BOPDS_VectorOfPave.hxx> |
4e57c75e |
31 | #include <BOPTools_AlgoTools.hxx> |
42cf5bc1 |
32 | #include <BRep_Builder.hxx> |
33 | #include <BRep_TEdge.hxx> |
34 | #include <BRep_TFace.hxx> |
35 | #include <BRep_Tool.hxx> |
36 | #include <BRep_TVertex.hxx> |
37 | #include <BRepBndLib.hxx> |
38 | #include <Geom_Curve.hxx> |
4e57c75e |
39 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
42cf5bc1 |
40 | #include <gp_Pnt.hxx> |
41 | #include <IntTools_Tools.hxx> |
42 | #include <NCollection_BaseAllocator.hxx> |
42cf5bc1 |
43 | #include <Precision.hxx> |
44 | #include <Standard_Assert.hxx> |
45 | #include <TopoDS_Edge.hxx> |
46 | #include <TopoDS_Face.hxx> |
47 | #include <TopoDS_Iterator.hxx> |
48 | #include <TopoDS_Shape.hxx> |
49 | #include <TopoDS_Vertex.hxx> |
3510db62 |
50 | #include <BOPCol_MapOfShape.hxx> |
51 | #include <BOPCol_DataMapOfIntegerListOfInteger.hxx> |
4e57c75e |
52 | |
7a76337e |
53 | #include <algorithm> |
42cf5bc1 |
54 | // |
4e57c75e |
55 | |
56 | static |
57 | void TotalShapes(const TopoDS_Shape& aS, |
3510db62 |
58 | Standard_Integer& aNbS, |
59 | BOPCol_MapOfShape& aMS); |
4e57c75e |
60 | |
61 | static |
62 | Standard_Real ComputeParameter(const TopoDS_Vertex& aV, |
63 | const TopoDS_Edge& aE); |
4e57c75e |
64 | |
65 | //======================================================================= |
66 | //function : |
67 | //purpose : |
68 | //======================================================================= |
72e88cf7 |
69 | BOPDS_DS::BOPDS_DS() |
4e57c75e |
70 | : |
71 | myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), |
72 | myArguments(myAllocator), |
402bfe81 |
73 | myRanges(0,myAllocator), |
74 | myLines(0, myAllocator), |
4e57c75e |
75 | myMapShapeIndex(100, myAllocator), |
402bfe81 |
76 | myPaveBlocksPool(0,myAllocator), |
5a77460e |
77 | myMapPBCB(100, myAllocator), |
402bfe81 |
78 | myFaceInfoPool(0, myAllocator), |
eafb234b |
79 | myShapesSD(100, myAllocator), |
3510db62 |
80 | myMapVE(100, myAllocator), |
4e57c75e |
81 | myInterfTB(100, myAllocator), |
402bfe81 |
82 | myInterfVV(0, myAllocator), |
83 | myInterfVE(0, myAllocator), |
84 | myInterfVF(0, myAllocator), |
85 | myInterfEE(0, myAllocator), |
86 | myInterfEF(0, myAllocator), |
87 | myInterfFF(0, myAllocator), |
88 | myInterfVZ(0, myAllocator), |
89 | myInterfEZ(0, myAllocator), |
90 | myInterfFZ(0, myAllocator), |
0d0481c7 |
91 | myInterfZZ(0, myAllocator) |
4e57c75e |
92 | { |
93 | myNbShapes=0; |
94 | myNbSourceShapes=0; |
95 | } |
96 | //======================================================================= |
97 | //function : |
98 | //purpose : |
99 | //======================================================================= |
72e88cf7 |
100 | BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator) |
4e57c75e |
101 | : |
102 | myAllocator(theAllocator), |
103 | myArguments(myAllocator), |
402bfe81 |
104 | myRanges(0, myAllocator), |
105 | myLines(0, myAllocator), |
4e57c75e |
106 | myMapShapeIndex(100, myAllocator), |
402bfe81 |
107 | myPaveBlocksPool(0, myAllocator), |
5a77460e |
108 | myMapPBCB(100, myAllocator), |
402bfe81 |
109 | myFaceInfoPool(0, myAllocator), |
eafb234b |
110 | myShapesSD(100, myAllocator), |
3510db62 |
111 | myMapVE(100, myAllocator), |
4e57c75e |
112 | myInterfTB(100, myAllocator), |
402bfe81 |
113 | myInterfVV(0, myAllocator), |
114 | myInterfVE(0, myAllocator), |
115 | myInterfVF(0, myAllocator), |
116 | myInterfEE(0, myAllocator), |
117 | myInterfEF(0, myAllocator), |
118 | myInterfFF(0, myAllocator), |
119 | myInterfVZ(0, myAllocator), |
120 | myInterfEZ(0, myAllocator), |
121 | myInterfFZ(0, myAllocator), |
0d0481c7 |
122 | myInterfZZ(0, myAllocator) |
4e57c75e |
123 | { |
124 | myNbShapes=0; |
125 | myNbSourceShapes=0; |
126 | } |
127 | //======================================================================= |
128 | //function : ~ |
129 | //purpose : |
130 | //======================================================================= |
72e88cf7 |
131 | BOPDS_DS::~BOPDS_DS() |
4e57c75e |
132 | { |
133 | Clear(); |
134 | } |
135 | //======================================================================= |
136 | //function : Clear |
137 | //purpose : |
138 | //======================================================================= |
72e88cf7 |
139 | void BOPDS_DS::Clear() |
4e57c75e |
140 | { |
141 | myNbShapes=0; |
142 | myNbSourceShapes=0; |
143 | // |
144 | myArguments.Clear(); |
145 | myRanges.Clear(); |
146 | myLines.Clear(); |
147 | myMapShapeIndex.Clear(); |
148 | myPaveBlocksPool.Clear(); |
149 | myFaceInfoPool.Clear(); |
150 | myShapesSD.Clear(); |
3510db62 |
151 | myMapVE.Clear(); |
5a77460e |
152 | myMapPBCB.Clear(); |
4e57c75e |
153 | myInterfTB.Clear(); |
154 | myInterfVV.Clear(); |
155 | myInterfVE.Clear(); |
156 | myInterfVF.Clear(); |
157 | myInterfEE.Clear(); |
158 | myInterfEF.Clear(); |
159 | myInterfFF.Clear(); |
ceaa5e27 |
160 | myInterfVZ.Clear(); |
161 | myInterfEZ.Clear(); |
162 | myInterfFZ.Clear(); |
163 | myInterfZZ.Clear(); |
4e57c75e |
164 | } |
165 | //======================================================================= |
166 | //function : SetArguments |
167 | //purpose : |
168 | //======================================================================= |
72e88cf7 |
169 | void BOPDS_DS::SetArguments(const BOPCol_ListOfShape& theLS) |
4e57c75e |
170 | { |
171 | myArguments=theLS; |
172 | } |
173 | //======================================================================= |
174 | //function : Arguments |
175 | //purpose : |
176 | //======================================================================= |
72e88cf7 |
177 | const BOPCol_ListOfShape& BOPDS_DS::Arguments()const |
4e57c75e |
178 | { |
179 | return myArguments; |
180 | } |
181 | //======================================================================= |
182 | //function : Allocator |
183 | //purpose : |
184 | //======================================================================= |
72e88cf7 |
185 | const Handle(NCollection_BaseAllocator)& BOPDS_DS::Allocator()const |
4e57c75e |
186 | { |
187 | return myAllocator; |
188 | } |
189 | |
190 | //======================================================================= |
191 | //function : NbShapes |
192 | //purpose : |
193 | //======================================================================= |
72e88cf7 |
194 | Standard_Integer BOPDS_DS::NbShapes()const |
4e57c75e |
195 | { |
196 | return myLines.Size(); |
197 | } |
198 | //======================================================================= |
199 | //function : NbSourceShapes |
200 | //purpose : |
201 | //======================================================================= |
72e88cf7 |
202 | Standard_Integer BOPDS_DS::NbSourceShapes()const |
4e57c75e |
203 | { |
204 | return myNbSourceShapes; |
205 | } |
206 | //======================================================================= |
207 | //function : NbRanges |
208 | //purpose : |
209 | //======================================================================= |
72e88cf7 |
210 | Standard_Integer BOPDS_DS::NbRanges()const |
4e57c75e |
211 | { |
212 | return myRanges.Size(); |
213 | } |
214 | //======================================================================= |
215 | //function : Range |
216 | //purpose : |
217 | //======================================================================= |
72e88cf7 |
218 | const BOPDS_IndexRange& BOPDS_DS::Range(const Standard_Integer theI)const |
4e57c75e |
219 | { |
220 | return myRanges(theI); |
221 | } |
222 | //======================================================================= |
223 | //function : Rank |
224 | //purpose : |
225 | //======================================================================= |
72e88cf7 |
226 | Standard_Integer BOPDS_DS::Rank(const Standard_Integer theI)const |
4e57c75e |
227 | { |
228 | Standard_Integer i, aNb, iErr; |
229 | // |
230 | iErr=-1; |
231 | aNb=NbRanges(); |
232 | for(i=0; i<aNb; ++i) { |
233 | const BOPDS_IndexRange& aR=Range(i); |
234 | if (aR.Contains(theI)) { |
235 | return i; |
236 | } |
237 | } |
238 | return iErr; |
239 | } |
240 | //======================================================================= |
241 | //function : IsNewShape |
242 | //purpose : |
243 | //======================================================================= |
72e88cf7 |
244 | Standard_Boolean BOPDS_DS::IsNewShape(const Standard_Integer theI)const |
4e57c75e |
245 | { |
246 | return theI>=NbSourceShapes(); |
247 | } |
248 | //======================================================================= |
249 | //function : Append |
250 | //purpose : |
251 | //======================================================================= |
72e88cf7 |
252 | Standard_Integer BOPDS_DS::Append(const BOPDS_ShapeInfo& theSI) |
4e57c75e |
253 | { |
254 | Standard_Integer iX; |
255 | // |
402bfe81 |
256 | myLines.Append1()=theSI; |
257 | iX=myLines.Extent()-1; |
24542bc0 |
258 | myMapShapeIndex.Bind(theSI.Shape(), iX); |
402bfe81 |
259 | // |
4e57c75e |
260 | return iX; |
261 | } |
262 | //======================================================================= |
263 | //function : Append |
264 | //purpose : |
265 | //======================================================================= |
72e88cf7 |
266 | Standard_Integer BOPDS_DS::Append(const TopoDS_Shape& theS) |
4e57c75e |
267 | { |
268 | Standard_Integer iX; |
269 | // |
402bfe81 |
270 | myLines.Append1().SetShape(theS); |
271 | iX=myLines.Extent()-1; |
24542bc0 |
272 | myMapShapeIndex.Bind(theS, iX); |
4e57c75e |
273 | return iX; |
274 | } |
275 | //======================================================================= |
276 | //function : ShapeInfo |
277 | //purpose : |
278 | //======================================================================= |
362dec17 |
279 | const BOPDS_ShapeInfo& BOPDS_DS::ShapeInfo |
280 | (const Standard_Integer theI)const |
4e57c75e |
281 | { |
282 | return myLines(theI); |
283 | } |
284 | //======================================================================= |
285 | //function : ChangeShapeInfo |
286 | //purpose : |
287 | //======================================================================= |
72e88cf7 |
288 | BOPDS_ShapeInfo& BOPDS_DS::ChangeShapeInfo(const Standard_Integer theI) |
4e57c75e |
289 | { |
290 | BOPDS_ShapeInfo *pSI; |
291 | // |
292 | const BOPDS_ShapeInfo& aSI=ShapeInfo(theI); |
293 | pSI=(BOPDS_ShapeInfo *)&aSI; |
294 | return *pSI; |
295 | } |
296 | //======================================================================= |
297 | //function : Shape |
298 | //purpose : |
299 | //======================================================================= |
72e88cf7 |
300 | const TopoDS_Shape& BOPDS_DS::Shape(const Standard_Integer theI)const |
4e57c75e |
301 | { |
402bfe81 |
302 | |
4e57c75e |
303 | const TopoDS_Shape& aS=ShapeInfo(theI).Shape(); |
304 | return aS; |
305 | } |
306 | //======================================================================= |
307 | //function : Index |
308 | //purpose : |
309 | //======================================================================= |
72e88cf7 |
310 | Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const |
4e57c75e |
311 | { |
312 | Standard_Integer iRet; |
313 | // |
314 | iRet=-1; |
315 | if (myMapShapeIndex.IsBound(theS)) { |
316 | iRet=myMapShapeIndex.Find(theS); |
317 | } |
318 | return iRet; |
319 | } |
4e57c75e |
320 | //======================================================================= |
321 | //function : Init |
322 | //purpose : |
323 | //======================================================================= |
0d0481c7 |
324 | void BOPDS_DS::Init(const Standard_Real theFuzz) |
4e57c75e |
325 | { |
362dec17 |
326 | Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx; |
327 | Standard_Integer n1, n2, n3, nV, nW, nE, aNbF; |
0d0481c7 |
328 | Standard_Real aTol, aTolAdd; |
4e57c75e |
329 | TopAbs_ShapeEnum aTS; |
50ba108c |
330 | TopoDS_Iterator aItS; |
4e57c75e |
331 | BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3; |
332 | BOPCol_ListIteratorOfListOfShape aIt; |
333 | BOPDS_IndexRange aR; |
488e5b9d |
334 | Handle(NCollection_BaseAllocator) aAllocator; |
3510db62 |
335 | BOPCol_MapOfShape aMS; |
4e57c75e |
336 | // |
337 | // 1 Append Source Shapes |
338 | aNb=myArguments.Extent(); |
339 | if (!aNb) { |
340 | return; |
341 | } |
342 | // |
402bfe81 |
343 | myRanges.SetIncrement(aNb); |
4e57c75e |
344 | // |
4e57c75e |
345 | aNbS=0; |
346 | aIt.Initialize(myArguments); |
347 | for (; aIt.More(); aIt.Next()) { |
348 | const TopoDS_Shape& aSx=aIt.Value(); |
349 | // |
350 | aNbSx=0; |
3510db62 |
351 | TotalShapes(aSx, aNbSx, aMS); |
352 | // |
4e57c75e |
353 | aNbS=aNbS+aNbSx; |
354 | } |
3510db62 |
355 | aMS.Clear(); |
4e57c75e |
356 | // |
402bfe81 |
357 | myLines.SetIncrement(2*aNbS); |
4e57c75e |
358 | //-----------------------------------------------------scope_1 f |
488e5b9d |
359 | aAllocator= |
360 | NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
361 | // |
4e57c75e |
362 | // |
363 | i1=0; |
364 | i2=0; |
365 | aIt.Initialize(myArguments); |
366 | for (; aIt.More(); aIt.Next()) { |
367 | const TopoDS_Shape& aS=aIt.Value(); |
24542bc0 |
368 | if (myMapShapeIndex.IsBound(aS)) { |
72e88cf7 |
369 | continue; |
370 | } |
4e57c75e |
371 | aI=Append(aS); |
4e57c75e |
372 | // |
24542bc0 |
373 | InitShape(aI, aS); |
4e57c75e |
374 | // |
375 | i2=NbShapes()-1; |
376 | aR.SetIndices(i1, i2); |
377 | myRanges.Append(aR); |
378 | i1=i2+1; |
379 | } |
380 | // |
0d0481c7 |
381 | aTolAdd = Max(theFuzz, Precision::Confusion()) * 0.5; |
3510db62 |
382 | myNbSourceShapes = NbShapes(); |
4e57c75e |
383 | // |
384 | // 2 Bounding Boxes |
385 | // |
386 | // 2.1 Vertex |
387 | for (j=0; j<myNbSourceShapes; ++j) { |
388 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j); |
389 | // |
390 | const TopoDS_Shape& aS=aSI.Shape(); |
4e57c75e |
391 | // |
392 | aTS=aSI.ShapeType(); |
393 | // |
394 | if (aTS==TopAbs_VERTEX) { |
395 | Bnd_Box& aBox=aSI.ChangeBox(); |
396 | const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS); |
397 | const gp_Pnt& aP=BRep_Tool::Pnt(aV); |
0d0481c7 |
398 | aTol = BRep_Tool::Tolerance(aV); |
3510db62 |
399 | aBox.SetGap(aTol + aTolAdd); |
4e57c75e |
400 | aBox.Add(aP); |
401 | } |
402 | } |
403 | // 2.2 Edge |
404 | aNbE=0; |
405 | for (j=0; j<myNbSourceShapes; ++j) { |
406 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j); |
407 | // |
408 | aTS=aSI.ShapeType(); |
409 | if (aTS==TopAbs_EDGE) { |
410 | const TopoDS_Shape& aS=aSI.Shape(); |
411 | const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS); |
0d0481c7 |
412 | aTol = BRep_Tool::Tolerance(aE); |
4e57c75e |
413 | // |
414 | if (!BRep_Tool::Degenerated(aE)) { |
415 | Standard_Boolean bInf1, bInf2; |
416 | Standard_Integer aIx; |
417 | Standard_Real aT1, aT2; |
418 | gp_Pnt aPx; |
419 | Handle(Geom_Curve) aC3D; |
420 | TopoDS_Vertex aVx; |
421 | TopoDS_Edge aEx; |
422 | BRep_Builder aBB; |
423 | BOPDS_ShapeInfo aSIx; |
424 | // |
425 | BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes(); |
426 | // |
427 | aEx=aE; |
428 | aEx.Orientation(TopAbs_FORWARD); |
429 | // |
430 | aC3D=BRep_Tool::Curve (aEx, aT1, aT2); |
431 | bInf1=Precision::IsNegativeInfinite(aT1); |
432 | bInf2=Precision::IsPositiveInfinite(aT2); |
433 | // |
434 | if (bInf1) { |
435 | aC3D->D0(aT1, aPx); |
436 | aBB.MakeVertex(aVx, aPx, aTol); |
437 | aVx.Orientation(TopAbs_FORWARD); |
438 | // |
439 | aSIx.SetShape(aVx); |
440 | aSIx.SetShapeType(TopAbs_VERTEX); |
441 | aSIx.SetFlag(1); //infinite flag |
442 | // |
443 | aIx=Append(aSIx); |
444 | aLI.Append(aIx); |
445 | } |
446 | if (bInf2) { |
447 | aC3D->D0(aT2, aPx); |
448 | aBB.MakeVertex(aVx, aPx, aTol); |
449 | aVx.Orientation(TopAbs_REVERSED); |
450 | // |
451 | aSIx.SetShape(aVx); |
452 | aSIx.SetShapeType(TopAbs_VERTEX); |
453 | aSIx.SetFlag(1);//infinite flag |
454 | // |
455 | aIx=Append(aSIx); |
456 | aLI.Append(aIx); |
457 | } |
458 | } |
459 | else { |
460 | aSI.SetFlag(j); |
461 | } |
462 | // |
463 | Bnd_Box& aBox=aSI.ChangeBox(); |
464 | BRepBndLib::Add(aE, aBox); |
465 | // |
466 | const BOPCol_ListOfInteger& aLV=aSI.SubShapes(); |
467 | aIt1.Initialize(aLV); |
468 | for (; aIt1.More(); aIt1.Next()) { |
469 | nV=aIt1.Value(); |
470 | BOPDS_ShapeInfo& aSIV=ChangeShapeInfo(nV); |
471 | Bnd_Box& aBx=aSIV.ChangeBox(); |
472 | aBox.Add(aBx); |
473 | } |
3510db62 |
474 | aBox.SetGap(aBox.GetGap() + aTolAdd); |
4e57c75e |
475 | ++aNbE; |
476 | } |
477 | } |
478 | // 2.3 Face |
479 | BOPCol_MapOfInteger aMI(100, aAllocator); |
480 | BOPCol_MapIteratorOfMapOfInteger aItMI; |
481 | // |
482 | aNbF=0; |
483 | for (j=0; j<myNbSourceShapes; ++j) { |
484 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j); |
485 | // |
486 | aTS=aSI.ShapeType(); |
487 | if (aTS==TopAbs_FACE) { |
488 | const TopoDS_Shape& aS=aSI.Shape(); |
4e57c75e |
489 | // |
490 | Bnd_Box& aBox=aSI.ChangeBox(); |
491 | BRepBndLib::Add(aS, aBox); |
492 | // |
493 | BOPCol_ListOfInteger& aLW=aSI.ChangeSubShapes(); |
494 | aIt1.Initialize(aLW); |
495 | for (; aIt1.More(); aIt1.Next()) { |
496 | nW=aIt1.Value(); |
497 | BOPDS_ShapeInfo& aSIW=ChangeShapeInfo(nW); |
498 | // |
499 | const BOPCol_ListOfInteger& aLE=aSIW.SubShapes(); |
500 | aIt2.Initialize(aLE); |
501 | for (; aIt2.More(); aIt2.Next()) { |
502 | nE=aIt2.Value(); |
503 | BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); |
504 | Bnd_Box& aBx=aSIE.ChangeBox(); |
505 | aBox.Add(aBx); |
506 | aMI.Add(nE); |
507 | // |
508 | const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSIE.Shape()); |
509 | if (BRep_Tool::Degenerated(aE)) { |
510 | aSIE.SetFlag(j); |
511 | } |
512 | // |
513 | const BOPCol_ListOfInteger& aLV=aSIE.SubShapes(); |
514 | aIt3.Initialize(aLV); |
515 | for (; aIt3.More(); aIt3.Next()) { |
516 | nV=aIt3.Value(); |
517 | aMI.Add(nV); |
518 | } |
519 | } |
520 | }//for (; aIt1.More(); aIt1.Next()) { |
521 | // |
50ba108c |
522 | // pure internal vertices on the face |
523 | aItS.Initialize(aS); |
524 | for (; aItS.More(); aItS.Next()) { |
362dec17 |
525 | const TopoDS_Shape& aSx=aItS.Value(); |
526 | if (aSx.ShapeType()==TopAbs_VERTEX){ |
527 | nV=Index(aSx); |
528 | aMI.Add(nV); |
529 | } |
50ba108c |
530 | } |
531 | // |
4e57c75e |
532 | // |
533 | // For a Face: change wires for BRep sub-shapes |
534 | aLW.Clear(); |
535 | aItMI.Initialize(aMI); |
536 | for (; aItMI.More(); aItMI.Next()) { |
537 | nV=aItMI.Value(); |
538 | aLW.Append(nV); |
539 | } |
540 | aMI.Clear(); |
3510db62 |
541 | aBox.SetGap(aBox.GetGap() + aTolAdd); |
4e57c75e |
542 | ++aNbF; |
543 | }//if (aTS==TopAbs_FACE) { |
544 | }//for (j=0; j<myNbSourceShapes; ++j) { |
545 | // |
30ecd5f8 |
546 | // 2.4 Solids |
547 | for (j=0; j<myNbSourceShapes; ++j) { |
548 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j); |
549 | // |
550 | aTS=aSI.ShapeType(); |
ceaa5e27 |
551 | if (aTS!=TopAbs_SOLID) { |
552 | continue; |
553 | } |
554 | Bnd_Box& aBox=aSI.ChangeBox(); |
555 | BuildBndBoxSolid(j, aBox); |
556 | // |
557 | // |
558 | // update sub-shapes by BRep comprising ones |
559 | aMI.Clear(); |
560 | BOPCol_ListOfInteger& aLI1=aSI.ChangeSubShapes(); |
561 | // |
562 | aIt1.Initialize(aLI1); |
563 | for (; aIt1.More(); aIt1.Next()) { |
564 | n1=aIt1.Value(); |
565 | BOPDS_ShapeInfo& aSI1=ChangeShapeInfo(n1); |
566 | if (aSI1.ShapeType()!=TopAbs_SHELL) { |
362dec17 |
567 | continue; |
ceaa5e27 |
568 | } |
569 | // |
570 | const BOPCol_ListOfInteger& aLI2=aSI1.SubShapes(); |
571 | aIt2.Initialize(aLI2); |
572 | for (; aIt2.More(); aIt2.Next()) { |
362dec17 |
573 | n2=aIt2.Value(); |
574 | BOPDS_ShapeInfo& aSI2=ChangeShapeInfo(n2); |
575 | if (aSI2.ShapeType()!=TopAbs_FACE) { |
576 | continue; |
577 | } |
578 | // |
579 | aMI.Add(n2); |
580 | // |
581 | const BOPCol_ListOfInteger& aLI3=aSI2.SubShapes(); |
582 | aIt3.Initialize(aLI3); |
583 | for (; aIt3.More(); aIt3.Next()) { |
584 | n3=aIt3.Value(); |
585 | aMI.Add(n3); |
586 | } |
ceaa5e27 |
587 | } |
30ecd5f8 |
588 | } |
ceaa5e27 |
589 | // |
590 | aLI1.Clear(); |
591 | aItMI.Initialize(aMI); |
592 | for (; aItMI.More(); aItMI.Next()) { |
593 | n1=aItMI.Value(); |
594 | aLI1.Append(n1); |
595 | } |
596 | aMI.Clear(); |
30ecd5f8 |
597 | }//for (j=0; j<myNbSourceShapes; ++j) { |
598 | // |
4e57c75e |
599 | aMI.Clear(); |
3510db62 |
600 | //----------------------------------------------------- |
601 | // |
602 | for (nE=0; nE<myNbSourceShapes; ++nE) { |
603 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE); |
604 | if (aSI.ShapeType()!=TopAbs_EDGE) { |
605 | continue; |
606 | } |
607 | // |
608 | const BOPCol_ListOfInteger& aLV=aSI.SubShapes(); |
609 | aIt1.Initialize(aLV); |
610 | for (; aIt1.More(); aIt1.Next()) { |
611 | nV=aIt1.Value(); |
612 | if (myMapVE.IsBound(nV)) { |
613 | BOPCol_ListOfInteger& aLE=myMapVE.ChangeFind(nV); |
614 | aLE.Append(nE); |
615 | } |
616 | else { |
617 | BOPCol_ListOfInteger aLE(myAllocator); |
618 | // |
619 | aLE.Append(nE); |
620 | myMapVE.Bind(nV, aLE); |
621 | } |
622 | } |
623 | } |
624 | // |
625 | BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItDMILI; |
626 | aItDMILI.Initialize(myMapVE); |
627 | for(; aItDMILI.More(); aItDMILI.Next()) { |
628 | BOPCol_MapOfInteger aMFence; |
629 | BOPCol_ListOfInteger aLEx; |
630 | // |
631 | nV=aItDMILI.Key(); |
632 | BOPCol_ListOfInteger& aLE=aItDMILI.ChangeValue(); |
633 | aIt1.Initialize(aLE); |
634 | for (; aIt1.More(); aIt1.Next()) { |
635 | nE=aIt1.Value(); |
636 | if(aMFence.Add(nE)) { |
637 | aLEx.Append(nE); |
638 | } |
639 | } |
640 | // |
641 | aLE.Clear(); |
642 | aIt1.Initialize(aLEx); |
643 | for (; aIt1.More(); aIt1.Next()) { |
644 | nE=aIt1.Value(); |
645 | aLE.Append(nE); |
646 | } |
647 | } |
4e57c75e |
648 | //-----------------------------------------------------scope_1 t |
4e57c75e |
649 | // 3 myPaveBlocksPool |
4e57c75e |
650 | // 4. myFaceInfoPool |
402bfe81 |
651 | myPaveBlocksPool.SetIncrement(aNbE); |
4e57c75e |
652 | myFaceInfoPool.SetIncrement(aNbF); |
4e57c75e |
653 | } |
654 | //======================================================================= |
655 | //function : InitShape |
656 | //purpose : |
657 | //======================================================================= |
362dec17 |
658 | void BOPDS_DS::InitShape |
659 | (const Standard_Integer aI, |
24542bc0 |
660 | const TopoDS_Shape& aS) |
4e57c75e |
661 | { |
662 | Standard_Integer aIx; |
663 | TopoDS_Iterator aIt; |
664 | BOPCol_ListIteratorOfListOfInteger aIt1; |
665 | // |
666 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(aI); |
667 | aSI.SetShapeType(aS.ShapeType()); |
668 | BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes(); |
669 | // |
24542bc0 |
670 | BOPCol_MapOfInteger aM; |
4e57c75e |
671 | // |
672 | aIt1.Initialize(aLI); |
673 | for (; aIt1.More(); aIt1.Next()) { |
674 | aM.Add(aIt1.Value()); |
675 | } |
676 | // |
677 | aIt.Initialize(aS); |
678 | for (; aIt.More(); aIt.Next()) { |
679 | const TopoDS_Shape& aSx=aIt.Value(); |
24542bc0 |
680 | const Standard_Integer* pIx = myMapShapeIndex.Seek(aSx); |
681 | aIx = (pIx ? *pIx : Append(aSx)); |
4e57c75e |
682 | // |
24542bc0 |
683 | InitShape(aIx, aSx); |
4e57c75e |
684 | // |
685 | if (aM.Add(aIx)) { |
686 | aLI.Append(aIx); |
687 | } |
688 | } |
689 | } |
690 | |
691 | //======================================================================= |
692 | //function : HasInterf |
693 | //purpose : |
694 | //======================================================================= |
72e88cf7 |
695 | Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI) const |
4e57c75e |
696 | { |
697 | Standard_Integer n1, n2; |
698 | Standard_Boolean bRet; |
25dfc507 |
699 | BOPDS_MapIteratorOfMapOfPair aIt; |
4e57c75e |
700 | // |
701 | bRet = Standard_False; |
702 | // |
703 | aIt.Initialize(myInterfTB); |
704 | for (; aIt.More(); aIt.Next()) { |
25dfc507 |
705 | const BOPDS_Pair& aPK = aIt.Value(); |
706 | aPK.Indices(n1, n2); |
4e57c75e |
707 | if (n1 == theI || n2 == theI) { |
708 | bRet = Standard_True; |
709 | break; |
710 | } |
711 | } |
712 | // |
713 | return bRet; |
714 | } |
4e57c75e |
715 | //======================================================================= |
716 | //function : HasInterfShapeSubShapes |
717 | //purpose : |
718 | //======================================================================= |
ceaa5e27 |
719 | Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes |
720 | (const Standard_Integer theI1, |
721 | const Standard_Integer theI2, |
722 | const Standard_Boolean theFlag)const |
4e57c75e |
723 | { |
724 | Standard_Boolean bRet; |
725 | Standard_Integer n2; |
726 | BOPCol_ListIteratorOfListOfInteger aIt; |
727 | bRet = Standard_False; |
728 | // |
729 | const BOPDS_ShapeInfo& aSI=ShapeInfo(theI2); |
730 | const BOPCol_ListOfInteger& aLI=aSI.SubShapes(); |
731 | aIt.Initialize(aLI); |
732 | for (; aIt.More(); aIt.Next()) { |
733 | n2=aIt.Value(); |
734 | bRet=HasInterf(theI1, n2); |
ceaa5e27 |
735 | if (theFlag) { |
736 | if(bRet) { |
b1d15f53 |
737 | break; |
ceaa5e27 |
738 | } |
739 | } |
740 | else { |
741 | if(!bRet) { |
b1d15f53 |
742 | break; |
ceaa5e27 |
743 | } |
4e57c75e |
744 | } |
745 | } |
746 | return bRet; |
747 | } |
4e57c75e |
748 | //======================================================================= |
749 | //function : HasInterfSubShapes |
750 | //purpose : |
751 | //======================================================================= |
362dec17 |
752 | Standard_Boolean BOPDS_DS::HasInterfSubShapes |
753 | (const Standard_Integer theI1, |
754 | const Standard_Integer theI2)const |
4e57c75e |
755 | { |
756 | Standard_Boolean bRet; |
757 | Standard_Integer n1; |
758 | BOPCol_ListIteratorOfListOfInteger aIt; |
759 | bRet = Standard_False; |
760 | // |
761 | const BOPDS_ShapeInfo& aSI=ShapeInfo(theI1); |
762 | const BOPCol_ListOfInteger& aLI=aSI.SubShapes(); |
763 | aIt.Initialize(aLI); |
764 | for (; aIt.More(); aIt.Next()) { |
765 | n1=aIt.Value(); |
766 | bRet=HasInterfShapeSubShapes(n1, theI2); |
767 | if(bRet) { |
768 | break; |
769 | } |
770 | } |
771 | return bRet; |
772 | } |
773 | // |
774 | // PaveBlocks |
775 | //======================================================================= |
776 | //function : PaveBlocksPool |
777 | //purpose : |
778 | //======================================================================= |
72e88cf7 |
779 | const BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::PaveBlocksPool()const |
4e57c75e |
780 | { |
781 | return myPaveBlocksPool; |
782 | } |
783 | //======================================================================= |
784 | //function : ChangePaveBlocksPool |
785 | //purpose : |
786 | //======================================================================= |
72e88cf7 |
787 | BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::ChangePaveBlocksPool() |
4e57c75e |
788 | { |
789 | return myPaveBlocksPool; |
790 | } |
791 | //======================================================================= |
792 | //function : HasPaveBlocks |
793 | //purpose : |
794 | //======================================================================= |
72e88cf7 |
795 | Standard_Boolean BOPDS_DS::HasPaveBlocks(const Standard_Integer theI)const |
4e57c75e |
796 | { |
797 | return ShapeInfo(theI).HasReference(); |
798 | } |
799 | //======================================================================= |
800 | //function : PaveBlocks |
801 | //purpose : |
802 | //======================================================================= |
362dec17 |
803 | const BOPDS_ListOfPaveBlock& BOPDS_DS::PaveBlocks |
804 | (const Standard_Integer theI)const |
4e57c75e |
805 | { |
806 | static BOPDS_ListOfPaveBlock sLPB; |
807 | Standard_Integer aRef; |
808 | // |
809 | if (HasPaveBlocks(theI)) { |
810 | aRef=ShapeInfo(theI).Reference(); |
811 | const BOPDS_ListOfPaveBlock& aLPB=myPaveBlocksPool(aRef); |
812 | return aLPB; |
813 | } |
814 | return sLPB; |
815 | } |
3510db62 |
816 | |
4e57c75e |
817 | //======================================================================= |
818 | //function : ChangePaveBlocks |
819 | //purpose : |
820 | //======================================================================= |
362dec17 |
821 | BOPDS_ListOfPaveBlock& BOPDS_DS::ChangePaveBlocks |
822 | (const Standard_Integer theI) |
4e57c75e |
823 | { |
824 | Standard_Boolean bHasReference; |
825 | Standard_Integer aRef; |
4e57c75e |
826 | // |
827 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
828 | bHasReference=aSI.HasReference(); |
829 | if (!bHasReference) { |
830 | InitPaveBlocks(theI); |
831 | } |
832 | // |
833 | aRef=aSI.Reference(); |
323c04de |
834 | return myPaveBlocksPool(aRef); |
4e57c75e |
835 | } |
836 | //======================================================================= |
837 | //function : InitPaveBlocks |
838 | //purpose : |
839 | //======================================================================= |
72e88cf7 |
840 | void BOPDS_DS::InitPaveBlocks(const Standard_Integer theI) |
4e57c75e |
841 | { |
59427cbc |
842 | Standard_Integer nV=0, iRef, aNbV, nVSD; |
4e57c75e |
843 | Standard_Real aT; |
59427cbc |
844 | TopAbs_Orientation aOrE; |
4e57c75e |
845 | TopoDS_Vertex aV; |
846 | BOPCol_ListIteratorOfListOfInteger aIt; |
847 | BOPDS_Pave aPave; |
848 | Handle(BOPDS_PaveBlock) aPB; |
849 | // |
850 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
851 | const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSI.Shape()); |
59427cbc |
852 | aOrE=aE.Orientation(); |
4e57c75e |
853 | // |
854 | const BOPCol_ListOfInteger& aLV=aSI.SubShapes(); |
855 | aNbV=aLV.Extent(); |
856 | if (!aNbV) { |
857 | return; |
858 | } |
859 | // |
860 | aPB=new BOPDS_PaveBlock; |
861 | aPB->SetOriginalEdge(theI); |
862 | // |
59427cbc |
863 | if (aOrE!=TopAbs_INTERNAL) { |
864 | aIt.Initialize(aLV); |
865 | for (; aIt.More(); aIt.Next()) { |
866 | nV=aIt.Value(); |
867 | // |
868 | const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV); |
869 | aV=*(TopoDS_Vertex*)(&aSIV.Shape()); |
870 | if (aSIV.HasFlag()) { |
871 | aT=ComputeParameter(aV, aE); |
872 | } |
873 | else { |
874 | aT=BRep_Tool::Parameter(aV, aE); |
875 | } |
876 | // |
877 | if (HasShapeSD(nV, nVSD)) { |
878 | nV=nVSD; |
879 | } |
880 | aPave.SetIndex(nV); |
881 | aPave.SetParameter(aT); |
0d0481c7 |
882 | if (aSI.HasFlag()) |
883 | // for a degenerated edge append pave unconditionally |
884 | aPB->AppendExtPave1(aPave); |
885 | else |
886 | aPB->AppendExtPave(aPave); |
4e57c75e |
887 | } |
4e57c75e |
888 | // |
59427cbc |
889 | if (aNbV==1) { |
890 | aV.Reverse(); |
891 | aT=BRep_Tool::Parameter(aV, aE); |
892 | aPave.SetIndex(nV); |
893 | aPave.SetParameter(aT); |
894 | aPB->AppendExtPave1(aPave); |
4e57c75e |
895 | } |
4e57c75e |
896 | } |
897 | // |
59427cbc |
898 | else { |
899 | TopoDS_Iterator aItE; |
900 | // |
901 | aItE.Initialize(aE, Standard_False, Standard_True); |
902 | for (; aItE.More(); aItE.Next()) { |
903 | aV=*((TopoDS_Vertex*)&aItE.Value()); |
904 | nV=Index(aV); |
2a2e3ecd |
905 | // |
906 | const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV); |
907 | if (aSIV.HasFlag()) { |
908 | aT=ComputeParameter(aV, aE); |
909 | } |
910 | else { |
911 | aT=BRep_Tool::Parameter(aV, aE); |
912 | } |
913 | // |
914 | if (HasShapeSD(nV, nVSD)) { |
915 | nV=nVSD; |
916 | } |
59427cbc |
917 | aPave.SetIndex(nV); |
918 | aPave.SetParameter(aT); |
919 | aPB->AppendExtPave1(aPave); |
920 | } |
4e57c75e |
921 | } |
922 | // |
402bfe81 |
923 | BOPDS_ListOfPaveBlock &aLPB=myPaveBlocksPool.Append1(); |
924 | iRef=myPaveBlocksPool.Extent()-1; |
4e57c75e |
925 | // |
926 | aPB->Update(aLPB, Standard_False); |
4e57c75e |
927 | aSI.SetReference(iRef); |
928 | } |
929 | //======================================================================= |
930 | //function : UpdatePaveBlocks |
931 | //purpose : |
932 | //======================================================================= |
72e88cf7 |
933 | void BOPDS_DS::UpdatePaveBlocks() |
4e57c75e |
934 | { |
935 | Standard_Boolean bIsToUpdate; |
936 | Standard_Integer i, aNbPBP; |
937 | BOPDS_ListOfPaveBlock aLPBN(myAllocator); |
938 | BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN; |
939 | // |
940 | BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; |
941 | // |
942 | aNbPBP=aPBP.Size(); |
943 | for (i=0; i<aNbPBP; ++i) { |
944 | BOPDS_ListOfPaveBlock& aLPB=aPBP(i); |
945 | // |
946 | aItPB.Initialize(aLPB); |
947 | for (; aItPB.More(); aItPB.Next()) { |
948 | Handle(BOPDS_PaveBlock)& aPB=aItPB.ChangeValue(); |
949 | // |
950 | bIsToUpdate=aPB->IsToUpdate(); |
951 | if (bIsToUpdate){ |
952 | aLPBN.Clear(); |
953 | aPB->Update(aLPBN); |
954 | |
955 | aItPBN.Initialize(aLPBN); |
956 | for (; aItPBN.More(); aItPBN.Next()) { |
957 | Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue(); |
958 | aLPB.Append(aPBN); |
959 | } |
960 | aLPB.Remove(aItPB); |
961 | } |
962 | }// for (; aItPB.More(); aItPB.Next()) { |
963 | }// for (i=0; i<aNbPBP; ++i) { |
964 | } |
965 | //======================================================================= |
966 | //function : UpdatePaveBlock |
967 | //purpose : |
968 | //======================================================================= |
72e88cf7 |
969 | void BOPDS_DS::UpdatePaveBlock(const Handle(BOPDS_PaveBlock)& thePB) |
4e57c75e |
970 | { |
971 | if (!thePB->IsToUpdate()){ |
972 | return; |
973 | } |
974 | // |
975 | Standard_Integer nE, iRef; |
976 | BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN; |
977 | BOPDS_ListOfPaveBlock aLPBN(myAllocator); |
978 | Handle(BOPDS_PaveBlock) aPB; |
979 | // |
980 | BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; |
981 | // |
982 | nE=thePB->OriginalEdge(); |
983 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE); |
984 | iRef=aSI.Reference(); |
985 | BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef); |
986 | // |
987 | aItPB.Initialize(aLPB); |
988 | for (; aItPB.More(); aItPB.Next()) { |
989 | aPB=aItPB.ChangeValue(); |
990 | if (aPB==thePB) { |
991 | aPB->Update(aLPBN); |
3510db62 |
992 | aLPB.Append(aLPBN); |
4e57c75e |
993 | aLPB.Remove(aItPB); |
994 | break; |
995 | } |
996 | } |
997 | } |
998 | //======================================================================= |
999 | //function : UpdateCommonBlock |
1000 | //purpose : |
1001 | //======================================================================= |
0d0481c7 |
1002 | void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB, |
1003 | const Standard_Real theFuzz) |
4e57c75e |
1004 | { |
1005 | Standard_Integer nE, iRef, n1, n2; |
1006 | BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN; |
4e57c75e |
1007 | BOPDS_ListOfPaveBlock aLPBN; |
25dfc507 |
1008 | NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher> aMPKLPB; |
1009 | NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher>::Iterator aItMPKLPB; |
4e57c75e |
1010 | Handle(BOPDS_PaveBlock) aPB; |
1011 | Handle(BOPDS_CommonBlock) aCBx; |
25dfc507 |
1012 | BOPDS_Pair aPK; |
4e57c75e |
1013 | // |
1014 | const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks(); |
1015 | if (!aLPBCB.First()->IsToUpdate()){ |
1016 | return; |
1017 | } |
1018 | // |
1019 | const BOPCol_ListOfInteger& aLF=theCB->Faces(); |
1020 | // |
1021 | BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; |
1022 | // |
1023 | aItPBCB.Initialize(aLPBCB); |
1024 | for (; aItPBCB.More(); aItPBCB.Next()) { |
1025 | const Handle(BOPDS_PaveBlock)& aPBCB=aItPBCB.ChangeValue(); |
1026 | // |
1027 | nE=aPBCB->OriginalEdge(); |
1028 | iRef=ChangeShapeInfo(nE).Reference(); |
1029 | BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef); |
1030 | // |
1031 | aItPB.Initialize(aLPB); |
1032 | for (; aItPB.More(); aItPB.Next()) { |
1033 | aPB=aItPB.ChangeValue(); |
1034 | if (aPB==aPBCB) { |
1035 | // |
1036 | aLPBN.Clear(); |
1037 | aPB->Update(aLPBN); |
1038 | // |
1039 | aItPBN.Initialize(aLPBN); |
1040 | for (; aItPBN.More(); aItPBN.Next()) { |
1041 | Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue(); |
1042 | aLPB.Append(aPBN); |
1043 | // |
1044 | aPBN->Indices(n1, n2); |
25dfc507 |
1045 | aPK.SetIndices(n1, n2); |
4e57c75e |
1046 | if (aMPKLPB.IsBound(aPK)) { |
1047 | BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK); |
1048 | aLPBx.Append(aPBN); |
1049 | } |
1050 | else { |
1051 | BOPDS_ListOfPaveBlock aLPBx; |
1052 | aLPBx.Append(aPBN); |
1053 | aMPKLPB.Bind(aPK, aLPBx); |
1054 | } |
1055 | } |
25dfc507 |
1056 | aLPB.Remove(aItPB); |
4e57c75e |
1057 | break; |
1058 | } |
1059 | } |
1060 | } |
1061 | // |
1062 | aItMPKLPB.Initialize(aMPKLPB); |
1063 | for (; aItMPKLPB.More(); aItMPKLPB.Next()) { |
1064 | BOPDS_ListOfPaveBlock& aLPBx=aItMPKLPB.ChangeValue(); |
1065 | // |
1066 | while (aLPBx.Extent()) { |
1067 | Standard_Boolean bCoinside; |
1068 | Standard_Real aTol, aTolMax(0.); |
1069 | BOPDS_ListOfPaveBlock aLPBxN; |
1070 | // |
1071 | aItPB.Initialize(aLPBx); |
1072 | for(; aItPB.More(); ) { |
1073 | const Handle(BOPDS_PaveBlock)& aPBx=aItPB.Value(); |
1074 | if (aLPBxN.Extent()) { |
1075 | const Handle(BOPDS_PaveBlock)& aPBCx = aLPBxN.First(); |
0d0481c7 |
1076 | bCoinside = CheckCoincidence(aPBx, aPBCx, theFuzz); |
4e57c75e |
1077 | if (bCoinside) { |
1078 | nE = aPBx->OriginalEdge(); |
1079 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); |
1080 | aTol = BRep_Tool::Tolerance(aE); |
1081 | // |
1082 | //pave block with the max tolerance of the original edge |
1083 | //must be the first in the common block |
1084 | if (aTolMax < aTol) { |
1085 | aTolMax = aTol; |
1086 | aLPBxN.Prepend(aPBx); |
1087 | } else { |
1088 | aLPBxN.Append(aPBx); |
1089 | } |
1090 | aLPBx.Remove(aItPB); |
1091 | continue; |
1092 | }//if (bCoinside) { |
1093 | }//if (aLPBxN.Extent()) { |
1094 | else { |
1095 | nE = aPBx->OriginalEdge(); |
1096 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); |
1097 | aTolMax = BRep_Tool::Tolerance(aE); |
1098 | // |
1099 | aLPBxN.Append(aPBx); |
1100 | aLPBx.Remove(aItPB); |
1101 | continue; |
1102 | } |
1103 | aItPB.Next(); |
1104 | }//for(; aItPB.More(); ) { |
1105 | // |
1106 | aCBx=new BOPDS_CommonBlock; |
1107 | aCBx->AddPaveBlocks(aLPBxN); |
3510db62 |
1108 | aCBx->SetFaces(aLF); |
4e57c75e |
1109 | // |
1110 | aItPB.Initialize(aLPBxN); |
1111 | for (; aItPB.More(); aItPB.Next()) { |
1112 | aPB=aItPB.ChangeValue(); |
5a77460e |
1113 | SetCommonBlock(aPB, aCBx); |
4e57c75e |
1114 | } |
1115 | } |
1116 | } |
1117 | } |
5a77460e |
1118 | |
1119 | //======================================================================= |
1120 | // function: RealPaveBlock |
1121 | // purpose: |
1122 | //======================================================================= |
72e88cf7 |
1123 | Handle(BOPDS_PaveBlock) BOPDS_DS::RealPaveBlock |
5a77460e |
1124 | (const Handle(BOPDS_PaveBlock)& thePB) const |
1125 | { |
1126 | if (IsCommonBlock(thePB)) { |
1127 | const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB); |
1128 | const Handle(BOPDS_PaveBlock)& aPB = aCB->PaveBlock1(); |
1129 | return aPB; |
1130 | } |
1131 | return thePB; |
1132 | } |
1133 | |
1134 | //======================================================================= |
1135 | // function: IsCommonBlockOnEdge |
1136 | // purpose: |
1137 | //======================================================================= |
72e88cf7 |
1138 | Standard_Boolean BOPDS_DS::IsCommonBlockOnEdge |
5a77460e |
1139 | (const Handle(BOPDS_PaveBlock)& thePB) const |
1140 | { |
1141 | if (IsCommonBlock(thePB)) { |
1142 | const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB); |
1143 | return aCB->PaveBlocks().Extent()>1; |
1144 | } |
1145 | return Standard_False; |
1146 | } |
1147 | |
1148 | //======================================================================= |
1149 | //function : IsCommonBlock |
1150 | //purpose : |
1151 | //======================================================================= |
72e88cf7 |
1152 | Standard_Boolean BOPDS_DS::IsCommonBlock |
5a77460e |
1153 | (const Handle(BOPDS_PaveBlock)& thePB) const |
1154 | { |
1155 | return myMapPBCB.IsBound(thePB); |
1156 | } |
1157 | |
1158 | //======================================================================= |
1159 | //function : CommonBlock |
1160 | //purpose : |
1161 | //======================================================================= |
819f58c7 |
1162 | Handle(BOPDS_CommonBlock) BOPDS_DS::CommonBlock |
5a77460e |
1163 | (const Handle(BOPDS_PaveBlock)& thePB) const |
1164 | { |
819f58c7 |
1165 | return (IsCommonBlock(thePB) ? myMapPBCB.Find(thePB) : NULL); |
5a77460e |
1166 | } |
1167 | |
1168 | //======================================================================= |
1169 | //function : SetCommonBlock |
1170 | //purpose : |
1171 | //======================================================================= |
72e88cf7 |
1172 | void BOPDS_DS::SetCommonBlock(const Handle(BOPDS_PaveBlock)& thePB, |
362dec17 |
1173 | const Handle(BOPDS_CommonBlock)& theCB) |
5a77460e |
1174 | { |
1175 | if (IsCommonBlock(thePB)) { |
1176 | Handle(BOPDS_CommonBlock)& aCB = myMapPBCB.ChangeFind(thePB); |
1177 | aCB=theCB; |
1178 | } |
1179 | else { |
1180 | myMapPBCB.Bind(thePB, theCB); |
1181 | } |
1182 | } |
1183 | |
4e57c75e |
1184 | // |
1185 | // FaceInfo |
1186 | // |
1187 | |
1188 | //======================================================================= |
1189 | //function : FaceInfoPool |
1190 | //purpose : |
1191 | //======================================================================= |
72e88cf7 |
1192 | const BOPDS_VectorOfFaceInfo& BOPDS_DS::FaceInfoPool()const |
4e57c75e |
1193 | { |
1194 | return myFaceInfoPool; |
1195 | } |
1196 | //======================================================================= |
1197 | //function : HasFaceInfo |
1198 | //purpose : |
1199 | //======================================================================= |
72e88cf7 |
1200 | Standard_Boolean BOPDS_DS::HasFaceInfo(const Standard_Integer theI)const |
4e57c75e |
1201 | { |
1202 | return ShapeInfo(theI).HasReference(); |
1203 | } |
1204 | //======================================================================= |
1205 | //function : FaceInfo |
1206 | //purpose : |
1207 | //======================================================================= |
72e88cf7 |
1208 | const BOPDS_FaceInfo& BOPDS_DS::FaceInfo(const Standard_Integer theI)const |
4e57c75e |
1209 | { |
1210 | static BOPDS_FaceInfo sFI; |
1211 | Standard_Integer aRef; |
1212 | // |
1213 | if (HasFaceInfo(theI)) { |
1214 | aRef=ShapeInfo(theI).Reference(); |
1215 | const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef); |
1216 | return aFI; |
1217 | } |
1218 | return sFI; |
1219 | } |
1220 | //======================================================================= |
1221 | //function : ChangeFaceInfo |
1222 | //purpose : |
1223 | //======================================================================= |
72e88cf7 |
1224 | BOPDS_FaceInfo& BOPDS_DS::ChangeFaceInfo(const Standard_Integer theI) |
4e57c75e |
1225 | { |
1226 | Standard_Boolean bHasReference; |
1227 | Standard_Integer aRef; |
1228 | BOPDS_FaceInfo* pFI; |
1229 | // |
1230 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
1231 | bHasReference=aSI.HasReference(); |
1232 | if (!bHasReference) { |
1233 | InitFaceInfo(theI); |
1234 | } |
1235 | // |
1236 | aRef=aSI.Reference(); |
1237 | const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef); |
1238 | pFI=(BOPDS_FaceInfo*)&aFI; |
1239 | return *pFI; |
1240 | } |
1241 | //======================================================================= |
1242 | //function : InitFaceInfo |
1243 | //purpose : |
1244 | //======================================================================= |
72e88cf7 |
1245 | void BOPDS_DS::InitFaceInfo(const Standard_Integer theI) |
4e57c75e |
1246 | { |
1247 | Standard_Integer iRef; |
1248 | // |
1249 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
402bfe81 |
1250 | BOPDS_FaceInfo &aFI=myFaceInfoPool.Append1(); |
1251 | iRef=myFaceInfoPool.Extent()-1; |
4e57c75e |
1252 | aSI.SetReference(iRef); |
1253 | // |
1254 | aFI.SetIndex(theI); |
1255 | UpdateFaceInfoIn(theI); |
1256 | UpdateFaceInfoOn(theI); |
1257 | } |
1258 | //======================================================================= |
1259 | //function : UpdateFaceInfoIn |
1260 | //purpose : |
1261 | //======================================================================= |
72e88cf7 |
1262 | void BOPDS_DS::UpdateFaceInfoIn(const Standard_Integer theI) |
4e57c75e |
1263 | { |
1264 | Standard_Integer iRef; |
1265 | // |
1266 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
1267 | if (aSI.HasReference()) { |
1268 | iRef=aSI.Reference(); |
1269 | BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef); |
1270 | // |
1271 | BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn(); |
1272 | BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); |
1273 | aMPBIn.Clear(); |
1274 | aMVIn.Clear(); |
1275 | FaceInfoIn(theI, aMPBIn, aMVIn); |
1276 | } |
1277 | } |
1278 | //======================================================================= |
1279 | //function : UpdateFaceInfoOn |
1280 | //purpose : |
1281 | //======================================================================= |
72e88cf7 |
1282 | void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI) |
4e57c75e |
1283 | { |
1284 | Standard_Integer iRef; |
1285 | // |
1286 | BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); |
1287 | if (aSI.HasReference()) { |
1288 | iRef=aSI.Reference(); |
1289 | BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef); |
1290 | // |
1291 | BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn(); |
1292 | BOPCol_MapOfInteger& aMVOn=aFI.ChangeVerticesOn(); |
1293 | aMPBOn.Clear(); |
1294 | aMVOn.Clear(); |
1295 | FaceInfoOn(theI, aMPBOn, aMVOn); |
1296 | } |
1297 | } |
1298 | //======================================================================= |
1299 | //function : FaceInfoOn |
1300 | //purpose : |
1301 | //======================================================================= |
72e88cf7 |
1302 | void BOPDS_DS::FaceInfoOn(const Standard_Integer theF, |
362dec17 |
1303 | BOPDS_IndexedMapOfPaveBlock& theMPB, |
1304 | BOPCol_MapOfInteger& theMI) |
4e57c75e |
1305 | { |
1306 | Standard_Integer nS, nSD, nV1, nV2; |
1307 | BOPCol_ListIteratorOfListOfInteger aIt; |
1308 | BOPDS_ListIteratorOfListOfPaveBlock aItPB; |
1309 | // |
1310 | const BOPDS_ShapeInfo& aSI=ShapeInfo(theF); |
1311 | const BOPCol_ListOfInteger& aLI=aSI.SubShapes(); |
1312 | aIt.Initialize(aLI); |
1313 | for (; aIt.More(); aIt.Next()) { |
1314 | nS=aIt.Value(); |
1315 | const BOPDS_ShapeInfo& aSIE=ShapeInfo(nS); |
1316 | if (aSIE.ShapeType()==TopAbs_EDGE) { |
1317 | const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nS); |
1318 | aItPB.Initialize(aLPB); |
1319 | for (; aItPB.More(); aItPB.Next()) { |
1320 | const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); |
1321 | aPB->Indices(nV1, nV2); |
1322 | theMI.Add(nV1); |
1323 | theMI.Add(nV2); |
5a77460e |
1324 | Handle(BOPDS_PaveBlock) aPBR=RealPaveBlock(aPB); |
1325 | theMPB.Add(aPBR); |
4e57c75e |
1326 | } |
1327 | }//if (aSIE.ShapeType()==TopAbs_EDGE) |
1328 | else { |
1329 | // nE is TopAbs_VERTEX |
1330 | if (HasShapeSD(nS, nSD)) { |
1331 | nS=nSD; |
1332 | } |
1333 | theMI.Add(nS); |
1334 | } |
1335 | } |
1336 | } |
1337 | //======================================================================= |
1338 | //function : FaceInfoIn |
1339 | //purpose : |
1340 | //======================================================================= |
72e88cf7 |
1341 | void BOPDS_DS::FaceInfoIn(const Standard_Integer theF, |
362dec17 |
1342 | BOPDS_IndexedMapOfPaveBlock& theMPB, |
1343 | BOPCol_MapOfInteger& theMI) |
4e57c75e |
1344 | { |
50ba108c |
1345 | Standard_Integer i, aNbVF, aNbEF, nV, nE, nVSD; |
1346 | TopoDS_Iterator aItS; |
4e57c75e |
1347 | BOPDS_ListIteratorOfListOfPaveBlock aItPB; |
1348 | // |
50ba108c |
1349 | // 1. Pure internal vertices on the face |
1350 | const TopoDS_Shape& aF=Shape(theF); |
1351 | aItS.Initialize(aF); |
1352 | for (; aItS.More(); aItS.Next()) { |
1353 | const TopoDS_Shape& aSx=aItS.Value(); |
1354 | if (aSx.ShapeType()==TopAbs_VERTEX){ |
1355 | nV=Index(aSx); |
1356 | if (HasShapeSD(nV, nVSD)) { |
319da2e4 |
1357 | nV=nVSD; |
50ba108c |
1358 | } |
1359 | theMI.Add(nV); |
1360 | } |
1361 | } |
1362 | // |
1363 | // 2. aVFs |
4e57c75e |
1364 | BOPDS_VectorOfInterfVF& aVFs=InterfVF(); |
1365 | aNbVF=aVFs.Extent(); |
1366 | for (i=0; i<aNbVF; ++i) { |
1367 | BOPDS_InterfVF& aVF=aVFs(i); |
1368 | if(aVF.Contains(theF)) { |
1369 | nV=aVF.OppositeIndex(theF); |
3510db62 |
1370 | if (HasShapeSD(nV, nVSD)) { |
1371 | nV=nVSD; |
1372 | } |
4e57c75e |
1373 | theMI.Add(nV); |
1374 | } |
1375 | } |
1376 | // |
50ba108c |
1377 | // 3. aEFs |
4e57c75e |
1378 | BOPDS_VectorOfInterfEF& aEFs=InterfEF(); |
1379 | aNbEF=aEFs.Extent(); |
1380 | for (i=0; i<aNbEF; ++i) { |
1381 | BOPDS_InterfEF& aEF=aEFs(i); |
1382 | if(aEF.Contains(theF)) { |
1383 | if(aEF.HasIndexNew(nV)) { |
1384 | theMI.Add(nV); |
1385 | } |
1386 | else { |
1387 | nE=aEF.OppositeIndex(theF); |
1388 | const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE); |
1389 | aItPB.Initialize(aLPB); |
1390 | for (; aItPB.More(); aItPB.Next()) { |
1391 | const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); |
5a77460e |
1392 | if (IsCommonBlock(aPB)) { |
1393 | const Handle(BOPDS_CommonBlock)& aCB=CommonBlock(aPB); |
4e57c75e |
1394 | if (aCB->Contains(theF)) { |
1395 | const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1(); |
1396 | theMPB.Add(aPB1); |
1397 | } |
1398 | } |
1399 | }// for (; aItPB.More(); aItPB.Next()) { |
1400 | }// else { |
1401 | }// if(aEF.Contains(theF)) { |
1402 | }// for (i=0; i<aNbEF; ++i) { |
1403 | } |
1404 | |
1405 | //======================================================================= |
1406 | //function : RefineFaceInfoOn |
1407 | //purpose : |
1408 | //======================================================================= |
72e88cf7 |
1409 | void BOPDS_DS::RefineFaceInfoOn() |
4e57c75e |
1410 | { |
1411 | Standard_Integer i, aNb, nF, aNbPB, j; |
1412 | BOPDS_IndexedMapOfPaveBlock aMPB; |
1413 | // |
1414 | aNb=myFaceInfoPool.Extent(); |
1415 | for (i=0; i<aNb; ++i) { |
1416 | BOPDS_FaceInfo &aFI=myFaceInfoPool(i); |
1417 | nF=aFI.Index(); |
1418 | UpdateFaceInfoOn(nF); |
1419 | BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn(); |
1420 | // |
1421 | aMPB.Clear(); |
1422 | aMPB.Assign(aMPBOn); |
1423 | aMPBOn.Clear(); |
1424 | // |
1425 | aNbPB=aMPB.Extent(); |
1426 | for (j=1; j<=aNbPB; ++j) { |
1427 | const Handle(BOPDS_PaveBlock)& aPB=aMPB(j); |
1428 | if (aPB->HasEdge()) { |
1429 | aMPBOn.Add(aPB); |
1430 | } |
1431 | } |
1432 | } |
1433 | } |
1434 | //======================================================================= |
1435 | //function : AloneVertices |
1436 | //purpose : |
1437 | //======================================================================= |
72e88cf7 |
1438 | void BOPDS_DS::AloneVertices(const Standard_Integer theI, |
362dec17 |
1439 | BOPCol_ListOfInteger& theLI)const |
4e57c75e |
1440 | { |
1441 | if (HasFaceInfo(theI)) { |
1442 | // |
319da2e4 |
1443 | Standard_Integer i, j, nV1, nV2, nV, aNbPB; |
4e57c75e |
1444 | BOPCol_MapIteratorOfMapOfInteger aItMI; |
1445 | // |
1446 | BOPCol_MapOfInteger aMI(100, myAllocator); |
1447 | // |
1448 | const BOPDS_FaceInfo& aFI=FaceInfo(theI); |
1449 | // |
319da2e4 |
1450 | for (i = 0; i < 2; ++i) { |
362dec17 |
1451 | const BOPDS_IndexedMapOfPaveBlock& aMPB= |
1452 | (!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc(); |
319da2e4 |
1453 | aNbPB = aMPB.Extent(); |
1454 | for (j = 1; j <= aNbPB; ++j) { |
1455 | const Handle(BOPDS_PaveBlock)& aPB = aMPB(j); |
4e57c75e |
1456 | aPB->Indices(nV1, nV2); |
1457 | aMI.Add(nV1); |
1458 | aMI.Add(nV2); |
1459 | } |
1460 | } |
1461 | // |
1462 | for (i=0; i<2; ++i) { |
362dec17 |
1463 | const BOPCol_MapOfInteger& aMIV= |
1464 | (!i) ? aFI.VerticesIn() : aFI.VerticesSc(); |
4e57c75e |
1465 | aItMI.Initialize(aMIV); |
1466 | for (; aItMI.More(); aItMI.Next()) { |
1467 | nV=aItMI.Value(); |
362dec17 |
1468 | if (nV>=0) { |
4e57c75e |
1469 | if (aMI.Add(nV)) { |
1470 | theLI.Append(nV); |
1471 | } |
1472 | } |
1473 | } |
1474 | } |
1475 | } |
1476 | } |
4e57c75e |
1477 | //======================================================================= |
1478 | //function : VerticesOnIn |
1479 | //purpose : |
1480 | //======================================================================= |
0d0481c7 |
1481 | void BOPDS_DS::SubShapesOnIn |
362dec17 |
1482 | (const Standard_Integer nF1, |
1483 | const Standard_Integer nF2, |
0d0481c7 |
1484 | BOPCol_MapOfInteger& theMVOnIn, |
1485 | BOPDS_IndexedMapOfPaveBlock& thePBOnIn, |
1486 | BOPDS_MapOfPaveBlock& theCommonPB)const |
4e57c75e |
1487 | { |
decdfc94 |
1488 | Standard_Integer i, j, nV, nV1, nV2, aNbPB; |
4e57c75e |
1489 | BOPCol_MapIteratorOfMapOfInteger aIt; |
decdfc94 |
1490 | BOPDS_IndexedMapOfPaveBlock pMPB[4]; |
4e57c75e |
1491 | // |
1492 | const BOPDS_FaceInfo& aFI1=FaceInfo(nF1); |
1493 | const BOPDS_FaceInfo& aFI2=FaceInfo(nF2); |
1494 | // |
decdfc94 |
1495 | pMPB[0]=aFI1.PaveBlocksOn(); |
1496 | pMPB[1]=aFI1.PaveBlocksIn(); |
1497 | pMPB[2]=aFI2.PaveBlocksOn(); |
1498 | pMPB[3]=aFI2.PaveBlocksIn(); |
1da6ad32 |
1499 | // |
1500 | for (i=0; i<4; ++i) { |
decdfc94 |
1501 | aNbPB = pMPB[i].Extent(); |
1502 | for (j = 1; j <= aNbPB; ++j) { |
1503 | const Handle(BOPDS_PaveBlock)& aPB = pMPB[i](j); |
0d0481c7 |
1504 | thePBOnIn.Add(aPB); |
1da6ad32 |
1505 | aPB->Indices(nV1, nV2); |
0d0481c7 |
1506 | theMVOnIn.Add(nV1); |
1507 | theMVOnIn.Add(nV2); |
1508 | if (i < 2) { |
1509 | if (pMPB[2].Contains(aPB) || pMPB[3].Contains(aPB)) |
1510 | theCommonPB.Add(aPB); |
1511 | } |
1da6ad32 |
1512 | } |
4e57c75e |
1513 | } |
1514 | // |
1515 | const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn(); |
4e57c75e |
1516 | const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn(); |
4e57c75e |
1517 | const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn(); |
4e57c75e |
1518 | const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn(); |
1da6ad32 |
1519 | // |
1520 | for (i=0; i<2; ++i) { |
1521 | const BOPCol_MapOfInteger& aMV1=(!i) ? aMVOn1 : aMVIn1; |
1522 | aIt.Initialize(aMV1); |
1523 | for (; aIt.More(); aIt.Next()) { |
1524 | nV=aIt.Value(); |
1525 | if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) { |
0d0481c7 |
1526 | theMVOnIn.Add(nV); |
1da6ad32 |
1527 | } |
1528 | } |
4e57c75e |
1529 | } |
1530 | } |
1531 | //======================================================================= |
1532 | //function : SharedEdges |
1533 | //purpose : |
1534 | //======================================================================= |
72e88cf7 |
1535 | void BOPDS_DS::SharedEdges(const Standard_Integer nF1, |
362dec17 |
1536 | const Standard_Integer nF2, |
1537 | BOPCol_ListOfInteger& theLI, |
1538 | const Handle(NCollection_BaseAllocator)& aAllocator) |
4e57c75e |
1539 | { |
1540 | Standard_Integer nE, nSp; |
1541 | BOPCol_ListIteratorOfListOfInteger aItLI; |
1542 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
1543 | BOPCol_MapOfInteger aMI(100, aAllocator); |
1544 | // |
1545 | const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1); |
1546 | const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes(); |
1547 | aItLI.Initialize(aLI1); |
1548 | for (; aItLI.More(); aItLI.Next()) { |
1549 | nE=aItLI.Value(); |
1550 | const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); |
1551 | if(aSIE.ShapeType()==TopAbs_EDGE) { |
1552 | const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE); |
1553 | if (aLPB.IsEmpty()) { |
1554 | aMI.Add(nE); |
1555 | } |
1556 | else { |
1557 | aItLPB.Initialize(aLPB); |
1558 | for (; aItLPB.More(); aItLPB.Next()) { |
5a77460e |
1559 | const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value()); |
4e57c75e |
1560 | nSp=aPB->Edge(); |
1561 | aMI.Add(nSp); |
1562 | } |
1563 | } |
1564 | } |
1565 | } |
1566 | // |
1567 | const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2); |
1568 | const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes(); |
1569 | aItLI.Initialize(aLI2); |
1570 | for (; aItLI.More(); aItLI.Next()) { |
1571 | nE=aItLI.Value(); |
1572 | const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); |
1573 | if(aSIE.ShapeType()==TopAbs_EDGE) { |
1574 | const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE); |
1575 | if (aLPB.IsEmpty()) { |
1576 | if (aMI.Contains(nE)) { |
1577 | theLI.Append(nE); |
1578 | } |
1579 | } |
1580 | else { |
1581 | aItLPB.Initialize(aLPB); |
1582 | for (; aItLPB.More(); aItLPB.Next()) { |
5a77460e |
1583 | const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value()); |
4e57c75e |
1584 | nSp=aPB->Edge(); |
1585 | if (aMI.Contains(nSp)) { |
1586 | theLI.Append(nSp); |
1587 | } |
1588 | } |
1589 | } |
1590 | } |
1591 | } |
1592 | } |
1593 | |
1594 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1595 | // |
1596 | // same domain shapes |
1597 | // |
1598 | //======================================================================= |
1599 | //function : ShapesSD |
1600 | //purpose : |
1601 | //======================================================================= |
72e88cf7 |
1602 | BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD() |
4e57c75e |
1603 | { |
1604 | return myShapesSD; |
1605 | } |
1606 | //======================================================================= |
1607 | //function : AddShapeSD |
1608 | //purpose : |
1609 | //======================================================================= |
72e88cf7 |
1610 | void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex, |
362dec17 |
1611 | const Standard_Integer theIndexSD) |
4e57c75e |
1612 | { |
1613 | myShapesSD.Bind(theIndex, theIndexSD); |
1614 | } |
1615 | //======================================================================= |
1616 | //function : HasShapeSD |
1617 | //purpose : |
1618 | //======================================================================= |
362dec17 |
1619 | Standard_Boolean BOPDS_DS::HasShapeSD |
1620 | (const Standard_Integer theIndex, |
1621 | Standard_Integer& theIndexSD)const |
4e57c75e |
1622 | { |
1623 | Standard_Boolean bRet; |
1624 | // |
1625 | bRet=myShapesSD.IsBound(theIndex); |
1626 | if (bRet) { |
1627 | theIndexSD=myShapesSD.Find(theIndex); |
1628 | } |
1629 | return bRet; |
1630 | } |
1631 | //======================================================================= |
1632 | //function : Dump |
1633 | //purpose : |
1634 | //======================================================================= |
72e88cf7 |
1635 | void BOPDS_DS::Dump()const |
4e57c75e |
1636 | { |
1637 | Standard_Integer i, aNb, aNbSS; |
1638 | // |
1639 | printf(" *** DS ***\n"); |
1640 | aNb=NbRanges(); |
1641 | printf(" Ranges:%d\n", aNb); |
1642 | for (i=0; i<aNb; ++i) { |
1643 | const BOPDS_IndexRange& aR=Range(i); |
1644 | aR.Dump(); |
1645 | printf("\n"); |
1646 | } |
1647 | // |
1648 | aNbSS=NbSourceShapes(); |
1649 | printf(" Shapes:%d\n", aNbSS); |
1650 | aNb=NbShapes(); |
1651 | for (i=0; i<aNb; ++i) { |
1652 | const BOPDS_ShapeInfo& aSI=ShapeInfo(i); |
1653 | printf(" %d :", i); |
1654 | aSI.Dump(); |
1655 | printf("\n"); |
1656 | if (i==aNbSS-1) { |
1657 | printf(" ****** adds\n"); |
1658 | } |
1659 | } |
1660 | printf(" ******\n"); |
1661 | } |
1662 | |
1663 | //======================================================================= |
1664 | // function: CheckCoincidence |
1665 | // purpose: |
1666 | //======================================================================= |
362dec17 |
1667 | Standard_Boolean BOPDS_DS::CheckCoincidence |
1668 | (const Handle(BOPDS_PaveBlock)& aPB1, |
0d0481c7 |
1669 | const Handle(BOPDS_PaveBlock)& aPB2, |
1670 | const Standard_Real theFuzz) |
4e57c75e |
1671 | { |
1672 | Standard_Boolean bRet; |
1673 | Standard_Integer nE1, nE2, aNbPoints; |
1674 | Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x; |
1675 | gp_Pnt aP1m; |
1676 | // |
1677 | bRet=Standard_False; |
1678 | // |
1679 | aPB1->Range(aT11, aT12); |
1680 | aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12); |
1681 | nE1=aPB1->OriginalEdge(); |
1682 | const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1))); |
1683 | BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m); |
1684 | // |
1685 | aPB2->Range(aT21, aT22); |
1686 | nE2=aPB2->OriginalEdge(); |
1687 | const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2))); |
1688 | // |
1689 | Standard_Real f, l; |
1690 | Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l); |
1691 | GeomAPI_ProjectPointOnCurve aPPC; |
1692 | aPPC.Init(aC2, f, l); |
1693 | aPPC.Perform(aP1m); |
1694 | aNbPoints=aPPC.NbPoints(); |
1695 | if (aNbPoints) { |
1696 | aD=aPPC.LowerDistance(); |
1697 | // |
1698 | aTol=BRep_Tool::Tolerance(aE1); |
0d0481c7 |
1699 | aTol = aTol + BRep_Tool::Tolerance(aE2) + Max(theFuzz, Precision::Confusion()); |
4e57c75e |
1700 | if (aD<aTol) { |
1701 | aT2x=aPPC.LowerDistanceParameter(); |
1702 | if (aT2x>aT21 && aT2x<aT22) { |
1703 | return !bRet; |
1704 | } |
1705 | } |
1706 | } |
1707 | return bRet; |
1708 | } |
4e57c75e |
1709 | //======================================================================= |
1710 | // function: SortPaveBlocks |
1711 | // purpose: |
1712 | //======================================================================= |
72e88cf7 |
1713 | void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB) |
4e57c75e |
1714 | { |
1715 | Standard_Integer theI; |
1716 | Standard_Boolean bToSort; |
1717 | bToSort = IsToSort(aCB, theI); |
1718 | if (!bToSort) { |
1719 | return; |
1720 | } |
1721 | |
1722 | Standard_Integer i(0); |
1723 | const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks(); |
1724 | BOPDS_ListOfPaveBlock aLPBN = aLPB; |
1725 | |
1726 | Handle(BOPDS_PaveBlock) aPB; |
1727 | BOPDS_ListIteratorOfListOfPaveBlock aIt; |
1728 | // |
1729 | aIt.Initialize(aLPBN); |
1730 | for (aIt.Next(); aIt.More(); ) { |
1731 | i++; |
1732 | if(i == theI) { |
1733 | aPB = aIt.Value(); |
1734 | aLPBN.Remove(aIt); |
1735 | aLPBN.Prepend(aPB); |
1736 | break; |
1737 | } |
1738 | aIt.Next(); |
1739 | } |
1740 | // |
1741 | aCB->AddPaveBlocks(aLPBN); |
1742 | } |
4e57c75e |
1743 | //======================================================================= |
1744 | // function: IsToSort |
1745 | // purpose: |
1746 | //======================================================================= |
362dec17 |
1747 | Standard_Boolean BOPDS_DS::IsToSort |
1748 | (const Handle(BOPDS_CommonBlock)& aCB, |
1749 | Standard_Integer& theI) |
4e57c75e |
1750 | { |
1751 | Standard_Boolean bRet; |
1752 | bRet = Standard_False; |
1753 | const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks(); |
1754 | if (aLPB.Extent()==1) { |
1755 | return bRet; |
1756 | } |
1757 | |
1758 | Standard_Integer nE; |
1759 | Standard_Real aTolMax, aTol; |
1760 | Handle(BOPDS_PaveBlock) aPB; |
1761 | TopoDS_Edge aE; |
1762 | BOPDS_ListIteratorOfListOfPaveBlock aIt; |
1763 | // |
1764 | aPB = aLPB.First(); |
1765 | nE = aPB->OriginalEdge(); |
1766 | aE = (*(TopoDS_Edge *)(&Shape(nE))); |
1767 | aTolMax = BRep_Tool::Tolerance(aE); |
1768 | // |
1769 | theI = 0; |
1770 | aIt.Initialize(aLPB); |
1771 | for (aIt.Next(); aIt.More(); aIt.Next()) { |
1772 | theI++; |
1773 | aPB = aIt.Value(); |
1774 | nE = aPB->OriginalEdge(); |
1775 | aE = (*(TopoDS_Edge *)(&Shape(nE))); |
1776 | aTol = BRep_Tool::Tolerance(aE); |
1777 | if (aTolMax < aTol) { |
1778 | aTolMax = aTol; |
1779 | bRet = Standard_True; |
1780 | } |
1781 | } |
1782 | |
1783 | return bRet; |
1784 | } |
4e57c75e |
1785 | //======================================================================= |
1786 | // function: IsSubShape |
1787 | // purpose: |
1788 | //======================================================================= |
362dec17 |
1789 | Standard_Boolean BOPDS_DS::IsSubShape |
1790 | (const Standard_Integer theI1, |
1791 | const Standard_Integer theI2) |
4e57c75e |
1792 | { |
1793 | Standard_Boolean bRet; |
1794 | Standard_Integer nS; |
1795 | bRet = Standard_False; |
1796 | // |
1797 | BOPCol_ListIteratorOfListOfInteger aItLI; |
1798 | // |
1799 | const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2); |
1800 | const BOPCol_ListOfInteger& aLI = aSI.SubShapes(); |
1801 | aItLI.Initialize(aLI); |
1802 | for(;aItLI.More(); aItLI.Next()) { |
1803 | nS = aItLI.Value(); |
1804 | if (nS == theI1) { |
1805 | bRet = Standard_True; |
1806 | break; |
1807 | } |
1808 | } |
1809 | |
1810 | return bRet; |
1811 | } |
4e57c75e |
1812 | //======================================================================= |
1813 | // function: Paves |
1814 | // purpose: |
1815 | //======================================================================= |
72e88cf7 |
1816 | void BOPDS_DS::Paves(const Standard_Integer theEdge, |
362dec17 |
1817 | BOPDS_ListOfPave& theLP) |
4e57c75e |
1818 | { |
1819 | Standard_Integer aNb, i; |
4e57c75e |
1820 | BOPDS_ListIteratorOfListOfPaveBlock aIt; |
1821 | BOPDS_MapOfPave aMP; |
1822 | // |
1823 | const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge); |
7a76337e |
1824 | aNb = aLPB.Extent() + 1; |
1825 | if (aNb == 1) { |
1826 | return; |
4e57c75e |
1827 | } |
1828 | // |
7a76337e |
1829 | BOPDS_VectorOfPave pPaves(1, aNb); |
1830 | // |
1831 | i = 1; |
1832 | aIt.Initialize(aLPB); |
1833 | for (; aIt.More(); aIt.Next()) { |
4e57c75e |
1834 | const Handle(BOPDS_PaveBlock)& aPB = aIt.Value(); |
7a76337e |
1835 | const BOPDS_Pave& aPave1 = aPB->Pave1(); |
1836 | const BOPDS_Pave& aPave2 = aPB->Pave2(); |
1837 | // |
1838 | if (aMP.Add(aPave1)){ |
1839 | pPaves(i) = aPave1; |
4e57c75e |
1840 | ++i; |
1841 | } |
7a76337e |
1842 | // |
1843 | if (aMP.Add(aPave2)){ |
1844 | pPaves(i) = aPave2; |
4e57c75e |
1845 | ++i; |
1846 | } |
1847 | } |
1848 | // |
7a76337e |
1849 | Standard_ASSERT_VOID(aNb == aMP.Extent(), "Abnormal number of paves"); |
1850 | // |
1851 | std::sort(pPaves.begin(), pPaves.end()); |
4e57c75e |
1852 | // |
7a76337e |
1853 | for (i = 1; i <= aNb; ++i) { |
1854 | theLP.Append(pPaves(i)); |
4e57c75e |
1855 | } |
1856 | } |
4e57c75e |
1857 | //======================================================================= |
1858 | // function: UpdateTolerance |
1859 | // purpose: |
1860 | //======================================================================= |
72e88cf7 |
1861 | void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE, |
0d0481c7 |
1862 | const Standard_Real aTol, |
1863 | const Standard_Real theFuzz) |
4e57c75e |
1864 | { |
1865 | Standard_Integer nV; |
1866 | Standard_Real aTolV; |
1867 | BRep_Builder aBB; |
1868 | BOPCol_ListIteratorOfListOfInteger aIt; |
1869 | // |
0d0481c7 |
1870 | Standard_Real aTolAdd = Max(theFuzz, Precision::Confusion()) * 0.5; |
1871 | |
4e57c75e |
1872 | const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); |
1873 | aBB.UpdateEdge(aE, aTol); |
1874 | BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); |
1875 | Bnd_Box& aBoxE=aSIE.ChangeBox(); |
1876 | BRepBndLib::Add(aE, aBoxE); |
0d0481c7 |
1877 | aBoxE.SetGap(aBoxE.GetGap() + aTolAdd); |
4e57c75e |
1878 | // |
1879 | const BOPCol_ListOfInteger& aLI = aSIE.SubShapes(); |
1880 | aIt.Initialize(aLI); |
1881 | for (; aIt.More(); aIt.Next()) { |
1882 | nV = aIt.Value(); |
1883 | const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV); |
1884 | aTolV = BRep_Tool::Tolerance(aV); |
1885 | if (aTolV < aTol) { |
1886 | aBB.UpdateVertex(aV, aTol); |
1887 | BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV); |
1888 | Bnd_Box& aBoxV = aSIV.ChangeBox(); |
1889 | BRepBndLib::Add(aV, aBoxV); |
0d0481c7 |
1890 | aBoxV.SetGap(aBoxV.GetGap() + aTolAdd); |
4e57c75e |
1891 | } |
1892 | } |
1893 | } |
4e57c75e |
1894 | //======================================================================= |
1895 | //function : TotalShapes |
1896 | //purpose : |
1897 | //======================================================================= |
1898 | void TotalShapes(const TopoDS_Shape& aS, |
3510db62 |
1899 | Standard_Integer& aNbS, |
1900 | BOPCol_MapOfShape& aMS) |
4e57c75e |
1901 | { |
3510db62 |
1902 | if (aMS.Add(aS)) { |
4e57c75e |
1903 | TopoDS_Iterator aIt; |
4e57c75e |
1904 | ++aNbS; |
1905 | aIt.Initialize(aS); |
1906 | for (; aIt.More(); aIt.Next()) { |
1907 | const TopoDS_Shape& aSx=aIt.Value(); |
3510db62 |
1908 | TotalShapes(aSx, aNbS, aMS); |
4e57c75e |
1909 | } |
1910 | } |
1911 | } |
3510db62 |
1912 | |
4e57c75e |
1913 | //======================================================================= |
1914 | //function : ComputeParameter |
1915 | //purpose : |
1916 | //======================================================================= |
1917 | Standard_Real ComputeParameter(const TopoDS_Vertex& aV, |
1918 | const TopoDS_Edge& aE) |
1919 | { |
1920 | Standard_Real aT1, aT2, aTRet, aTolE2, aD2; |
1921 | gp_Pnt aPC, aPV; |
1922 | Handle(Geom_Curve) aC3D; |
1923 | TopoDS_Edge aEE; |
1924 | // |
1925 | aEE=aE; |
1926 | aEE.Orientation(TopAbs_FORWARD); |
1927 | // |
1928 | aTRet=0.; |
1929 | // |
1930 | aTolE2=BRep_Tool::Tolerance(aE); |
1931 | aTolE2=aTolE2*aTolE2; |
1932 | // |
1933 | aPV=BRep_Tool::Pnt(aV); |
1934 | // |
1935 | aC3D=BRep_Tool::Curve (aEE, aT1, aT2); |
1936 | // |
1937 | aC3D->D0(aT1, aPC); |
1938 | aD2=aPC.SquareDistance(aPV); |
1939 | if (aD2<aTolE2) { |
1940 | aTRet=aT1; |
1941 | } |
1942 | // |
1943 | aC3D->D0(aT2, aPC); |
1944 | aD2=aPC.SquareDistance(aPV); |
1945 | if (aD2<aTolE2) { |
1946 | aTRet=aT2; |
1947 | } |
1948 | // |
1949 | return aTRet; |
1950 | } |
1951 | //======================================================================= |
30ecd5f8 |
1952 | //function : BuildBndBoxSolid |
1953 | //purpose : |
1954 | //======================================================================= |
1955 | void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex, |
362dec17 |
1956 | Bnd_Box& aBoxS) |
30ecd5f8 |
1957 | { |
1958 | Standard_Boolean bIsOpenBox, bIsInverted; |
1959 | Standard_Integer nSh, nFc; |
1960 | Standard_Real aTolS, aTolFc; |
1961 | BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1; |
1962 | // |
1963 | const BOPDS_ShapeInfo& aSI=ShapeInfo(theIndex); |
1964 | const TopoDS_Shape& aS=aSI.Shape(); |
1965 | const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS)); |
1966 | // |
1967 | bIsOpenBox=Standard_False; |
1968 | // |
1969 | aTolS=0.; |
1970 | const BOPCol_ListOfInteger& aLISh=aSI.SubShapes(); |
1971 | aItLI.Initialize(aLISh); |
1972 | for (; aItLI.More(); aItLI.Next()) { |
1973 | nSh=aItLI.Value(); |
1974 | const BOPDS_ShapeInfo& aSISh=ShapeInfo(nSh); |
1975 | if (aSISh.ShapeType()!=TopAbs_SHELL) { |
1976 | continue; |
1977 | } |
1978 | // |
1979 | const BOPCol_ListOfInteger& aLIFc=aSISh.SubShapes(); |
1980 | aItLI1.Initialize(aLIFc); |
1981 | for (; aItLI1.More(); aItLI1.Next()) { |
1982 | nFc=aItLI1.Value(); |
1983 | const BOPDS_ShapeInfo& aSIFc=ShapeInfo(nFc); |
1984 | if (aSIFc.ShapeType()!=TopAbs_FACE) { |
362dec17 |
1985 | continue; |
30ecd5f8 |
1986 | } |
1987 | // |
1988 | const Bnd_Box& aBFc=aSIFc.Box(); |
1989 | aBoxS.Add(aBFc); |
1990 | // |
1991 | if (!bIsOpenBox) { |
362dec17 |
1992 | bIsOpenBox=(aBFc.IsOpenXmin() || aBFc.IsOpenXmax() || |
1993 | aBFc.IsOpenYmin() || aBFc.IsOpenYmax() || |
1994 | aBFc.IsOpenZmin() || aBFc.IsOpenZmax()); |
1995 | if (bIsOpenBox) { |
1996 | break; |
1997 | } |
30ecd5f8 |
1998 | } |
1999 | // |
2000 | const TopoDS_Face& aFc=*((TopoDS_Face*)&aSIFc.Shape()); |
2001 | aTolFc=BRep_Tool::Tolerance(aFc); |
2002 | if (aTolFc>aTolS) { |
362dec17 |
2003 | aTolS=aTolFc; |
30ecd5f8 |
2004 | } |
2005 | }//for (; aItLI1.More(); aItLI1.Next()) { |
2006 | if (bIsOpenBox) { |
2007 | break; |
2008 | } |
2009 | // |
2010 | const TopoDS_Shell& aSh=*((TopoDS_Shell*)&aSISh.Shape()); |
2011 | bIsOpenBox=BOPTools_AlgoTools::IsOpenShell(aSh); |
2012 | if (bIsOpenBox) { |
2013 | break; |
2014 | } |
2015 | }//for (; aItLI.More(); aItLI.Next()) { |
2016 | // |
2017 | if (bIsOpenBox) { |
2018 | aBoxS.SetWhole(); |
2019 | } |
2020 | else { |
2021 | bIsInverted=BOPTools_AlgoTools::IsInvertedSolid(aSolid); |
2022 | if (bIsInverted) { |
2023 | aBoxS.SetWhole(); |
2024 | } |
2025 | } |
2026 | } |
b1d15f53 |
2027 | |
3510db62 |
2028 | //======================================================================= |
2029 | //function : UpdatePaveBlocksWithSDVertices |
2030 | //purpose : |
2031 | //======================================================================= |
2032 | void BOPDS_DS::UpdatePaveBlocksWithSDVertices() |
2033 | { |
2034 | Standard_Integer i, aNbPBP; |
2035 | BOPDS_ListIteratorOfListOfPaveBlock aItPB; |
2036 | // |
2037 | BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; |
2038 | // |
2039 | aNbPBP=aPBP.Size(); |
2040 | for (i = 0; i < aNbPBP; ++i) { |
2041 | BOPDS_ListOfPaveBlock& aLPB = aPBP(i); |
2042 | // |
2043 | aItPB.Initialize(aLPB); |
2044 | for (; aItPB.More(); aItPB.Next()) { |
2045 | Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue(); |
2046 | UpdatePaveBlockWithSDVertices(aPB); |
2047 | }// for (; aItPB.More(); aItPB.Next()) { |
2048 | }// for (i = 0; i < aNbPBP; ++i) { |
2049 | } |
2050 | //======================================================================= |
2051 | //function : UpdatePaveBlockWithSDVertices |
2052 | //purpose : |
2053 | //======================================================================= |
2054 | void BOPDS_DS::UpdatePaveBlockWithSDVertices |
2055 | (const Handle(BOPDS_PaveBlock)& thePB) |
2056 | { |
2057 | Standard_Integer nV1, nV2; |
2058 | BOPDS_Pave aPave1, aPave2; |
2059 | // |
2060 | aPave1 = thePB->Pave1(); |
2061 | aPave2 = thePB->Pave2(); |
2062 | // |
2063 | nV1 = aPave1.Index(); |
2064 | nV2 = aPave2.Index(); |
2065 | // |
2066 | if (HasShapeSD(nV1, nV1)) { |
2067 | aPave1.SetIndex(nV1); |
2068 | thePB->SetPave1(aPave1); |
2069 | } |
2070 | // |
2071 | if (HasShapeSD(nV2, nV2)) { |
2072 | aPave2.SetIndex(nV2); |
2073 | thePB->SetPave2(aPave2); |
2074 | } |
2075 | } |
2076 | //======================================================================= |
2077 | //function : UpdateCommonBlockWithSDVertices |
2078 | //purpose : |
2079 | //======================================================================= |
2080 | void BOPDS_DS::UpdateCommonBlockWithSDVertices |
2081 | (const Handle(BOPDS_CommonBlock)& theCB) |
2082 | { |
2083 | const BOPDS_ListOfPaveBlock& aLPB = theCB->PaveBlocks(); |
2084 | BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB); |
2085 | for (; aItPB.More(); aItPB.Next()) { |
2086 | const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); |
2087 | UpdatePaveBlockWithSDVertices(aPB); |
2088 | } |
2089 | } |
2090 | //======================================================================= |
2091 | //function : InitPaveBlocksForVertex |
2092 | //purpose : |
2093 | //======================================================================= |
2094 | void BOPDS_DS::InitPaveBlocksForVertex(const Standard_Integer theNV) |
2095 | { |
2096 | Standard_Integer nE; |
2097 | BOPCol_ListIteratorOfListOfInteger aItLE; |
2098 | // |
2099 | if (myMapVE.IsBound(theNV)) { |
2100 | const BOPCol_ListOfInteger& aLE=myMapVE.Find(theNV); |
2101 | aItLE.Initialize(aLE); |
2102 | for (; aItLE.More(); aItLE.Next()) { |
2103 | nE=aItLE.Value(); |
2104 | ChangePaveBlocks(nE); |
2105 | } |
2106 | } |
2107 | } |