Rodin::Geometry::PointCloud class

Point cloud with a point-centric API and Eigen "matrix" views.

Ownership: std::vector<Eigen::Vector3<Real>> (always 3 scalars per point). Active dimension: m_rows in {0,1,2,3} tells which prefix is meaningful.

Views:

  • getMatrix(): (rows x N) view for computations in the active dimension.
  • getPackedMatrix(): (3 x N) full view of the underlying packed storage.

Storage layout (AoS): [x0 y0 z0][x1 y1 z1]...

We map it as a column-major 3xN matrix with outer stride 3 and inner stride 1.

Public types

using Scalar = Real
The coordinate scalar type.
using Data = std::vector<std::array<Scalar, 3>>
Underlying packed storage (three coordinates per point).
using StrideType = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>
Eigen stride mapping the packed storage to a column-major view.
using MapType3xN = Eigen::Map<Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>, 0, StrideType>
Mutable Eigen map of the packed storage as a 3-by-N matrix.
using ConstMapType3xN = Eigen::Map<const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>, 0, StrideType>
Const Eigen map of the packed storage as a 3-by-N matrix.

Public static variables

static std::uint8_t MaxRows constexpr
Maximum storable spatial dimension (RODIN_MAXIMAL_SPACE_DIMENSION, fixed at 3).

Constructors, destructors, conversion operators

PointCloud() noexcept
Constructs an empty point cloud (dimension 0, no points).
PointCloud(std::uint8_t rows, size_t n) explicit
Constructs n zero-initialized points in rows dimensions.
PointCloud(const PointCloud&) defaulted
Copy constructor.
PointCloud(PointCloud&&) defaulted
Move constructor.

Public functions

auto operator=(const PointCloud&) -> PointCloud& defaulted
Copy assignment operator.
auto operator=(PointCloud&&) -> PointCloud& defaulted
Move assignment operator.
auto getDimension() const -> std::uint8_t constexpr noexcept
Returns the active spatial dimension (0..3).
auto rows() const -> std::uint8_t constexpr noexcept
Returns the active spatial dimension (Eigen-style row count).
auto cols() const -> size_t noexcept
Returns the number of points (Eigen-style column count).
auto getCount() const -> size_t noexcept
Returns the number of points.
void setDimension(std::uint8_t r) noexcept
Sets the active spatial dimension (must not exceed MaxRows).
void resize(std::uint8_t r, size_t n)
Resizes to n points in r dimensions.
void reserve(size_t n)
Reserves storage for n points.
void clear() noexcept
Removes all points.
void push_back(const std::array<Scalar, 1>& p)
Appends a 1D point (requires active dimension 1).
void push_back(const std::array<Real, 2>& p)
Appends a 2D point (requires active dimension 2).
void push_back(const std::array<Scalar, 3>& p)
Appends a 3D point (requires active dimension 3).
void push_back(const Math::SpatialPoint& p)
Appends a spatial point, zero-padding unused coordinates.
auto operator()(std::uint8_t i, size_t j) -> Scalar& noexcept
Returns a reference to coordinate i of point j.
auto operator()(std::uint8_t i, size_t j) const -> const Scalar& noexcept
Returns a const reference to coordinate i of point j.
auto point3(size_t j) -> std::array<Scalar, 3>& noexcept
Returns a reference to the packed 3-coordinate storage of point j.
auto point3(size_t j) const -> const std::array<Scalar, 3>& noexcept
Returns a const reference to the packed 3-coordinate storage of point j.
auto operator[](size_t j) const -> Math::SpatialPoint noexcept
Returns point j as a SpatialPoint of the active dimension.
auto col(size_t j) const -> auto noexcept
Returns point j as a SpatialPoint (Eigen-style column accessor).
void setZero() noexcept
Sets the active coordinates of all points to zero.
auto getMatrix() -> auto noexcept
Returns a (rows x N) matrix view of the active coordinates.
auto getMatrix() const -> auto noexcept
Returns a (rows x N) matrix view of the active coordinates.
auto getPackedMatrix() -> MapType3xN noexcept
Returns a (3 x N) matrix view of the underlying packed storage.
auto getPackedMatrix() const -> ConstMapType3xN noexcept
Returns a (3 x N) matrix view of the underlying packed storage.
auto dot(const PointCloud& other) const -> Scalar noexcept
Returns the Frobenius inner product of the active coordinates with another point cloud.
template<class EigenDerived>
auto dot(const Eigen::MatrixBase<EigenDerived>& other) const -> Scalar noexcept
Returns the Frobenius inner product of the active coordinates with an Eigen matrix.
auto squaredNorm() const -> Scalar noexcept
Returns the squared Frobenius norm of the active coordinates.
auto getPoints() -> std::vector<std::array<Scalar, 3>>& noexcept
Returns a reference to the underlying packed point storage.
auto getPoints() const -> const std::vector<std::array<Scalar, 3>>& noexcept
Returns a const reference to the underlying packed point storage.
void setConstant(const Scalar& v) noexcept
Sets the active coordinates of all points to v.
auto operator*=(const Scalar& s) -> PointCloud& noexcept
Scales the active coordinates of all points by s in place.
template<class Archive>
void serialize(Archive& ar, const unsigned int)
Serializes the point cloud (for boost::serialization).

Function documentation

MapType3xN Rodin::Geometry::PointCloud::getPackedMatrix() noexcept

Returns a (3 x N) matrix view of the underlying packed storage.

Naming rationale: this is the raw, packed, always-3D storage view.