// File: TopOpeBRep_EdgesFiller.cxx // Created: Wed Oct 12 16:18:53 1994 // Author: Jean Yves LEBEY // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB #include Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceEDSF(); Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceDSF(); Standard_IMPORT Standard_Boolean TopOpeBRep_GettraceEEFF(); Standard_EXPORT void debefre(const Standard_Integer IE) {cout<<"+++ debefre E"<ChangeDS()); myE1 = TopoDS::Edge(E1); myE2 = TopoDS::Edge(E2); myLI1.Clear(); myLI2.Clear(); myHDS = HDS; #ifdef DEB Standard_Boolean trc = TopOpeBRepDS_GettraceDSF(); trc = trc || TopOpeBRepDS_GettraceEDSF(); trc = trc || TopOpeBRep_GettraceEEFF(); if (trc) { if (TopOpeBRep_GettraceEEFF()) debeeff(); TCollection_AsciiString str="EdgesFiller dim";str=str+myPEI->Dimension(); myPEI->Dump(str,myPDS->Shape(myE1),myPDS->Shape(myE2)); } #endif Standard_Boolean esd = myPEI->SameDomain(); if (esd) myPDS->FillShapesSameDomain(E1,E2); // exit if no point. myPEI->InitPoint(); if ( !myPEI->MorePoint() ) return; // --- Add in BDS Standard_Integer E1index = myPDS->AddShape(E1,1); Standard_Integer E2index = myPDS->AddShape(E2,2); // --- get list of interferences connected to edges , TopOpeBRepDS_ListOfInterference& EIL1 = myPDS->ChangeShapeInterferences(E1); Handle(TopOpeBRepDS_Interference) EPI; //edge/point interference Handle(TopOpeBRepDS_Interference) EVI; //edge/vertex interference // TopOpeBRepDS_Transition TposF,TposL; for (; myPEI->MorePoint(); myPEI->NextPoint() ) { const TopOpeBRep_Point2d P2D = myPEI->Point(); Standard_Real par1 = P2D.Parameter(1); Standard_Real par2 = P2D.Parameter(2); #ifdef DEB Standard_Boolean pointofsegment = P2D.IsPointOfSegment(); if (trc) { if (pointofsegment && esd) debposesd(); else if (pointofsegment && !esd) debposnesd(); } #endif TopOpeBRepDS_Transition T1 = P2D.Transition(1); TopOpeBRepDS_Transition T2 = P2D.Transition(2); SetShapeTransition(P2D,T1,T2); Standard_Boolean isvertex1 = P2D.IsVertex(1); TopoDS_Vertex V1; if (isvertex1) V1 = P2D.Vertex(1); Standard_Boolean isvertex2 = P2D.IsVertex(2); TopoDS_Vertex V2; if (isvertex2) V2 = P2D.Vertex(2); Standard_Boolean isvertex = isvertex1 || isvertex2; #ifdef DEB if (isvertex1 && isvertex2) { gp_Pnt P3D1 = BRep_Tool::Pnt(V1); gp_Pnt P3D2 = BRep_Tool::Pnt(V2); Standard_Real tol1 = BRep_Tool::Tolerance(V1); Standard_Real tol2 = BRep_Tool::Tolerance(V2); Standard_Real dpp = P3D1.Distance(P3D2); if (dpp> tol1+tol2) { cout<ShapeInterferences(E1) ); Standard_Integer G; TopOpeBRepDS_Kind K; Standard_Boolean found = GetGeometry(itloI1,P2D,G,K); if (!found) MakeGeometry(P2D,G,K); Standard_Boolean foundpoint = (found) && (K == TopOpeBRepDS_POINT); #ifdef DEB Standard_Boolean foundvertex = (found) && (K == TopOpeBRepDS_VERTEX); #endif Standard_Boolean isnewpoint = (!found) && (K == TopOpeBRepDS_POINT); Standard_Boolean isnewvertex = (!found) && (K == TopOpeBRepDS_VERTEX); Standard_Boolean faulty = (isvertex && isnewpoint) || (!isvertex && isnewvertex); if (faulty) { #ifdef DEB cout<<"- - - faulty EdgesFiller : G "<StoreInterferences(linew,is,"EdgesFiller modif : "); } } // (is<=ns) } // (isvertex && foundpoint) if (isvertex1) { const TopoDS_Vertex& VV1 = V1; // const TopoDS_Vertex& VV1 = TopoDS::Vertex(V1); const TopoDS_Edge& EE1 = TopoDS::Edge(E1); par1 = BRep_Tool::Parameter(VV1,EE1); } if (isvertex2) { const TopoDS_Vertex& VV2 = V2; // const TopoDS_Vertex& VV2 = TopoDS::Vertex(V2); const TopoDS_Edge& EE2 = TopoDS::Edge(E2); par2 = BRep_Tool::Parameter(VV2,EE2); } if ( isvertex1 && isvertex2 ) { myPDS->FillShapesSameDomain(V1,V2); } Standard_Integer DSPindex; Standard_Boolean EPIfound; if ( ! isvertex ) { TopOpeBRepDS_Kind KKK; TopOpeBRepDS_ListIteratorOfListOfInterference itEIL1(EIL1); EPIfound = GetGeometry(itEIL1,P2D,DSPindex,KKK); if ( ! EPIfound ) MakeGeometry(P2D,DSPindex,KKK); SetShapeTransition(P2D,T1,T2); if (KKK == TopOpeBRepDS_POINT) { EPI = StorePI(P2D,T1,E2index,DSPindex,par1,1); EPI = StorePI(P2D,T2,E1index,DSPindex,par2,2); } else if ( KKK == TopOpeBRepDS_VERTEX) { Standard_Integer Vindex = DSPindex; Standard_Boolean bevi = Standard_False; TopOpeBRepDS_Config cevi = TopOpeBRepDS_UNSHGEOMETRY; EVI = StoreVI(P2D,T1,E2index,Vindex,bevi,cevi,par1,1); EVI = StoreVI(P2D,T2,E1index,Vindex,bevi,cevi,par2,2); } } // ( ! isvertex ) else { SetShapeTransition(P2D,T1,T2); if (isvertex1) { const TopoDS_Shape V = V1; Standard_Integer Vindex = myPDS->AddShape(V,1); TopOpeBRepDS_Config SSC = P2D.EdgesConfig(); EVI = StoreVI(P2D,T1,E2index,Vindex,Standard_True,SSC,par1,1); EVI = StoreVI(P2D,T2,E1index,Vindex,Standard_False,SSC,par2,2); } if (isvertex2) { const TopoDS_Shape V = V2; Standard_Integer Vindex = myPDS->AddShape(V,2); TopOpeBRepDS_Config SSC = P2D.EdgesConfig(); EVI = StoreVI(P2D,T1,E2index,Vindex,Standard_False,SSC,par1,1); EVI = StoreVI(P2D,T2,E1index,Vindex,Standard_True,SSC,par2,2); } } // ( isvertex ) } // MorePoint() RecomputeInterferences(myE1,myLI1); RecomputeInterferences(myE2,myLI2); } // Insert // =============== // private methods // =============== //======================================================================= //function : SetShapeTransition //purpose : //======================================================================= void TopOpeBRep_EdgesFiller::SetShapeTransition(const TopOpeBRep_Point2d& P2D, TopOpeBRepDS_Transition& T1,TopOpeBRepDS_Transition& T2) const { Standard_Boolean pointofsegment = P2D.IsPointOfSegment(); Standard_Boolean esd = myPEI->SameDomain(); Standard_Integer ie1=0,ie2=0,if1=0,if2=0; if (pointofsegment && esd) { T1.ShapeBefore(TopAbs_EDGE);T1.ShapeAfter(TopAbs_EDGE); T2.ShapeBefore(TopAbs_EDGE);T2.ShapeAfter(TopAbs_EDGE); if ( ! myE1.IsNull() ) ie1 = myPDS->AddShape(myE1,1); if ( ! myE2.IsNull() ) ie2 = myPDS->AddShape(myE2,2); if ( ! myE2.IsNull() ) T1.Index(ie2); if ( ! myE1.IsNull() ) T2.Index(ie1); } else if (pointofsegment && !esd) { T1.ShapeBefore(TopAbs_FACE);T1.ShapeAfter(TopAbs_FACE); T2.ShapeBefore(TopAbs_FACE);T2.ShapeAfter(TopAbs_FACE); if ( ! myF1.IsNull() ) if1 = myPDS->AddShape(myF1,1); if ( ! myF2.IsNull() ) if2 = myPDS->AddShape(myF2,2); if ( ! myF1.IsNull() ) T2.Index(if1); if ( ! myF2.IsNull() ) T1.Index(if2); } else { T1.ShapeBefore(TopAbs_FACE);T1.ShapeAfter(TopAbs_FACE); T2.ShapeBefore(TopAbs_FACE);T2.ShapeAfter(TopAbs_FACE); if ( ! myF1.IsNull() ) if1 = myPDS->AddShape(myF1,1); if ( ! myF2.IsNull() ) if2 = myPDS->AddShape(myF2,2); if ( ! myF1.IsNull() ) T2.Index(if1); if ( ! myF2.IsNull() ) T1.Index(if2); } } //======================================================================= //function : GetGeometry //purpose : private //======================================================================= Standard_Boolean TopOpeBRep_EdgesFiller::GetGeometry(TopOpeBRepDS_ListIteratorOfListOfInterference& IT,const TopOpeBRep_Point2d& P2D,Standard_Integer& G,TopOpeBRepDS_Kind& K) const { TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(P2D); Standard_Boolean b = myHDS->GetGeometry(IT,DSP,G,K); return b; } //======================================================================= //function : MakeGeometry //purpose : //======================================================================= Standard_Boolean TopOpeBRep_EdgesFiller::MakeGeometry(const TopOpeBRep_Point2d& P2D,Standard_Integer& G,TopOpeBRepDS_Kind& K) const { Standard_Boolean isvertex1 = P2D.IsVertex(1); Standard_Boolean isvertex2 = P2D.IsVertex(2); if (isvertex1 && isvertex2) { Standard_Integer G1 = myPDS->AddShape(P2D.Vertex(1),1); myPDS->AddShape(P2D.Vertex(2),2); G = G1; K = TopOpeBRepDS_VERTEX; } else if (isvertex1) { G = myPDS->AddShape(P2D.Vertex(1),1); K = TopOpeBRepDS_VERTEX; } else if (isvertex2) { G = myPDS->AddShape(P2D.Vertex(2),2); K = TopOpeBRepDS_VERTEX; } else { G = myPDS->AddPoint(TopOpeBRep_PointGeomTool::MakePoint(P2D)); K = TopOpeBRepDS_POINT; } return Standard_True; } //======================================================================= //function : Face //purpose : //======================================================================= void TopOpeBRep_EdgesFiller::Face(const Standard_Integer ISI,const TopoDS_Shape& F) { if (ISI == 1) myF1 = TopoDS::Face(F); else if (ISI == 2) myF2 = TopoDS::Face(F); else Standard_Failure::Raise("Face(i,f) : ISI incorrect"); } //======================================================================= //function : Face //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRep_EdgesFiller::Face(const Standard_Integer ISI) const { if (ISI == 1) return myF1; else if (ISI == 2) return myF2; else Standard_Failure::Raise("Face(i) : ISI incorrect"); return myF1; } //======================================================================= //function : StorePI //purpose : //======================================================================= Handle(TopOpeBRepDS_Interference) TopOpeBRep_EdgesFiller::StorePI(const TopOpeBRep_Point2d& P2D, const TopOpeBRepDS_Transition& T,const Standard_Integer SI,const Standard_Integer GI, const Standard_Real param,const Standard_Integer IEmother) { Handle(TopOpeBRepDS_Interference) I = TopOpeBRepDS_InterferenceTool::MakeEdgeInterference(T,TopOpeBRepDS_EDGE,SI,TopOpeBRepDS_POINT,GI,param); TopoDS_Shape Emother; if (IEmother == 1) Emother = myE1; else if (IEmother == 2) Emother = myE2; myHDS->StoreInterference(I,Emother); Standard_Boolean b = ToRecompute(P2D,I,IEmother); if (b) StoreRecompute(I,IEmother); return I; } //======================================================================= //function : StoreVI //purpose : //======================================================================= Handle(TopOpeBRepDS_Interference) TopOpeBRep_EdgesFiller::StoreVI(const TopOpeBRep_Point2d& P2D, const TopOpeBRepDS_Transition& T,const Standard_Integer EI,const Standard_Integer VI, const Standard_Boolean VisB,const TopOpeBRepDS_Config C, const Standard_Real param,const Standard_Integer IEmother) { Handle(TopOpeBRepDS_Interference) I = TopOpeBRepDS_InterferenceTool::MakeEdgeVertexInterference(T,EI,VI,VisB,C,param); TopoDS_Shape Emother; if (IEmother == 1) Emother = myE1; else if (IEmother == 2) Emother = myE2; myHDS->StoreInterference(I,Emother); Standard_Boolean b = ToRecompute(P2D,I,IEmother); if (b) StoreRecompute(I,IEmother); return I; } //======================================================================= //function : ToRecompute //purpose : //======================================================================= Standard_Boolean TopOpeBRep_EdgesFiller::ToRecompute(const TopOpeBRep_Point2d& P2D,const Handle(TopOpeBRepDS_Interference)& I,const Standard_Integer IEmother) { Standard_Boolean b = Standard_True; const TopOpeBRepDS_Transition& T = I->Transition(); T.Before(); T.After(); Standard_Boolean pointofsegment = P2D.IsPointOfSegment(); Standard_Boolean esd = myPEI->SameDomain(); b = b && (pointofsegment && !esd); return b; } //======================================================================= //function : StoreRecompute //purpose : //======================================================================= void TopOpeBRep_EdgesFiller::StoreRecompute(const Handle(TopOpeBRepDS_Interference)& I,const Standard_Integer IEmother) { if (IEmother == 1) myLI1.Append(I); else if (IEmother == 2) myLI2.Append(I); } //======================================================================= //function : RecomputeInterferences //purpose : //======================================================================= void TopOpeBRep_EdgesFiller::RecomputeInterferences(const TopoDS_Edge& E,TopOpeBRepDS_ListOfInterference& LI) { if (LI.IsEmpty()) return; TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI); #ifdef DEB Standard_Integer EIX = myPDS->Shape(E); Standard_Boolean TRC=DSREDUEDGETRCE(EIX); if (TRC) cout< 1) {cout<<"TopOpeBRep_EdgesFiller : > 1 I on UNUN/F on E"<ChangeTransition(); Standard_Integer ifb = TU.IndexBefore(); Standard_Integer ifa = TU.IndexAfter(); const TopoDS_Face& fb = TopoDS::Face(myPDS->Shape(ifb)); #ifdef DEB if (ifb != ifa) {cout<<"TopOpeBRep_EdgesFiller : ifb != ifa on E"< ";TN.Dump(cout);cout< TN ko"<