// Created on: 1993-06-17 // Created by: Jean Yves LEBEY // Copyright (c) 1993-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and / or modify it // under the terms of the GNU Lesser General Public version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifdef DRAW #include #include static TCollection_AsciiString PRODINS("dins "); #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB extern Standard_Boolean TopOpeBRep_GettraceSHA(const Standard_Integer i); extern Standard_Boolean TopOpeBRepBuild_GettraceSS(); extern Standard_Boolean TopOpeBRepBuild_GetcontextSSCONNEX(); extern Standard_Boolean TopOpeBRepBuild_GettraceCHK(); TopOpeBRepBuild_Builder* LOCAL_PBUILDER_DEB = NULL; void debwesclo(const Standard_Integer) {} #endif //======================================================================= //function : TopOpeBRepBuild_WireEdgeSet //purpose : //======================================================================= TopOpeBRepBuild_WireEdgeSet::TopOpeBRepBuild_WireEdgeSet(const TopoDS_Shape& F, const Standard_Address /*A*/) : TopOpeBRepBuild_ShapeSet(TopAbs_VERTEX) { myFace = TopoDS::Face(F); #ifdef DRAW myDEBName = "WES"; LOCAL_PBUILDER_DEB = (TopOpeBRepBuild_Builder*)((void*)A); if (LOCAL_PBUILDER_DEB != NULL) { myDEBNumber = LOCAL_PBUILDER_DEB->GdumpSHASETindex(); Standard_Integer iF; Standard_Boolean tSPS = LOCAL_PBUILDER_DEB->GtraceSPS(F,iF); if(tSPS){DumpName(cout,"creation ");cout<<" on ";} if(tSPS){LOCAL_PBUILDER_DEB->GdumpSHA(F,NULL);cout<= 2 ) { const TopoDS_Face& F = myFace; // plusieurs aretes de couture connexes a E par V et telles que : // orientation de V dans E # orientation de V dans ces aretes. // on ne garde,parmi les aretes de couture connexes, // que l'arete A qui verifie tg(E) ^ tg(A) > 0 gp_Vec2d d1E; gp_Pnt2d pE; Standard_Real parE = BRep_Tool::Parameter(V,E); Standard_Real fiE,laE,tolpc; Standard_Boolean trim3d = Standard_True; Handle(Geom2d_Curve) PCE = FC2D_CurveOnSurface(E,F,fiE,laE,tolpc,trim3d); if (!PCE.IsNull()) PCE->D1(parE,pE,d1E); else LocalD1(F,E,V,pE,d1E); TopAbs_Orientation Eori = E.Orientation(); if (Eori == TopAbs_REVERSED) d1E.Reverse(); TopTools_ListIteratorOfListOfShape lclo(myCurrentShapeNeighbours); Standard_Integer rang = 0; while (lclo.More()) { rang++; if ( ! IsClosed(lclo.Value()) ) { lclo.Next(); continue; } const TopoDS_Edge& EE = TopoDS::Edge(lclo.Value()); gp_Vec2d d1EE; gp_Pnt2d pEE; Standard_Real parEE = BRep_Tool::Parameter(V,EE); Standard_Real fiEE,laEE,tolpc1; Handle(Geom2d_Curve) PCEE = FC2D_CurveOnSurface(EE,F,fiEE,laEE,tolpc1,trim3d); if (!PCEE.IsNull()) PCEE->D1(parEE,pEE,d1EE); else LocalD1(F,EE,V,pEE,d1EE); TopAbs_Orientation EEori = EE.Orientation(); if (EEori == TopAbs_REVERSED) d1EE.Reverse(); Standard_Real cross = d1E.Crossed(d1EE); TopAbs_Orientation oVE,oVEE; VertexConnectsEdges(V,E,EE,oVE,oVEE); Standard_Boolean t2 = ( (cross > 0) && oVE == TopAbs_REVERSED ) || ( (cross < 0) && oVE == TopAbs_FORWARD ); #ifdef DRAW if ( traceSS ) { cout<<"#-------- rang "< cross "<<" "< on garde EE"< on vire EE"< edges are connected // // E1 FORWARD, V REVERSED on E1 // E2 REVERSED, V FORWARD on E2 --> edges are NOT connected //----------------------------------------------------------------------- Standard_Boolean c1 = IsClosed(E1); Standard_Boolean c2 = IsClosed(E2); Standard_Boolean testconnect = c1 || c2; Standard_Boolean resu = Standard_False; TopAbs_Orientation o1,o2; // SSCONNEX = False ==> on selectionne E2 de facon a creer ulterieurement // (defaut) autant de faces que de composantes connexes en UV. // SSCONNEX = True ==> on prend toute arete E2 qui partage V avec E1 // et telle que orientation(V/E1) # orientation(V/E2) // ==> face de part et d'autre des coutures #ifdef DRAW if ( TopOpeBRepBuild_GetcontextSSCONNEX() ) { if (testconnect) resu = VertexConnectsEdges(V,E1,E2,o1,o2); return resu; } #endif if ((c1 && c2)) { Standard_Boolean u1 = c1 ? IsUClosed(E1) : Standard_False; Standard_Boolean v1 = c1 ? IsVClosed(E1) : Standard_False; Standard_Boolean u2 = c2 ? IsUClosed(E2) : Standard_False; Standard_Boolean v2 = c2 ? IsVClosed(E2) : Standard_False; Standard_Boolean uvdiff = (u1 && v2) || (u2 && v1); testconnect = uvdiff; } if (testconnect) { resu = VertexConnectsEdges(V,E1,E2,o1,o2); } else { // cto 012 O2 arete de couture de face cylindrique // chainage des composantes splitees ON et OUT de meme orientation TopAbs_Orientation oe1 = E1.Orientation(); TopAbs_Orientation oe2 = E2.Orientation(); Standard_Boolean iseq = E1.IsEqual(E2); if ( (c1 && c2) && (oe1 == oe2) && (!iseq) ) { resu = VertexConnectsEdges(V,E1,E2,o1,o2); } } return resu; } //======================================================================= //function : NbClosingShapes //purpose : //======================================================================= Standard_Integer TopOpeBRepBuild_WireEdgeSet::NbClosingShapes(const TopTools_ListOfShape & L) const { Standard_Integer n = 0; for (TopTools_ListIteratorOfListOfShape it(L); it.More(); it.Next()) { const TopoDS_Shape& S = it.Value(); if ( IsClosed(S) ) n++; } return n; } //======================================================================= //function : LocalD1 //purpose : //======================================================================= void TopOpeBRepBuild_WireEdgeSet::LocalD1(const TopoDS_Shape& SF,const TopoDS_Shape& SE,const TopoDS_Shape& SV, gp_Pnt2d& pE, gp_Vec2d& d1E) const { const TopoDS_Face& F = TopoDS::Face(SF); const TopoDS_Edge& E = TopoDS::Edge(SE); const TopoDS_Vertex& V = TopoDS::Vertex(SV); Standard_Real parE = BRep_Tool::Parameter(V,E); TopLoc_Location Loc; Standard_Real fiE,laE; Handle(Geom_Curve) CE = BRep_Tool::Curve(E,Loc,fiE,laE); CE = Handle(Geom_Curve)::DownCast(CE->Transformed(Loc.Transformation())); gp_Pnt p3dE; gp_Vec d3dE; CE->D1(parE,p3dE,d3dE); Handle(Geom_Surface) S = BRep_Tool::Surface(F); GeomAPI_ProjectPointOnSurf proj(p3dE,S); Standard_Real u,v; proj.LowerDistanceParameters(u,v); pE.SetCoord(u,v); gp_Pnt bid; gp_Vec d1u,d1v; S->D1(u,v,bid,d1u,d1v); u = d3dE.Dot(d1u); v = d3dE.Dot(d1v); d1E.SetCoord(u,v); } //======================================================================= //function : IsClosed //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsClosed(const TopoDS_Shape& E) const { #ifdef DEB Standard_Integer ista=myOMSS.FindIndex(E);Standard_Boolean tsh=(ista)?TopOpeBRep_GettraceSHA(ista):Standard_False; if (tsh) debwesclo(ista); #endif const TopoDS_Edge& EE = TopoDS::Edge(E); Standard_Boolean closed = BRep_Tool::IsClosed(EE,myFace); if ( closed ) return Standard_True; return Standard_False; } //======================================================================= //function : IsUVISO //purpose : //======================================================================= void TopOpeBRepBuild_WireEdgeSet::IsUVISO(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Boolean& uiso,Standard_Boolean& viso) { uiso = viso = Standard_False; Standard_Real fE,lE,tolpc;Handle(Geom2d_Curve) PC; Standard_Boolean trim3d = Standard_True; PC = FC2D_CurveOnSurface(E,F,fE,lE,tolpc,trim3d); if (PC.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_WireEdgeSet::IsUVISO"); Handle(Standard_Type) TheType = PC->DynamicType(); if (TheType == STANDARD_TYPE(Geom2d_Line)) { const Handle(Geom2d_Line)& HL = *((Handle(Geom2d_Line)*)&PC); const gp_Dir2d& D = HL->Direction(); Standard_Real tol = Precision::Angular(); if (D.IsParallel(gp_Dir2d(0.,1.),tol)) uiso = Standard_True; else if (D.IsParallel(gp_Dir2d(1.,0.),tol)) viso = Standard_True; } } //======================================================================= //function : IsUClosed //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsUClosed(const TopoDS_Shape& E) const { const TopoDS_Edge& EE = TopoDS::Edge(E); Standard_Boolean bid,closed; IsUVISO(EE,myFace,closed,bid); return closed; } //======================================================================= //function : IsVClosed //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_WireEdgeSet::IsVClosed(const TopoDS_Shape& E) const { const TopoDS_Edge& EE = TopoDS::Edge(E); Standard_Boolean bid,closed; IsUVISO(EE,myFace,bid,closed); return closed; } //======================================================================= //function : SNameVEE //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEE(const TopoDS_Shape& VV, const TopoDS_Shape& EE1, const TopoDS_Shape& EE2) const { TCollection_AsciiString str; const TopoDS_Vertex& V = TopoDS::Vertex(VV); const TopoDS_Shape& E1 = TopoDS::Edge(EE1); const TopoDS_Shape& E2 = TopoDS::Edge(EE2); TopAbs_Orientation oVE1,oVE2; Standard_Boolean conn = VertexConnectsEdges(V,E1,E2,oVE1,oVE2); str=SName(VV)+" "; str=str+SNameori(E1)+" V/E1 : "; TCollection_AsciiString so1;TestTopOpeDraw_TTOT::OrientationToString(oVE1,so1);so1.UpperCase(); str=str+so1.SubString(1,1)+" "; str=str+SNameori(E2)+" V/E2 : "; TCollection_AsciiString so2;TestTopOpeDraw_TTOT::OrientationToString(oVE2,so2);so2.UpperCase(); str=str+so2.SubString(1,1)+" "; return str; } #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEE(const TopoDS_Shape&, const TopoDS_Shape&, const TopoDS_Shape&) const { TCollection_AsciiString str; return str; } #endif //======================================================================= //function : SNameVEL //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEL(const TopoDS_Shape& V, const TopoDS_Shape& E, const TopTools_ListOfShape& L) const #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameVEL(const TopoDS_Shape&, const TopoDS_Shape&, const TopTools_ListOfShape&) const #endif { TCollection_AsciiString str; #ifdef DRAW Standard_Integer nc = NbClosingShapes(L), nl = L.Extent(); str=SNameori(E)+" "+SName(V)+" "+SNameori(L); #endif return str; } //======================================================================= //function : DumpSS //purpose : //======================================================================= void TopOpeBRepBuild_WireEdgeSet::DumpSS() { #ifdef DRAW TopOpeBRepBuild_ShapeSet::DumpSS(); #endif } //======================================================================= //function : SName //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopoDS_Shape& S, const TCollection_AsciiString& sb, const TCollection_AsciiString& sa) const #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopoDS_Shape&, const TCollection_AsciiString& sb, const TCollection_AsciiString&) const #endif { TCollection_AsciiString str=sb; #ifdef DRAW str=str+TopOpeBRepBuild_ShapeSet::SName(S); str=str+sa; DBRep::Set(str.ToCString(),S); #endif return str; } //======================================================================= //function : SNameori //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopoDS_Shape& S, const TCollection_AsciiString& sb, const TCollection_AsciiString& sa) const #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopoDS_Shape&, const TCollection_AsciiString& sb, const TCollection_AsciiString&) const #endif { TCollection_AsciiString str=sb; #ifdef DRAW str=str+TopOpeBRepBuild_ShapeSet::SNameori(S); if ( S.ShapeType() == TopAbs_EDGE ) { const TopoDS_Shape& E = TopoDS::Edge(S); Standard_Boolean c = IsClosed(E), u = IsUClosed(E), v = IsVClosed(E); if (c) str=str+"c"; if (u) str=str+"u"; if (v) str=str+"v"; str=str+sa; DBRep::Set(str.ToCString(),S); } #endif return str; } //======================================================================= //function : SName //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopTools_ListOfShape& L, const TCollection_AsciiString& sb, const TCollection_AsciiString& sa) const #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SName(const TopTools_ListOfShape&, const TCollection_AsciiString&, const TCollection_AsciiString&) const #endif { TCollection_AsciiString str; #ifdef DRAW for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SName(it.Value())+sa+" "; #endif return str; } //======================================================================= //function : SNameori //purpose : //======================================================================= #ifdef DRAW TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopTools_ListOfShape& L, const TCollection_AsciiString& sb, const TCollection_AsciiString& sa) const #else TCollection_AsciiString TopOpeBRepBuild_WireEdgeSet::SNameori(const TopTools_ListOfShape&, const TCollection_AsciiString&, const TCollection_AsciiString&) const #endif { TCollection_AsciiString str; #ifdef DRAW for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SNameori(it.Value())+sa+" "; #endif return str; }