From 49e5423bfe19ae6dbeec5137f0bd9e5975878beb Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 26 Nov 2008 10:10:44 +0000 Subject: [PATCH] Bug 0020052: Non removable extra edges. A fix by SKL merged from V4_1_0_maintainance. --- src/GEOMAlgo/BlockFix_UnionEdges.cxx | 47 +++++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx index 1cdb061a2..aadf32584 100644 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cxx +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cxx @@ -203,21 +203,44 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, } if(aChain.Length()>1) { // second step: union edges with various curves - MESSAGE ("can not make analitical union => make approximation"); - TopoDS_Wire W; - B.MakeWire(W); + // skl for bug 0020052 from Mantis: perform such unions + // only if curves are bspline or bezier + bool NeedUnion = true; for(j=1; j<=aChain.Length(); j++) { TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - B.Add(W,edge); + Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); + if(c3d.IsNull()) continue; + while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d); + c3d = tc->BasisCurve(); + } + if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; + NeedUnion = false; + break; + } + if(NeedUnion) { + MESSAGE ("can not make analitical union => make approximation"); + TopoDS_Wire W; + B.MakeWire(W); + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + B.Add(W,edge); + } + Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); + Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); + Handle(Geom_BSplineCurve) bc = Conv.Curve(); + TopoDS_Edge E; + B.MakeEdge (E,bc,Precision::Confusion()); + B.Add (E,VF); + B.Add (E,VL); + aChain.SetValue(1,E); + } + else { + MESSAGE ("can not make approximation for such types of curves"); + return Standard_False; } - Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); - Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); - Handle(Geom_BSplineCurve) bc = Conv.Curve(); - TopoDS_Edge E; - B.MakeEdge (E,bc,Precision::Confusion()); - B.Add (E,VF); - B.Add (E,VL); - aChain.SetValue(1,E); } anEdge = TopoDS::Edge(aChain.Value(1)); -- 2.39.2