From 9063f1e089fd05da73e48a320369d97289a1623e Mon Sep 17 00:00:00 2001 From: drazmyslovich Date: Wed, 7 Aug 2019 11:04:53 +0300 Subject: [PATCH] 0030870: Data Exchange - Add the support for empty draughting models and empty presentation layer assignments for step import Protections to avoid exception in the methods RWStepVisual_RWDraughtingModel::ReadStep and RWStepVisual_RWPresentationLayerAssignment::ReadStep for case when assigned items are absent were added --- .../RWStepVisual_RWDraughtingModel.cxx | 13 ++++++++----- ...epVisual_RWPresentationLayerAssignment.cxx | 19 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx b/src/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx index 13161312c1..c503bbbf78 100644 --- a/src/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx +++ b/src/RWStepVisual/RWStepVisual_RWDraughtingModel.cxx @@ -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); + } } } diff --git a/src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx b/src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx index 1a3b1db4d1..070ae7ad5d 100644 --- a/src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx +++ b/src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx @@ -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); + } } }