14 #include <boost/graph/graph_traits.hpp>
15 #include <CGAL/boost/graph/iterator.h>
17 #include <CGAL/boost/graph/Euler_operations.h>
40 template<
typename MutableFaceIncidentGraph
45 typename boost::graph_traits<MutableFaceIncidentGraph>::edge_descriptor
47 MutableFaceIncidentGraph &g,
48 typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor
56 typedef boost::graph_traits< MutableFaceIncidentGraph > GraphTraits;
57 typedef typename GraphTraits::edge_descriptor edge_descriptor;
59 typedef typename GraphTraits::face_descriptor face_descriptor;
62 if(e == boost::graph_traits< MutableFaceIncidentGraph >::null_edge())
63 return boost::graph_traits<MutableFaceIncidentGraph>::null_edge();
68 return boost::graph_traits<MutableFaceIncidentGraph>::null_edge();
80 #ifdef USE_ADD_EDGE_AIF // conflict with function in Euler_operations.h (CGAL)
81 std::pair<edge_descriptor, bool> p =
add_edge(vs, midpoint_vertex, g);
88 #ifdef USE_ADD_EDGE_AIF
96 std::vector< vertex_descriptor > face1_vertices, face2_vertices;
97 auto face_range_pair =
in_edges(e, g);
98 std::vector< face_descriptor > copy_f(
99 face_range_pair.first,
102 typename std::vector< face_descriptor >::iterator iter_f(copy_f.begin()),
103 iter_fe(copy_f.end());
104 for(; iter_f != iter_fe; ++iter_f)
106 auto edge_range_pair =
out_edges(*iter_f, g);
107 auto iter_e = edge_range_pair.first;
113 edge_descriptor prev_e = *iter_e;
115 if(iter_e == edge_range_pair.second)
116 iter_e = edge_range_pair.first;
120 face1_vertices.push_back(
target(*iter_e, g));
121 face1_vertices.push_back(
target(prev_e, g));
122 face1_vertices.push_back(midpoint_vertex);
124 face2_vertices.push_back(
source(prev_e, g));
125 face2_vertices.push_back(
target(*iter_e, g));
126 face2_vertices.push_back(midpoint_vertex);
130 face1_vertices.push_back(
target(*iter_e, g));
131 face1_vertices.push_back(
source(prev_e, g));
132 face1_vertices.push_back(midpoint_vertex);
134 face2_vertices.push_back(
target(prev_e, g));
135 face2_vertices.push_back(
target(*iter_e, g));
136 face2_vertices.push_back(midpoint_vertex);
140 face1_vertices.push_back(
source(*iter_e, g));
141 face1_vertices.push_back(
target(prev_e, g));
142 face1_vertices.push_back(midpoint_vertex);
144 face2_vertices.push_back(
source(prev_e, g));
145 face2_vertices.push_back(
source(*iter_e, g));
146 face2_vertices.push_back(midpoint_vertex);
150 face1_vertices.push_back(
source(*iter_e, g));
151 face1_vertices.push_back(
source(prev_e, g));
152 face1_vertices.push_back(midpoint_vertex);
154 face2_vertices.push_back(
target(prev_e, g));
155 face2_vertices.push_back(
source(*iter_e, g));
156 face2_vertices.push_back(midpoint_vertex);
161 face1_vertices.clear();
162 face2_vertices.clear();
169 std::pair<edge_descriptor, bool> p2 =
edge(vs, midpoint_vertex, g);
186 template<
typename MutableFaceIncidentGraph
188 typename boost::graph_traits<MutableFaceIncidentGraph>::edge_descriptor
189 split_edge(MutableFaceIncidentGraph& g,
typename boost::graph_traits<MutableFaceIncidentGraph>::edge_descriptor e)
191 typedef boost::graph_traits<MutableFaceIncidentGraph> GraphTraits;
197 return split_edge<MutableFaceIncidentGraph>(g, e, midpoint_vertex);
216 template<
typename MutableFaceIncidentGraph,
220 typename boost::graph_traits<MutableFaceIncidentGraph>::edge_descriptor
221 split_edge(MutableFaceIncidentGraph& g, PointMap pm,
typename boost::graph_traits<MutableFaceIncidentGraph>::edge_descriptor e)
225 typedef boost::graph_traits<MutableFaceIncidentGraph> GraphTraits;
226 typedef typename GraphTraits::edge_descriptor edge_descriptor;
228 GeometryTraits gt(g);
232 edge_descriptor res = split_edge<MutableFaceIncidentGraph>(g, e);
234 if (res == boost::graph_traits<MutableFaceIncidentGraph>::null_edge())
235 return boost::graph_traits<MutableFaceIncidentGraph>::null_edge();
240 put(pm, midpoint_vertex,
Point( (gt.get_x(
get(pm, vs)) + gt.get_x(
get(pm, vt)))*0.5f,
241 (gt.get_y(
get(pm, vs)) + gt.get_y(
get(pm, vt)))*0.5f,
242 (gt.get_z(
get(pm, vs)) + gt.get_z(
get(pm, vt)))*0.5f));