From e0658d1e6001270c6f76d7b986b6b9d496d94b23 Mon Sep 17 00:00:00 2001 From: abv Date: Tue, 10 Feb 2015 16:56:26 +0300 Subject: [PATCH] 0025415: Invalid result of loading a STEP file Handling of special case found on some STEP files produced by FPX Expert 2013 (PCB design system): edge curve is line displaced from its true position but with correct direction; we shift the line in this case so that it passes through vertices correcty. Protection against possible exception in writing XDE. --- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 2 +- .../StepToTopoDS_TranslateEdge.cxx | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 69aaa42189..0d32752b16 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -748,7 +748,7 @@ static Standard_Integer FindEntities (const Handle(Transfer_FinderProcess) &FP, //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); Handle(Transfer_TransientListBinder)::DownCast( bnd ); Standard_Integer nres=0; - if ( TransientListBinder.IsNull() && S.ShapeType() == TopAbs_COMPOUND) + if ( TransientListBinder.IsNull() || S.ShapeType() == TopAbs_COMPOUND) { for ( TopoDS_Iterator it(S); it.More(); it.Next() ) { Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity ( FP, it.Value(), L ); diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx index 2078652d20..81ba8fb665 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx @@ -425,7 +425,24 @@ void StepToTopoDS_TranslateEdge::MakeFromCurve3D temp1 = pU1.Distance ( pv1 ); temp2 = pU2.Distance ( pv2 ); if ( temp1 > preci || temp2 > preci ) { - TP->AddWarning (C3D,"Poor result from projection vertex / curve 3d"); + // #25415: handling of special case found on some STEP files produced by FPX Expert 2013 (PCB design system): + // edge curve is line displaced from its true position but with correct direction; + // we can shift the line in this case so that it passes through vertices correcty + if (Abs (temp1 - temp2) < preci && Abs (U2 - U1 - pnt1.Distance(pnt2)) < Precision::Confusion() && + C1->IsKind(STANDARD_TYPE(Geom_Line))) + { + Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast (C1); + gp_Lin aLin = aLine->Lin(); + gp_Pnt anOrigin = pnt1.XYZ() - aLin.Position().Direction().XYZ() * U1; + aLin.SetLocation (anOrigin); + C1 = new Geom_Line (aLin); + + TP->AddWarning (C3D,"Poor result from projection vertex / line 3d, line shifted"); + } + else + { + TP->AddWarning (C3D,"Poor result from projection vertex / curve 3d"); + } } B.UpdateVertex ( V1, 1.000001*temp1 ); //:h6 abv 14 Jul 98: PRO8845 #2746: *=1.0001 B.UpdateVertex ( V2, 1.000001*temp2 ); //:h6 -- 2.39.5