[vtkusers] vtkPLYWriter : vertices are not generated in a the PLY file

MOUSSAUD David 244079 David.MOUSSAUD at cea.fr
Mon Jan 11 11:13:35 EST 2016


Hello,

No, due to project time constraint, i had to implement my method to generate the PLY file.
By the way, the stlWriter works very well. It uses the same vtkPolyData that my plyWriter.

stlWriter->SetFileName(filename.c_str());
stlWriter->SetInputData(polydata);
stlWriter->SetFileTypeToBinary();
stlWriter->Write();

I have a small example that figure out that problem but it is based on Qt widgets and qmake. Are you interested in ?
Otherwise, maybe you could enhance the examples for C++ that shows how a plyWriter can be used with a vtkPolyData ?

Best regards,
David.


________________________________________
De : Cory Quammen [cory.quammen at kitware.com]
Envoyé : lundi 11 janvier 2016 15:17
À : MOUSSAUD David 244079
Cc : vtkusers at vtk.org
Objet : Re: [vtkusers] vtkPLYWriter : vertices are not generated in a the PLY file

David,

Have you made any progress on this issue?

I can generate a Point Source in ParaView and save it to a PLY file.
It saved the point locations just fine. By the way, ParaView uses the
vtkPLYWriter to write points.

I don't see anything odd in the reader that would cause me to think
your points wouldn't get written.

If you are still having trouble, could you post a self-contained .cxx
file and CMakeLists.txt file? That will make it easier for us to
diagnose what is going on.

Thanks,
Cory

On Thu, Jan 7, 2016 at 11:44 AM, MOUSSAUD David 244079
<David.MOUSSAUD at cea.fr> wrote:
> 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.



--
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160111/f692ec8f/attachment.html>


More information about the vtkusers mailing list