[vtkusers] vtkPLYWriter : vertices are not generated in a the PLY file
MOUSSAUD David 244079
David.MOUSSAUD at cea.fr
Thu Jan 7 11:44:34 EST 2016
Yes it works, I have already success to generate one (without using vtk library).
After the line "end_header', you have to write line by line the 3 coordinates of the vertices and theirs RGB colors (3 more numbers)
You don't need to generate the faces if it is set to the 0 value in the header.
Best Regards,
David MOUSSAUD
________________________________________
De : Cory Quammen [cory.quammen at kitware.com]
Envoyé : jeudi 7 janvier 2016 16:58
À : MOUSSAUD David 244079
Cc : vtkusers at vtk.org
Objet : Re: [vtkusers] vtkPLYWriter : vertices are not generated in a the PLY file
Hi David,
Can you confirm that the PLY file format supports single-vertex cells
like this? My perusal of the PLY documentation didn't reveal anything.
Thanks,
Cory
On Thu, Jan 7, 2016 at 9:55 AM, MOUSSAUD David 244079
<David.MOUSSAUD at cea.fr> wrote:
> 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.
>
>
> _______________________________________________
> 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:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
--
Cory Quammen
R&D Engineer
Kitware, Inc.
More information about the vtkusers
mailing list