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& other) defaulted
Copy constructor.
PointCloud(PointCloud&& other) defaulted
Move constructor.

Public functions

auto operator=(const PointCloud& other) -> PointCloud& defaulted
Copy assignment operator.
auto operator=(PointCloud&& other) -> 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 version)
Serializes the point cloud (for boost::serialization).

Function documentation

Rodin::Geometry::PointCloud::PointCloud(std::uint8_t rows, size_t n) explicit

Constructs n zero-initialized points in rows dimensions.

Parameters
rows Number of rows.
n Number of entries.

Rodin::Geometry::PointCloud::PointCloud(const PointCloud& other) defaulted

Copy constructor.

Parameters
other Object to copy from.

Rodin::Geometry::PointCloud::PointCloud(PointCloud&& other) defaulted

Move constructor.

Parameters
other Object to move from.

PointCloud& Rodin::Geometry::PointCloud::operator=(const PointCloud& other) defaulted

Copy assignment operator.

Parameters
other Object to copy from.
Returns Reference to this object after the operation.

PointCloud& Rodin::Geometry::PointCloud::operator=(PointCloud&& other) defaulted

Move assignment operator.

Parameters
other Object to move from.
Returns Reference to this object after the operation.

std::uint8_t Rodin::Geometry::PointCloud::getDimension() const constexpr noexcept

Returns the active spatial dimension (0..3).

Returns The active spatial dimension (0..3).

std::uint8_t Rodin::Geometry::PointCloud::rows() const constexpr noexcept

Returns the active spatial dimension (Eigen-style row count).

Returns The active spatial dimension (Eigen-style row count).

size_t Rodin::Geometry::PointCloud::cols() const noexcept

Returns the number of points (Eigen-style column count).

Returns The number of points (Eigen-style column count).

size_t Rodin::Geometry::PointCloud::getCount() const noexcept

Returns the number of points.

Returns The number of points.

void Rodin::Geometry::PointCloud::setDimension(std::uint8_t r) noexcept

Sets the active spatial dimension (must not exceed MaxRows).

Parameters
r Number of rows.

void Rodin::Geometry::PointCloud::resize(std::uint8_t r, size_t n)

Resizes to n points in r dimensions.

Parameters
r Number of rows.
n Number of entries.

void Rodin::Geometry::PointCloud::reserve(size_t n)

Reserves storage for n points.

Parameters
n Number of entries.

void Rodin::Geometry::PointCloud::push_back(const std::array<Scalar, 1>& p)

Appends a 1D point (requires active dimension 1).

Parameters
p Point coordinates.

void Rodin::Geometry::PointCloud::push_back(const std::array<Real, 2>& p)

Appends a 2D point (requires active dimension 2).

Parameters
p Point coordinates.

void Rodin::Geometry::PointCloud::push_back(const std::array<Scalar, 3>& p)

Appends a 3D point (requires active dimension 3).

Parameters
p Point coordinates.

void Rodin::Geometry::PointCloud::push_back(const Math::SpatialPoint& p)

Appends a spatial point, zero-padding unused coordinates.

Parameters
p Point at which the operation is evaluated.

Scalar& Rodin::Geometry::PointCloud::operator()(std::uint8_t i, size_t j) noexcept

Returns a reference to coordinate i of point j.

Parameters
i Index of the requested entry.
j Index of the second coordinate.
Returns Value of the expression at the supplied evaluation point.

const Scalar& Rodin::Geometry::PointCloud::operator()(std::uint8_t i, size_t j) const noexcept

Returns a const reference to coordinate i of point j.

Parameters
i Index of the requested entry.
j Index of the second coordinate.
Returns Value of the expression at the supplied evaluation point.

std::array<Scalar, 3>& Rodin::Geometry::PointCloud::point3(size_t j) noexcept

Returns a reference to the packed 3-coordinate storage of point j.

Parameters
j Index of the second coordinate.
Returns A reference to the packed 3-coordinate storage of point j.

const std::array<Scalar, 3>& Rodin::Geometry::PointCloud::point3(size_t j) const noexcept

Returns a const reference to the packed 3-coordinate storage of point j.

Parameters
j Index of the second coordinate.
Returns A const reference to the packed 3-coordinate storage of point j.

Math::SpatialPoint Rodin::Geometry::PointCloud::operator[](size_t j) const noexcept

Returns point j as a SpatialPoint of the active dimension.

Parameters
j Index of the second coordinate.
Returns Entry at the supplied index.

auto Rodin::Geometry::PointCloud::col(size_t j) const noexcept

Returns point j as a SpatialPoint (Eigen-style column accessor).

Parameters
j Index of the second coordinate.
Returns Point j as a SpatialPoint (Eigen-style column accessor).

auto Rodin::Geometry::PointCloud::getMatrix() noexcept

Returns a (rows x N) matrix view of the active coordinates.

Returns A (rows x N) matrix view of the active coordinates.

auto Rodin::Geometry::PointCloud::getMatrix() const noexcept

Returns a (rows x N) matrix view of the active coordinates.

Returns A (rows x N) matrix view of the active coordinates.

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

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

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

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

ConstMapType3xN Rodin::Geometry::PointCloud::getPackedMatrix() const noexcept

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

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

Scalar Rodin::Geometry::PointCloud::dot(const PointCloud& other) const noexcept

Returns the Frobenius inner product of the active coordinates with another point cloud.

Parameters
other Other operand.
Returns The Frobenius inner product of the active coordinates with another point cloud.

template<class EigenDerived>
Scalar Rodin::Geometry::PointCloud::dot(const Eigen::MatrixBase<EigenDerived>& other) const noexcept

Returns the Frobenius inner product of the active coordinates with an Eigen matrix.

Parameters
other Other operand.
Returns The Frobenius inner product of the active coordinates with an Eigen matrix.

Scalar Rodin::Geometry::PointCloud::squaredNorm() const noexcept

Returns the squared Frobenius norm of the active coordinates.

Returns The squared Frobenius norm of the active coordinates.

std::vector<std::array<Scalar, 3>>& Rodin::Geometry::PointCloud::getPoints() noexcept

Returns a reference to the underlying packed point storage.

Returns A reference to the underlying packed point storage.

const std::vector<std::array<Scalar, 3>>& Rodin::Geometry::PointCloud::getPoints() const noexcept

Returns a const reference to the underlying packed point storage.

Returns A const reference to the underlying packed point storage.

void Rodin::Geometry::PointCloud::setConstant(const Scalar& v) noexcept

Sets the active coordinates of all points to v.

Parameters
v Value to assign.

PointCloud& Rodin::Geometry::PointCloud::operator*=(const Scalar& s) noexcept

Scales the active coordinates of all points by s in place.

Parameters
s Scalar factor.
Returns Reference to this object after the operation.

template<class Archive>
void Rodin::Geometry::PointCloud::serialize(Archive& ar, const unsigned int version)

Serializes the point cloud (for boost::serialization).

Parameters
ar Serialization archive.
version Boost.Serialization class version; unused by this implementation.