]> OCCT Git - occt.git/commitdiff
0025415: Data Exchange - Invalid result of loading a STEP file
authorabv <abv@opencascade.com>
Fri, 8 Mar 2024 18:56:26 +0000 (18:56 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sun, 31 Mar 2024 21:40:18 +0000 (22:40 +0100)
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
src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx
tests/bugs/step/bug25415 [new file with mode: 0644]

index 669550e308b86dd5c628bb2fb9e05df15d40dbf8..d9a716269bc2fcb27da9b5392ce31e0bcc494b85 100644 (file)
@@ -983,7 +983,7 @@ static Standard_Integer FindEntities(const Handle(Transfer_FinderProcess)& theFP
     //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) );
     Handle(Transfer_TransientListBinder)::DownCast(aBinder);
   Standard_Integer aResCount = 0;
-  if (aTransientListBinder.IsNull() && theShape.ShapeType() == TopAbs_COMPOUND)
+  if (aTransientListBinder.IsNull())
   {
     for (TopoDS_Iterator anIter(theShape); anIter.More(); anIter.Next())
     {
index 043e946b93967b89b7835b048b71c4f08fd1612d..227b9f46a44461b238c22ab77176baf843623b2d 100644 (file)
@@ -408,7 +408,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
diff --git a/tests/bugs/step/bug25415 b/tests/bugs/step/bug25415
new file mode 100644 (file)
index 0000000..384fbfe
--- /dev/null
@@ -0,0 +1,11 @@
+puts "========"
+puts "OCC25415"
+puts "========"
+puts ""
+##########################################################################
+# Invalid result of loading a STEP file
+##########################################################################
+
+stepread [locate_data_file bug25415_part_of_hdrv8w64p254_4x2_1016x502h838p.stp] a *
+
+checkshape a_1