mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
point.h
Go to the documentation of this file.
1 #ifndef MF_POINT_CLOUD_POINT_H_
2 #define MF_POINT_CLOUD_POINT_H_
3 
4 #include "../color.h"
5 #include "../eigen.h"
6 #include "../elem.h"
7 #include "../elem_tuple.h"
8 
9 namespace mf {
10 
12 
14 struct point_xyz {
16 
19 
20  point_xyz(const Eigen_vec3& pos) :
21  homogeneous_coordinates(pos[0], pos[1], pos[2], 1.0) { }
22 
23  auto position() { return homogeneous_coordinates.head<3>(); }
24  auto position() const { return homogeneous_coordinates.head<3>(); }
25 
26  bool is_null() const noexcept { return (homogeneous_coordinates[3] != 1.0); }
27 };
28 
29 
30 template<>
31 struct elem_traits<point_xyz> : elem_traits_base<point_xyz, Eigen_scalar, 3, true> { };
32 
33 
35 struct point_xyzrgb : elem_tuple<point_xyz, rgb_color> {
37 
38  point_xyzrgb(const base& tup) : base(tup) { }
39 
40  point_xyzrgb(const point_xyz& xyz) :
41  base(Eigen_vec3(xyz.position()), rgb_color{255,255,255}) { }
42 
43  auto position() { return get<0>(*this).position(); }
44  auto position() const { return get<0>(*this).position(); }
45 
46  rgb_color& color() { return get<1>(*this); }
47  const rgb_color& color() const { return get<1>(*this); }
48 };
49 
50 
52 struct point_full : elem_tuple<point_xyz, Eigen_vec3, Eigen_scalar, rgb_color> {
54 
55  point_full(const base& tup) : base(tup) { }
56 
57  point_full(const point_xyz& xyz) :
58  base(Eigen_vec3(xyz.position()), Eigen_vec3::Zero(), 1.0, rgb_color{255,255,255}) { }
59 
60  point_full(const point_xyzrgb& xyzrgb) :
61  base(Eigen_vec3(xyzrgb.position()), Eigen_vec3::Zero(), 1.0, xyzrgb.color()) { }
62 
63  auto position() { return get<0>(*this).position(); }
64  auto position() const { return get<0>(*this).position(); }
65 
66  Eigen_vec3& normal() { return get<1>(*this); }
67  const Eigen_vec3& normal() const { return get<1>(*this); }
68 
69  Eigen_scalar& weight() { return get<2>(*this); }
70  const Eigen_scalar& weight() const { return get<2>(*this); }
71 
72  rgb_color& color() { return get<3>(*this); }
73  const rgb_color& color() const { return get<3>(*this); }
74 };
75 
76 
77 }
78 
79 #endif
rgb_color & color()
Definition: point.h:72
auto position() const
Definition: point.h:64
real Eigen_scalar
Floating point type used for Eigen objects.
Definition: eigen.h:19
Point cloud point with XYZ coordinates, and RGB color.
Definition: point.h:35
Eigen_vec3 & normal()
Definition: point.h:66
auto position()
Definition: point.h:43
Heterogeneous tuple of items.
Definition: elem_tuple.h:16
const rgb_color & color() const
Definition: point.h:73
bool is_null() const noexcept
Definition: point.h:26
Point cloud point with only XYZ coordinates.
Definition: point.h:14
point_xyz()
Definition: point.h:17
Point cloud point with XYZ coordinates, normal vector, weight, and RGB color.
Definition: point.h:52
auto position() const
Definition: point.h:24
const Eigen_vec3 & normal() const
Definition: point.h:67
point_xyz(const Eigen_vec3 &pos)
Definition: point.h:20
Eigen_scalar & weight()
Definition: point.h:69
Elem traits base class with the required members.
Definition: elem.h:14
point_full(const base &tup)
Definition: point.h:55
Eigen_vec4 homogeneous_coordinates
Definition: point.h:15
auto position() const
Definition: point.h:44
point_full(const point_xyzrgb &xyzrgb)
Definition: point.h:60
rgb_color & color()
Definition: point.h:46
Default elem traits, using Elem as standard layout scalar type.
Definition: elem.h:30
auto position()
Definition: point.h:63
point_xyzrgb(const base &tup)
Definition: point.h:38
const Eigen_scalar & weight() const
Definition: point.h:70
RGB color, 8 bit.
Definition: color.h:27
point_full(const point_xyz &xyz)
Definition: point.h:57
const rgb_color & color() const
Definition: point.h:47
Eigen_mat< 4, 1 > Eigen_vec4
Definition: eigen.h:26
Eigen_mat< 3, 1 > Eigen_vec3
Definition: eigen.h:25
point_xyzrgb(const point_xyz &xyz)
Definition: point.h:40
auto position()
Definition: point.h:23