MEPP2 Project
test_point_cloud_curvature.inl
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 Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, 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 
13 
15 
16 #include <string>
17 
21 template< typename PointCloud >
22  int
23 test_point_cloud_curvature(int argc, const char **argv)
24 {
25  // parse arguments
26 
27  if(argc < 3)
28  {
29  std::cout << "Load a point cloud then apply the Point Cloud Curvature"
30  << " filter."
31  << std::endl;
32  std::cout << "Usage: " << argv[0]
33  << " input_point_cloud_file output_file.ply"
34  << " [nearest_neighbors_number [reference_file]]"
35  << std::endl;
36  std::cout << "Examples: \n"
37  << argv[0] << " casting.xyz casting.curvature.ply\n"
38  << argv[0] << " casting.xyz casting.curvature.ply 15\n"
39  << argv[0] << " casting.xyz casting.curvature.ply 15"
40  " casting.curvature.ref.ply\n"
41  << std::endl;
42 
43  return EXIT_FAILURE;
44  }
45 
46  std::string input_file_path = argv[1];
47  std::string output_file_path = argv[2];
48  std::string reference_file_path;
49  unsigned int k = 15;
50  if(argc > 3)
51  k = static_cast<unsigned int>(std::stoi(argv[3]));
52  if(argc > 4)
53  reference_file_path = argv[4];
54 
55  // display parameters summary
56  std::cout << "\nParameters summary:" << std::endl;
57  std::cout << " - input file: " << input_file_path << std::endl;
58  std::cout << " - output file: " << output_file_path << std::endl;
59  std::cout << " - k: " << k << std::endl;
60 
61  //--------------------------------------------------
62 
63  // read point cloud from file
64  PointCloud pc;
65  FEVV::PMapsContainer pmaps_bag;
66  FEVV::Filters::read_mesh(input_file_path, pc, pmaps_bag);
67 
68  // retrieve geometry property map
69  auto pm = get(boost::vertex_point, pc);
70 
71  // create a vertex curvature property map
72  auto v_curvm = FEVV::make_vertex_property_map< PointCloud, double >(pc);
73 
74  // create a vertex color property map
75  auto v_cm = make_property_map(FEVV::vertex_color, pc);
76  put_property_map(FEVV::vertex_color, pc, pmaps_bag, v_cm);
77 
78  // apply Point Cloud Curvature filter
79  FEVV::Filters::point_cloud_curvature(pc, pm, k, 0.0, v_curvm, v_cm);
80 
81  // save the point cloud
82  std::cout << "saving point cloud with curvature to " << output_file_path
83  << std::endl;
84  FEVV::Filters::write_mesh(output_file_path, pc, pmaps_bag);
85 
86  // check output file
87  if(!reference_file_path.empty())
88  {
89  std::cout << "Comparing output file" << std::endl;
90  std::cout << " '" << output_file_path << "'" << std::endl;
91  std::cout << "with reference file" << std::endl;
92  std::cout << " '" << reference_file_path << "'" << std::endl;
93  std::cout << "..." << std::endl;
94 
95  // use text file comparator
96  if(!identical_text_based_files(output_file_path, reference_file_path))
97  {
98  std::cout << "Files are different!" << std::endl;
99  return EXIT_FAILURE;
100  }
101 
102  std::cout << "Files are identical." << std::endl;
103  }
104 
105  return 0;
106 }
107 
FEVV::put_property_map
void put_property_map(PropertyT p, const MeshT &, PMapsContainer &pmaps, const typename PMap_traits< PropertyT, MeshT >::pmap_type &pmap)
Definition: properties.h:664
point_cloud_curvature.hpp
test_point_cloud_curvature
int test_point_cloud_curvature(int argc, const char **argv)
Generic test of Point Cloud Curvature filter.
Definition: test_point_cloud_curvature.inl:23
utils_identical_text_based_files.hpp
FEVV::Filters::point_cloud_curvature
void point_cloud_curvature(const PointCloud &pc, const PointMap &pm, unsigned int k, double radius, VertexCurvatureMap &v_curvm, VertexColorMap &v_cm, const GeometryTraits &gt)
Compute the curvature for each point of the point cloud using the nearest neighbors.
Definition: point_cloud_curvature.hpp:212
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
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
FEVV::vertex_color
@ vertex_color
Definition: properties.h:47
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
boost::get
boost::property_map< FEVV::DataStructures::AIF::AIFMesh, boost::vertex_index_t >::const_type get(const boost::vertex_index_t &, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the vertex index property map of the mesh.
Definition: Graph_properties_aif.h:108
FEVV::make_property_map
PMap_traits< PropertyT, MeshT >::pmap_type make_property_map(PropertyT, const MeshT &m)
Definition: properties.h:630