[vtkusers] vtkPLYWriter : vertices are not generated in a the PLY file
MOUSSAUD David 244079
David.MOUSSAUD at cea.fr
Thu Jan 7 09:55:20 EST 2016
Hi all,
I've got a problem to generate a simple ply file with 4 vertices.
Here how i proceed :
// Setup points
points = vtkSmartPointer<vtkPoints>::New();
// Setup the colors array
colors = vtkSmartPointer<vtkUnsignedCharArray>::New();
colors->SetNumberOfComponents(3);
colors->SetName("Colors");
// create a vertex
vertex = vtkSmartPointer<vtkVertex>::New();
// list of all the vertices
vertices= vtkSmartPointer<vtkCellArray>::New();
/* Create a PLY Writer */
plyWriter = vtkSmartPointer<vtkPLYWriter>::New();
// Create a polydata object and add everything to it
polydata = vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
polydata->SetVerts(vertices);
polydata->GetPointData()->SetScalars(colors);
Then here how i create my vertices and how i set them :
points->Resize(4);
points->SetPoint(0, 0.0, 0.0, 0.0);
points->SetPoint(1, 1.0, 0.0, 0.0);
points->SetPoint(2, 0.0, 1.0, 0.0);
points->SetPoint(3, 0.0, 0.0, 1.0);
vertices->Initialize();
vertex->GetPointIds()->SetId(0,0);
vertices->InsertNextCell(vertex);
vertex->GetPointIds()->SetId(0,1);
vertices->InsertNextCell(vertex);
vertex->GetPointIds()->SetId(0,2);
vertices->InsertNextCell(vertex);
vertex->GetPointIds()->SetId(0,3);
vertices->InsertNextCell(vertex);
colors->Initialize();
colors->InsertNextTuple3(255,0,0);
colors->InsertNextTuple3(0,255,0);
colors->InsertNextTuple3(0,0,255);
colors->InsertNextTuple3(255,255,255);
QString plyFilePath = "output.ply";
std::string filename = plyFilePath.toStdString();
plyWriter->SetFileName(filename.c_str());
plyWriter->SetInputData(polydata);
plyWriter->SetColorModeToUniformPointColor();
plyWriter->SetArrayName("Colors");
plyWriter->SetFileTypeToASCII();
plyWriter->Write();
I've checked that the 4 vertex are well displayed (cf screenshot).
Unfortunately, my ply file shows 0 vertex.
ply
format ascii 1.0
comment VTK generated PLY File
obj_info vtkPolyData points and polygons: vtk4.0
element vertex 0
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
element face 0
property list uchar int vertex_indices
end_header
I'm using vtk 6.3.
If someone has already meet this problem or know the solution ...
Thanks for your time,
Best regards,
David MOUSSAUD.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160107/dd15e5d3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4Vertices_PlyWriter.png
Type: image/png
Size: 25232 bytes
Desc: 4Vertices_PlyWriter.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160107/dd15e5d3/attachment-0001.png>
More information about the vtkusers
mailing list