0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_HBuilder.cxx
1 // Created on: 1993-06-14
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
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>
29 #include <TopOpeBRepDS_CurveExplorer.hxx>
30 #include <TopOpeBRepDS_CurveIterator.hxx>
31 #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State.hxx>
32 #include <TopOpeBRepDS_HDataStructure.hxx>
33 #include <TopOpeBRepDS_Interference.hxx>
34 #include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
35 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 #include <TopTools_ListOfShape.hxx>
38 #include <TopTools_MapOfShape.hxx>
39
40 IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRepBuild_HBuilder,MMgt_TShared)
41
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 {
317   if (PITLE == NULL) Standard_ProgramError::Raise("no more CurrentSection");
318   if (!PITLE->More()) Standard_ProgramError::Raise("no more CurrentSection");
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;
473   const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
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()));
484       if(mySectEdgeDSCurve.IsBound(E)) {
485 #ifdef OCCT_DEBUG
486         cout<<"BRepAlgo_DSAccess::MakeEdgeAncestorFromCurve : program error"<<endl;
487 #endif
488       }
489       mySectEdgeDSCurve.Bind(E, ic);
490     }
491   }
492 }
493
494 //=======================================================================
495 //function : GetDSCurveFromSectEdge
496 //purpose  : 
497 //=======================================================================
498
499 Standard_Integer TopOpeBRepBuild_HBuilder::GetDSCurveFromSectEdge(const TopoDS_Shape& SectEdge)
500 {
501   Standard_Integer i = 0;
502   if(!myMakeCurveAncestorIsDone)
503     MakeCurveAncestorMap();
504   
505   if(mySectEdgeDSCurve.IsBound(SectEdge)) {
506     i = mySectEdgeDSCurve.Find(SectEdge);
507   }
508   return i;
509 }
510
511 //=======================================================================
512 //function : GetDSFaceFromDSCurve
513 //purpose  : 
514 //=======================================================================
515
516 Standard_Integer TopOpeBRepBuild_HBuilder::GetDSFaceFromDSCurve(const Standard_Integer indexCur,const Standard_Integer rank)
517 {
518   Standard_Integer i = 0;
519   if(!myMakeCurveAncestorIsDone)
520     MakeCurveAncestorMap();
521
522   const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
523   if(rank == 1) {
524     const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur);
525     const TopoDS_Shape& F1 = DSC.Shape1();
526     i = DS.Shape(F1);
527   }
528   
529   if(rank == 2) {
530     const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur);
531     const TopoDS_Shape& F2 = DSC.Shape2();
532     i = DS.Shape(F2);
533   }
534
535   return i;
536 }
537
538 //=======================================================================
539 //function : GetDSPointFromNewVertex
540 //purpose  : 
541 //=======================================================================
542
543 Standard_Integer TopOpeBRepBuild_HBuilder::GetDSPointFromNewVertex(const TopoDS_Shape& NewVert)
544 {
545   if(!myMakePointAncestorIsDone) {
546     myMakePointAncestorIsDone = Standard_True;
547     TopOpeBRepDS_DataStructure& DS = DataStructure()->ChangeDS();
548     Standard_Integer i, NbPoint = DS.NbPoints();
549     for(i = 1; i <= NbPoint; i++) {
550       const TopoDS_Shape& Vertex = NewVertex(i);
551       if(!Vertex.IsNull())
552         myNewVertexDSPoint.Bind(Vertex, i);
553     }
554   }
555   
556   Standard_Integer iPnt = 0;
557   if(myNewVertexDSPoint.IsBound(NewVert))
558     iPnt = myNewVertexDSPoint.Find(NewVert);
559   return iPnt;
560 }
561
562 //=======================================================================
563 //function : EdgeCurveAncestors
564 //purpose  : 
565 //=======================================================================
566
567 Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeCurveAncestors(const TopoDS_Shape& E,TopoDS_Shape& F1,TopoDS_Shape& F2,Standard_Integer& IC)
568 {
569   F1.Nullify(); F2.Nullify(); IC = 0;
570
571   const Handle(TopOpeBRepDS_HDataStructure)& HDS = myBuilder.DataStructure();
572   const TopOpeBRepDS_DataStructure& DS = HDS->DS();
573
574 //  TopTools_ListIteratorOfListOfShape itloe;
575   IC = GetDSCurveFromSectEdge(E);
576   if(!IC)
577     return Standard_False;
578
579   Standard_Integer iF1, iF2;
580   iF1 = GetDSFaceFromDSCurve(IC, 1);
581   iF2 = GetDSFaceFromDSCurve(IC, 2);
582   
583   F1 = DS.Shape(iF1);
584   F2 = DS.Shape(iF2);
585   return Standard_True;
586 }
587
588 //=======================================================================
589 //function : EdgeSectionAncestors
590 //purpose  : 
591 //=======================================================================
592
593 Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeSectionAncestors
594 (const TopoDS_Shape& E, TopTools_ListOfShape& LF1, TopTools_ListOfShape& LF2, TopTools_ListOfShape& LE1, TopTools_ListOfShape& LE2)
595 {
596   if (E.ShapeType() != TopAbs_EDGE) return Standard_False;
597
598   LF1.Clear(); LF2.Clear(); LE1.Clear(); LE2.Clear();
599   TColStd_ListOfInteger f1, f2;
600   f1.Clear(); f2.Clear();
601   Standard_Integer ie1, ie2, curr;
602   
603   ie1 = GetDSEdgeFromSectEdge(E,1);
604   ie2 = GetDSEdgeFromSectEdge(E,2);
605   TColStd_ListIteratorOfListOfInteger it;
606   
607   if(ie1 && ie2) {
608     TColStd_MapOfInteger moi;
609     
610     f1 = GetDSFaceFromDSEdge(ie1,1);
611     it.Initialize(f1);
612     moi.Clear();
613     for(; it.More(); it.Next()) {
614       moi.Add(it.Value());
615     }
616     it.Initialize(GetDSFaceFromDSEdge(ie2,1));
617     for(; it.More(); it.Next()) {
618       curr = it.Value();
619       if(!moi.Contains(curr)) {
620         moi.Add(curr);
621         f1.Append(curr);
622       }
623     }
624     f2 = GetDSFaceFromDSEdge(ie1,2);
625     it.Initialize(f2);
626     moi.Clear();
627     for(; it.More(); it.Next()) {
628       moi.Add(it.Value());
629     }
630     it.Initialize(GetDSFaceFromDSEdge(ie2,2));
631     for(; it.More(); it.Next()) {
632       curr = it.Value();
633       if(!moi.Contains(curr)) {
634         moi.Add(curr);
635         f2.Append(curr);
636       }
637     }
638   }
639   else {
640     if(ie1) {
641       f1 = GetDSFaceFromDSEdge(ie1,1);
642       f2 = GetDSFaceFromDSEdge(ie1,2);
643     }
644     else if(ie2) { 
645       f1 = GetDSFaceFromDSEdge(ie2,1);
646       f2 = GetDSFaceFromDSEdge(ie2,2);
647     }  
648   }
649   
650   const TopOpeBRepDS_DataStructure& DS = myBuilder.DataStructure()->DS();  
651
652   if(ie1)
653     LE1.Append(DS.Shape(ie1));
654   if(ie2)
655     LE2.Append(DS.Shape(ie2));
656
657   for(it.Initialize(f1); it.More(); it.Next()) {
658     curr = it.Value();
659     LF1.Append(DS.Shape(curr));
660   }
661   for(it.Initialize(f2); it.More(); it.Next()) {
662     curr = it.Value();
663     LF2.Append(DS.Shape(curr));
664   }
665   
666   Standard_Boolean r = (!LF1.IsEmpty() && !LF2.IsEmpty());
667   r = r && (!LE1.IsEmpty() || !LE2.IsEmpty());
668   return r;
669 }
670
671 //=======================================================================
672 //function : IsKPart
673 //purpose  : 
674 //=======================================================================
675
676 Standard_Integer TopOpeBRepBuild_HBuilder::IsKPart() 
677 {
678   Standard_Integer kp = myBuilder.IsKPart();
679   return kp;
680 }
681
682 //=======================================================================
683 //function : MergeKPart
684 //purpose  : 
685 //=======================================================================
686
687 void TopOpeBRepBuild_HBuilder::MergeKPart(const TopAbs_State TB1,const TopAbs_State TB2)
688 {
689   Standard_Integer kp = IsKPart();
690   if ( kp ) myBuilder.MergeKPart(TB1,TB2);
691 }
692
693 //=======================================================================
694 //function : ChangeBuilder
695 //purpose  : 
696 //=======================================================================
697
698 TopOpeBRepBuild_Builder& TopOpeBRepBuild_HBuilder::ChangeBuilder()
699 {
700   return myBuilder;
701 }