diff --git a/src/RWStepShape/RWStepShape_RWToleranceValue.cxx b/src/RWStepShape/RWStepShape_RWToleranceValue.cxx index 66cd8fc062..f2821fa002 100644 --- a/src/RWStepShape/RWStepShape_RWToleranceValue.cxx +++ b/src/RWStepShape/RWStepShape_RWToleranceValue.cxx @@ -19,6 +19,8 @@ #include #include #include +#include +#include RWStepShape_RWToleranceValue::RWStepShape_RWToleranceValue () {} @@ -34,18 +36,45 @@ void RWStepShape_RWToleranceValue::ReadStep // --- 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); } diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index afeae40835..49c0472ba6 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -3239,9 +3239,23 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt, 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(); @@ -3259,9 +3273,25 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt, } 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(); @@ -4105,7 +4135,7 @@ void collectViewShapes(const Handle(XSControl_WorkSession)& theWS, 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); } } diff --git a/src/StepShape/StepShape_ToleranceValue.cxx b/src/StepShape/StepShape_ToleranceValue.cxx index e5c5e2f070..dee367d7d8 100644 --- a/src/StepShape/StepShape_ToleranceValue.cxx +++ b/src/StepShape/StepShape_ToleranceValue.cxx @@ -21,21 +21,21 @@ IMPLEMENT_STANDARD_RTTIEXT(StepShape_ToleranceValue,Standard_Transient) 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; } diff --git a/src/StepShape/StepShape_ToleranceValue.hxx b/src/StepShape/StepShape_ToleranceValue.hxx index 9fe6bc9c08..b9118384e2 100644 --- a/src/StepShape/StepShape_ToleranceValue.hxx +++ b/src/StepShape/StepShape_ToleranceValue.hxx @@ -35,15 +35,15 @@ public: 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); @@ -58,8 +58,8 @@ protected: private: - Handle(StepBasic_MeasureWithUnit) theLowerBound; - Handle(StepBasic_MeasureWithUnit) theUpperBound; + Handle(Standard_Transient) theLowerBound; + Handle(Standard_Transient) theUpperBound; }; diff --git a/tests/bugs/step/bug30616 b/tests/bugs/step/bug30616 new file mode 100644 index 0000000000..ec76d95fff --- /dev/null +++ b/tests/bugs/step/bug30616 @@ -0,0 +1,8 @@ +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]