MEPP2 Project
Testing
CGAL
Surface_mesh
test_generic_writer_surfacemesh.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/Surface_mesh.h>
13
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
14
#include "
FEVV/Wrappings/Geometry_traits_cgal_surface_mesh.h
"
15
#include "
FEVV/Wrappings/Graph_traits_extension_cgal_surface_mesh.h
"
16
17
#include "
FEVV/Wrappings/properties_surface_mesh.h
"
18
#include "
FEVV/Filters/Generic/generic_reader.hpp
"
19
#include "
FEVV/Filters/Generic/generic_writer.hpp
"
20
21
#include "
FEVV/Tools/IO/FileUtilities.hpp
"
22
#include "
Testing/Utils/utils_are_meshes_identical.hpp
"
23
#include "
Testing/Utils/utils_identical_text_based_files.hpp
"
24
25
#include <iostream>
26
#include <string>
27
28
29
using
CGALKernel
= CGAL::Cartesian< double >;
30
using
CGALPoint
= CGALKernel::Point_3;
31
using
MeshT
= CGAL::Surface_mesh< CGALPoint >;
32
33
34
int
35
main
(
int
argc,
const
char
**argv)
36
{
37
if
(argc != 4)
38
{
39
std::cout <<
"Load a mesh from an input file using the generic reader, "
40
"write it to an output file using the generic writer, then "
41
"compare the output file with a reference file."
42
<< std::endl;
43
std::cout <<
"Usage: "
<< argv[0]
44
<<
" input_mesh_file output_mesh_file reference_mesh_file"
45
<< std::endl;
46
std::cout <<
"Example: "
<< argv[0]
47
<<
" airplane.off airplane.out.obj airplane.ref.obj"
48
<< std::endl;
49
return
EXIT_FAILURE;
50
}
51
52
std::string input_file_path = argv[1];
53
std::string output_file_path = argv[2];
54
std::string reference_file_path = argv[3];
55
56
//--------------------------------------------------
57
58
// read mesh from file
59
MeshT
m;
60
FEVV::PMapsContainer
pmaps;
61
FEVV::Filters::read_mesh
(input_file_path, m, pmaps);
62
63
// write mesh to file
64
FEVV::Filters::write_mesh
(output_file_path, m, pmaps);
65
66
// check output file
67
std::cout <<
"Comparing output file '"
<< output_file_path
68
<<
"' with reference file '"
<< reference_file_path <<
"'..."
69
<< std::endl;
70
71
if
(
FEVV::FileUtils::has_extension
(output_file_path,
".off"
) ||
72
FEVV::FileUtils::has_extension
(output_file_path,
".coff"
))
73
{
74
// use OFF file comparator
75
if
(!
are_meshes_equal
(output_file_path, reference_file_path,
false
))
76
{
77
std::cout <<
"Files are different!"
<< std::endl;
78
return
EXIT_FAILURE;
79
}
80
}
81
else
82
{
83
// use text file comparator
84
if
(!
identical_text_based_files
(output_file_path, reference_file_path))
85
{
86
std::cout <<
"Files are different!"
<< std::endl;
87
return
EXIT_FAILURE;
88
}
89
}
90
91
std::cout <<
"Files are identical."
<< std::endl;
92
93
return
0;
94
}
generic_reader.hpp
main
int main(int argc, const char **argv)
Definition:
test_generic_writer_surfacemesh.cpp:35
utils_identical_text_based_files.hpp
Graph_traits_extension_cgal_surface_mesh.h
Geometry_traits_cgal_surface_mesh.h
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
CGALKernel
CGAL::Cartesian< double > CGALKernel
Definition:
boolops_enriched_polyhedron.hpp:100
properties_surface_mesh.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
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
CGALPoint
CGALKernel::Point_3 CGALPoint
Definition:
test_generic_writer_surfacemesh.cpp:30
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
Generated by
1.8.20