MEPP2 Project
test_non_manifold_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 
18 
19 #include <fstream>
20 #include <iostream>
21 
25 // DBG #include "FEVV/Filters/Generic/print_points.hpp"
26 
27 using namespace FEVV;
28 using namespace FEVV::Operators;
29 
30 //------------------------------------------------------------------------------
31 
32 void
33 test_split_edge_aif(std::string filename,
34  int source_index,
35  int target_index,
36  const std::string &output_file_name)
37 {
40 
41  // Load a mesh
42  ptr_mesh pm;
43 
45  if(!(pm = in.read(filename)))
46  {
47  std::cout << "failed";
48  return;
49  }
50 
51  typedef boost::graph_traits< Mesh > GraphTraits;
52  typedef GraphTraits::edge_descriptor edge_descriptor;
53 
54  // DBG print_points(M, get(CGAL::vertex_point, *pm));
55 
56  edge_descriptor e = retrieve_edge(*pm, source_index, target_index);
57  if(e == GraphTraits::null_edge())
58  {
59  std::cout << "Failed to retrieve edge from " << source_index << " to "
60  << target_index << "." << std::endl;
61  std::cout << "Exiting";
62  exit(EXIT_FAILURE);
63  }
64 
65  std::cout << "Splitting edge " << source_index << " to " << target_index
66  << "." << std::endl;
67  split_edge(*pm, get(boost::vertex_point, *pm), e);
68 
69  // DBG print_points(*pm, get(CGAL::vertex_point, M));
70 
72  try
73  {
74  out.write(pm, output_file_name);
75  }
76  catch(...)
77  {
78  std::cout << "writing failed";
79  return;
80  }
81 }
82 
83 //------------------------------------------------------------------------------
84 
85 int
86 main(int narg, char **argv)
87 {
88  if(narg < 3 || narg > 5)
89  {
90  std::cout << "Usage: " << argv[0]
91  << " filename int [filenameresult [filenameexpectedresult]]; int "
92  "is either 0, 1, 2 or 3."
93  << std::endl;
94  exit(EXIT_FAILURE);
95  }
96 
97  std::string to_treat = argv[1];
98 
99  int halfedge_case = std::stoi(std::string(argv[2]));
100  std::string output_file_name = std::string(argv[3]);
101 
102  if(halfedge_case == 0)
103  {
104  test_split_edge_aif(to_treat, 1, 2, output_file_name); // border halfedge
105  }
106  else if(halfedge_case == 1)
107  {
108  test_split_edge_aif(to_treat, 2, 1, output_file_name); // border halfedge
109  }
110  else if(halfedge_case == 2)
111  {
112  test_split_edge_aif(to_treat, 3, 4, output_file_name);
113  }
114  else if(halfedge_case == 3)
115  {
116  test_split_edge_aif(to_treat, 4, 3, output_file_name);
117  }
118  else if(halfedge_case == 4)
119  {
120  test_split_edge_aif(to_treat, 5, 7, output_file_name);
121  }
122  else if(halfedge_case == 5)
123  {
124  test_split_edge_aif(to_treat, 7, 5, output_file_name);
125  }
126  else
127  {
128  return 1; // test failed
129  }
130 
131  if(narg == 5)
132  {
133  if(!are_meshes_equal(
134  output_file_name,
135  argv[4],
136  true)) // this test currently fails for case 0 [border edge, because
137  // this is not handled for the time being]
138  return 1; // test failed
139  }
140 
141  return 0; // test succeeded
142 }
FEVV::DataStructures::AIF::AIFMeshWriter
This class represents an AIFMesh object writer. An AIFMeshWriter writes a mesh file (....
Definition: AIFMeshWriter.hpp:37
test_split_edge_aif
void test_split_edge_aif(std::string filename, int source_index, int target_index, const std::string &output_file_name)
Definition: test_non_manifold_split_edge_aif.cpp:33
FEVV::DataStructures::AIF::AIFMeshReader::read
ptr_output read(const std::string &filePath)
Definition: AIFMeshReader.inl:50
GraphConcept::edge_descriptor
boost::graph_traits< G >::edge_descriptor edge_descriptor
Definition: test_boost_graph_concept_aif.cpp:23
retrieve_edge
boost::graph_traits< MutableFaceGraph >::edge_descriptor retrieve_edge(MutableFaceGraph &g, int source_index, int target_index)
Definition: utils_retrieve_edge.h:30
are_meshes_equal
bool are_meshes_equal(std::string filename_a, std::string filename_b, bool verbose)
Definition: utils_are_meshes_identical.inl:925
Graph_properties_aif.h
FEVV::get
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:117
split_edge.hpp
FEVV::DataStructures::AIF::AIFMeshWriter::write
void write(const ptr_input inputMesh, const std::string &filePath)
Definition: AIFMeshWriter.inl:28
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
AIFMesh.hpp
main
int main(int narg, char **argv)
Definition: test_non_manifold_split_edge_aif.cpp:86
FEVV::DataStructures::AIF::AIFMesh::ptr_mesh
boost::shared_ptr< Self > ptr_mesh
Definition: AIFMesh.hpp:51
FEVV::Operators
Definition: collapse_edge.hpp:25
Graph_traits_aif.h
Mesh
FEVV::DataStructures::AIF::AIFMesh Mesh
Definition: test_complying_concepts_aif.cpp:18
Geometry_traits_aif.h
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
FEVV::DataStructures::AIF::AIFMeshReader
This class represents an AIFMesh object reader. An AIFMeshReader reads a mesh file (....
Definition: AIFMeshReader.hpp:37
AIFMeshReader.hpp
utils_retrieve_edge.h
AIFMeshWriter.hpp