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

Andras Lasso lasso at queensu.ca
Sat Dec 8 11:37:27 EST 2018


VTK's OBJ exporter can save solid color that is set in the actor's property and Blender can use that. Point scalar data could be exported to texture and probably Blender would use that, but that has not been implemented in VTK's OBJ exporter yet - contributions are welcome.

VTK's PLY writer can write RGB point scalars and some software, for example MeshLab can display the colored model correctly. However, Blender ignores this color information (at least it does not show up when you simply import the file; maybe there are plug-ins or some settings that would fix this). MeshLab may be able to export the colored model into a format that Blender can read.

Andras
________________________________
From: kenichiro yoshimi <rccm.kyoshimi at gmail.com>
Sent: Saturday, December 8, 2018 5:01 AM
To: rastor.ragereaver at gmail.com
Cc: vtkusers at public.kitware.com
Subject: Re: [vtkusers] Exporting RGB Polydata to .OBJ or .PLY

Hi,

You can use the vtkX3DExporter or vtkVRMLExporter to export VTK scene
and render the meshes and colors in blender.
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.vtk.org%2Fgitweb%3Fp%3DVTK.git%3Ba%3Dblob%3Bf%3DIO%2FExport%2FTesting%2FCxx%2FX3DTest.cxx&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=YaDsvSv7gjU5x3ilese0EXWFXXP%2FwfbM36CNGZFT2xM%3D&reserved=0
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.vtk.org%2Fgitweb%3Fp%3DVTK.git%3Ba%3Dblob%3Bf%3DRendering%2FCore%2FTesting%2FPython%2Fcells.py&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=s3zn9M6VhL8ISVFAq6pXutgYLsC1tT4%2BQGOcuB%2F7%2Bgo%3D&reserved=0

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 https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=PeaSVC7fX37vaEEQwDU9tjq%2FRKKkqqekeYXkr1xuvBA%3D&reserved=0
>
> Visit other Kitware open-source projects at https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=3RrDlN1d5fM25xQ9EsSRczIGHKV3dBkig4LeYNLuX%2B0%3D&reserved=0
>
> Please keep messages on-topic and check the VTK FAQ at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vtk.org%2FWiki%2FVTK_FAQ&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=Pmqn82Jp7%2FGZuwY6IZ5ipdL0qa8vlnHpqEar9fDkUjk%3D&reserved=0
>
> Search the list archives at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtkusers&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=B6DlpR1Z4bStYhDE4jPKthNVzS7f%2BWIkcl2roYr3Z9E%3D&reserved=0
>
> Follow this link to subscribe/unsubscribe:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fvtkusers&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=q5CzMjBx1OH7rByxI0E1gaDDKYSnHx292eNNVf9rcIQ%3D&reserved=0
_______________________________________________
Powered by https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=PeaSVC7fX37vaEEQwDU9tjq%2FRKKkqqekeYXkr1xuvBA%3D&reserved=0

Visit other Kitware open-source projects at https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=3RrDlN1d5fM25xQ9EsSRczIGHKV3dBkig4LeYNLuX%2B0%3D&reserved=0

Please keep messages on-topic and check the VTK FAQ at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vtk.org%2FWiki%2FVTK_FAQ&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=Pmqn82Jp7%2FGZuwY6IZ5ipdL0qa8vlnHpqEar9fDkUjk%3D&reserved=0

Search the list archives at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtkusers&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=B6DlpR1Z4bStYhDE4jPKthNVzS7f%2BWIkcl2roYr3Z9E%3D&reserved=0

Follow this link to subscribe/unsubscribe:
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fvtkusers&data=02%7C01%7Classo%40queensu.ca%7C1e8d31503e08484147da08d65cf4124d%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636798600696862805&sdata=q5CzMjBx1OH7rByxI0E1gaDDKYSnHx292eNNVf9rcIQ%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181208/66782eb6/attachment.html>


More information about the vtkusers mailing list