MEPP2 Project
test_comparison_operators_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.
13 
14 // must be the last include to avoid side effect of disabling NDEBUG
15 #undef NDEBUG
16 #include <cassert>
17 
18 //------------------------------------------------------------------------------
19 
20 int
21 main(void)
22 {
24  //typedef FEVV::DataStructures::AIF::AIFVertex AIFVertex;
25  //typedef FEVV::DataStructures::AIF::AIFEdge AIFEdge;
26  //typedef FEVV::DataStructures::AIF::AIFFace AIFFace;
28  //typedef helpers::AIFHalfEdge AIFHalfEdge;
29  typedef helpers::smart_ptr_mesh smart_ptr_mesh;
32  typedef helpers::face_descriptor face_descriptor;
33 
34 
35  /* build mesh
36 
37  v3
38  /|\
39  e3/ | \e2
40  v0 /f0|f1\ v2
41  \e4| /
42  e0\ | /e1
43  \|/
44  v1
45  */
46  smart_ptr_mesh m = AIFMesh::New();
47 
48  // add vertices
53 
54  // add edges
56  helpers::link_vertex_and_edge(v0, e0, helpers::vertex_pos::FIRST);
57  helpers::link_vertex_and_edge(v1, e0, helpers::vertex_pos::SECOND);
59  helpers::link_vertex_and_edge(v1, e1, helpers::vertex_pos::FIRST);
60  helpers::link_vertex_and_edge(v2, e1, helpers::vertex_pos::SECOND);
62  helpers::link_vertex_and_edge(v2, e2, helpers::vertex_pos::FIRST);
63  helpers::link_vertex_and_edge(v3, e2, helpers::vertex_pos::SECOND);
65  helpers::link_vertex_and_edge(v3, e3, helpers::vertex_pos::FIRST);
66  helpers::link_vertex_and_edge(v0, e3, helpers::vertex_pos::SECOND);
68  helpers::link_vertex_and_edge(v1, e4, helpers::vertex_pos::FIRST);
69  helpers::link_vertex_and_edge(v3, e4, helpers::vertex_pos::SECOND);
70 
71  // add faces
72  face_descriptor f0 = helpers::add_face(m);
76  face_descriptor f1 = helpers::add_face(m);
80 
81  // display mesh informations
82  std::cout << "Input mesh:\n";
83  m->Print();
84 
85  //---------------------- Tests ---------------------
86 
87  // Beware!
88  // Comparing v1 and v2 is comparing shared pointers
89  // comparing *v1 and *v2 is comparing two AIFVertex objects,
90  // using AIFVertex class comparison operators.
91 
92  // vertex operators
93  assert(*v2 == *v2);
94  assert(*v2 <= *v2);
95  assert(*v2 >= *v2);
96  assert(!(*v2 != *v2));
97  assert(!(*v2 < *v2));
98  assert(!(*v2 > *v2));
99 
100  assert(*v2 != *v3);
101  assert(!(*v2 == *v3));
102  assert((*v2 < *v3) != (*v2 > *v3));
103  assert((*v2 <= *v3) != (*v2 >= *v3));
104 
105  assert(v2 == v2); // compare smart pointers, ok for vertices !
106  assert(v2 != v3); // compare smart pointers, ok for vertices !
107 
108  // face operators
109  assert(*f0 == *f0);
110  assert(*f0 <= *f0);
111  assert(*f0 >= *f0);
112  assert(!(*f0 != *f0));
113  assert(!(*f0 < *f0));
114  assert(!(*f0 > *f0));
115 
116  assert(*f0 != *f1);
117  assert(!(*f0 == *f1));
118  assert((*f0 < *f1) != (*f0 > *f1));
119  assert((*f0 <= *f1) != (*f0 >= *f1));
120 
121  assert(f0 == f0); // compare smart pointers, ok for faces !
122  assert(f0 != f1); // compare smart pointers, ok for faces !
123 
124  // edge operators
125  assert(*e3 == *e3);
126  assert(*e3 <= *e3);
127  assert(*e3 >= *e3);
128  assert(!(*e3 != *e3));
129  assert(!(*e3 < *e3));
130  assert(!(*e3 > *e3));
131 
132  assert(*e3 != *e1);
133  assert(!(*e3 == *e1));
134  assert((*e3 < *e1) != (*e3 > *e1));
135  assert((*e3 <= *e1) != (*e3 >= *e1));
136 
137  // Edge comparison is not based on direct pointer comparison
138  // but on vertices comparison, so distinct edge objects can be
139  // equal.
141  helpers::link_vertex_and_edge(v2, e2twin, helpers::vertex_pos::FIRST);
142  helpers::link_vertex_and_edge(v3, e2twin, helpers::vertex_pos::SECOND);
143  edge_descriptor e2reversetwin = helpers::add_edge(m);
144  helpers::link_vertex_and_edge(v3, e2reversetwin, helpers::vertex_pos::FIRST);
145  helpers::link_vertex_and_edge(v2, e2reversetwin, helpers::vertex_pos::SECOND);
146  assert(*e2twin == *e2);
147  assert(*e2reversetwin == *e2);
148  assert(*e2reversetwin == *e2twin);
149  assert(*e2twin != *e3);
150 
151  assert(e2twin != e2); // compare smart pointers, NOT ok for edges !
152 
153 
154  std::cout << "Test passed.\n";
155  return 0; // all tests passed
156 }
helpers
AIFTopologyHelpers helpers
Definition: test_helpers_aif.cpp:16
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_face
static face_descriptor add_face(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2887
FEVV::DataStructures::AIF::AIFTopologyHelpers::link_edge_and_face
static void link_edge_and_face(edge_descriptor edge, face_descriptor face)
Definition: AIFTopologyHelpers.h:1305
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_descriptor
vertex_type::ptr vertex_descriptor
Definition: AIFTopologyHelpers.h:70
GraphConcept::edge_descriptor
boost::graph_traits< G >::edge_descriptor edge_descriptor
Definition: test_boost_graph_concept_aif.cpp:23
main
int main(void)
Definition: test_comparison_operators_aif.cpp:21
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_descriptor
edge_type::ptr edge_descriptor
Definition: AIFTopologyHelpers.h:71
FEVV::DataStructures::AIF::AIFMesh::New
static ptr_mesh New()
Definition: AIFMesh.inl:720
FEVV::DataStructures::AIF::AIFTopologyHelpers::face_descriptor
face_type::ptr face_descriptor
Definition: AIFTopologyHelpers.h:72
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_edge
static edge_descriptor add_edge(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2772
FEVV::DataStructures::AIF::AIFTopologyHelpers::link_vertex_and_edge
static void link_vertex_and_edge(vertex_descriptor vertex, edge_descriptor edge, vertex_pos position)
Definition: AIFTopologyHelpers.h:515
AIFMesh.hpp
Graph_traits_aif.h
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::DataStructures::AIF::AIFTopologyHelpers::smart_ptr_mesh
mesh_type::ptr smart_ptr_mesh
Definition: AIFTopologyHelpers.h:64
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
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_vertex
static vertex_descriptor add_vertex(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2709
AIFMesh
FEVV::DataStructures::AIF::AIFMesh AIFMesh
Definition: Graph_properties_aif.h:19