diff --git a/src/Interface/Interface_EntityCluster.cxx b/src/Interface/Interface_EntityCluster.cxx index 579c31d811..244bbea5e4 100644 --- a/src/Interface/Interface_EntityCluster.cxx +++ b/src/Interface/Interface_EntityCluster.cxx @@ -19,6 +19,7 @@ #include #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Interface_EntityCluster,Standard_Transient) @@ -56,7 +57,12 @@ Interface_EntityCluster::Interface_EntityCluster () { } else if (theents[3].IsNull()) theents[3] = ent; else { // Si celui-ci est plein ... if (thenext.IsNull()) thenext = new Interface_EntityCluster(ent); - else thenext->Append(ent); + else { + Handle(Interface_EntityCluster) aCurEntClust = thenext; + while (aCurEntClust->HasNext() && aCurEntClust->IsLocalFull()) + aCurEntClust = aCurEntClust->thenext; + aCurEntClust->Append(ent); + } } } @@ -110,24 +116,39 @@ Interface_EntityCluster::Interface_EntityCluster () { } const Handle(Standard_Transient)& Interface_EntityCluster::Value (const Standard_Integer num) const { - Standard_Integer nb = NbLocal(); + Standard_Integer nb = NbLocal(), aLocalNum=num; if (num <= 0) throw Standard_OutOfRange("Interface EntityCluster : Value"); - if (num > nb) { - if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : Value"); - return thenext->Value(num-nb); + if (num > nb) { + Handle(Interface_EntityCluster) aCurEntClust = thenext; + aLocalNum -= nb; + while (aLocalNum>aCurEntClust->NbLocal()) + { + if (!aCurEntClust->HasNext()) throw Standard_OutOfRange("Interface EntityCluster : Value"); + aCurEntClust = aCurEntClust->thenext; + aLocalNum-= nb; + } + return aCurEntClust->theents[aLocalNum - 1]; } return theents[num-1]; // numerotation a partir de 0 } void Interface_EntityCluster::SetValue (const Standard_Integer num, const Handle(Standard_Transient)& ent) -{ +{ if (ent.IsNull()) throw Standard_NullObject("Interface_EntityCluster SetValue"); - Standard_Integer nb = NbLocal(); + Standard_Integer nb = NbLocal(), aLocalNum = num; if (num <= 0) throw Standard_OutOfRange("Interface EntityCluster : SetValue"); - if (num > nb) { - if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : SetValue"); - thenext->SetValue(num-nb,ent); + if (num > nb) + { + Handle(Interface_EntityCluster) aCurEntClust = thenext; + aLocalNum -= nb; + while (aLocalNum > aCurEntClust->NbLocal()) + { + if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : SetValue"); + aCurEntClust = aCurEntClust->thenext; + aLocalNum -= nb; + } + aCurEntClust->theents[aLocalNum - 1] = ent; } else theents[num-1] = ent; // numerotation a partir de 0 } @@ -168,3 +189,38 @@ Standard_Boolean Interface_EntityCluster::IsLocalFull () const Handle(Interface_EntityCluster) Interface_EntityCluster::Next () const { return thenext; } + +Interface_EntityCluster::~Interface_EntityCluster() +{ + if (!thenext.IsNull()) + { + //Loading entities into the collection + //for deletion in reverse order(avoiding the recursion) + NCollection_Sequence aNColOfEntClust; + Handle(Interface_EntityCluster) aCurEntClust = thenext; + while (aCurEntClust->HasNext()) + { + aNColOfEntClust.Append(aCurEntClust); + aCurEntClust = aCurEntClust->Next(); + } + aNColOfEntClust.Append(aCurEntClust); + aNColOfEntClust.Reverse(); + for (NCollection_Sequence::Iterator anEntClustIter(aNColOfEntClust); + anEntClustIter.More(); anEntClustIter.Next()) + { + //Nullifying and destruction all fields of each entity in the collection + for (Standard_Integer anInd = 0; anInd < anEntClustIter.ChangeValue()->NbLocal(); ++anInd) + { + anEntClustIter.ChangeValue()->theents[anInd].Nullify(); + } + anEntClustIter.ChangeValue()->thenext.Nullify(); + } + } + for (Standard_Integer anInd = 0; anInd < NbLocal(); ++anInd) + { + theents[anInd].Nullify(); + } + thenext.Nullify(); +} + + diff --git a/src/Interface/Interface_EntityCluster.hxx b/src/Interface/Interface_EntityCluster.hxx index 476a4333e1..15bc444311 100644 --- a/src/Interface/Interface_EntityCluster.hxx +++ b/src/Interface/Interface_EntityCluster.hxx @@ -92,6 +92,9 @@ public: //! Fills an Iterator with designated Entities (includes Next) Standard_EXPORT void FillIterator (Interface_EntityIterator& iter) const; + //! Destructor + //! If Next exists, destroy from the last entity in reverse order. + Standard_EXPORT virtual ~Interface_EntityCluster(); friend class Interface_EntityList; diff --git a/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx b/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx index 4617f73919..2c79553fcf 100644 --- a/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx +++ b/src/STEPCAFControl/STEPCAFControl_GDTProperty.cxx @@ -404,13 +404,12 @@ void STEPCAFControl_GDTProperty::GetDimClassOfTolerance(const Handle(StepShape_L theHolle = Standard_True; } Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("01"); - if(aGrade->IsSameString(aStr)) + theG = XCAFDimTolObjects_DimensionGrade_IT01; + if (!aGrade.IsNull() + && !aGrade->String().IsEqual("01") + && aGrade->IsIntegerValue()) { - theG = XCAFDimTolObjects_DimensionGrade_IT01; - } - else - { - theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue()+1); + theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue() + 1); } } diff --git a/tests/bugs/step/bug31435_1 b/tests/bugs/step/bug31435_1 new file mode 100644 index 0000000000..5466c5a642 --- /dev/null +++ b/tests/bugs/step/bug31435_1 @@ -0,0 +1,11 @@ +puts "# =====================================================================" +puts "# 0031435: Data Exchange - Problem importing STEP files" +puts "# =====================================================================" +puts "" + +pload OCAF +ReadStep D_1 [locate_data_file sp7_04-do-242.stp] + +XGetOneShape res_1 D_1 +checkshape res_1 r +checknbshapes res_1 -vertex 912 -edge 1320 -shape 3397 -face 518 -solid 1 -shell 2 \ No newline at end of file diff --git a/tests/bugs/step/bug31435_2 b/tests/bugs/step/bug31435_2 new file mode 100644 index 0000000000..d8b1d2ecbd --- /dev/null +++ b/tests/bugs/step/bug31435_2 @@ -0,0 +1,10 @@ +puts "# =====================================================================" +puts "# 0031435: Data Exchange - Problem importing STEP files" +puts "# =====================================================================" +puts "" + +pload OCAF +ReadStep D_2 [locate_data_file sp7_04-dx-242.stp] +XGetOneShape res_2 D_2 +checkshape res_2 r +checknbshapes res_2 -vertex 927 -edge 1158 -shape 3196 -face 406 -solid 1 -shell 2 \ No newline at end of file diff --git a/tests/bugs/step/bug31435_3 b/tests/bugs/step/bug31435_3 new file mode 100644 index 0000000000..2826a22e05 --- /dev/null +++ b/tests/bugs/step/bug31435_3 @@ -0,0 +1,12 @@ +puts "# =====================================================================" +puts "# 0031435: Data Exchange - Problem importing STEP files" +puts "# =====================================================================" +puts "" + + +ReadStep D [locate_data_file sp7_08_nx-242.stp] +ReadStep D_3 [locate_data_file sp7_08_nx-242.stp] +XGetOneShape res_3 D_3 +checkshape res_3 r +checknbshapes res_3 -vertex 404 -edge 664 -shape 1623 -face 248 -solid 1 -shell 2 +