mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0031435: Data Exchange - Problem importing STEP files
- Fix recursion in EntityCluster's methods : - Value - SetValue - Append - Add destructor in the EntityCluster - Add check null grade in the STEPCAFControl_GDTProperty::GetDimClassOfTolerance
This commit is contained in:
parent
590b3f0416
commit
e00b8ed948
@ -19,6 +19,7 @@
|
|||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
#include <NCollection_Sequence.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Interface_EntityCluster,Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(Interface_EntityCluster,Standard_Transient)
|
||||||
|
|
||||||
@ -56,7 +57,12 @@ Interface_EntityCluster::Interface_EntityCluster () { }
|
|||||||
else if (theents[3].IsNull()) theents[3] = ent;
|
else if (theents[3].IsNull()) theents[3] = ent;
|
||||||
else { // Si celui-ci est plein ...
|
else { // Si celui-ci est plein ...
|
||||||
if (thenext.IsNull()) thenext = new Interface_EntityCluster(ent);
|
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,11 +116,18 @@ Interface_EntityCluster::Interface_EntityCluster () { }
|
|||||||
const Handle(Standard_Transient)& Interface_EntityCluster::Value
|
const Handle(Standard_Transient)& Interface_EntityCluster::Value
|
||||||
(const Standard_Integer num) const
|
(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 <= 0) throw Standard_OutOfRange("Interface EntityCluster : Value");
|
||||||
if (num > nb) {
|
if (num > nb) {
|
||||||
if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : Value");
|
Handle(Interface_EntityCluster) aCurEntClust = thenext;
|
||||||
return thenext->Value(num-nb);
|
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
|
return theents[num-1]; // numerotation a partir de 0
|
||||||
}
|
}
|
||||||
@ -123,11 +136,19 @@ Interface_EntityCluster::Interface_EntityCluster () { }
|
|||||||
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
|
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
|
||||||
{
|
{
|
||||||
if (ent.IsNull()) throw Standard_NullObject("Interface_EntityCluster SetValue");
|
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 <= 0) throw Standard_OutOfRange("Interface EntityCluster : SetValue");
|
||||||
if (num > nb) {
|
if (num > nb)
|
||||||
|
{
|
||||||
|
Handle(Interface_EntityCluster) aCurEntClust = thenext;
|
||||||
|
aLocalNum -= nb;
|
||||||
|
while (aLocalNum > aCurEntClust->NbLocal())
|
||||||
|
{
|
||||||
if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : SetValue");
|
if (thenext.IsNull()) throw Standard_OutOfRange("Interface EntityCluster : SetValue");
|
||||||
thenext->SetValue(num-nb,ent);
|
aCurEntClust = aCurEntClust->thenext;
|
||||||
|
aLocalNum -= nb;
|
||||||
|
}
|
||||||
|
aCurEntClust->theents[aLocalNum - 1] = ent;
|
||||||
}
|
}
|
||||||
else theents[num-1] = ent; // numerotation a partir de 0
|
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
|
Handle(Interface_EntityCluster) Interface_EntityCluster::Next () const
|
||||||
{ return thenext; }
|
{ return thenext; }
|
||||||
|
|
||||||
|
Interface_EntityCluster::~Interface_EntityCluster()
|
||||||
|
{
|
||||||
|
if (!thenext.IsNull())
|
||||||
|
{
|
||||||
|
//Loading entities into the collection
|
||||||
|
//for deletion in reverse order(avoiding the recursion)
|
||||||
|
NCollection_Sequence<Handle(Interface_EntityCluster)> aNColOfEntClust;
|
||||||
|
Handle(Interface_EntityCluster) aCurEntClust = thenext;
|
||||||
|
while (aCurEntClust->HasNext())
|
||||||
|
{
|
||||||
|
aNColOfEntClust.Append(aCurEntClust);
|
||||||
|
aCurEntClust = aCurEntClust->Next();
|
||||||
|
}
|
||||||
|
aNColOfEntClust.Append(aCurEntClust);
|
||||||
|
aNColOfEntClust.Reverse();
|
||||||
|
for (NCollection_Sequence<Handle(Interface_EntityCluster)>::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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@ public:
|
|||||||
//! Fills an Iterator with designated Entities (includes Next)
|
//! Fills an Iterator with designated Entities (includes Next)
|
||||||
Standard_EXPORT void FillIterator (Interface_EntityIterator& iter) const;
|
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;
|
friend class Interface_EntityList;
|
||||||
|
|
||||||
|
@ -404,11 +404,10 @@ void STEPCAFControl_GDTProperty::GetDimClassOfTolerance(const Handle(StepShape_L
|
|||||||
theHolle = Standard_True;
|
theHolle = Standard_True;
|
||||||
}
|
}
|
||||||
Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("01");
|
Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("01");
|
||||||
if(aGrade->IsSameString(aStr))
|
|
||||||
{
|
|
||||||
theG = XCAFDimTolObjects_DimensionGrade_IT01;
|
theG = XCAFDimTolObjects_DimensionGrade_IT01;
|
||||||
}
|
if (!aGrade.IsNull()
|
||||||
else
|
&& !aGrade->String().IsEqual("01")
|
||||||
|
&& aGrade->IsIntegerValue())
|
||||||
{
|
{
|
||||||
theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue() + 1);
|
theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue() + 1);
|
||||||
}
|
}
|
||||||
|
11
tests/bugs/step/bug31435_1
Normal file
11
tests/bugs/step/bug31435_1
Normal file
@ -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
|
10
tests/bugs/step/bug31435_2
Normal file
10
tests/bugs/step/bug31435_2
Normal file
@ -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
|
12
tests/bugs/step/bug31435_3
Normal file
12
tests/bugs/step/bug31435_3
Normal file
@ -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
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user