MEPP2 Project
test_generic_writer_openmesh.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 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 #define CGAL_USE_OM_POINTS
12 #include "FEVV/Wrappings/Geometry_traits_openmesh.h" // Always in first position for MVS 4996 warnings
13 #include <OpenMesh/Core/IO/MeshIO.hh>
14 // force usage of OpenMesh native Point type instead of CGAL Point type
15 // in point map in properties_PolyMesh_ArrayKernelT.h
16 #include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
17 #include <CGAL/boost/graph/properties_PolyMesh_ArrayKernelT.h>
19 
23 
27 
28 #include <iostream>
29 #include <string>
30 
31 
32 using MeshT = OpenMesh::PolyMesh_ArrayKernelT< /*MyTraits*/ >;
33 
34 
35 int
36 main(int argc, const char **argv)
37 {
38  if(argc != 4)
39  {
40  std::cout << "Load a mesh from an input file using the generic reader, "
41  "write it to an output file using the generic writer, then "
42  "compare the output file with a reference file."
43  << std::endl;
44  std::cout << "Usage: " << argv[0]
45  << " input_mesh_file output_mesh_file reference_mesh_file"
46  << std::endl;
47  std::cout << "Example: " << argv[0]
48  << " airplane.off airplane.out.obj airplane.ref.obj"
49  << std::endl;
50  return EXIT_FAILURE;
51  }
52 
53  std::string input_file_path = argv[1];
54  std::string output_file_path = argv[2];
55  std::string reference_file_path = argv[3];
56 
57  //--------------------------------------------------
58 
59  // read mesh from file
60  MeshT m;
62  FEVV::Filters::read_mesh(input_file_path, m, pmaps);
63 
64  // write mesh to file
65  FEVV::Filters::write_mesh(output_file_path, m, pmaps);
66 
67  // check output file
68  std::cout << "Comparing output file '" << output_file_path
69  << "' with reference file '" << reference_file_path << "'..."
70  << std::endl;
71 
72  if(FEVV::FileUtils::has_extension(output_file_path, ".off") ||
73  FEVV::FileUtils::has_extension(output_file_path, ".coff"))
74  {
75  // use OFF file comparator
76  if(!are_meshes_equal(output_file_path, reference_file_path, false))
77  {
78  std::cout << "Files are different!" << std::endl;
79  return EXIT_FAILURE;
80  }
81  }
82  else
83  {
84  // use text file comparator
85  if(!identical_text_based_files(output_file_path, reference_file_path))
86  {
87  std::cout << "Files are different!" << std::endl;
88  return EXIT_FAILURE;
89  }
90  }
91 
92  std::cout << "Files are identical." << std::endl;
93 
94  return 0;
95 }
Geometry_traits_openmesh.h
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
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
main
int main(int argc, const char **argv)
Definition: test_generic_writer_openmesh.cpp:36
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_openmesh.h
properties_openmesh.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