Hallo,
I am working on a plugin for the rendering software Realsoft3D, this plugin introduces the modeling features of OpenCASCADE in that host program. First results are encouraging, see for instance.. http://www.deltaknowledge.com/gallery/thumbnails.php?album=5
My problem is that I have to implement the serialization of my 'shape' objects for the Realsoft3D binary files, that is I
need to save (for example) a TopoDS_Shape into an already opened
binary file. The same for loading. Then, it looks a bit like
the CArchive mechanism for MSFC technology (but I do not use MSFC).
Well, I cannot use the BRepTool::Write function because it uses an
ascii file (it would mix it with the stream containing other
Realsoft3D binary info.. I do not know if this is a good way to go..)
So I thought that a basic method could be to convert the
transient object to persistent object, then to save the persistent
object byte-by-byte on file. Is this possible? And how?
best regards,
Discussion
4 archived replies
Posts are displayed in their archived order.
01Commenter-1
Hello Alessandro,
we did in fact use a similar approach to the BRepTool::Write method to serialize a TopoDS_Shape. What we did was to implement new class based on BRepTools_ShapeSet, GeomTools_Curve2dSet, GeomTools_CurveSet , GeomTools_SurfaceSet TopTools_LocationSet and TopTools_ShapeSet and we make sure to remove anything ASCII related to be able to used in with a binary stream. Then, to read a shape from a stream at a the current location we just do:
We have been doing this for 5 years.
Good Luck,
Commenter-1.
02Commenter-2
Thank you Francois!
In fact I suspected that a posible way to go was
to rewrite the BRepTools_ShapeSet class (and the other
classes you told me), but I hoped there was a simplier
method...
For the moment, I found an easy workaround: on serialization
03Commenter-2
Thank you Francois!
In fact I suspected that a posible way to go was
to rewrite the BRepTools_ShapeSet class (and the other
classes you told me), but I hoped there was a simplier
method...
For the moment, I found an easy workaround: when
serializing my shape on disk, I simply save a
'temporary' .brep file on HD using the OpenCASCADE
tool, then I read it byte-by-byte as raw data,
and I store it 'embedded' in my custom binary file
using my file functions. The temporary file is deleted
automatically. Viceversa for loading from disk.
Of course this is a 'dirty' workaround, since it is
not very fast (nor memory-efficient), and it still passes
through ascii conversions of floatingpoint numbers (precision
is affected?). But enough for now.
Thank you very much for your help!
Commenter-2
04Commenter-3
Hello Francois,
I'm having the same problem but I saw that there's something done with the Storage_Schema and his driver FSD_BinaryFile, but it didn't seems to be finish...did you tried that?
And for the solution you did, how much time did takes you to rewrite all those saves functions??