StretchingForce.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_StretchingForce_H
21 #define MIRTK_StretchingForce_H
22 
23 #include "mirtk/InternalForce.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * A spring force which favors a given rest edge length
31  *
32  * This spring force keeps the edge lengths of a simplicial complex either
33  * similar to a specified average edge length or a predefined rest edge lenght.
34  * It is usually used in conjunction a with local remeshing filter.
35  *
36  * Lachaud and Montanvert, Deformable meshes with automated topology changes
37  * for coarse-to-fine three-dimensional surface extraction. Medical Image Analysis,
38  * 3(2), 187–207, doi:10.1016/S1361-8415(99)80012-7 (1999).
39  *
40  * Park et al., A non-self-intersecting adaptive deformable surface for
41  * complex boundary extraction from volumetric images, 25, 421–440 (2001).
42  */
44 {
45  mirtkEnergyTermMacro(StretchingForce, EM_Stretching);
46 
47  // ---------------------------------------------------------------------------
48  // Attributes
49 
50  /// Rest edge length
51  mirtkPublicAttributeMacro(double, RestLength);
52 
53  /// Average edge length, used only when _RestLength < 0
54  mirtkAttributeMacro(double, AverageLength);
55 
56  /// Whether to use current average edge length at each iteration
57  mirtkPublicAttributeMacro(bool, UseCurrentAverageLength);
58 
59  /// Copy attributes of this class from another instance
60  void CopyAttributes(const StretchingForce &);
61 
62  // ---------------------------------------------------------------------------
63  // Construction/Destruction
64 
65 public:
66 
67  /// Constructor
68  StretchingForce(const char * = "", double = 1.0);
69 
70  /// Copy constructor
72 
73  /// Assignment operator
75 
76  /// Destructor
77  virtual ~StretchingForce();
78 
79  // ---------------------------------------------------------------------------
80  // Configuration
81 
82 protected:
83 
84  /// Set parameter value from string
85  virtual bool SetWithoutPrefix(const char *, const char *);
86 
87 public:
88 
89  // Import other overloads
91 
92  /// Get parameter name/value pairs
93  virtual ParameterList Parameter() const;
94 
95  // ---------------------------------------------------------------------------
96  // Evaluation
97 
98  /// Initialize internal force term once input and parameters have been set
99  virtual void Initialize();
100 
101  /// Reinitialize internal force term after change of input topology
102  virtual void Reinitialize();
103 
104  /// Update internal force data structures
105  virtual void Update(bool);
106 
107 protected:
108 
109  /// Common (re-)initialization steps of this internal force term
110  /// \note Must be a non-virtual function!
111  void Init();
112 
113  /// Compute penalty for current transformation estimate
114  virtual double Evaluate();
115 
116  /// Compute internal force w.r.t. transformation parameters
117  virtual void EvaluateGradient(double *, double, double);
118 
119 };
120 
121 
122 } // namespace mirtk
123 
124 #endif // MIRTK_StretchingForce_H
virtual bool SetWithoutPrefix(const char *, const char *)
Set parameter value from string.
virtual void EvaluateGradient(double *, double, double)
Compute internal force w.r.t. transformation parameters.
virtual double Evaluate()
Compute penalty for current transformation estimate.
virtual ParameterList Parameter() const
Get parameter name/value pairs.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
StretchingForce & operator=(const StretchingForce &)
Assignment operator.
Definition: IOConfig.h:41
Stretching force (rest edge length)
Definition: EnergyMeasure.h:81
virtual void Initialize()
Initialize internal force term once input and parameters have been set.
virtual void Update(bool)
Update internal force data structures.
StretchingForce(const char *="", double=1.0)
Constructor.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
virtual ~StretchingForce()
Destructor.
virtual void Reinitialize()
Reinitialize internal force term after change of input topology.