From 6a52e30ef99e56f167e715af74ef31dd127a8a2a Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 1 Feb 2005 11:12:39 +0000 Subject: [PATCH] Improve RemoveExtraEdges() function. Fix done by SKL. --- src/GEOMAlgo/BlockFix_UnionEdges.cxx | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx index f36e8c7e1..8e1e89805 100644 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cxx +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cxx @@ -152,13 +152,45 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, gp_Pnt PV2 = BRep_Tool::Pnt(V2); TopoDS_Vertex VM = sae.LastVertex(edge1); gp_Pnt PVM = BRep_Tool::Pnt(VM); + Standard_Boolean IsClosed = Standard_False; + if(V1.IsSame(V2)) { + IsClosed = Standard_True; + TopExp_Explorer expe; + Standard_Boolean HasOtherEdges = Standard_False; + for(expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge Etmp = TopoDS::Edge(expe.Current()); + if( Etmp.IsSame(edge1) || Etmp.IsSame(edge2) ) continue; + if( sae.FirstVertex(Etmp).IsSame(V1) || + sae.LastVertex(Etmp).IsSame(V1) ) { + HasOtherEdges = Standard_True; + break; + } + } + if(HasOtherEdges) { + Standard_Real par = (fp2+lp2)/2.; + c3d2->D0(par,PV2); + } + else { + V1 = sae.FirstVertex(edge2); + PV1 = BRep_Tool::Pnt(V1); + V2 = VM; + VM = sae.LastVertex(edge2); + PVM = BRep_Tool::Pnt(VM); + Standard_Real par = (fp1+lp1)/2.; + c3d1->D0(par,PV2); + } + } GC_MakeCircle MC(PV1,PVM,PV2); Handle(Geom_Circle) C = MC.Value(); gp_Pnt P0 = C->Location(); gp_Dir D1(gp_Vec(P0,PV1)); gp_Dir D2(gp_Vec(P0,PV2)); Standard_Real fpar = C->XAxis().Direction().Angle(D1); - Standard_Real lpar = C->XAxis().Direction().Angle(D2); + Standard_Real lpar; + if(IsClosed) + lpar = fpar+2*PI; + else + lpar = C->XAxis().Direction().Angle(D2); Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); TopoDS_Edge E; B.MakeEdge (E,tc,Precision::Confusion());