MEPP2 Project
Midpoint.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2022 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 
12 #pragma once
13 
14 #include "Kept_position.h"
15 
16 namespace FEVV {
17 namespace Filters {
22 template< typename HalfedgeGraph,
23  typename PointMap,
24  typename Geometry = typename FEVV::Geometry_traits< HalfedgeGraph > >
25 class Midpoint : public Kept_position< HalfedgeGraph,
26  PointMap,
27  Geometry >
28 {
29 public:
30  using Vector = typename Geometry::Vector;
31  using Point = typename Geometry::Point;
32  typedef Kept_position< HalfedgeGraph,
33  PointMap,
34  Geometry >
36 
37  Midpoint(HalfedgeGraph &g,
38  PointMap &pm)
39  : Super_class(g, pm)
40  {
41  Super_class::_type = VKEPT_POSITION::MIDPOINT;
42  Super_class::_reverse = false; // has no reverse case
43  }
44  Midpoint(HalfedgeGraph &g,
45  PointMap &pm,
46  Geometry &gt)
47  : Super_class(g, pm, gt)
48  {
49  Super_class::_type = VKEPT_POSITION::MIDPOINT;
50  Super_class::_reverse = false; // has no reverse case
51  }
52 
53  std::string get_as_string() const override { return "midpoint"; }
54 
57  typename boost::graph_traits< HalfedgeGraph >::edge_descriptor edge) override
58  {
59  const Point& source_point = get(Super_class::_pm, source(edge, Super_class::_g));
60  const Point& target_point = get(Super_class::_pm, target(edge, Super_class::_g));
61  Point collapsePos = Point((Super_class::_gt.get_x(source_point) +
62  Super_class::_gt.get_x(target_point)) /
63  2,
64  (Super_class::_gt.get_y(source_point) +
65  Super_class::_gt.get_y(target_point)) /
66  2,
67  (Super_class::_gt.get_z(source_point) +
68  Super_class::_gt.get_z(target_point)) /
69  2);
70 
71 
72  collapsePos = Point(std::round(Super_class::_gt.get_x(collapsePos)),
73  std::round(Super_class::_gt.get_y(collapsePos)),
74  std::round(Super_class::_gt.get_z(collapsePos)));
75 
76 
77 
78  return collapsePos;
79  }
80 
81  ~Midpoint() {}
82 };
83 } // namespace Filters
84 } // namespace FEVV
FEVV::Filters::Midpoint::Point
typename Geometry::Point Point
Definition: Midpoint.h:31
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Filters::Kept_position::_pm
PointMap & _pm
Definition: Kept_position.h:55
FEVV::Filters::Midpoint::Super_class
Kept_position< HalfedgeGraph, PointMap, Geometry > Super_class
Definition: Midpoint.h:35
FEVV::Filters::Midpoint::Midpoint
Midpoint(HalfedgeGraph &g, PointMap &pm, Geometry &gt)
Definition: Midpoint.h:44
Kept_position.h
FEVV::Filters::Kept_position::_g
HalfedgeGraph & _g
Definition: Kept_position.h:53
FEVV::Filters::Midpoint::Midpoint
Midpoint(HalfedgeGraph &g, PointMap &pm)
Definition: Midpoint.h:37
FEVV::Geometry_traits< HalfedgeGraph >
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::DataStructures::AIF::edge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor edge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the edge corresponding to h and opposite(h).
Definition: Graph_traits_aif.h:345
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::Filters::Kept_position
Abstract class to represent the position type of the resulting vertex of an edge collapse.
Definition: Kept_position.h:31
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Filters::Kept_position::_type
FEVV::Filters::VKEPT_POSITION _type
Definition: Kept_position.h:56
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
FEVV::Filters::Midpoint::Vector
typename Geometry::Vector Vector
Definition: Midpoint.h:30
FEVV::Filters::Midpoint::get_as_string
std::string get_as_string() const override
Definition: Midpoint.h:53
FEVV::Filters::Midpoint
Concrete class to represent the midpoint position type of the resulting vertex of an edge collapse.
Definition: Midpoint.h:28
FEVV::Filters::Midpoint::compute_position
Point compute_position(typename boost::graph_traits< HalfedgeGraph >::edge_descriptor edge) override
Compute the midpoint of an edge.
Definition: Midpoint.h:56
FEVV::Filters::Midpoint::~Midpoint
~Midpoint()
Definition: Midpoint.h:81
FEVV::Filters::Kept_position::_gt
const Geometry _gt
Definition: Kept_position.h:54
FEVV::Filters::Kept_position::_reverse
bool _reverse
Definition: Kept_position.h:57