From 4552136784136decf450bdde8f30dba342cef73b Mon Sep 17 00:00:00 2001 From: omy Date: Thu, 12 Sep 2013 14:08:48 +0400 Subject: [PATCH] 0024135: Result of reading step file is invalid. Now wrong multiplicity of boundary knots will be set to Degree + 1 (if it is higher). Adding test case for issue CR24135 --- .../RWStepAP214_RWAppliedGroupAssignment.cxx | 29 ++++++----- .../StepToGeom_MakeBSplineCurve.pxx | 48 ++++++++++++------- src/XSDRAWSTEP/XSDRAWSTEP.cxx | 2 +- tests/bugs/step/bug24135 | 27 +++++++++++ 4 files changed, 75 insertions(+), 31 deletions(-) create mode 100755 tests/bugs/step/bug24135 diff --git a/src/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx b/src/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx index c28554fe03..08f81742c7 100755 --- a/src/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx +++ b/src/RWStepAP214/RWStepAP214_RWAppliedGroupAssignment.cxx @@ -52,22 +52,23 @@ void RWStepAP214_RWAppliedGroupAssignment::ReadStep (const Handle(StepData_StepR // Own fields of AppliedGroupAssignment - Handle(StepAP214_HArray1OfGroupItem) aItems; + Handle(StepAP214_HArray1OfGroupItem) anItems; Standard_Integer sub2 = 0; if ( data->ReadSubList (num, 2, "items", ach, sub2) ) { Standard_Integer num2 = sub2; Standard_Integer nb0 = data->NbParams(num2); - aItems = new StepAP214_HArray1OfGroupItem (1, nb0); - for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { - StepAP214_GroupItem anIt0; - data->ReadEntity (num2, i0, "items", ach, anIt0); - aItems->SetValue(i0, anIt0); + if (nb0) + { + anItems = new StepAP214_HArray1OfGroupItem (1, nb0); + for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { + StepAP214_GroupItem anIt0; + data->ReadEntity (num2, i0, "items", ach, anIt0); + anItems->SetValue(i0, anIt0); + } } } - // Initialize entity - ent->Init(aGroupAssignment_AssignedGroup, - aItems); + ent->Init(aGroupAssignment_AssignedGroup, anItems); } //======================================================================= @@ -107,9 +108,11 @@ void RWStepAP214_RWAppliedGroupAssignment::Share (const Handle(StepAP214_Applied iter.AddItem (ent->StepBasic_GroupAssignment::AssignedGroup()); // Own fields of AppliedGroupAssignment - - for (Standard_Integer i2=1; i2 <= ent->Items()->Length(); i2++ ) { - StepAP214_GroupItem Var0 = ent->Items()->Value(i2); - iter.AddItem (Var0.Value()); + if (!ent->Items().IsNull()) + { + for (Standard_Integer i2=1; i2 <= ent->Items()->Length(); i2++ ) { + StepAP214_GroupItem Var0 = ent->Items()->Value(i2); + iter.AddItem (Var0.Value()); + } } } diff --git a/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx b/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx index e61c1edc9b..7eb21df7b6 100755 --- a/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx +++ b/src/StepToGeom/StepToGeom_MakeBSplineCurve.pxx @@ -36,27 +36,41 @@ const Standard_Integer Deg = BSCW->Degree(); const Standard_Integer NbPoles = BSCW->NbControlPointsList(); - //aControlPointsList = new StepGeom_HArray1OfCartesianPoint(1,NbPoles); - const Handle(StepGeom_HArray1OfCartesianPoint)& aControlPointsList = BSCW->ControlPointsList(); - Array1OfPnt_gen Poles(1,NbPoles); - - Standard_Integer i; - CartesianPoint_gen P; - for (i=1; i<=NbPoles; i++) - { - if (StepToGeom_MakeCartesianPoint_gen::Convert(aControlPointsList->Value(i),P)) - Poles.SetValue(i,P->Pnt_fonc()); - else - return Standard_False; - } - const Standard_Integer NbKnots = BSCW->NbKnotMultiplicities(); //aKnotMultiplicities = new TColStd_HArray1OfInteger(1,NbKnots); const Handle(TColStd_HArray1OfInteger)& aKnotMultiplicities = BSCW->KnotMultiplicities(); + + Standard_Integer i; + Standard_Integer aFMulDiff = 0,aLMulDiff = 0; TColStd_Array1OfInteger Mult(1,NbKnots); - for (i=1; i<=NbKnots; i++) { - Mult.SetValue(i,aKnotMultiplicities->Value(i)); + for (i=1; i<=NbKnots; ++i) { + Standard_Integer aCurrentVal = aKnotMultiplicities->Value(i); + if (aCurrentVal > Deg + 1) + { + if (i == 1) aFMulDiff = aCurrentVal - Deg - 1; + if (i == NbKnots) aLMulDiff = aCurrentVal - Deg - 1; +#ifdef DEB + cout << "\nWrong multiplicity " << aCurrentVal << " on " << i + << " knot!" << "\nChanged to " << Deg + 1 << endl; +#endif + aCurrentVal = Deg + 1; + } + Mult.SetValue(i,aCurrentVal); + } + + //aControlPointsList = new StepGeom_HArray1OfCartesianPoint(1,NbPoles); + const Handle(StepGeom_HArray1OfCartesianPoint)& aControlPointsList = BSCW->ControlPointsList(); + Standard_Integer aSumMulDiff = aFMulDiff + aLMulDiff; + Array1OfPnt_gen Poles(1,NbPoles - aSumMulDiff); + CartesianPoint_gen P; + + for (i = 1 + aFMulDiff; i<= NbPoles - aLMulDiff; ++i) + { + if (StepToGeom_MakeCartesianPoint_gen::Convert(aControlPointsList->Value(i),P)) + Poles.SetValue(i - aFMulDiff,P->Pnt_fonc()); + else + return Standard_False; } //aKnots = new TColStd_HArray1OfReal(1,NbKnots); @@ -86,7 +100,7 @@ shouldBePeriodic = Standard_False; //cout << "Strange BSpline Curve Descriptor" << endl; } - + if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) { const Handle(TColStd_HArray1OfReal)& aWeight = BSCWR->WeightsData(); TColStd_Array1OfReal W(1,NbPoles); diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index 8a2cdcbaf5..12e1bf52fa 100755 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -121,7 +121,7 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_ progress->Show(); Standard_Boolean fromtcl = Standard_False; - Standard_Boolean aFullMode = 0; + Standard_Boolean aFullMode = Standard_False; Standard_Integer k = 3; if(argc > k ) { diff --git a/tests/bugs/step/bug24135 b/tests/bugs/step/bug24135 new file mode 100755 index 0000000000..eefe71ebf7 --- /dev/null +++ b/tests/bugs/step/bug24135 @@ -0,0 +1,27 @@ +puts "========" +puts "OCC24135" +puts "========" +puts "" +####################################################################### +# Result of reading step file is invalid. +####################################################################### + +set BugNumber OCC24135 + +stepread [locate_data_file bug24135_Drum.stp] a * + +set exception_status 0 +set msg [ tpstat c ] +set index [ lsearch $msg Exeption ] + +if {$index > -1} { + set exception_status 1 +} + +if { ${exception_status} != 0 } { + puts "Faulty ${BugNumber}" +} else { + puts "OK ${BugNumber}" +} + +set 2dviewer 0