1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +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:
myn
2016-03-11 22:08:01 +03:00
committed by abv
parent 944d808cd0
commit 45d8465ea2
82 changed files with 1524 additions and 1333 deletions

View File

@@ -1,5 +1,4 @@
StdObjMgt_Attribute.hxx
StdObjMgt_ContentTypes.hxx
StdObjMgt_MapOfInstantiators.cxx
StdObjMgt_MapOfInstantiators.hxx
StdObjMgt_Persistent.cxx

View File

@@ -20,8 +20,7 @@
//! Root class for a temporary persistent object corresponding to an attribute.
template <class Transient>
class StdObjMgt_Attribute : public Standard_Transient,
protected StdObjMgt_ContentTypes
class StdObjMgt_Attribute : public Standard_Transient
{
class base : public StdObjMgt_Persistent
{
@@ -53,8 +52,8 @@ public:
DataType myData;
};
struct SingleInt : Simple <Value<Standard_Integer> > {};
struct SingleRef : Simple <Reference<> > {};
struct SingleInt : Simple<Standard_Integer> {};
struct SingleRef : Simple<Handle(StdObjMgt_Persistent)> {};
private:
template <class Persistent>

View File

@@ -1,102 +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 _StdObjMgt_ContentTypes_HeaderFile
#define _StdObjMgt_ContentTypes_HeaderFile
#include <StdObjMgt_ReadData.hxx>
class StdObjMgt_Persistent;
//! Root class for an object containing other obects.
class StdObjMgt_ContentTypes
{
template <typename Type>
class holder
{
public:
//! Return the value.
operator Type() const { return myValue; }
protected:
Type myValue;
};
template <typename Type>
struct enum_ : holder<Type>
{
//! Read the value from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadEnum (this->myValue); }
};
template <typename Type>
struct value : holder<Type>
{
//! Read the value from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadValue (this->myValue); }
};
template <class Class>
struct object : Class
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadObject ((Class&)*this); }
};
template <class Persistent>
struct referenceT : Handle(Persistent)
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadReference (*this); }
};
struct reference : Handle(StdObjMgt_Persistent)
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ Handle(StdObjMgt_Persistent)::operator= (theReadData.ReadReference()); }
//! Cast the reference to a target type.
template <class Persistent>
bool Cast (Handle(Persistent)& theTarget) const
{
theTarget = Handle(Persistent)::DownCast(*this);
return ! theTarget.IsNull();
}
};
public:
template <class Type>
struct Enum : StdObjMgt_ReadData::Content <enum_<Type> > {};
template <class Type>
struct Value : StdObjMgt_ReadData::Content <value<Type> > {};
template <class Class>
struct Object : StdObjMgt_ReadData::Content <object<Class> > {};
template <class Persistent = StdObjMgt_Persistent>
struct Reference : StdObjMgt_ReadData::Content <referenceT<Persistent> > {};
};
template<>
struct StdObjMgt_ContentTypes::Reference<StdObjMgt_Persistent>
: StdObjMgt_ReadData::Content <reference> {};
#endif // _StdObjMgt_ContentTypes_HeaderFile

View File

@@ -18,7 +18,6 @@
#include <Standard.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
#include <StdObjMgt_ContentTypes.hxx>
#include <TDF_Label.hxx>
@@ -32,8 +31,7 @@ class TCollection_HExtendedString;
//! Root class for a temporary persistent object that reads data from a file
//! and then creates transient object using the data.
class StdObjMgt_Persistent : public Standard_Transient,
protected StdObjMgt_ContentTypes
class StdObjMgt_Persistent : public Standard_Transient
{
public:
//! Derived class instance create function.

View File

@@ -14,6 +14,8 @@
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <Standard_GUID.hxx>
StdObjMgt_ReadData::StdObjMgt_ReadData
(Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects)
@@ -39,3 +41,23 @@ Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference()
myDriver->GetReference (aRef);
return aRef ? PersistentObject (aRef) : NULL;
}
//=======================================================================
//function : operator >>
//purpose : Read persistent data from a file
//=======================================================================
StdObjMgt_ReadData& operator >>
(StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID)
{
Standard_Integer a32b;
Standard_ExtCharacter a16b[3];
Standard_Character a8b [6];
theReadData >> a32b >> a16b[0] >> a16b[1] >> a16b[2];
theReadData >> a8b[0] >> a8b[1] >> a8b[2] >> a8b[3] >> a8b[4] >> a8b[5];
theGUID = Standard_GUID (a32b, a16b[0], a16b[1], a16b[2],
a8b[0], a8b[1], a8b[2], a8b[3], a8b[4], a8b[5]);
return theReadData;
}

View File

@@ -19,17 +19,18 @@
#include <NCollection_Array1.hxx>
class StdObjMgt_Persistent;
class Standard_GUID;
//! Auxiliary data used to read persistent objects from a file.
class StdObjMgt_ReadData
{
public:
class Object;
Standard_EXPORT StdObjMgt_ReadData
(Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects);
Storage_BaseDriver& Driver() const
{ return *myDriver; }
template <class Instantiator>
void CreatePersistentObject
(const Standard_Integer theRef, Instantiator theInstantiator)
@@ -45,45 +46,69 @@ public:
Standard_EXPORT Handle(StdObjMgt_Persistent) ReadReference();
template <class Persistent>
void ReadReference (Handle(Persistent)& theTarget)
StdObjMgt_ReadData& operator >> (Handle(Persistent)& theTarget)
{
theTarget = Handle(Persistent)::DownCast (ReadReference());
}
template <class Object>
void ReadObject (Object& theObject)
{
myDriver->BeginReadObjectData();
theObject.Read (*this);
myDriver->EndReadObjectData();
}
template <class Type>
void ReadValue (Type& theValue)
{
*myDriver >> theValue;
}
template <class Type>
void ReadEnum (Type& theEnum)
{
Standard_Integer aValue;
*myDriver >> aValue;
theEnum = static_cast<Type> (aValue);
}
template <class Base> struct Content : Base {};
template <class Base>
StdObjMgt_ReadData& operator >> (Content<Base>& theContent)
{
theContent.Read (*this);
return *this;
}
StdObjMgt_ReadData& operator >> (Handle(StdObjMgt_Persistent)& theTarget)
{
theTarget = ReadReference();
return *this;
}
template <class Type>
StdObjMgt_ReadData& ReadValue (Type& theValue)
{
*myDriver >> theValue;
return *this;
}
StdObjMgt_ReadData& operator >> (Standard_Character& theValue)
{ return ReadValue (theValue); }
StdObjMgt_ReadData& operator >> (Standard_ExtCharacter& theValue)
{ return ReadValue (theValue); }
StdObjMgt_ReadData& operator >> (Standard_Integer& theValue)
{ return ReadValue (theValue); }
StdObjMgt_ReadData& operator >> (Standard_Boolean& theValue)
{ return ReadValue (theValue); }
StdObjMgt_ReadData& operator >> (Standard_Real& theValue)
{ return ReadValue (theValue); }
StdObjMgt_ReadData& operator >> (Standard_ShortReal& theValue)
{ return ReadValue (theValue); }
private:
Storage_BaseDriver* myDriver;
NCollection_Array1<Handle(StdObjMgt_Persistent)> myPersistentObjects;
};
class StdObjMgt_ReadData::Object
{
public:
Object (StdObjMgt_ReadData& theData) : myReadData (&theData)
{ myReadData->myDriver->BeginReadObjectData(); }
~Object()
{ myReadData->myDriver->EndReadObjectData(); }
operator StdObjMgt_ReadData&()
{ return *myReadData; }
template <class Data>
StdObjMgt_ReadData& operator >> (Data& theData)
{ return *myReadData >> theData; }
private:
StdObjMgt_ReadData* myReadData;
};
Standard_EXPORT StdObjMgt_ReadData& operator >>
(StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID);
#endif // _StdObjMgt_ReadData_HeaderFile

View File

@@ -21,11 +21,8 @@
class StdObjMgt_SharedObject
{
public:
class PersistentBase : public Standard_Transient,
protected StdObjMgt_ContentTypes {};
template <class Transient>
class AbstractPersistentBase : public PersistentBase
class AbstractPersistentBase : public Standard_Transient
{
public:
virtual Handle(Transient) Import() const = 0;