1 // File : SALOMEDSImpl_AttributeSequenceOfReal.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDSImpl_AttributeSequenceOfReal.hxx"
6 #include <Standard_GUID.hxx>
10 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfReal, SALOMEDSImpl_GenericAttribute )
11 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeSequenceOfReal, SALOMEDSImpl_GenericAttribute )
13 //=======================================================================
16 //=======================================================================
18 const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfReal::GetID ()
20 static Standard_GUID SALOMEDSImpl_AttributeSequenceOfRealID ("12837183-8F52-11d6-A8A3-0001021E8C7F");
21 return SALOMEDSImpl_AttributeSequenceOfRealID;
26 //=======================================================================
29 //=======================================================================
31 Handle(SALOMEDSImpl_AttributeSequenceOfReal) SALOMEDSImpl_AttributeSequenceOfReal::Set (const TDF_Label& L)
33 Handle(SALOMEDSImpl_AttributeSequenceOfReal) A;
34 if (!L.FindAttribute(SALOMEDSImpl_AttributeSequenceOfReal::GetID(),A)) {
35 A = new SALOMEDSImpl_AttributeSequenceOfReal();
42 //=======================================================================
43 //function : constructor
45 //=======================================================================
46 SALOMEDSImpl_AttributeSequenceOfReal::SALOMEDSImpl_AttributeSequenceOfReal()
47 :SALOMEDSImpl_GenericAttribute("AttributeSequenceOfReal")
49 myValue = new TColStd_HSequenceOfReal();
52 //=======================================================================
55 //=======================================================================
57 const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfReal::ID () const { return GetID(); }
60 //=======================================================================
63 //=======================================================================
65 Handle(TDF_Attribute) SALOMEDSImpl_AttributeSequenceOfReal::NewEmpty () const
67 return new SALOMEDSImpl_AttributeSequenceOfReal();
70 //=======================================================================
73 //=======================================================================
75 void SALOMEDSImpl_AttributeSequenceOfReal::Restore(const Handle(TDF_Attribute)& with)
78 Handle(SALOMEDSImpl_AttributeSequenceOfReal) anSeq = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(with);
79 if(!anSeq->myValue.IsNull()) {
80 myValue = new TColStd_HSequenceOfReal();
81 Standard_Integer Len = anSeq->Length();
82 for(i = 1; i<=Len; i++) Add(anSeq->Value(i));
89 //=======================================================================
92 //=======================================================================
94 void SALOMEDSImpl_AttributeSequenceOfReal::Paste (const Handle(TDF_Attribute)& into,
95 const Handle(TDF_RelocationTable)& ) const
97 if(!myValue.IsNull()) {
98 Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast (into)->Assign(myValue);
102 void SALOMEDSImpl_AttributeSequenceOfReal::Assign(const Handle(TColStd_HSequenceOfReal)& other)
106 if (myValue.IsNull()) myValue = new TColStd_HSequenceOfReal;
107 myValue->ChangeSequence() = other->Sequence();
109 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
112 void SALOMEDSImpl_AttributeSequenceOfReal::ChangeValue(const Standard_Integer Index,const Standard_Real Value)
116 myValue->SetValue(Index, Value);
118 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
121 void SALOMEDSImpl_AttributeSequenceOfReal::Add(const Standard_Real Value)
125 myValue->Append(Value);
127 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
130 void SALOMEDSImpl_AttributeSequenceOfReal::Remove(const Standard_Integer Index)
134 myValue->Remove(Index);
136 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
139 Standard_Integer SALOMEDSImpl_AttributeSequenceOfReal::Length()
141 return myValue->Length();
144 Standard_Real SALOMEDSImpl_AttributeSequenceOfReal::Value(const Standard_Integer Index)
146 return myValue->Value(Index);
150 TCollection_AsciiString SALOMEDSImpl_AttributeSequenceOfReal::Save()
152 Standard_Integer aLength = Length();
153 char* aResult = new char[aLength * 25];
155 Standard_Integer aPosition = 0;
156 for (int i = 1; i <= aLength; i++) {
157 sprintf(aResult + aPosition , "%f ", Value(i));
158 aPosition += strlen(aResult + aPosition);
160 TCollection_AsciiString ret(aResult);
166 void SALOMEDSImpl_AttributeSequenceOfReal::Load(const TCollection_AsciiString& value)
168 Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
170 char* aCopy = value.ToCString();
171 char* adr = strtok(aCopy, " ");
174 Standard_Real r = strtod(adr, &err);
175 CasCadeSeq->Append(r);
176 adr = strtok(NULL, " ");