MEPP2 Project
test_collapse_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.
14 
16 
19 
20 //---------------- specific code above --------------------
21 
22 //---------------- generic code below ---------------------
23 
27 
30 
31 //---------------- generic code above ---------------------
32 
33 //---------------- other code below -----------------------
34 #include <fstream>
35 #include <iostream>
36 
37 void
38 test_collapse_edge_aif(const std::string &input_file_path,
39  int source_index,
40  int target_index,
41  const std::string &output_file_path)
42 {
43  typedef boost::graph_traits< MeshT > GraphTraits;
44  typedef GraphTraits::halfedge_descriptor halfedge_descriptor;
45 
46  // read mesh from file
47  MeshT m;
48  FEVV::PMapsContainer pmaps_bag;
49  FEVV::Filters::read_mesh(input_file_path, m, pmaps_bag);
50 
51  // some check and filter application
52  halfedge_descriptor h = retrieve_halfedge(m, source_index, target_index);
53  if(h == GraphTraits::null_halfedge())
54  {
55  std::cout << "Failed to retrieve edge from " << source_index << " to "
56  << target_index << "." << std::endl;
57  std::cout << "Exiting";
58  exit(EXIT_FAILURE);
59  }
60 
61  std::cout << "Collapsing edge " << source_index << " to " << target_index
62  << "." << std::endl;
64 
65  // write mesh to file
66  FEVV::Filters::write_mesh(output_file_path, m, pmaps_bag);
67 }
68 
69 //------------------------------------------------------------------------------
70 
71 int
72 main(int narg, char **argv)
73 {
74  if(narg < 3 || narg > 4)
76  {
77  std::cout << "Usage: a.out filename; filename being an off file."
78  << std::endl;
79  exit(EXIT_FAILURE);
80  }
81 
82  std::string to_treat = argv[1];
83 
84  int deletion_case = std::stoi(std::string(argv[2]));
85  std::string output_file_name = std::string(argv[0]) + argv[2] + ".off";
86 
87  if(deletion_case == 0)
88  {
89  test_collapse_edge_aif(to_treat, 0, 1, output_file_name);
90  }
91  else if(deletion_case == 1)
92  {
93  test_collapse_edge_aif(to_treat, 3, 4, output_file_name);
94  }
95  else if(deletion_case == 2)
96  {
97  test_collapse_edge_aif(to_treat, 4, 3, output_file_name);
98  }
99 
100  if(narg == 4)
101  {
102  if(!are_meshes_equal(
103  output_file_name,
104  argv[3],
105  true)) // this test currently fails for case 0 [border edge, because
106  // this is not handled for the time being]
107  return 1; // test failed
108  }
109 
110  return 0; // test succeeded
111 }
retrieve_halfedge
boost::graph_traits< MutableFaceGraph >::halfedge_descriptor retrieve_halfedge(MutableFaceGraph &g, int source_index, int target_index)
Definition: utils_retrieve_halfedge.h:30
utils_retrieve_halfedge.h
collapse_edge.hpp
generic_reader.hpp
main
int main(int narg, char **argv)
Definition: test_collapse_edge_aif.cpp:72
are_meshes_equal
bool are_meshes_equal(std::string filename_a, std::string filename_b, bool verbose)
Definition: utils_are_meshes_identical.inl:925
properties_aif.h
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
test_collapse_edge_aif
void test_collapse_edge_aif(const std::string &input_file_path, int source_index, int target_index, const std::string &output_file_path)
Definition: test_collapse_edge_aif.cpp:38
FEVV::Operators::collapse_edge_keep_target
void collapse_edge_keep_target(MutableFaceIncidentGraph &g, typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor &e)
Collapse an edge of the graph. The edge to collapse is given as a non-oriented edge....
Definition: collapse_edge.hpp:180
FEVV::AIF_mesh_kernel_generator
AIF specialization. Refer to for concrete usage .
Definition: Geometry_traits_aif.h:31
AIFMesh.hpp
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::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
Geometry_traits_aif.h
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
AIFMesh
FEVV::DataStructures::AIF::AIFMesh AIFMesh
Definition: Graph_properties_aif.h:19