0024283: STEP read failes to read unbound advanced_face
authorgka <gka@opencascade.com>
Wed, 4 Dec 2013 06:47:40 +0000 (10:47 +0400)
committerabv <abv@opencascade.com>
Thu, 12 Dec 2013 15:36:51 +0000 (19:36 +0400)
Fix to avoid exception if sphere is written without bounds.

src/RWStepShape/RWStepShape_RWAdvancedFace.cxx
tests/bugs/step/bug24283_1 [new file with mode: 0644]
tests/bugs/step/bug24283_2 [new file with mode: 0644]

index 0dec59b..c0990a1 100755 (executable)
@@ -55,12 +55,15 @@ void RWStepShape_RWAdvancedFace::ReadStep
        Standard_Integer nsub2;
        if (data->ReadSubList (num,2,"bounds",ach,nsub2)) {
          Standard_Integer nb2 = data->NbParams(nsub2);
-         aBounds = new StepShape_HArray1OfFaceBound (1, nb2);
-         for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
-           //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
-           if (data->ReadEntity (nsub2, i2,"face_bound", ach, STANDARD_TYPE(StepShape_FaceBound), anent2))
-             aBounds->SetValue(i2, anent2);
-         }
+    if( nb2)
+    {
+           aBounds = new StepShape_HArray1OfFaceBound (1, nb2);
+           for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
+             //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
+             if (data->ReadEntity (nsub2, i2,"face_bound", ach, STANDARD_TYPE(StepShape_FaceBound), anent2))
+               aBounds->SetValue(i2, anent2);
+           }
+    }
        }
 
        // --- inherited field : faceGeometry ---
diff --git a/tests/bugs/step/bug24283_1 b/tests/bugs/step/bug24283_1
new file mode 100644 (file)
index 0000000..10ccbb3
--- /dev/null
@@ -0,0 +1,11 @@
+puts "============"
+puts "OCC24283"
+puts "============"
+puts ""
+#####################################################
+# STEP read failes to read unbound advanced_face
+#####################################################
+
+ReadStep D [locate_data_file bug24283_spheres.stp]
+
+
diff --git a/tests/bugs/step/bug24283_2 b/tests/bugs/step/bug24283_2
new file mode 100644 (file)
index 0000000..4ef128b
--- /dev/null
@@ -0,0 +1,19 @@
+puts "============"
+puts "OCC24283"
+puts "============"
+puts ""
+#####################################################
+# STEP read failes to read unbound advanced_face
+#####################################################
+
+stepread [locate_data_file bug24283_spheres.stp] a *
+tpcompound result
+
+vinit
+vdisplay result
+vfit
+vsetdispmode 1
+set only_screen 1
+
+
+