STL File Export Support

How to export a STL file by using open cascade?
Do we need to mesh the shape or is there any default function to do it?
I would like to configure the Triangulation parameters before exporting it as STL (such as tolerance and error)
Please give me the necessary methods or a sample to do it

Is it ok to use RWStl::WriteBinary, If so what is the procedure of doing?

Thanks in advance,

Best Regards,
Pahee

Sharjith Naramparambath's picture

Export of Stl is well demonstrated in the Import/Export Sample.

rathan0001's picture

Thanks Sharjith

Yap I did. Thanks. But having some problems in saving as binary files.By default they supports ASCII, what is the way for Binary files, How to use StlAPI_Writer to do it,

Please let me know the way.

Best Regards,
Pahee

sergey zaritchny's picture

Hi Pahee,
It seems that you mixed up different features if I understood you in right way.
Stl is import/export feature (format dedicated for communication with external systems).
Binary format is document feature (to keep data in one's own format of OCCT persistence component).
Regards
Sergey

Sharjith Naramparambath's picture

I think you are using the class StlAPI_Writer shown in the example which has only Write method that defaults to ASCII. The class has a method ASCIIMode() that returns a reference to the format flag which can used as lvalue to set the flag to true or false for Ascii or binary. Check the documentation.

Another way is to use the class RWStl.
The RWStl class has WriteBinary and WriteAscii methods. Note the Stl read code that we discussed earlier in this forum uses the same class and it reads files right away, irrespective of the format. But one thing you need to do is to make the Stl_Mesh first out of the topological entity after triangulating it and then send it to RWStl::WriteBinary/Ascii method. But it is a lengthy process.

Using the StlAPI_Writer class you can directly send the topological entity and its easy. Hope this helps.

rathan0001's picture

Definitely Sharjith,

This what I expected. Thanks for your reply.

Regards,
Pahee