title: Dicom to .PLY Conversion using VTK
body: <p>I am trying to convert a DICOM file into PLY format using VTK to further convert it into .pcd (point cloud format). I have followed the example provided <a href="https://lorensen.github.io/VTKExamples/site/Cxx/IO/ConvertFile/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>However in the above example the code is supposed to change .vtu format into .ply format. I changed the code to convert the .dcm format into .ply format as shown below. The build succeeded and the exe file is working as well, however, it does not write the required output file. Can anyone please point out where did I go wrong??</p>
  
  <pre><code>#include &lt;vtkSmartPointer.h&gt;
  #include &lt;vtkPolyData.h&gt;
  #include &lt;vtkDICOMImageReader.h&gt;
  #include &lt;vtkXMLPolyDataReader.h&gt;
  #include &lt;vtkPLYWriter.h&gt;
  
  int main(int argc, char *argv[])
  {
    if(argc &lt; 3)
    {
      std::cerr &lt;&lt; "Required arguments: input.vtp output.ply" &lt;&lt; std::endl;
      return EXIT_FAILURE;
    }
  
    std::string inputFileName = argv[1];
    std::string outputFileName = argv[2];
  
    // Read the DICOM file in the specified directory.
    vtkSmartPointer&lt;vtkDICOMImageReader&gt; reader = 
  vtkSmartPointer&lt;vtkDICOMImageReader&gt;::New();
    reader-&gt;SetFileName(inputFilename.c_str());
    reader-&gt;Update();
  
  
    vtkSmartPointer&lt;vtkPLYWriter&gt; writer = vtkSmartPointer&lt;vtkPLYWriter&gt;::New();
    writer-&gt;SetFileName(outputFileName.c_str());
    writer-&gt;SetInputConnection(reader-&gt;GetOutputPort());
    writer-&gt;Update();
  
    return EXIT_SUCCESS;
  }
  </code></pre>