Re: Exporting RGB Polydata to .OBJ or .PLY

kenichiro yoshimi <[email protected]>
Newsgroups gmane.comp.lib.vtk.user
Message-ID <CAHDyfPDM8DPkRS7cR3Kmvc+pQN-sKnQgLrVDqLcywHq09+9uKA@mail.gmail.com>
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 <[email protected]>:
>
> 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
_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.