[vtkusers] file conversion

David Doria daviddoria at gmail.com
Wed Apr 18 07:53:02 EDT 2012


On Wed, Apr 18, 2012 at 5:42 AM, p0rter <a.schmitz703 at gmail.com> wrote:

> *hi,
>
> the vtk looks like this:*
>
> # vtk DataFile Version 1.0
> Generator=TriangleMesh.java, Wed Dec 01 15:32:52 CET 2010
> ASCII
> DATASET POLYDATA
> POINTS 1500 double
> -10.516600913464657 177.84067036857135 394.5663277002459
> -8.948885903928584 175.66132806672883 394.7663426028354
> -11.175970694055763 174.878784436299 394.8202448540949
> 0.5256460757442767 229.73798767584557 389.9518823843581
> -0.3635826600914527 230.2230158375073 387.4975767250487
> [...]
> POLYGONS 3000 12000
> 3 833 1239 390
> 3 1145 645 18
> 3 595 1387 1110
> 3 337 336 416
> [...]
> CELL_DATA 3000
> SCALARS labels int 1
> LOOKUP_TABLE default
> 391
> 390
> 390
> 390
> 400
> 393
> 394
> 390
> 391
> 392
> [...]
>
> *pretty basic. i know i can export vtk to x3d and vrml but actually i need
> .obj or better: JSON. example:*
>
> {
>    "metadata": { "formatVersion" : 3, "generatedBy": "Blender 2.58
> Exporter" },
>    "scale" : 100.000000,
>    "materials": [],
>    "vertices": [-1306,2788,-842,340,-4515,-1884,1880,1458,-1603, ....],
>    "morphTargets": [],
>    "normals": [],
>    "colors": [],
>    "uvs": [[]],
>    "faces": [0,661,1599,29,0,1123,1162,1622,0,1425,1180,199,0,320, ...],
>    "edges" : []
> }
>

You should be able to use this to read the file:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/GenericDataObjectReader

Then use this to write an obj:
https://github.com/daviddoria/vtkOBJWriter

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120418/d5dfae85/attachment.htm>


More information about the vtkusers mailing list