PLY形式で用意された点群データをParaView標準のPLY Readerで読み込んだ際、Cell Dataが生成されないため、Render View上で点群表示が得られない。
Programmable Filterで明示的にCell Dataを追加することで、Render View上で所望の点群表示を得ることができる。
PLYデータには8bitのRGBカラー値が付与されている前提で処理を行っているが、Intensityなど他の値が付与されている場合も同様に色付け表示可能である。
RGBカラーで表示したい場合(Magnitudeベースでカラーマップを適用するのではなく、各点に付与された8bit RGB値により色表示を行いたい場合)は、Programmable Filter適用後、Object Inspector上のPropertiesタブにて‘Map Scalars’のチェックを外すこと。
動作確認バージョン
ParaView 5.9.0-RC3
Output Data Set Type
vtkPolyData (Same as Input)
Script
pdi = self.GetInput()
pdo = self.GetOutput()
c = vtk.vtkUnsignedCharArray()
c.SetName('RGB')
c.SetNumberOfComponents(3)
c.SetNumberOfTuples(pdi.GetNumberOfPoints())
rgb = pdi.GetPointData().GetArray('RGB')
pdo.Allocate(pdi.GetNumberOfPoints(), 1)
id = vtk.vtkDoubleArray()
id.SetName('id')
id.SetNumberOfComponents(1)
id.SetNumberOfTuples(pdi.GetNumberOfPoints())
for i in range(pdi.GetNumberOfPoints()):
vrt = vtk.vtkVertex()
vrt.GetPointIds().SetNumberOfIds(1)
vrt.GetPointIds().SetId(0, i)
pdo.InsertNextCell(vrt.GetCellType(), vrt.GetPointIds())
c.SetTuple3(i, rgb.GetValue(i * 3), rgb.GetValue(i * 3 + 1), rgb.GetValue(i * 3 + 2))
pdo.GetPointData().AddArray(c)
コメントを残す