Volume Cartographer 2.27.0
|
Base class for 3D transforms. More...
#include <vc/core/types/Transforms.hpp>
Public Types | |
using | Pointer = std::shared_ptr< Transform3D > |
using | Identifier = std::string |
Public Member Functions | |
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 | 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 {"Transform3D"} |
Transform type string constant. More... | |
Protected Types | |
using | Metadata = nlohmann::ordered_json |
Protected Member Functions | |
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 | |
static auto | Serialize (const Pointer &transform) -> Metadata |
static auto | Deserialize (const Metadata &meta) -> Pointer |
Private Attributes | |
std::string | src_ |
std::string | tgt_ |
Base class for 3D transforms.
Provides a common interface for all 3D transforms. Transform implementations should derive from this class and be careful to implement all virtual functions. Because Transform3D objects are polymorphic in nature, they must be constructed on the heap using a New() static function or copied using the clone() member function.
Transforms can be applied from either the base or derived class.
Definition at line 49 of file Transforms.hpp.
using volcart::Transform3D::Identifier = std::string |
Transform identifier type (for VolumePkg)
Definition at line 59 of file Transforms.hpp.
|
protected |
On-disk metadata type
Definition at line 193 of file Transforms.hpp.
using volcart::Transform3D::Pointer = std::shared_ptr<Transform3D> |
Pointer type
Definition at line 56 of file Transforms.hpp.
|
virtualdefault |
Default constructor
|
delete |
Disallow move construction
|
protecteddefault |
Only derived classes can construct
|
protecteddefault |
Only derived classes can copy
|
pure virtual |
Transform a 3D point.
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
auto volcart::Transform3D::applyPointAndNormal | ( | const cv::Vec6d & | ptN, |
bool | normalize = true |
||
) | const -> cv::Vec6d |
Transform a 3D point and surface normal stored in a cv::Vec6d.
This is a convenience function for transforming values stored in a PerPixelMap.
ptN | The point and normal to be transformed. |
normalize | If true (default), the normal component of the output (the last 3 elements in the output) will be normalized. |
auto volcart::Transform3D::applyUnitVector | ( | const cv::Vec3d & | vector | ) | const -> cv::Vec3d |
Transform a 3D direction unit vector.
This is a convenience function for vectors which should be normalized after transformation (e.g. surface normals).
|
pure virtual |
Transform a 3D direction vector.
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
pure virtual |
Clone the transform.
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
virtual |
Return whether the underlying transform is composable.
Reimplemented in volcart::AffineTransform, and volcart::IdentityTransform.
|
static |
Compose two transforms into a single new transform.
Returns a pair of transform pointers. If the composition fails, the pair will contain pointers to both of the original inputs. If the second value in the pair is nullptr, then the composition was successful, and the new transform is available from the first pointer.
|
protectedvirtual |
Helper compose function. The base implementation returns a nullptr. Implementing derived classes should set the returned transform's source to this->source() and the target to rhs->target().
Reimplemented in volcart::AffineTransform, and volcart::IdentityTransform.
Deserialize the transform from metadata
|
protectedpure virtual |
Deserialize the derived class parameters
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
virtual |
Return the inverted transform.
Reimplemented in volcart::AffineTransform, and volcart::IdentityTransform.
|
virtual |
Return whether the underlying transform is invertible.
Reimplemented in volcart::AffineTransform, and volcart::IdentityTransform.
|
protecteddefault |
Only derived classes can copy
|
delete |
Disallow move assignment
|
pure virtual |
Reset the transform parameters.
Resets all parameters controlled by the derived transform. Does not reset base transform properties like source and target.
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
staticprotected |
Serialize the transform to metadata
auto volcart::Transform3D::source | ( | ) | const -> std::string |
Get the source space identifier.
This is a convenience feature for tracking the input and output spaces for the transform. This is usually a Volume::Identifier.
void volcart::Transform3D::source | ( | const std::string & | src | ) |
Set the identifier for the source space.
This is a convenience feature for tracking the input and output spaces for the transform. This is usually a Volume::Identifier.
auto volcart::Transform3D::target | ( | ) | const -> std::string |
Set the identifier for the target space.
This is a convenience feature for tracking the input and output spaces for the transform. This is usually a Volume::Identifier.
void volcart::Transform3D::target | ( | const std::string & | tgt | ) |
Set the identifier for the target space.
This is a convenience feature for tracking the input and output spaces for the transform. This is usually a Volume::Identifier.
|
protectedpure virtual |
Serialize the derived class parameters
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
pure virtual |
Return a string representation of the transform type.
Implemented in volcart::AffineTransform, volcart::IdentityTransform, and volcart::CompositeTransform.
|
private |
Source space identifier
Definition at line 205 of file Transforms.hpp.
|
private |
Target space identifier
Definition at line 207 of file Transforms.hpp.
|
staticconstexpr |
Transform type string constant.
Definition at line 53 of file Transforms.hpp.