mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-16 21:30:14 +08:00
0022807: Loading of STEP entities in model during reading of STEP file requires redundant memory
This commit is contained in:
@@ -2,18 +2,39 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
Interface_BitMap::Interface_BitMap()
|
||||
{
|
||||
Initialize(0);
|
||||
}
|
||||
|
||||
Interface_BitMap::Interface_BitMap
|
||||
(const Standard_Integer nbitems, const Standard_Integer resflags)
|
||||
|
||||
Interface_BitMap::Interface_BitMap
|
||||
(const Standard_Integer nbitems, const Standard_Integer resflags)
|
||||
{
|
||||
Initialize(nbitems,resflags);
|
||||
}
|
||||
|
||||
void Interface_BitMap::Initialize(const Standard_Integer nbitems, const Standard_Integer resflags)
|
||||
{
|
||||
thenbitems = nbitems;
|
||||
thenbwords = nbitems/32 + 1;
|
||||
thenbflags = 0;
|
||||
theflags = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1)); theflags->Init(0);
|
||||
if(nbitems)
|
||||
{
|
||||
theflags = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1));
|
||||
theflags->Init(0);
|
||||
}
|
||||
}
|
||||
|
||||
Interface_BitMap::Interface_BitMap
|
||||
(const Interface_BitMap& other, const Standard_Boolean copied)
|
||||
Interface_BitMap::Interface_BitMap
|
||||
(const Interface_BitMap& other, const Standard_Boolean copied)
|
||||
{
|
||||
|
||||
Initialize(other,copied);
|
||||
}
|
||||
|
||||
void Interface_BitMap::Initialize(const Interface_BitMap& other,
|
||||
const Standard_Boolean copied)
|
||||
{
|
||||
other.Internals (thenbitems,thenbwords,thenbflags,theflags,thenames);
|
||||
if (!copied) return;
|
||||
@@ -31,18 +52,18 @@
|
||||
thenames = names;
|
||||
}
|
||||
|
||||
void Interface_BitMap::Internals
|
||||
(Standard_Integer& nbitems, Standard_Integer& nbwords,
|
||||
Standard_Integer& nbflags,
|
||||
Handle(TColStd_HArray1OfInteger)& flags,
|
||||
Handle(TColStd_HSequenceOfAsciiString)& names) const
|
||||
void Interface_BitMap::Internals
|
||||
(Standard_Integer& nbitems, Standard_Integer& nbwords,
|
||||
Standard_Integer& nbflags,
|
||||
Handle(TColStd_HArray1OfInteger)& flags,
|
||||
Handle(TColStd_HSequenceOfAsciiString)& names) const
|
||||
{
|
||||
nbitems = thenbitems; nbwords = thenbwords; nbflags = thenbflags;
|
||||
flags = theflags; names = thenames;
|
||||
}
|
||||
|
||||
|
||||
void Interface_BitMap::Reservate (const Standard_Integer moreflags)
|
||||
void Interface_BitMap::Reservate (const Standard_Integer moreflags)
|
||||
{
|
||||
Standard_Integer nb = theflags->Upper ();
|
||||
Standard_Integer nbflags = nb / thenbwords - 1; // flag 0 non compte ...
|
||||
@@ -57,7 +78,7 @@
|
||||
}
|
||||
|
||||
|
||||
void Interface_BitMap::SetLength (const Standard_Integer nbitems)
|
||||
void Interface_BitMap::SetLength (const Standard_Integer nbitems)
|
||||
{
|
||||
Standard_Integer nbw = nbitems/32 + 1;
|
||||
if (nbw == thenbwords) return;
|
||||
@@ -77,7 +98,7 @@
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer Interface_BitMap::AddFlag (const Standard_CString name)
|
||||
Standard_Integer Interface_BitMap::AddFlag (const Standard_CString name)
|
||||
{
|
||||
Reservate(1);
|
||||
Standard_Integer deja = 0;
|
||||
@@ -86,7 +107,7 @@
|
||||
Standard_Integer i, nb = thenames->Length();
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
if (thenames->Value(i).IsEqual("."))
|
||||
{ thenames->ChangeValue(i).AssignCat(name); deja = i; }
|
||||
{ thenames->ChangeValue(i).AssignCat(name); deja = i; }
|
||||
}
|
||||
}
|
||||
if (!deja) thenames->Append (TCollection_AsciiString(name));
|
||||
@@ -94,8 +115,8 @@
|
||||
return (deja ? deja : thenbflags);
|
||||
}
|
||||
|
||||
Standard_Integer Interface_BitMap::AddSomeFlags
|
||||
(const Standard_Integer more)
|
||||
Standard_Integer Interface_BitMap::AddSomeFlags
|
||||
(const Standard_Integer more)
|
||||
{
|
||||
Reservate(more);
|
||||
if (thenames.IsNull()) thenames = new TColStd_HSequenceOfAsciiString();
|
||||
@@ -105,8 +126,8 @@
|
||||
return thenbflags;
|
||||
}
|
||||
|
||||
Standard_Boolean Interface_BitMap::RemoveFlag
|
||||
(const Standard_Integer num)
|
||||
Standard_Boolean Interface_BitMap::RemoveFlag
|
||||
(const Standard_Integer num)
|
||||
{
|
||||
if (num < 1 || num > thenames->Length()) return Standard_False;
|
||||
if (num == thenames->Length()) thenames->Remove (thenames->Length());
|
||||
@@ -115,8 +136,8 @@
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean Interface_BitMap::SetFlagName
|
||||
(const Standard_Integer num, const Standard_CString name)
|
||||
Standard_Boolean Interface_BitMap::SetFlagName
|
||||
(const Standard_Integer num, const Standard_CString name)
|
||||
{
|
||||
if (num < 1 || num > thenames->Length()) return Standard_False;
|
||||
Standard_Integer deja = (name[0] == '\0' ? 0 : FlagNumber (name) );
|
||||
@@ -125,22 +146,22 @@
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Integer Interface_BitMap::NbFlags () const
|
||||
{ return thenbflags; }
|
||||
Standard_Integer Interface_BitMap::NbFlags () const
|
||||
{ return thenbflags; }
|
||||
|
||||
Standard_Integer Interface_BitMap::Length () const
|
||||
{ return thenbitems; }
|
||||
Standard_Integer Interface_BitMap::Length () const
|
||||
{ return thenbitems; }
|
||||
|
||||
Standard_CString Interface_BitMap::FlagName
|
||||
(const Standard_Integer num) const
|
||||
Standard_CString Interface_BitMap::FlagName
|
||||
(const Standard_Integer num) const
|
||||
{
|
||||
if (theflags.IsNull()) return "";
|
||||
if (num < 1 || num > thenames->Length()) return "";
|
||||
return thenames->Value(num).ToCString();
|
||||
}
|
||||
|
||||
Standard_Integer Interface_BitMap::FlagNumber
|
||||
(const Standard_CString name) const
|
||||
Standard_Integer Interface_BitMap::FlagNumber
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
if (name[0] == '\0') return 0;
|
||||
if (thenames.IsNull()) return 0;
|
||||
@@ -153,8 +174,8 @@
|
||||
|
||||
// Les valeurs ...
|
||||
|
||||
Standard_Boolean Interface_BitMap::Value
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
Standard_Boolean Interface_BitMap::Value
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
|
||||
const Standard_Integer& val = theflags->Value (numw);
|
||||
@@ -164,24 +185,24 @@
|
||||
return ( ((1 << numb) & val) != 0);
|
||||
}
|
||||
|
||||
void Interface_BitMap::SetValue
|
||||
(const Standard_Integer item, const Standard_Boolean val,
|
||||
const Standard_Integer flag) const
|
||||
void Interface_BitMap::SetValue
|
||||
(const Standard_Integer item, const Standard_Boolean val,
|
||||
const Standard_Integer flag) const
|
||||
{
|
||||
if (val) SetTrue (item,flag);
|
||||
else SetFalse (item,flag);
|
||||
}
|
||||
|
||||
void Interface_BitMap::SetTrue
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
void Interface_BitMap::SetTrue
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
|
||||
Standard_Integer numb = item & 31;
|
||||
theflags->ChangeValue (numw) |= (1 << numb);
|
||||
}
|
||||
|
||||
void Interface_BitMap::SetFalse
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
void Interface_BitMap::SetFalse
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
|
||||
Standard_Integer& val = theflags->ChangeValue (numw);
|
||||
@@ -190,8 +211,8 @@
|
||||
theflags->ChangeValue (numw) &= ~(1 << numb);
|
||||
}
|
||||
|
||||
Standard_Boolean Interface_BitMap::CTrue
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
Standard_Boolean Interface_BitMap::CTrue
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
|
||||
Standard_Integer numb = item & 31;
|
||||
@@ -203,8 +224,8 @@
|
||||
return (res != 0);
|
||||
}
|
||||
|
||||
Standard_Boolean Interface_BitMap::CFalse
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
Standard_Boolean Interface_BitMap::CFalse
|
||||
(const Standard_Integer item, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
|
||||
Standard_Integer numb = item & 31;
|
||||
@@ -217,11 +238,17 @@
|
||||
}
|
||||
|
||||
|
||||
void Interface_BitMap::Init
|
||||
(const Standard_Boolean val, const Standard_Integer flag) const
|
||||
void Interface_BitMap::Init
|
||||
(const Standard_Boolean val, const Standard_Integer flag) const
|
||||
{
|
||||
Standard_Integer i, ii = thenbwords, i1 = thenbwords *flag;
|
||||
if (flag < 0) { i1 = 0; ii = thenbwords*(thenbflags+1); }
|
||||
if (val) for (i = 0; i < ii; i ++) theflags->SetValue (i1+i,~(0));
|
||||
else for (i = 0; i < ii; i ++) theflags->SetValue (i1+i, 0 );
|
||||
}
|
||||
|
||||
void Interface_BitMap::Clear()
|
||||
{
|
||||
theflags.Nullify();
|
||||
Initialize(0);
|
||||
}
|
||||
Reference in New Issue
Block a user