#include <HYDROData_Object.h>
#include <TDataStd_Name.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_BooleanArray.hxx>
+#include <TDataStd_RealArray.hxx>
#include <TDF_CopyLabel.hxx>
+#include <QString>
+#include <QStringList>
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared)
TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
}
+QStringList HYDROData_Object::DumpToPython() const
+{
+ QStringList anEmptyList;
+ return anEmptyList;
+}
+
bool HYDROData_Object::IsRemoved() const
{
return !myLab.HasAttribute();
{
myLab = theLabel;
}
+
+void HYDROData_Object::SaveByteArray(const int theTag,
+ const char* theData, const int theLen)
+{
+ TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
+ // array is empty, remove the attribute
+ if (theLen <= 0) {
+ aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
+ return;
+ }
+ // store data of image in byte array
+ Handle(TDataStd_ByteArray) aData;
+ if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
+ aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
+ }
+ // copy bytes one by one
+ if (aData->Length() != theLen) {
+ Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
+ for(int a = 0; a < theLen; a++)
+ aNewData->SetValue(a + 1, theData[a]);
+ aData->ChangeArray(aNewData);
+ } else {
+ for(int a = 0; a < theLen; a++)
+ aData->SetValue(a + 1, theData[a]);
+ }
+}
+
+const char* HYDROData_Object::ByteArray(const int theTag, int& theLen)
+{
+ TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
+ Handle(TDataStd_ByteArray) aData;
+ if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
+ return NULL; // return empty image if there is no array
+ theLen = aData->Length();
+ if (theLen)
+ return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
+ return NULL;
+}