MEPP2 Project
split_edge_euler.hpp
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 <CGAL/boost/graph/internal/helpers.h> // set_border
14 #include <boost/graph/graph_traits.hpp>
15 #include <CGAL/boost/graph/iterator.h>
16 
17 #include <CGAL/boost/graph/Euler_operations.h> // for add_face(vr,g)
18 
19 #include <CGAL/boost/graph/helpers.h> // is_border + is_triangle_mesh
20 
21 #include <cassert>
22 
24 
25 namespace FEVV {
26 namespace Operators {
27 
42 template< typename MutableFaceGraph, typename PointMap >
43 void
45  MutableFaceGraph &g,
46  PointMap pm,
47  typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
48 {
49  typedef FEVV::Geometry_traits< MutableFaceGraph > GeometryTraits;
50  typedef typename GeometryTraits::Point Point;
51 
52  typedef boost::graph_traits< MutableFaceGraph > GraphTraits;
53  typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
55  //typedef typename GraphTraits::face_descriptor face_descriptor;
56  GeometryTraits gt(g);
57 
58  if(h == boost::graph_traits< MutableFaceGraph >::null_halfedge())
59  return;
60 
61  halfedge_descriptor opp_h = opposite(h, g);
62  // ensure the edge is incident to triangles (only)
63  if(CGAL::is_border(h, g))
64  {
65  if(!CGAL::is_triangle(opp_h, g))
66  return;
67  }
68  else if(CGAL::is_border(opp_h, g))
69  {
70  if(!CGAL::is_triangle(h, g))
71  return;
72  }
73  else
74  {
75  if(!CGAL::is_triangle(h, g) || !CGAL::is_triangle(opp_h, g))
76  return;
77  }
78 
79  // deal with vertex geometry
80  vertex_descriptor vs = source(h, g);
81  vertex_descriptor vt = target(h, g);
82 
83  // use CGAL::Euler function
84  std::cout
85  << "Warning: use CGAL::Euler::split_edge() and CGAL::Euler::split_face"
86  << "\n";
87  halfedge_descriptor res;
88  if(CGAL::is_border(h, g))
89  {
90  res = CGAL::Euler::split_edge(opp_h, g); // does not work with AIFMesh
91  CGAL::Euler::split_face(res, next(opp_h, g), g);
92  }
93  else if(CGAL::is_border(opp_h, g))
94  {
95  res = CGAL::Euler::split_edge(h, g);
96  CGAL::Euler::split_face(res, next(h, g), g);
97  }
98  else
99  {
100  res = CGAL::Euler::split_edge(h, g);
101  CGAL::Euler::split_face(res, next(h, g), g);
102  CGAL::Euler::split_face(opposite(h, g), next(opposite(res, g), g), g);
103  }
104  put(pm,
105  target(res, g),
106  Point((gt.get_x(get(pm, vs)) + gt.get_x(get(pm, vt))) * 0.5f,
107  (gt.get_y(get(pm, vs)) + gt.get_y(get(pm, vt))) * 0.5f,
108  (gt.get_z(get(pm, vs)) + gt.get_z(get(pm, vt))) * 0.5f));
109 }
110 
111 } // namespace Operators
112 } // namespace FEVV
FEVV::DataStructures::AIF::next
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor next(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the next halfedge around its face.
Definition: Graph_traits_aif.h:599
FEVV::DataStructures::AIF::opposite
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor opposite(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the halfedge with source and target swapped.
Definition: Graph_traits_aif.h:625
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::DataStructures::AIF::source
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor source(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the source vertex of e.
Definition: Graph_traits_aif.h:387
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
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Operators::split_edge_euler
void split_edge_euler(MutableFaceGraph &g, PointMap pm, typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
Split an edge of the graph. The edge to split is given as a halfedge.
Definition: split_edge_euler.hpp:44
FEVV::DataStructures::AIF::target
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor target(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the target vertex of e.
Definition: Graph_traits_aif.h:400
Geometry_traits.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
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::put
void put(FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key, const FEVV::PCLPointCloudPointMap::value_type &value)
Specialization of put(point_map, key, value) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:126