MEPP2 Project
test_copy_graph.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 
15 
16 #include <iostream>
17 #include <string>
18 #include <vector>
19 
20 
21 template< typename MeshT >
22 int
23 test_copy_graph(int argc, const char **argv)
24 {
25  // parse arguments
26 
27  if(argc < 4)
28  {
29  std::cout << "Load a mesh, copy it in a new mesh, then save the new mesh."
30  << std::endl
31  << "Usage: " << argv[0]
32  << " input_mesh_file output_mesh_file reference_mesh_file"
33  << std::endl
34  << "Example: " << argv[0]
35  << " airplane.off airplane_copy.off airplane_copy.ref.off"
36  << std::endl;
37  return EXIT_FAILURE;
38  }
39 
40  std::string input_file_path = argv[1];
41  std::string output_file_path = argv[2];
42  std::string reference_file_path = argv[3];
43 
44  // display parameters summary
45  std::cout << "\nParameters summary:" << std::endl
46  << " - input file: " << input_file_path << std::endl
47  << " - output file: " << output_file_path << std::endl
48  << " - reference file: " << reference_file_path << std::endl
49  << std::endl;
50 
51  //--------------------------------------------------
52 
53  // read mesh from file
54  MeshT m;
55  FEVV::PMapsContainer pmaps_bag;
56  FEVV::Filters::read_mesh(input_file_path, m, pmaps_bag);
57 
58  // copy mesh
59  MeshT m2;
60  FEVV::PMapsContainer pmaps_bag2;
61  FEVV::Filters::copy_graph(m, pmaps_bag, m2, pmaps_bag2);
62 
63  // save the copied mesh
64  FEVV::Filters::write_mesh(output_file_path, m2, pmaps_bag2);
65 
66  // check output file
67  std::cout << "Comparing output file" << std::endl
68  << " '" << output_file_path << "'" << std::endl
69  << "with reference file" << std::endl
70  << " '" << reference_file_path << "'" << std::endl
71  << "..." << std::endl;
72 
73  if(FEVV::FileUtils::has_extension(output_file_path, ".off") ||
74  FEVV::FileUtils::has_extension(output_file_path, ".coff"))
75  {
76  // use OFF file comparator
77  if(! are_meshes_equal(output_file_path,
78  reference_file_path,
79  false))
80  {
81  std::cout << "Files are different!" << std::endl;
82  return EXIT_FAILURE;
83  }
84  }
85  else
86  {
87  // use text file comparator
88  std::vector< std::string > skip = { "mtllib" };
89  if(! identical_text_based_files(output_file_path,
90  reference_file_path,
91  skip))
92  {
93  std::cout << "Files are different!" << std::endl;
94  return EXIT_FAILURE;
95  }
96  }
97 
98  std::cout << "Files are identical." << std::endl;
99 
100  return 0;
101 }
FEVV::Filters::copy_graph
void copy_graph(const FEVV::CGALPointSet &pc_s, const FEVV::PMapsContainer &pmaps_s, PointCloudT &pc_t, FEVV::PMapsContainer &pmaps_t, const Parameters &params, const GeometryTraitsS &gt_s, const GeometryTraitsT &gt_t)
Overloading of copy_graph() for CGAL Point Set copy from.
Definition: copy_graph_cgal_point_set.hpp:43
utils_identical_text_based_files.hpp
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
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
test_copy_graph
int test_copy_graph(int argc, const char **argv)
Definition: test_copy_graph.inl:23
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::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
FEVV::FileUtils::has_extension
bool has_extension(const std::string &file_name)
Definition: FileUtilities.hpp:58
FileUtilities.hpp