MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / main

Function main

tools/converter.cpp:203–308  ·  view source on GitHub ↗

* Parse input files and options. Calls the right conversion function. * @param argc[in] * @param argv[in] * @return 0 on success, any other value on failure. */

Source from the content-addressed store, hash-verified

201 * @return 0 on success, any other value on failure.
202 */
203int
204main (int argc,
205 char** argv)
206{
207 // Display help
208 if (pcl::console::find_switch (argc, argv, "-h") != 0 || pcl::console::find_switch (argc, argv, "--help") != 0)
209 {
210 displayHelp (argc, argv);
211 return (0);
212 }
213
214 // Parse all files and options
215 std::vector<std::string> supported_extensions;
216 supported_extensions.emplace_back("obj");
217 supported_extensions.emplace_back("pcd");
218 supported_extensions.emplace_back("ply");
219 supported_extensions.emplace_back("stl");
220 supported_extensions.emplace_back("vtk");
221 std::vector<int> file_args;
222 for (int i = 1; i < argc; ++i)
223 for (const auto &supported_extension : supported_extensions)
224 if (boost::algorithm::ends_with(argv[i], supported_extension))
225 {
226 file_args.push_back(i);
227 break;
228 }
229
230 std::string parsed_output_type;
231 pcl::console::parse_argument (argc, argv, "-f", parsed_output_type);
232 pcl::console::parse_argument (argc, argv, "--format", parsed_output_type);
233 bool cloud_output (false);
234 if (pcl::console::find_switch (argc, argv, "-c") != 0 ||
235 pcl::console::find_switch (argc, argv, "--cloud") != 0)
236 cloud_output = true;
237
238 // Make sure that we have one input and one output file only
239 if (file_args.size() != 2)
240 {
241 PCL_ERROR ("Wrong input/output file count!\n");
242 displayHelp (argc, argv);
243 return (-1);
244 }
245
246 // Convert parsed output type to output type
247 int output_type (BINARY);
248 if (!parsed_output_type.empty ())
249 {
250 if (parsed_output_type == "ascii")
251 output_type = ASCII;
252 else if (parsed_output_type == "binary")
253 output_type = BINARY;
254 else if (parsed_output_type == "binary_compressed")
255 output_type = BINARY_COMPRESSED;
256 else
257 {
258 PCL_ERROR ("Wrong output type!\n");
259 displayHelp (argc, argv);
260 return (-1);

Callers

nothing calls this directly

Calls 11

displayHelpFunction · 0.85
parse_argumentFunction · 0.85
saveMeshFunction · 0.85
loadFunction · 0.85
savePointCloudFunction · 0.85
emplace_backMethod · 0.80
getFieldsListFunction · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected