0026289: STEP import/export produces an empty shape
authorgka <gka@opencascade.com>
Thu, 20 Aug 2015 13:53:50 +0000 (16:53 +0300)
committerski <ski@opencascade.com>
Thu, 20 Aug 2015 13:54:26 +0000 (16:54 +0300)
Exception is raised during reading step file containing p-curve having not-unique last knot.
Modification correcting misprint during computation new numbers of poles for such case was made in the file StepToGeom_MakeBSplineCurve.pxx
Protection against exception was made in the file StepToTopoDS/StepToTopoDS_TranslateEdge.cxx.
Warning message was added in the file StepToTopoDS_TranslateEdgeLoop.cxx.

Test case for issue CR26289

src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx
src/StepToTopoDS/StepToTopoDS_TranslateEdge.cxx
src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx
tests/bugs/step/bug26289 [new file with mode: 0755]

index 9692b4e..4eda09f 100644 (file)
@@ -70,7 +70,7 @@
     if (aCurrentVal > Deg + 1)
     {
       if (i == 1)       aFMulDiff = aCurrentVal - Deg - 1;
-      if (i == NbKnots) aLMulDiff = aCurrentVal - Deg - 1;
+      if (i == NbUniqueKnots) aLMulDiff = aCurrentVal - Deg - 1;
 #ifdef OCCT_DEBUG
       cout << "\nWrong multiplicity " << aCurrentVal <<  " on " << i 
            << " knot!" << "\nChanged to " << Deg + 1 << endl;
index 6077aeb..58b8b6f 100644 (file)
@@ -61,6 +61,7 @@
 #include <TopoDS_Vertex.hxx>
 #include <Transfer_TransientProcess.hxx>
 #include <UnitsMethods.hxx>
+#include <Standard_Failure.hxx>
 
 //#include <StepGeom_Polyline.hxx>
 //#include <TransferBRep.hxx>
@@ -501,11 +502,19 @@ Handle(Geom2d_Curve)  StepToTopoDS_TranslateEdge::MakePCurve
   const Handle(StepRepr_DefinitionalRepresentation) DRI = PCU->ReferenceToCurve();
   if( DRI.IsNull()) return C2d;
   const Handle(StepGeom_Curve) StepCurve = Handle(StepGeom_Curve)::DownCast(DRI->ItemsValue(1));
-  C2d = StepToGeom::MakeCurve2d (StepCurve);
-  if (! C2d.IsNull()) {
+  try
+  {
+    C2d = StepToGeom::MakeCurve2d (StepCurve);
+    if (! C2d.IsNull()) {
     // -- if the surface is a RectangularTrimmedSurface, 
     // -- send the BasisSurface.
-    C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf);
+     C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf);
+    }
+    
+  }
+  catch(Standard_Failure)
+  {
+    return C2d;
   }
   return C2d;
 }
index 26363a2..b4a94dc 100644 (file)
@@ -551,6 +551,7 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac
          while (lastpcurve > 0) {
            C2d1 = myTranEdge.MakePCurve (StepPCurve,ConvSurf);
            if (C2d1.IsNull()) {
+         TP->AddWarning(EC,"Incorrect pcurve is not translated. Pcurve definition is not correct");
              hasPcurve = Standard_False;
              break;
            }
diff --git a/tests/bugs/step/bug26289 b/tests/bugs/step/bug26289
new file mode 100755 (executable)
index 0000000..3d4174c
--- /dev/null
@@ -0,0 +1,28 @@
+puts "============"
+puts "OCC26289"
+puts "============"
+puts ""
+#######################################################################
+# STEP import/export produces an empty shape
+#######################################################################
+
+restore [locate_data_file bug26289_solid_3.brep] a1
+
+set aFile ${imagedir}/bug26289.stp
+catch { file delete ${aFile} }
+
+stepwrite a a1 ${aFile}
+
+stepread ${aFile} b *
+
+checknbshapes b_1 -vertex 338 -edge 673 -wire 337 -face 337 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 1687 -m "Shape"
+
+vinit View1
+vdisplay a1
+vfit
+vdump ${imagedir}/${casename}_1.png
+
+vinit View2
+vdisplay b_1
+vfit
+vdump ${imagedir}/${casename}_2.png