mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027932: Improvement of standard attributes usability.
OCAF attributes TDataStd_AsciiString, TDataStd_Integer, TDataStd_Name, TDataStd_Real are extended by possibility to use custom GUID. Now multiple attributes of any of these types can be placed at the same label using different user-defined GUIDs. For this new "Set" methods were added into each attribute, which takes this custom GUID as an argument. Other aspects of management of attributes on labels remain the same. Version number of persistent OCAF documents is incremented. However, the attributes are stored in the same way unless non-standard GUID is used for particular attribute. Previously saved documents are fully supported, but the new documents with this extension used will be non-readable by the previous version of OCAF libraries.
This commit is contained in:
@@ -51,7 +51,7 @@ const Standard_GUID& TDataStd_AsciiString::GetID()
|
||||
|
||||
const Standard_GUID& TDataStd_AsciiString::ID() const
|
||||
{
|
||||
return GetID();
|
||||
return myID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -67,12 +67,30 @@ Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
|
||||
if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
|
||||
{
|
||||
A = new TDataStd_AsciiString;
|
||||
A->SetID(GetID());
|
||||
theLabel.AddAttribute(A);
|
||||
}
|
||||
A->Set(theAsciiString);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const TCollection_AsciiString& theAsciiString)
|
||||
{
|
||||
Handle(TDataStd_AsciiString) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_AsciiString ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (theAsciiString);
|
||||
return A;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
@@ -80,6 +98,7 @@ Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
|
||||
|
||||
void TDataStd_AsciiString::Set (const TCollection_AsciiString& theAsciiString)
|
||||
{
|
||||
if(myString == theAsciiString) return;
|
||||
Backup();
|
||||
myString = theAsciiString;
|
||||
}
|
||||
@@ -94,6 +113,19 @@ const TCollection_AsciiString& TDataStd_AsciiString::Get () const
|
||||
return myString;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_AsciiString::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@@ -101,7 +133,9 @@ const TCollection_AsciiString& TDataStd_AsciiString::Get () const
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_AsciiString();
|
||||
Handle(TDataStd_AsciiString) Att = new TDataStd_AsciiString();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -113,6 +147,7 @@ void TDataStd_AsciiString::Restore (const Handle(TDF_Attribute)& theWith)
|
||||
{
|
||||
Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast(theWith);
|
||||
myString = R->Get();
|
||||
myID = R->ID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -125,6 +160,7 @@ void TDataStd_AsciiString::Paste (const Handle(TDF_Attribute)& theInto,
|
||||
{
|
||||
Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast (theInto);
|
||||
R->Set(myString);
|
||||
R->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -144,5 +180,9 @@ Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const
|
||||
{
|
||||
Standard_OStream& anOS = TDF_Attribute::Dump( theOS );
|
||||
anOS << myString;
|
||||
anOS << " Name=|"<<myString<<"|";
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid << "|" <<endl;
|
||||
return anOS;
|
||||
}
|
||||
|
@@ -23,7 +23,8 @@
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_GUID;
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class TDF_Label;
|
||||
class TCollection_AsciiString;
|
||||
class TDF_Attribute;
|
||||
@@ -50,11 +51,19 @@ public:
|
||||
//! AsciiString methods
|
||||
//! ===================
|
||||
Standard_EXPORT static Handle(TDataStd_AsciiString) Set (const TDF_Label& label, const TCollection_AsciiString& string);
|
||||
|
||||
|
||||
//! Finds, or creates, an AsciiString attribute with explicit user defined <guid> and sets <string>.
|
||||
//! The Name attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_AsciiString) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const TCollection_AsciiString& string);
|
||||
|
||||
Standard_EXPORT TDataStd_AsciiString();
|
||||
|
||||
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 const TCollection_AsciiString& Get() const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsEmpty() const;
|
||||
@@ -83,7 +92,7 @@ private:
|
||||
|
||||
|
||||
TCollection_AsciiString myString;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -48,12 +48,30 @@ Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L,
|
||||
Handle(TDataStd_Integer) A;
|
||||
if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) {
|
||||
A = new TDataStd_Integer ();
|
||||
A->SetID(GetID());
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const Standard_Integer V)
|
||||
{
|
||||
Handle(TDataStd_Integer) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_Integer ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : TDataStd_Integer
|
||||
//purpose : Empty Constructor
|
||||
@@ -103,9 +121,20 @@ Standard_Boolean TDataStd_Integer::IsCaptured() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); }
|
||||
const Standard_GUID& TDataStd_Integer::ID () const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Integer::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@@ -113,7 +142,9 @@ const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Integer ();
|
||||
Handle(TDataStd_Integer) Att = new TDataStd_Integer();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -123,7 +154,9 @@ Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
|
||||
|
||||
void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myValue = Handle(TDataStd_Integer)::DownCast (With)->Get();
|
||||
Handle(TDataStd_Integer) anInt = Handle(TDataStd_Integer)::DownCast (With);
|
||||
myValue = anInt->Get();
|
||||
myID = anInt->ID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -134,7 +167,9 @@ void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With)
|
||||
void TDataStd_Integer::Paste (const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
Handle(TDataStd_Integer)::DownCast(Into)->Set(myValue);
|
||||
Handle(TDataStd_Integer) anInt = Handle(TDataStd_Integer)::DownCast (Into);
|
||||
anInt->Set(myValue);
|
||||
anInt->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -146,6 +181,9 @@ Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Integer:: "<< this <<" : ";
|
||||
anOS << myValue;
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid;
|
||||
//
|
||||
anOS <<"\nAttribute fields: ";
|
||||
TDF_Attribute::Dump(anOS);
|
||||
|
@@ -24,6 +24,8 @@
|
||||
#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;
|
||||
@@ -47,12 +49,20 @@ public:
|
||||
|
||||
//! Finds, or creates, an Integer attribute and sets <value>
|
||||
//! the Integer attribute is returned.
|
||||
//! Integer methods
|
||||
//! ===============
|
||||
Standard_EXPORT static Handle(TDataStd_Integer) Set (const TDF_Label& label, const Standard_Integer value);
|
||||
|
||||
//! Finds, or creates, an Integer attribute with explicit user defined <guid> and sets <value>.
|
||||
//! The Integer attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_Integer) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const Standard_Integer value);
|
||||
|
||||
//! Integer methods
|
||||
//! ===============
|
||||
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);
|
||||
|
||||
//! Returns the integer value contained in the attribute.
|
||||
Standard_EXPORT Standard_Integer Get() const;
|
||||
|
||||
@@ -85,7 +95,7 @@ private:
|
||||
|
||||
|
||||
Standard_Integer myValue;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -50,7 +50,8 @@ Handle(TDataStd_Name) TDataStd_Name::Set
|
||||
{
|
||||
Handle(TDataStd_Name) N;
|
||||
if (!label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
N = new TDataStd_Name ();
|
||||
N = new TDataStd_Name ();
|
||||
N->SetID(GetID());
|
||||
label.AddAttribute(N);
|
||||
}
|
||||
N->Set(theString);
|
||||
@@ -58,68 +59,22 @@ Handle(TDataStd_Name) TDataStd_Name::Set
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Find
|
||||
//purpose :
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDF_Label& label, Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
// if (label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// name = N;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// TDF_Label L = label;
|
||||
// while (!L.IsRoot()) {
|
||||
// L = L.Father();
|
||||
// if (L.FindAttribute (TDataStd_Name::GetID(), N)) {
|
||||
// name = N;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : IsNamed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::IsNamed(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// return label.FindAttribute(TDataStd_Name::GetID(), N);
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::IsEmpty(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
// if(label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// return N->IsEmpty();
|
||||
// }
|
||||
|
||||
// Standard_DomainError::Raise("There isn't the Name Attribute on the label");
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Erase
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// void TDataStd_Name::Erase(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// if(label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// N->SetEmpty();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Standard_DomainError::Raise("There isn't the Name Attribute on the label");
|
||||
// }
|
||||
|
||||
Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const TCollection_ExtendedString& theString)
|
||||
{
|
||||
Handle(TDataStd_Name) N;
|
||||
if (!L.FindAttribute(theGuid, N)) {
|
||||
N = new TDataStd_Name ();
|
||||
N->SetID(theGuid);
|
||||
L.AddAttribute(N);
|
||||
}
|
||||
N->Set (theString);
|
||||
return N;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : TDataStd_Name
|
||||
//purpose : Empty Constructor
|
||||
@@ -150,15 +105,26 @@ const TCollection_ExtendedString& TDataStd_Name::Get () const
|
||||
return myString;
|
||||
}
|
||||
|
||||
// TDF_Attribute methods
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Name::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
|
||||
// TDF_Attribute methods
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Name::ID () const { return GetID(); }
|
||||
|
||||
const Standard_GUID& TDataStd_Name::ID () const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
@@ -167,7 +133,9 @@ const Standard_GUID& TDataStd_Name::ID () const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Name();
|
||||
Handle(TDataStd_Name) Att = new TDataStd_Name();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -177,7 +145,9 @@ Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
|
||||
|
||||
void TDataStd_Name::Restore(const Handle(TDF_Attribute)& with)
|
||||
{
|
||||
myString = Handle(TDataStd_Name)::DownCast (with)->Get();
|
||||
Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (with);
|
||||
myString = anAtt->Get();
|
||||
myID = anAtt->ID();
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +159,9 @@ void TDataStd_Name::Restore(const Handle(TDF_Attribute)& with)
|
||||
void TDataStd_Name::Paste (const Handle(TDF_Attribute)& into,
|
||||
const Handle(TDF_RelocationTable)&/* RT*/) const
|
||||
{
|
||||
Handle(TDataStd_Name)::DownCast (into)->Set (myString);
|
||||
Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (into);
|
||||
anAtt->Set (myString);
|
||||
anAtt->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -200,258 +172,9 @@ void TDataStd_Name::Paste (const Handle(TDF_Attribute)& into,
|
||||
Standard_OStream& TDataStd_Name::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
TDF_Attribute::Dump(anOS);
|
||||
anOS << " Name=|"<<myString<<"|"<<endl;
|
||||
anOS << " Name=|"<<myString<<"|";
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid << endl;
|
||||
return anOS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the full path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const Handle(TDF_Data)& framework,
|
||||
// const TDataStd_ListOfExtendedString& fullPath,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_Label L, root = framework->Root();
|
||||
// TDF_ChildIterator ChItr (root, Standard_True);
|
||||
// TCollection_ExtendedString string, first = fullPath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// Standard_Boolean IsRootVisited = Standard_False;
|
||||
|
||||
// tmpPath.Assign(fullPath);
|
||||
// if(tmpPath.Extent() > 0 ) tmpPath.RemoveFirst();
|
||||
|
||||
// while( ChItr.More() ) {
|
||||
// if( !IsRootVisited ) L = root; //For the fisrt time visit the root label
|
||||
// else L = ChItr.Value();
|
||||
|
||||
// if( L.FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( fullPath.Extent() == 1 ) {
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// if (Ncurrent->Find(tmpPath, name) ) return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if( !Ncurrent->IsEmpty() ) {
|
||||
// //The root contains String different from first name in the path
|
||||
// if( !IsRootVisited ) return Standard_False;
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if( !IsRootVisited ) {
|
||||
// IsRootVisited = Standard_True;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// ChItr.Next();
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDF_Label& currentLabel,
|
||||
// const TDataStd_ListOfExtendedString& relativePath,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_ChildIterator ChItr (currentLabel, Standard_True);
|
||||
// TCollection_ExtendedString string, first = relativePath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// tmpPath.Assign(relativePath);
|
||||
|
||||
// if( !currentLabel.FindAttribute(TDataStd_Name::GetID(), Ncurrent) )
|
||||
// Standard_DomainError::Raise("There isn't the Name attribute on the label");
|
||||
|
||||
|
||||
// while( ChItr.More() ) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( relativePath.Extent() == 1 ) { //it has reached the end of the relative path
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if (tmpPath.Extent() > 0) tmpPath.RemoveFirst();
|
||||
// if (Find(ChItr.Value(), tmpPath, Ncurrent)) return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if( !Ncurrent->IsEmpty() ) {
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ChItr.Next();
|
||||
// }
|
||||
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find(const TDF_Label& currentLabel,
|
||||
// const TCollection_ExtendedString& string,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// TDataStd_Name::MakePath(string, tmpPath,':');
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// if (TDataStd_Name::Find(currentLabel,Ncurrent)) {
|
||||
// return Ncurrent->Find(tmpPath, name);
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the full path)
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find(const Handle(TDF_Data)& framework,
|
||||
// const TCollection_ExtendedString& string,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// TDataStd_Name::MakePath(string, tmpPath,':');
|
||||
// return Find(framework, tmpPath, name);
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : FullPath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::FullPath (TDF_AttributeList& path) const
|
||||
// {
|
||||
// path.Clear();
|
||||
// if( !IsEmpty() ) path.Append(this);
|
||||
// TDF_Label L = Label();
|
||||
// if(L.IsRoot() ) return Standard_True;
|
||||
// Handle(TDataStd_Name) Ncur;
|
||||
// while ( !L.IsRoot()) {
|
||||
// L = L.Father();
|
||||
// if(L.FindAttribute (TDataStd_Name::GetID(), Ncur)) {
|
||||
// if( !Ncur->IsEmpty() )path.Prepend(Ncur);
|
||||
// }
|
||||
// }
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : MakePath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::MakePath(const TCollection_ExtendedString& path,
|
||||
// TDataStd_ListOfExtendedString& pathlist,
|
||||
// const Standard_ExtCharacter Separator)
|
||||
// {
|
||||
// TCollection_ExtendedString tmpPath = path, str;
|
||||
|
||||
// str+=Separator; str+=Separator;
|
||||
// if( tmpPath.Search(str) != -1 ) return Standard_False; //Not valid path (contains two adjacent separators)
|
||||
|
||||
// if( tmpPath.Search(Separator) == -1 ) { //The path contains only one name.
|
||||
// pathlist.Append(path);
|
||||
// return Standard_True;
|
||||
// }
|
||||
// Standard_Integer i;
|
||||
// while( (i = tmpPath.SearchFromEnd(Separator) ) != -1 ) {
|
||||
// str = tmpPath.Split(i-1);
|
||||
// str.Remove(1);
|
||||
// pathlist.Prepend(str);
|
||||
// }
|
||||
// if( tmpPath.Length() > 0 ) pathlist.Prepend(tmpPath);
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MakePath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::MakePath(const TDF_AttributeList& pathlist,
|
||||
// TCollection_ExtendedString& path,
|
||||
// const Standard_ExtCharacter Separator)
|
||||
// {
|
||||
// TDF_ListIteratorOfAttributeList Itr(pathlist);
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// if( pathlist.Extent() == 0 ) return Standard_False;
|
||||
// path.Clear();
|
||||
// for(; Itr.More(); Itr.Next() ) {
|
||||
// N = Handle(TDataStd_Name)::DownCast(Itr.Value());
|
||||
// path = path + N->Get();
|
||||
// path = path + Separator;
|
||||
// }
|
||||
// path.Remove(path.Length(), 1);
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDataStd_ListOfExtendedString& relativePath,
|
||||
// Handle(TDataStd_Name)& name) const
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_ChildIterator ChItr (Label(), Standard_True);
|
||||
// TCollection_ExtendedString string, first = relativePath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// tmpPath.Assign(relativePath);
|
||||
// //
|
||||
// while( ChItr.More() ) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( relativePath.Extent() == 1 ) { //it has reached the end of the relative path
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if (tmpPath.Extent() > 0) tmpPath.RemoveFirst();
|
||||
// if (Ncurrent->Find(tmpPath, name)) return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (!Ncurrent->IsEmpty()) {
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ChItr.Next();
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : ChildNames
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::ChildNames (TDF_AttributeList& list) const
|
||||
// {
|
||||
// Standard_Boolean found = Standard_False;
|
||||
// TDF_ChildIterator ChItr (Label(), Standard_True);
|
||||
// Handle(TDataStd_Name) N;
|
||||
// list.Clear();
|
||||
// for(; ChItr.More(); ChItr.Next()) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), N) ) {
|
||||
// list.Append(N);
|
||||
// found = Standard_True;
|
||||
// cout << N->Get() << endl;
|
||||
// }
|
||||
// }
|
||||
// return found;
|
||||
// }
|
||||
|
@@ -23,8 +23,9 @@
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class Standard_DomainError;
|
||||
class Standard_GUID;
|
||||
class TDF_Label;
|
||||
class TCollection_ExtendedString;
|
||||
class TDF_Attribute;
|
||||
@@ -69,12 +70,18 @@ public:
|
||||
//! Name methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const TCollection_ExtendedString& string);
|
||||
|
||||
|
||||
//! Finds, or creates, a Name attribute with explicit user defined <guid> and sets <string>.
|
||||
//! The Name attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const TCollection_ExtendedString& string);
|
||||
Standard_EXPORT TDataStd_Name();
|
||||
|
||||
//! Sets <S> as name. Raises if <S> is not a valid name.
|
||||
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);
|
||||
|
||||
//! Returns the name contained in this name attribute.
|
||||
Standard_EXPORT const TCollection_ExtendedString& Get() const;
|
||||
@@ -103,7 +110,7 @@ private:
|
||||
|
||||
|
||||
TCollection_ExtendedString myString;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -48,12 +48,30 @@ Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
|
||||
Handle(TDataStd_Real) A;
|
||||
if (!L.FindAttribute(TDataStd_Real::GetID(), A)) {
|
||||
A = new TDataStd_Real ();
|
||||
A->SetID(GetID());
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : User defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const Standard_Real V)
|
||||
{
|
||||
Handle(TDataStd_Real) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_Real ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TDataStd_Real
|
||||
@@ -78,8 +96,9 @@ Standard_Boolean TDataStd_Real::IsCaptured() const
|
||||
// pour test
|
||||
|
||||
if (Label().FindAttribute(TDF_Reference::GetID(),reference)) {
|
||||
const TDF_Label& label = reference->Get();
|
||||
return label.IsAttribute (TDataStd_Real::GetID());
|
||||
const TDF_Label& aLabel = reference->Get();
|
||||
return aLabel.IsAttribute (myID);
|
||||
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -138,9 +157,20 @@ TDataStd_RealEnum TDataStd_Real::GetDimension () const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Real::ID() const { return GetID(); }
|
||||
const Standard_GUID& TDataStd_Real::ID() const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Real::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@@ -148,7 +178,9 @@ const Standard_GUID& TDataStd_Real::ID() const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Real();
|
||||
Handle(TDataStd_Real) Att = new TDataStd_Real();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -161,6 +193,7 @@ void TDataStd_Real::Restore(const Handle(TDF_Attribute)& With)
|
||||
Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (With);
|
||||
myValue = R->Get();
|
||||
myDimension = R->GetDimension();
|
||||
myID = R->ID();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,6 +209,7 @@ void TDataStd_Real::Paste (const Handle(TDF_Attribute)& Into,
|
||||
Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (Into);
|
||||
R->Set(myValue);
|
||||
R->SetDimension(myDimension);
|
||||
R->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -187,6 +221,10 @@ Standard_OStream& TDataStd_Real::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Real ";
|
||||
TDataStd::Print(GetDimension(),anOS);
|
||||
anOS << myValue;
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid;
|
||||
return anOS;
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,8 @@
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_GUID;
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class TDF_Label;
|
||||
class TDF_Attribute;
|
||||
class TDF_RelocationTable;
|
||||
@@ -43,16 +44,23 @@ public:
|
||||
|
||||
//! class methods
|
||||
//! =============
|
||||
//! Returns the GUID for real numbers.
|
||||
//! Returns the default GUID for real numbers.
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Finds, or creates, an Real attribute and sets <value> the
|
||||
//! Real attribute is returned. the Real dimension is
|
||||
//! Scalar by default. use SetDimension to overwrite.
|
||||
//! Finds, or creates, a Real attribute with default GUID and sets <value>.
|
||||
//! The Real attribute is returned. The Real dimension is Scalar by default.
|
||||
//! Use SetDimension to overwrite.
|
||||
//! Real methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Real) Set (const TDF_Label& label, const Standard_Real value);
|
||||
|
||||
//! Finds, or creates, a Real attribute with explicit GUID and sets <value>.
|
||||
//! The Real attribute is returned.
|
||||
//! Real methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Real) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const Standard_Real value);
|
||||
|
||||
Standard_EXPORT TDataStd_Real();
|
||||
|
||||
Standard_EXPORT void SetDimension (const TDataStd_RealEnum DIM);
|
||||
@@ -60,9 +68,11 @@ public:
|
||||
Standard_EXPORT TDataStd_RealEnum GetDimension() const;
|
||||
|
||||
|
||||
//! Finds or creates the real number V.
|
||||
//! Sets the real number V.
|
||||
Standard_EXPORT void Set (const Standard_Real V);
|
||||
|
||||
//! Sets the explicit GUID for the attribute.
|
||||
Standard_EXPORT void SetID (const Standard_GUID& guid);
|
||||
|
||||
//! Returns the real number value contained in the attribute.
|
||||
Standard_EXPORT Standard_Real Get() const;
|
||||
@@ -95,7 +105,7 @@ private:
|
||||
|
||||
Standard_Real myValue;
|
||||
TDataStd_RealEnum myDimension;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user