b311480e |
1 | // Created on: 1993-06-14 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <Standard_NoSuchObject.hxx> |
19 | #include <Standard_ProgramError.hxx> |
20 | #include <Standard_Type.hxx> |
21 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
22 | #include <TColStd_MapOfInteger.hxx> |
23 | #include <TopoDS.hxx> |
24 | #include <TopoDS_Shape.hxx> |
25 | #include <TopOpeBRepBuild_Builder.hxx> |
26 | #include <TopOpeBRepBuild_define.hxx> |
27 | #include <TopOpeBRepBuild_HBuilder.hxx> |
28 | #include <TopOpeBRepDS_BuildTool.hxx> |
7fd59977 |
29 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
42cf5bc1 |
30 | #include <TopOpeBRepDS_CurveIterator.hxx> |
31 | #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State.hxx> |
32 | #include <TopOpeBRepDS_HDataStructure.hxx> |
7fd59977 |
33 | #include <TopOpeBRepDS_Interference.hxx> |
42cf5bc1 |
34 | #include <TopOpeBRepDS_ListOfShapeOn1State.hxx> |
7fd59977 |
35 | #include <TopOpeBRepDS_ShapeShapeInterference.hxx> |
7fd59977 |
36 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
42cf5bc1 |
37 | #include <TopTools_ListOfShape.hxx> |
7fd59977 |
38 | #include <TopTools_MapOfShape.hxx> |
7fd59977 |
39 | |
25e59720 |
40 | IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRepBuild_HBuilder,Standard_Transient) |
92efcf78 |
41 | |
7fd59977 |
42 | //======================================================================= |
43 | //function : TopOpeBRepBuild_HBuilder |
44 | //purpose : |
45 | //======================================================================= |
46 | TopOpeBRepBuild_HBuilder::TopOpeBRepBuild_HBuilder |
47 | (const TopOpeBRepDS_BuildTool& BT) |
48 | : myBuilder(BT), |
49 | myMakeEdgeAncestorIsDone(Standard_False), |
50 | myMakeCurveAncestorIsDone(Standard_False), |
51 | myMakePointAncestorIsDone(Standard_False) |
52 | { |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : Perform |
57 | //purpose : |
58 | //======================================================================= |
59 | void TopOpeBRepBuild_HBuilder::Perform |
60 | (const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
61 | { |
62 | myBuilder.Perform(HDS); |
63 | } |
64 | |
65 | //======================================================================= |
66 | //function : Perform |
67 | //purpose : |
68 | //======================================================================= |
69 | void TopOpeBRepBuild_HBuilder::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const TopoDS_Shape& S1, const TopoDS_Shape& S2) |
70 | { |
71 | myBuilder.Perform(HDS,S1,S2); |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : Clear |
76 | //purpose : |
77 | //======================================================================= |
78 | void TopOpeBRepBuild_HBuilder::Clear() |
79 | { |
80 | myBuilder.Clear(); |
81 | InitExtendedSectionDS(); |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : DataStructure |
86 | //purpose : |
87 | //======================================================================= |
88 | Handle(TopOpeBRepDS_HDataStructure) TopOpeBRepBuild_HBuilder::DataStructure() const |
89 | { |
90 | return myBuilder.DataStructure(); |
91 | } |
92 | |
93 | //======================================================================= |
94 | //function : ChangeBuildTool |
95 | //purpose : |
96 | //======================================================================= |
97 | TopOpeBRepDS_BuildTool& TopOpeBRepBuild_HBuilder::ChangeBuildTool() |
98 | { |
99 | TopOpeBRepDS_BuildTool& BT = myBuilder.ChangeBuildTool(); |
100 | return BT; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : BuildTool |
105 | //purpose : |
106 | //======================================================================= |
107 | const TopOpeBRepDS_BuildTool& TopOpeBRepBuild_HBuilder::BuildTool() const |
108 | { |
109 | return myBuilder.BuildTool(); |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : MergeShapes |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | void TopOpeBRepBuild_HBuilder::MergeShapes |
118 | (const TopoDS_Shape& S1, const TopAbs_State ToBuild1,const TopoDS_Shape& S2, const TopAbs_State ToBuild2) |
119 | { |
120 | myBuilder.MergeShapes(S1,ToBuild1,S2,ToBuild2); |
121 | } |
122 | |
123 | |
124 | //======================================================================= |
125 | //function : MergeSolids |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | void TopOpeBRepBuild_HBuilder::MergeSolids |
130 | (const TopoDS_Shape& S1, const TopAbs_State ToBuild1,const TopoDS_Shape& S2, const TopAbs_State ToBuild2) |
131 | { |
132 | myBuilder.MergeSolids(S1,ToBuild1,S2,ToBuild2); |
133 | } |
134 | |
135 | |
136 | //======================================================================= |
137 | //function : MergeSolid |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | void TopOpeBRepBuild_HBuilder::MergeSolid(const TopoDS_Shape& S, const TopAbs_State ToBuild) |
142 | { |
143 | myBuilder.MergeSolid(S,ToBuild); |
144 | } |
145 | |
146 | |
147 | //======================================================================= |
148 | //function : IsSplit |
149 | //purpose : |
150 | //======================================================================= |
151 | Standard_Boolean TopOpeBRepBuild_HBuilder::IsSplit(const TopoDS_Shape& S, const TopAbs_State ToBuild) const |
152 | { |
153 | Standard_Boolean res = myBuilder.IsSplit(S,ToBuild); |
154 | return res; |
155 | } |
156 | |
157 | |
158 | //======================================================================= |
159 | //function : Splits |
160 | //purpose : |
161 | //======================================================================= |
162 | const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Splits(const TopoDS_Shape& S, const TopAbs_State ToBuild) const |
163 | { |
164 | const TopTools_ListOfShape& L = myBuilder.Splits(S,ToBuild); |
165 | return L; |
166 | } |
167 | |
168 | |
169 | //======================================================================= |
170 | //function : IsMerged |
171 | //purpose : |
172 | //======================================================================= |
173 | |
174 | Standard_Boolean TopOpeBRepBuild_HBuilder::IsMerged(const TopoDS_Shape& S, const TopAbs_State ToBuild) const |
175 | { |
176 | Standard_Boolean res = myBuilder.IsMerged(S,ToBuild); |
177 | return res; |
178 | } |
179 | |
180 | |
181 | //======================================================================= |
182 | //function : Merged |
183 | //purpose : |
184 | //======================================================================= |
185 | |
186 | const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Merged(const TopoDS_Shape& S, const TopAbs_State ToBuild) const |
187 | { |
188 | const TopTools_ListOfShape& L = myBuilder.Merged(S,ToBuild); |
189 | return L; |
190 | } |
191 | |
192 | |
193 | //======================================================================= |
194 | //function : NewVertex |
195 | //purpose : |
196 | //======================================================================= |
197 | const TopoDS_Shape& TopOpeBRepBuild_HBuilder::NewVertex(const Standard_Integer I) const |
198 | { |
199 | const TopoDS_Shape& V = myBuilder.NewVertex(I); |
200 | return V; |
201 | } |
202 | |
203 | |
204 | //======================================================================= |
205 | //function : NewEdges |
206 | //purpose : |
207 | //======================================================================= |
208 | const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::NewEdges(const Standard_Integer I) const |
209 | { |
210 | const TopTools_ListOfShape& L = myBuilder.NewEdges(I); |
211 | return L; |
212 | } |
213 | |
214 | //======================================================================= |
215 | //function : ChangeNewEdges |
216 | //purpose : |
217 | //======================================================================= |
218 | TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::ChangeNewEdges(const Standard_Integer I) |
219 | { |
220 | TopTools_ListOfShape& L = myBuilder.ChangeNewEdges(I); |
221 | return L; |
222 | } |
223 | |
224 | |
225 | //======================================================================= |
226 | //function : NewFaces |
227 | //purpose : |
228 | //======================================================================= |
229 | const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::NewFaces(const Standard_Integer I) const |
230 | { |
231 | const TopTools_ListOfShape& L = myBuilder.NewFaces(I); |
232 | return L; |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : Section |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Section() |
242 | { |
243 | const TopTools_ListOfShape& L = myBuilder.Section(); |
244 | return L; |
245 | } |
246 | |
247 | static TopTools_ListOfShape* PLE = NULL; |
248 | static TopTools_ListIteratorOfListOfShape* PITLE = NULL; |
249 | //======================================================================= |
250 | //function : InitExtendedSectionDS |
251 | //purpose : |
252 | //======================================================================= |
253 | |
254 | void TopOpeBRepBuild_HBuilder::InitExtendedSectionDS(const Standard_Integer k) |
255 | { |
256 | if (k == 1) { |
257 | myMakeCurveAncestorIsDone = Standard_False; |
258 | } |
259 | else if (k == 2) { |
260 | myMakeEdgeAncestorIsDone = Standard_False; |
261 | } |
262 | else if (k == 3) { |
263 | myMakeEdgeAncestorIsDone = Standard_False; |
264 | myMakeCurveAncestorIsDone = Standard_False; |
265 | } |
266 | else return; |
267 | } |
268 | |
269 | //======================================================================= |
270 | //function : InitSection |
271 | //purpose : |
272 | //======================================================================= |
273 | |
274 | void TopOpeBRepBuild_HBuilder::InitSection(const Standard_Integer k) |
275 | { |
276 | if (PLE == NULL) PLE = new TopTools_ListOfShape(); |
277 | if (PITLE == NULL) PITLE = new TopTools_ListIteratorOfListOfShape(); |
278 | PLE->Clear(); PITLE->Initialize(*PLE); |
279 | InitExtendedSectionDS(k); |
280 | if (k == 1) myBuilder.SectionCurves(*PLE); |
281 | else if (k == 2) myBuilder.SectionEdges(*PLE); |
282 | else if (k == 3) myBuilder.Section(*PLE); |
283 | else return; |
284 | PITLE->Initialize(*PLE); |
285 | } |
286 | |
287 | //======================================================================= |
288 | //function : MoreSection |
289 | //purpose : |
290 | //======================================================================= |
291 | |
292 | Standard_Boolean TopOpeBRepBuild_HBuilder::MoreSection() const |
293 | { |
294 | if (PITLE == NULL) return Standard_False; |
295 | Standard_Boolean b = PITLE->More(); |
296 | return b; |
297 | } |
298 | |
299 | //======================================================================= |
300 | //function : NextSection |
301 | //purpose : |
302 | //======================================================================= |
303 | |
304 | void TopOpeBRepBuild_HBuilder::NextSection() |
305 | { |
306 | if (PITLE == NULL) return; |
307 | if (PITLE->More()) PITLE->Next(); |
308 | } |
309 | |
310 | //======================================================================= |
311 | //function : CurrentSection |
312 | //purpose : |
313 | //======================================================================= |
314 | |
315 | const TopoDS_Shape& TopOpeBRepBuild_HBuilder::CurrentSection() const |
316 | { |
9775fa61 |
317 | if (PITLE == NULL) throw Standard_ProgramError("no more CurrentSection"); |
318 | if (!PITLE->More()) throw Standard_ProgramError("no more CurrentSection"); |
7fd59977 |
319 | return PITLE->Value(); |
320 | } |
321 | |
322 | //======================================================================= |
323 | //function : MakeEdgeAncestorMap |
324 | //purpose : private |
325 | //======================================================================= |
326 | |
327 | void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap() |
328 | { |
329 | if(myMakeEdgeAncestorIsDone) |
330 | return; |
331 | mySectEdgeDSEdges1.Clear(); |
332 | mySectEdgeDSEdges2.Clear(); |
333 | myDSEdgesDSFaces1.Clear(); |
334 | myDSEdgesDSFaces2.Clear(); |
335 | |
336 | myMakeEdgeAncestorIsDone = Standard_True; |
337 | TopTools_MapOfShape MF, ME; |
338 | |
339 | const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); |
340 | // Standard_Integer ns = DS.NbShapes(),is; |
341 | Standard_Integer ns = DS.NbShapes(); |
342 | // Standard_Integer ei, fi, re, rf ,gi, ise; |
343 | Standard_Integer ei, fi, re, rf ,gi; |
344 | |
345 | TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State |
346 | it(myBuilder.mySplitON); |
347 | TopTools_ListIteratorOfListOfShape its; |
348 | for(;it.More(); it.Next()) { |
349 | const TopoDS_Shape& ShaSpl = it.Key(); |
350 | ei = DS.Shape(ShaSpl); |
351 | re = DS.AncestorRank(ShaSpl); |
352 | if(!re) continue; |
353 | TopOpeBRepDS_ListOfShapeOn1State& losos1s = |
354 | (*(TopOpeBRepDS_ListOfShapeOn1State*)&it.Value()); |
355 | TopTools_ListOfShape& los = losos1s.ChangeListOnState(); |
356 | its.Initialize(los); |
357 | if(re == 1) |
358 | for(; its.More(); its.Next()) { |
359 | TopoDS_Shape& SecEdg = its.Value(); |
360 | if(!mySectEdgeDSEdges1.IsBound(SecEdg)) |
361 | mySectEdgeDSEdges1.Bind(SecEdg, ei); |
362 | } |
363 | else if(re == 2) |
364 | for(; its.More(); its.Next()) { |
365 | TopoDS_Shape& SecEdg = its.Value(); |
366 | if(!mySectEdgeDSEdges2.IsBound(SecEdg)) |
367 | mySectEdgeDSEdges2.Bind(SecEdg,ei); |
368 | } |
369 | } |
370 | |
371 | // Standard_Boolean gb; |
372 | TopOpeBRepDS_Kind gk; |
373 | for (fi=1;fi<=ns;fi++) { |
374 | const TopoDS_Shape& fds = DS.Shape(fi); |
375 | if(fds.IsNull()) |
376 | continue; |
377 | if (fds.ShapeType() != TopAbs_FACE) continue; |
378 | TopOpeBRepDS_ListIteratorOfListOfInterference |
379 | it1(DS.ShapeInterferences(fds)); |
380 | for (;it1.More();it1.Next()) { |
381 | Handle(TopOpeBRepDS_ShapeShapeInterference) SSI = |
382 | Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(it1.Value()); |
383 | if (SSI.IsNull()) continue; |
384 | gk = SSI->GeometryType(); |
385 | gi = SSI->Geometry(); |
386 | if (gk != TopOpeBRepDS_EDGE) continue; |
387 | rf = DS.AncestorRank(fds); |
388 | if(!rf) continue; |
389 | // if (!MF.Contains(fds) ) { |
390 | // MF.Add(fds); |
391 | if(rf == 1) { |
392 | if(!myDSEdgesDSFaces1.IsBound(gi)) { |
393 | TColStd_ListOfInteger thelist; |
394 | myDSEdgesDSFaces1.Bind(gi,thelist ); |
395 | } |
396 | myDSEdgesDSFaces1.ChangeFind(gi).Append(fi); |
397 | } |
398 | else if(rf == 2) { |
399 | if(!myDSEdgesDSFaces2.IsBound(gi)){ |
400 | TColStd_ListOfInteger thelist1; |
401 | myDSEdgesDSFaces2.Bind(gi, thelist1); |
402 | } |
403 | myDSEdgesDSFaces2.ChangeFind(gi).Append(fi); |
404 | } |
405 | // } |
406 | } |
407 | } |
408 | } |
409 | |
410 | //======================================================================= |
411 | //function : GetDSEdgeFromSectEdge |
412 | //purpose : |
413 | //======================================================================= |
414 | Standard_Integer TopOpeBRepBuild_HBuilder::GetDSEdgeFromSectEdge(const TopoDS_Shape& E,const Standard_Integer rank) |
415 | { |
416 | if(!myMakeEdgeAncestorIsDone) |
417 | MakeEdgeAncestorMap(); |
418 | |
419 | Standard_Integer i = 0; |
420 | |
421 | if(rank == 1) { |
422 | if(mySectEdgeDSEdges1.IsBound(E)) |
423 | i = mySectEdgeDSEdges1.Find(E); |
424 | } |
425 | |
426 | if(rank == 2) { |
427 | if(mySectEdgeDSEdges2.IsBound(E)) |
428 | i = mySectEdgeDSEdges2.Find(E); |
429 | } |
430 | return i; |
431 | } |
432 | |
433 | //======================================================================= |
434 | //function : GetDSFaceFromDSEdge |
435 | //purpose : |
436 | //======================================================================= |
437 | TColStd_ListOfInteger& TopOpeBRepBuild_HBuilder::GetDSFaceFromDSEdge |
438 | (const Standard_Integer indexEdg, const Standard_Integer rank) |
439 | { |
440 | if(!myMakeEdgeAncestorIsDone) |
441 | MakeEdgeAncestorMap(); |
442 | |
443 | if(rank == 1) { |
444 | if(myDSEdgesDSFaces1.IsBound(indexEdg)) { |
445 | TColStd_ListOfInteger& loi = |
446 | myDSEdgesDSFaces1.ChangeFind(indexEdg); |
447 | return loi; |
448 | } |
449 | } |
450 | |
451 | if(rank == 2) { |
452 | if(myDSEdgesDSFaces2.IsBound(indexEdg)) { |
453 | TColStd_ListOfInteger& loi = |
454 | myDSEdgesDSFaces2.ChangeFind(indexEdg); |
455 | return loi; |
456 | } |
457 | } |
458 | |
459 | return myEmptyIntegerList; |
460 | } |
461 | |
462 | //======================================================================= |
463 | //function : MakeCurveAncestorMap |
464 | //purpose : |
465 | //======================================================================= |
466 | |
467 | void TopOpeBRepBuild_HBuilder::MakeCurveAncestorMap() |
468 | { |
469 | if(myMakeCurveAncestorIsDone) |
470 | return; |
471 | mySectEdgeDSCurve.Clear(); |
472 | myMakeCurveAncestorIsDone = Standard_True; |
7fd59977 |
473 | const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); |
7fd59977 |
474 | TopTools_ListIteratorOfListOfShape itloe; |
475 | TopOpeBRepDS_CurveExplorer cex(DS,Standard_True); |
476 | // Standard_Integer ic, icm; |
477 | Standard_Integer ic; |
478 | for (; cex.More(); cex.Next()) { |
479 | ic = cex.Index(); |
480 | const TopTools_ListOfShape& LOS = myBuilder.myNewEdges.Find(ic); |
481 | itloe.Initialize(LOS); |
482 | for(;itloe.More();itloe.Next()) { |
483 | TopoDS_Shape& E = *((TopoDS_Shape*)(&itloe.Value())); |
7fd59977 |
484 | mySectEdgeDSCurve.Bind(E, ic); |
485 | } |
486 | } |
487 | } |
488 | |
489 | //======================================================================= |
490 | //function : GetDSCurveFromSectEdge |
491 | //purpose : |
492 | //======================================================================= |
493 | |
494 | Standard_Integer TopOpeBRepBuild_HBuilder::GetDSCurveFromSectEdge(const TopoDS_Shape& SectEdge) |
495 | { |
496 | Standard_Integer i = 0; |
497 | if(!myMakeCurveAncestorIsDone) |
498 | MakeCurveAncestorMap(); |
499 | |
500 | if(mySectEdgeDSCurve.IsBound(SectEdge)) { |
501 | i = mySectEdgeDSCurve.Find(SectEdge); |
502 | } |
503 | return i; |
504 | } |
505 | |
506 | //======================================================================= |
507 | //function : GetDSFaceFromDSCurve |
508 | //purpose : |
509 | //======================================================================= |
510 | |
511 | Standard_Integer TopOpeBRepBuild_HBuilder::GetDSFaceFromDSCurve(const Standard_Integer indexCur,const Standard_Integer rank) |
512 | { |
513 | Standard_Integer i = 0; |
514 | if(!myMakeCurveAncestorIsDone) |
515 | MakeCurveAncestorMap(); |
516 | |
517 | const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); |
518 | if(rank == 1) { |
519 | const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur); |
520 | const TopoDS_Shape& F1 = DSC.Shape1(); |
521 | i = DS.Shape(F1); |
522 | } |
523 | |
524 | if(rank == 2) { |
525 | const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur); |
526 | const TopoDS_Shape& F2 = DSC.Shape2(); |
527 | i = DS.Shape(F2); |
528 | } |
529 | |
530 | return i; |
531 | } |
532 | |
533 | //======================================================================= |
534 | //function : GetDSPointFromNewVertex |
535 | //purpose : |
536 | //======================================================================= |
537 | |
538 | Standard_Integer TopOpeBRepBuild_HBuilder::GetDSPointFromNewVertex(const TopoDS_Shape& NewVert) |
539 | { |
540 | if(!myMakePointAncestorIsDone) { |
541 | myMakePointAncestorIsDone = Standard_True; |
542 | TopOpeBRepDS_DataStructure& DS = DataStructure()->ChangeDS(); |
543 | Standard_Integer i, NbPoint = DS.NbPoints(); |
544 | for(i = 1; i <= NbPoint; i++) { |
545 | const TopoDS_Shape& Vertex = NewVertex(i); |
546 | if(!Vertex.IsNull()) |
547 | myNewVertexDSPoint.Bind(Vertex, i); |
548 | } |
549 | } |
550 | |
551 | Standard_Integer iPnt = 0; |
552 | if(myNewVertexDSPoint.IsBound(NewVert)) |
553 | iPnt = myNewVertexDSPoint.Find(NewVert); |
554 | return iPnt; |
555 | } |
556 | |
557 | //======================================================================= |
558 | //function : EdgeCurveAncestors |
559 | //purpose : |
560 | //======================================================================= |
561 | |
562 | Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeCurveAncestors(const TopoDS_Shape& E,TopoDS_Shape& F1,TopoDS_Shape& F2,Standard_Integer& IC) |
563 | { |
564 | F1.Nullify(); F2.Nullify(); IC = 0; |
565 | |
566 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = myBuilder.DataStructure(); |
567 | const TopOpeBRepDS_DataStructure& DS = HDS->DS(); |
568 | |
569 | // TopTools_ListIteratorOfListOfShape itloe; |
570 | IC = GetDSCurveFromSectEdge(E); |
571 | if(!IC) |
572 | return Standard_False; |
573 | |
574 | Standard_Integer iF1, iF2; |
575 | iF1 = GetDSFaceFromDSCurve(IC, 1); |
576 | iF2 = GetDSFaceFromDSCurve(IC, 2); |
577 | |
578 | F1 = DS.Shape(iF1); |
579 | F2 = DS.Shape(iF2); |
580 | return Standard_True; |
581 | } |
582 | |
583 | //======================================================================= |
584 | //function : EdgeSectionAncestors |
585 | //purpose : |
586 | //======================================================================= |
587 | |
588 | Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeSectionAncestors |
589 | (const TopoDS_Shape& E, TopTools_ListOfShape& LF1, TopTools_ListOfShape& LF2, TopTools_ListOfShape& LE1, TopTools_ListOfShape& LE2) |
590 | { |
591 | if (E.ShapeType() != TopAbs_EDGE) return Standard_False; |
592 | |
593 | LF1.Clear(); LF2.Clear(); LE1.Clear(); LE2.Clear(); |
594 | TColStd_ListOfInteger f1, f2; |
595 | f1.Clear(); f2.Clear(); |
596 | Standard_Integer ie1, ie2, curr; |
597 | |
598 | ie1 = GetDSEdgeFromSectEdge(E,1); |
599 | ie2 = GetDSEdgeFromSectEdge(E,2); |
600 | TColStd_ListIteratorOfListOfInteger it; |
601 | |
602 | if(ie1 && ie2) { |
603 | TColStd_MapOfInteger moi; |
604 | |
605 | f1 = GetDSFaceFromDSEdge(ie1,1); |
606 | it.Initialize(f1); |
607 | moi.Clear(); |
608 | for(; it.More(); it.Next()) { |
609 | moi.Add(it.Value()); |
610 | } |
611 | it.Initialize(GetDSFaceFromDSEdge(ie2,1)); |
612 | for(; it.More(); it.Next()) { |
613 | curr = it.Value(); |
614 | if(!moi.Contains(curr)) { |
615 | moi.Add(curr); |
616 | f1.Append(curr); |
617 | } |
618 | } |
619 | f2 = GetDSFaceFromDSEdge(ie1,2); |
620 | it.Initialize(f2); |
621 | moi.Clear(); |
622 | for(; it.More(); it.Next()) { |
623 | moi.Add(it.Value()); |
624 | } |
625 | it.Initialize(GetDSFaceFromDSEdge(ie2,2)); |
626 | for(; it.More(); it.Next()) { |
627 | curr = it.Value(); |
628 | if(!moi.Contains(curr)) { |
629 | moi.Add(curr); |
630 | f2.Append(curr); |
631 | } |
632 | } |
633 | } |
634 | else { |
635 | if(ie1) { |
636 | f1 = GetDSFaceFromDSEdge(ie1,1); |
637 | f2 = GetDSFaceFromDSEdge(ie1,2); |
638 | } |
639 | else if(ie2) { |
640 | f1 = GetDSFaceFromDSEdge(ie2,1); |
641 | f2 = GetDSFaceFromDSEdge(ie2,2); |
642 | } |
643 | } |
644 | |
645 | const TopOpeBRepDS_DataStructure& DS = myBuilder.DataStructure()->DS(); |
646 | |
647 | if(ie1) |
648 | LE1.Append(DS.Shape(ie1)); |
649 | if(ie2) |
650 | LE2.Append(DS.Shape(ie2)); |
651 | |
652 | for(it.Initialize(f1); it.More(); it.Next()) { |
653 | curr = it.Value(); |
654 | LF1.Append(DS.Shape(curr)); |
655 | } |
656 | for(it.Initialize(f2); it.More(); it.Next()) { |
657 | curr = it.Value(); |
658 | LF2.Append(DS.Shape(curr)); |
659 | } |
660 | |
661 | Standard_Boolean r = (!LF1.IsEmpty() && !LF2.IsEmpty()); |
662 | r = r && (!LE1.IsEmpty() || !LE2.IsEmpty()); |
663 | return r; |
664 | } |
665 | |
666 | //======================================================================= |
667 | //function : IsKPart |
668 | //purpose : |
669 | //======================================================================= |
670 | |
671 | Standard_Integer TopOpeBRepBuild_HBuilder::IsKPart() |
672 | { |
673 | Standard_Integer kp = myBuilder.IsKPart(); |
674 | return kp; |
675 | } |
676 | |
677 | //======================================================================= |
678 | //function : MergeKPart |
679 | //purpose : |
680 | //======================================================================= |
681 | |
682 | void TopOpeBRepBuild_HBuilder::MergeKPart(const TopAbs_State TB1,const TopAbs_State TB2) |
683 | { |
684 | Standard_Integer kp = IsKPart(); |
685 | if ( kp ) myBuilder.MergeKPart(TB1,TB2); |
686 | } |
687 | |
688 | //======================================================================= |
689 | //function : ChangeBuilder |
690 | //purpose : |
691 | //======================================================================= |
692 | |
693 | TopOpeBRepBuild_Builder& TopOpeBRepBuild_HBuilder::ChangeBuilder() |
694 | { |
695 | return myBuilder; |
696 | } |