mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0027241: Create a complete test case to verify reading of all attribute types from MDTV-Standard document
Added test case that works in one of two modes: 1) create synthetic document (in old version of OCCT) containing all possible attributes. 2) open the document and compare all attributes with expected values. Fixed reading of TDataStd_NamedData, TDataXtd_PatternStd, and PColStd_HArray2OfReal. Point and curve representations are created even from NULL geometry handles. The code is simplified by abandoning usage of templates from StdObjMgt_ContentTypes class for persistent data elements. Fixed SetAsciiString Draw command failed when the target label contained NamedData attribute.
This commit is contained in:
@@ -9,7 +9,6 @@ StdLPersistent_Dependency.hxx
|
||||
StdLPersistent_Document.cxx
|
||||
StdLPersistent_Document.hxx
|
||||
StdLPersistent_Function.hxx
|
||||
StdLPersistent_HArray1OfPersistent.hxx
|
||||
StdLPersistent_HArray1.cxx
|
||||
StdLPersistent_HArray1.hxx
|
||||
StdLPersistent_HArray2.cxx
|
||||
|
@@ -66,17 +66,17 @@ private:
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
template <class Persistent>
|
||||
void StdLPersistent_Collection::booleanArrayBase<Persistent>::Read
|
||||
template <class Base>
|
||||
void StdLPersistent_Collection::booleanArrayBase<Base>::Read
|
||||
(StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
StdLPersistent_Collection::booleanArrayBase<Persistent>::SingleRef::Read (theReadData);
|
||||
Base::Read (theReadData);
|
||||
theReadData >> myLower >> myUpper;
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class Base>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::booleanArrayBase<Persistent>::import
|
||||
void StdLPersistent_Collection::booleanArrayBase<Base>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
Handle(TColStd_HArray1OfByte) aByteArray =
|
||||
@@ -89,17 +89,17 @@ void StdLPersistent_Collection::booleanArrayBase<Persistent>::import
|
||||
this->myTransient->SetInternalArray (aByteArray);
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class Base>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::directArrayBase<Persistent>::import
|
||||
void StdLPersistent_Collection::directArrayBase<Base>::import
|
||||
(const ArrayHandle& theArray, Converter) const
|
||||
{
|
||||
this->myTransient->ChangeArray (theArray);
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class Base>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::arrayBase<Persistent>::import
|
||||
void StdLPersistent_Collection::arrayBase<Base>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
this->myTransient->Init (theArray->Lower(), theArray->Upper());
|
||||
@@ -107,18 +107,18 @@ void StdLPersistent_Collection::arrayBase<Persistent>::import
|
||||
this->myTransient->SetValue (i, theConverter (theArray->Value(i)));
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class Base>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::listBase<Persistent>::import
|
||||
void StdLPersistent_Collection::listBase<Base>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
|
||||
this->myTransient->Append (theConverter (theArray->Value(i)));
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class Base>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::mapBase<Persistent>::import
|
||||
void StdLPersistent_Collection::mapBase<Base>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) anHMap = new TColStd_HPackedMapOfInteger;
|
||||
@@ -138,8 +138,8 @@ template <template<class> class BaseT,
|
||||
void StdLPersistent_Collection::
|
||||
instance<BaseT, HArrayClass, AttribClass, Converter>::ImportAttribute()
|
||||
{
|
||||
Handle(HArrayClass) anHArray;
|
||||
if (this->myData.Cast (anHArray))
|
||||
Handle(HArrayClass) anHArray = Handle(HArrayClass)::DownCast (this->myData);
|
||||
if (anHArray)
|
||||
{
|
||||
typename HArrayClass::ArrayHandle anArray = anHArray->Array();
|
||||
if (anArray)
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include <TDataStd_IntPackedMap.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Collection : private StdObjMgt_ContentTypes
|
||||
class StdLPersistent_Collection
|
||||
{
|
||||
// Converters
|
||||
struct noConversion;
|
||||
@@ -54,8 +54,8 @@ class StdLPersistent_Collection : private StdObjMgt_ContentTypes
|
||||
const;
|
||||
|
||||
protected:
|
||||
Value<Standard_Integer> myLower;
|
||||
Value<Standard_Integer> myUpper;
|
||||
Standard_Integer myLower;
|
||||
Standard_Integer myUpper;
|
||||
};
|
||||
|
||||
template <class Base>
|
||||
@@ -118,7 +118,7 @@ class StdLPersistent_Collection : private StdObjMgt_ContentTypes
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
|
||||
private:
|
||||
Value<Standard_Boolean> myDelta;
|
||||
Standard_Boolean myDelta;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class StdLPersistent_Data::Parser
|
||||
{
|
||||
public:
|
||||
//! Start parsing a persistent data.
|
||||
Parser (const TColStd_HArray1OfInteger& theLabels,
|
||||
Parser (const TColStd_HArray1OfInteger& theLabels,
|
||||
const StdLPersistent_HArray1OfPersistent& theAttributes)
|
||||
: myLabelsIter (theLabels)
|
||||
, myAttribIter (theAttributes) {}
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
TColStd_HArray1OfInteger ::Iterator myLabelsIter;
|
||||
TColStd_HArray1OfInteger ::Iterator myLabelsIter;
|
||||
StdLPersistent_HArray1OfPersistent::Iterator myAttribIter;
|
||||
};
|
||||
|
||||
|
@@ -34,9 +34,9 @@ private:
|
||||
class Parser;
|
||||
|
||||
private:
|
||||
Value <Standard_Integer> myVersion;
|
||||
Reference <StdLPersistent_HArray1::Integer> myLabels;
|
||||
Reference <StdLPersistent_HArray1::Persistent> myAttributes;
|
||||
Standard_Integer myVersion;
|
||||
Handle(StdLPersistent_HArray1::Integer) myLabels;
|
||||
Handle(StdLPersistent_HArray1::Persistent) myAttributes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -37,8 +37,8 @@ class StdLPersistent_Dependency
|
||||
void Import (const Handle(AttribClass)& theAttribute) const;
|
||||
|
||||
private:
|
||||
StdObjMgt_ContentTypes::Reference<StdLPersistent_HString::Extended> myName;
|
||||
StdObjMgt_ContentTypes::Reference<StdLPersistent_HArray1::Persistent> myVariables;
|
||||
Handle(StdLPersistent_HString::Extended) myName;
|
||||
Handle(StdLPersistent_HArray1::Persistent) myVariables;
|
||||
};
|
||||
|
||||
public:
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
(const Handle(TDocStd_Document)& theDocument) const;
|
||||
|
||||
private:
|
||||
Reference<StdLPersistent_Data> myData;
|
||||
Handle(StdLPersistent_Data) myData;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -16,9 +16,9 @@
|
||||
#define _StdLPersistent_Function_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLObject_GUID.hxx>
|
||||
|
||||
#include <TFunction_Function.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Function : public StdObjMgt_Attribute<TFunction_Function>
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Object<StdLObject_GUID> myDriverGUID;
|
||||
Value<Standard_Integer> myFailure;
|
||||
Standard_GUID myDriverGUID;
|
||||
Standard_Integer myFailure;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -12,44 +12,23 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_HArray1::commonBase::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_HArray1::base::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Value<Standard_Integer> aLowerBound, anUpperBound;
|
||||
Standard_Integer aLowerBound, anUpperBound;
|
||||
theReadData >> aLowerBound >> anUpperBound;
|
||||
createArray (aLowerBound, anUpperBound);
|
||||
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
StdObjMgt_ReadData::Object anObjectData (theReadData);
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
anObjectData >> aSize;
|
||||
|
||||
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
|
||||
readValue (theReadData, i);
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
readValue (anObjectData, i);
|
||||
}
|
||||
|
||||
template <class ArrayClass, class ValueClass>
|
||||
void StdLPersistent_HArray1::instance<ArrayClass, ValueClass>::readValue (
|
||||
StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{
|
||||
ValueClass aValue;
|
||||
theReadData >> aValue;
|
||||
this->myArray->SetValue (theIndex, static_cast<typename ArrayClass::value_type> (aValue));
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfInteger>;
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfReal>;
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfByte,
|
||||
StdObjMgt_ContentTypes::Value<Standard_Character> >;
|
||||
template class StdLPersistent_HArray1::instance<StdLPersistent_HArray1OfPersistent,
|
||||
StdObjMgt_ContentTypes::Reference<> >;
|
||||
|
@@ -16,7 +16,10 @@
|
||||
#define _StdLPersistent_HArray1_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdLPersistent_HArray1OfPersistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
@@ -26,9 +29,13 @@ class TDF_Label;
|
||||
class TDF_Data;
|
||||
|
||||
|
||||
class StdLPersistent_HArray1 : protected StdObjMgt_ContentTypes
|
||||
DEFINE_HARRAY1 (StdLPersistent_HArray1OfPersistent,
|
||||
NCollection_Array1<Handle(StdObjMgt_Persistent)>)
|
||||
|
||||
|
||||
class StdLPersistent_HArray1
|
||||
{
|
||||
class commonBase : public StdObjMgt_Persistent
|
||||
class base : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
@@ -44,7 +51,7 @@ class StdLPersistent_HArray1 : protected StdObjMgt_ContentTypes
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class base : public commonBase
|
||||
class instance : public base
|
||||
{
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
@@ -60,24 +67,23 @@ protected:
|
||||
const Standard_Integer theUpperBound)
|
||||
{ myArray = new ArrayClass (theLowerBound, theUpperBound); }
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{ theReadData >> myArray->ChangeValue (theIndex); }
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
private:
|
||||
template <class ArrayClass, class ValueClass = Value<typename ArrayClass::value_type> >
|
||||
class instance : public base<ArrayClass>
|
||||
{
|
||||
protected:
|
||||
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex);
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray1OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray1OfReal> Real;
|
||||
typedef instance<TColStd_HArray1OfByte, Value<Standard_Character> >Byte;
|
||||
typedef instance<StdLPersistent_HArray1OfPersistent, Reference<> > Persistent;
|
||||
typedef instance<TColStd_HArray1OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray1OfReal> Real;
|
||||
typedef instance<TColStd_HArray1OfByte> Byte;
|
||||
typedef instance<StdLPersistent_HArray1OfPersistent> Persistent;
|
||||
};
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData& theReadData, Standard_Byte& theByte)
|
||||
{ return theReadData >> reinterpret_cast<Standard_Character&> (theByte); }
|
||||
|
||||
#endif
|
||||
|
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2015 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdLPersistent_HArray1OfPersistent_HeaderFile
|
||||
#define _StdLPersistent_HArray1OfPersistent_HeaderFile
|
||||
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
DEFINE_HARRAY1 (StdLPersistent_HArray1OfPersistent,
|
||||
NCollection_Array1<Handle(StdObjMgt_Persistent)>)
|
||||
|
||||
#endif // _StdLPersistent_HArray1OfPersistent_HeaderFile
|
@@ -12,7 +12,6 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_HArray2.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
@@ -22,35 +21,18 @@
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_HArray2::commonBase::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_HArray2::base::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Value<Standard_Integer> aLowerRow, aLowerCol, anUpperRow, anUpperCol;
|
||||
Standard_Integer aLowerRow, aLowerCol, anUpperRow, anUpperCol;
|
||||
theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol;
|
||||
createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol);
|
||||
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
StdObjMgt_ReadData::Object anObjectData (theReadData);
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
anObjectData >> aSize;
|
||||
|
||||
for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
|
||||
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
|
||||
readValue (theReadData, aRow, aCol);
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
readValue (anObjectData, aRow, aCol);
|
||||
}
|
||||
|
||||
template <class ArrayClass>
|
||||
void StdLPersistent_HArray2::instance<ArrayClass>::readValue (
|
||||
StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol)
|
||||
{
|
||||
typename ArrayClass::value_type aValue;
|
||||
theReadData.ReadValue (aValue);
|
||||
this->myArray->SetValue (theRow, theCol, aValue);
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>;
|
||||
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>;
|
||||
|
@@ -16,14 +16,21 @@
|
||||
#define _StdLPersistent_HArray2_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <NCollection_DefineHArray2.hxx>
|
||||
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
|
||||
DEFINE_HARRAY2 (StdLPersistent_HArray2OfPersistent,
|
||||
NCollection_Array2<Handle(StdObjMgt_Persistent)>)
|
||||
|
||||
|
||||
class StdLPersistent_HArray2
|
||||
{
|
||||
class commonBase : public StdObjMgt_Persistent
|
||||
class base : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
@@ -42,7 +49,7 @@ class StdLPersistent_HArray2
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class base : public commonBase
|
||||
class instance : public base
|
||||
{
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
@@ -60,23 +67,19 @@ protected:
|
||||
theLowerCol, theUpperCol);
|
||||
}
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol)
|
||||
{ theReadData >> myArray->ChangeValue (theRow, theCol); }
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
private:
|
||||
template <class ArrayClass>
|
||||
class instance : public base<ArrayClass>
|
||||
{
|
||||
protected:
|
||||
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol);
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray2OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray2OfReal> Real;
|
||||
typedef instance<TColStd_HArray2OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray2OfReal> Real;
|
||||
typedef instance<StdLPersistent_HArray2OfPersistent> Persistent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -25,20 +25,18 @@ template <class StringClass, typename CharType>
|
||||
void StdLPersistent_HString::instance<StringClass, CharType>::Read
|
||||
(StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
StdObjMgt_ReadData::Object anObjectData (theReadData);
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
anObjectData >> aSize;
|
||||
myValue = new StringClass (aSize, 0);
|
||||
|
||||
for (Standard_Integer i = 1; i <= aSize; i++)
|
||||
{
|
||||
CharType aChar;
|
||||
theReadData.ReadValue (aChar);
|
||||
anObjectData >> aChar;
|
||||
myValue->SetValue (i, aChar);
|
||||
}
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -13,8 +13,6 @@
|
||||
|
||||
#include <StdLPersistent_NamedData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
#include <TColStd_DataMapOfStringInteger.hxx>
|
||||
#include <TDataStd_DataMapOfStringReal.hxx>
|
||||
#include <TDataStd_DataMapOfStringString.hxx>
|
||||
@@ -23,6 +21,24 @@
|
||||
#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
|
||||
|
||||
|
||||
static const TCollection_ExtendedString&
|
||||
String (Handle(StdObjMgt_Persistent) theValue)
|
||||
{
|
||||
if (theValue)
|
||||
return theValue->ExtString()->String();
|
||||
|
||||
static TCollection_ExtendedString anEmptyString;
|
||||
return anEmptyString;
|
||||
}
|
||||
|
||||
template <class HArray>
|
||||
static typename HArray::ArrayHandle
|
||||
Array (Handle(StdObjMgt_Persistent) theValue)
|
||||
{
|
||||
Handle(HArray) anArray = Handle(HArray)::DownCast (theValue);
|
||||
return anArray ? anArray->Array() : NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
@@ -37,10 +53,8 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TColStd_DataMapOfStringInteger aMap;
|
||||
for (Standard_Integer i = lower(0); i <= upper(0); i++)
|
||||
{
|
||||
Standard_Integer aValue = 0;
|
||||
aMap.Bind (myInts.Get (i, aValue), aValue);
|
||||
}
|
||||
aMap.Bind (myInts.Key(i), myInts.Value(i));
|
||||
|
||||
theAttribute->ChangeIntegers (aMap);
|
||||
}
|
||||
|
||||
@@ -48,10 +62,8 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TDataStd_DataMapOfStringReal aMap;
|
||||
for (Standard_Integer i = lower(1); i <= upper(1); i++)
|
||||
{
|
||||
Standard_Real aValue = 0.0;
|
||||
aMap.Bind (myReals.Get (i, aValue), aValue);
|
||||
}
|
||||
aMap.Bind (myReals.Key(i), myReals.Value(i));
|
||||
|
||||
theAttribute->ChangeReals (aMap);
|
||||
}
|
||||
|
||||
@@ -59,12 +71,8 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TDataStd_DataMapOfStringString aMap;
|
||||
for (Standard_Integer i = lower(2); i <= upper(2); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
aMap.Bind (myStrings.Get (i, aValue),
|
||||
aValue ? aValue->ExtString()->String()
|
||||
: TCollection_ExtendedString());
|
||||
}
|
||||
aMap.Bind (myStrings.Key(i), String (myStrings.Value(i)));
|
||||
|
||||
theAttribute->ChangeStrings (aMap);
|
||||
}
|
||||
|
||||
@@ -72,10 +80,8 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TDataStd_DataMapOfStringByte aMap;
|
||||
for (Standard_Integer i = lower(3); i <= upper(3); i++)
|
||||
{
|
||||
Standard_Byte aValue = 0;
|
||||
aMap.Bind (myBytes.Get (i, aValue), aValue);
|
||||
}
|
||||
aMap.Bind (myBytes.Key(i), myBytes.Value(i));
|
||||
|
||||
theAttribute->ChangeBytes (aMap);
|
||||
}
|
||||
|
||||
@@ -83,19 +89,9 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TDataStd_DataMapOfStringHArray1OfInteger aMap;
|
||||
for (Standard_Integer i = lower(4); i <= upper(4); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
const TCollection_ExtendedString& aKey = myIntArrays.Get (i, aValue);
|
||||
aMap.Bind (myIntArrays.Key(i),
|
||||
Array<StdLPersistent_HArray1::Integer> (myIntArrays.Value(i)));
|
||||
|
||||
Handle(StdLPersistent_HArray1::Integer) aPArray =
|
||||
Handle(StdLPersistent_HArray1::Integer)::DownCast (aValue);
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) aTArray;
|
||||
if (aPArray)
|
||||
aTArray = aPArray->Array();
|
||||
|
||||
aMap.Bind (aKey, aTArray);
|
||||
}
|
||||
theAttribute->ChangeArraysOfIntegers (aMap);
|
||||
}
|
||||
|
||||
@@ -103,19 +99,9 @@ void StdLPersistent_NamedData::Import
|
||||
{
|
||||
TDataStd_DataMapOfStringHArray1OfReal aMap;
|
||||
for (Standard_Integer i = lower(5); i <= upper(5); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
const TCollection_ExtendedString& aKey = myRealArrays.Get (i, aValue);
|
||||
aMap.Bind (myRealArrays.Key(i),
|
||||
Array<StdLPersistent_HArray1::Real> (myRealArrays.Value(i)));
|
||||
|
||||
Handle(StdLPersistent_HArray1::Real) aPArray =
|
||||
Handle(StdLPersistent_HArray1::Real)::DownCast (aValue);
|
||||
|
||||
Handle(TColStd_HArray1OfReal) aTArray;
|
||||
if (aPArray)
|
||||
aTArray = aPArray->Array();
|
||||
|
||||
aMap.Bind (aKey, aTArray);
|
||||
}
|
||||
theAttribute->ChangeArraysOfReals (aMap);
|
||||
}
|
||||
}
|
||||
|
@@ -25,35 +25,39 @@
|
||||
class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
|
||||
{
|
||||
template <class HValuesArray>
|
||||
class element
|
||||
class pMapData
|
||||
{
|
||||
public:
|
||||
typedef typename HValuesArray::ValueType ValueType;
|
||||
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myKeys >> myValues; }
|
||||
|
||||
inline operator bool() const
|
||||
{ return ! myKeys.IsNull(); }
|
||||
{ return !myKeys.IsNull(); }
|
||||
|
||||
template <class Value>
|
||||
inline const TCollection_ExtendedString& Get
|
||||
(Standard_Integer theIndex, Value& theValue) const
|
||||
{
|
||||
if (myValues)
|
||||
theValue = myValues->Array()->Value(theIndex);
|
||||
return myKeys->Array()->Value(theIndex)->ExtString()->String();
|
||||
}
|
||||
const TCollection_ExtendedString& Key (Standard_Integer theIndex) const
|
||||
{ return myKeys->Array()->Value(theIndex)->ExtString()->String(); }
|
||||
|
||||
ValueType Value (Standard_Integer theIndex) const
|
||||
{ return myValues ? myValues->Array()->Value(theIndex) : 0; }
|
||||
|
||||
private:
|
||||
Reference <StdLPersistent_HArray1::Persistent> myKeys;
|
||||
Reference <HValuesArray> myValues;
|
||||
Handle(StdLPersistent_HArray1::Persistent) myKeys;
|
||||
Handle(HValuesArray) myValues;
|
||||
};
|
||||
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myDimensions >>
|
||||
myInts >> myReals >> myStrings >> myBytes >> myIntArrays >> myRealArrays;
|
||||
theReadData >> myDimensions;
|
||||
myInts .Read (theReadData);
|
||||
myReals .Read (theReadData);
|
||||
myStrings .Read (theReadData);
|
||||
myBytes .Read (theReadData);
|
||||
myIntArrays .Read (theReadData);
|
||||
myRealArrays.Read (theReadData);
|
||||
}
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
@@ -64,13 +68,13 @@ private:
|
||||
inline Standard_Integer upper (Standard_Integer theIndex) const;
|
||||
|
||||
private:
|
||||
Reference <StdLPersistent_HArray2::Integer> myDimensions;
|
||||
Object <element<StdLPersistent_HArray1::Integer> > myInts;
|
||||
Object <element<StdLPersistent_HArray1::Real> > myReals;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myStrings;
|
||||
Object <element<StdLPersistent_HArray1::Byte> > myBytes;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myIntArrays;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myRealArrays;
|
||||
Handle(StdLPersistent_HArray2::Integer) myDimensions;
|
||||
pMapData<StdLPersistent_HArray1::Integer> myInts;
|
||||
pMapData<StdLPersistent_HArray1::Real> myReals;
|
||||
pMapData<StdLPersistent_HArray1::Persistent> myStrings;
|
||||
pMapData<StdLPersistent_HArray1::Byte> myBytes;
|
||||
pMapData<StdLPersistent_HArray1::Persistent> myIntArrays;
|
||||
pMapData<StdLPersistent_HArray1::Persistent> myRealArrays;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_RealEnum.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Real : public StdObjMgt_Attribute<TDataStd_Real>
|
||||
@@ -31,13 +30,13 @@ public:
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_Real)& theAttribute) const
|
||||
{
|
||||
theAttribute->Set (myValue);
|
||||
theAttribute->SetDimension (myDimension);
|
||||
theAttribute->Set (myValue);
|
||||
theAttribute->SetDimension (static_cast<TDataStd_RealEnum> (myDimension));
|
||||
}
|
||||
|
||||
private:
|
||||
Value<Standard_Real> myValue;
|
||||
Enum<TDataStd_RealEnum> myDimension;
|
||||
Standard_Real myValue;
|
||||
Standard_Integer myDimension;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -16,9 +16,9 @@
|
||||
#define _StdLPersistent_TreeNode_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLObject_GUID.hxx>
|
||||
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_TreeNode
|
||||
@@ -37,12 +37,12 @@ public:
|
||||
private:
|
||||
struct dynamic : public Standard_Transient
|
||||
{
|
||||
Reference <StdLPersistent_TreeNode> First;
|
||||
Object <StdLObject_GUID> TreeID;
|
||||
Handle(StdLPersistent_TreeNode) First;
|
||||
Standard_GUID TreeID;
|
||||
};
|
||||
|
||||
Handle(dynamic) myDynamicData;
|
||||
Reference<StdLPersistent_TreeNode> myNext;
|
||||
Handle(StdLPersistent_TreeNode) myNext;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -34,8 +34,9 @@ void StdLPersistent_Value::integer<AttribClass>::ImportAttribute()
|
||||
template <class AttribClass, class HStringClass>
|
||||
void StdLPersistent_Value::string<AttribClass, HStringClass>::ImportAttribute()
|
||||
{
|
||||
Handle(HStringClass) anHString;
|
||||
if (this->myData.Cast (anHString))
|
||||
Handle(HStringClass) anHString =
|
||||
Handle(HStringClass)::DownCast (this->myData);
|
||||
if (anHString)
|
||||
{
|
||||
this->myTransient->Set (anHString->Value()->String());
|
||||
this->myData.Nullify();
|
||||
@@ -83,7 +84,7 @@ Handle(TDF_Attribute) StdLPersistent_Value::UAttribute::CreateAttribute()
|
||||
}
|
||||
|
||||
return this->myTransient;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_Value::integer <TDataStd_Integer>;
|
||||
|
@@ -37,8 +37,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Value <Standard_Boolean> myIsConstant;
|
||||
Reference <StdLPersistent_HString::Ascii> myUnit;
|
||||
Standard_Boolean myIsConstant;
|
||||
Handle(StdLPersistent_HString::Ascii) myUnit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -39,8 +39,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Reference<StdLPersistent_HString::Ascii> myDocEntry;
|
||||
Reference<StdLPersistent_HString::Ascii> myLabEntry;
|
||||
Handle(StdLPersistent_HString::Ascii) myDocEntry;
|
||||
Handle(StdLPersistent_HString::Ascii) myLabEntry;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user