<html><head></head><body><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">Hi All,</div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">I have a .ply file and need to visualize it in C++. I tried paraview in order to get the output view and I could see the visualization. With VTK, I used the below code to read, write and visualize the .ply file but I do not see anything on Render Window. The window is  blank and also the output file is in different format probably binary. Please help me to get the visualization the render window. Thanks<br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">Few lines of my .ply file <br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">input.ply:<br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><span>ply<br>format ascii 1.0<br>element vertex 1444314<br>property float x<br>property float y<br>property float z<br>property uchar red<br>property uchar green<br>property uchar blue<br>property uchar alpha<br>end_header<br>9.629254 11.183217 2.379896 120 138 143 0<br>9.687406 11.172439 2.375881 115 133 140 0<br>9.896527 11.479791 1.872450 32 40 48 0<br>9.750688 11.167464 2.372992 122 138 145 0<br>9.943034 11.452575 1.865112 36 34 57 0<br>9.825553 11.175802 2.372624 119 134 142 0<br>9.907058 11.464114 1.311501 43 60 71 0</span><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">Code:</div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">//vtkvisualization.cxx</div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><span> <span>#include <vtkPolyData.h><br>#include <vtkPolyData.h><br>#include <vtkPLYReader.h><br>#include <vtkPLYWriter.h><br>#include <vtkNamedColors.h><br>#include <vtkSmartPointer.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br>#include <vtkCamera.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindowInteractor.h><br>#include <array><br><br>int main ( int argc, char *argv[] )<br>{<br><br><br>  vtkSmartPointer<vtkNamedColors> colors =<br>      vtkSmartPointer<vtkNamedColors>::New();<br><br>  // Set the background color.<br>  std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};<br>  //colors->SetName("RGB");<br>  colors->SetColor("BkgColor", bkg.data());  <br><br><br>  //defining source<br>  if(argc != 2)<br>    {<br>    std::cout << "Usage: " << argv[0] << "  Filename(.ply)" << std::endl;<br>    return EXIT_FAILURE;<br>    }<br><br>  std::string inputFilename = argv[1];<br><br>  vtkSmartPointer<vtkPLYReader> reader =<br>    vtkSmartPointer<vtkPLYReader>::New();<br><br>  reader->SetFileName ( inputFilename.c_str() );<br>  reader->Update();<br><br>  <br>//writing to a file<br>  vtkSmartPointer<vtkPLYWriter> plyWriter =<br>    vtkSmartPointer<vtkPLYWriter>::New();<br>  plyWriter->SetFileName("output.ply");<br>  //plyWriter->SetArrayName("RGB");<br>  plyWriter->SetInputData(reader->GetOutput());<br>  plyWriter->Write();<br><br>  // Visualize steps:<br><br>  //defining mapper<br>  vtkSmartPointer<vtkPolyDataMapper> mapper =<br>    vtkSmartPointer<vtkPolyDataMapper>::New();<br>  mapper->SetInputConnection(reader->GetOutputPort());<br>  <br>  //defining actor<br>  vtkSmartPointer<vtkActor> actor =<br>    vtkSmartPointer<vtkActor>::New();<br>  actor->SetMapper(mapper);<br><br>  //defining renderer<br>  // The renderer generates the image<br>  // which is then displayed on the render window.<br>  // It can be thought of as a scene to which the actor is added    <br>  vtkSmartPointer<vtkRenderer> renderer =<br>    vtkSmartPointer<vtkRenderer>::New();<br>  renderer->AddActor(actor); //i have put the actor here to tryout<br>  renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());<br>  //renderer->SetBackground(0.1804,0.5451,0.3412); // Sea green<br> // Zoom in a little by accessing the camera and invoking its "Zoom" method.<br>  renderer->ResetCamera();<br>  renderer->GetActiveCamera()->Zoom(2.5);<br><br>  //defining rendering window<br>  // The render window is the actual GUI window<br>  // that appears on the computer screen<br>  vtkSmartPointer<vtkRenderWindow> renderWindow =<br>    vtkSmartPointer<vtkRenderWindow>::New();<br>  renderWindow->SetSize(300, 300);<br>  renderWindow->AddRenderer(renderer);<br>  renderWindow->SetWindowName("Visualization of ply file");<br><br>  //defining interactor<br>  // The render window interactor captures mouse events<br>  // and will perform appropriate camera or actor manipulation<br>  // depending on the nature of the events.<br>  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>    vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>  renderWindowInteractor->SetRenderWindow(renderWindow);<br><br>  //renderer->AddActor(actor);// i think this function should be in renderer, needs to check<br>  <br>  <br><br>  renderWindow->Render();<br>// This starts the event loop and as a side effect causes an initial render.<br>  renderWindowInteractor->Start();<br><br>  return EXIT_SUCCESS;<br>}</span></span><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">CMakeLists.txt:</div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><span>cmake_minimum_required(VERSION 2.8)<br><br>PROJECT(vtkvisualization)<br><br>find_package(VTK REQUIRED)<br>include(${VTK_USE_FILE})<br><br>add_executable(vtkvisualization MACOSX_BUNDLE vtkvisualization.cxx )<br><br></span><div><span>target_link_libraries(vtkvisualization ${VTK_LIBRARIES})<br></span></div><div><br></div><div><br><span></span></div></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><span><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">output.ply:</div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><span>ply<br>format binary_little_endian 1.0<br>comment VTK generated PLY File<br>obj_info vtkPolyData points and polygons: vtk4.0<br>element vertex 1444314<br>property float x<br>property float y<br>property float z<br>element face 0<br>property list uchar int vertex_indices<br>end_header<br></span><div><span>mAu\EE2A7P@\9D\FFAO\C22Ao@-XA9\AD7Aq\AC\EF?\D1A\EF\AD2A\DF@\ABA\BF=7A\FD\BB\EE?w5A\D02A\D9@O\83Am7ADߧ?N
 
A\C6$7A\84-\EE?\82NA\D8\D12A{\BB@\9F\D9A\98{7A\94\DBB?"vA\88:7A\BA\A7?se!A$U7A\C7\F1\ED?\818A՚2A:t@R\D5AeV7A\E4A?b\A6
 A\80S7A\E0\84\A6?a"A\FE.7A\C5W\ED? 
AR2A6!@zA\C67Av\FDR>\D9A\C5>7A__??S\80!A;   
 7A\B8\AD\A5?.p#A<br></span></div><div><br><span></span></div></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div></span><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div><div class="ydp238269b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><br></div></body></html>