b311480e |
1 | // Created on: 2001-03-13 |
2 | // Created by: Peter KURNEV |
3 | // Copyright (c) 2001-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | |
22 | #include <BOPTools_PaveFiller.ixx> |
23 | |
24 | #include <Precision.hxx> |
25 | #include <SortTools_QuickSortOfReal.hxx> |
26 | #include <TColStd_Array1OfReal.hxx> |
27 | #include <TCollection_CompareOfReal.hxx> |
28 | #include <BRep_Tool.hxx> |
29 | |
30 | #include <TopoDS.hxx> |
31 | #include <TopoDS_Shape.hxx> |
32 | #include <TopoDS_Edge.hxx> |
33 | #include <TopoDS_Vertex.hxx> |
34 | |
35 | #include <IntTools_Tools.hxx> |
36 | #include <IntTools_EdgeEdge.hxx> |
37 | #include <IntTools_Range.hxx> |
38 | #include <IntTools_ShrunkRange.hxx> |
39 | #include <IntTools_EdgeFace.hxx> |
40 | #include <IntTools_SequenceOfCommonPrts.hxx> |
41 | #include <IntTools_CommonPrt.hxx> |
42 | #include <IntTools_SequenceOfRanges.hxx> |
43 | |
44 | #include <BooleanOperations_ShapesDataStructure.hxx> |
45 | #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx> |
46 | #include <BooleanOperations_OnceExplorer.hxx> |
47 | |
48 | #include <BOPTools_InterferencePool.hxx> |
49 | #include <BOPTools_IteratorOfCoupleOfShape.hxx> |
50 | #include <BOPTools_VVInterference.hxx> |
51 | #include <BOPTools_VEInterference.hxx> |
52 | #include <BOPTools_EEInterference.hxx> |
53 | #include <BOPTools_CArray1OfVEInterference.hxx> |
54 | #include <BOPTools_CArray1OfVVInterference.hxx> |
55 | #include <BOPTools_CArray1OfEEInterference.hxx> |
56 | #include <BOPTools_Tools.hxx> |
57 | #include <BOPTools_Pave.hxx> |
58 | #include <BOPTools_PaveSet.hxx> |
59 | #include <BOPTools_PaveBlockIterator.hxx> |
60 | #include <BOPTools_ListOfPave.hxx> |
61 | #include <BOPTools_ListIteratorOfListOfPave.hxx> |
62 | #include <BOPTools_ListOfPaveBlock.hxx> |
63 | #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx> |
64 | #include <BOPTools_CommonBlock.hxx> |
65 | #include <BOPTools_ListOfCommonBlock.hxx> |
66 | #include <BOPTools_ListIteratorOfListOfCommonBlock.hxx> |
67 | #include <BOPTools_ESInterference.hxx> |
68 | #include <BOPTools_CommonBlockAPI.hxx> |
69 | #include <BOPTools_PaveBlock.hxx> |
70 | #include <BOPTools_ListIteratorOfListOfInterference.hxx> |
71 | #include <BOPTools_Interference.hxx> |
72 | #include <BOPTools_InterferenceLine.hxx> |
73 | #include <BOPTools_CArray1OfInterferenceLine.hxx> |
74 | |
75 | #include <BOPTColStd_Failure.hxx> |
76 | |
77 | #include <stdio.h> |
78 | |
79 | //======================================================================= |
80 | // function: PerformEF |
81 | // purpose: |
82 | //======================================================================= |
b311480e |
83 | void BOPTools_PaveFiller::PerformEF() |
7fd59977 |
84 | { |
85 | myIsDone=Standard_False; |
86 | |
87 | Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength; |
88 | |
89 | BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); |
90 | // |
91 | // E/F Interferences [BooleanOperations_EdgeFace] |
92 | myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE); |
93 | // |
94 | // BlockLength correction |
95 | aNbEFs=ExpectedPoolLength(); |
96 | aBlockLength=aEFs.BlockLength(); |
97 | if (aNbEFs > aBlockLength) { |
98 | aEFs.SetBlockLength(aNbEFs); |
99 | } |
100 | // |
101 | for (; myDSIt.More(); myDSIt.Next()) { |
102 | Standard_Boolean justaddinterference = Standard_True; |
103 | myDSIt.Current(n1, n2, justaddinterference); |
104 | |
105 | if(justaddinterference) { |
106 | if (!myIntrPool->IsComputed(n1, n2)) { |
107 | anIndexIn = 0; |
108 | nE=n1; |
109 | nF=n2; |
110 | SortTypes(nE, nF); |
111 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
112 | } |
113 | continue; |
114 | } |
115 | // |
116 | if (myIntrPool->IsComputed(n1, n2)) { |
117 | continue; |
118 | } |
119 | // |
120 | nE=n1; |
121 | nF=n2; |
122 | SortTypes(nE, nF); |
123 | // |
124 | // ListOfCommonBlock for nE and CommonBlockAPI object to avoid |
125 | // CommonBlocks processing |
126 | BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); |
127 | BOPTools_CommonBlockAPI aCBAPI(aLCB); |
128 | // |
129 | Standard_Real aTolE, aTolF, aDeflection=0.01; |
130 | Standard_Integer aDiscretize=35; |
131 | |
132 | // modified by NIZHNY-MKK Thu Oct 27 12:31:45 2005 |
133 | // const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); |
134 | TopoDS_Edge aE=TopoDS::Edge(myDS->GetShape(nE)); |
135 | // |
136 | if (BRep_Tool::Degenerated(aE)){ |
137 | continue; |
138 | } |
139 | // |
140 | aTolE=BRep_Tool::Tolerance(aE); |
141 | |
142 | // modified by NIZHNY-MKK Thu Oct 27 12:31:52 2005 |
143 | // const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF)); |
144 | TopoDS_Face aF=TopoDS::Face(myDS->GetShape(nF)); |
145 | aTolF=BRep_Tool::Tolerance(aF); |
146 | // modified by NIZHNY-MKK Thu Oct 27 12:32:02 2005 |
147 | // const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); |
148 | Bnd_Box aBBF=myDS->GetBoundingBox(nF); |
149 | // |
150 | BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); |
151 | BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); |
152 | |
153 | for (; anIt.More(); anIt.Next()) { |
154 | |
155 | BOPTools_PaveBlock& aPB=anIt.Value(); |
156 | |
157 | if (aCBAPI.IsCommonBlock(aPB)) { |
158 | // avoid CommonBlocks processing |
159 | continue; |
160 | } |
161 | |
162 | const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); |
163 | const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); |
164 | const Bnd_Box& aBBE=aShrunkRange.BndBox(); |
165 | |
166 | ////////////////////////////////////////////// |
167 | if (aBBF.IsOut (aBBE)) { |
168 | continue; |
169 | } |
170 | // |
171 | // EF |
172 | IntTools_EdgeFace aEF; |
173 | aEF.SetEdge (aE); |
174 | aEF.SetFace (aF); |
175 | aEF.SetTolE (aTolE); |
176 | aEF.SetTolF (aTolF); |
177 | aEF.SetDiscretize (aDiscretize); |
178 | aEF.SetDeflection (aDeflection); |
179 | // |
4f189102 |
180 | aEF.SetContext(myContext); |
7fd59977 |
181 | // |
182 | |
183 | BRepAdaptor_Curve aCurve(aE); |
184 | IntTools_Range anewSR = aSR; |
185 | // |
186 | // Correction of the Shrunk Range |
187 | // |
188 | BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); |
189 | // |
190 | aEF.SetRange (anewSR); |
191 | // |
192 | aEF.Perform(); |
193 | // |
194 | anIndexIn=0; |
195 | // |
196 | if (aEF.IsDone()) { |
197 | // |
198 | const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); |
199 | Standard_Integer i, aNbCPrts; |
200 | aNbCPrts=aCPrts.Length(); |
201 | |
202 | // modified by NIZHNY-MKK Thu Aug 26 17:37:07 2004.BEGIN |
203 | if(aNbCPrts != 0) { |
204 | char buf[512]; |
205 | |
206 | if(!aShrunkRange.IsDone()) { |
207 | sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); |
208 | throw BOPTColStd_Failure(buf) ; |
209 | } |
210 | } |
211 | // modified by NIZHNY-MKK Thu Aug 26 17:37:09 2004.END |
212 | |
213 | for (i=1; i<=aNbCPrts; i++) { |
214 | const IntTools_CommonPrt& aCPart=aCPrts.Value(i); |
215 | // |
216 | anIndexIn=0; |
217 | // |
218 | TopAbs_ShapeEnum aType=aCPart.Type(); |
219 | switch (aType) { |
220 | |
221 | case TopAbs_VERTEX: { |
222 | |
223 | Standard_Real aT; |
224 | Standard_Integer aNewShape; |
225 | |
226 | const IntTools_Range& aR=aCPart.Range1(); |
227 | |
228 | Standard_Real aRFirst, aRLast; |
229 | |
230 | aR.Range(aRFirst, aRLast); |
231 | aT=0.5*(aRFirst+aRLast); |
232 | |
233 | if((aCPart.VertexParameter1() >= aRFirst) && |
234 | (aCPart.VertexParameter1() <= aRLast)) { |
235 | aT = aCPart.VertexParameter1(); |
236 | } |
237 | |
238 | TopoDS_Vertex aNewVertex; |
239 | BOPTools_Tools::MakeNewVertex(aE, aT, aF,aNewVertex); |
240 | // |
241 | Standard_Boolean isonpave1, isonpave2; |
242 | Standard_Real aTolToDecide; |
243 | aTolToDecide=5.e-8; |
244 | |
245 | // modified by NIZHNY-IFV Feb 15 2007 |
246 | // for occ11565 |
247 | //Check that whole edge belongs face |
248 | isonpave1 = (Abs(anewSR.First() - aRFirst) < aTolToDecide); |
249 | isonpave2 = (Abs(anewSR.Last() - aRLast) < aTolToDecide); |
250 | //++ |
251 | if(isonpave1 && isonpave2) { |
252 | //Seems whole edge belongs face |
253 | |
254 | Standard_Boolean aCoinsideFlag = |
255 | BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); |
256 | if (aCoinsideFlag) { |
257 | // |
258 | // Add Interference to the Pool |
259 | |
260 | IntTools_CommonPrt aCP = aCPart; |
261 | aCP.SetType(TopAbs_EDGE); |
262 | BOPTools_ESInterference anInterf (nE, nF, aCP); |
263 | anIndexIn=aEFs.Append(anInterf); |
264 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
265 | // |
266 | BOPTools_CommonBlock aCB(aPB, nF); |
267 | |
268 | aLCB.Append(aCB); |
269 | break; |
270 | } |
271 | } |
272 | // modified by NIZHNY-IFV Feb 15 2007. end |
273 | // |
274 | //decide to add pave or not.begin |
275 | isonpave1 = (Abs(anewSR.First() - aT) < aTolToDecide); |
276 | isonpave2 = (Abs(anewSR.Last() - aT) < aTolToDecide); |
277 | |
278 | // modified by NIZHNY-MKK Wed Nov 6 14:43:07 2002.BEGIN |
279 | if(!isonpave1 && !isonpave2) { |
280 | isonpave1 = (Abs(anewSR.First() - aR.First()) < aTolToDecide); |
281 | isonpave2 = (Abs(anewSR.Last() - aR.Last()) < aTolToDecide); |
282 | } |
283 | // modified by NIZHNY-MKK Wed Nov 6 14:43:11 2002.END |
284 | //++ |
285 | { |
286 | Standard_Integer nVP1, nVP2; |
287 | Standard_Boolean bIsComputed; |
288 | |
289 | // Pave 1 |
290 | const BOPTools_Pave& aPave1=aPB.Pave1(); |
291 | nVP1=aPave1.Index(); |
292 | |
293 | bIsComputed=Standard_True; |
294 | if (nVP1 <= myNbSources) { |
295 | |
296 | if(((nVP1 <= myDS->NumberOfShapesOfTheObject()) && |
297 | (nF <= myDS->NumberOfShapesOfTheObject())) || |
298 | ((nVP1 > myDS->NumberOfShapesOfTheObject()) && |
299 | (nF > myDS->NumberOfShapesOfTheObject()))) { |
300 | bIsComputed=myIntrPool->IsComputed(nVP1, nE); |
301 | |
302 | if (!bIsComputed) { |
303 | bIsComputed=IsSuccesstorsComputed(nVP1, nE); |
304 | } |
305 | } |
306 | else { |
307 | bIsComputed=myIntrPool->IsComputed(nVP1, nF); |
308 | if (!bIsComputed) { |
309 | bIsComputed=IsSuccesstorsComputed(nVP1, nF); |
310 | } |
311 | } |
312 | } |
313 | |
314 | if (bIsComputed && isonpave1) { |
315 | // |
316 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
317 | const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP1)); |
318 | BOPTools_Tools::UpdateVertex(aE, aT, aVF); |
319 | continue; |
320 | } |
321 | // Pave 2 |
322 | const BOPTools_Pave& aPave2=aPB.Pave2(); |
323 | nVP2=aPave2.Index(); |
324 | |
325 | bIsComputed=Standard_True; |
326 | if (nVP2 <= myNbSources) { |
327 | |
328 | if((nVP2 <= myDS->NumberOfShapesOfTheObject() && |
329 | nF <= myDS->NumberOfShapesOfTheObject()) || |
330 | (nVP2 > myDS->NumberOfShapesOfTheObject() && |
331 | nF > myDS->NumberOfShapesOfTheObject())) { |
332 | bIsComputed=myIntrPool->IsComputed(nVP2, nE); |
333 | |
334 | if (!bIsComputed) { |
335 | bIsComputed=IsSuccesstorsComputed(nVP2, nE); |
336 | } |
337 | } |
338 | else { |
339 | bIsComputed=myIntrPool->IsComputed(nVP2, nF); |
340 | if (!bIsComputed) { |
341 | bIsComputed=IsSuccesstorsComputed(nVP2, nF); |
342 | } |
343 | } |
344 | } |
345 | |
346 | if (bIsComputed && isonpave2) { |
347 | // |
348 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
349 | const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP2)); |
350 | BOPTools_Tools::UpdateVertex(aE, aT, aVF); |
351 | continue; |
352 | } |
353 | } |
354 | //decide to add pave or not.end |
355 | // |
356 | // Insert New Vertex in DS; |
357 | // aNewShape is # of DS-line, where aNewVertex is kept |
358 | // |
359 | BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; |
360 | // |
361 | Standard_Integer nVF, iFlag; |
362 | nVF=CheckFacePaves(aNewVertex, nF); |
363 | if (nVF) { |
364 | const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); |
365 | |
366 | Standard_Real aTNew; |
367 | // |
4f189102 |
368 | iFlag=myContext->ComputeVE(aVF, aE, aTNew); |
7fd59977 |
369 | // |
370 | aT=aTNew; |
371 | aNewShape=nVF; |
372 | BOPTools_Tools::UpdateVertex(aVF, aNewVertex); |
373 | } |
374 | // |
375 | else { |
376 | myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); |
377 | aNewShape=myDS->NumberOfInsertedShapes(); |
378 | } |
379 | // |
380 | // Add Interference to the Pool |
381 | BOPTools_ESInterference anInterf (nE, nF, aCPart); |
382 | anIndexIn=aEFs.Append(anInterf); |
383 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
384 | // |
385 | // State of the new Vertex is ON |
386 | myDS->SetState (aNewShape, BooleanOperations_ON); |
387 | // |
388 | // Insert New Vertex in EE Interference |
389 | BOPTools_ESInterference& aESInterf= aEFs(anIndexIn); |
390 | aESInterf.SetNewShape(aNewShape); |
391 | // |
392 | // Add Pave to the myPavePoolNew |
393 | BOPTools_Pave aPave; |
394 | aPave.SetInterference(anIndexIn); |
395 | aPave.SetType (BooleanOperations_EdgeSurface); |
396 | aPave.SetIndex(aNewShape); |
397 | |
398 | aPave.SetParam(aT); |
399 | BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); |
400 | aPaveSet.Append(aPave); |
401 | |
402 | }// case TopAbs_VERTEX: |
403 | break; |
404 | |
405 | case TopAbs_EDGE: { |
406 | |
407 | Standard_Boolean aCoinsideFlag; |
408 | aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); |
409 | if (!aCoinsideFlag) { |
410 | // |
411 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
412 | break; |
413 | } |
414 | // Add Interference to the Pool |
415 | BOPTools_ESInterference anInterf (nE, nF, aCPart); |
416 | anIndexIn=aEFs.Append(anInterf); |
417 | myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); |
418 | // |
419 | BOPTools_CommonBlock aCB(aPB, nF); |
420 | |
421 | aLCB.Append(aCB); |
422 | |
423 | }// case TopAbs_EDGE: |
424 | break; |
425 | |
426 | default: |
427 | break; |
428 | } // switch (aType) |
429 | } // for (i=1; i<=aNbCPrts; i++) |
430 | } //if (aEF.IsDone()) |
431 | } // for (; anIt.More(); anIt.Next()) |
432 | }// for (; myDSIt.More(); myDSIt.Next()) |
433 | myIsDone=Standard_True; |
434 | } |
435 | |
436 | |
437 | //======================================================================= |
438 | // function: DoSDEdges |
439 | // purpose: |
440 | //======================================================================= |
441 | void BOPTools_PaveFiller::DoSDEdges() |
442 | { |
443 | myIsDone=Standard_False; |
444 | |
445 | Standard_Integer aNbObj, nEObj, nETool, aSplitIndexObj, aSplitIndexTool; |
446 | TopAbs_ShapeEnum aType; |
447 | |
448 | aNbObj=myDS->NumberOfShapesOfTheObject(); |
449 | |
450 | for (nEObj=1; nEObj<=aNbObj; nEObj++) { |
451 | // modified by NIZHNY-MKK Thu Oct 27 12:32:37 2005 |
452 | // const TopoDS_Shape& aS=myDS->GetShape(nEObj); |
453 | TopoDS_Shape aS=myDS->GetShape(nEObj); |
454 | aType=aS.ShapeType(); |
455 | if (aType==TopAbs_EDGE) { |
456 | //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nEObj)); |
457 | |
458 | BOPTools_ListOfCommonBlock& aLCBObj=myCommonBlockPool(myDS->RefEdge(nEObj)); |
459 | BOPTools_ListIteratorOfListOfCommonBlock anItCBObj(aLCBObj); |
460 | for (; anItCBObj.More(); anItCBObj.Next()) { |
461 | BOPTools_CommonBlock& aCBObj=anItCBObj.Value(); |
462 | |
463 | if (aCBObj.Face()) { |
464 | continue; |
465 | } |
466 | |
467 | BOPTools_PaveBlock& aPBObj1=aCBObj.PaveBlock1(nEObj); |
468 | BOPTools_PaveBlock& aPBObj2=aCBObj.PaveBlock2(nEObj); |
469 | // |
470 | // Tool |
471 | nETool=aPBObj2.OriginalEdge(); |
472 | |
473 | BOPTools_ListOfCommonBlock& aLCBTool=myCommonBlockPool(myDS->RefEdge(nETool)); |
474 | BOPTools_ListIteratorOfListOfCommonBlock anItCBTool(aLCBTool); |
475 | for (; anItCBTool.More(); anItCBTool.Next()) { |
476 | BOPTools_CommonBlock& aCBTool=anItCBTool.Value(); |
477 | |
478 | BOPTools_PaveBlock& aPBTool1=aCBTool.PaveBlock1(nETool); |
479 | BOPTools_PaveBlock& aPBTool2=aCBTool.PaveBlock2(nETool); |
480 | |
481 | if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) { |
482 | // |
483 | // That is aCBObj==aCBTool |
484 | // Find SplitIndices in DS for aPBObj1 and aPBTool1 |
485 | aSplitIndexObj =SplitIndex(aPBObj1); |
486 | aSplitIndexTool=SplitIndex(aPBTool1); |
487 | if (aSplitIndexObj && aSplitIndexTool) { |
488 | |
489 | aPBObj1. SetEdge(aSplitIndexObj); |
490 | aPBObj2. SetEdge(aSplitIndexTool); |
491 | aPBTool1.SetEdge(aSplitIndexTool); |
492 | aPBTool2.SetEdge(aSplitIndexObj); |
493 | break; |
494 | } |
495 | else { |
496 | //error: can not find SplitIndex |
497 | throw |
498 | BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex"); |
499 | |
500 | myIsDone=Standard_False; |
501 | return; |
502 | } |
503 | |
504 | } // if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) |
505 | } // for (; anItCBTool.More(); anItCBTool.Next()) |
506 | } // for (; anItCBObj.More(); anItCBObj.Next()) |
507 | } // if (aType==TopAbs_EDGE) |
508 | } // for (nEObj=1; nEObj<=aNbObj; nEObj++) |
509 | |
510 | // |
511 | // 2. EF CommonBlocks |
512 | // |
513 | Standard_Integer nE, aSplitIndex; |
514 | for (nE=1; nE<=myNbSources; nE++) { |
515 | // modified by NIZHNY-MKK Thu Oct 27 12:32:57 2005 |
516 | // const TopoDS_Shape& aS=myDS->GetShape(nE); |
517 | TopoDS_Shape aS=myDS->GetShape(nE); |
518 | aType=aS.ShapeType(); |
519 | if (aType==TopAbs_EDGE) { |
520 | //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); |
521 | |
522 | BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); |
523 | BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); |
524 | |
525 | for (; anItCB.More(); anItCB.Next()) { |
526 | BOPTools_CommonBlock& aCB=anItCB.Value(); |
527 | if (aCB.Face()) { |
528 | BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE); |
529 | aSplitIndex =SplitIndex(aPB); |
530 | if (aSplitIndex) { |
531 | aPB.SetEdge(aSplitIndex); |
532 | //break; |
533 | } |
534 | else { |
535 | //error: can not find SplitIndex |
536 | throw |
537 | BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex"); |
538 | myIsDone=Standard_False; |
539 | return; |
540 | } |
541 | } |
542 | } |
543 | } |
544 | } |
545 | myIsDone=Standard_True; |
546 | } |
547 | |
548 | //======================================================================= |
549 | // function: SplitIndex |
550 | // purpose: |
551 | //======================================================================= |
552 | Standard_Integer BOPTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx) |
553 | { |
554 | Standard_Integer anOriginalEdge, anEdgeIndex=0; |
555 | |
556 | anOriginalEdge=aPBx.OriginalEdge(); |
557 | |
558 | BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge)); |
559 | BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); |
560 | |
561 | for (; anIt.More(); anIt.Next()) { |
562 | BOPTools_PaveBlock& aPB=anIt.Value(); |
563 | if (aPB.IsEqual(aPBx)) { |
564 | anEdgeIndex=aPB.Edge(); |
565 | return anEdgeIndex; |
566 | } |
567 | } |
568 | return anEdgeIndex; |
569 | } |
570 | //======================================================================= |
571 | // function: CheckFacePaves |
572 | // purpose: |
573 | //======================================================================= |
574 | Standard_Integer BOPTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex, |
575 | const Standard_Integer nF) |
576 | { |
577 | Standard_Integer nEF, nVF, iFlag; |
578 | BOPTools_ListIteratorOfListOfPave anIt; |
579 | // 1. |
580 | BooleanOperations_OnceExplorer aExp(*myDS); |
581 | aExp.Init(nF, TopAbs_EDGE); |
582 | for (; aExp.More(); aExp.Next()) { |
583 | nEF=aExp.Current(); |
584 | BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nEF)); |
585 | const BOPTools_ListOfPave& aLP=aPaveSet.Set(); |
586 | anIt.Initialize(aLP); |
587 | for (; anIt.More(); anIt.Next()) { |
588 | const BOPTools_Pave& aPave=anIt.Value(); |
589 | nVF=aPave.Index(); |
590 | const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); |
591 | iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); |
592 | if (!iFlag) { |
593 | return nVF; |
594 | } |
595 | } |
596 | } |
597 | // |
598 | // 2. |
599 | aExp.Init(nF, TopAbs_EDGE); |
600 | for (; aExp.More(); aExp.Next()) { |
601 | nEF=aExp.Current(); |
602 | BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF)); |
603 | const BOPTools_ListOfPave& aLP=aPaveSet.Set(); |
604 | anIt.Initialize(aLP); |
605 | for (; anIt.More(); anIt.Next()) { |
606 | const BOPTools_Pave& aPave=anIt.Value(); |
607 | nVF=aPave.Index(); |
608 | const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); |
609 | iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); |
610 | if (!iFlag) { |
611 | return nVF; |
612 | } |
613 | } |
614 | } |
615 | |
616 | return 0; |
617 | } |
618 | // |
619 | |
620 | |