// File: TopOpeBRep_ShapeIntersector2d.cxx // Created: Fri May 7 17:36:28 1993 // Author: Jean Yves LEBEY // #include #include #include #include #include #include #ifdef DEB extern Standard_Boolean TopOpeBRep_GettraceSI(); extern Standard_Boolean TopOpeBRep_GetcontextFFOR(); #endif //======================================================================= //function : TopOpeBRep_ShapeIntersector2d //purpose : //======================================================================= TopOpeBRep_ShapeIntersector2d::TopOpeBRep_ShapeIntersector2d() { Reset(); myHBoxTool = FBOX_GetHBoxTool(); myFaceScanner.ChangeBoxSort().SetHBoxTool(myHBoxTool); myEdgeScanner.ChangeBoxSort().SetHBoxTool(myHBoxTool); } //======================================================================= //function : Reset //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::Reset() { myIntersectionDone = Standard_False; myFFDone = Standard_False; myEEFFDone = Standard_False; myFFInit = Standard_False; myEEFFInit = Standard_False; } //======================================================================= //function : Init //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::Init (const TopoDS_Shape& S1, const TopoDS_Shape& S2) { Reset(); myShape1 = S1; myShape2 = S2; myHBoxTool->Clear(); } //======================================================================= //function : SetIntersectionDone //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::SetIntersectionDone() { myIntersectionDone = (myFFDone || myEEFFDone); } //======================================================================= //function : CurrentGeomShape //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRep_ShapeIntersector2d::CurrentGeomShape (const Standard_Integer Index) const { if ( myIntersectionDone ) { if (myFFDone) { if ( Index == 1 ) return myFaceScanner.Current(); else if ( Index == 2 ) return myFaceExplorer.Current(); } else if (myEEFFDone) { if ( Index == 1 ) return myEdgeScanner.Current(); else if ( Index == 2 ) return myEdgeExplorer.Current(); } } Standard_ProgramError::Raise("CurrentGeomShape : no intersection 2d"); TopoDS_Shape* bid = new TopoDS_Shape(); return *bid; } //======================================================================= //function : InitIntersection //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::InitIntersection (const TopoDS_Shape& S1, const TopoDS_Shape& S2) { Init(S1,S2); InitFFIntersection(); } //======================================================================= //function : MoreIntersection //purpose : //======================================================================= Standard_Boolean TopOpeBRep_ShapeIntersector2d::MoreIntersection() const { Standard_Boolean res = myIntersectionDone; #ifdef DEB if (TopOpeBRep_GettraceSI() && res) { if ( myFFDone ) cout<<"FF : "; else if ( myEEFFDone ) cout<<" EE : "; DumpCurrent(1); DumpCurrent(2); } #endif return res; } //======================================================================= //function : DumpCurrent //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::DumpCurrent(const Standard_Integer K) const { #ifdef DEB if ( myFFDone ) { if ( K == 1 ) myFaceScanner.DumpCurrent(cout); else if ( K == 2 ) myFaceExplorer.DumpCurrent(cout); } else if ( myEEFFDone ) { if ( K == 1 ) myEdgeScanner.DumpCurrent(cout); else if ( K == 2 ) myEdgeExplorer.DumpCurrent(cout); } #endif } //======================================================================= //function : Index //purpose : //======================================================================= Standard_Integer TopOpeBRep_ShapeIntersector2d::Index (const Standard_Integer K)const { Standard_Integer i = 0; #ifdef DEB if ( myFFDone ) { if ( K == 1 ) i = myFaceScanner.Index(); else if ( K == 2 ) i = myFaceExplorer.Index(); } else if ( myEEFFDone ) { if ( K == 1 ) i = myEdgeScanner.Index(); else if ( K == 2 ) i = myEdgeExplorer.Index(); } #endif return i; } //======================================================================= //function : NextIntersection //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::NextIntersection() { myIntersectionDone = Standard_False; if (myFFDone) { // precedant etat du More() : 2 faces myFFDone = Standard_False; InitEEFFIntersection(); FindEEFFIntersection(); if ( !myIntersectionDone ) { NextFFCouple(); FindFFIntersection(); } } else if ( myEEFFDone ) { NextEEFFCouple(); FindEEFFIntersection(); if ( !myIntersectionDone ) { NextFFCouple(); FindFFIntersection(); } } if ( !myIntersectionDone ) { InitFFIntersection(); } } // ======== // FFFFFFFF // ======== //======================================================================= //function : InitFFIntersection //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::InitFFIntersection() { if ( !myFFInit) { TopAbs_ShapeEnum tscann = TopAbs_FACE; TopAbs_ShapeEnum texplo = TopAbs_FACE; myFaceScanner.Clear(); myFaceScanner.AddBoxesMakeCOB(myShape1,tscann); myFaceExplorer.Init(myShape2,texplo); myFaceScanner.Init(myFaceExplorer); FindFFIntersection(); } myFFInit = Standard_True; } //======================================================================= //function : FindFFIntersection //purpose : //======================================================================= void TopOpeBRep_ShapeIntersector2d::FindFFIntersection() { myFFDone = Standard_False; // myFFSameDomain = Standard_False; while ( MoreFFCouple() ) { // The two candidate intersecting GeomShapes GS1,GS2 and their types t1,t2 const TopoDS_Shape& GS1 = myFaceScanner.Current(); const TopoDS_Shape& GS2 = myFaceExplorer.Current(); #ifdef DEB if (TopOpeBRep_GettraceSI()) { cout<<"?? FF : "; myFaceScanner.DumpCurrent(cout); myFaceExplorer.DumpCurrent(cout); cout<