ImFusion SDK 4.3
GlDenseDeformation Class Reference

#include <ImFusion/GL/GlDenseDeformation.h>

The GlDenseDeformation class represents dense deformations based on a displacement map. More...

+ Inheritance diagram for GlDenseDeformation:

Detailed Description

The GlDenseDeformation class represents dense deformations based on a displacement map.

Public Member Functions

 GlDenseDeformation (int width, int height, int slices)
 Creates a deformation field of the given size.
 
 GlDenseDeformation (const SharedImage *img)
 Creates a deformation field with the same size as img.
 
 GlDenseDeformation (const Image &img)
 Creates a deformation field with the same size as img.
 
 GlDenseDeformation (const ImageDescriptor &desc)
 
 GlDenseDeformation (const GlDenseDeformation &other)
 Copy constructor.
 
Deformationclone () const override
 Returns a copy of the deformation.
 
bool isIdentity () const override
 Returns if the current state of the deformation transformations the image or not.
 
void setIdentity () override
 Sets all displacements to 0.
 
void setChanged ()
 Causes listeners to be notified because the deformation field was changed.
 
void copyFrom (const Deformation &other, const SharedImage &image)
 
vec3 displacement (const vec3 &pos) const override
 Returns the displacement for pos (in world coordinates).
 
int setIncludeArguments (GL::Program &p, const SharedImage *img=nullptr, const std::string &prefix="deform") const override
 Initializes the DenseDeformation shader header to deform the given image.
 
int dimension () const override
 Dimension of the displacement field, either 2 or 3.
 
mat4 transformation () const
 The world transformation of the displacement field.
 
void setTransformation (const mat4 &matrix)
 
void setDisplacement (const SharedImage &d)
 Set displacement in mm.
 
const SharedImagedisplacementField () const
 Returns the complete displacement field.
 
SharedImagedisplacementField ()
 
void configure (const Properties *p) override
 Set one or multiple properties.
 
void configuration (Properties *p) const override
 Retrieve the properties of this object.
 
std::string id () const override
 Returns a unique string identifier for this type of deformation.
 
std::unique_ptr< SharedImageSetsupportingImages () const override
 Returns the images that, together with the configuration, defines the deformation.
 
virtual vec3 displacement (const vec2 &pos) const
 Returns the displacement at the world position pos.
 
- Public Member Functions inherited from Deformation
 Deformation (const std::string &shaderPath)
 Initializes the Deformation with path to the GlInclude file.
 
virtual vec3 displacePoint (const vec3 &point) const
 Returns the displaced position of the given point in world-coordinates.
 
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.
 
- 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::function< std::string(const std::string &)> includeCodeSubstitution () const
 Optionally the abstract include can provide a function to change the shader code.
 
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
 

Static Public Member Functions

static std::unique_ptr< GlDenseDeformationcreateFrom (const Deformation &other, const SharedImage &image, std::optional< ImageDescriptorWorld > domain=std::nullopt)
 Create a new dense deformation field based on a given deformation and image.
 
- 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)
 

Protected Attributes

std::unique_ptr< SharedImagem_disp
 Displacement field.
 
std::unique_ptr< GL::Samplerm_sampler
 
- 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.
 

Additional Inherited Members

- Public Types inherited from MultiIncludable< Deformation, const SharedImage * >
using MultiIncludeType
 Alias for type of a multi-include instance of the original include.
 
- 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 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.
 

Member Function Documentation

◆ createFrom()

static std::unique_ptr< GlDenseDeformation > createFrom ( const Deformation & other,
const SharedImage & image,
std::optional< ImageDescriptorWorld > domain = std::nullopt )
static

Create a new dense deformation field based on a given deformation and image.

Parameters
otherDeformation to use as source, will be evaluated for every voxel of the new dense deformation field.
imageImage to use as reference for size, spacing and transformation of the old deformation field.
domainDomain of the new deformation field. If nullptr, then image is used.

◆ clone()

Deformation * clone ( ) const
overridevirtual

Returns a copy of the deformation.

Implements Deformation.

◆ isIdentity()

bool isIdentity ( ) const
overridevirtual

Returns if the current state of the deformation transformations the image or not.

Implements Deformation.

◆ setIdentity()

void setIdentity ( )
overridevirtual

Sets all displacements to 0.

Implements Deformation.

◆ displacement() [1/2]

vec3 displacement ( const vec3 & pos) const
overridevirtual

Returns the displacement for pos (in world coordinates).

The returned displacement is also in world coordinates. The displacement indicates where pos originated from before applying the deformation.

Implements Deformation.

◆ setIncludeArguments()

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

Initializes the DenseDeformation shader header to deform the given image.

Inside the shader the deformDisplacement function returns the displacement in texture coordinates. If you need them in world coordinates, transform them with SharedImage::textureToWorldMatrix.

Implements Deformation.

◆ dimension()

int dimension ( ) const
overridevirtual

Dimension of the displacement field, either 2 or 3.

Implements Deformation.

◆ transformation()

mat4 transformation ( ) const

The world transformation of the displacement field.

This is the same as displacementField().matrix().

◆ setDisplacement()

void setDisplacement ( const SharedImage & d)

Set displacement in mm.

The given image must be a 3 channel FLOAT image.

◆ displacementField()

const SharedImage & displacementField ( ) const

Returns the complete displacement field.

The returned image is always 3 channel FLOAT. Each pixel is a 3D displacement vector in mm (world coordinates). Use SharedImage::texture/pixelToWorld and SharedImage::worldToTexture/Pixel to convert between coordinates.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Set one or multiple properties.

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieve the properties of this object.

Reimplemented from Configurable.

◆ 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.

◆ supportingImages()

std::unique_ptr< SharedImageSet > supportingImages ( ) const
overridevirtual

Returns the images that, together with the configuration, defines the deformation.

See also
DeformationFactory

Reimplemented from Deformation.

◆ displacement() [2/2]

virtual vec3 displacement ( const vec2 & pos) const
virtual

Returns the displacement at the world position pos.

The base implementation just calls displacement(vec3(pos,0.0))

Reimplemented from Deformation.


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