MEPP2 Project
test_split_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_split_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 << "Splitting edge " << source_index << " to " << target_index
62  << "." << std::endl;
63  FEVV::Operators::split_edge(m, get(boost::vertex_point, m), h);
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 > 5)
75  {
76  std::cout << "Usage: " << argv[0]
77  << " filename int [filenameresult [filenameexpectedresult]]; int "
78  "is either 0, 1, 2 or 3."
79  << std::endl;
80  exit(EXIT_FAILURE);
81  }
82 
83  std::string to_treat = argv[1];
84 
85  int halfedge_case = std::stoi(std::string(argv[2]));
86  std::string output_file_name = std::string(argv[3]);
87 
88  if(halfedge_case == 0)
89  {
90  test_split_edge_aif(to_treat, 1, 2, output_file_name); // border halfedge
91  }
92  else if(halfedge_case == 1)
93  {
94  test_split_edge_aif(to_treat, 2, 1, output_file_name); // border halfedge
95  }
96  else if(halfedge_case == 2)
97  {
98  test_split_edge_aif(to_treat, 3, 4, output_file_name);
99  }
100  else if(halfedge_case == 3)
101  {
102  test_split_edge_aif(to_treat, 4, 3, output_file_name);
103  }
104  else
105  {
106  return 1; // test failed
107  }
108 
109  if(narg == 5)
110  {
111  if(!are_meshes_equal(
112  output_file_name,
113  argv[4],
114  true)) // this test currently fails for case 0 [border edge, because
115  // this is not handled for the time being]
116  return 1; // test failed
117  }
118 
119  return 0; // test succeeded
120 }
split_edge.hpp
test_split_edge_aif
void test_split_edge_aif(const std::string &input_file_path, int source_index, int target_index, const std::string &output_file_path)
Definition: test_split_edge_aif.cpp:38
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
main
int main(int narg, char **argv)
Definition: test_split_edge_aif.cpp:72
generic_reader.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
properties_aif.h
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
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
boost::get
boost::property_map< FEVV::DataStructures::AIF::AIFMesh, boost::vertex_index_t >::const_type get(const boost::vertex_index_t &, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the vertex index property map of the mesh.
Definition: Graph_properties_aif.h:108
FEVV::Operators::split_edge
boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor split_edge(MutableFaceIncidentGraph &g, typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor e, typename boost::graph_traits< MutableFaceIncidentGraph >::vertex_descriptor midpoint_vertex)
Split an edge of the graph.
Definition: split_edge.hpp:46
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