Store/Retrieve TopoDS_Shape (and) others to xml string

Not using OCAF, I'd need to create an xml representation of a TopoDS_Shape object and retrieve it
back from xml.
Is it possible ?

Max

Forum supervisor's picture

Dear Massimo,
There is no ready to use services of the requested type in OCCT .
OCCT services in xml persistence domain are oriented to store/retrieve OCAF document only. Nevertheless you can do it (store/retrieve TopoDS_Shape in xml) by yourself reusing the same low level tools (see LDOM package) or ask our support via Contact Form http://www.opencascade.org/about/contacts/.
Regards

Massimo Del Fedele's picture

Thank you, already done it in a maybe too simple way (using Write in TopTolls, IIRC...) and seen that it's maybe not a so good idea, looking at the size of xml files generated by shapes.
Maybe there's a better way, but I guess I'll do it with foundation classes binary storage for now.

Best Regards

Max

Stephane Routelous's picture

I did that a while ago with BRepTools::Write to save to a string, then compress (zip) the string and base64 encode the result to save it as an XML node into an XML doc containing other application dependant data.

it was working pretty well.

Stephane

Massimo Del Fedele's picture

Hi Stephane,

I did almost the same, without encoding nor compressing, the Bottle shape from example (I'm testing
the performances of my app....) gave a file of 382 KB.
200 Bottles gave a proportional size of around 70 MB, which, when zipped, were packed to a factor 1/5, so 15
MB around..... a bit too much for the size of drawing data. I guess that without a special packer the data won't be much less than that, which is really too much.
I'll try with binary save, and then decide if it's worth to stay with xml encoding/packing it or to go to
binary at once, depending on the resulting file size.

Thank you for your answer !

Best Regards

Max

Stephane Routelous's picture

Have you called BRepTools::Clean before saving the brep ?
It will remove all the triangulation which will be regenerated when needed in your app.

Stephane

Massimo Del Fedele's picture

mmmhhh... right ! I didn't do a Clean() before, now I get 15 MB for 200 bottles and, zipped, 2.2 MB.
It's becoming interesting....

Thank you very much for hint !

Max

Baba Ali's picture

Hi All,

Could you please be more specific about the progress you did? I am familiar to C++ but new to OCC and I am interested in your xml process. How I can repeat your steps?

Thanks in Advance