MEPP2 Project
test_reader_writer_pcl.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 
16 
19 
23 
24 #include <iostream>
25 #include <string>
26 
27 
28 // main
29 int main(int argc, char *argv[])
30 {
31  // parse arguments
32  if(argc != 4)
33  {
34  std::cout << "Usage: " << argv[0]
35  << " input_mesh_filename output_mesh_filename reference_mesh_filename" << std::endl;
36  std::cout << "Example: " << argv[0] << " ../Testing/Data/tetra.xyz tetra.out.ply tetra.out.ref.ply"
37  << std::endl;
38  return EXIT_FAILURE;
39  }
40  std::string input_file = argv[1];
41  std::string output_file = argv[2];
42  std::string reference_file = argv[3];
43 
44  //----------------------------------
45 
46  // create point cloud
47  typedef FEVV::PCLPointCloud PointCloudT;
48  PointCloudT pc;
49 
50  // load point cloud
51  FEVV::PMapsContainer pmaps_bag;
52  FEVV::Filters::read_mesh(input_file, pc, pmaps_bag);
53 
54  //----------------------------------
55 
56  // save point cloud
57  FEVV::Filters::write_mesh(output_file, pc, pmaps_bag);
58 
59  //----------------------------------
60 
61  // check output file
62  std::cout << "Comparing output file '" << output_file
63  << "' with reference file '" << reference_file << "'..."
64  << std::endl;
65 
66  if(FEVV::FileUtils::has_extension(output_file, ".off") ||
67  FEVV::FileUtils::has_extension(output_file, ".coff"))
68  {
69  // use OFF file comparator
70  if(!are_meshes_equal(output_file, reference_file, false))
71  {
72  std::cout << "Files are different!" << std::endl;
73  return EXIT_FAILURE;
74  }
75  }
76  else
77  {
78  // use text file comparator
79  if(!identical_text_based_files(output_file, reference_file))
80  {
81  std::cout << "Files are different!" << std::endl;
82  return EXIT_FAILURE;
83  }
84  }
85 
86  std::cout << "Files are identical." << std::endl;
87 
88  return 0;
89 }
pcl_point_cloud_writer.hpp
Geometry_traits_pcl_point_cloud.h
Graph_properties_pcl_point_cloud.h
utils_identical_text_based_files.hpp
FEVV::PCLPointCloud
pcl::PointCloud< PCLEnrichedPoint > PCLPointCloud
Definition: DataStructures_pcl_point_cloud.h:28
main
int main(int argc, char *argv[])
Definition: test_reader_writer_pcl.cpp:29
are_meshes_equal
bool are_meshes_equal(std::string filename_a, std::string filename_b, bool verbose)
Definition: utils_are_meshes_identical.inl:925
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
identical_text_based_files
bool identical_text_based_files(std::string filename_a, std::string filename_b, const std::vector< std::string > &skip=std::vector< std::string >())
Definition: utils_identical_text_based_files.hpp:27
DataStructures_pcl_point_cloud.h
FEVV::Filters::read_mesh
void read_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps, bool=false)
Load mesh from file.
Definition: cgal_point_set_reader.hpp:110
pcl_point_cloud_reader.hpp
properties_pcl_point_cloud.h
FEVV::Filters::write_mesh
void write_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps)
Write mesh to file.
Definition: cgal_point_set_writer.hpp:42
utils_are_meshes_identical.hpp
FEVV::FileUtils::has_extension
bool has_extension(const std::string &file_name)
Definition: FileUtilities.hpp:58
FileUtilities.hpp