MEPP2 Project
Raw_positions.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 "Predictor.h"
15 
16 #include <vector>
17 
18 namespace FEVV {
19 namespace Filters {
20 
21 template<typename HalfedgeGraph,
22  typename PointMap>
23 class Raw_positions : public Predictor<HalfedgeGraph,
24  PointMap>
25 {
26 public:
30  typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor;
34 
37 
38  Raw_positions(HalfedgeGraph &g,
40  PointMap &pm): Super_class(g,kp,pm)
41  {
42  Super_class::_type = PREDICTION_TYPE::POSITION;
44  }
45 
47 
48 
49  std::vector< Vector > compute_residuals(vertex_descriptor v1,
51  Point /*kept_position*/)
52  {
53  const Point& p1 = get(Super_class::_pm, v1);
54  const Point& p2 = get(Super_class::_pm, v2);
55 
56  Vector vec1 = Super_class::_gt.sub_p(p1,Super_class::_gt.ORIGIN);
57  Vector vec2 = Super_class::_gt.sub_p(p2, Super_class::_gt.ORIGIN);
58  std::vector<Vector> residuals;
59  residuals.reserve(2);
60  residuals.push_back(std::move(vec1));
61  residuals.push_back(std::move(vec2));
62 
63  return residuals;
64  }
65 
66  std::vector< Vector > compute_residuals(Collapse_info<HalfedgeGraph, PointMap> &mem) override
67  {
68  Vector vec1 = Super_class::_gt.sub_p(mem.get_pos_vt(), Super_class::_gt.ORIGIN);
69  Vector vec2 = Super_class::_gt.sub_p(mem.get_pos_vs(), Super_class::_gt.ORIGIN);
70  std::vector< Vector > residuals;
71  residuals.reserve(2);
72  residuals.push_back(std::move(vec1));
73  residuals.push_back(std::move(vec2));
74  if(mem.get_reverse())
75  {
76  Vector save = std::move(residuals[0]);
77  residuals[0] = std::move(residuals[1]);
78  residuals[1] = std::move(save);
79  }
80  mem.record_error_prediction(residuals);
81  return residuals;
82  }
83 
84  std::pair< Point, Point > place_points(const std::vector<Vector> &residuals,
85  vertex_descriptor vkept,
86  halfedge_descriptor /*h1*/,
87  halfedge_descriptor /*h2*/) override
88  {
89  Point p1 = Super_class::_gt.add_pv(Super_class::_gt.ORIGIN, residuals[0]);
90  Point p2 = Super_class::_gt.add_pv(Super_class::_gt.ORIGIN, residuals[1]);
91  return std::make_pair(p1,p2);
92  }
93 
94  void set_rev(bool /*b*/) override {}
95 
96  std::string get_as_string() const override { return "position"; }
97 };
98 } // namespace Filters
99 } // namespace FEVV
FEVV::Filters::Predictor::halfedge_descriptor
typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor halfedge_descriptor
Definition: Predictor.h:40
FEVV::Filters::Predictor::Vector
typename FEVV::Geometry_traits< HalfedgeGraph >::Vector Vector
Definition: Predictor.h:43
FEVV::Filters::Predictor::Point
typename FEVV::Geometry_traits< HalfedgeGraph >::Point Point
Definition: Predictor.h:44
FEVV::Filters::Raw_positions::compute_residuals
std::vector< Vector > compute_residuals(Collapse_info< HalfedgeGraph, PointMap > &mem) override
Definition: Raw_positions.h:66
FEVV::Filters::Collapse_info::record_error_prediction
void record_error_prediction(const std::vector< Vector > &pred)
Definition: Collapse_info.h:144
FEVV::Filters::Raw_positions::Raw_positions
Raw_positions(HalfedgeGraph &g, Kept_position< HalfedgeGraph, PointMap > *kp, PointMap &pm)
Definition: Raw_positions.h:38
FEVV::Filters::Collapse_info::get_reverse
bool get_reverse() const
Definition: Collapse_info.h:106
FEVV::Filters::Raw_positions
Definition: Raw_positions.h:25
FEVV::Filters::Predictor::_pm
PointMap & _pm
Definition: Predictor.h:88
FEVV::Filters::Collapse_info< HalfedgeGraph, PointMap >
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
FEVV::Filters::Predictor
Abstract class used to predict position.
Definition: Predictor.h:35
FEVV::Filters::Collapse_info::get_pos_vs
const Point & get_pos_vs() const
Get edge source vertex position.
Definition: Collapse_info.h:99
FEVV::Filters::Collapse_info::get_pos_vt
const Point & get_pos_vt() const
Get edge target vertex position.
Definition: Collapse_info.h:97
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::Predictor::_type
FEVV::Filters::PREDICTION_TYPE _type
Definition: Predictor.h:91
FEVV::Filters::Kept_position< HalfedgeGraph, PointMap >
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
Predictor.h
FEVV::Filters::Predictor::Geometry
typename FEVV::Geometry_traits< HalfedgeGraph > Geometry
Definition: Predictor.h:45
FEVV::Filters::Raw_positions::compute_residuals
std::vector< Vector > compute_residuals(vertex_descriptor v1, vertex_descriptor v2, Point)
Definition: Raw_positions.h:49
FEVV::Filters::Raw_positions::set_rev
void set_rev(bool) override
Definition: Raw_positions.h:94
FEVV::Filters::Predictor::_gt
const Geometry _gt
Definition: Predictor.h:87
FEVV::Filters::Raw_positions::place_points
std::pair< Point, Point > place_points(const std::vector< Vector > &residuals, vertex_descriptor vkept, halfedge_descriptor, halfedge_descriptor) override
Decompression side: predicts a position from encoded residuals.
Definition: Raw_positions.h:84
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::Filters::Raw_positions::get_as_string
std::string get_as_string() const override
Definition: Raw_positions.h:96
FEVV::Filters::Raw_positions::Super_class
Predictor< HalfedgeGraph, PointMap > Super_class
Definition: Raw_positions.h:36
FEVV::Filters::Predictor::_nbResiduals
int _nbResiduals
Definition: Predictor.h:89
FEVV::Filters::Predictor::vertex_descriptor
typename boost::graph_traits< HalfedgeGraph >::vertex_descriptor vertex_descriptor
Definition: Predictor.h:38
FEVV::Filters::Raw_positions::~Raw_positions
~Raw_positions()
Definition: Raw_positions.h:46