Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mirtk::DeformableSurfaceModel Class Reference

#include <DeformableSurfaceModel.h>

Inheritance diagram for mirtk::DeformableSurfaceModel:
Inheritance graph
Collaboration diagram for mirtk::DeformableSurfaceModel:
Collaboration graph

Public Member Functions

void Add (class ExternalForce *, bool=true)
 Add external force term and take over ownership of the object.
 
void Add (class InternalForce *, bool=true)
 Add internal force term and take over ownership of the object.
 
void Add (TransformationConstraint *, bool=true)
 Add transformation regularization term and take over ownership of the object.
 
void Clear ()
 Delete previously added energy terms.
 
 DeformableSurfaceModel ()
 Constructor.
 
bool Empty () const
 Whether energy function has no terms.
 
virtual double Evaluate (double *dx=NULL, double step=.0, bool *sgn_chg=NULL)
 
class ExternalForceExternalForce (int)
 Get the n-th external force term.
 
const class ExternalForceExternalForce (int) const
 Get the n-th external force term.
 
virtual void Get (double *x) const
 
virtual double Get (int) const
 
void Gradient (double *dx, double step=.0, bool *sgn_chg=NULL)
 
double GradientNorm (const double *) const
 
void GradientStep (const double *dx, double &min, double &max) const
 
virtual void Initialize ()
 Initialize energy terms once input and parameters have been set.
 
double InitialValue ()
 Query/evaluate initial value of energy function.
 
double InitialValue (int)
 Get initial value of n-th energy term.
 
class InternalForceInternalForce (int)
 Get the n-th internal force term.
 
const class InternalForceInternalForce (int) const
 Get the n-th internal force term.
 
bool IsExternalForce (int) const
 Determine whether n-th energy term is an external force.
 
bool IsImplicitSurfaceForce (int) const
 Determine whether n-th energy term is an external implicit surface force.
 
bool IsInternalForce (int) const
 Determine whether n-th energy term is an internal force.
 
virtual int NumberOfDOFs () const
 Get number of deformable surface parameters.
 
int NumberOfExternalForces () const
 Number of external force terms.
 
int NumberOfForces () const
 Number of energy terms.
 
int NumberOfInternalForces () const
 Number of internal force terms.
 
int NumberOfPoints () const
 Get number of deformable surface points.
 
vtkSmartPointer< vtkPointSet > Output () const
 Output surface mesh.
 
virtual ParameterList Parameter () const
 Get parameter as key/value as string map.
 
virtual void Put (const double *x)
 
double RawValue (int)
 
virtual bool Remesh ()
 
virtual bool Set (const char *, const char *)
 Set parameter value from string.
 
virtual double Step (double *dx)
 
void Sub (class ExternalForce *)
 Remove external force term and revoke ownership of the object.
 
void Sub (class InternalForce *)
 Remove internal force term and revoke ownership of the object.
 
void Sub (TransformationConstraint *)
 Remove transformation regularization term and revoke ownership of the object.
 
EnergyTermTerm (int)
 Get the n-th energy term.
 
const EnergyTermTerm (int) const
 Get the n-th energy term.
 
virtual void Update (bool=true)
 Update internal state after change of parameters.
 
virtual bool Upgrade ()
 
double Value ()
 Evaluate energy function.
 
double Value (int)
 Get value of n-th energy term computed upon last evaluation.
 
virtual void WriteDataSets (const char *, const char *, bool=true) const
 Write input of data force terms.
 
virtual void WriteGradient (const char *, const char *) const
 Write gradient of force terms.
 
virtual ~DeformableSurfaceModel ()
 Destructor.
 
- Public Member Functions inherited from mirtk::ObjectiveFunction
virtual void AddConstraintGradient (double *dx, double step=.0, bool *sgn_chg=nullptr)
 
virtual void DataFidelityGradient (double *dx, double step=.0, bool *sgn_chg=nullptr)
 
virtual ~ObjectiveFunction ()=0
 Destructor.
 
- Public Member Functions inherited from mirtk::Observable
void AddObserver (Observer &)
 Add observer.
 
void Broadcast (Event, const void *=NULL)
 Broadcast event to observers.
 
void ClearObservers ()
 Delete all observers.
 
void DeleteObserver (Observer &)
 Delete observer.
 
void NotifyObservers (Event, const void *=NULL)
 Notify all observers about given event if this object has changed.
 
int NumberOfObservers () const
 Number of current observers.
 
virtual ~Observable ()
 Destructor.
 
- Public Member Functions inherited from mirtk::Object
virtual const char * NameOfClass () const =0
 Get name of class, which this object is an instance of.
 
bool Parameter (const ParameterList &)
 Set parameters from name/value pairs.
 
virtual ~Object ()
 Destructor.
 

Static Public Member Functions

static bool IsExternalForce (const EnergyTerm *)
 Determine whether a given force term is an external force.
 
static bool IsImplicitSurfaceForce (const EnergyTerm *)
 Determine whether a given force term is an external implicit surface force.
 
static bool IsInternalForce (const EnergyTerm *)
 Determine whether a given force term is an internal force.
 
- Static Public Member Functions inherited from mirtk::Object
static const char * NameOfType ()
 Get name of this class type.
 

Protected Member Functions

virtual void EnforceHardConstraints (double *dx) const
 
void ResolveSurfaceCollisions (double *dx, bool nsi, double mind, double minw) const
 
virtual void SmoothGradient (double *dx) const
 Smooth gradient such that neighboring points move coherently.
 
- Protected Member Functions inherited from mirtk::ObjectiveFunction
 mirtkAttributeMacro (double, StepLength)
 Default step length used for gradient approximation.
 
- Protected Member Functions inherited from mirtk::Observable
 Observable ()
 Default constructor.
 
 Observable (const Observable &)
 Copy constructor.
 
Observableoperator= (const Observable &)
 Assignment operator.
 
- Protected Member Functions inherited from mirtk::Object
template<typename... Args>
void Throw (ErrorType err, const char *func, Args... args) const
 

Protected Attributes

Array< vtkSmartPointer< vtkPolyData > > _BoundaryConstraint
 Input surface meshes which the deformed surface mesh may not intersect.
 
Array< TransformationConstraint * > _Constraint
 Energy terms which regularize the parametric transformation.
 
Array< class ExternalForce * > _ExternalForce
 Energy terms corresponding to external forces.
 
Array< class InternalForce * > _InternalForce
 Energy terms corresponding to internal forces.
 
int _LowPassCounter
 Number of iterations since last low-pass filtering.
 

Additional Inherited Members

- Static Protected Member Functions inherited from mirtk::Object
template<typename... Args>
static void ThrowStatic (ErrorType err, const char *cls, const char *func, Args... args)
 

Detailed Description

Energy function describing a deformable surface model

Definition at line 48 of file DeformableSurfaceModel.h.

Member Function Documentation

§ EnforceHardConstraints()

virtual void mirtk::DeformableSurfaceModel::EnforceHardConstraints ( double *  dx) const
protectedvirtual

Enforce hard constraints on surface model deformation

This function clamps a nodes' displacement vector (velocity times \(\delta t\)), if otherwise the hard constraints of the deformable surface model would be violated. Common hard constraints are non-self-intersection and a maximum total node displacement. If the surface model is deformed by a parametric transformation, this function does nothing as hard constraints can only be enforced during the optimization when the parameters of the deformable surface model are the positions of the individual surface nodes.

Parameters
[in,out]dx(Scaled) gradient of objective function.

§ Evaluate()

virtual double mirtk::DeformableSurfaceModel::Evaluate ( double *  dx = NULL,
double  step = .0,
bool *  sgn_chg = NULL 
)
virtual

Evaluate energy function

This function first updates the internal state of the function object if required due to a previous change of the function parameters and then evaluates the current energy function value.

Parameters
[in]stepStep length for finite differences.
[out]dxGradient of objective function. If NULL, only the function value is computed.
[out]sgn_chgWhether function parameter value is allowed to change sign when stepping along the computed gradient. Ignord if dx is NULL.

Reimplemented from mirtk::ObjectiveFunction.

§ Get() [1/2]

virtual void mirtk::DeformableSurfaceModel::Get ( double *  x) const
virtual

Get deformable surface parameters

This function can be used to store a backup of the current deformable surface parameters before an update such that these can be restored using the Put member function if the update did not result in the desired change of the overall energy.

Parameters
[in]xCurrent values of deformable surface parameters (DoFs).

Implements mirtk::ObjectiveFunction.

§ Get() [2/2]

virtual double mirtk::DeformableSurfaceModel::Get ( int  ) const
virtual

Get function parameter value

Returns
Value of specified function parameter (DoF).

Implements mirtk::ObjectiveFunction.

§ Gradient()

void mirtk::DeformableSurfaceModel::Gradient ( double *  dx,
double  step = .0,
bool *  sgn_chg = NULL 
)
virtual

Evaluate gradient of energy function

This gradient corresponds to the weighted sum of external and internal forces of the deformable surface model.

Parameters
[in]dxGradient of energy function.
[in]stepStep length for finite differences.
[out]sgn_chgWhether function parameter value is allowed to change sign when stepping along the computed gradient.

Implements mirtk::ObjectiveFunction.

§ GradientNorm()

double mirtk::DeformableSurfaceModel::GradientNorm ( const double *  ) const
virtual

Compute norm of gradient of energy function

This norm can, for example, be the maximum absolute parameter change, the maximum control point displacement if a FFD transformation is used to deform the initial surface mesh, or the maximum vertex displacement.

Implements mirtk::ObjectiveFunction.

§ GradientStep()

void mirtk::DeformableSurfaceModel::GradientStep ( const double *  dx,
double &  min,
double &  max 
) const
virtual

Adjust step length range

Parameters
[in]dxGradient of objective function.
[in,out]minMinimum step length.
[in,out]maxMaximum step length.

Reimplemented from mirtk::ObjectiveFunction.

§ Put()

virtual void mirtk::DeformableSurfaceModel::Put ( const double *  x)
virtual

Set deformable surface parameters

This function can be used to restore the deformable surface parameters after a failed update which did not result in the desired improvement.

Parameters
[in]xValue of deformable surface parameters (DoFs).

Implements mirtk::ObjectiveFunction.

§ RawValue()

double mirtk::DeformableSurfaceModel::RawValue ( int  )

Get unweighted and unnormalized value of n-th energy term

Remarks
Use for progress reporting only.

§ Remesh()

virtual bool mirtk::DeformableSurfaceModel::Remesh ( )
virtual

Perform local adaptive remeshing

Returns
Whether the surface model has been remeshed. The Update function must be called after such remeshing operation before evaluating the energy and/or gradient of the deformable surface model.

§ ResolveSurfaceCollisions()

void mirtk::DeformableSurfaceModel::ResolveSurfaceCollisions ( double *  dx,
bool  nsi,
double  mind,
double  minw 
) const
protected

Adjust node displacements to avoid self-intersections and collisions

Parameters
[in,out]dx(Scaled) gradient of objective function.
[in]nsiEnforce non-self-intersection.
[in]mindMinimum front-facing distance.
[in]minwMinimum back-facing distance.

§ Step()

virtual double mirtk::DeformableSurfaceModel::Step ( double *  dx)
virtual

Add change (i.e., scaled gradient) to each deformable surface parameter

This function updates each parameter of the deformable surface model given a vector of desired changes, i.e., the computed gradient of the energy function.

Parameters
[in,out]dxChange of each function parameter (DoF) as computed by the Gradient member function and scaled by a chosen step length. The change of a parameter may be modified by this function in order to satisfy the hard constraints (if any).
Returns
Maximum change of transformation parameter.

Implements mirtk::ObjectiveFunction.

§ Upgrade()

virtual bool mirtk::DeformableSurfaceModel::Upgrade ( )
virtual

Update energy function after convergence

For example, fiducial registration error (FRE) terms may update the point correspondences before another gradient-based optimization of the new FRE term.

Returns
Whether the energy function has changed.

Reimplemented from mirtk::ObjectiveFunction.


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