Added protections to avoid exceptions for null objects.
For reading entity StepShape_ToleranceValue was added reading lower and upper bounds represented by entities "StepRepr_ReprItemAndMeasureWithUnit" or "StepRepr_MeasureRepresentationItem"
#include <StepData_StepReaderData.hxx>
#include <StepData_StepWriter.hxx>
#include <StepShape_ToleranceValue.hxx>
+#include <StepRepr_MeasureRepresentationItem.hxx>
+#include <StepRepr_ReprItemAndMeasureWithUnit.hxx>
RWStepShape_RWToleranceValue::RWStepShape_RWToleranceValue () {}
// --- own field : lower_bound ---
- Handle(StepBasic_MeasureWithUnit) LB;
- data->ReadEntity (num,1,"lower_bound",ach,
- STANDARD_TYPE(StepBasic_MeasureWithUnit),LB);
+ Handle(Standard_Transient) LB;
+ if(!data->ReadEntity (num,1,"lower_bound",ach,
+ STANDARD_TYPE(StepBasic_MeasureWithUnit),LB))
+ {
+ Handle(StepRepr_MeasureRepresentationItem) aMSR;
+ Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU;
+
+ if(data->ReadEntity (num,1,"lower_bound",ach,
+ STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR) ||
+ data->ReadEntity (num,1,"lower_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU))
+ {
+ if(!aMSR.IsNull())
+ LB = aMSR;
+ else if(!aRIMU.IsNull())
+ LB = aRIMU;
+ }
+ }
// --- own field : upper_bound ---
- Handle(StepBasic_MeasureWithUnit) UB;
- data->ReadEntity (num,2,"upper_bound",ach,
- STANDARD_TYPE(StepBasic_MeasureWithUnit),UB);
+ Handle(Standard_Transient) UB;
+ if(!data->ReadEntity (num,2,"upper_bound",ach,
+ STANDARD_TYPE(StepBasic_MeasureWithUnit),UB))
+ {
+ Handle(StepRepr_MeasureRepresentationItem) aMSR1;
+ Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU1;
+ if(data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR1) ||
+ data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU1))
+ {
+ if(!aMSR1.IsNull())
+ UB = aMSR1;
+ else if(!aRIMU1.IsNull())
+ UB = aRIMU1;
+ }
+ }
//--- Initialisation of the read entity ---
-
+ if( !LB.IsNull() && !UB.IsNull())
+ ach->ClearFails();
ent->Init(LB,UB);
}
aTV = aTMD.ToleranceValue();
if (aTV.IsNull()) continue;
- Handle(StepBasic_MeasureWithUnit) aMWU = aTV->UpperBound();
- Standard_Real aVal = aTV->UpperBound()->ValueComponent();
- StepBasic_Unit anUnit = aTV->UpperBound()->UnitComponent();
+ Handle(Standard_Transient) aUpperBound = aTV->UpperBound();
+ if(aUpperBound.IsNull())
+ continue;
+ Handle(StepBasic_MeasureWithUnit) aMWU;
+ if(aUpperBound->IsKind(STANDARD_TYPE(StepBasic_MeasureWithUnit)) )
+ aMWU = Handle(StepBasic_MeasureWithUnit)::DownCast(aUpperBound);
+ else if(aUpperBound->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit)) )
+ {
+ Handle(StepRepr_ReprItemAndMeasureWithUnit) aReprMeasureItem =
+ Handle(StepRepr_ReprItemAndMeasureWithUnit)::DownCast(aUpperBound);
+ aMWU = aReprMeasureItem->GetMeasureWithUnit();
+
+ }
+ if(aMWU.IsNull())
+ continue;
+ Standard_Real aVal = aMWU->ValueComponent();
+ StepBasic_Unit anUnit = aMWU->UnitComponent();
if (anUnit.IsNull()) continue;
if (!(anUnit.CaseNum(anUnit.Value()) == 1)) continue;
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
}
aDim3 = aVal;
- aMWU = aTV->LowerBound();
- aVal = aTV->LowerBound()->ValueComponent();
- anUnit = aTV->LowerBound()->UnitComponent();
+
+ Handle(Standard_Transient) aLowerBound = aTV->LowerBound();
+ if(aLowerBound.IsNull())
+ continue;
+
+ if(aLowerBound->IsKind(STANDARD_TYPE(StepBasic_MeasureWithUnit)) )
+ aMWU = Handle(StepBasic_MeasureWithUnit)::DownCast(aLowerBound);
+ else if(aLowerBound->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit)) )
+ {
+ Handle(StepRepr_ReprItemAndMeasureWithUnit) aReprMeasureItem =
+ Handle(StepRepr_ReprItemAndMeasureWithUnit)::DownCast(aLowerBound);
+ aMWU = aReprMeasureItem->GetMeasureWithUnit();
+
+ }
+ if(aMWU.IsNull())
+ continue;
+
+ aVal = aMWU->ValueComponent();
+ anUnit = aMWU->UnitComponent();
if (anUnit.IsNull()) continue;
if (!(anUnit.CaseNum(anUnit.Value()) == 1)) continue;
NU = anUnit.NamedUnit();
if (!anIter.Value()->IsKind(STANDARD_TYPE(StepRepr_RepresentationRelationship)))
continue;
Handle(StepRepr_RepresentationRelationship) aReprRelationship = Handle(StepRepr_RepresentationRelationship)::DownCast(anIter.Value());
- if (aReprRelationship->Rep1() != theRepr)
+ if (!aReprRelationship->Rep1().IsNull() && aReprRelationship->Rep1() != theRepr)
collectViewShapes(theWS, theDoc, aReprRelationship->Rep1(), theShapes);
}
}
StepShape_ToleranceValue::StepShape_ToleranceValue () { }
void StepShape_ToleranceValue::Init
- (const Handle(StepBasic_MeasureWithUnit)& lower_bound,
- const Handle(StepBasic_MeasureWithUnit)& upper_bound)
+ (const Handle(Standard_Transient)& lower_bound,
+ const Handle(Standard_Transient)& upper_bound)
{
theLowerBound = lower_bound;
theUpperBound = upper_bound;
}
-Handle(StepBasic_MeasureWithUnit) StepShape_ToleranceValue::LowerBound () const
+Handle(Standard_Transient) StepShape_ToleranceValue::LowerBound () const
{ return theLowerBound; }
-void StepShape_ToleranceValue::SetLowerBound (const Handle(StepBasic_MeasureWithUnit)& lower_bound)
+void StepShape_ToleranceValue::SetLowerBound (const Handle(Standard_Transient)& lower_bound)
{ theLowerBound = lower_bound; }
-Handle(StepBasic_MeasureWithUnit) StepShape_ToleranceValue::UpperBound () const
+Handle(Standard_Transient) StepShape_ToleranceValue::UpperBound () const
{ return theUpperBound; }
-void StepShape_ToleranceValue::SetUpperBound (const Handle(StepBasic_MeasureWithUnit)& upper_bound)
+void StepShape_ToleranceValue::SetUpperBound (const Handle(Standard_Transient)& upper_bound)
{ theUpperBound = upper_bound; }
Standard_EXPORT StepShape_ToleranceValue();
- Standard_EXPORT void Init (const Handle(StepBasic_MeasureWithUnit)& lower_bound, const Handle(StepBasic_MeasureWithUnit)& upper_bound);
+ Standard_EXPORT void Init (const Handle(Standard_Transient)& lower_bound, const Handle(Standard_Transient)& upper_bound);
- Standard_EXPORT Handle(StepBasic_MeasureWithUnit) LowerBound() const;
+ Standard_EXPORT Handle(Standard_Transient) LowerBound() const;
- Standard_EXPORT void SetLowerBound (const Handle(StepBasic_MeasureWithUnit)& lower_bound);
+ Standard_EXPORT void SetLowerBound (const Handle(Standard_Transient)& lower_bound);
- Standard_EXPORT Handle(StepBasic_MeasureWithUnit) UpperBound() const;
+ Standard_EXPORT Handle(Standard_Transient) UpperBound() const;
- Standard_EXPORT void SetUpperBound (const Handle(StepBasic_MeasureWithUnit)& upper_bound);
+ Standard_EXPORT void SetUpperBound (const Handle(Standard_Transient)& upper_bound);
private:
- Handle(StepBasic_MeasureWithUnit) theLowerBound;
- Handle(StepBasic_MeasureWithUnit) theUpperBound;
+ Handle(Standard_Transient) theLowerBound;
+ Handle(Standard_Transient) theUpperBound;
};
--- /dev/null
+puts "===================================="
+puts "0030616: Crash on reading STEP file"
+puts "===================================="
+puts ""
+
+param xstep.cascade.unit M
+
+ReadStep D [locate_data_file bug30616_nist_ctc_01_asme1_ap242.stp]