Region using CAD file - solution

Submitted by cstoltz on Wed, 04/17/2013 - 12:55

Attached is a little stl-to-vtk conversion tool. From the command line, it is just './convert file.stl', where 'file.stl' can be whatever you want. It should produce a vtk file called 'file.vtk'. Limit of 1e6 facets/vertices in the STL file.

Best regards,
Chris

AttachmentSize
Binary Data stl_to_vtk.tar_.gz194.78 KB
ckloss's picture

ckloss | Fri, 04/19/2013 - 15:18

Hi Chris,

thanks - looks very cool and works very nicely! One question: what does it do if the STL is an open shell?

Thanks, cheers,
Christoph

cstoltz | Fri, 04/19/2013 - 18:55

Hi Christoph,

Shouldn't matter (unless of course I screwed up in the code :) ). I tried to make it just a straight conversion of the triangular facets from the stl file into a vtk file. If you (or anyone else) has some cases that fail, please let me know.

I pulled the vtk format that I used from something found via google, which doesn't directly match the format used for LIGGGHTS (hence the first problem with importing). I tried changing it a bit to match the format LIGGGHTS seems to be requesting, but wasn't able to quickly get it working properly. I'll try it again later when I have some time.

Best Regards,
Chris

AGl | Mon, 04/22/2013 - 07:48

Just one more suggestion to convert stl into vtk using gmsh:

gmsh -2 file.stl -o file.vtk

tdl | Mon, 04/22/2013 - 11:18

Thanks for your suggestion, with the program you suggested I
could convert the STL files to VTK legacy ascii unstructured grid.
Thanks again,
Alessandro