Volume Cartographer 2.27.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
volcart::CompositeTransform Class Reference

Collection of transforms. More...

#include <vc/core/types/Transforms.hpp>

Inheritance diagram for volcart::CompositeTransform:
[legend]
Collaboration diagram for volcart::CompositeTransform:
[legend]

Public Types

using Pointer = std::shared_ptr< CompositeTransform >
 
- Public Types inherited from volcart::Transform3D
using Pointer = std::shared_ptr< Transform3D >
 
using Identifier = std::string
 

Public Member Functions

auto type () const -> std::string_view final
 Return a string representation of the transform type. More...
 
auto clone () const -> Transform3D::Pointer final
 Clone the transform. More...
 
void reset () final
 Reset the transform parameters. More...
 
auto applyPoint (const cv::Vec3d &point) const -> cv::Vec3d final
 Transform a 3D point. More...
 
auto applyVector (const cv::Vec3d &vector) const -> cv::Vec3d final
 Transform a 3D direction vector. More...
 
void push_front (const Transform3D::Pointer &t)
 Add a transform to the front of the composite transform stack. More...
 
void push_back (const Transform3D::Pointer &t)
 Add a transform to the end of the composite transform stack. More...
 
auto size () const noexcept -> std::size_t
 Get the number of transforms in the composite transform.
 
void simplify ()
 Compose all composable transforms. More...
 
auto transforms () const -> std::vector< Transform3D::Pointer >
 Get a list of the stored transforms.
 
- Public Member Functions inherited from volcart::Transform3D
virtual ~Transform3D ()=default
 
 Transform3D (Transform3D &&)=delete
 
auto operator= (Transform3D &&other) -> Transform3D &=delete
 
virtual auto type () const -> std::string_view=0
 Return a string representation of the transform type. More...
 
virtual auto clone () const -> Pointer=0
 Clone the transform. More...
 
virtual auto invertible () const -> bool
 Return whether the underlying transform is invertible. More...
 
virtual auto invert () const -> Pointer
 Return the inverted transform. More...
 
virtual auto composable () const -> bool
 Return whether the underlying transform is composable. More...
 
virtual void reset ()=0
 Reset the transform parameters. More...
 
void clear ()
 Clears all parameters and properties of the transform.
 
void source (const std::string &src)
 Set the identifier for the source space. More...
 
auto source () const -> std::string
 Get the source space identifier. More...
 
void target (const std::string &tgt)
 Set the identifier for the target space. More...
 
auto target () const -> std::string
 Set the identifier for the target space. More...
 
virtual auto applyPoint (const cv::Vec3d &point) const -> cv::Vec3d=0
 Transform a 3D point. More...
 
virtual auto applyVector (const cv::Vec3d &vector) const -> cv::Vec3d=0
 Transform a 3D direction vector. More...
 
auto applyUnitVector (const cv::Vec3d &vector) const -> cv::Vec3d
 Transform a 3D direction unit vector. More...
 
auto applyPointAndNormal (const cv::Vec6d &ptN, bool normalize=true) const -> cv::Vec6d
 Transform a 3D point and surface normal stored in a cv::Vec6d. More...
 

Static Public Member Functions

static auto New () -> Pointer
 Create a new CompositeTransform.
 
- Static Public Member Functions inherited from volcart::Transform3D
static auto Compose (const Pointer &lhs, const Pointer &rhs) -> std::pair< Pointer, Pointer >
 Compose two transforms into a single new transform. More...
 
static void Save (const filesystem::path &path, const Pointer &transform)
 Save a transform to a JSON file.
 
static auto Load (const filesystem::path &path) -> Pointer
 Load a transform from a JSON file.
 

Static Public Attributes

static constexpr std::string_view TYPE {"CompositeTransform"}
 Transform type string constant. More...
 
- Static Public Attributes inherited from volcart::Transform3D
static constexpr std::string_view TYPE {"Transform3D"}
 Transform type string constant. More...
 

Private Member Functions

 CompositeTransform ()=default
 
void to_meta_ (Metadata &meta) final
 
void from_meta_ (const Metadata &meta) final
 

Private Attributes

std::list< Transform3D::Pointertfms_
 

Additional Inherited Members

- Protected Types inherited from volcart::Transform3D
using Metadata = nlohmann::ordered_json
 
- Protected Member Functions inherited from volcart::Transform3D
 Transform3D ()=default
 
 Transform3D (const Transform3D &)=default
 
auto operator= (const Transform3D &other) -> Transform3D &=default
 
virtual auto compose_ (const Pointer &rhs) const -> Pointer
 
virtual void to_meta_ (Metadata &meta)=0
 
virtual void from_meta_ (const Metadata &meta)=0
 
- Static Protected Member Functions inherited from volcart::Transform3D
static auto Serialize (const Pointer &transform) -> Metadata
 
static auto Deserialize (const Metadata &meta) -> Pointer
 

Detailed Description

Collection of transforms.

A convenience class which holds a list of transforms. When transforming points and vectors, each transform is applied sequentially to the input.

// New transform
// Add some transforms
t->translate(1, 2, 3);
tfm->push_back(t);
t->reset();
t->scale(4);
tfm->push_back(t);
// Apply all transforms to an input
auto pt = tfm->applyPoint({0, 1, 0}); // {4, 12, 12}
static auto New() -> Pointer
Create a new AffineTransform.
static auto New() -> Pointer
Create a new CompositeTransform.

It can often be preferable, for both performance and numerical stability, to simplify all adjacent, composable transforms (e.g. AffineTransform, IdentityTransform) into a single transform.

// Add some composable transforms
tfm->push_back(AffineTransform::New());
tfm->push_back(IdentityTransform::New());
tfm->push_back(AffineTransform::New());
tfm->size(); // 3
// Simplify the transform
tfm->simplify();
tfm->size(); // 1
static auto New() -> Pointer
Create a new IdentityTransform.

Definition at line 436 of file Transforms.hpp.

Member Typedef Documentation

◆ Pointer

Pointer type

Definition at line 443 of file Transforms.hpp.

Constructor & Destructor Documentation

◆ CompositeTransform()

volcart::CompositeTransform::CompositeTransform ( )
privatedefault

Don't allow construction on the stack

Member Function Documentation

◆ applyPoint()

auto volcart::CompositeTransform::applyPoint ( const cv::Vec3d &  point) const -> cv::Vec3d
finalvirtual

Transform a 3D point.

Implements volcart::Transform3D.

◆ applyVector()

auto volcart::CompositeTransform::applyVector ( const cv::Vec3d &  vector) const -> cv::Vec3d
finalvirtual

Transform a 3D direction vector.

Implements volcart::Transform3D.

◆ clone()

auto volcart::CompositeTransform::clone ( ) const -> Transform3D::Pointer
finalvirtual

Clone the transform.

Implements volcart::Transform3D.

◆ from_meta_()

void volcart::CompositeTransform::from_meta_ ( const Metadata meta)
finalprivatevirtual

Deserialize the derived class parameters

Implements volcart::Transform3D.

◆ push_back()

void volcart::CompositeTransform::push_back ( const Transform3D::Pointer t)

Add a transform to the end of the composite transform stack.

The transform is cloned before being added to the transform stack. If the transform is also a CompositeTransform, its transform stack is expanded and copied to the end of this transform's stack.

◆ push_front()

void volcart::CompositeTransform::push_front ( const Transform3D::Pointer t)

Add a transform to the front of the composite transform stack.

The transform is cloned before being added to the transform stack. If the transform is also a CompositeTransform, its transform stack is expanded and copied to the front of this transform's stack.

◆ reset()

void volcart::CompositeTransform::reset ( )
finalvirtual

Reset the transform parameters.

Resets all parameters controlled by the derived transform. Does not reset base transform properties like source and target.

See also
Transform3D::clear()

Implements volcart::Transform3D.

◆ simplify()

void volcart::CompositeTransform::simplify ( )

Compose all composable transforms.

Simplifies the transform by composing all adjacent, composable transforms in the composite transform list. This can lead to better runtime performance and numerical stability for the apply functions.

◆ to_meta_()

void volcart::CompositeTransform::to_meta_ ( Metadata meta)
finalprivatevirtual

Serialize the derived class parameters

Implements volcart::Transform3D.

◆ type()

auto volcart::CompositeTransform::type ( ) const -> std::string_view
finalvirtual

Return a string representation of the transform type.

Implements volcart::Transform3D.

Member Data Documentation

◆ tfms_

std::list<Transform3D::Pointer> volcart::CompositeTransform::tfms_
private

Transform list

Definition at line 499 of file Transforms.hpp.

◆ TYPE

constexpr std::string_view volcart::CompositeTransform::TYPE {"CompositeTransform"}
staticconstexpr

Transform type string constant.

Definition at line 440 of file Transforms.hpp.


The documentation for this class was generated from the following file: