1 // File: BRepAlgo_DSAccess.cxx
2 // Created: Wed Aug 13 16:05:15 1997
3 // Author: Prestataire Mary FABIEN
4 // <fbi@langdox.paris1.matra-dtv.fr>
7 #include <BRepAlgo_DSAccess.ixx>
8 #include <BRepAlgo_EdgeConnector.hxx>
10 #include <TColStd_ListOfInteger.hxx>
11 #include <TColStd_MapOfInteger.hxx>
12 #include <TColStd_IndexedMapOfInteger.hxx>
13 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
14 #include <TColStd_SetIteratorOfSetOfInteger.hxx>
16 #include <TopTools_ListOfShape.hxx>
17 #include <TopTools_ListIteratorOfListOfShape.hxx>
18 #include <TopTools_MapOfShape.hxx>
19 #include <TColStd_ListIteratorOfListOfInteger.hxx>
21 #include <TopoDS_Compound.hxx>
22 #include <TopoDS_Wire.hxx>
23 #include <TopOpeBRepDS_PointIterator.hxx>
24 #include <TopOpeBRepDS_BuildTool.hxx>
25 #include <TopOpeBRepDS_CheckStatus.hxx>
26 #include <TopOpeBRepDS_Check.hxx>
27 #include <TopOpeBRepDS_ListOfInterference.hxx>
28 #include <TopOpeBRepDS_Interference.hxx>
29 #include <TopOpeBRepDS_InterferenceIterator.hxx>
30 #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
31 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
32 #include <TopOpeBRepDS_HDataStructure.hxx>
33 #include <TopOpeBRepDS_CurveExplorer.hxx>
34 #include <TopOpeBRepDS_CurveIterator.hxx>
35 #include <TopOpeBRepDS_Filter.hxx>
36 #include <TopOpeBRepDS_Reducer.hxx>
37 #include <TopOpeBRepTool_GeomTool.hxx>
38 #include <TopOpeBRepBuild_HBuilder.hxx>
39 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
40 #include <TopOpeBRepBuild_FaceBuilder.hxx>
41 #include <TopOpeBRep_DSFiller.hxx>
44 //#include <TestTopOpe.hxx>
47 //=======================================================================
50 //=======================================================================
52 BRepAlgo_DSAccess::BRepAlgo_DSAccess() {
56 //=======================================================================
59 //=======================================================================
61 void BRepAlgo_DSAccess::Init()
64 myHDS = new TopOpeBRepDS_HDataStructure();
66 myHDS->ChangeDS().Init();
67 myRecomputeBuilderIsDone = Standard_False;
68 myGetSectionIsDone = Standard_False;
69 myListOfCompoundOfEdgeConnected.Clear();
70 myEC = new BRepAlgo_EdgeConnector();
73 // init of the builder
74 Standard_Real tol3dAPPROX = 1e-7;
75 Standard_Real tol2dAPPROX = 1e-7;
76 // set tolerance values used by the APPROX process
77 TopOpeBRepTool_GeomTool GT;
78 GT.Define(TopOpeBRepTool_APPROX);
79 GT.SetTolerances(tol3dAPPROX,tol2dAPPROX);
80 TopOpeBRepDS_BuildTool BT(GT);
81 myHB = new TopOpeBRepBuild_HBuilder(BT);
82 myHB->ChangeBuilder().ChangeClassify(Standard_False);
84 myState1 = TopAbs_UNKNOWN;
85 myState2 = TopAbs_UNKNOWN;
92 //=======================================================================
95 //=======================================================================
97 void BRepAlgo_DSAccess::Load(const TopoDS_Shape& S)
99 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
104 //=======================================================================
107 //=======================================================================
109 void BRepAlgo_DSAccess::Load(TopoDS_Shape& S1,
112 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
114 if ( S1.Orientation() == TopAbs_REVERSED ) {
115 S1.Orientation(TopAbs_FORWARD);
117 if ( S2.Orientation() == TopAbs_REVERSED ) {
118 S2.Orientation(TopAbs_FORWARD);
124 TopOpeBRepTool_ShapeExplorer ex1,ex2;
125 for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) {
126 const TopoDS_Shape& so1 = ex1.Current();
127 for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) {
128 const TopoDS_Shape& so2 = ex2.Current();
129 DS.FillShapesSameDomain(so1,so2);
137 // TestTopOpe::CurrentDS(myHDS);
138 // TestTopOpe::Shapes(myS1,myS2);
142 //=======================================================================
143 //function : Intersect
145 //=======================================================================
147 void BRepAlgo_DSAccess::Intersect()
149 myRecomputeBuilderIsDone = Standard_False;
151 if(!myS1.IsNull() && !myS2.IsNull())
152 myDSFiller.Insert(myS1, myS2, myHDS);
155 //=======================================================================
156 //function : Intersect
158 //=======================================================================
160 void BRepAlgo_DSAccess::Intersect
161 (const TopoDS_Shape& S1,
162 const TopoDS_Shape& S2)
164 myRecomputeBuilderIsDone = Standard_False;
166 if(S1.IsNull() || S2.IsNull()) {
170 Standard_Boolean orientFORWARD = Standard_False;
172 if(S1.ShapeType() != TopAbs_FACE) {
173 exp.Init(S1, TopAbs_FACE);
177 if(S2.ShapeType() != TopAbs_FACE) {
178 exp.Init(S2, TopAbs_FACE);
182 myDSFiller.Insert(S1, S2, myHDS, orientFORWARD);
185 //=======================================================================
186 //function : SameDomain
188 //=======================================================================
190 void BRepAlgo_DSAccess::SameDomain
191 (const TopoDS_Shape& S1,
192 const TopoDS_Shape& S2)
194 myRecomputeBuilderIsDone = Standard_False;
196 if(S1.IsNull() || S2.IsNull())
199 TopExp_Explorer exp1, exp2;
200 exp1.Init(S1, TopAbs_FACE);
203 exp2.Init(S2, TopAbs_FACE);
207 myDSFiller.Insert2d(S1, S2, myHDS);
211 // Construction of Sections
213 #define FindKeep Standard_False
215 //=======================================================================
216 //function : GetSectionEdgeSet
218 //=======================================================================
220 const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet
221 (const TopoDS_Shape& S1,
222 const TopoDS_Shape& S2)
226 // Check if S1 and S2 contain faces
227 TopExp_Explorer exp1, exp2;
228 exp1.Init(S1, TopAbs_FACE);
230 return myEmptyListOfShape;
231 exp2.Init(S2, TopAbs_FACE);
233 return myEmptyListOfShape;
235 for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) {
236 if(!myHDS->HasShape(exp1.Current(), FindKeep))
237 return myEmptyListOfShape;
239 for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next())
240 if(!myHDS->HasShape(exp2.Current(), FindKeep))
241 return myEmptyListOfShape;
243 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
244 TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder();
246 // The purpose is to find interferences associated with faces,
247 // edges that come from their Geometry (= Edge || Curve)
248 TopTools_ListOfShape LE;
251 for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) {
252 const TopoDS_Shape& F1 = exp1.Current();
254 TopOpeBRepDS_ListOfInterference& lof = DS.ChangeShapeInterferences(F1);
255 TopOpeBRepDS_InterferenceIterator li(lof);
256 li.SupportKind(TopOpeBRepDS_FACE);
257 for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) {
258 const TopoDS_Shape& F2 = exp2.Current();
259 Standard_Integer si = DS.Shape(F2, FindKeep);
262 for(; li.More(); li.Next()) {
263 const TopOpeBRepDS_Interference& CurrInt = li.Value();
264 TopOpeBRepDS_Kind gk = CurrInt.GeometryType();
265 Standard_Integer gi = CurrInt.Geometry();
266 const TopoDS_Shape& geosha = DS.Shape(gi, FindKeep);
267 if(gk == TopOpeBRepDS_CURVE) {
268 const TopTools_ListOfShape& lEdge = myHB->NewEdges(gi);
269 LE.Append(lEdge.First());
271 const TopTools_ListOfShape& lEdge = Builder.Splits(geosha, TopAbs_ON);
272 TopTools_ListIteratorOfListOfShape it(lEdge);
273 for(; it.More(); it.Next()) {
274 const TopoDS_Shape& CurrEdge = it.Value();
275 Standard_Integer ipv1, ipv2;
276 TopOpeBRepDS_Kind pvk1, pvk2;
277 PntVtxOnSectEdge(CurrEdge, ipv1, pvk1, ipv2, pvk2);
278 if(pvk1 != TopOpeBRepDS_VERTEX) {
280 if(pvk2 != TopOpeBRepDS_VERTEX) continue;
282 if(pvk2 != TopOpeBRepDS_VERTEX)
285 for(exp.Init(F1, TopAbs_VERTEX); exp.More(); exp.Next()) {
286 Standard_Integer iVert = DS.Shape(exp.Current());
288 if((iVert == ipv1) || (iVert == ipv2)) {
300 // find all groups of connected Edges associated to LE
301 TopTools_ListIteratorOfListOfShape ILE;
302 myCurrentList.Clear();
303 TopTools_MapOfShape ME;
305 TopTools_ListIteratorOfListOfShape ILC;
308 for(;ILE.More();ILE.Next()) {
309 const TopoDS_Shape& E = ILE.Value();
310 ILC.Initialize(myListOfCompoundOfEdgeConnected);
311 for(;ILC.More();ILC.Next()) {
312 const TopoDS_Shape& Com = ILC.Value();
313 ECE.Init(Com, TopAbs_EDGE);
314 for(;ECE.More();ECE.Next()) {
315 if(ECE.Current().IsSame(E)) {
316 if(!ME.Contains(Com)) {
317 myCurrentList.Append(Com);
326 return myCurrentList;
329 //=======================================================================
330 //function : GetSectionEdgeSet
332 //=======================================================================
334 const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet()
336 if(!myRecomputeBuilderIsDone) {
337 // it is possible to call the method many times consecutively
338 myHDS->AddAncestors(myS1);
339 // start of lpa modification
340 if (!myS1.IsSame(myS2) && !myS2.IsNull()) {
341 myHDS->AddAncestors(myS2);
342 myHB->Perform(myHDS,myS1,myS2);
345 myHB->Perform(myHDS);
348 myRecomputeBuilderIsDone = Standard_True;
349 myGetSectionIsDone = Standard_False;
351 if(myGetSectionIsDone)
352 return myListOfCompoundOfEdgeConnected;
353 myGetSectionIsDone = Standard_True;
355 myListOfCompoundOfEdgeConnected.Clear();
358 Handle(BRepAlgo_EdgeConnector) EC = myEC;
359 EC->ClearStartElement();
360 TopTools_MapOfShape ME;
363 for(; myHB->MoreSection(); myHB->NextSection()) {
364 const TopoDS_Edge& ES = TopoDS::Edge(myHB->CurrentSection());
365 if(ME.Contains(ES)) continue;
369 TopTools_ListOfShape& LW = EC->MakeBlock();
371 // the wires are tranformed into compounds.
372 myCompoundWireMap.Clear();
374 TopTools_ListIteratorOfListOfShape ILW(LW);
375 TopExp_Explorer Explor;
376 for(;ILW.More();ILW.Next()) {
377 TopoDS_Compound Compound;
379 BB.MakeCompound(Compound);
380 // BB.MakeCompound(TopoDS::Compound(Compound));
381 Explor.Init(ILW.Value(), TopAbs_EDGE);
382 for(;Explor.More(); Explor.Next()) {
383 BB.Add(Compound, Explor.Current());
385 myListOfCompoundOfEdgeConnected.Append(Compound);
386 myCompoundWireMap.Bind(Compound,ILW.Value());
388 return myListOfCompoundOfEdgeConnected;
391 //=======================================================================
394 //=======================================================================
396 Standard_Boolean BRepAlgo_DSAccess::IsWire(const TopoDS_Shape& S)
398 Standard_Boolean b = Standard_False;
400 if (myCompoundWireMap.IsBound(S))
401 b = myEC->IsWire(myCompoundWireMap(S));
406 //=======================================================================
409 //=======================================================================
411 const TopoDS_Shape& BRepAlgo_DSAccess::Wire(const TopoDS_Shape& S)
419 TopExp_Explorer Explor(S, TopAbs_EDGE);
420 for(;Explor.More(); Explor.Next()) BB.Add(myWire, Explor.Current());
425 //=======================================================================
426 //function : SectionVertex
428 //=======================================================================
430 const TopTools_ListOfShape& BRepAlgo_DSAccess::SectionVertex
431 (const TopoDS_Shape& F,
432 const TopoDS_Shape& E)
434 TopTools_ListOfShape Result;
436 if(F.ShapeType() != TopAbs_FACE) return myEmptyListOfShape;
437 if(E.ShapeType() != TopAbs_EDGE) return myEmptyListOfShape;
438 Standard_Integer iF = myHDS->Shape(F), iE = myHDS->Shape(E);
439 if((iF == 0) || (iE == 0)) return myEmptyListOfShape;
441 const TopOpeBRepDS_DataStructure& DS = myHDS->DS();
442 const TopOpeBRepDS_ListOfInterference& LI =
443 DS.ShapeInterferences(E, Standard_False);
444 TopOpeBRepDS_InterferenceIterator II(LI);
445 Standard_Integer goodIndex = 0;
446 TopOpeBRepDS_Kind goodKind;
447 for(;II.More();II.Next()) {
448 Handle(TopOpeBRepDS_Interference)& I = II.Value();
449 const TopOpeBRepDS_Transition& T = I->Transition();
450 if((T.ONAfter() == TopAbs_FACE) &&
451 (T.IndexAfter() == iF)) {
452 goodKind = I->GeometryType();
453 goodIndex = I->Geometry();
454 if(goodKind == TopOpeBRepDS_VERTEX)
455 Result.Append(myHDS->Shape(goodIndex));
457 if (goodKind == TopOpeBRepDS_POINT)
458 Result.Append(myHB->NewVertex(goodIndex));
461 myListOfVertex = Result;
462 return myListOfVertex;
468 //=======================================================================
469 //function : SuppressEdgeSet
471 //=======================================================================
473 void BRepAlgo_DSAccess::SuppressEdgeSet
474 (const TopoDS_Shape& C)
476 // It is checked if C really is a Coumpound of connected Edges
478 myHB->InitExtendedSectionDS();
479 // myGetSectionIsDone = Standard_False;
481 TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected);
482 for(;LLS.More(); LLS.Next())
492 myListOfCompoundOfEdgeConnected.Remove(LLS);
495 //=======================================================================
496 //function : ChangeEdgeSet
498 //=======================================================================
500 void BRepAlgo_DSAccess::ChangeEdgeSet
501 (const TopoDS_Shape& Old, const TopoDS_Shape& New)
503 // It is checked if Old is a Coumpound of connected Edges
505 myHB->InitExtendedSectionDS();
507 TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected);
508 for(;LLS.More(); LLS.Next())
509 if(Old == LLS.Value())
514 // The compound of Edges to be rotated is constructed
516 Standard_Boolean Trouve;
521 TColStd_SetOfInteger RPoint; //The points to be controlled
523 TopOpeBRepDS_ListIteratorOfListOfInterference iter;
524 TopExp_Explorer exp(Old, TopAbs_EDGE);
525 TopExp_Explorer exp2;
526 for(; exp.More(); exp.Next()) {
527 const TopoDS_Shape& Edge = exp.Current();
528 for(exp2.Init(New, TopAbs_EDGE), Trouve=Standard_False;
529 exp2.More() && (!Trouve); exp2.Next()) {
530 E = TopoDS::Edge(exp2.Current());
531 Trouve = E.IsSame(Edge);
534 if (!Trouve) B.Add(C, Edge); // Edge to be removed
535 else if (!E.IsEqual(Edge)) {
536 // It is necessary to change Interferences => take the complement
537 iC = myHB->GetDSCurveFromSectEdge(Edge);
540 cout << "Warning DSAccess: Modifications of Edge are not implemented" << endl;
544 // Complete the interferences Curve/Face
546 Handle(TopOpeBRepDS_Interference) interf;
548 iF = myHB->GetDSFaceFromDSCurve(iC, 1);
549 TopOpeBRepDS_ListOfInterference& list1 =
550 myHDS->ChangeDS().ChangeShapeInterferences(iF);
551 for(iter.Initialize(list1); iter.More(); iter.Next()) {
552 interf = iter.Value();
553 if (interf->Geometry() == iC)
554 interf->Transition(interf->Transition().Complement());
556 iF = myHB->GetDSFaceFromDSCurve(iC, 2);
557 TopOpeBRepDS_ListOfInterference& list2 =
558 myHDS->ChangeDS().ChangeShapeInterferences(iF);
559 for(iter.Initialize(list2); iter.More(); iter.Next()) {
560 interf = iter.Value();
561 if (interf->Geometry() == iC)
562 interf->Transition(interf->Transition().Complement());
564 // The associated points are recorded
565 Standard_Integer ipv1, ipv2;
566 //Standard_Boolean bid; // skl
567 TopOpeBRepDS_Kind k1, k2;
568 PntVtxOnCurve(iC, ipv1, k1, ipv2, k2);
569 if (ipv1 != 0) /*bid = */RPoint.Add(ipv1); // skl
570 if (ipv2 != 0) /*bid = */RPoint.Add(ipv2); // skl
579 // Is it necessary to invert the Interferences "Edge on Fa"
580 if (!RPoint.IsEmpty()) {
581 const TopOpeBRepDS_DataStructure & DS = myHDS->DS();
582 Standard_Integer iP,iE, nbShape = DS.NbShapes();
583 Handle(TopOpeBRepDS_Interference) interf;
584 for (iE=1; iE<=nbShape; iE++) {
585 if (DS.Shape(iE,0).ShapeType() == TopAbs_EDGE) {
586 const TopOpeBRepDS_ListOfInterference& List =
587 myHDS->DS().ShapeInterferences(iE);
588 for(iter.Initialize(List); iter.More(); iter.Next()) {
589 interf = iter.Value();
590 if (interf->GeometryType() == TopOpeBRepDS_POINT) {
591 iP = interf->Geometry();
592 if (RPoint.Contains(iP))
593 interf->Transition(interf->Transition().Complement());
600 // The old is replaced by new
605 //=======================================================================
608 //=======================================================================
610 void BRepAlgo_DSAccess::Suppress(const TopoDS_Shape& C,
611 const TopoDS_Shape& Keep)
613 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
614 TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder();
615 Standard_Integer i, iC = 0, iF1, iF2,iE1, iE2;
616 // TopOpeBRepDS_ListIteratorOfListOfInterference;
617 TColStd_ListIteratorOfListOfInteger it1, it2;
619 //A group of points to be kept is constructed
620 mySetOfKeepPoint.Clear();
621 if (!Keep.IsNull()) {
622 //Standard_Boolean B; // skl
623 Standard_Integer ipv1, ipv2;
624 TopOpeBRepDS_Kind k1, k2;
625 TopExp_Explorer exp(Keep, TopAbs_EDGE);
626 for(; exp.More(); exp.Next()) {
627 const TopoDS_Shape& SectEdge = exp.Current();
628 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
630 PntVtxOnSectEdge(SectEdge, ipv1, k1, ipv2, k2);
632 PntVtxOnCurve(iC, ipv1, k1, ipv2, k2);
633 if (ipv1 != 0) /*B = */mySetOfKeepPoint.Add(ipv1); // skl
634 if (ipv2 != 0) /*B = */mySetOfKeepPoint.Add(ipv2); // skl
638 // The curves, which generated the the Edges, are found
639 // during the parsing the Edges which come from Edge are found
640 // (= MapOfInteger : ESE)
642 // First, the interferences of support 1d.
643 TopExp_Explorer exp(C, TopAbs_EDGE);
644 for(; exp.More(); exp.Next()) {
645 const TopoDS_Shape& SectEdge = exp.Current();
646 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
648 // the Edges that come from Edge are processed
649 // the interferences connected with Edges are processed :
650 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
651 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
653 RemoveEdgeInterferences(iE1,iE2,SectEdge);
655 TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1);
656 TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2);
657 for(it1.Initialize(loi11); it1.More(); it1.Next()) {
659 for(it2.Initialize(loi12); it2.More(); it2.Next()) {
661 // similar to the case of SectEdges coming from curve.
662 RemoveEdgeInterferences(iF1,iF2,SectEdge);
665 TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1);
666 TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2);
667 for(it1.Initialize(loi21); it1.More(); it1.Next()) {
669 for(it2.Initialize(loi22); it2.More(); it2.Next()) {
671 // similar to the case of SectEdges coming from curve.
672 RemoveEdgeInterferences(iF1,iF2,SectEdge);
677 // The Edges that come from Curve are processed
678 iF1 = myHB->GetDSFaceFromDSCurve(iC, 1);
679 iF2 = myHB->GetDSFaceFromDSCurve(iC, 2);
681 RemoveEdgeInterferences(iF1, iF2, iC);
682 DS.ChangeKeepCurve(iC, FindKeep);
685 // Secondly, the interferences of 2D support.
686 exp.Init(C, TopAbs_EDGE);
687 for(; exp.More(); exp.Next()) {
688 const TopoDS_Shape& SectEdge = exp.Current();
689 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
691 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
692 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
693 TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1);
694 TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2);
695 for(it1.Initialize(loi11); it1.More(); it1.Next()) {
697 for(it2.Initialize(loi12); it2.More(); it2.Next()) {
701 RemoveFaceInterferences(iF1, iF2, iE1, iE2);
704 TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1);
705 TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2);
706 for(it1.Initialize(loi21); it1.More(); it1.Next()) {
708 for(it2.Initialize(loi22); it2.More(); it2.Next()) {
712 RemoveFaceInterferences(iF1, iF2, iE1, iE2);
717 iF1 = myHB->GetDSFaceFromDSCurve(iC, 1);
718 iF2 = myHB->GetDSFaceFromDSCurve(iC, 2);
720 RemoveFaceInterferences(iF1, iF2, iC);
724 // Thirdly, RemoveSameDomain is done for the faces that contain all Edges of C,
725 // and are SameDomain and without Geometry.
727 RemoveFaceSameDomain(C);
729 // Fourthly, the faces, that were not concerned, are removed
730 Standard_Integer NbSh = DS.NbShapes();
731 for(i = 1; i <= NbSh; i++) {
732 const TopoDS_Shape& Face = DS.Shape(i);
735 if((Face.ShapeType() != TopAbs_FACE) || DS.HasGeometry(Face) ||
736 (myHDS->HasSameDomain(Face)))
738 for(exp.Init(Face, TopAbs_EDGE); exp.More(); exp.Next()){
739 const TopoDS_Shape& Edge = exp.Current();
740 if(DS.HasShape(Edge))
745 DS.ChangeKeepShape(Face, Standard_False);
748 // Builder.myKPMAPf1f2 is reconstructed
749 Builder.FindIsKPart();
751 // The Edges of section are removed from Builder.mySplitON
752 exp.Init(C, TopAbs_EDGE);
753 for(; exp.More(); exp.Next()) {
754 const TopoDS_Shape& SectE= exp.Current();
755 TopTools_ListOfShape& losob = Builder.ChangeSplit(SectE, TopAbs_ON);
760 //=======================================================================
761 //function : SuppressSectionVertex
763 //=======================================================================
765 void BRepAlgo_DSAccess::SuppressSectionVertex
766 (const TopoDS_Vertex& /*V*/)
768 if(!myRecomputeBuilderIsDone)
773 // Reconstruction of Shapes
775 //=======================================================================
778 //=======================================================================
780 const TopoDS_Shape& BRepAlgo_DSAccess::Merge
781 (const TopAbs_State state1,
782 const TopAbs_State state2)
784 if((state1 != TopAbs_IN) &&
785 (state1 != TopAbs_OUT))
787 if((state2 != TopAbs_IN) &&
788 (state2 != TopAbs_OUT))
790 // if GetSectionEdgeSet has already been called, nothing is done
791 // in GetSectionEdgeSet.
792 if(myState1 != TopAbs_UNKNOWN)
793 if(myState1 != state1 || myState2 != state2)
794 myGetSectionIsDone = Standard_False;
800 myHB->MergeShapes(myS1,state1,myS2,state2);
801 const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1);
804 myResultShape.Nullify();
805 BB.MakeCompound(TopoDS::Compound(myResultShape));
806 TopTools_ListIteratorOfListOfShape it(L1);
807 for(;it.More(); it.Next()) {
808 BB.Add(myResultShape, it.Value());
810 return myResultShape;
813 //=======================================================================
816 //=======================================================================
818 const TopoDS_Shape& BRepAlgo_DSAccess::Merge
819 (const TopAbs_State state1)
821 if((state1 != TopAbs_IN) &&
822 (state1 != TopAbs_OUT))
827 myHB->MergeSolid(myS1,state1);
828 const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1);
831 myResultShape.Nullify();
832 BB.MakeCompound(TopoDS::Compound(myResultShape));
833 TopTools_ListIteratorOfListOfShape it(L1);
834 for(;it.More(); it.Next()) {
835 BB.Add(myResultShape, it.Value());
837 return myResultShape;
840 //=======================================================================
841 //function : Propagate
843 //=======================================================================
845 const TopoDS_Shape& BRepAlgo_DSAccess::Propagate
846 (const TopAbs_State what,
847 const TopoDS_Shape& /*fromShape*/,
848 const TopoDS_Shape& /*LoadShape*/)
850 if((what != TopAbs_IN) &&
851 (what != TopAbs_OUT))
853 if(!myRecomputeBuilderIsDone)
856 // myHB->MergeShapes(myS1,t1,myS2,t2);
859 static TopoDS_Shape bid;
863 //=======================================================================
864 //function : PropagateFromSection
866 //=======================================================================
868 const TopoDS_Shape& BRepAlgo_DSAccess::PropagateFromSection
869 (const TopoDS_Shape& SectionShape)
872 TopTools_ListIteratorOfListOfShape ils(myListOfCompoundOfEdgeConnected);
874 for(; ils.More(); ils.Next()) {
875 const TopoDS_Shape& SetEdgSet = ils.Value();
876 exp.Init(SetEdgSet, TopAbs_EDGE);
877 for(; exp.More(); exp.Next()) {
878 if(SectionShape.IsSame(exp.Current()))
885 //=======================================================================
886 //function : Modified
888 //=======================================================================
890 const TopTools_ListOfShape& BRepAlgo_DSAccess::Modified (const TopoDS_Shape& Shape)
894 // Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ;
895 TopTools_ListIteratorOfListOfShape Iterator ;
897 if (myHB->IsSplit (Shape, TopAbs_OUT)) {
898 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_OUT)) ;
901 myModified.Append (Iterator.Value()) ;
904 if (myHB->IsSplit (Shape, TopAbs_IN)) {
905 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_IN)) ;
908 myModified.Append (Iterator.Value()) ;
911 if (myHB->IsSplit (Shape, TopAbs_ON)) {
912 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_ON)) ;
915 myModified.Append (Iterator.Value()) ;
919 if (myHB->IsMerged (Shape, TopAbs_OUT)) {
920 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_OUT)) ;
923 myModified.Append (Iterator.Value()) ;
926 if (myHB->IsMerged(Shape, TopAbs_IN)) {
927 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_IN)) ;
930 myModified.Append (Iterator.Value()) ;
933 if (myHB->IsMerged(Shape, TopAbs_ON)) {
934 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_ON)) ;
937 myModified.Append (Iterator.Value()) ;
946 //=======================================================================
949 //=======================================================================
951 BRepAlgo_CheckStatus BRepAlgo_DSAccess::Check()
953 // TopOpeBRepDS_Check Ck(HDS);
954 // to be precised : in Ck, there is a possibility to know
955 // exactly the n*n of shapes/points/curves/surfaces,
956 // which are not correct in the DS.
957 // Standard_Boolean IsOK = Ck.ChkIntgSamDom() ;
958 // IsOK = IsOK && Ck.OneVertexOnPnt();
959 // IsOK = IsOK && Ck.ChkIntg();
961 // return TopOpeBRepDS_OK;
965 //=======================================================================
966 //function : RemoveEdgeInterferences
967 //purpose : case of SectEdge coming from Edge(s)
969 // if iE1 and iE2 are Edges :
970 // Remove interferences of DSEdge(= iE1 or iE2) of
971 // geometry a vertex of SectEdge, and if there is nothing else,
972 // make unkeep on DSEdge
973 // if iE1 or iE2 == 0, no interference on Edges in the DS
974 // NYI : management of SameDomain
976 // if iE1 and iE2 are Faces :
977 // for each of faces F1 and F2, explode into Edges
979 // remove the interferences of a SectEdge vertex
980 // on geometry. If there is no other interferences attached to
981 // these Edges, and if these Edges are not SameDomain,
983 //=======================================================================
985 void BRepAlgo_DSAccess::RemoveEdgeInterferences
986 (const Standard_Integer iE1,
987 const Standard_Integer iE2,
988 const TopoDS_Shape& SectEdge)
993 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
994 TopOpeBRepDS_Kind kind1, kind2;
995 TopExp_Explorer exp(SectEdge, TopAbs_VERTEX);
996 Standard_Integer i = 1, ipv1, ipv2;
998 // the Vertex/Points of SectEdge are retrieved
999 PntVtxOnSectEdge(SectEdge, ipv1, kind1, ipv2, kind2);
1001 const TopoDS_Shape& Shape = DS.Shape(iE1, FindKeep);
1004 if(Shape.ShapeType() == TopAbs_FACE) {
1005 Standard_Integer iF1 = iE1, iF2 = iE2;
1006 RemoveEdgeInterferencesFromFace(iF1, iF2, ipv1, kind1, ipv2, kind2);
1009 else if(Shape.ShapeType() != TopAbs_EDGE)
1012 // the interferences are taken from the DS
1013 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1014 TopOpeBRepDS_Kind gk;
1015 Standard_Integer iCurrE1, iCurrE2, gi;
1016 // Standard_Boolean RemInterf;
1018 for(i = 1; i <= 2; i++) {
1019 iCurrE1 = ((i == 1) ? iE1 : iE2);
1020 iCurrE2 = ((i == 1) ? iE2 : iE1);
1021 const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep);
1024 TopOpeBRepDS_ListOfInterference& loi =
1025 DS.ChangeShapeInterferences(DSEdge);
1026 // RemInterf = Standard_True;
1027 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1028 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1029 if (I.IsNull()) continue;
1030 if((I->SupportType() != TopOpeBRepDS_EDGE) ||
1031 (I->Support() != iCurrE2)) {
1032 // RemInterf = Standard_False;//debug ...
1035 gk = I->GeometryType();
1039 DS.RemoveShapeInterference(DSEdge, I);
1040 if(!DS.HasGeometry(DSEdge)) {
1041 // if(RemInterf || (!lioloi.More())) {
1042 RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain
1043 DS.ChangeKeepShape(iCurrE1, FindKeep);
1048 else if(gk == kind2) {
1050 DS.RemoveShapeInterference(DSEdge, I);
1051 if(!DS.HasGeometry(DSEdge)) {
1052 // if(RemInterf || (!lioloi.More())) {//debug
1053 RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain
1054 DS.ChangeKeepShape(iCurrE1, FindKeep);
1063 //=======================================================================
1064 //function : RemoveEdgeInterferences
1065 //purpose : case of SectEdge coming from Curve
1066 // for each of faces F1 and F2, explode into Edges
1068 // remove the interferences that have a vertex of SectEdge
1069 // as a geometry. If no other interferences are attached to
1070 // these Edges, and if the Edges are not SameDomain,
1071 // make unKeepShape.
1072 //=======================================================================
1074 void BRepAlgo_DSAccess::RemoveEdgeInterferences
1075 (const Standard_Integer iF1,
1076 const Standard_Integer iF2,
1077 const Standard_Integer iCurve)
1079 TopOpeBRepDS_Kind gk1, gk2;
1080 Standard_Integer gi1, gi2;
1082 PntVtxOnCurve(iCurve, gi1, gk1, gi2, gk2);
1084 if (!mySetOfKeepPoint.IsEmpty()) {
1085 if (mySetOfKeepPoint.Contains(gi1)) gi1 = 0;
1086 if (mySetOfKeepPoint.Contains(gi2)) gi2 = 0;
1090 RemoveEdgeInterferencesFromFace(iF1, iF2, gi1, gk1, gi2, gk2);
1093 //=======================================================================
1094 //function : RemoveFaceInterferences
1095 //purpose : case of SectEdge coming from Edge(s)
1096 // Remove interferences between F1 and F2 concerning
1097 // DSEdge (= E1 or E2) :
1098 // a) if DSEdge is not SameDomain -> the edge is Removed
1099 // b) if among other interferences of DSEdge of
1100 // GeomtryType == VERTEX, there is none
1101 // with Edge of DSFace(= F1 or F2)
1102 // if DSFace has no more interferences and is not SameDomain,
1103 // make unkeep DSFace.
1104 //=======================================================================
1106 void BRepAlgo_DSAccess::RemoveFaceInterferences
1107 (const Standard_Integer iF1,
1108 const Standard_Integer iF2,
1109 const Standard_Integer iE1,
1110 const Standard_Integer iE2)
1114 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1115 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;//, lioloei, liolofi;
1116 TopTools_ListIteratorOfListOfShape liolos;
1117 TopOpeBRepDS_Kind gk;
1118 TopExp_Explorer exp;
1119 Standard_Integer i, iCurrF1, iCurrF2, j, iCurrE1, /*iCurrE2,*/ gi; // skl
1120 Standard_Boolean RemInterf;
1122 for(i = 1; i <= 2; i++) {
1123 iCurrF1 = ((i == 1) ? iF1 : iF2);
1124 iCurrF2 = ((i == 1) ? iF2 : iF1);
1125 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1);
1128 const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace);
1129 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1130 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1131 if (I.IsNull()) continue;
1132 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1133 (I->Support() != iCurrF2)) {
1136 gk = I->GeometryType();
1138 if(gk != TopOpeBRepDS_EDGE) continue;
1139 for(j = 1; j <= 2; j++) {
1140 iCurrE1 = ((j == 1) ? iE1 : iE2);
1141 //iCurrE2 = ((j == 1) ? iE2 : iE1); // skl
1142 if(gi != iCurrE1) continue;
1143 // a) if DSEdge is not SameDomain -> the interference is Removed
1145 const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep);
1148 if(!myHDS->HasSameDomain(DSEdge)) {
1149 if(!DS.HasGeometry(DSEdge)) {
1150 DS.RemoveShapeInterference(DSFace, I);
1151 DS.ChangeKeepShape(DSEdge, FindKeep);
1153 // NYI : manage the case when the geometry of DSEdge
1154 // NYI : is not connected anyhow with two faces
1156 if(!DS.HasGeometry(DSFace)) {
1157 DS.ChangeKeepShape(DSFace, FindKeep);
1161 // b) if no Edges of SameDomain(DSEdge),
1162 // belong to DSFace(= F1 or F2)
1163 // -> the interference is removed
1164 const TopoDS_Shape& Edge = DS.Shape(iCurrE1, FindKeep);
1167 const TopTools_ListOfShape& loe = DS.ShapeSameDomain(Edge);
1168 RemInterf = Standard_True;
1169 for(liolos.Initialize(loe); liolos.More(); liolos.Next()) {
1170 const TopoDS_Shape& ESD = liolos.Value();
1171 for(exp.Init(DSFace, TopAbs_EDGE); exp.More(); exp.Next()) {
1172 if(ESD.IsSame(exp.Current())) {
1173 RemInterf = Standard_False;
1177 if(!RemInterf) break;
1180 // RemoveSameDomain(iCurrF1, iCurrF2);
1182 if(!DS.HasGeometry(DSFace)) {
1183 if(!myHDS->HasSameDomain(DSFace))
1184 DS.ChangeKeepShape(DSFace, FindKeep);
1187 if(!DS.HasGeometry(DSFace) && !myHDS->HasSameDomain(DSFace))
1188 DS.ChangeKeepShape(DSFace, FindKeep);
1194 //=======================================================================
1195 //function : RemoveFaceInterferences
1196 //purpose : case of SectEdge from Curve
1197 // remove interferences of Geometry iCurve between F1 and F2.
1198 // if Face(= F1 or F2) has noother interference, and if Face
1199 // is not SameDomain, make unKeepShape Face.
1200 //=======================================================================
1202 void BRepAlgo_DSAccess::RemoveFaceInterferences
1203 (const Standard_Integer iF1,
1204 const Standard_Integer iF2,
1205 const Standard_Integer iCurve)
1207 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1208 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1209 TopOpeBRepDS_Kind gk;
1210 Standard_Integer i, iCurrF1, iCurrF2, gi;
1212 for(i = 1; i <= 2; i++) {
1213 iCurrF1 = ((i == 1) ? iF1 : iF2);
1214 iCurrF2 = ((i == 1) ? iF2 : iF1);
1215 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1);
1216 const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace);
1217 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1218 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1219 if (I.IsNull()) continue;
1220 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1221 (I->Support() != iCurrF2)) {
1225 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1226 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1227 if (I.IsNull()) continue;
1228 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1229 (I->Support() != iCurrF2)) {
1232 gk = I->GeometryType();
1234 if(gk != TopOpeBRepDS_CURVE) continue;
1235 if(gi != iCurve) continue;
1236 DS.RemoveShapeInterference(DSFace, I);
1237 // const TopoDS_Shape& interferenceface = DS.Shape(iCurrF2);
1238 // DS.RemoveShapeInterference(interferenceface, I);
1239 if(!DS.HasGeometry(DSFace)) {
1240 const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSFace);
1242 DS.ChangeKeepShape(DSFace, FindKeep);
1244 // if(!DS.HasGeometry(interferenceface)) {
1245 // const TopTools_ListOfShape& los = DS.ShapeSameDomain(interferenceface);
1246 // if(los.IsEmpty())
1247 // DS.ChangeKeepShape(interferenceface, FindKeep);
1253 //=======================================================================
1254 //function : RemoveEdgeInterferencesFromFace
1255 //purpose : Remove interferences of Edges from iF1 or iF2
1256 // that have GeometryType kind1/kind2 and
1257 // Geometry ipv1/ipv2.
1258 // if kind1/kind2 == TopAbs_VERTEX -> RemoveEdgeFromFace
1259 //=======================================================================
1261 void BRepAlgo_DSAccess::RemoveEdgeInterferencesFromFace
1262 (const Standard_Integer iF1,
1263 const Standard_Integer iF2,
1264 const Standard_Integer ipv1,
1265 const TopOpeBRepDS_Kind kind1,
1266 const Standard_Integer ipv2,
1267 const TopOpeBRepDS_Kind kind2)
1269 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1270 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1271 TopExp_Explorer exp, exp2;
1272 TopOpeBRepDS_Kind sk, gk;
1273 Standard_Integer i, iCurrF1, iCurrF2, iE = 0, si, gi;
1275 for(i = 1; i <= 2; i++) {
1276 iCurrF1 = ((i == 1) ? iF1 : iF2);
1277 iCurrF2 = ((i == 1) ? iF2 : iF1);
1278 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1, FindKeep);
1281 exp.Init(DSFace, TopAbs_EDGE);
1282 for(; exp.More(); exp.Next()) {
1283 const TopoDS_Shape& DSEdge = exp.Current();
1284 iE = DS.Shape(DSEdge, FindKeep);
1286 const TopOpeBRepDS_ListOfInterference& loi =
1287 DS.ShapeInterferences(DSEdge);
1288 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1289 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1290 if (I.IsNull()) continue;
1291 sk = I->SupportType();
1293 if((sk != TopOpeBRepDS_FACE) || (si != iCurrF2)) {
1294 if(sk != TopOpeBRepDS_EDGE)
1296 const TopoDS_Shape& DSFace2 = DS.Shape(iCurrF2, FindKeep);
1297 exp2.Init(DSFace2, TopAbs_EDGE);
1298 for(; exp2.More(); exp2.Next()) {
1299 if(si == DS.Shape(exp2.Current(), FindKeep))
1305 gk = I->GeometryType();
1309 DS.RemoveShapeInterference(DSEdge, I);
1310 // if(!DS.HasGeometry(DSEdge)) {
1311 // const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge);
1312 // if(los.IsEmpty()) {
1313 // DS.ChangeKeepShape(iE, FindKeep);
1317 else if(gk == kind2) {
1319 DS.RemoveShapeInterference(DSEdge, I);
1320 // if(!DS.HasGeometry(DSEdge)) {
1321 // const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge);
1322 // if(los.IsEmpty()) {
1323 // DS.ChangeKeepShape(iE, FindKeep);
1332 if(kind1 == TopOpeBRepDS_VERTEX)
1333 RemoveEdgeFromFace(iCurrF1,ipv1);
1334 if(kind2 == TopOpeBRepDS_VERTEX)
1335 RemoveEdgeFromFace(iCurrF1,ipv2);
1339 //=======================================================================
1340 //function : RemoveEdgeFromFace
1341 //purpose : Remove from DS the Edges, which belong to iF
1342 // and have iV as vertex if they do not have Geometry and
1343 // are not SameDomain.
1344 //=======================================================================
1346 void BRepAlgo_DSAccess::RemoveEdgeFromFace
1347 (const Standard_Integer iF,
1348 const Standard_Integer iV)
1352 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1353 const TopoDS_Shape& DSFace = DS.Shape(iF, FindKeep);
1354 const TopoDS_Shape& Vertex = DS.Shape(iV, FindKeep);
1355 if(DSFace.IsNull() || Vertex.IsNull())
1357 TopExp_Explorer exp(DSFace, TopAbs_EDGE), exp2;
1358 for(; exp.More(); exp.Next()) {
1359 const TopoDS_Shape& Edge = exp.Current();
1361 // Standard_Integer iEdge2 = DS.Shape(Edge, FindKeep);
1362 // Standard_Integer iEdge3 = DS.Shape(Edge);
1365 if(!DS.HasShape(Edge))
1367 exp2.Init(Edge, TopAbs_VERTEX);
1368 for(; exp2.More(); exp2.Next()) {
1370 // Standard_Integer iEdge5 = DS.Shape(Vertex, FindKeep);
1371 // Standard_Integer iEdge4 = DS.Shape(Vertex);
1372 // Standard_Integer iEdge6 = DS.Shape(exp2.Current(), FindKeep);
1373 // Standard_Integer iEdge7 = DS.Shape(exp2.Current());
1376 if(Vertex.IsSame(exp2.Current())) {
1377 if(!DS.HasGeometry(Edge)) {
1378 const TopTools_ListOfShape& los = DS.ShapeSameDomain(Edge);
1381 // Standard_Integer iEdge = DS.Shape(Edge);
1383 DS.ChangeKeepShape(Edge, FindKeep);
1391 //=======================================================================
1392 //function : PntVtxOnCurve
1393 //purpose : To find the points/vertices on curves
1394 //=======================================================================
1396 void BRepAlgo_DSAccess::PntVtxOnCurve
1397 (const Standard_Integer iCurve,
1398 Standard_Integer& ipv1,
1399 TopOpeBRepDS_Kind& pvk1,
1400 Standard_Integer& ipv2,
1401 TopOpeBRepDS_Kind& pvk2)
1403 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1405 const TopOpeBRepDS_Curve& C = DS.Curve(iCurve);
1406 TopOpeBRepDS_Kind pvk;
1407 Standard_Integer ipv, iMother = C.Mother(), igoodC = iCurve, comp = 0;
1408 if(iMother) igoodC = iMother;
1410 TopOpeBRepDS_PointIterator PII = myHDS->CurvePoints(igoodC);
1411 TopOpeBRepDS_PointIterator& PIt = PII; // skl : I change "M_PI" to "PIt"
1413 // TopOpeBRepDS_PointIterator& PIt = myHDS->CurvePoints(igoodC);
1415 for(;PIt.More(); PIt.Next()) {
1418 // Standard_Error ...
1420 ipv = PIt.Current();
1421 // a point or a vertex is removed from the DS
1423 pvk = TopOpeBRepDS_POINT;
1424 DS.ChangeKeepPoint(ipv, FindKeep);
1426 else if(PIt.IsVertex()) {
1427 pvk = TopOpeBRepDS_VERTEX;
1428 DS.ChangeKeepShape(ipv, FindKeep);
1431 ((comp == 1) ? ipv1 : ipv2) = ipv;
1432 ((comp == 1) ? pvk1 : pvk2) = pvk;
1436 //=======================================================================
1437 //function : PntVtxOnSectEdge
1438 //purpose : Points/Vertexes on SectEdge are found
1439 //=======================================================================
1441 void BRepAlgo_DSAccess::PntVtxOnSectEdge
1442 (const TopoDS_Shape& SectEdge,
1443 Standard_Integer& ipv1,
1444 TopOpeBRepDS_Kind& pvk1,
1445 Standard_Integer& ipv2,
1446 TopOpeBRepDS_Kind& pvk2)
1448 // myHB->ChangeBuilder();
1449 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1450 TopOpeBRepDS_Kind kind = TopOpeBRepDS_POINT;
1451 TopExp_Explorer exp(SectEdge, TopAbs_VERTEX);
1452 Standard_Integer i = 1, ipv;
1454 for(; exp.More(); exp.Next(), i++) {
1455 const TopoDS_Shape& DSVertex = exp.Current();
1456 ipv = myHB->GetDSPointFromNewVertex(DSVertex);
1458 ipv = DS.Shape(DSVertex, FindKeep);
1459 kind = TopOpeBRepDS_VERTEX;
1461 // Standard_Error ...
1474 // Standard_Error ...
1479 //=======================================================================
1480 //function : RemoveEdgeSameDomain
1482 //=======================================================================
1484 void BRepAlgo_DSAccess::RemoveEdgeSameDomain
1485 (const Standard_Integer /*iE1*/,
1486 const Standard_Integer /*iE2*/)
1489 /* TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1490 const TopoDS_Shape& E1 = DS.Shape(iE1);
1491 const TopoDS_Shape& E2 = DS.Shape(iE2);
1492 TopAbs_ShapeEnum ts1, ts2;
1493 ts1 = E1.ShapeType();
1494 ts2 = E2.ShapeType();
1495 if((ts1 != TopAbs_EDGE) ||
1496 (ts2 != TopAbs_EDGE))
1498 TopTools_ListOfShape& lossd = DS.ChangeShapeSameDomain(E1);
1501 Standard_Integer exte = lossd.Extent();
1503 if(lossd.First().IsSame(E2))
1504 DS.UnfillShapesSameDomain(E1,E2);
1509 //=======================================================================
1510 //function : RemoveFaceSameDomain
1511 //purpose : remove SameDomain information of glued faces
1512 //=======================================================================
1514 void BRepAlgo_DSAccess::RemoveFaceSameDomain
1515 (const TopoDS_Shape& C)
1517 // myHB->ChangeBuilder();
1518 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1520 //TColStd_ListIteratorOfListOfInteger it;
1521 TopExp_Explorer exp(C, TopAbs_EDGE);
1522 Standard_Integer iE1, iE2, iE, /*NbF,*/ iF1, iF2, iCurrF1, iCurrF2, iC =0; // skl
1523 iF1 = iF2 = iCurrF1 = iCurrF2 = 0;
1525 const TopoDS_Shape& SectEdge = exp.Current();
1527 for(; exp.More(); exp.Next()) {
1528 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
1529 if(!iC && !SectEdge.IsNull())
1531 // const TopoDS_Shape& SectEdge = exp.Current();
1533 if(!iC && !SectEdge.IsNull()) {
1534 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
1535 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
1536 if(iE1 && iE2) return;
1537 iE = (iE1 ? iE1 : iE2);
1540 TColStd_ListOfInteger& loi = FindGoodFace(iE, iF1, b);
1544 //NbF = loi.Extent(); // skl
1545 for(; exp.More(); exp.Next()) {
1546 // skl : I change "SectEdge" to "SectEdg"
1547 const TopoDS_Shape& SectEdg = exp.Current();
1548 iC = myHB->GetDSCurveFromSectEdge(SectEdg);
1550 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdg, 1);
1551 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdg, 2);
1552 if(iE1 && iE2) return;
1553 iE = (iE1 ? iE1 : iE2);
1556 TColStd_ListOfInteger& loi2 = FindGoodFace(iE, iCurrF1, b);
1558 if(!iCurrF1 || !iF1) return;
1559 if(iCurrF1 != iF1) {
1560 if(loi2.Extent() == 1) iCurrF2 = loi2.First();
1561 if(iCurrF2 == iF1) continue;
1562 if(loi.Extent() == 1) iF2 = loi.First();
1564 if(!iCurrF2 || !iF2) return;
1565 if((iCurrF1 == iF2) ||
1575 const TopoDS_Shape& FSD = DS.Shape(iF1);
1578 TopTools_ListOfShape& ssd = DS.ChangeShapeSameDomain(FSD);
1579 TopTools_ListIteratorOfListOfShape itssd(ssd);
1580 TopExp_Explorer exp2;
1581 for(; itssd.More(); itssd.Next()) {
1582 exp2.Init(itssd.Value(), TopAbs_VERTEX);
1583 for(; exp2.More(); exp2.Next()) {
1584 const TopoDS_Shape& exp2Curr = exp2.Current();
1585 exp.Init(C, TopAbs_VERTEX);
1586 for(; exp.More(); exp.Next()) {
1587 if(exp2Curr.IsSame(exp.Current()))
1598 const TopoDS_Shape& FSD2 = itssd.Value();
1599 Standard_Integer iFSD = DS.Shape(FSD), iFSD2 = DS.Shape(FSD2);
1600 RemoveFaceSameDomain(iFSD, iFSD2);
1601 // DS.UnfillShapesSameDomain(FSD, FSD2);
1606 //=======================================================================
1607 //function : FindGoodFace
1609 //=======================================================================
1611 TColStd_ListOfInteger& BRepAlgo_DSAccess::FindGoodFace
1612 (const Standard_Integer iE,
1613 Standard_Integer& iF1,
1614 Standard_Boolean& b)
1616 // myHB->ChangeBuilder();
1618 TColStd_ListOfInteger& loi = myHB->GetDSFaceFromDSEdge(iE, 1);
1619 if(loi.Extent() == 1) {
1622 TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2);
1626 TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2);
1627 if(loi2.Extent() == 1) {
1634 return myEmptyListOfInteger;
1637 //=======================================================================
1638 //function : RemoveFaceSameDomain
1640 //=======================================================================
1642 void BRepAlgo_DSAccess::RemoveFaceSameDomain
1643 (const Standard_Integer iF1,
1644 const Standard_Integer iF2)
1646 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1647 const TopoDS_Shape& F1 = DS.Shape(iF1, FindKeep);
1648 const TopoDS_Shape& F2 = DS.Shape(iF2, FindKeep);
1649 if(F1.IsNull() || F2.IsNull())
1653 Standard_Integer iref1 = DS.SameDomainRef(F1),
1654 iref2 = DS.SameDomainRef(F2), istart, iend;
1656 DS.SameDomainRef(F2,iF2);
1658 DS.SameDomainRef(F1,iF1);
1659 DS.UnfillShapesSameDomain(F1,F2);
1663 Standard_Boolean iF1iF2IsConnected = Standard_False;
1664 TColStd_IndexedMapOfInteger moi;
1675 Standard_Integer NbConnect = 0, icurr;
1676 while(moi.Extent() > NbConnect) {
1678 icurr = moi.FindKey(NbConnect);
1679 DS.SameDomainRef(icurr, istart);
1680 const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr);
1682 const TopoDS_Shape& SNSD = DS.Shape(icurr);
1683 DS.SameDomainRef(SNSD, 0);
1685 TopTools_ListIteratorOfListOfShape li(los);
1686 for(; li.More(); li.Next()) {
1687 Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep);
1690 if(iCurrShap == iend)
1691 iF1iF2IsConnected = Standard_True;
1695 if(!iF1iF2IsConnected) {
1699 while(moi.Extent() > NbConnect) {
1701 icurr = moi.FindKey(NbConnect);
1702 DS.SameDomainRef(icurr, iend);
1703 const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr);
1705 const TopoDS_Shape& SNSD = DS.Shape(icurr);
1706 DS.SameDomainRef(SNSD, 0);
1708 TopTools_ListIteratorOfListOfShape li(los);
1709 for(; li.More(); li.Next()) {
1710 Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep);
1719 //=======================================================================
1722 //=======================================================================
1724 const Handle(TopOpeBRepDS_HDataStructure)&
1725 BRepAlgo_DSAccess::DS() const
1730 //=======================================================================
1731 //function : changeDS
1733 //=======================================================================
1734 Handle(TopOpeBRepDS_HDataStructure)&
1735 BRepAlgo_DSAccess::ChangeDS()
1740 //=======================================================================
1741 //function : Builder
1743 //=======================================================================
1745 const Handle(TopOpeBRepBuild_HBuilder)&
1746 BRepAlgo_DSAccess::Builder() const
1751 //=======================================================================
1752 //function : ChangeBuilder
1754 //=======================================================================
1756 Handle(TopOpeBRepBuild_HBuilder)&
1757 BRepAlgo_DSAccess::ChangeBuilder()