Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
Point Cloud Analysis library
Loading...
Searching...
No Matches
pointTypes.h
1/*
2This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "./defines.h"
10#include <Eigen/Core>
11
17namespace Ponca
18{
19 // [PointPositionNormal]
21 template <typename _Scalar, int _Dim>
23 {
24 public:
25 enum
26 {
27 Dim = _Dim
28 };
29 using Scalar = _Scalar;
30 using VectorType = Eigen::Matrix<Scalar, Dim, 1>;
31 using MatrixType = Eigen::Matrix<Scalar, Dim, Dim>;
32
33 PONCA_MULTIARCH inline PointPositionNormal(const VectorType& pos = VectorType::Zero(),
34 const VectorType& normal = VectorType::Zero())
35 : m_pos(pos), m_normal(normal)
36 {
37 }
38
40 PONCA_MULTIARCH [[nodiscard]] inline const VectorType& pos() const { return m_pos; }
42 PONCA_MULTIARCH [[nodiscard]] inline const VectorType& normal() const { return m_normal; }
44 PONCA_MULTIARCH [[nodiscard]] inline VectorType& pos() { return m_pos; }
46 PONCA_MULTIARCH [[nodiscard]] inline VectorType& normal() { return m_normal; }
47
48 private:
49 VectorType m_pos, m_normal;
50 };
51 // [PointPositionNormal]
52
53 // [PointPosition]
55 template <typename _Scalar, int _Dim>
57 {
58 public:
59 enum
60 {
61 Dim = _Dim
62 };
63 using Scalar = _Scalar;
64 using VectorType = Eigen::Matrix<Scalar, Dim, 1>;
65 using MatrixType = Eigen::Matrix<Scalar, Dim, Dim>;
66
67 PONCA_MULTIARCH inline PointPosition(const VectorType& pos = VectorType::Zero()) : m_pos(pos) {}
68
70 PONCA_MULTIARCH [[nodiscard]] inline const VectorType& pos() const { return m_pos; }
72 PONCA_MULTIARCH [[nodiscard]] inline VectorType& pos() { return m_pos; }
73
74 private:
75 VectorType m_pos;
76 };
77 // [PointPosition]
78
79 // [PointPositionNormalBinding]
89 template <typename _Scalar, int _Dim>
91 {
92 public:
93 enum
94 {
95 Dim = _Dim
96 };
97 using Scalar = _Scalar;
98 using VectorType = Eigen::Matrix<Scalar, Dim, 1>;
99 using MatrixType = Eigen::Matrix<Scalar, Dim, Dim>;
100
101 PONCA_MULTIARCH inline PointPositionNormalBinding(const Scalar* _interlacedArray, const int _pId)
102 : m_pos(Eigen::Map<const VectorType>(_interlacedArray + Dim * 2 * _pId)),
103 m_normal(Eigen::Map<const VectorType>(_interlacedArray + Dim * 2 * _pId + Dim))
104 {
105 }
106
108 PONCA_MULTIARCH [[nodiscard]] inline const Eigen::Map<const VectorType>& pos() const { return m_pos; }
110 PONCA_MULTIARCH [[nodiscard]] inline const Eigen::Map<const VectorType>& normal() const { return m_normal; }
111
112 private:
113 const Eigen::Map<const VectorType> m_pos, m_normal;
114 };
115 // [PointPositionNormalBinding]
116
117 // [PointPositionNormalLazyBinding]
128 template <typename _Scalar, int _Dim>
130 {
131 public:
132 enum
133 {
134 Dim = _Dim
135 };
136 using Scalar = _Scalar;
137 using VectorType = Eigen::Matrix<Scalar, Dim, 1>;
138 using MatrixType = Eigen::Matrix<Scalar, Dim, Dim>;
139
140 PONCA_MULTIARCH inline PointPositionNormalLazyBinding(Scalar* _interlacedArray, const int _pId)
141 : m_interlacedArray(_interlacedArray), m_id(_pId)
142 {
143 }
144
146 PONCA_MULTIARCH inline void bind(Scalar* _interlacedArray) { m_interlacedArray = _interlacedArray; }
147
149 PONCA_MULTIARCH [[nodiscard]] inline Eigen::Map<const VectorType> pos() const
150 {
151 return Eigen::Map<const VectorType>(m_interlacedArray + Dim * 2 * m_id);
152 }
154 PONCA_MULTIARCH [[nodiscard]] inline Eigen::Map<const VectorType> normal() const
155 {
156 return Eigen::Map<const VectorType>(m_interlacedArray + Dim * 2 * m_id + Dim);
157 }
158
159 private:
160 Scalar* m_interlacedArray;
161 const int m_id;
162 };
163 // [PointPositionNormalLazyBinding]
164} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
Variant of the PointPositionNormal data type that uses external raw data.
Definition pointTypes.h:91
const Eigen::Map< const VectorType > & normal() const
Get the point normal.
Definition pointTypes.h:110
const Eigen::Map< const VectorType > & pos() const
Get the point position.
Definition pointTypes.h:108
Variant of the PointPositionNormal data type that uses external raw data.
Definition pointTypes.h:130
Eigen::Map< const VectorType > pos() const
Get the point position.
Definition pointTypes.h:149
void bind(Scalar *_interlacedArray)
Allows change of reference.
Definition pointTypes.h:146
Eigen::Map< const VectorType > normal() const
Get the point normal.
Definition pointTypes.h:154
Point data type containing the position and normal vectors.
Definition pointTypes.h:23
VectorType & normal()
Get the point normal.
Definition pointTypes.h:46
const VectorType & pos() const
Get the point position.
Definition pointTypes.h:40
const VectorType & normal() const
Get the point normal.
Definition pointTypes.h:42
VectorType & pos()
Get the point position.
Definition pointTypes.h:44
Point data type containing only containing the position vector.
Definition pointTypes.h:57
const VectorType & pos() const
Get the point position.
Definition pointTypes.h:70
VectorType & pos()
Get the point position.
Definition pointTypes.h:72
This Source Code Form is subject to the terms of the Mozilla Public License, v.