
Thu, 02/14/2019 - 20:22
Hi all,
I have a question about the code snippet for reading/writing TopoDS_Shape in the following link:
https://dev.opencascade.org/doc/overview/html/occt_dev_guides__upgrade.h...
Is this the old method/format to read/write shapes? If yes, what is the new method and please can someone
show me the sample code.
Many thanks.
Fri, 02/15/2019 - 04:17
Read Shape Code like this
f.SetSkipHeader(true);
Handle(StdStorage_Data) aData;
Storage_Error anError = StdStorage::Read(f, aData);
if (anError != Storage_VSOk)
{
return;
}
else
{
TopTools_SequenceOfShape aShapes;
Handle(StdStorage_TypeData) aTypeData = aData->TypeData();
Handle(StdStorage_RootData) aRootData = aData->RootData();
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
if (!aRoots.IsNull())
{
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
{
Handle(StdStorage_Root)& aRoot = anIt.ChangeValue();
Handle(StdObjMgt_Persistent) aPObject = aRoot->Object();
if (!aPObject.IsNull())
{
Handle(ShapePersistent_TopoDS::HShape) aHShape = Handle(ShapePersistent_TopoDS::HShape)::DownCast(aPObject);
if (aHShape) // shapes are expected
{
TopoDS_Shape aShape = aHShape->Import();
aShapes.Append(aShape);
}
}
}
}
if (aShapes.Length() > 1)
{
BRep_Builder aB;
TopoDS_Compound aC;
aB.MakeCompound(aC);
for (Standard_Integer i = 1; i <= aShapes.Length(); ++i)
aB.Add(aC, aShapes.Value(i));
Shape() = aC;
}
else
Shape() = aShapes.First();
}
f is FSD_Archive,the code locate in samples\mfc\standard\05_ImportExport\src
my OCCT Version is 7.3.0,only on Windows,others Platform not test