1 // Created on: 1997-08-13
2 // Created by: Prestataire Mary FABIEN
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepAlgo_DSAccess.ixx>
18 #include <BRepAlgo_EdgeConnector.hxx>
20 #include <TColStd_ListOfInteger.hxx>
21 #include <TColStd_MapOfInteger.hxx>
22 #include <TColStd_IndexedMapOfInteger.hxx>
23 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
24 #include <TColStd_SetIteratorOfSetOfInteger.hxx>
26 #include <TopTools_ListOfShape.hxx>
27 #include <TopTools_ListIteratorOfListOfShape.hxx>
28 #include <TopTools_MapOfShape.hxx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
31 #include <TopoDS_Compound.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <TopOpeBRepDS_PointIterator.hxx>
34 #include <TopOpeBRepDS_BuildTool.hxx>
35 #include <TopOpeBRepDS_CheckStatus.hxx>
36 #include <TopOpeBRepDS_Check.hxx>
37 #include <TopOpeBRepDS_ListOfInterference.hxx>
38 #include <TopOpeBRepDS_Interference.hxx>
39 #include <TopOpeBRepDS_InterferenceIterator.hxx>
40 #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
41 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
42 #include <TopOpeBRepDS_HDataStructure.hxx>
43 #include <TopOpeBRepDS_CurveExplorer.hxx>
44 #include <TopOpeBRepDS_CurveIterator.hxx>
45 #include <TopOpeBRepDS_Filter.hxx>
46 #include <TopOpeBRepDS_Reducer.hxx>
47 #include <TopOpeBRepTool_GeomTool.hxx>
48 #include <TopOpeBRepBuild_HBuilder.hxx>
49 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
50 #include <TopOpeBRepBuild_FaceBuilder.hxx>
51 #include <TopOpeBRep_DSFiller.hxx>
54 //#include <TestTopOpe.hxx>
57 //=======================================================================
60 //=======================================================================
62 BRepAlgo_DSAccess::BRepAlgo_DSAccess() {
66 //=======================================================================
69 //=======================================================================
71 void BRepAlgo_DSAccess::Init()
74 myHDS = new TopOpeBRepDS_HDataStructure();
76 myHDS->ChangeDS().Init();
77 myRecomputeBuilderIsDone = Standard_False;
78 myGetSectionIsDone = Standard_False;
79 myListOfCompoundOfEdgeConnected.Clear();
80 myEC = new BRepAlgo_EdgeConnector();
83 // init of the builder
84 Standard_Real tol3dAPPROX = 1e-7;
85 Standard_Real tol2dAPPROX = 1e-7;
86 // set tolerance values used by the APPROX process
87 TopOpeBRepTool_GeomTool GT;
88 GT.Define(TopOpeBRepTool_APPROX);
89 GT.SetTolerances(tol3dAPPROX,tol2dAPPROX);
90 TopOpeBRepDS_BuildTool BT(GT);
91 myHB = new TopOpeBRepBuild_HBuilder(BT);
92 myHB->ChangeBuilder().ChangeClassify(Standard_False);
94 myState1 = TopAbs_UNKNOWN;
95 myState2 = TopAbs_UNKNOWN;
102 //=======================================================================
105 //=======================================================================
107 void BRepAlgo_DSAccess::Load(const TopoDS_Shape& S)
109 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
114 //=======================================================================
117 //=======================================================================
119 void BRepAlgo_DSAccess::Load(TopoDS_Shape& S1,
122 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
124 if ( S1.Orientation() == TopAbs_REVERSED ) {
125 S1.Orientation(TopAbs_FORWARD);
127 if ( S2.Orientation() == TopAbs_REVERSED ) {
128 S2.Orientation(TopAbs_FORWARD);
134 TopOpeBRepTool_ShapeExplorer ex1,ex2;
135 for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) {
136 const TopoDS_Shape& so1 = ex1.Current();
137 for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) {
138 const TopoDS_Shape& so2 = ex2.Current();
139 DS.FillShapesSameDomain(so1,so2);
147 // TestTopOpe::CurrentDS(myHDS);
148 // TestTopOpe::Shapes(myS1,myS2);
152 //=======================================================================
153 //function : Intersect
155 //=======================================================================
157 void BRepAlgo_DSAccess::Intersect()
159 myRecomputeBuilderIsDone = Standard_False;
161 if(!myS1.IsNull() && !myS2.IsNull())
162 myDSFiller.Insert(myS1, myS2, myHDS);
165 //=======================================================================
166 //function : Intersect
168 //=======================================================================
170 void BRepAlgo_DSAccess::Intersect
171 (const TopoDS_Shape& S1,
172 const TopoDS_Shape& S2)
174 myRecomputeBuilderIsDone = Standard_False;
176 if(S1.IsNull() || S2.IsNull()) {
180 Standard_Boolean orientFORWARD = Standard_False;
182 if(S1.ShapeType() != TopAbs_FACE) {
183 exp.Init(S1, TopAbs_FACE);
187 if(S2.ShapeType() != TopAbs_FACE) {
188 exp.Init(S2, TopAbs_FACE);
192 myDSFiller.Insert(S1, S2, myHDS, orientFORWARD);
195 //=======================================================================
196 //function : SameDomain
198 //=======================================================================
200 void BRepAlgo_DSAccess::SameDomain
201 (const TopoDS_Shape& S1,
202 const TopoDS_Shape& S2)
204 myRecomputeBuilderIsDone = Standard_False;
206 if(S1.IsNull() || S2.IsNull())
209 TopExp_Explorer exp1, exp2;
210 exp1.Init(S1, TopAbs_FACE);
213 exp2.Init(S2, TopAbs_FACE);
217 myDSFiller.Insert2d(S1, S2, myHDS);
221 // Construction of Sections
223 #define FindKeep Standard_False
225 //=======================================================================
226 //function : GetSectionEdgeSet
228 //=======================================================================
230 const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet
231 (const TopoDS_Shape& S1,
232 const TopoDS_Shape& S2)
236 // Check if S1 and S2 contain faces
237 TopExp_Explorer exp1, exp2;
238 exp1.Init(S1, TopAbs_FACE);
240 return myEmptyListOfShape;
241 exp2.Init(S2, TopAbs_FACE);
243 return myEmptyListOfShape;
245 for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) {
246 if(!myHDS->HasShape(exp1.Current(), FindKeep))
247 return myEmptyListOfShape;
249 for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next())
250 if(!myHDS->HasShape(exp2.Current(), FindKeep))
251 return myEmptyListOfShape;
253 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
254 TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder();
256 // The purpose is to find interferences associated with faces,
257 // edges that come from their Geometry (= Edge || Curve)
258 TopTools_ListOfShape LE;
261 for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) {
262 const TopoDS_Shape& F1 = exp1.Current();
264 TopOpeBRepDS_ListOfInterference& lof = DS.ChangeShapeInterferences(F1);
265 TopOpeBRepDS_InterferenceIterator li(lof);
266 li.SupportKind(TopOpeBRepDS_FACE);
267 for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) {
268 const TopoDS_Shape& F2 = exp2.Current();
269 Standard_Integer si = DS.Shape(F2, FindKeep);
272 for(; li.More(); li.Next()) {
273 const TopOpeBRepDS_Interference& CurrInt = li.Value();
274 TopOpeBRepDS_Kind gk = CurrInt.GeometryType();
275 Standard_Integer gi = CurrInt.Geometry();
276 const TopoDS_Shape& geosha = DS.Shape(gi, FindKeep);
277 if(gk == TopOpeBRepDS_CURVE) {
278 const TopTools_ListOfShape& lEdge = myHB->NewEdges(gi);
279 LE.Append(lEdge.First());
281 const TopTools_ListOfShape& lEdge = Builder.Splits(geosha, TopAbs_ON);
282 TopTools_ListIteratorOfListOfShape it(lEdge);
283 for(; it.More(); it.Next()) {
284 const TopoDS_Shape& CurrEdge = it.Value();
285 Standard_Integer ipv1, ipv2;
286 TopOpeBRepDS_Kind pvk1, pvk2;
287 PntVtxOnSectEdge(CurrEdge, ipv1, pvk1, ipv2, pvk2);
288 if(pvk1 != TopOpeBRepDS_VERTEX) {
290 if(pvk2 != TopOpeBRepDS_VERTEX) continue;
292 if(pvk2 != TopOpeBRepDS_VERTEX)
295 for(exp.Init(F1, TopAbs_VERTEX); exp.More(); exp.Next()) {
296 Standard_Integer iVert = DS.Shape(exp.Current());
298 if((iVert == ipv1) || (iVert == ipv2)) {
310 // find all groups of connected Edges associated to LE
311 TopTools_ListIteratorOfListOfShape ILE;
312 myCurrentList.Clear();
313 TopTools_MapOfShape ME;
315 TopTools_ListIteratorOfListOfShape ILC;
318 for(;ILE.More();ILE.Next()) {
319 const TopoDS_Shape& E = ILE.Value();
320 ILC.Initialize(myListOfCompoundOfEdgeConnected);
321 for(;ILC.More();ILC.Next()) {
322 const TopoDS_Shape& Com = ILC.Value();
323 ECE.Init(Com, TopAbs_EDGE);
324 for(;ECE.More();ECE.Next()) {
325 if(ECE.Current().IsSame(E)) {
326 if(!ME.Contains(Com)) {
327 myCurrentList.Append(Com);
336 return myCurrentList;
339 //=======================================================================
340 //function : GetSectionEdgeSet
342 //=======================================================================
344 const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet()
346 if(!myRecomputeBuilderIsDone) {
347 // it is possible to call the method many times consecutively
348 myHDS->AddAncestors(myS1);
349 // start of lpa modification
350 if (!myS1.IsSame(myS2) && !myS2.IsNull()) {
351 myHDS->AddAncestors(myS2);
352 myHB->Perform(myHDS,myS1,myS2);
355 myHB->Perform(myHDS);
358 myRecomputeBuilderIsDone = Standard_True;
359 myGetSectionIsDone = Standard_False;
361 if(myGetSectionIsDone)
362 return myListOfCompoundOfEdgeConnected;
363 myGetSectionIsDone = Standard_True;
365 myListOfCompoundOfEdgeConnected.Clear();
368 Handle(BRepAlgo_EdgeConnector) EC = myEC;
369 EC->ClearStartElement();
370 TopTools_MapOfShape ME;
373 for(; myHB->MoreSection(); myHB->NextSection()) {
374 const TopoDS_Edge& ES = TopoDS::Edge(myHB->CurrentSection());
375 if(ME.Contains(ES)) continue;
379 TopTools_ListOfShape& LW = EC->MakeBlock();
381 // the wires are tranformed into compounds.
382 myCompoundWireMap.Clear();
384 TopTools_ListIteratorOfListOfShape ILW(LW);
385 TopExp_Explorer Explor;
386 for(;ILW.More();ILW.Next()) {
387 TopoDS_Compound Compound;
389 BB.MakeCompound(Compound);
390 // BB.MakeCompound(TopoDS::Compound(Compound));
391 Explor.Init(ILW.Value(), TopAbs_EDGE);
392 for(;Explor.More(); Explor.Next()) {
393 BB.Add(Compound, Explor.Current());
395 myListOfCompoundOfEdgeConnected.Append(Compound);
396 myCompoundWireMap.Bind(Compound,ILW.Value());
398 return myListOfCompoundOfEdgeConnected;
401 //=======================================================================
404 //=======================================================================
406 Standard_Boolean BRepAlgo_DSAccess::IsWire(const TopoDS_Shape& S)
408 Standard_Boolean b = Standard_False;
410 if (myCompoundWireMap.IsBound(S))
411 b = myEC->IsWire(myCompoundWireMap(S));
416 //=======================================================================
419 //=======================================================================
421 const TopoDS_Shape& BRepAlgo_DSAccess::Wire(const TopoDS_Shape& S)
429 TopExp_Explorer Explor(S, TopAbs_EDGE);
430 for(;Explor.More(); Explor.Next()) BB.Add(myWire, Explor.Current());
435 //=======================================================================
436 //function : SectionVertex
438 //=======================================================================
440 const TopTools_ListOfShape& BRepAlgo_DSAccess::SectionVertex
441 (const TopoDS_Shape& F,
442 const TopoDS_Shape& E)
444 TopTools_ListOfShape Result;
446 if(F.ShapeType() != TopAbs_FACE) return myEmptyListOfShape;
447 if(E.ShapeType() != TopAbs_EDGE) return myEmptyListOfShape;
448 Standard_Integer iF = myHDS->Shape(F), iE = myHDS->Shape(E);
449 if((iF == 0) || (iE == 0)) return myEmptyListOfShape;
451 const TopOpeBRepDS_DataStructure& DS = myHDS->DS();
452 const TopOpeBRepDS_ListOfInterference& LI =
453 DS.ShapeInterferences(E, Standard_False);
454 TopOpeBRepDS_InterferenceIterator II(LI);
455 Standard_Integer goodIndex = 0;
456 TopOpeBRepDS_Kind goodKind;
457 for(;II.More();II.Next()) {
458 Handle(TopOpeBRepDS_Interference)& I = II.Value();
459 const TopOpeBRepDS_Transition& T = I->Transition();
460 if((T.ONAfter() == TopAbs_FACE) &&
461 (T.IndexAfter() == iF)) {
462 goodKind = I->GeometryType();
463 goodIndex = I->Geometry();
464 if(goodKind == TopOpeBRepDS_VERTEX)
465 Result.Append(myHDS->Shape(goodIndex));
467 if (goodKind == TopOpeBRepDS_POINT)
468 Result.Append(myHB->NewVertex(goodIndex));
471 myListOfVertex = Result;
472 return myListOfVertex;
478 //=======================================================================
479 //function : SuppressEdgeSet
481 //=======================================================================
483 void BRepAlgo_DSAccess::SuppressEdgeSet
484 (const TopoDS_Shape& C)
486 // It is checked if C really is a Coumpound of connected Edges
488 myHB->InitExtendedSectionDS();
489 // myGetSectionIsDone = Standard_False;
491 TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected);
492 for(;LLS.More(); LLS.Next())
502 myListOfCompoundOfEdgeConnected.Remove(LLS);
505 //=======================================================================
506 //function : ChangeEdgeSet
508 //=======================================================================
510 void BRepAlgo_DSAccess::ChangeEdgeSet
511 (const TopoDS_Shape& Old, const TopoDS_Shape& New)
513 // It is checked if Old is a Coumpound of connected Edges
515 myHB->InitExtendedSectionDS();
517 TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected);
518 for(;LLS.More(); LLS.Next())
519 if(Old == LLS.Value())
524 // The compound of Edges to be rotated is constructed
526 Standard_Boolean Trouve;
531 TColStd_SetOfInteger RPoint; //The points to be controlled
533 TopOpeBRepDS_ListIteratorOfListOfInterference iter;
534 TopExp_Explorer exp(Old, TopAbs_EDGE);
535 TopExp_Explorer exp2;
536 for(; exp.More(); exp.Next()) {
537 const TopoDS_Shape& Edge = exp.Current();
538 for(exp2.Init(New, TopAbs_EDGE), Trouve=Standard_False;
539 exp2.More() && (!Trouve); exp2.Next()) {
540 E = TopoDS::Edge(exp2.Current());
541 Trouve = E.IsSame(Edge);
544 if (!Trouve) B.Add(C, Edge); // Edge to be removed
545 else if (!E.IsEqual(Edge)) {
546 // It is necessary to change Interferences => take the complement
547 iC = myHB->GetDSCurveFromSectEdge(Edge);
550 cout << "Warning DSAccess: Modifications of Edge are not implemented" << endl;
554 // Complete the interferences Curve/Face
556 Handle(TopOpeBRepDS_Interference) interf;
558 iF = myHB->GetDSFaceFromDSCurve(iC, 1);
559 TopOpeBRepDS_ListOfInterference& list1 =
560 myHDS->ChangeDS().ChangeShapeInterferences(iF);
561 for(iter.Initialize(list1); iter.More(); iter.Next()) {
562 interf = iter.Value();
563 if (interf->Geometry() == iC)
564 interf->Transition(interf->Transition().Complement());
566 iF = myHB->GetDSFaceFromDSCurve(iC, 2);
567 TopOpeBRepDS_ListOfInterference& list2 =
568 myHDS->ChangeDS().ChangeShapeInterferences(iF);
569 for(iter.Initialize(list2); iter.More(); iter.Next()) {
570 interf = iter.Value();
571 if (interf->Geometry() == iC)
572 interf->Transition(interf->Transition().Complement());
574 // The associated points are recorded
575 Standard_Integer ipv1, ipv2;
576 //Standard_Boolean bid; // skl
577 TopOpeBRepDS_Kind k1, k2;
578 PntVtxOnCurve(iC, ipv1, k1, ipv2, k2);
579 if (ipv1 != 0) /*bid = */RPoint.Add(ipv1); // skl
580 if (ipv2 != 0) /*bid = */RPoint.Add(ipv2); // skl
589 // Is it necessary to invert the Interferences "Edge on Fa"
590 if (!RPoint.IsEmpty()) {
591 const TopOpeBRepDS_DataStructure & DS = myHDS->DS();
592 Standard_Integer iP,iE, nbShape = DS.NbShapes();
593 Handle(TopOpeBRepDS_Interference) interf;
594 for (iE=1; iE<=nbShape; iE++) {
595 if (DS.Shape(iE,0).ShapeType() == TopAbs_EDGE) {
596 const TopOpeBRepDS_ListOfInterference& List =
597 myHDS->DS().ShapeInterferences(iE);
598 for(iter.Initialize(List); iter.More(); iter.Next()) {
599 interf = iter.Value();
600 if (interf->GeometryType() == TopOpeBRepDS_POINT) {
601 iP = interf->Geometry();
602 if (RPoint.Contains(iP))
603 interf->Transition(interf->Transition().Complement());
610 // The old is replaced by new
615 //=======================================================================
618 //=======================================================================
620 void BRepAlgo_DSAccess::Suppress(const TopoDS_Shape& C,
621 const TopoDS_Shape& Keep)
623 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
624 TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder();
625 Standard_Integer i, iC = 0, iF1, iF2,iE1, iE2;
626 // TopOpeBRepDS_ListIteratorOfListOfInterference;
627 TColStd_ListIteratorOfListOfInteger it1, it2;
629 //A group of points to be kept is constructed
630 mySetOfKeepPoint.Clear();
631 if (!Keep.IsNull()) {
632 //Standard_Boolean B; // skl
633 Standard_Integer ipv1, ipv2;
634 TopOpeBRepDS_Kind k1, k2;
635 TopExp_Explorer exp(Keep, TopAbs_EDGE);
636 for(; exp.More(); exp.Next()) {
637 const TopoDS_Shape& SectEdge = exp.Current();
638 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
640 PntVtxOnSectEdge(SectEdge, ipv1, k1, ipv2, k2);
642 PntVtxOnCurve(iC, ipv1, k1, ipv2, k2);
643 if (ipv1 != 0) /*B = */mySetOfKeepPoint.Add(ipv1); // skl
644 if (ipv2 != 0) /*B = */mySetOfKeepPoint.Add(ipv2); // skl
648 // The curves, which generated the the Edges, are found
649 // during the parsing the Edges which come from Edge are found
650 // (= MapOfInteger : ESE)
652 // First, the interferences of support 1d.
653 TopExp_Explorer exp(C, TopAbs_EDGE);
654 for(; exp.More(); exp.Next()) {
655 const TopoDS_Shape& SectEdge = exp.Current();
656 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
658 // the Edges that come from Edge are processed
659 // the interferences connected with Edges are processed :
660 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
661 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
663 RemoveEdgeInterferences(iE1,iE2,SectEdge);
665 TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1);
666 TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2);
667 for(it1.Initialize(loi11); it1.More(); it1.Next()) {
669 for(it2.Initialize(loi12); it2.More(); it2.Next()) {
671 // similar to the case of SectEdges coming from curve.
672 RemoveEdgeInterferences(iF1,iF2,SectEdge);
675 TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1);
676 TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2);
677 for(it1.Initialize(loi21); it1.More(); it1.Next()) {
679 for(it2.Initialize(loi22); it2.More(); it2.Next()) {
681 // similar to the case of SectEdges coming from curve.
682 RemoveEdgeInterferences(iF1,iF2,SectEdge);
687 // The Edges that come from Curve are processed
688 iF1 = myHB->GetDSFaceFromDSCurve(iC, 1);
689 iF2 = myHB->GetDSFaceFromDSCurve(iC, 2);
691 RemoveEdgeInterferences(iF1, iF2, iC);
692 DS.ChangeKeepCurve(iC, FindKeep);
695 // Secondly, the interferences of 2D support.
696 exp.Init(C, TopAbs_EDGE);
697 for(; exp.More(); exp.Next()) {
698 const TopoDS_Shape& SectEdge = exp.Current();
699 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
701 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
702 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
703 TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1);
704 TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2);
705 for(it1.Initialize(loi11); it1.More(); it1.Next()) {
707 for(it2.Initialize(loi12); it2.More(); it2.Next()) {
711 RemoveFaceInterferences(iF1, iF2, iE1, iE2);
714 TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1);
715 TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2);
716 for(it1.Initialize(loi21); it1.More(); it1.Next()) {
718 for(it2.Initialize(loi22); it2.More(); it2.Next()) {
722 RemoveFaceInterferences(iF1, iF2, iE1, iE2);
727 iF1 = myHB->GetDSFaceFromDSCurve(iC, 1);
728 iF2 = myHB->GetDSFaceFromDSCurve(iC, 2);
730 RemoveFaceInterferences(iF1, iF2, iC);
734 // Thirdly, RemoveSameDomain is done for the faces that contain all Edges of C,
735 // and are SameDomain and without Geometry.
737 RemoveFaceSameDomain(C);
739 // Fourthly, the faces, that were not concerned, are removed
740 Standard_Integer NbSh = DS.NbShapes();
741 for(i = 1; i <= NbSh; i++) {
742 const TopoDS_Shape& Face = DS.Shape(i);
745 if((Face.ShapeType() != TopAbs_FACE) || DS.HasGeometry(Face) ||
746 (myHDS->HasSameDomain(Face)))
748 for(exp.Init(Face, TopAbs_EDGE); exp.More(); exp.Next()){
749 const TopoDS_Shape& Edge = exp.Current();
750 if(DS.HasShape(Edge))
755 DS.ChangeKeepShape(Face, Standard_False);
758 // Builder.myKPMAPf1f2 is reconstructed
759 Builder.FindIsKPart();
761 // The Edges of section are removed from Builder.mySplitON
762 exp.Init(C, TopAbs_EDGE);
763 for(; exp.More(); exp.Next()) {
764 const TopoDS_Shape& SectE= exp.Current();
765 TopTools_ListOfShape& losob = Builder.ChangeSplit(SectE, TopAbs_ON);
770 //=======================================================================
771 //function : SuppressSectionVertex
773 //=======================================================================
775 void BRepAlgo_DSAccess::SuppressSectionVertex
776 (const TopoDS_Vertex& /*V*/)
778 if(!myRecomputeBuilderIsDone)
783 // Reconstruction of Shapes
785 //=======================================================================
788 //=======================================================================
790 const TopoDS_Shape& BRepAlgo_DSAccess::Merge
791 (const TopAbs_State state1,
792 const TopAbs_State state2)
794 if((state1 != TopAbs_IN) &&
795 (state1 != TopAbs_OUT))
797 if((state2 != TopAbs_IN) &&
798 (state2 != TopAbs_OUT))
800 // if GetSectionEdgeSet has already been called, nothing is done
801 // in GetSectionEdgeSet.
802 if(myState1 != TopAbs_UNKNOWN)
803 if(myState1 != state1 || myState2 != state2)
804 myGetSectionIsDone = Standard_False;
810 myHB->MergeShapes(myS1,state1,myS2,state2);
811 const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1);
814 myResultShape.Nullify();
815 BB.MakeCompound(TopoDS::Compound(myResultShape));
816 TopTools_ListIteratorOfListOfShape it(L1);
817 for(;it.More(); it.Next()) {
818 BB.Add(myResultShape, it.Value());
820 return myResultShape;
823 //=======================================================================
826 //=======================================================================
828 const TopoDS_Shape& BRepAlgo_DSAccess::Merge
829 (const TopAbs_State state1)
831 if((state1 != TopAbs_IN) &&
832 (state1 != TopAbs_OUT))
837 myHB->MergeSolid(myS1,state1);
838 const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1);
841 myResultShape.Nullify();
842 BB.MakeCompound(TopoDS::Compound(myResultShape));
843 TopTools_ListIteratorOfListOfShape it(L1);
844 for(;it.More(); it.Next()) {
845 BB.Add(myResultShape, it.Value());
847 return myResultShape;
850 //=======================================================================
851 //function : Propagate
853 //=======================================================================
855 const TopoDS_Shape& BRepAlgo_DSAccess::Propagate
856 (const TopAbs_State what,
857 const TopoDS_Shape& /*fromShape*/,
858 const TopoDS_Shape& /*LoadShape*/)
860 if((what != TopAbs_IN) &&
861 (what != TopAbs_OUT))
863 if(!myRecomputeBuilderIsDone)
866 // myHB->MergeShapes(myS1,t1,myS2,t2);
869 static TopoDS_Shape bid;
873 //=======================================================================
874 //function : PropagateFromSection
876 //=======================================================================
878 const TopoDS_Shape& BRepAlgo_DSAccess::PropagateFromSection
879 (const TopoDS_Shape& SectionShape)
882 TopTools_ListIteratorOfListOfShape ils(myListOfCompoundOfEdgeConnected);
884 for(; ils.More(); ils.Next()) {
885 const TopoDS_Shape& SetEdgSet = ils.Value();
886 exp.Init(SetEdgSet, TopAbs_EDGE);
887 for(; exp.More(); exp.Next()) {
888 if(SectionShape.IsSame(exp.Current()))
895 //=======================================================================
896 //function : Modified
898 //=======================================================================
900 const TopTools_ListOfShape& BRepAlgo_DSAccess::Modified (const TopoDS_Shape& Shape)
904 // Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ;
905 TopTools_ListIteratorOfListOfShape Iterator ;
907 if (myHB->IsSplit (Shape, TopAbs_OUT)) {
908 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_OUT)) ;
911 myModified.Append (Iterator.Value()) ;
914 if (myHB->IsSplit (Shape, TopAbs_IN)) {
915 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_IN)) ;
918 myModified.Append (Iterator.Value()) ;
921 if (myHB->IsSplit (Shape, TopAbs_ON)) {
922 for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_ON)) ;
925 myModified.Append (Iterator.Value()) ;
929 if (myHB->IsMerged (Shape, TopAbs_OUT)) {
930 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_OUT)) ;
933 myModified.Append (Iterator.Value()) ;
936 if (myHB->IsMerged(Shape, TopAbs_IN)) {
937 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_IN)) ;
940 myModified.Append (Iterator.Value()) ;
943 if (myHB->IsMerged(Shape, TopAbs_ON)) {
944 for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_ON)) ;
947 myModified.Append (Iterator.Value()) ;
956 //=======================================================================
959 //=======================================================================
961 BRepAlgo_CheckStatus BRepAlgo_DSAccess::Check()
963 // TopOpeBRepDS_Check Ck(HDS);
964 // to be precised : in Ck, there is a possibility to know
965 // exactly the n*n of shapes/points/curves/surfaces,
966 // which are not correct in the DS.
967 // Standard_Boolean IsOK = Ck.ChkIntgSamDom() ;
968 // IsOK = IsOK && Ck.OneVertexOnPnt();
969 // IsOK = IsOK && Ck.ChkIntg();
971 // return TopOpeBRepDS_OK;
975 //=======================================================================
976 //function : RemoveEdgeInterferences
977 //purpose : case of SectEdge coming from Edge(s)
979 // if iE1 and iE2 are Edges :
980 // Remove interferences of DSEdge(= iE1 or iE2) of
981 // geometry a vertex of SectEdge, and if there is nothing else,
982 // make unkeep on DSEdge
983 // if iE1 or iE2 == 0, no interference on Edges in the DS
984 // NYI : management of SameDomain
986 // if iE1 and iE2 are Faces :
987 // for each of faces F1 and F2, explode into Edges
989 // remove the interferences of a SectEdge vertex
990 // on geometry. If there is no other interferences attached to
991 // these Edges, and if these Edges are not SameDomain,
993 //=======================================================================
995 void BRepAlgo_DSAccess::RemoveEdgeInterferences
996 (const Standard_Integer iE1,
997 const Standard_Integer iE2,
998 const TopoDS_Shape& SectEdge)
1003 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1004 TopOpeBRepDS_Kind kind1, kind2;
1005 TopExp_Explorer exp(SectEdge, TopAbs_VERTEX);
1006 Standard_Integer i = 1, ipv1, ipv2;
1008 // the Vertex/Points of SectEdge are retrieved
1009 PntVtxOnSectEdge(SectEdge, ipv1, kind1, ipv2, kind2);
1011 const TopoDS_Shape& Shape = DS.Shape(iE1, FindKeep);
1014 if(Shape.ShapeType() == TopAbs_FACE) {
1015 Standard_Integer iF1 = iE1, iF2 = iE2;
1016 RemoveEdgeInterferencesFromFace(iF1, iF2, ipv1, kind1, ipv2, kind2);
1019 else if(Shape.ShapeType() != TopAbs_EDGE)
1022 // the interferences are taken from the DS
1023 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1024 TopOpeBRepDS_Kind gk;
1025 Standard_Integer iCurrE1, iCurrE2, gi;
1026 // Standard_Boolean RemInterf;
1028 for(i = 1; i <= 2; i++) {
1029 iCurrE1 = ((i == 1) ? iE1 : iE2);
1030 iCurrE2 = ((i == 1) ? iE2 : iE1);
1031 const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep);
1034 TopOpeBRepDS_ListOfInterference& loi =
1035 DS.ChangeShapeInterferences(DSEdge);
1036 // RemInterf = Standard_True;
1037 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1038 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1039 if (I.IsNull()) continue;
1040 if((I->SupportType() != TopOpeBRepDS_EDGE) ||
1041 (I->Support() != iCurrE2)) {
1042 // RemInterf = Standard_False;//debug ...
1045 gk = I->GeometryType();
1049 DS.RemoveShapeInterference(DSEdge, I);
1050 if(!DS.HasGeometry(DSEdge)) {
1051 // if(RemInterf || (!lioloi.More())) {
1052 RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain
1053 DS.ChangeKeepShape(iCurrE1, FindKeep);
1058 else if(gk == kind2) {
1060 DS.RemoveShapeInterference(DSEdge, I);
1061 if(!DS.HasGeometry(DSEdge)) {
1062 // if(RemInterf || (!lioloi.More())) {//debug
1063 RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain
1064 DS.ChangeKeepShape(iCurrE1, FindKeep);
1073 //=======================================================================
1074 //function : RemoveEdgeInterferences
1075 //purpose : case of SectEdge coming from Curve
1076 // for each of faces F1 and F2, explode into Edges
1078 // remove the interferences that have a vertex of SectEdge
1079 // as a geometry. If no other interferences are attached to
1080 // these Edges, and if the Edges are not SameDomain,
1081 // make unKeepShape.
1082 //=======================================================================
1084 void BRepAlgo_DSAccess::RemoveEdgeInterferences
1085 (const Standard_Integer iF1,
1086 const Standard_Integer iF2,
1087 const Standard_Integer iCurve)
1089 TopOpeBRepDS_Kind gk1, gk2;
1090 Standard_Integer gi1, gi2;
1092 PntVtxOnCurve(iCurve, gi1, gk1, gi2, gk2);
1094 if (!mySetOfKeepPoint.IsEmpty()) {
1095 if (mySetOfKeepPoint.Contains(gi1)) gi1 = 0;
1096 if (mySetOfKeepPoint.Contains(gi2)) gi2 = 0;
1100 RemoveEdgeInterferencesFromFace(iF1, iF2, gi1, gk1, gi2, gk2);
1103 //=======================================================================
1104 //function : RemoveFaceInterferences
1105 //purpose : case of SectEdge coming from Edge(s)
1106 // Remove interferences between F1 and F2 concerning
1107 // DSEdge (= E1 or E2) :
1108 // a) if DSEdge is not SameDomain -> the edge is Removed
1109 // b) if among other interferences of DSEdge of
1110 // GeomtryType == VERTEX, there is none
1111 // with Edge of DSFace(= F1 or F2)
1112 // if DSFace has no more interferences and is not SameDomain,
1113 // make unkeep DSFace.
1114 //=======================================================================
1116 void BRepAlgo_DSAccess::RemoveFaceInterferences
1117 (const Standard_Integer iF1,
1118 const Standard_Integer iF2,
1119 const Standard_Integer iE1,
1120 const Standard_Integer iE2)
1124 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1125 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;//, lioloei, liolofi;
1126 TopTools_ListIteratorOfListOfShape liolos;
1127 TopOpeBRepDS_Kind gk;
1128 TopExp_Explorer exp;
1129 Standard_Integer i, iCurrF1, iCurrF2, j, iCurrE1, /*iCurrE2,*/ gi; // skl
1130 Standard_Boolean RemInterf;
1132 for(i = 1; i <= 2; i++) {
1133 iCurrF1 = ((i == 1) ? iF1 : iF2);
1134 iCurrF2 = ((i == 1) ? iF2 : iF1);
1135 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1);
1138 const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace);
1139 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1140 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1141 if (I.IsNull()) continue;
1142 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1143 (I->Support() != iCurrF2)) {
1146 gk = I->GeometryType();
1148 if(gk != TopOpeBRepDS_EDGE) continue;
1149 for(j = 1; j <= 2; j++) {
1150 iCurrE1 = ((j == 1) ? iE1 : iE2);
1151 //iCurrE2 = ((j == 1) ? iE2 : iE1); // skl
1152 if(gi != iCurrE1) continue;
1153 // a) if DSEdge is not SameDomain -> the interference is Removed
1155 const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep);
1158 if(!myHDS->HasSameDomain(DSEdge)) {
1159 if(!DS.HasGeometry(DSEdge)) {
1160 DS.RemoveShapeInterference(DSFace, I);
1161 DS.ChangeKeepShape(DSEdge, FindKeep);
1163 // NYI : manage the case when the geometry of DSEdge
1164 // NYI : is not connected anyhow with two faces
1166 if(!DS.HasGeometry(DSFace)) {
1167 DS.ChangeKeepShape(DSFace, FindKeep);
1171 // b) if no Edges of SameDomain(DSEdge),
1172 // belong to DSFace(= F1 or F2)
1173 // -> the interference is removed
1174 const TopoDS_Shape& Edge = DS.Shape(iCurrE1, FindKeep);
1177 const TopTools_ListOfShape& loe = DS.ShapeSameDomain(Edge);
1178 RemInterf = Standard_True;
1179 for(liolos.Initialize(loe); liolos.More(); liolos.Next()) {
1180 const TopoDS_Shape& ESD = liolos.Value();
1181 for(exp.Init(DSFace, TopAbs_EDGE); exp.More(); exp.Next()) {
1182 if(ESD.IsSame(exp.Current())) {
1183 RemInterf = Standard_False;
1187 if(!RemInterf) break;
1190 // RemoveSameDomain(iCurrF1, iCurrF2);
1192 if(!DS.HasGeometry(DSFace)) {
1193 if(!myHDS->HasSameDomain(DSFace))
1194 DS.ChangeKeepShape(DSFace, FindKeep);
1197 if(!DS.HasGeometry(DSFace) && !myHDS->HasSameDomain(DSFace))
1198 DS.ChangeKeepShape(DSFace, FindKeep);
1204 //=======================================================================
1205 //function : RemoveFaceInterferences
1206 //purpose : case of SectEdge from Curve
1207 // remove interferences of Geometry iCurve between F1 and F2.
1208 // if Face(= F1 or F2) has noother interference, and if Face
1209 // is not SameDomain, make unKeepShape Face.
1210 //=======================================================================
1212 void BRepAlgo_DSAccess::RemoveFaceInterferences
1213 (const Standard_Integer iF1,
1214 const Standard_Integer iF2,
1215 const Standard_Integer iCurve)
1217 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1218 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1219 TopOpeBRepDS_Kind gk;
1220 Standard_Integer i, iCurrF1, iCurrF2, gi;
1222 for(i = 1; i <= 2; i++) {
1223 iCurrF1 = ((i == 1) ? iF1 : iF2);
1224 iCurrF2 = ((i == 1) ? iF2 : iF1);
1225 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1);
1226 const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace);
1227 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1228 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1229 if (I.IsNull()) continue;
1230 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1231 (I->Support() != iCurrF2)) {
1235 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1236 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1237 if (I.IsNull()) continue;
1238 if((I->SupportType() != TopOpeBRepDS_FACE) ||
1239 (I->Support() != iCurrF2)) {
1242 gk = I->GeometryType();
1244 if(gk != TopOpeBRepDS_CURVE) continue;
1245 if(gi != iCurve) continue;
1246 DS.RemoveShapeInterference(DSFace, I);
1247 // const TopoDS_Shape& interferenceface = DS.Shape(iCurrF2);
1248 // DS.RemoveShapeInterference(interferenceface, I);
1249 if(!DS.HasGeometry(DSFace)) {
1250 const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSFace);
1252 DS.ChangeKeepShape(DSFace, FindKeep);
1254 // if(!DS.HasGeometry(interferenceface)) {
1255 // const TopTools_ListOfShape& los = DS.ShapeSameDomain(interferenceface);
1256 // if(los.IsEmpty())
1257 // DS.ChangeKeepShape(interferenceface, FindKeep);
1263 //=======================================================================
1264 //function : RemoveEdgeInterferencesFromFace
1265 //purpose : Remove interferences of Edges from iF1 or iF2
1266 // that have GeometryType kind1/kind2 and
1267 // Geometry ipv1/ipv2.
1268 // if kind1/kind2 == TopAbs_VERTEX -> RemoveEdgeFromFace
1269 //=======================================================================
1271 void BRepAlgo_DSAccess::RemoveEdgeInterferencesFromFace
1272 (const Standard_Integer iF1,
1273 const Standard_Integer iF2,
1274 const Standard_Integer ipv1,
1275 const TopOpeBRepDS_Kind kind1,
1276 const Standard_Integer ipv2,
1277 const TopOpeBRepDS_Kind kind2)
1279 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1280 TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;
1281 TopExp_Explorer exp, exp2;
1282 TopOpeBRepDS_Kind sk, gk;
1283 Standard_Integer i, iCurrF1, iCurrF2, iE = 0, si, gi;
1285 for(i = 1; i <= 2; i++) {
1286 iCurrF1 = ((i == 1) ? iF1 : iF2);
1287 iCurrF2 = ((i == 1) ? iF2 : iF1);
1288 const TopoDS_Shape& DSFace = DS.Shape(iCurrF1, FindKeep);
1291 exp.Init(DSFace, TopAbs_EDGE);
1292 for(; exp.More(); exp.Next()) {
1293 const TopoDS_Shape& DSEdge = exp.Current();
1294 iE = DS.Shape(DSEdge, FindKeep);
1296 const TopOpeBRepDS_ListOfInterference& loi =
1297 DS.ShapeInterferences(DSEdge);
1298 for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) {
1299 Handle(TopOpeBRepDS_Interference) I = lioloi.Value();
1300 if (I.IsNull()) continue;
1301 sk = I->SupportType();
1303 if((sk != TopOpeBRepDS_FACE) || (si != iCurrF2)) {
1304 if(sk != TopOpeBRepDS_EDGE)
1306 const TopoDS_Shape& DSFace2 = DS.Shape(iCurrF2, FindKeep);
1307 exp2.Init(DSFace2, TopAbs_EDGE);
1308 for(; exp2.More(); exp2.Next()) {
1309 if(si == DS.Shape(exp2.Current(), FindKeep))
1315 gk = I->GeometryType();
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);
1327 else if(gk == kind2) {
1329 DS.RemoveShapeInterference(DSEdge, I);
1330 // if(!DS.HasGeometry(DSEdge)) {
1331 // const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge);
1332 // if(los.IsEmpty()) {
1333 // DS.ChangeKeepShape(iE, FindKeep);
1342 if(kind1 == TopOpeBRepDS_VERTEX)
1343 RemoveEdgeFromFace(iCurrF1,ipv1);
1344 if(kind2 == TopOpeBRepDS_VERTEX)
1345 RemoveEdgeFromFace(iCurrF1,ipv2);
1349 //=======================================================================
1350 //function : RemoveEdgeFromFace
1351 //purpose : Remove from DS the Edges, which belong to iF
1352 // and have iV as vertex if they do not have Geometry and
1353 // are not SameDomain.
1354 //=======================================================================
1356 void BRepAlgo_DSAccess::RemoveEdgeFromFace
1357 (const Standard_Integer iF,
1358 const Standard_Integer iV)
1362 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1363 const TopoDS_Shape& DSFace = DS.Shape(iF, FindKeep);
1364 const TopoDS_Shape& Vertex = DS.Shape(iV, FindKeep);
1365 if(DSFace.IsNull() || Vertex.IsNull())
1367 TopExp_Explorer exp(DSFace, TopAbs_EDGE), exp2;
1368 for(; exp.More(); exp.Next()) {
1369 const TopoDS_Shape& Edge = exp.Current();
1371 // Standard_Integer iEdge2 = DS.Shape(Edge, FindKeep);
1372 // Standard_Integer iEdge3 = DS.Shape(Edge);
1375 if(!DS.HasShape(Edge))
1377 exp2.Init(Edge, TopAbs_VERTEX);
1378 for(; exp2.More(); exp2.Next()) {
1380 // Standard_Integer iEdge5 = DS.Shape(Vertex, FindKeep);
1381 // Standard_Integer iEdge4 = DS.Shape(Vertex);
1382 // Standard_Integer iEdge6 = DS.Shape(exp2.Current(), FindKeep);
1383 // Standard_Integer iEdge7 = DS.Shape(exp2.Current());
1386 if(Vertex.IsSame(exp2.Current())) {
1387 if(!DS.HasGeometry(Edge)) {
1388 const TopTools_ListOfShape& los = DS.ShapeSameDomain(Edge);
1391 // Standard_Integer iEdge = DS.Shape(Edge);
1393 DS.ChangeKeepShape(Edge, FindKeep);
1401 //=======================================================================
1402 //function : PntVtxOnCurve
1403 //purpose : To find the points/vertices on curves
1404 //=======================================================================
1406 void BRepAlgo_DSAccess::PntVtxOnCurve
1407 (const Standard_Integer iCurve,
1408 Standard_Integer& ipv1,
1409 TopOpeBRepDS_Kind& pvk1,
1410 Standard_Integer& ipv2,
1411 TopOpeBRepDS_Kind& pvk2)
1413 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1415 const TopOpeBRepDS_Curve& C = DS.Curve(iCurve);
1416 TopOpeBRepDS_Kind pvk;
1417 Standard_Integer ipv, iMother = C.Mother(), igoodC = iCurve, comp = 0;
1418 if(iMother) igoodC = iMother;
1420 TopOpeBRepDS_PointIterator PII = myHDS->CurvePoints(igoodC);
1421 TopOpeBRepDS_PointIterator& PIt = PII; // skl : I change "M_PI" to "PIt"
1423 // TopOpeBRepDS_PointIterator& PIt = myHDS->CurvePoints(igoodC);
1425 for(;PIt.More(); PIt.Next()) {
1428 // Standard_Error ...
1430 ipv = PIt.Current();
1431 // a point or a vertex is removed from the DS
1433 pvk = TopOpeBRepDS_POINT;
1434 DS.ChangeKeepPoint(ipv, FindKeep);
1436 else if(PIt.IsVertex()) {
1437 pvk = TopOpeBRepDS_VERTEX;
1438 DS.ChangeKeepShape(ipv, FindKeep);
1441 ((comp == 1) ? ipv1 : ipv2) = ipv;
1442 ((comp == 1) ? pvk1 : pvk2) = pvk;
1446 //=======================================================================
1447 //function : PntVtxOnSectEdge
1448 //purpose : Points/Vertexes on SectEdge are found
1449 //=======================================================================
1451 void BRepAlgo_DSAccess::PntVtxOnSectEdge
1452 (const TopoDS_Shape& SectEdge,
1453 Standard_Integer& ipv1,
1454 TopOpeBRepDS_Kind& pvk1,
1455 Standard_Integer& ipv2,
1456 TopOpeBRepDS_Kind& pvk2)
1458 // myHB->ChangeBuilder();
1459 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1460 TopOpeBRepDS_Kind kind = TopOpeBRepDS_POINT;
1461 TopExp_Explorer exp(SectEdge, TopAbs_VERTEX);
1462 Standard_Integer i = 1, ipv;
1464 for(; exp.More(); exp.Next(), i++) {
1465 const TopoDS_Shape& DSVertex = exp.Current();
1466 ipv = myHB->GetDSPointFromNewVertex(DSVertex);
1468 ipv = DS.Shape(DSVertex, FindKeep);
1469 kind = TopOpeBRepDS_VERTEX;
1471 // Standard_Error ...
1484 // Standard_Error ...
1489 //=======================================================================
1490 //function : RemoveEdgeSameDomain
1492 //=======================================================================
1494 void BRepAlgo_DSAccess::RemoveEdgeSameDomain
1495 (const Standard_Integer /*iE1*/,
1496 const Standard_Integer /*iE2*/)
1499 /* TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1500 const TopoDS_Shape& E1 = DS.Shape(iE1);
1501 const TopoDS_Shape& E2 = DS.Shape(iE2);
1502 TopAbs_ShapeEnum ts1, ts2;
1503 ts1 = E1.ShapeType();
1504 ts2 = E2.ShapeType();
1505 if((ts1 != TopAbs_EDGE) ||
1506 (ts2 != TopAbs_EDGE))
1508 TopTools_ListOfShape& lossd = DS.ChangeShapeSameDomain(E1);
1511 Standard_Integer exte = lossd.Extent();
1513 if(lossd.First().IsSame(E2))
1514 DS.UnfillShapesSameDomain(E1,E2);
1519 //=======================================================================
1520 //function : RemoveFaceSameDomain
1521 //purpose : remove SameDomain information of glued faces
1522 //=======================================================================
1524 void BRepAlgo_DSAccess::RemoveFaceSameDomain
1525 (const TopoDS_Shape& C)
1527 // myHB->ChangeBuilder();
1528 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1530 //TColStd_ListIteratorOfListOfInteger it;
1531 TopExp_Explorer exp(C, TopAbs_EDGE);
1532 Standard_Integer iE1, iE2, iE, /*NbF,*/ iF1, iF2, iCurrF1, iCurrF2, iC =0; // skl
1533 iF1 = iF2 = iCurrF1 = iCurrF2 = 0;
1535 const TopoDS_Shape& SectEdge = exp.Current();
1537 for(; exp.More(); exp.Next()) {
1538 iC = myHB->GetDSCurveFromSectEdge(SectEdge);
1539 if(!iC && !SectEdge.IsNull())
1541 // const TopoDS_Shape& SectEdge = exp.Current();
1543 if(!iC && !SectEdge.IsNull()) {
1544 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1);
1545 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2);
1546 if(iE1 && iE2) return;
1547 iE = (iE1 ? iE1 : iE2);
1550 TColStd_ListOfInteger& loi = FindGoodFace(iE, iF1, b);
1554 //NbF = loi.Extent(); // skl
1555 for(; exp.More(); exp.Next()) {
1556 // skl : I change "SectEdge" to "SectEdg"
1557 const TopoDS_Shape& SectEdg = exp.Current();
1558 iC = myHB->GetDSCurveFromSectEdge(SectEdg);
1560 iE1 = myHB->GetDSEdgeFromSectEdge(SectEdg, 1);
1561 iE2 = myHB->GetDSEdgeFromSectEdge(SectEdg, 2);
1562 if(iE1 && iE2) return;
1563 iE = (iE1 ? iE1 : iE2);
1566 TColStd_ListOfInteger& loi2 = FindGoodFace(iE, iCurrF1, b);
1568 if(!iCurrF1 || !iF1) return;
1569 if(iCurrF1 != iF1) {
1570 if(loi2.Extent() == 1) iCurrF2 = loi2.First();
1571 if(iCurrF2 == iF1) continue;
1572 if(loi.Extent() == 1) iF2 = loi.First();
1574 if(!iCurrF2 || !iF2) return;
1575 if((iCurrF1 == iF2) ||
1585 const TopoDS_Shape& FSD = DS.Shape(iF1);
1588 TopTools_ListOfShape& ssd = DS.ChangeShapeSameDomain(FSD);
1589 TopTools_ListIteratorOfListOfShape itssd(ssd);
1590 TopExp_Explorer exp2;
1591 for(; itssd.More(); itssd.Next()) {
1592 exp2.Init(itssd.Value(), TopAbs_VERTEX);
1593 for(; exp2.More(); exp2.Next()) {
1594 const TopoDS_Shape& exp2Curr = exp2.Current();
1595 exp.Init(C, TopAbs_VERTEX);
1596 for(; exp.More(); exp.Next()) {
1597 if(exp2Curr.IsSame(exp.Current()))
1608 const TopoDS_Shape& FSD2 = itssd.Value();
1609 Standard_Integer iFSD = DS.Shape(FSD), iFSD2 = DS.Shape(FSD2);
1610 RemoveFaceSameDomain(iFSD, iFSD2);
1611 // DS.UnfillShapesSameDomain(FSD, FSD2);
1616 //=======================================================================
1617 //function : FindGoodFace
1619 //=======================================================================
1621 TColStd_ListOfInteger& BRepAlgo_DSAccess::FindGoodFace
1622 (const Standard_Integer iE,
1623 Standard_Integer& iF1,
1624 Standard_Boolean& b)
1626 // myHB->ChangeBuilder();
1628 TColStd_ListOfInteger& loi = myHB->GetDSFaceFromDSEdge(iE, 1);
1629 if(loi.Extent() == 1) {
1632 TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2);
1636 TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2);
1637 if(loi2.Extent() == 1) {
1644 return myEmptyListOfInteger;
1647 //=======================================================================
1648 //function : RemoveFaceSameDomain
1650 //=======================================================================
1652 void BRepAlgo_DSAccess::RemoveFaceSameDomain
1653 (const Standard_Integer iF1,
1654 const Standard_Integer iF2)
1656 TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS();
1657 const TopoDS_Shape& F1 = DS.Shape(iF1, FindKeep);
1658 const TopoDS_Shape& F2 = DS.Shape(iF2, FindKeep);
1659 if(F1.IsNull() || F2.IsNull())
1663 Standard_Integer iref1 = DS.SameDomainRef(F1),
1664 iref2 = DS.SameDomainRef(F2), istart, iend;
1666 DS.SameDomainRef(F2,iF2);
1668 DS.SameDomainRef(F1,iF1);
1669 DS.UnfillShapesSameDomain(F1,F2);
1673 Standard_Boolean iF1iF2IsConnected = Standard_False;
1674 TColStd_IndexedMapOfInteger moi;
1685 Standard_Integer NbConnect = 0, icurr;
1686 while(moi.Extent() > NbConnect) {
1688 icurr = moi.FindKey(NbConnect);
1689 DS.SameDomainRef(icurr, istart);
1690 const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr);
1692 const TopoDS_Shape& SNSD = DS.Shape(icurr);
1693 DS.SameDomainRef(SNSD, 0);
1695 TopTools_ListIteratorOfListOfShape li(los);
1696 for(; li.More(); li.Next()) {
1697 Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep);
1700 if(iCurrShap == iend)
1701 iF1iF2IsConnected = Standard_True;
1705 if(!iF1iF2IsConnected) {
1709 while(moi.Extent() > NbConnect) {
1711 icurr = moi.FindKey(NbConnect);
1712 DS.SameDomainRef(icurr, iend);
1713 const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr);
1715 const TopoDS_Shape& SNSD = DS.Shape(icurr);
1716 DS.SameDomainRef(SNSD, 0);
1718 TopTools_ListIteratorOfListOfShape li(los);
1719 for(; li.More(); li.Next()) {
1720 Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep);
1729 //=======================================================================
1732 //=======================================================================
1734 const Handle(TopOpeBRepDS_HDataStructure)&
1735 BRepAlgo_DSAccess::DS() const
1740 //=======================================================================
1741 //function : changeDS
1743 //=======================================================================
1744 Handle(TopOpeBRepDS_HDataStructure)&
1745 BRepAlgo_DSAccess::ChangeDS()
1750 //=======================================================================
1751 //function : Builder
1753 //=======================================================================
1755 const Handle(TopOpeBRepBuild_HBuilder)&
1756 BRepAlgo_DSAccess::Builder() const
1761 //=======================================================================
1762 //function : ChangeBuilder
1764 //=======================================================================
1766 Handle(TopOpeBRepBuild_HBuilder)&
1767 BRepAlgo_DSAccess::ChangeBuilder()