[vtkusers] Exporting RGB Polydata to .OBJ or .PLY

kenichiro yoshimi rccm.kyoshimi at gmail.com
Sat Dec 8 05:00:50 EST 2018


Hi,

You can use the vtkX3DExporter or vtkVRMLExporter to export VTK scene
and render the meshes and colors in blender.
https://www.vtk.org/gitweb?p=VTK.git;a=blob;f=IO/Export/Testing/Cxx/X3DTest.cxx
https://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Rendering/Core/Testing/Python/cells.py

Regards
2018年12月7日(金) 3:13 Radosław Furmaniak <rastor.ragereaver at gmail.com>:
>
> Hello,
> I have set up PolyData and added 4 component scalar array to it. When I create PolyDataMapper, set scalar visibility and add actor to the scene, all colors are rendered properly.
> However, I have a problem with exporting this scene or just the polydata to the .OBJ (+mtl) file or to the .PLY. When I open it up in Blender, geometry is exported correctly, however OBJ is created all white, and .PLY has a single, grayish color (apart from the shadows of course), which I don't think is even present in input PolyData.
>
> I am trying to do it like this:
>
> plyWriter = vtk.vtkPLYWriter()
> plyWriter.SetInputData(polydata)
> plyWriter.SetFileTypeToBinary()
> plyWriter.SetDataByteOrderToLittleEndian()
> plyWriter.SetArrayName("Scalars")
> plyWriter.SetFileName("model.ply")
> plyWriter.Write()
>
> I have also tried setting up different color modes in plyWriter,
>  but the results are always the same.
>
> Scalar array is set up like this:
>
> scalarArray = vtk.vtkDoubleArray()
> scalarArray.SetNumberOfComponents(4)
> scalarArray.SetName("Scalars")
>
> polydata.GetPointData().AddArray(scalarArray)
>
> polydata.GetPointData().SetActiveScalars("Scalars")
>
> (I am omitting the part where I am actually setting elements of this array)
>
> I have also tried using the OBJExporter:
>
> writer = vtk.vtkOBJExporter()
> writer.SetFilePrefix(output_prefix)
> writer.SetInput(renWin)
> writer.Write()
>
> where renWin is rendering window with a single actor made from polydata mentioned above.
>
> I am using Python 3.6 and VTK 8.1.1.
>
> Any help how to export geometry and colors, so they can be reused in other programs?
>
> Thanks in advance.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list