![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/Deformation.h>
Base class for different kinds of non-linear image transformations. More...
Inheritance diagram for Deformation:Base class for different kinds of non-linear image transformations.
The transformations are defined inversely, i.e. they do not describe how a point has to be displaced, but where a point originates from. If x is a point in world coordinates and g(x) the same point after applying the deformation, the displacement disp describes:
and NOT:
This means, for each point in world coordinates (g(x)) one can directly determine where this point originates from (x). However, one can not directly tell where a point x will be displaced to because non-linear deformations are not always reversible.. While this may seem is very useless to transform individual points, it is very helpful when deforming images. * When deforming an image, one can iterate the pixels of the resulting deformed image and look-up the values in the original, undeformed image. To get the deformed position of an individual point, use the displacePoint method.
Derived classes should provide a CPU and OpenGL implementation. A generic OpenGL interface is provided by a GlAbstractInclude. Similar as with GlMask, you can use several different deformation fields in the same shader by using the helper class DeformationMultiInclude.
In order to work with DeformationMultiInclude, derived classes need to comply with the following requirements:
Public Member Functions | |
| Deformation (const std::string &shaderPath) | |
| Initializes the Deformation with path to the GlInclude file. | |
| virtual Deformation * | clone () const =0 |
| Returns a copy of the deformation. | |
| virtual vec3 | displacement (const vec3 &pos) const =0 |
| Returns the displacement for pos (in world coordinates). | |
| virtual vec3 | displacement (const vec2 &pos) const |
| Returns the displacement at the world position pos. | |
| virtual vec3 | displacePoint (const vec3 &point) const |
| Returns the displaced position of the given point in world-coordinates. | |
| virtual bool | isIdentity () const =0 |
| Returns if the current state of the deformation transformations the image or not. | |
| virtual void | setIdentity ()=0 |
| Sets all displacements to 0. | |
| int | setIncludeArguments (GL::Program &p, const SharedImage *img=nullptr, const std::string &prefix="deform") const override=0 |
| Override default arguments for GlMask includes. | |
| 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 int | dimension () const =0 |
| Returns the dimension of the deformation. | |
| virtual std::string | id () const =0 |
| Returns a unique string identifier for this type of deformation. | |
| virtual std::unique_ptr< SharedImageSet > | supportingImages () 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::string & | defineName () const |
| Returns the name of define used by this include. | |
| const std::string & | includePath () 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< MultiIncludeType > | createMultiInclude (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 | configure (const Properties *p) |
| Configure this object instance by de-serializing the given Properties. | |
| virtual void | configuration (Properties *p) const |
| Serialize the current object configuration into the given Properties object. | |
| 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 | |
| Configurable & | operator= (const Configurable &) |
| Configurable & | operator= (Configurable &&) noexcept |
Static Public Member Functions | |
| 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) | |
Public Attributes | |
| 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 | |
| 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 Attributes | |
| bool | m_disabled |
| Disabled flag for visualization. | |
Protected Attributes inherited from Configurable | |
| std::vector< Param > | m_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. | |
|
pure virtual |
Returns a copy of the deformation.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
static |
Returns the define name of GlAbstractInclude for all deformations.
Always returns IMAGE_DEFORM
|
pure virtual |
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.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
virtual |
Returns the displacement at the world position pos.
The base implementation just calls displacement(vec3(pos,0.0))
Reimplemented in FreeFormDeformation, and GlDenseDeformation.
|
virtual |
Returns the displaced position of the given point in world-coordinates.
This method will estimate the inverse displacement.
Reimplemented in GlFlattenTrackingDeformation, and GlPolyRigidDeformation.
|
pure virtual |
Returns if the current state of the deformation transformations the image or not.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
pure virtual |
Sets all displacements to 0.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
overridepure virtual |
Override default arguments for GlMask includes.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
pure virtual |
Returns the dimension of the deformation.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
pure virtual |
Returns a unique string identifier for this type of deformation.
Usually the name of the class.
Implemented in FreeFormDeformation, GlDenseDeformation, GlFlattenTrackingDeformation, GlPolyRigidDeformation, GlTPSDeformation, OperandDeformation< T >, GlProbeDeformation, and GlSweepStretchDeformation.
|
inlinevirtual |
Returns the images that, together with the configuration, defines the deformation.
Reimplemented in GlDenseDeformation.