1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0028564: Support of applications using old persistence (ShapeSchema)

1. Bug fix in reading old persistent data using FSD_File storage driver
2. Persistence compatible with legacy format was restored for shapes
   a. Implemented a storage read / write wrapper for legacy persistence
   b. Added DRAW commands to read / write files in legacy format
   c. Added test cases for reading / writing operations with checking number of sub-shapes and physical properties
   d. Updated related sections of the development guide
This commit is contained in:
snn
2017-03-28 17:13:04 +03:00
committed by bugmaster
parent 632175c3a8
commit ec96437207
124 changed files with 7813 additions and 128 deletions

View File

@@ -333,6 +333,8 @@ The applications that used these data persistence tools need to be updated to us
The existing data files in standard formats can be converted using OCCT 6.9.1 or a previous version, as follows.
@note Reading / writing custom files capability from OCCT 6.9.1 is restored in OCCT 7.2.0. See details in @ref upgrade_720_persistence section.
#### CSFDB files
Files in *CSFDB* format (usually with extension .csfdb) contain OCCT shape data that can be converted to BRep format.
@@ -1248,3 +1250,101 @@ The following Grid management methods within class V3d_Viewer do not implicitly
- *IntTools_Curve::Tolerance()* - returns the valid tolerance for the curve;
- *IntTools_Curve::TangentialTolerance()* - returns the tangential tolerance, which reflects the size of the common between faces.
* 2d tolerance (*IntTools_FaceFace::TolReached2d()*) has been completely removed from the algorithm as unused.
@subsection upgrade_720_persistence Restore OCCT 6.9.1 persistence
Capability of reading / writing files in old format using *Storage_ShapeSchema* functionality from OCCT 6.9.1 has been restored in OCCT 7.2.0.
One can use this functionality in two ways:
- invoke DRAW Test Harness commands fsdread / fsdwrite for shapes
- call *StdStorage* class Read / Write functions in custom code
Code example below demonstrates how to read shapes from a storage driver using *StdStorage* class.
~~~~
// aDriver should be created and opened for reading
Handle(StdStorage_Data) aData;
// Read data from the driver
// StdStorage::Read creates aData instance automatically if it is null
Storage_Error anError = StdStorage::Read(*aDriver, aData);
if (anError != Storage_VSOk)
{
// Error processing
}
// Get root objects
Handle(StdStorage_RootData) aRootData = aData->RootData();
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
if (!aRoots.IsNull())
{
// Iterator over the sequence of root objects
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
{
Handle(StdStorage_Root)& aRoot = anIt.ChangeValue();
// Get a persistent root's object
Handle(StdObjMgt_Persistent) aPObject = aRoot->Object();
if (!aPObject.IsNull())
{
Handle(ShapePersistent_TopoDS::HShape) aHShape = Handle(ShapePersistent_TopoDS::HShape)::DownCast(aPObject);
if (aHShape) // Downcast to an expected type to import transient data
{
TopoDS_Shape aShape = aHShape->Import();
shapes.Append(aShape);
}
}
}
}
~~~~
The following code demonstrates how to write shapes in OCCT 7.2.0 using *StdStorage* class.
~~~~
// Create a file driver
NCollection_Handle<Storage_BaseDriver> aFileDriver(new FSD_File());
// Try to open the file driver for writing
try
{
OCC_CATCH_SIGNALS
PCDM_ReadWriter::Open(*aFileDriver, TCollection_ExtendedString(CStringA(filename).GetBuffer()), Storage_VSWrite);
}
catch (Standard_Failure& e)
{
// Error processing
}
// Create a storage data instance
Handle(StdStorage_Data) aData = new StdStorage_Data;
// Set an axiliary application name (optional)
aData->HeaderData()->SetApplicationName(TCollection_ExtendedString("Application"));
// Provide a map to track sharing
StdObjMgt_TransientPersistentMap aMap;
// Iterator over a collection of shapes
for (Standard_Integer i = 1; i <= shapes.Length(); ++i)
{
TopoDS_Shape aShape = shapes.Value(i);
// Translate a shape to a persistent object
Handle(ShapePersistent_TopoDS::HShape) aPShape =
ShapePersistent_TopoDS::Translate(aShape, aMap, ShapePersistent_WithTriangle);
if (aPShape.IsNull())
{
// Error processing
}
// Construct a root name
TCollection_AsciiString aName = "Shape_";
aName += i;
// Add a root to storage data
Handle(StdStorage_Root) aRoot = new StdStorage_Root(aName, aPShape);
aData->RootData()->AddRoot(aRoot);
}
// Write storage data to the driver
Storage_Error anError = StdStorage::Write(*aFileDriver, aData);
if (anError != Storage_VSOk)
{
// Error processing
}
~~~~