1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027970: Improvement of standard attributes usability - containers.

This commit is contained in:
szy
2017-05-11 17:37:44 +03:00
committed by bugmaster
parent b18a83d4a7
commit 5a1271c8b4
111 changed files with 6038 additions and 1223 deletions

View File

@@ -127,6 +127,15 @@ void TDataStd_AsciiString::SetID( const Standard_GUID& theGuid)
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_AsciiString::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :

View File

@@ -62,7 +62,10 @@ public:
Standard_EXPORT void Set (const TCollection_AsciiString& S);
//! Sets the explicit user defined GUID to the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid);
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
Standard_EXPORT const TCollection_AsciiString& Get() const;

View File

@@ -59,6 +59,30 @@ const Standard_GUID& TDataStd_BooleanArray::GetID()
return TDataStd_BooleanArrayID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_BooleanArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_GUID& theGuid)
{
Handle(TDataStd_BooleanArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_BooleanArray;
A->SetID(theGuid);
A->Init (lower, upper);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : TDataStd_BooleanArray
//purpose : Empty Constructor
@@ -73,14 +97,13 @@ TDataStd_BooleanArray::TDataStd_BooleanArray()
//purpose :
//=======================================================================
void TDataStd_BooleanArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_BooleanArray::Init");
Backup();
myLower = lower;
myUpper = upper;
if (myUpper >= myLower)
myValues = new TColStd_HArray1OfByte(0, Length() >> 3, 0/*initialize to FALSE*/);
myValues = new TColStd_HArray1OfByte(0, Length() >> 3, 0/*initialize to FALSE*/);
}
//=======================================================================
@@ -88,30 +111,31 @@ void TDataStd_BooleanArray::Init(const Standard_Integer lower,
//purpose :
//=======================================================================
Handle(TDataStd_BooleanArray) TDataStd_BooleanArray::Set(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer lower,
const Standard_Integer upper)
{
Handle(TDataStd_BooleanArray) A;
if (!label.FindAttribute (TDataStd_BooleanArray::GetID(), A))
{
A = new TDataStd_BooleanArray;
A->Init (lower, upper);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
return SetAttr(label, lower, upper, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_BooleanArray) TDataStd_BooleanArray::Set(const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper)
{
return SetAttr(label, lower, upper, theGuid);
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void TDataStd_BooleanArray::SetValue (const Standard_Integer index,
const Standard_Boolean value)
const Standard_Boolean value)
{
if (myValues.IsNull())
@@ -204,9 +228,30 @@ void TDataStd_BooleanArray::SetInternalArray (const Handle(TColStd_HArray1OfByte
//=======================================================================
const Standard_GUID& TDataStd_BooleanArray::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_BooleanArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_BooleanArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :
@@ -234,6 +279,7 @@ void TDataStd_BooleanArray::Restore(const Handle(TDF_Attribute)& With)
{
myValues->SetValue(i, with_array.Value(i));
}
myID = anArray->ID();
}
else
{
@@ -256,9 +302,10 @@ void TDataStd_BooleanArray::Paste (const Handle(TDF_Attribute)& Into,
anArray->Init(myLower, myUpper);
for (Standard_Integer i = myLower; i <= myUpper; i++)
{
anArray->SetValue(i, Value(i));
anArray->SetValue(i, Value(i));
}
}
anArray->SetID(myID);
}
}
@@ -268,6 +315,10 @@ void TDataStd_BooleanArray::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_BooleanArray::Dump (Standard_OStream& anOS) const
{
anOS << "BooleanArray";
anOS << "\nBooleanArray: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS <<endl;
return anOS;
}

View File

@@ -24,6 +24,7 @@
#include <TDF_Attribute.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -45,22 +46,33 @@ public:
//! Returns an ID for array.
Standard_EXPORT static const Standard_GUID& GetID();
//! Finds or creates an attribute with the array.
//! Finds or creates an attribute with internal boolean array.
Standard_EXPORT static Handle(TDataStd_BooleanArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper);
//! Finds or creates an attribute with the array using explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_BooleanArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper);
//! Initialize the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
//! Sets the <Index>th element of the array to <Value>
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer index, const Standard_Boolean value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Return the value of the <Index>th element of the array.
Standard_EXPORT Standard_Boolean Value (const Standard_Integer Index) const;
Standard_Boolean operator () (const Standard_Integer Index) const
{
return Value(Index);
}
Standard_Boolean operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Returns the lower boundary of the array.
Standard_EXPORT Standard_Integer Lower() const;
@@ -103,7 +115,7 @@ private:
Handle(TColStd_HArray1OfByte) myValues;
Standard_Integer myLower;
Standard_Integer myUpper;
Standard_GUID myID;
};

View File

@@ -34,6 +34,23 @@ const Standard_GUID& TDataStd_BooleanList::GetID()
return TDataStd_BooleanListID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_BooleanList) SetAttr(const TDF_Label& label,
const Standard_GUID& theGuid)
{
Handle(TDataStd_BooleanList) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_BooleanList;
A->SetID(theGuid);
label.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataStd_BooleanList
//purpose : Empty Constructor
@@ -49,15 +66,18 @@ TDataStd_BooleanList::TDataStd_BooleanList()
//=======================================================================
Handle(TDataStd_BooleanList) TDataStd_BooleanList::Set(const TDF_Label& label)
{
Handle(TDataStd_BooleanList) A;
if (!label.FindAttribute (TDataStd_BooleanList::GetID(), A))
{
A = new TDataStd_BooleanList;
label.AddAttribute(A);
}
return A;
return SetAttr(label, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_BooleanList) TDataStd_BooleanList::Set(const TDF_Label& label,
const Standard_GUID& theGuid)
{
return SetAttr(label, theGuid);
}
//=======================================================================
//function : IsEmpty
//purpose :
@@ -207,7 +227,30 @@ Standard_Boolean TDataStd_BooleanList::Remove(const Standard_Integer index)
//=======================================================================
const Standard_GUID& TDataStd_BooleanList::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_BooleanList::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_BooleanList::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -232,6 +275,7 @@ void TDataStd_BooleanList::Restore(const Handle(TDF_Attribute)& With)
{
myList.Append (itr.Value() ? 1 : 0);
}
myID = aList->ID();
}
//=======================================================================
@@ -248,6 +292,7 @@ void TDataStd_BooleanList::Paste (const Handle(TDF_Attribute)& Into,
{
aList->Append (itr.Value() != 0);
}
aList->SetID(myID);
}
//=======================================================================
@@ -256,6 +301,10 @@ void TDataStd_BooleanList::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_BooleanList::Dump (Standard_OStream& anOS) const
{
anOS << "BooleanList";
anOS << "\nBooleanList: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -24,6 +24,8 @@
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -47,6 +49,9 @@ public:
//! Finds or creates a list of boolean values attribute.
Standard_EXPORT static Handle(TDataStd_BooleanList) Set (const TDF_Label& label);
//! Finds or creates a list of boolean values attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_BooleanList) Set (const TDF_Label& label, const Standard_GUID& theGuid);
Standard_EXPORT TDataStd_BooleanList();
@@ -78,7 +83,13 @@ public:
//! Removes a value at <index> position.
Standard_EXPORT Standard_Boolean Remove (const Standard_Integer index);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
@@ -103,7 +114,7 @@ private:
TDataStd_ListOfByte myList;
Standard_GUID myID;
};

View File

@@ -40,20 +40,44 @@ const Standard_GUID& TDataStd_ByteArray::GetID()
//function : TDataStd_ByteArray
//purpose : Empty Constructor
//=======================================================================
TDataStd_ByteArray::TDataStd_ByteArray() : myIsDelta(Standard_False){}
TDataStd_ByteArray::TDataStd_ByteArray() : myIsDelta(Standard_False)
{}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_ByteArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta,
const Standard_GUID& theGuid)
{
Handle(TDataStd_ByteArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_ByteArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
A->SetID(theGuid);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TDataStd_ByteArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_ByteArray::Init");
Backup();
if (upper >= lower)
myValue = new TColStd_HArray1OfByte(lower, upper, 0x00);
myValue = new TColStd_HArray1OfByte(lower, upper, 0x00);
}
//=======================================================================
@@ -61,19 +85,24 @@ void TDataStd_ByteArray::Init(const Standard_Integer lower,
//purpose :
//=======================================================================
Handle(TDataStd_ByteArray) TDataStd_ByteArray::Set(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
Handle(TDataStd_ByteArray) A;
if (!label.FindAttribute (TDataStd_ByteArray::GetID(), A))
{
A = new TDataStd_ByteArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
label.AddAttribute(A);
}
return A;
return SetAttr(label, lower, upper, isDelta, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_ByteArray) TDataStd_ByteArray::Set(const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
return SetAttr(label, lower, upper, isDelta, theGuid);
}
//=======================================================================
@@ -81,7 +110,7 @@ Handle(TDataStd_ByteArray) TDataStd_ByteArray::Set(const TDF_Label& label,
//purpose :
//=======================================================================
void TDataStd_ByteArray::SetValue (const Standard_Integer index,
const Standard_Byte value)
const Standard_Byte value)
{
if (myValue.IsNull())
return;
@@ -140,7 +169,7 @@ Standard_Integer TDataStd_ByteArray::Length (void) const
// : that holds <newArray>
//=======================================================================
void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newArray,
const Standard_Boolean isCheckItems)
const Standard_Boolean isCheckItems)
{
Standard_Integer aLower = newArray->Lower();
@@ -153,13 +182,13 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr
if(isCheckItems) {
Standard_Boolean isEqual = Standard_True;
for(i = aLower; i <= anUpper; i++) {
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
}
if(isEqual)
return;
return;
}
}
@@ -178,7 +207,30 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr
//=======================================================================
const Standard_GUID& TDataStd_ByteArray::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_ByteArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_ByteArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -205,6 +257,7 @@ void TDataStd_ByteArray::Restore(const Handle(TDF_Attribute)& With)
for (; i <= upper; i++)
myValue->SetValue(i, with_array.Value(i));
myIsDelta = anArray->myIsDelta;
myID = anArray->ID();
}
else
myValue.Nullify();
@@ -215,7 +268,7 @@ void TDataStd_ByteArray::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_ByteArray::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& ) const
const Handle(TDF_RelocationTable)& ) const
{
if (!myValue.IsNull())
{
@@ -224,6 +277,7 @@ void TDataStd_ByteArray::Paste (const Handle(TDF_Attribute)& Into,
{
anAtt->ChangeArray( myValue, Standard_False);
anAtt->SetDelta(myIsDelta);
anAtt->SetID(myID);
}
}
}
@@ -234,7 +288,10 @@ void TDataStd_ByteArray::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_ByteArray::Dump (Standard_OStream& anOS) const
{
anOS << "ByteArray";
anOS << "\nByteArray: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid << endl;
return anOS;
}

View File

@@ -25,6 +25,8 @@
#include <Standard_Integer.hxx>
#include <Standard_Byte.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class TDataStd_DeltaOnModificationOfByteArray;
class Standard_GUID;
class TDF_Label;
@@ -43,6 +45,7 @@ class TDataStd_ByteArray : public TDF_Attribute
DEFINE_STANDARD_RTTIEXT(TDataStd_ByteArray, TDF_Attribute)
public:
//! Static methods
//! ==============
//! Returns an ID for array.
@@ -55,6 +58,11 @@ public:
//! attribute is returned.
Standard_EXPORT static Handle(TDataStd_ByteArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper, const Standard_Boolean isDelta = Standard_False);
//! Finds or creates an attribute with byte array and explicit user defined <guid> on the specified label.
Standard_EXPORT static Handle(TDataStd_ByteArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper,
const Standard_Boolean isDelta = Standard_False);
//! Initialize the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
@@ -62,12 +70,19 @@ public:
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer index, const Standard_Byte value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Return the value of the <Index>th element of the array.
Standard_EXPORT Standard_Byte Value (const Standard_Integer Index) const;
Standard_Byte operator () (const Standard_Integer Index) const
{
return Value(Index);
}
Standard_Byte operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Returns the lower boundary of the array.
Standard_EXPORT Standard_Integer Lower() const;
@@ -117,6 +132,7 @@ private:
Handle(TColStd_HArray1OfByte) myValue;
Standard_Boolean myIsDelta;
Standard_GUID myID;
};

View File

@@ -37,7 +37,31 @@ const Standard_GUID& TDataStd_ExtStringArray::GetID()
return anExtStringArrayID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
Handle(TDataStd_ExtStringArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta,
const Standard_GUID& theGuid)
{
Handle(TDataStd_ExtStringArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_ExtStringArray;
A->SetID(theGuid);
A->Init (lower, upper);
A->SetDelta(isDelta);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : TDataStd_ExtStringArray::TDataStd_ExtStringArray
//purpose :
@@ -52,8 +76,9 @@ TDataStd_ExtStringArray::TDataStd_ExtStringArray()
//=======================================================================
void TDataStd_ExtStringArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_ExtStringArray::Init");
Backup();
myValue = new TColStd_HArray1OfExtendedString(lower, upper, "");
}
@@ -64,27 +89,30 @@ void TDataStd_ExtStringArray::Init(const Standard_Integer lower,
//=======================================================================
Handle(TDataStd_ExtStringArray) TDataStd_ExtStringArray::Set (
const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
Handle(TDataStd_ExtStringArray) A;
if (!label.FindAttribute (TDataStd_ExtStringArray::GetID(), A)) {
A = new TDataStd_ExtStringArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init (lower, upper);
}
return A;
return SetAttr(label, lower, upper, isDelta, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_ExtStringArray) TDataStd_ExtStringArray::Set (
const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
return SetAttr(label, lower, upper, isDelta, theGuid);
}
//=======================================================================
//function : SetValue
//purpose :
@@ -108,12 +136,12 @@ void TDataStd_ExtStringArray::SetValue(const Standard_Integer index, const TColl
const TCollection_ExtendedString& TDataStd_ExtStringArray::Value (const Standard_Integer index) const
{
if (myValue.IsNull())
{
static TCollection_ExtendedString staticEmptyValue;
return staticEmptyValue;
}
return myValue->Value(index);
if (myValue.IsNull())
{
static TCollection_ExtendedString staticEmptyValue;
return staticEmptyValue;
}
return myValue->Value(index);
}
//=======================================================================
@@ -158,7 +186,7 @@ Standard_Integer TDataStd_ExtStringArray::Length (void) const
//=======================================================================
void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtendedString)& newArray,
const Standard_Boolean isCheckItems)
const Standard_Boolean isCheckItems)
{
Standard_Integer aLower = newArray->Lower();
Standard_Integer anUpper = newArray->Upper();
@@ -170,13 +198,13 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended
Standard_Boolean isEqual = Standard_True;
if(isCheckItems) {
for(i = aLower; i <= anUpper; i++) {
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
}
if(isEqual)
return;
return;
}
}
@@ -195,8 +223,30 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_ExtStringArray::ID () const { return GetID(); }
const Standard_GUID& TDataStd_ExtStringArray::ID () const { return myID; }
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_ExtStringArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_ExtStringArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
@@ -224,6 +274,7 @@ void TDataStd_ExtStringArray::Restore(const Handle(TDF_Attribute)& With)
for(i = lower; i<=upper; i++)
myValue->SetValue(i, anArray->Value(i));
myIsDelta = anArray->myIsDelta;
myID = anArray->ID();
}
else
myValue.Nullify();
@@ -235,13 +286,14 @@ void TDataStd_ExtStringArray::Restore(const Handle(TDF_Attribute)& With)
//=======================================================================
void TDataStd_ExtStringArray::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& ) const
const Handle(TDF_RelocationTable)& ) const
{
if(!myValue.IsNull()) {
Handle(TDataStd_ExtStringArray) anAtt = Handle(TDataStd_ExtStringArray)::DownCast(Into);
if(!anAtt.IsNull()) {
anAtt->ChangeArray( myValue, Standard_False );
anAtt->SetDelta(myIsDelta);
anAtt->SetID(myID);
}
}
}
@@ -253,7 +305,7 @@ void TDataStd_ExtStringArray::Paste (const Handle(TDF_Attribute)& Into,
Standard_OStream& TDataStd_ExtStringArray::Dump (Standard_OStream& anOS) const
{
anOS << "ExtStringArray :";
anOS << "\nExtStringArray :";
if(!myValue.IsNull()) {
Standard_Integer i, lower, upper;
lower = myValue->Lower();
@@ -262,6 +314,9 @@ Standard_OStream& TDataStd_ExtStringArray::Dump (Standard_OStream& anOS) const
anOS << "\t" <<myValue->Value(i)<<endl;
}
anOS << " Delta is " << (myIsDelta ? "ON":"OFF");
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -24,6 +24,8 @@
#include <TDF_Attribute.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class TDataStd_DeltaOnModificationOfExtStringArray;
class Standard_GUID;
class TDF_Label;
@@ -55,20 +57,34 @@ public:
//! If attribute is already set, all input parameters are refused and the found
//! attribute is returned.
Standard_EXPORT static Handle(TDataStd_ExtStringArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper, const Standard_Boolean isDelta = Standard_False);
//! Finds, or creates, an ExtStringArray attribute with explicit user defined <guid>.
//! The ExtStringArray attribute is returned.
Standard_EXPORT static Handle(TDataStd_ExtStringArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper,
const Standard_Boolean isDelta = Standard_False);
//! Initializes the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
//! Sets the <Index>th element of the array to <Value>
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer Index, const TCollection_ExtendedString& Value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the value of the <Index>th element of the array
Standard_EXPORT const TCollection_ExtendedString& Value (const Standard_Integer Index) const;
const TCollection_ExtendedString& operator () (const Standard_Integer Index) const
{
return Value(Index);
}
const TCollection_ExtendedString& operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Return the lower bound.
Standard_EXPORT Standard_Integer Lower() const;
@@ -118,6 +134,7 @@ private:
Handle(TColStd_HArray1OfExtendedString) myValue;
Standard_Boolean myIsDelta;
Standard_GUID myID;
};

View File

@@ -35,14 +35,29 @@ const Standard_GUID& TDataStd_ExtStringList::GetID()
return TDataStd_ExtStringListID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_ExtStringList) SetAttr(const TDF_Label& label,
const Standard_GUID& theGuid)
{
Handle(TDataStd_ExtStringList) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_ExtStringList;
A->SetID(theGuid);
label.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataStd_ExtStringList
//purpose : Empty Constructor
//=======================================================================
TDataStd_ExtStringList::TDataStd_ExtStringList()
{
}
TDataStd_ExtStringList::TDataStd_ExtStringList()
{}
//=======================================================================
//function : Set
@@ -50,13 +65,17 @@ TDataStd_ExtStringList::TDataStd_ExtStringList()
//=======================================================================
Handle(TDataStd_ExtStringList) TDataStd_ExtStringList::Set(const TDF_Label& label)
{
Handle(TDataStd_ExtStringList) A;
if (!label.FindAttribute (TDataStd_ExtStringList::GetID(), A))
{
A = new TDataStd_ExtStringList;
label.AddAttribute(A);
}
return A;
return SetAttr(label, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_ExtStringList) TDataStd_ExtStringList::Set(const TDF_Label& label,
const Standard_GUID& theGuid)
{
return SetAttr(label, theGuid);
}
//=======================================================================
@@ -102,7 +121,7 @@ void TDataStd_ExtStringList::Append(const TCollection_ExtendedString& value)
//purpose :
//=======================================================================
Standard_Boolean TDataStd_ExtStringList::InsertBefore(const TCollection_ExtendedString& value,
const TCollection_ExtendedString& before_value)
const TCollection_ExtendedString& before_value)
{
TDataStd_ListIteratorOfListOfExtendedString itr(myList);
for (; itr.More(); itr.Next())
@@ -145,7 +164,7 @@ Standard_Boolean TDataStd_ExtStringList::InsertBefore(const Standard_Integer ind
//purpose :
//=======================================================================
Standard_Boolean TDataStd_ExtStringList::InsertAfter(const TCollection_ExtendedString& value,
const TCollection_ExtendedString& after_value)
const TCollection_ExtendedString& after_value)
{
TDataStd_ListIteratorOfListOfExtendedString itr(myList);
for (; itr.More(); itr.Next())
@@ -267,9 +286,31 @@ const TDataStd_ListOfExtendedString& TDataStd_ExtStringList::List() const
//=======================================================================
const Standard_GUID& TDataStd_ExtStringList::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_ExtStringList::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_ExtStringList::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :
@@ -292,6 +333,7 @@ void TDataStd_ExtStringList::Restore(const Handle(TDF_Attribute)& With)
{
myList.Append(itr.Value());
}
myID = aList->ID();
}
//=======================================================================
@@ -299,7 +341,7 @@ void TDataStd_ExtStringList::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_ExtStringList::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& ) const
const Handle(TDF_RelocationTable)& ) const
{
Handle(TDataStd_ExtStringList) aList = Handle(TDataStd_ExtStringList)::DownCast(Into);
aList->Clear();
@@ -308,6 +350,7 @@ void TDataStd_ExtStringList::Paste (const Handle(TDF_Attribute)& Into,
{
aList->Append(itr.Value());
}
aList->SetID(myID);
}
//=======================================================================
@@ -316,6 +359,10 @@ void TDataStd_ExtStringList::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_ExtStringList::Dump (Standard_OStream& anOS) const
{
anOS << "ExtStringList";
anOS << "\nExtStringList: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -24,6 +24,8 @@
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TCollection_ExtendedString;
@@ -46,8 +48,11 @@ public:
//! Returns the ID of the list of strings attribute.
Standard_EXPORT static const Standard_GUID& GetID();
//! Finds or creates a list of string values attribute.
//! Finds or creates a list of string values attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_ExtStringList) Set (const TDF_Label& label);
//! Finds or creates a list of string values attribute.
Standard_EXPORT static Handle(TDataStd_ExtStringList) Set (const TDF_Label& label, const Standard_GUID& theGuid);
Standard_EXPORT TDataStd_ExtStringList();
@@ -58,7 +63,13 @@ public:
Standard_EXPORT void Prepend (const TCollection_ExtendedString& value);
Standard_EXPORT void Append (const TCollection_ExtendedString& value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const TCollection_ExtendedString& value, const TCollection_ExtendedString& before_value);
@@ -111,7 +122,7 @@ private:
TDataStd_ListOfExtendedString myList;
Standard_GUID myID;
};

View File

@@ -135,6 +135,17 @@ void TDataStd_Integer::SetID( const Standard_GUID& theGuid)
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_Integer::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :

View File

@@ -61,7 +61,10 @@ public:
Standard_EXPORT void Set (const Standard_Integer V);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid);
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the integer value contained in the attribute.
Standard_EXPORT Standard_Integer Get() const;

View File

@@ -37,6 +37,31 @@ const Standard_GUID& TDataStd_IntegerArray::GetID()
return TDataStd_IntegerArrayID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_IntegerArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta,
const Standard_GUID& theGuid)
{
Handle(TDataStd_IntegerArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_IntegerArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
A->SetID(theGuid);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : TDataStd_IntegerArray
@@ -44,7 +69,8 @@ const Standard_GUID& TDataStd_IntegerArray::GetID()
//=======================================================================
TDataStd_IntegerArray::TDataStd_IntegerArray()
:myIsDelta(Standard_False) {}
:myIsDelta(Standard_False)
{}
//=======================================================================
//function : Init
@@ -54,6 +80,7 @@ TDataStd_IntegerArray::TDataStd_IntegerArray()
void TDataStd_IntegerArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_IntegerArray::Init");
Backup();
myValue = new TColStd_HArray1OfInteger(lower, upper, 0);
}
@@ -67,23 +94,27 @@ Handle(TDataStd_IntegerArray) TDataStd_IntegerArray::Set
(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
const Standard_Boolean isDelta)
{
Handle(TDataStd_IntegerArray) A;
if (!label.FindAttribute (TDataStd_IntegerArray::GetID(), A)) {
A = new TDataStd_IntegerArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init (lower, upper);
}
return A;
return SetAttr(label, lower, upper, isDelta, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_IntegerArray) TDataStd_IntegerArray::Set
(const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
return SetAttr(label, lower, upper, isDelta, theGuid);
}
//=======================================================================
//function : SetValue
//purpose :
@@ -153,7 +184,7 @@ Standard_Integer TDataStd_IntegerArray::Length (void) const
//=======================================================================
void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)& newArray,
const Standard_Boolean isCheckItems)
const Standard_Boolean isCheckItems)
{
Standard_Integer aLower = newArray->Lower();
Standard_Integer anUpper = newArray->Upper();
@@ -165,16 +196,16 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)&
if(isCheckItems) {
Standard_Boolean isEqual = Standard_True;
for(i = aLower; i <= anUpper; i++) {
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
}
if(isEqual)
return;
return;
}
}
Backup();
// Handles of myValue of current and backuped attributes will be different!
if(myValue.IsNull() || !aDimEqual)
@@ -190,8 +221,30 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)&
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_IntegerArray::ID () const { return GetID(); }
const Standard_GUID& TDataStd_IntegerArray::ID () const { return myID; }
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_IntegerArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_IntegerArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
@@ -219,6 +272,7 @@ void TDataStd_IntegerArray::Restore(const Handle(TDF_Attribute)& With)
for(i = lower; i<=upper; i++)
myValue->SetValue(i, anArray->Value(i));
myIsDelta = anArray->myIsDelta;
myID = anArray->ID();
}
else
myValue.Nullify();
@@ -238,6 +292,7 @@ void TDataStd_IntegerArray::Paste (const Handle(TDF_Attribute)& Into,
if(!anAtt.IsNull()) {
anAtt->ChangeArray( myValue, Standard_False );
anAtt->SetDelta(myIsDelta);
anAtt->SetID(myID);
}
}
}
@@ -258,6 +313,9 @@ Standard_OStream& TDataStd_IntegerArray::Dump (Standard_OStream& anOS) const
anOS << " " <<myValue->Value(i);
}
anOS << " Delta is " << (myIsDelta ? "ON":"OFF");
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
// anOS <<"\nAttribute fields: ";
@@ -278,5 +336,3 @@ Handle(TDF_DeltaOnModification) TDataStd_IntegerArray::DeltaOnModification
return new TDataStd_DeltaOnModificationOfIntArray(Handle(TDataStd_IntegerArray)::DownCast (OldAttribute));
else return new TDF_DefaultDeltaOnModification(OldAttribute);
}

View File

@@ -25,6 +25,8 @@
#include <TDF_Attribute.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class TDataStd_DeltaOnModificationOfIntArray;
class Standard_GUID;
class TDF_Label;
@@ -54,8 +56,16 @@ public:
//! If <isDelta> == True, DeltaOnModification of the current attribute is used.
//! If attribute is already set, all input parameters are refused and the found
//! attribute is returned.
Standard_EXPORT static Handle(TDataStd_IntegerArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper, const Standard_Boolean isDelta = Standard_False);
Standard_EXPORT static Handle(TDataStd_IntegerArray) Set (const TDF_Label& label, const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta = Standard_False);
//! Finds, or creates, an IntegerArray attribute with explicit user defined <guid>.
//! The IntegerArray attribute is returned.
Standard_EXPORT static Handle(TDataStd_IntegerArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper,
const Standard_Boolean isDelta = Standard_False);
//! Initialize the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
@@ -63,12 +73,19 @@ public:
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer Index, const Standard_Integer Value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Return the value of the <Index>th element of the array
Standard_EXPORT Standard_Integer Value (const Standard_Integer Index) const;
Standard_Integer operator () (const Standard_Integer Index) const
{
return Value(Index);
}
Standard_Integer operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Returns the lower boundary of this array of integers.
Standard_EXPORT Standard_Integer Lower() const;
@@ -121,6 +138,8 @@ private:
Handle(TColStd_HArray1OfInteger) myValue;
Standard_Boolean myIsDelta;
Standard_GUID myID;
};

View File

@@ -34,6 +34,23 @@ const Standard_GUID& TDataStd_IntegerList::GetID()
return TDataStd_IntegerListID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_IntegerList) SetAttr(const TDF_Label& label,
const Standard_GUID& theGuid)
{
Handle(TDataStd_IntegerList) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_IntegerList;
A->SetID(theGuid);
label.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataStd_IntegerList
//purpose : Empty Constructor
@@ -49,13 +66,17 @@ TDataStd_IntegerList::TDataStd_IntegerList()
//=======================================================================
Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label)
{
Handle(TDataStd_IntegerList) A;
if (!label.FindAttribute (TDataStd_IntegerList::GetID(), A))
{
A = new TDataStd_IntegerList;
label.AddAttribute(A);
}
return A;
return SetAttr(label, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label,
const Standard_GUID& theGuid)
{
return SetAttr(label, theGuid);
}
//=======================================================================
@@ -101,7 +122,7 @@ void TDataStd_IntegerList::Append(const Standard_Integer value)
//purpose :
//=======================================================================
Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value,
const Standard_Integer before_value)
const Standard_Integer before_value)
{
TColStd_ListIteratorOfListOfInteger itr(myList);
for (; itr.More(); itr.Next())
@@ -142,7 +163,7 @@ Standard_Boolean TDataStd_IntegerList::InsertBeforeByIndex (const Standard_Integ
//purpose :
//=======================================================================
Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value,
const Standard_Integer after_value)
const Standard_Integer after_value)
{
TColStd_ListIteratorOfListOfInteger itr(myList);
for (; itr.More(); itr.Next())
@@ -262,7 +283,30 @@ const TColStd_ListOfInteger& TDataStd_IntegerList::List() const
//=======================================================================
const Standard_GUID& TDataStd_IntegerList::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_IntegerList::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_IntegerList::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -287,6 +331,7 @@ void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With)
{
myList.Append(itr.Value());
}
myID = aList->ID();
}
//=======================================================================
@@ -294,7 +339,7 @@ void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& ) const
const Handle(TDF_RelocationTable)& ) const
{
Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(Into);
aList->Clear();
@@ -303,6 +348,7 @@ void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
{
aList->Append(itr.Value());
}
aList->SetID(myID);
}
//=======================================================================
@@ -311,6 +357,10 @@ void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_IntegerList::Dump (Standard_OStream& anOS) const
{
anOS << "IntegerList";
anOS << "\nIntegerList: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -24,6 +24,8 @@
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -47,7 +49,10 @@ public:
//! Finds or creates a list of integer values attribute.
Standard_EXPORT static Handle(TDataStd_IntegerList) Set (const TDF_Label& label);
//! Finds or creates a list of integer values attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_IntegerList) Set (const TDF_Label& label, const Standard_GUID& theGuid);
Standard_EXPORT TDataStd_IntegerList();
Standard_EXPORT Standard_Boolean IsEmpty() const;
@@ -57,7 +62,13 @@ public:
Standard_EXPORT void Prepend (const Standard_Integer value);
Standard_EXPORT void Append (const Standard_Integer value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Integer value, const Standard_Integer before_value);
@@ -110,7 +121,7 @@ private:
TColStd_ListOfInteger myList;
Standard_GUID myID;
};

View File

@@ -119,6 +119,16 @@ void TDataStd_Name::SetID( const Standard_GUID& theGuid)
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_Name::SetID()
{
Backup();
myID = GetID();
}
// TDF_Attribute methods
//=======================================================================
//function : ID

View File

@@ -81,7 +81,10 @@ public:
Standard_EXPORT void Set (const TCollection_ExtendedString& S);
//! Sets the explicit user defined GUID to the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid);
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the name contained in this name attribute.
Standard_EXPORT const TCollection_ExtendedString& Get() const;

View File

@@ -172,6 +172,16 @@ void TDataStd_Real::SetID( const Standard_GUID& theGuid)
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_Real::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :

View File

@@ -72,7 +72,10 @@ public:
Standard_EXPORT void Set (const Standard_Real V);
//! Sets the explicit GUID for the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid);
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the real number value contained in the attribute.
Standard_EXPORT Standard_Real Get() const;

View File

@@ -37,13 +37,39 @@ const Standard_GUID& TDataStd_RealArray::GetID()
return TDataStd_RealArrayID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_RealArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta,
const Standard_GUID& theGuid)
{
Handle(TDataStd_RealArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_RealArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
A->SetID(theGuid);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : TDataStd_RealArray
//purpose : Empty Constructor
//=======================================================================
TDataStd_RealArray::TDataStd_RealArray() : myIsDelta(Standard_False){}
TDataStd_RealArray::TDataStd_RealArray() : myIsDelta(Standard_False)
{}
//=======================================================================
//function : Init
@@ -53,8 +79,8 @@ TDataStd_RealArray::TDataStd_RealArray() : myIsDelta(Standard_False){}
void TDataStd_RealArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_RealArray::Init");
Backup(); // jfa 15.01.2003 for LH3D1378
myValue = new TColStd_HArray1OfReal(lower, upper, 0.);
}
@@ -67,23 +93,25 @@ Handle(TDataStd_RealArray) TDataStd_RealArray::Set
(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
const Standard_Boolean isDelta)
{
Handle(TDataStd_RealArray) A;
if (!label.FindAttribute (TDataStd_RealArray::GetID(), A)) {
A = new TDataStd_RealArray;
A->Init (lower, upper);
A->SetDelta(isDelta);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init (lower, upper);
}
return A;
return SetAttr(label, lower, upper, isDelta, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_RealArray) TDataStd_RealArray::Set
(const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_Boolean isDelta)
{
return SetAttr(label, lower, upper, isDelta, theGuid);
}
//=======================================================================
//function : SetValue
//purpose :
@@ -95,7 +123,7 @@ void TDataStd_RealArray::SetValue (const Standard_Integer index,
// OCC2932 correction
if(myValue.IsNull()) return;
if(myValue->Value(index) == value)
return;
return;
Backup();
myValue->SetValue(index, value);
}
@@ -155,7 +183,7 @@ Standard_Integer TDataStd_RealArray::Length (void) const
//=======================================================================
void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray,
const Standard_Boolean isCheckItems)
const Standard_Boolean isCheckItems)
{
Standard_Integer aLower = newArray->Lower();
Standard_Integer anUpper = newArray->Upper();
@@ -167,13 +195,13 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr
Standard_Boolean isEqual = Standard_True;
if(isCheckItems) {
for(i = aLower; i <= anUpper; i++) {
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
if(myValue->Value(i) != newArray->Value(i)) {
isEqual = Standard_False;
break;
}
}
if(isEqual)
return;
return;
}
}
@@ -191,8 +219,30 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_RealArray::ID () const { return GetID(); }
const Standard_GUID& TDataStd_RealArray::ID () const { return myID; }
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_RealArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_RealArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
//function : NewEmpty
@@ -220,6 +270,7 @@ void TDataStd_RealArray::Restore(const Handle(TDF_Attribute)& With)
myValue = new TColStd_HArray1OfReal(lower, upper);
for(i = lower; i<=upper; i++)
myValue->SetValue(i, anArray->Value(i));
myID = anArray->ID();
}
else
myValue.Nullify();
@@ -238,6 +289,7 @@ void TDataStd_RealArray::Paste (const Handle(TDF_Attribute)& Into,
if(!anAtt.IsNull()) {
anAtt->ChangeArray( myValue, Standard_False );
anAtt->SetDelta(myIsDelta);
anAtt->SetID(myID);
}
}
}
@@ -258,6 +310,9 @@ Standard_OStream& TDataStd_RealArray::Dump (Standard_OStream& anOS) const
anOS << " " <<myValue->Value(i);
}
anOS << " Delta is " << (myIsDelta ? "ON":"OFF");
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -26,6 +26,8 @@
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class TDataStd_DeltaOnModificationOfRealArray;
class Standard_GUID;
class TDF_Label;
@@ -56,20 +58,33 @@ public:
//! If attribute is already set, input parameter <isDelta> is refused and the found
//! attribute returned.
Standard_EXPORT static Handle(TDataStd_RealArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper, const Standard_Boolean isDelta = Standard_False);
//! Finds, or creates, an RealArray attribute with explicit user defined <guid>.
//! The RealArray attribute is returned.
Standard_EXPORT static Handle(TDataStd_RealArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper,
const Standard_Boolean isDelta = Standard_False);
//! Initialize the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Sets the <Index>th element of the array to <Value>
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer Index, const Standard_Real Value);
//! Return the value of the <Index>th element of the array
Standard_EXPORT Standard_Real Value (const Standard_Integer Index) const;
Standard_Real operator () (const Standard_Integer Index) const
{
return Value(Index);
}
Standard_Real operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Returns the lower boundary of the array.
Standard_EXPORT Standard_Integer Lower() const;
@@ -122,6 +137,7 @@ private:
Handle(TColStd_HArray1OfReal) myValue;
Standard_Boolean myIsDelta;
Standard_GUID myID;
};

View File

@@ -34,6 +34,23 @@ const Standard_GUID& TDataStd_RealList::GetID()
return TDataStd_RealListID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_RealList) SetAttr(const TDF_Label& label,
const Standard_GUID& theGuid)
{
Handle(TDataStd_RealList) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_RealList;
A->SetID(theGuid);
label.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataStd_RealList
//purpose : Empty Constructor
@@ -49,13 +66,17 @@ TDataStd_RealList::TDataStd_RealList()
//=======================================================================
Handle(TDataStd_RealList) TDataStd_RealList::Set(const TDF_Label& label)
{
Handle(TDataStd_RealList) A;
if (!label.FindAttribute (TDataStd_RealList::GetID(), A))
{
A = new TDataStd_RealList;
label.AddAttribute(A);
}
return A;
return SetAttr(label, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_RealList) TDataStd_RealList::Set(const TDF_Label& label,
const Standard_GUID& theGuid)
{
return SetAttr(label, theGuid);
}
//=======================================================================
@@ -101,7 +122,7 @@ void TDataStd_RealList::Append(const Standard_Real value)
//purpose :
//=======================================================================
Standard_Boolean TDataStd_RealList::InsertBefore(const Standard_Real value,
const Standard_Real before_value)
const Standard_Real before_value)
{
TColStd_ListIteratorOfListOfReal itr(myList);
for (; itr.More(); itr.Next())
@@ -142,7 +163,7 @@ Standard_Boolean TDataStd_RealList::InsertBeforeByIndex (const Standard_Integer
//purpose :
//=======================================================================
Standard_Boolean TDataStd_RealList::InsertAfter(const Standard_Real value,
const Standard_Real after_value)
const Standard_Real after_value)
{
TColStd_ListIteratorOfListOfReal itr(myList);
for (; itr.More(); itr.Next())
@@ -262,7 +283,28 @@ const TColStd_ListOfReal& TDataStd_RealList::List() const
//=======================================================================
const Standard_GUID& TDataStd_RealList::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_RealList::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_RealList::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -287,6 +329,7 @@ void TDataStd_RealList::Restore(const Handle(TDF_Attribute)& With)
{
myList.Append(itr.Value());
}
myID = aList->ID();
}
//=======================================================================
@@ -294,7 +337,7 @@ void TDataStd_RealList::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_RealList::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& ) const
const Handle(TDF_RelocationTable)& ) const
{
Handle(TDataStd_RealList) aList = Handle(TDataStd_RealList)::DownCast(Into);
aList->Clear();
@@ -303,6 +346,7 @@ void TDataStd_RealList::Paste (const Handle(TDF_Attribute)& Into,
{
aList->Append(itr.Value());
}
aList->SetID(myID);
}
//=======================================================================
@@ -311,6 +355,10 @@ void TDataStd_RealList::Paste (const Handle(TDF_Attribute)& Into,
//=======================================================================
Standard_OStream& TDataStd_RealList::Dump (Standard_OStream& anOS) const
{
anOS << "RealList";
anOS << "\nRealList: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -25,6 +25,8 @@
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -48,7 +50,10 @@ public:
//! Finds or creates a list of double values attribute.
Standard_EXPORT static Handle(TDataStd_RealList) Set (const TDF_Label& label);
//! Finds or creates a list of double values attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_RealList) Set (const TDF_Label& label, const Standard_GUID& theGuid);
Standard_EXPORT TDataStd_RealList();
Standard_EXPORT Standard_Boolean IsEmpty() const;
@@ -58,7 +63,13 @@ public:
Standard_EXPORT void Prepend (const Standard_Real value);
Standard_EXPORT void Append (const Standard_Real value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Real value, const Standard_Real before_value);
@@ -111,7 +122,7 @@ private:
TColStd_ListOfReal myList;
Standard_GUID myID;
};

View File

@@ -34,6 +34,30 @@ const Standard_GUID& TDataStd_ReferenceArray::GetID()
return TDataStd_ReferenceArrayID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_ReferenceArray) SetAttr(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper,
const Standard_GUID& theGuid)
{
Handle(TDataStd_ReferenceArray) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_ReferenceArray;
A->Init (lower, upper);
A->SetID(theGuid);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
}
//=======================================================================
//function : TDataStd_ReferenceArray
//purpose : Empty Constructor
@@ -48,7 +72,7 @@ TDataStd_ReferenceArray::TDataStd_ReferenceArray()
//purpose :
//=======================================================================
void TDataStd_ReferenceArray::Init(const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer upper)
{
Standard_RangeError_Raise_if(upper < lower,"TDataStd_ReferenceArray::Init");
Backup();
@@ -60,29 +84,30 @@ void TDataStd_ReferenceArray::Init(const Standard_Integer lower,
//purpose :
//=======================================================================
Handle(TDataStd_ReferenceArray) TDataStd_ReferenceArray::Set(const TDF_Label& label,
const Standard_Integer lower,
const Standard_Integer upper)
const Standard_Integer lower,
const Standard_Integer upper)
{
Handle(TDataStd_ReferenceArray) A;
if (!label.FindAttribute (TDataStd_ReferenceArray::GetID(), A))
{
A = new TDataStd_ReferenceArray;
A->Init (lower, upper);
label.AddAttribute(A);
}
else if (lower != A->Lower() || upper != A->Upper())
{
A->Init(lower, upper);
}
return A;
return SetAttr(label, lower, upper, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_ReferenceArray) TDataStd_ReferenceArray::Set(const TDF_Label& label,
const Standard_GUID& theGuid,
const Standard_Integer lower,
const Standard_Integer upper)
{
return SetAttr(label, lower, upper, theGuid);
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void TDataStd_ReferenceArray::SetValue (const Standard_Integer index,
const TDF_Label& value)
const TDF_Label& value)
{
if(myArray.IsNull()) return;
if (value == myArray->Value(index))
@@ -162,13 +187,13 @@ void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArra
Standard_Boolean isEqual = Standard_True;
if(isCheckItems) {
for(i = aLower; i <= anUpper; i++) {
if(myArray->Value(i) != values->Value(i)) {
isEqual = Standard_False;
break;
}
if(myArray->Value(i) != values->Value(i)) {
isEqual = Standard_False;
break;
}
}
if(isEqual)
return;
return;
}
}
#endif
@@ -188,7 +213,30 @@ void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArra
//=======================================================================
const Standard_GUID& TDataStd_ReferenceArray::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_ReferenceArray::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_ReferenceArray::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -216,6 +264,7 @@ void TDataStd_ReferenceArray::Restore(const Handle(TDF_Attribute)& With)
{
myArray->SetValue(i, arr.Value(i));
}
myID = anArray->ID();
}
else
{
@@ -228,7 +277,7 @@ void TDataStd_ReferenceArray::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_ReferenceArray::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& RT) const
const Handle(TDF_RelocationTable)& RT) const
{
Handle(TDataStd_ReferenceArray) anArray = Handle(TDataStd_ReferenceArray)::DownCast(Into);
if (myArray.IsNull())
@@ -246,10 +295,11 @@ void TDataStd_ReferenceArray::Paste (const Handle(TDF_Attribute)& Into,
if (!L.IsNull())
{
if (!RT->HasRelocation(L, rL))
rL = L;
rL = L;
anArray->myArray->SetValue(i, rL);
}
}
anArray->SetID(myID);
}
//=======================================================================
@@ -265,7 +315,7 @@ void TDataStd_ReferenceArray::References(const Handle(TDF_DataSet)& aDataSet) co
for (; i <= upper; i++)
{
if (!arr.Value(i).IsNull())
aDataSet->AddLabel(arr.Value(i));
aDataSet->AddLabel(arr.Value(i));
}
}
}
@@ -276,6 +326,9 @@ void TDataStd_ReferenceArray::References(const Handle(TDF_DataSet)& aDataSet) co
//=======================================================================
Standard_OStream& TDataStd_ReferenceArray::Dump (Standard_OStream& anOS) const
{
anOS << "ReferenceArray";
anOS << "\nReferenceArray: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid << endl;
return anOS;
}

View File

@@ -25,6 +25,8 @@
#include <TDF_Label.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -49,6 +51,10 @@ public:
//! Finds or creates an array of reference values (labels) attribute.
Standard_EXPORT static Handle(TDataStd_ReferenceArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper);
//! Finds or creates an array of reference values (labels) attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_ReferenceArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
const Standard_Integer lower, const Standard_Integer upper);
//! Initialize the inner array with bounds from <lower> to <upper>
Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
@@ -56,13 +62,20 @@ public:
//! Sets the <Index>th element of the array to <Value>
//! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
Standard_EXPORT void SetValue (const Standard_Integer index, const TDF_Label& value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the value of the <Index>th element of the array.
Standard_EXPORT TDF_Label Value (const Standard_Integer Index) const;
TDF_Label operator () (const Standard_Integer Index) const
{
return Value(Index);
}
TDF_Label operator () (const Standard_Integer Index) const
{
return Value(Index);
}
//! Returns the lower boundary of the array.
Standard_EXPORT Standard_Integer Lower() const;
@@ -105,7 +118,7 @@ private:
Handle(TDataStd_HLabelArray1) myArray;
Standard_GUID myID;
};

View File

@@ -35,6 +35,23 @@ const Standard_GUID& TDataStd_ReferenceList::GetID()
return TDataStd_ReferenceListID;
}
//=======================================================================
//function : SetAttr
//purpose : Implements Set functionality
//=======================================================================
static Handle(TDataStd_ReferenceList) SetAttr(const TDF_Label& label,
const Standard_GUID& theGuid)
{
Handle(TDataStd_ReferenceList) A;
if (!label.FindAttribute (theGuid, A))
{
A = new TDataStd_ReferenceList;
A->SetID(theGuid);
label.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataStd_ReferenceList
//purpose : Empty Constructor
@@ -50,13 +67,17 @@ TDataStd_ReferenceList::TDataStd_ReferenceList()
//=======================================================================
Handle(TDataStd_ReferenceList) TDataStd_ReferenceList::Set(const TDF_Label& label)
{
Handle(TDataStd_ReferenceList) A;
if (!label.FindAttribute (TDataStd_ReferenceList::GetID(), A))
{
A = new TDataStd_ReferenceList;
label.AddAttribute(A);
}
return A;
return SetAttr(label, GetID());
}
//=======================================================================
//function : Set
//purpose : Set user defined attribute with specific ID
//=======================================================================
Handle(TDataStd_ReferenceList) TDataStd_ReferenceList::Set(const TDF_Label& label,
const Standard_GUID& theGuid)
{
return SetAttr(label, theGuid);
}
//=======================================================================
@@ -102,7 +123,7 @@ void TDataStd_ReferenceList::Append(const TDF_Label& value)
//purpose :
//=======================================================================
Standard_Boolean TDataStd_ReferenceList::InsertBefore(const TDF_Label& value,
const TDF_Label& before_value)
const TDF_Label& before_value)
{
TDF_ListIteratorOfLabelList itr(myList);
for (; itr.More(); itr.Next())
@@ -143,7 +164,7 @@ Standard_Boolean TDataStd_ReferenceList::InsertBefore (const Standard_Integer in
//purpose :
//=======================================================================
Standard_Boolean TDataStd_ReferenceList::InsertAfter(const TDF_Label& value,
const TDF_Label& after_value)
const TDF_Label& after_value)
{
TDF_ListIteratorOfLabelList itr(myList);
for (; itr.More(); itr.Next())
@@ -263,7 +284,28 @@ const TDF_LabelList& TDataStd_ReferenceList::List() const
//=======================================================================
const Standard_GUID& TDataStd_ReferenceList::ID () const
{
return GetID();
return myID;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_ReferenceList::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_ReferenceList::SetID()
{
Backup();
myID = GetID();
}
//=======================================================================
@@ -271,7 +313,7 @@ const Standard_GUID& TDataStd_ReferenceList::ID () const
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_ReferenceList::NewEmpty () const
{
{
return new TDataStd_ReferenceList();
}
@@ -288,6 +330,7 @@ void TDataStd_ReferenceList::Restore(const Handle(TDF_Attribute)& With)
{
myList.Append(itr.Value());
}
myID = aList->ID();
}
//=======================================================================
@@ -295,7 +338,7 @@ void TDataStd_ReferenceList::Restore(const Handle(TDF_Attribute)& With)
//purpose :
//=======================================================================
void TDataStd_ReferenceList::Paste (const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& RT) const
const Handle(TDF_RelocationTable)& RT) const
{
Handle(TDataStd_ReferenceList) aList = Handle(TDataStd_ReferenceList)::DownCast(Into);
aList->Clear();
@@ -306,10 +349,11 @@ void TDataStd_ReferenceList::Paste (const Handle(TDF_Attribute)& Into,
if (!L.IsNull())
{
if (!RT->HasRelocation(L, rL))
rL = L;
rL = L;
aList->Append(rL);
}
}
aList->SetID(myID);
}
//=======================================================================
@@ -334,6 +378,10 @@ void TDataStd_ReferenceList::References(const Handle(TDF_DataSet)& aDataSet) con
//=======================================================================
Standard_OStream& TDataStd_ReferenceList::Dump (Standard_OStream& anOS) const
{
anOS << "ReferenceList";
anOS << "\nReferenceList: ";
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
myID.ToCString(sguid);
anOS << sguid;
anOS << endl;
return anOS;
}

View File

@@ -24,6 +24,8 @@
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
@@ -48,6 +50,9 @@ public:
//! Finds or creates a list of reference values (labels) attribute.
Standard_EXPORT static Handle(TDataStd_ReferenceList) Set (const TDF_Label& label);
//! Finds or creates a list of reference values (labels) attribute with explicit user defined <guid>.
Standard_EXPORT static Handle(TDataStd_ReferenceList) Set (const TDF_Label& label, const Standard_GUID& theGuid);
Standard_EXPORT TDataStd_ReferenceList();
@@ -58,7 +63,13 @@ public:
Standard_EXPORT void Prepend (const TDF_Label& value);
Standard_EXPORT void Append (const TDF_Label& value);
//! Sets the explicit GUID (user defined) for the attribute.
Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const TDF_Label& value, const TDF_Label& before_value);
@@ -113,7 +124,7 @@ private:
TDF_LabelList myList;
Standard_GUID myID;
};

View File

@@ -50,7 +50,7 @@ public:
Standard_EXPORT TDataStd_UAttribute();
Standard_EXPORT void SetID (const Standard_GUID& LocalID);
Standard_EXPORT void SetID (const Standard_GUID& LocalID) Standard_OVERRIDE;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;