MEPP2 Project
test_not_2_manifold_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 
15 #include <algorithm>
16 
17 // must be the last include to avoid side effect of disabling NDEBUG
18 #undef NDEBUG
19 #include <cassert>
20 
21 //------------------------------------------------------------------------------
22 
23 /*
24  * Display container or range content.
25  */
26 template< typename T >
27 void
28 display_container(const T &container, const char *title)
29 {
30  std::cout << title << " =" << std::endl;
31  for(auto element : container)
32  std::cout << " " << element << std::endl;
33  std::cout << std::endl;
34 }
35 
36 //------------------------------------------------------------------------------
37 
38 const bool VERBOSE = false;
39 
40 //------------------------------------------------------------------------------
41 
42 int
43 main(void)
44 {
46  //typedef FEVV::DataStructures::AIF::AIFVertex AIFVertex;
47  //typedef FEVV::DataStructures::AIF::AIFEdge AIFEdge;
48  //typedef FEVV::DataStructures::AIF::AIFFace AIFFace;
50  //typedef TopoHelpers::AIFHalfEdge AIFHalfEdge;
51  typedef TopoHelpers::smart_ptr_mesh smart_ptr_mesh;
53  typedef TopoHelpers::edge_descriptor edge_descriptor;
54  typedef TopoHelpers::face_descriptor face_descriptor;
55 
56 
57  // build mesh
58  /* e14 (dangling)
59  v2 ----------- v6
60  /|
61  / |
62  / |
63  / | e15
64  / |
65  e4/ | v11
66  / | /\
67  / f4 |/ \
68  / / | \
69  / / | \ e16
70  / /e17 | \
71  / / | f5 \
72  / / | \
73  / / e13 | e9 \
74 v1 ---------- v0 ----------- v3 v7 --------- v8
75  \ |\ / e7 (isolated)
76  \ | \ f6 /
77  \ |e19\ / e18
78  \ | \ /
79  \ f0 | \ /
80  \ | \/
81  \ | v12 v9 (isolated)
82  e12\ |e11 X
83  \ |
84  \ |
85  \ |
86  \ |
87  \ |
88  \| e10 (dangling) e8 (dangling)
89  v5 ----------- v4 ----------- v10
90  */
91 
92  smart_ptr_mesh m = AIFMesh::New();
93 
94  // add vertices
108 
109  // add edges
111  TopoHelpers::link_vertex_and_edge(v1, e4, TopoHelpers::vertex_pos::FIRST);
112  TopoHelpers::link_vertex_and_edge(v2, e4, TopoHelpers::vertex_pos::SECOND);
113 
115  TopoHelpers::link_vertex_and_edge(v7, e7, TopoHelpers::vertex_pos::FIRST);
116  TopoHelpers::link_vertex_and_edge(v8, e7, TopoHelpers::vertex_pos::SECOND);
117 
119  TopoHelpers::link_vertex_and_edge(v4, e8, TopoHelpers::vertex_pos::FIRST);
120  TopoHelpers::link_vertex_and_edge(v10, e8, TopoHelpers::vertex_pos::SECOND);
121 
123  TopoHelpers::link_vertex_and_edge(v0, e9, TopoHelpers::vertex_pos::FIRST);
124  TopoHelpers::link_vertex_and_edge(v3, e9, TopoHelpers::vertex_pos::SECOND);
125 
127  TopoHelpers::link_vertex_and_edge(v4, e10, TopoHelpers::vertex_pos::FIRST);
128  TopoHelpers::link_vertex_and_edge(v5, e10, TopoHelpers::vertex_pos::SECOND);
129 
131  TopoHelpers::link_vertex_and_edge(v5, e11, TopoHelpers::vertex_pos::FIRST);
132  TopoHelpers::link_vertex_and_edge(v0, e11, TopoHelpers::vertex_pos::SECOND);
133 
135  TopoHelpers::link_vertex_and_edge(v1, e12, TopoHelpers::vertex_pos::FIRST);
136  TopoHelpers::link_vertex_and_edge(v5, e12, TopoHelpers::vertex_pos::SECOND);
137 
139  TopoHelpers::link_vertex_and_edge(v1, e13, TopoHelpers::vertex_pos::FIRST);
140  TopoHelpers::link_vertex_and_edge(v0, e13, TopoHelpers::vertex_pos::SECOND);
141 
143  TopoHelpers::link_vertex_and_edge(v6, e14, TopoHelpers::vertex_pos::FIRST);
144  TopoHelpers::link_vertex_and_edge(v2, e14, TopoHelpers::vertex_pos::SECOND);
145 
147  TopoHelpers::link_vertex_and_edge(v0, e15, TopoHelpers::vertex_pos::FIRST);
148  TopoHelpers::link_vertex_and_edge(v2, e15, TopoHelpers::vertex_pos::SECOND);
149 
151  TopoHelpers::link_vertex_and_edge(v3, e16, TopoHelpers::vertex_pos::FIRST);
152  TopoHelpers::link_vertex_and_edge(v11, e16, TopoHelpers::vertex_pos::SECOND);
153 
155  TopoHelpers::link_vertex_and_edge(v11, e17, TopoHelpers::vertex_pos::FIRST);
156  TopoHelpers::link_vertex_and_edge(v1, e17, TopoHelpers::vertex_pos::SECOND);
157 
159  TopoHelpers::link_vertex_and_edge(v12, e18, TopoHelpers::vertex_pos::FIRST);
160  TopoHelpers::link_vertex_and_edge(v3, e18, TopoHelpers::vertex_pos::SECOND);
161 
163  TopoHelpers::link_vertex_and_edge(v0, e19, TopoHelpers::vertex_pos::FIRST);
164  TopoHelpers::link_vertex_and_edge(v12, e19, TopoHelpers::vertex_pos::SECOND);
165 
166  // add faces
167  face_descriptor f0 = TopoHelpers::add_face(m);
168  TopoHelpers::link_edge_and_face(e11, f0);
169  TopoHelpers::link_edge_and_face(e12, f0);
170  TopoHelpers::link_edge_and_face(e13, f0);
171 
172  face_descriptor f4 = TopoHelpers::add_face(m);
173  TopoHelpers::link_edge_and_face(e4, f4);
174  TopoHelpers::link_edge_and_face(e13, f4);
175  TopoHelpers::link_edge_and_face(e15, f4);
176 
177  face_descriptor f5 = TopoHelpers::add_face(m);
178  TopoHelpers::link_edge_and_face(e9, f5);
179  TopoHelpers::link_edge_and_face(e13, f5);
180  TopoHelpers::link_edge_and_face(e17, f5);
181  TopoHelpers::link_edge_and_face(e16, f5);
182 
183  face_descriptor f6 = TopoHelpers::add_face(m);
184  TopoHelpers::link_edge_and_face(e18, f6);
185  TopoHelpers::link_edge_and_face(e9, f6);
186  TopoHelpers::link_edge_and_face(e19, f6);
187 
188  // display mesh informations
189  std::cout << "Input mesh:\n";
190  m->Print();
191 
192  // 2-manifoldness of vertex:
193 
194  std::cout << "testing is_2_manifold_vertex(v0)" << std::endl;
195  assert((TopoHelpers::is_2_manifold_vertex(v0) == false));
196 
197  std::cout << "testing is_2_manifold_vertex(v1)" << std::endl;
198  assert((TopoHelpers::is_2_manifold_vertex(v1) == false));
199 
200  std::cout << "testing is_2_manifold_vertex(v2)" << std::endl;
201  assert((TopoHelpers::is_2_manifold_vertex(v2) == false));
202 
203  std::cout << "testing is_2_manifold_vertex(v3)" << std::endl;
204  assert((TopoHelpers::is_2_manifold_vertex(v3) == true));
205 
206  std::cout << "testing is_2_manifold_vertex(v4)" << std::endl;
207  assert((TopoHelpers::is_2_manifold_vertex(v4) == false));
208 
209  std::cout << "testing is_2_manifold_vertex(v5)" << std::endl;
210  assert((TopoHelpers::is_2_manifold_vertex(v5) == false));
211 
212  std::cout << "testing is_2_manifold_vertex(v6)" << std::endl;
213  assert((TopoHelpers::is_2_manifold_vertex(v6) == false));
214 
215  std::cout << "testing is_2_manifold_vertex(v7)" << std::endl;
216  assert((TopoHelpers::is_2_manifold_vertex(v7) == false));
217 
218  std::cout << "testing is_2_manifold_vertex(v8)" << std::endl;
219  assert((TopoHelpers::is_2_manifold_vertex(v8) == false));
220 
221  std::cout << "testing is_2_manifold_vertex(v9)" << std::endl;
222  assert((TopoHelpers::is_2_manifold_vertex(v9) == false));
223 
224  std::cout << "testing is_2_manifold_vertex(v10)" << std::endl;
225  assert((TopoHelpers::is_2_manifold_vertex(v10) == false));
226 
227  std::cout << "testing is_2_manifold_vertex(v11)" << std::endl;
228  assert((TopoHelpers::is_2_manifold_vertex(v11) == true));
229 
230  std::cout << "testing is_2_manifold_vertex(v12)" << std::endl;
231  assert((TopoHelpers::is_2_manifold_vertex(v12) == true));
232 
233  // 2-manifoldness of edge:
234 
235  std::cout << "testing is_2_manifold_edge(e4)" << std::endl;
236  assert((TopoHelpers::is_2_manifold_edge(e4) == false));
237 
238  std::cout << "testing is_2_manifold_edge(e7)" << std::endl;
239  assert((TopoHelpers::is_2_manifold_edge(e7) == false));
240 
241  std::cout << "testing is_2_manifold_edge(e8)" << std::endl;
242  assert((TopoHelpers::is_2_manifold_edge(e8) == false));
243 
244  std::cout << "testing is_2_manifold_edge(e9)" << std::endl;
245  assert((TopoHelpers::is_2_manifold_edge(e9) == false));
246 
247  std::cout << "testing is_2_manifold_edge(e10)" << std::endl;
248  assert((TopoHelpers::is_2_manifold_edge(e10) == false));
249 
250  std::cout << "testing is_2_manifold_edge(e11)" << std::endl;
251  assert((TopoHelpers::is_2_manifold_edge(e11) == false));
252 
253  std::cout << "testing is_2_manifold_edge(e12)" << std::endl;
254  assert((TopoHelpers::is_2_manifold_edge(e12) == false));
255 
256  std::cout << "testing is_2_manifold_edge(e13)" << std::endl;
257  assert((TopoHelpers::is_2_manifold_edge(e13) == false));
258 
259  std::cout << "testing is_2_manifold_edge(e14)" << std::endl;
260  assert((TopoHelpers::is_2_manifold_edge(e14) == false));
261 
262  std::cout << "testing is_2_manifold_edge(e15)" << std::endl;
263  assert((TopoHelpers::is_2_manifold_edge(e15) == false));
264 
265  std::cout << "testing is_2_manifold_edge(e16)" << std::endl;
266  assert((TopoHelpers::is_2_manifold_edge(e16) == true));
267 
268  std::cout << "testing is_2_manifold_edge(e17)" << std::endl;
269  assert((TopoHelpers::is_2_manifold_edge(e17) == false));
270 
271  std::cout << "testing is_2_manifold_edge(e18)" << std::endl;
272  assert((TopoHelpers::is_2_manifold_edge(e18) == true));
273 
274  std::cout << "testing is_2_manifold_edge(e19)" << std::endl;
275  assert((TopoHelpers::is_2_manifold_edge(e19) == false));
276 
277  // 2-manifoldness of vertex' one-ring:
278 
279  std::cout << "testing is_one_ring_2_manifold(v0)" << std::endl;
280  assert((TopoHelpers::is_one_ring_2_manifold(v0) == false));
281 
282  std::cout << "testing is_one_ring_2_manifold(v1)" << std::endl;
283  assert((TopoHelpers::is_one_ring_2_manifold(v1) == false));
284 
285  std::cout << "testing is_one_ring_2_manifold(v2)" << std::endl;
286  assert((TopoHelpers::is_one_ring_2_manifold(v2) == false));
287 
288  std::cout << "testing is_one_ring_2_manifold(v3)" << std::endl;
289  assert((TopoHelpers::is_one_ring_2_manifold(v3) == false));
290 
291  std::cout << "testing is_one_ring_2_manifold(v4)" << std::endl;
292  assert((TopoHelpers::is_one_ring_2_manifold(v4) == false));
293 
294  std::cout << "testing is_one_ring_2_manifold(v5)" << std::endl;
295  assert((TopoHelpers::is_one_ring_2_manifold(v5) == false));
296 
297  std::cout << "testing is_one_ring_2_manifold(v6)" << std::endl;
298  assert((TopoHelpers::is_one_ring_2_manifold(v6) == false));
299 
300  std::cout << "testing is_one_ring_2_manifold(v7)" << std::endl;
301  assert((TopoHelpers::is_one_ring_2_manifold(v7) == false));
302 
303  std::cout << "testing is_one_ring_2_manifold(v8)" << std::endl;
304  assert((TopoHelpers::is_one_ring_2_manifold(v8) == false));
305 
306  std::cout << "testing is_one_ring_2_manifold(v9)" << std::endl;
307  assert((TopoHelpers::is_one_ring_2_manifold(v9) == false));
308 
309  std::cout << "testing is_one_ring_2_manifold(v10)" << std::endl;
310  assert((TopoHelpers::is_one_ring_2_manifold(v10) == false));
311 
312  std::cout << "testing is_one_ring_2_manifold(v11)" << std::endl;
313  assert((TopoHelpers::is_one_ring_2_manifold(v11) == false));
314 
315  std::cout << "testing is_one_ring_2_manifold(v12)" << std::endl;
316  assert((TopoHelpers::is_one_ring_2_manifold(v12) == false));
317 
318  std::cout << "Test passed.\n";
319  return 0; // all tests passed
320 }
display_container
void display_container(const T &container, const char *title)
Definition: test_not_2_manifold_aif.cpp:28
GraphConcept::edge_descriptor
boost::graph_traits< G >::edge_descriptor edge_descriptor
Definition: test_boost_graph_concept_aif.cpp:23
FEVV::DataStructures::AIF::add_face
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor add_face(FEVV::DataStructures::AIF::AIFMesh &sm)
Adds a new face to the graph without initializing the connectivity.
Definition: Graph_traits_aif.h:1056
FEVV::DataStructures::AIF::AIFMesh::New
static ptr_mesh New()
Definition: AIFMesh.inl:720
VERBOSE
const bool VERBOSE
Definition: test_not_2_manifold_aif.cpp:38
FEVV::DataStructures::AIF::add_edge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor add_edge(FEVV::DataStructures::AIF::AIFMesh &sm)
Adds two opposite halfedges to the graph without initializing the connectivity.
Definition: Graph_traits_aif.h:827
AIFMesh.hpp
Graph_traits_aif.h
FEVV::DataStructures::AIF::add_vertex
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor add_vertex(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_property_type vp, FEVV::DataStructures::AIF::AIFMesh &sm)
Definition: Graph_properties_aif.h:263
AIFMeshHelpers.h
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::DataStructures::AIF::AIFTopologyHelpers
This class is an helper class associated to the AIFMesh structure. AIFTopologyHelpers implements all ...
Definition: AIFTopologyHelpers.h:57
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
main
int main(void)
Definition: test_not_2_manifold_aif.cpp:43