ImFusion SDK 4.3
GlPolyRigidDeformation Class Reference

#include <ImFusion/Reg/GlPolyRigidDeformation.h>

Poly-rigid deformation class. More...

+ Inheritance diagram for GlPolyRigidDeformation:

Detailed Description

Poly-rigid deformation class.

Based on inverse distance weighting using the positions of the rigid segments before deformation. To-world matrices for both deformed and undeformed rigid segments have to be provided separately. Note that excessive stretching may cause tearing in the displacement field due to numerical limitations. Does not have a CPU mode.

Classes

struct  RigidSegmentParameters
 

Public Types

enum class  Mode { BACKWARD = 0 , FORWARD = 1 , ONLYRIGID = 2 }
 
- Public Types inherited from MultiIncludable< Deformation, const SharedImage * >
using MultiIncludeType
 Alias for type of a multi-include instance of the original include.
 

Public Member Functions

 GlPolyRigidDeformation (std::unique_ptr< SharedImageSet > distVol, const SharedImageSet &refVol, SharedImageSet *multiLabelMap=nullptr)
 Constructor with distance volumes for the individual rigid segments Does not take ownership of.
 
 GlPolyRigidDeformation (std::unique_ptr< SharedImageSet > distVol, const SharedImageSet &refVol, std::unique_ptr< SharedImageSet > multiLabelMap)
 Constructor with distance volumes for the individual rigid segments.
 
 GlPolyRigidDeformation (SharedImageSet &labelMap, const SharedImageSet &refVol)
 Constructor that computes distance volumes from a label map.
 
 GlPolyRigidDeformation (const GlPolyRigidDeformation &other)
 Copy constructor. Warning: ownership of the labelMap is not transferred.
 
 ~GlPolyRigidDeformation () override
 Destructor.
 
Deformationclone () const override
 Clone method which calls the copy constructor.
 
SharedImageSetdistanceVolumes ()
 Access to the distance volumes in order to e.g. update its matrices.
 
void setSegmentMatrices (const std::vector< mat4 > &v)
 Current/deformed to-world matrices of the rigid segments.
 
void setInitialSegmentMatrices (const std::vector< mat4 > &v)
 Initial/undeformed to-world matrices of the rigid segments.
 
std::shared_ptr< GlDenseDeformationforwardDef ()
 
std::shared_ptr< GlDenseDeformationbackwardDef ()
 
void setSphereMode (bool v)
 
void setParametersToUse (const RigidSegmentParameters &params, int segmentIdx=-1)
 Specify which parts of the rigid segment poses are used by the setParameters/parameters functions.
 
void setParameters (const std::vector< double > &pars) override
 Set the parameters of the deformation, effectively calls setSegmentMatrices.
 
void parameters (std::vector< double > &parsOut) const override
 Retrieve the current parameters of the deformation.
 
void setMode (Mode mode)
 Set the mode.
 
Mode mode ()
 
void setUseDistanceExponentialAsParam (bool v)
 Sets whether to treat the distance exponential as an optimization parameter.
 
int numberOfParameters () const override
 Returns the number of parameters e.g. for optimization.
 
void setInversionSteps (int v)
 
std::string id () const override
 Returns a unique string identifier for this type of deformation.
 
- Public Member Functions inherited from ParametricDeformation
 ParametricDeformation (const std::string &shaderPath)
 Initializes the parametric deformation with path to the GlInclude file.
 
 ~ParametricDeformation () override
 Destructor.
 
virtual void setDisplacement (const std::vector< vec3f > &d)
 Set displacement in mm for all control points if applicable For 2D images the z-coordinate of the displacement is ignored.
 
virtual std::vector< vec3f > displacements () const
 Get displacement in mm of all control points if applicable.
 
virtual std::vector< vec3 > controlPoints () const
 Returns a list of all control points in world coordinates (might be empty for certain models)
 
virtual int numberOfControlPoints () const
 Returns the number of control points (may be zero for certain deformations)
 
- Public Member Functions inherited from Deformation
 Deformation (const std::string &shaderPath)
 Initializes the Deformation with path to the GlInclude file.
 
virtual vec3 displacement (const vec2 &pos) const
 Returns the displacement at the world position pos.
 
void setDisabled (bool flag)
 Set a disabled flag in order to hide the visualization of this deformation.
 
bool disabled () const
 Return whether the deformation was set to disabled.
 
virtual std::unique_ptr< SharedImageSetsupportingImages () const
 Returns the images that, together with the configuration, defines the deformation.
 
- Public Member Functions inherited from AbstractInclude
 AbstractInclude (const std::string &defineName, const std::string &includePath)
 Creates a AbstractInclude for the given define and with the corresponding GLSL file at includePath.
 
const std::stringdefineName () const
 Returns the name of define used by this include.
 
const std::stringincludePath () const
 Returns the path to the included shader file.
 
virtual std::vector< AbstractInclude * > dependentIncludes () const
 Returns a list of dependent abstract includes that need to be included as well.
 
virtual Fingerprint fingerprint () const
 Provides a finger print of the include.
 
- Public Member Functions inherited from MultiIncludable< Deformation, const SharedImage * >
std::shared_ptr< MultiIncludeTypecreateMultiInclude (const std::string &replacementToken)
 Instantiates a new AbstractInclude instance where all occurrences of baseToken provided during construction are replaces with replacementToken according to the specified replacementScheme.
 
virtual int setIncludeArguments (Program &prog, IncludeArgumentsTypes... includeArgs, const std::string &token) const=0
 Interface that multi includes should use to configure the shader include (such as setting uniforms, binding textures, etc).
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
 
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
 

Public Attributes

Signal signalCachedDeformChanged
 
- Public Attributes inherited from Deformation
Signal< const DeformationEvent & > signalChanged
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Protected Member Functions

 GlPolyRigidDeformation (SharedImageSet *multiLabel, const SharedImageSet &refVol)
 Constructor that computes distance volumes from a multi-label map.
 
void recomputeDeformation () const
 If m_dirty=true, sets m_dirty=false and recomputes deformation.
 
- Protected Member Functions inherited from Deformation
void notifyListeners (const DeformationEvent &event) const
 convenience function to call signalChanged.emitSignal(event).
 
- Protected Member Functions inherited from MultiIncludable< Deformation, const SharedImage * >
 MultiIncludable (Deformation *crtpInstance, const std::string &baseToken, Flags< ShaderTextReplacement > replacementScheme)
 Instantiate and configure the MultiIncludable interface.
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Protected Attributes

const SharedImageSetm_refVol
 
Mode m_mode = Mode::BACKWARD
 
std::unique_ptr< SharedImageSetm_distVol
 The distance volume(s)
 
int m_convergenceFallbackMode = 0
 No convergence: 0 = discard voxel, 1 = best guess, 2 = best guess unless it maps to rigid segment.
 
float m_distanceExponential = 1.5
 Exponential of the inverse distance for weighting.
 
int m_inversionSteps = 50
 
std::vector< mat4 > m_segmentMats
 Current to-world matrices of the rigid segments.
 
std::vector< mat4 > m_segmentInitialMats
 Initial to-world matrices of the rigid segments.
 
bool m_deformationDirty = true
 Indicates if the Deformation needs to be recomputed.
 
std::unique_ptr< GL::ImageProgramm_extractDefProg
 
std::shared_ptr< GlDenseDeformationm_forwardDef
 
std::shared_ptr< GlDenseDeformationm_backwardDef
 
bool m_sphereMode = false
 Simplified mode using control points with spherical influence, not requiring distance volumes.
 
std::vector< RigidSegmentParametersm_segmentParamsToUse
 
RigidSegmentParameters m_defaultSegmentParams
 
bool m_distanceExponentialAsParam = false
 
SharedImageSetm_labelMap = nullptr
 
std::unique_ptr< SharedImageSetm_labelMapOwner
 
- Protected Attributes inherited from Deformation
bool m_disabled
 Disabled flag for visualization.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Methods implementing the required base class functionality

int dimension () const override
 
vec3 displacement (const vec3 &pos) const override
 Does nothing due to lack of CPU mode.
 
vec3 displacePoint (const vec3 &pos) const override
 Returns the displaced position of the given point in world-coordinates.
 
int setIncludeArguments (GL::Program &p, const SharedImage *img=nullptr, const std::string &prefix="deform") const override
 Override default arguments for GlMask includes.
 
std::function< std::string(const std::string &)> includeCodeSubstitution () const override
 Optionally the abstract include can provide a function to change the shader code.
 
bool isIdentity () const override
 Checks whether the deformed and undeformed segment matrices match.
 
void setIdentity () override
 Removes the deformation by pretenting the rigid segments have always been in the current position.
 

Methods implementing the Configurable interface

void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
 
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
 

Additional Inherited Members

- Static Public Member Functions inherited from Deformation
static std::string defineName ()
 Returns the define name of GlAbstractInclude for all deformations.
 
static std::string defineSuffix ()
 Returns "DEFORM".
 
static std::string multiIncludeDefine (const std::string &replacementToken)
 Returns "IMAGE_" + toUpper(replacementToken)
 

Member Enumeration Documentation

◆ Mode

enum class Mode
strong
Enumerator
FORWARD 

Compute deformation based on forward model, then invert it.

ONLYRIGID 

Compute deformation based on backwards model directly.

Constructor & Destructor Documentation

◆ GlPolyRigidDeformation() [1/2]

GlPolyRigidDeformation ( std::unique_ptr< SharedImageSet > distVol,
const SharedImageSet & refVol,
SharedImageSet * multiLabelMap = nullptr )

Constructor with distance volumes for the individual rigid segments Does not take ownership of.

Parameters
multiLabelMap

◆ GlPolyRigidDeformation() [2/2]

GlPolyRigidDeformation ( SharedImageSet & labelMap,
const SharedImageSet & refVol )

Constructor that computes distance volumes from a label map.

If labelMap is not already split into one frame per label, a temporary version of this type is created and owned by this object. In this case, updates via setParameters will not be propagated to the input label map.

Member Function Documentation

◆ clone()

Deformation * clone ( ) const
overridevirtual

Clone method which calls the copy constructor.

Implements Deformation.

◆ dimension()

int dimension ( ) const
overridevirtual

Spatial dimensions of the input data (or rather the distance maps)

Implements Deformation.

◆ displacement()

vec3 displacement ( const vec3 & pos) const
overridevirtual

Does nothing due to lack of CPU mode.

Implements Deformation.

◆ displacePoint()

vec3 displacePoint ( const vec3 & pos) const
overridevirtual

Returns the displaced position of the given point in world-coordinates.

Reimplemented from Deformation.

◆ setIncludeArguments()

int setIncludeArguments ( GL::Program & p,
const SharedImage * img = nullptr,
const std::string & prefix = "deform" ) const
overridevirtual

Override default arguments for GlMask includes.

Implements Deformation.

◆ includeCodeSubstitution()

std::function< std::string(const std::string &)> includeCodeSubstitution ( ) const
overridevirtual

Optionally the abstract include can provide a function to change the shader code.

This function will be called after the shader include has been loaded from includePath() and receives the include code as argument. The function can then modify the code and is supposed to return the modified GLSL code. This can be used to include two instances of the same include by for example prefixing every uniform and function. The default implementation returns NULL and therefore does not change the code.

Reimplemented from AbstractInclude.

◆ isIdentity()

bool isIdentity ( ) const
overridevirtual

Checks whether the deformed and undeformed segment matrices match.

Implements Deformation.

◆ setIdentity()

void setIdentity ( )
overridevirtual

Removes the deformation by pretenting the rigid segments have always been in the current position.

Implements Deformation.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from Configurable.

◆ setParametersToUse()

void setParametersToUse ( const RigidSegmentParameters & params,
int segmentIdx = -1 )

Specify which parts of the rigid segment poses are used by the setParameters/parameters functions.

setInitialSegmentMatrices should have been used beforehand to configure the number of rigid segments. If segmentIdx is less than zero, the configuration is applied to all segments.

◆ setParameters()

void setParameters ( const std::vector< double > & pars)
overridevirtual

Set the parameters of the deformation, effectively calls setSegmentMatrices.

Reimplemented from ParametricDeformation.

◆ parameters()

void parameters ( std::vector< double > & parsOut) const
overridevirtual

Retrieve the current parameters of the deformation.

Reimplemented from ParametricDeformation.

◆ numberOfParameters()

int numberOfParameters ( ) const
overridevirtual

Returns the number of parameters e.g. for optimization.

Reimplemented from ParametricDeformation.

◆ id()

std::string id ( ) const
inlineoverridevirtual

Returns a unique string identifier for this type of deformation.

Usually the name of the class.

Note
To avoid conflicts make sure to include potential plugin names into this ID. Due to the modular architecture of the ImFusion library, uniqueness of IDs cannot be checked at compile time. However, DeformationFactory will check the uniqueness of the ID during registration.
See also
DeformationFactory

Implements Deformation.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close