MEPP2 Project
Graph_traits_cgal_point_set.h
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.
11 #pragma once
12 
13 #include <boost/graph/graph_traits.hpp>
14 #include <boost/graph/properties.hpp>
15 
16 #include <utility> // for std::make_pair
17 
19 
20 
21 namespace boost {
22 
23 template<>
24 struct graph_traits< FEVV::CGALPointSet >
25 {
26 private:
28 
29 public:
30  // Graph
31  typedef FEVV::CGALPointSet::Index vertex_descriptor;
33 
34  // HalfedgeGraph
35  typedef int halfedge_descriptor;
36  //TODO-elo-fix halfedge_descriptor needed by SimpleViewer::draw_or_redraw_mesh()
37  // remove when draw_redraw_mesh() is fixed
38 
39  // FaceGraph
40  typedef int face_descriptor;
41  //TODO-elo-fix face_decriptor needed par SimpleViewer::internal_createMesh()
42  // remove when internal_createMesh() is fixed
43 
44  // VertexListGraph
45  typedef FEVV::CGALPointSet::iterator vertex_iterator;
46  typedef std::size_t vertices_size_type;
47 
48  // nulls
49  static vertex_descriptor null_vertex() { return -1; }
50 };
51 
52 template<>
53 struct graph_traits< const FEVV::CGALPointSet >
54  : public graph_traits< FEVV::CGALPointSet >
55 { };
56 
57 } // namespace boost
58 
59 
60 namespace CGAL {
61 
62  // note:
63  // FEVV::CGALPointSet is a typedef to CGAL::Point_set_3<...> ;
64  // vertices(FEVV::CGALPointSet) must be declared in the same
65  // namespace as CGALPointSet real underlying class for the
66  // name lookup mecanism to work properly ;
67  // see https://en.cppreference.com/w/cpp/language/adl
68 
69 // Essential free functions specialization for CGALPointSet.
70 
71 // See http://www.boost.org/doc/libs/1_61_0/libs/graph/doc/graph_concepts.html
72 // for BGL concepts description.
73 
74 // See http://doc.cgal.org/latest/BGL/group__PkgBGLConcepts.html
75 // for CGAL-BGL concepts description.
76 
77 // BGL VertexListGraph
81 
82 inline
83 std::pair< typename boost::graph_traits<
84  FEVV::CGALPointSet >::vertex_iterator,
85  typename boost::graph_traits<
86  FEVV::CGALPointSet >::vertex_iterator >
88 {
89  return std::make_pair(ps.begin(), ps.end());
90 }
91 
92 inline
93 std::pair< FEVV::CGALPointSet::const_iterator,
94  FEVV::CGALPointSet::const_iterator >
96 {
97  return std::make_pair(ps.begin(), ps.end());
98 }
99 
100 
101 // BGL VertexListGraph
105 inline
108 {
109  return ps.number_of_points();
110 }
111 
112 
113 // BGL VertexMutableGraph Concept
118 inline
121 {
122  FEVV::CGALPointSet::iterator new_point_it = ps.insert();
123 
124  // return index of new point
125  return new_point_it - ps.begin();
126 }
127 
128 
129 // CGAL MutableHalfedgeGraph Concept
133 inline
134 void
135 remove_vertex(typename boost::graph_traits<
137  FEVV::CGALPointSet &ps)
138 {
139  ps.remove(v);
140 
141  // collect_garbage() must be called to really remove the point from container
142  // and ensure that the point index is equivalent to the non-removed-point
143  // iterator
144  ps.collect_garbage();
145 }
146 
147 
148 } // namespace CGAL
boost::graph_traits< FEVV::CGALPointSet >::vertex_property_type
Point vertex_property_type
Definition: Graph_traits_cgal_point_set.h:32
FEVV::CGALPointSet
CGAL::Point_set_3< CGALPointSetPoint > CGALPointSet
Definition: DataStructures_cgal_point_set.h:71
CGAL::num_vertices
boost::graph_traits< FEVV::CGALPointSet >::vertices_size_type num_vertices(const FEVV::CGALPointSet &ps)
Returns an upper bound of the number of vertices of the mesh.
Definition: Graph_traits_cgal_point_set.h:107
DataStructures_cgal_point_set.h
boost::graph_traits< FEVV::CGALPointSet >::halfedge_descriptor
int halfedge_descriptor
Definition: Graph_traits_cgal_point_set.h:35
boost::graph_traits< FEVV::CGALPointSet >::null_vertex
static vertex_descriptor null_vertex()
Definition: Graph_traits_cgal_point_set.h:49
boost
Definition: Graph_properties_aif.h:48
CGAL::add_vertex
boost::graph_traits< FEVV::CGALPointSet >::vertex_descriptor add_vertex(FEVV::CGALPointSet &ps)
Adds a new vertex to the graph without initializing the connectivity.
Definition: Graph_traits_cgal_point_set.h:120
CGAL::remove_vertex
void remove_vertex(typename boost::graph_traits< FEVV::CGALPointSet >::vertex_descriptor v, FEVV::CGALPointSet &ps)
Removes v from the mesh.
Definition: Graph_traits_cgal_point_set.h:135
boost::graph_traits< FEVV::CGALPointSet >::vertex_iterator
FEVV::CGALPointSet::iterator vertex_iterator
Definition: Graph_traits_cgal_point_set.h:45
FEVV::CGALPointSetPoint
CGALPointSetKernel::Point_3 CGALPointSetPoint
Definition: DataStructures_cgal_point_set.h:30
boost::graph_traits< FEVV::CGALPointSet >::vertices_size_type
std::size_t vertices_size_type
Definition: Graph_traits_cgal_point_set.h:46
boost::graph_traits< FEVV::CGALPointSet >::Point
FEVV::CGALPointSetPoint Point
Definition: Graph_traits_cgal_point_set.h:27
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
CGAL
Definition: Graph_properties_cgal_point_set.h:32
CGAL::vertices
std::pair< typename boost::graph_traits< FEVV::CGALPointSet >::vertex_iterator, typename boost::graph_traits< FEVV::CGALPointSet >::vertex_iterator > vertices(FEVV::CGALPointSet &ps)
Returns the iterator range of the vertices of the mesh.
Definition: Graph_traits_cgal_point_set.h:87
boost::graph_traits< FEVV::CGALPointSet >::face_descriptor
int face_descriptor
Definition: Graph_traits_cgal_point_set.h:40
boost::graph_traits< FEVV::CGALPointSet >::vertex_descriptor
FEVV::CGALPointSet::Index vertex_descriptor
Definition: Graph_traits_cgal_point_set.h:31
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33