]> OCCT Git - occt.git/commitdiff
0027575: Reading STEP file gives an empty result
authorgka <gka@opencascade.com>
Thu, 17 Nov 2016 11:44:59 +0000 (14:44 +0300)
committerapn <apn@opencascade.com>
Thu, 17 Nov 2016 11:45:16 +0000 (14:45 +0300)
Exception is raised during translation BSpline curve having only one unique knot.
Protection for such case was added
Added protection against exception during reading BSpline curve with number of control points equal to 0
Added protection against exception due to using null binder during writing XDE document

Test case for issue #27575

src/RWStepGeom/RWStepGeom_RWBSplineCurveWithKnots.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx
tests/bugs/step/bug27575 [new file with mode: 0644]
tests/de/step_2/G5

index a3a31f722d375d5942947e66105660a2a8478093..8911fcfc8fcf1060a2e5c7586fed3e57d2f8d931 100644 (file)
@@ -76,13 +76,18 @@ void RWStepGeom_RWBSplineCurveWithKnots::ReadStep
        Standard_Integer nsub3;
        if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) {
          Standard_Integer nb3 = data->NbParams(nsub3);
-         aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb3);
-         for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
-           //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
-           if (data->ReadEntity (nsub3, i3,"cartesian_point", ach,
-                                 STANDARD_TYPE(StepGeom_CartesianPoint), anent3))
-             aControlPointsList->SetValue(i3, anent3);
-         }
+    if(nb3 <1)
+      ach->AddFail("Number of control points of the b_spline_curve_form is equal to 0");
+    else
+    {
+      aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb3);
+      for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
+        //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
+        if (data->ReadEntity (nsub3, i3,"cartesian_point", ach,
+          STANDARD_TYPE(StepGeom_CartesianPoint), anent3))
+          aControlPointsList->SetValue(i3, anent3);
+      }
+    }
        }
 
        // --- inherited field : curveForm ---
index 708e3e7299c26c3d38667ecaba36ba7db10fbe6e..93c8277dbbf11f6324afc773e95bc3a195c48d41 100644 (file)
@@ -889,8 +889,9 @@ static Standard_Integer FindEntities (const Handle(Transfer_FinderProcess) &FP,
       seqRI.Append (aLocalItem);
     }
   }
-  else
+  else if(!TransientListBinder.IsNull())
   {
+
     const Standard_Integer nb = TransientListBinder->NbTransients();
     for (Standard_Integer i=1; i<=nb; i++) {
       Handle(Standard_Transient) t = TransientListBinder->Transient(i);
index 6933a838a2c1f74c44ac1e0179d04a2d1eb16d3d..043b419cabca10e025946733d8e87338197b353a 100644 (file)
       lastKnot = aKnots->Value(i);
     }
   }
-  
+  if(NbUniqueKnots <= 1)
+  {
+    return 0;
+  }
   TColStd_Array1OfReal Kn(1,NbUniqueKnots);
   TColStd_Array1OfInteger Mult(1,NbUniqueKnots);
   lastKnot = aKnots->Value(1);
   //aControlPointsList = new StepGeom_HArray1OfCartesianPoint(1,NbPoles);
   const Handle(StepGeom_HArray1OfCartesianPoint)& aControlPointsList = BSCW->ControlPointsList();
   Standard_Integer aSumMulDiff = aFMulDiff + aLMulDiff;
+  Standard_Integer nbP = NbPoles - aSumMulDiff;
+  if( nbP <= 0)
+  {
+     return 0;
+  }
   Array1OfPnt_gen Poles(1,NbPoles - aSumMulDiff);
   
   for (i = 1 + aFMulDiff; i<= NbPoles - aLMulDiff; ++i)
diff --git a/tests/bugs/step/bug27575 b/tests/bugs/step/bug27575
new file mode 100644 (file)
index 0000000..e10b538
--- /dev/null
@@ -0,0 +1,16 @@
+puts "========"
+puts "OCC27575"
+puts "========"
+puts ""
+###########################################
+# Reading STEP file gives an empty result
+###########################################
+
+stepread [locate_data_file bug27575_Outer_Shell.stp] a *
+renamevar a_1 result
+
+whatis result
+
+checkshape result
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
index f5cd3c70c6a4b0bdaeefd8cd7fe768cba4031906..8ea589ef8a336c9ad6dd5c15bd614b09dd825f46 100644 (file)
@@ -1,17 +1,20 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
+puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
+
+
 set filename Inventor_iPartExample.stp
 
 set ref_data {
-DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
-TPSTAT      : Faulties = 0  ( 16 )  Warnings = 0  ( 0 )  Summary  = 0  ( 16 )
+DATA        : Faulties = 0  ( 30 )  Warnings = 0  ( 0 )  Summary  = 0  ( 30 )
+TPSTAT      : Faulties = 0  ( 188 )  Warnings = 0  ( 96 )  Summary  = 0  ( 284 )
 CHECKSHAPE  : Wires    = 0  ( 0 )  Faces    = 0  ( 0 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 8  ( 8 )  Shell    = 8  ( 8 )  Face     = 517  ( 517 )   Summary  = 3521  ( 3521 )
-STATSHAPE   : Solid    = 8  ( 8 )  Shell    = 8  ( 8 )  Face     = 517  ( 517 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 1464  ( 1464 )
-TOLERANCE   : MaxTol   = 1.000100003e-007  ( 1.000100003e-007 )  AvgTol   =  1.00006193e-007  (  1.00006193e-007 )
-LABELS      : N0Labels = 9  ( 9 )  N1Labels = 11  ( 11 )  N2Labels = 0  ( 0 )   TotalLabels = 20  ( 20 )   NameLabels = 17  ( 17 )   ColorLabels = 8  ( 8 )   LayerLabels = 0  ( 0 )
+NBSHAPES    : Solid    = 8  ( 8 )  Shell    = 10  ( 44 )  Face     = 783  ( 817 )   Summary  = 5535  ( 5605 )
+STATSHAPE   : Solid    = 8  ( 8 )  Shell    = 10  ( 44 )  Face     = 783  ( 817 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 2330  ( 2330 )
+TOLERANCE   : MaxTol   = 0.0003647191536  ( 0.0003647191504 )  AvgTol   =  4.200927531e-005  (  4.190525894e-005 )
+LABELS      : N0Labels = 9  ( 9 )  N1Labels = 11  ( 11 )  N2Labels = 0  ( 0 )   TotalLabels = 20  ( 20 )   NameLabels = 17  ( 17 )   ColorLabels = 10  ( 10 )   LayerLabels = 0  ( 0 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
-NCOLORS     : NColors  = 2  ( 2 )
-COLORS      : Colors   = GRAY66 SANDYBROWN  ( GRAY66 SANDYBROWN )
+NCOLORS     : NColors  = 3  ( 3 )
+COLORS      : Colors   = GOLDENROD3 GRAY66 SANDYBROWN  ( GOLDENROD3 GRAY66 SANDYBROWN )
 NLAYERS     : NLayers  = 0  ( 0 )
 LAYERS      : Layers   =   (  )