0030870: Data Exchange - Add the support for empty draughting models and empty presen...
authordrazmyslovich <razmyslovich@volumegraphics.com>
Wed, 7 Aug 2019 08:04:53 +0000 (11:04 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 6 Sep 2019 16:24:56 +0000 (19:24 +0300)
Protections to avoid exception in the methods  RWStepVisual_RWDraughtingModel::ReadStep and RWStepVisual_RWPresentationLayerAssignment::ReadStep for case when assigned items are absent were added

src/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx
src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx

index 1316131..c503bbb 100644 (file)
@@ -56,11 +56,14 @@ void RWStepVisual_RWDraughtingModel::ReadStep (const Handle(StepData_StepReaderD
   if ( data->ReadSubList (num, 2, "representation.items", ach, sub2) ) {
     Standard_Integer num2 = sub2;
     Standard_Integer nb0 = data->NbParams(num2);
-    aRepresentation_Items = new StepRepr_HArray1OfRepresentationItem (1, nb0);
-    for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
-      Handle(StepRepr_RepresentationItem) anIt0;
-      data->ReadEntity (num2, i0, "representation.items", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anIt0);
-      aRepresentation_Items->SetValue(i0, anIt0);
+    if (nb0 > 0)
+    {
+      aRepresentation_Items = new StepRepr_HArray1OfRepresentationItem (1, nb0);
+      for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
+        Handle(StepRepr_RepresentationItem) anIt0;
+        data->ReadEntity (num2, i0, "representation.items", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anIt0);
+        aRepresentation_Items->SetValue(i0, anIt0);
+      }
     }
   }
 
index 1a3b1db..070ae7a 100644 (file)
@@ -52,17 +52,16 @@ void RWStepVisual_RWPresentationLayerAssignment::ReadStep
        Handle(StepVisual_HArray1OfLayeredItem) aAssignedItems;
        StepVisual_LayeredItem aAssignedItemsItem;
        Standard_Integer nsub3;
-  if (data->ReadSubList(num, 3, "assigned_items", ach, nsub3)) {
-    Standard_Integer nb3 = data->NbParams(nsub3);
-    if (nb3)
+       if (data->ReadSubList (num,3,"assigned_items",ach,nsub3)) {
+         Standard_Integer nb3 = data->NbParams(nsub3);
+    if (nb3 > 0)
     {
-    
-    aAssignedItems = new StepVisual_HArray1OfLayeredItem(1, nb3);
-    for (Standard_Integer i3 = 1; i3 <= nb3; i3++) {
-      //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
-      if (data->ReadEntity(nsub3, i3, "assigned_items", ach, aAssignedItemsItem))
-        aAssignedItems->SetValue(i3, aAssignedItemsItem);
-    }
+           aAssignedItems = new StepVisual_HArray1OfLayeredItem (1, nb3);
+           for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
+             //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
+             if (data->ReadEntity (nsub3,i3,"assigned_items",ach,aAssignedItemsItem))
+               aAssignedItems->SetValue(i3,aAssignedItemsItem);
+           }
     }
        }