MEPP2 Project
test_load_dangling_edge_aif.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 //
12 // Mesh loading test using either generic reader
13 // or native readers.
14 
15 #include <iostream>
16 #include <fstream>
17 //---------------------------------------------------------
18 
19 // uncomment one at a time
20 //#define WITH_GENERIC_READER
21 //#define WITH_NATIVE_READER
22 
23 // uncomment one at a time
24 //#define USE_POLYHEDRON
25 //#define USE_SURFACEMESH
26 //#define USE_LCC
27 //#define USE_OPENMESH
28 //#define USE_AIF
29 
30 //---------------------------------------------------------
31 #if defined(FEVV_USE_CGAL) && \
32  (defined(USE_POLYHEDRON) || defined(USE_SURFACEMESH) || defined(USE_LCC))
33 #include "FEVV/DataStructures/DataStructures_cgal.h"
34 #ifdef WITH_GENERIC_READER
40 #endif
41 #endif
42 
43 #if defined(FEVV_USE_OPENMESH) && defined(USE_OPENMESH)
45 #ifdef WITH_GENERIC_READER
48 #endif
49 #endif
50 
51 #if defined(FEVV_USE_AIF) && defined(USE_AIF)
53 // \todo Inquire on the asymetry of the inclusion of the Graph_traits*.h
54 // between SurfaceMesh and OpenMesh (that only include the GraphTraits
55 // when in the WITH_GENERIC_READER section) and AIF.
58 #ifdef WITH_GENERIC_READER
61 #endif
62 #endif
63 
64 #ifdef WITH_GENERIC_READER
66 
67 std::string reader_type("generic reader");
68 #else
69 #ifdef WITH_NATIVE_READER
70 std::string reader_type("native reader");
71 #else
72 std::string reader_type("unkonwn reader");
73 #endif
74 #endif
75 
76 #ifdef USE_POLYHEDRON
78 std::string mesh_type("Polyhedron");
79 #endif
80 
81 #ifdef USE_SURFACEMESH
82 using MeshT = FEVV::MeshSurface;
83 std::string mesh_type("Surface_mesh");
84 #endif
85 
86 #ifdef USE_LCC
87 using MeshT = FEVV::MeshLCC;
88 std::string mesh_type("LCC");
89 #endif
90 
91 #ifdef USE_OPENMESH
93 std::string mesh_type("Openmesh");
94 #endif
95 
96 #ifdef USE_AIF
97 using MeshT = FEVV::MeshAIF;
98 std::string mesh_type("AIF");
99 #endif
100 
101 //---------------------------------------------------------
102 
103 #ifdef WITH_GENERIC_READER
104 
105 // with generic reader
106 void
107 load_mesh(std::string filename)
108 {
109  MeshT m;
110  FEVV::PMapsContainer pmaps_bag;
111  FEVV::Filters::read_mesh(filename, m, pmaps_bag);
112 
113  std::cout << "the mesh has " << num_vertices(m) << " vertice(s), "
114  << num_edges(m) << " edge(s), "
115 #if !defined(USE_AIF)
116  << num_halfedges(m) << " halfedge(s), "
117 #endif
118  << num_faces(m) << " face(s)." << std::endl;
119 
120  std::cout << "Done." << std::endl;
121 }
122 
123 #else
124 
125 // with native reader
126 void
127 load_mesh(std::string filename)
128 {
129 #ifdef USE_AIF
130  typedef FEVV::MeshAIFPtr ptr_mesh;
131  // Load a mesh
132  ptr_mesh pm;
133 
135  if(!(pm = in.read(filename)))
136  {
137  std::cout << "failed";
138  return;
139  }
140  MeshT m(*pm);
141 #else
142 #ifdef USE_OPENMESH
143 
144  MeshT m;
145  if(!OpenMesh::IO::read_mesh(m, filename))
146  {
147  std::cout << "failed";
148  return;
149  }
150 
151 #else
152  std::ifstream in(filename);
153  if(!in)
154  {
155  std::cout << "Unable to read file " << filename << std::endl;
156  exit(EXIT_FAILURE);
157  }
158  MeshT m;
159 #ifndef USE_LCC
160  // Polyhedron, Surface_mesh
161  in >> m;
162 #else
163  // USE_LCC
164  CGAL::load_off(m, in);
165 #endif // USE_LCC
166 
167 #endif // USE_OPENMESH
168 
169 #endif // USE_AIF
170 
171  std::cout << "the mesh has " << num_vertices(m) << " vertice(s), "
172  << num_edges(m) << " edge(s), "
173 #if !defined(USE_AIF)
174  << num_halfedges(m) << " halfedge(s), "
175 #endif
176  << num_faces(m) << " face(s)." << std::endl;
177 
178  std::cout << "Done." << std::endl;
179 }
180 
181 #endif
182 
183 
184 int
185 main(int narg, char **argv)
186 {
187  if(narg < 2)
188  {
189  std::cout << "Usage: " << argv[0]
190  << " filename; filename being an off or vtk file." << std::endl;
191  exit(EXIT_FAILURE);
192  }
193 
194  std::cout << "Loading mesh using " << reader_type << " and " << mesh_type
195  << std::endl;
196 
197  load_mesh(argv[1]);
198 
199  return 0;
200 }
Graph_traits_extension_aif.h
FEVV::DataStructures::AIF::num_vertices
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertices_size_type num_vertices(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns an upper bound of the number of vertices of the mesh.
Definition: Graph_traits_aif.h:191
FEVV::MeshAIFPtr
FEVV::DataStructures::AIF::AIFMeshReader::ptr_output MeshAIFPtr
Definition: DataStructures_aif.h:20
Geometry_traits_openmesh.h
FEVV::MeshLCC
CGAL::Linear_cell_complex_for_combinatorial_map< 2, 3, CGALLCCTraits, CGALItem > MeshLCC
Definition: DataStructures_cgal_linear_cell_complex.h:43
generic_reader.hpp
FEVV::DataStructures::AIF::AIFMeshReader::read
ptr_output read(const std::string &filePath)
Definition: AIFMeshReader.inl:50
Graph_traits_extension_cgal_surface_mesh.h
Geometry_traits_cgal_surface_mesh.h
main
int main(int narg, char **argv)
Definition: test_load_dangling_edge_aif.cpp:185
FEVV::MeshSurface
CGAL::Surface_mesh< CGALPoint > MeshSurface
Definition: DataStructures_cgal_surface_mesh.h:23
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
Geometry_traits_cgal_polyhedron_3.h
Graph_properties_aif.h
FEVV::DataStructures::AIF::num_faces
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::faces_size_type num_faces(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns an upper bound of the number of faces of the graph.
Definition: Graph_traits_aif.h:283
load_mesh
void load_mesh(std::string filename)
Definition: test_load_dangling_edge_aif.cpp:127
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_aif.h
FEVV::DataStructures::AIF::num_edges
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edges_size_type num_edges(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns an upper bound of the number of edges of the graph.
Definition: Graph_traits_aif.h:257
Graph_traits_extension_cgal_polyhedron_3.h
reader_type
std::string reader_type("unkonwn reader")
DataStructures_aif.h
reader_type
AIFMeshReader reader_type
Definition: test_reader_writer_aif.cpp:22
DataStructures_openmesh.h
Graph_traits_extension_openmesh.h
Geometry_traits_aif.h
FEVV::MeshOpenMesh
OpenMesh::PolyMesh_ArrayKernelT< MyTraits > MeshOpenMesh
Definition: DataStructures_openmesh.h:51
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::DataStructures::AIF::AIFMeshReader
This class represents an AIFMesh object reader. An AIFMeshReader reads a mesh file (....
Definition: AIFMeshReader.hpp:37
FEVV::MeshPolyhedron
CGAL::Polyhedron_3< CGALKernel, CGAL::Polyhedron_items_with_id_3 > MeshPolyhedron
Definition: DataStructures_cgal_polyhedron_3.h:33
FEVV::MeshAIF
FEVV::DataStructures::AIF::AIFMesh MeshAIF
Definition: DataStructures_aif.h:19
Geometry_traits_cgal_linear_cell_complex.h