---[ */
| 74 | |
| 75 | /* ---[ */ |
| 76 | int |
| 77 | main (int argc, char** argv) |
| 78 | { |
| 79 | print_info ("Convert a VTK file to PCD format. For more information, use: %s -h\n", argv[0]); |
| 80 | |
| 81 | if (argc < 3) |
| 82 | { |
| 83 | printHelp (argc, argv); |
| 84 | return (-1); |
| 85 | } |
| 86 | |
| 87 | // Parse the command line arguments for .pcd and .vtk files |
| 88 | std::vector<int> pcd_file_indices = parse_file_extension_argument (argc, argv, ".pcd"); |
| 89 | std::vector<int> vtk_file_indices = parse_file_extension_argument (argc, argv, ".vtk"); |
| 90 | if (pcd_file_indices.size () != 1 || vtk_file_indices.size () != 1) |
| 91 | { |
| 92 | print_error ("Need one input VTK file and one output PCD file.\n"); |
| 93 | return (-1); |
| 94 | } |
| 95 | |
| 96 | // Load the VTK file |
| 97 | TicToc tt; |
| 98 | print_highlight ("Loading "); print_value ("%s ", argv[vtk_file_indices[0]]); |
| 99 | |
| 100 | vtkSmartPointer<vtkPolyDataReader> reader = vtkSmartPointer<vtkPolyDataReader>::New (); |
| 101 | reader->SetFileName (argv[vtk_file_indices[0]]); |
| 102 | reader->Update (); |
| 103 | vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput (); |
| 104 | print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", polydata->GetNumberOfPoints ()); print_info (" points]\n"); |
| 105 | |
| 106 | bool copy_normals = false; |
| 107 | parse_argument (argc, argv, "-copy_normals", copy_normals); |
| 108 | PCL_INFO ("Copy normals: %s.\n", copy_normals ? "true" : "false"); |
| 109 | |
| 110 | if (copy_normals) |
| 111 | { |
| 112 | vtkSmartPointer<vtkPolyDataNormals> ng = vtkSmartPointer<vtkPolyDataNormals>::New (); |
| 113 | ng->SetInputData (polydata); |
| 114 | ng->ComputePointNormalsOn (); |
| 115 | ng->ComputeCellNormalsOff (); |
| 116 | ng->Update (); |
| 117 | polydata = ng->GetOutput (); |
| 118 | |
| 119 | pcl::PointCloud<pcl::PointNormal> cloud; |
| 120 | vtkPolyDataToPointCloud (polydata, cloud); |
| 121 | // Convert to pcd and save |
| 122 | saveCloud (argv[pcd_file_indices[0]], cloud); |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | pcl::PointCloud<pcl::PointXYZ> cloud; |
| 127 | vtkPolyDataToPointCloud (polydata, cloud); |
| 128 | // Convert to pcd and save |
| 129 | saveCloud (argv[pcd_file_indices[0]], cloud); |
| 130 | } |
| 131 | |
| 132 | return (0); |
| 133 | } |
nothing calls this directly
no test coverage detected