From 951bb21f99cf97dceb72cf5a981d48837a3d0a5a Mon Sep 17 00:00:00 2001 From: skl Date: Fri, 21 Nov 2008 11:21:28 +0000 Subject: [PATCH] Updated for bug 0020052 from Mantis. --- 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));