MEPP2 Project
test_generic_writer_polyhedron.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 #include <CGAL/Cartesian.h>
12 #include <CGAL/Polyhedron_3.h>
13 #include <CGAL/Polyhedron_items_with_id_3.h>
14 #include <CGAL/IO/Polyhedron_iostream.h>
15 #include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
18 
22 
26 
27 #include <iostream>
28 #include <string>
29 
30 
31 using CGALKernel = CGAL::Cartesian< double >;
32 using MeshT =
33  CGAL::Polyhedron_3< CGALKernel, CGAL::Polyhedron_items_with_id_3 >;
34 
35 
36 int
37 main(int argc, const char **argv)
38 {
39  if(argc != 4)
40  {
41  std::cout << "Load a mesh from an input file using the generic reader, "
42  "write it to an output file using the generic writer, then "
43  "compare the output file with a reference file."
44  << std::endl;
45  std::cout << "Usage: " << argv[0]
46  << " input_mesh_file output_mesh_file reference_mesh_file"
47  << std::endl;
48  std::cout << "Example: " << argv[0]
49  << " airplane.off airplane.out.obj airplane.ref.obj"
50  << std::endl;
51  return EXIT_FAILURE;
52  }
53 
54  std::string input_file_path = argv[1];
55  std::string output_file_path = argv[2];
56  std::string reference_file_path = argv[3];
57 
58  //--------------------------------------------------
59 
60  // read mesh from file
61  MeshT m;
63  FEVV::Filters::read_mesh(input_file_path, m, pmaps);
64 
65  // write mesh to file
66  FEVV::Filters::write_mesh(output_file_path, m, pmaps);
67 
68  // check output file
69  std::cout << "Comparing output file '" << output_file_path
70  << "' with reference file '" << reference_file_path << "'..."
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, reference_file_path, false))
78  {
79  std::cout << "Files are different!" << std::endl;
80  return EXIT_FAILURE;
81  }
82  }
83  else
84  {
85  // use text file comparator
86  if(!identical_text_based_files(output_file_path, reference_file_path))
87  {
88  std::cout << "Files are different!" << std::endl;
89  return EXIT_FAILURE;
90  }
91  }
92 
93  std::cout << "Files are identical." << std::endl;
94 
95  return 0;
96 }
generic_reader.hpp
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
Geometry_traits_cgal_polyhedron_3.h
properties_polyhedron_3.h
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
CGALKernel
CGAL::Cartesian< double > CGALKernel
Definition: boolops_enriched_polyhedron.hpp:100
main
int main(int argc, const char **argv)
Definition: test_generic_writer_polyhedron.cpp:37
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
Graph_traits_extension_cgal_polyhedron_3.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
generic_writer.hpp
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