RepulsiveForce.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2016 Imperial College London
5  * Copyright 2013-2016 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_RepulsiveForce_H
21 #define MIRTK_RepulsiveForce_H
22 
23 #include "mirtk/SurfaceConstraint.h"
24 
25 #include "vtkSmartPointer.h"
26 #include "vtkAbstractPointLocator.h"
27 
28 
29 namespace mirtk {
30 
31 
32 /**
33  * Internal force which makes non-neighboring nodes repell each other
34  *
35  * This force term is based on the respective mrisComputeRepulsiveTerm
36  * found in mrisurf.c of the FreeSurfer open source implementation.
37  */
39 {
40  mirtkEnergyTermMacro(RepulsiveForce, EM_RepulsiveForce);
41 
42  // ---------------------------------------------------------------------------
43  // Attributes
44 
45  /// Radius within which repelling force is active
46  ///
47  /// Marks the intersection point of the quadratic distance weighting function
48  /// with the x axis. The intersection point with the y axis is equal to the
49  /// weight of this force term.
50  mirtkPublicAttributeMacro(double, FrontfaceRadius);
51 
52  /// Radius within which repelling force is active
53  ///
54  /// Marks the intersection point of the quadratic distance weighting function
55  /// with the x axis. The intersection point with the y axis is equal to the
56  /// weight of this force term.
57  mirtkPublicAttributeMacro(double, BackfaceRadius);
58 
59  /// Point locator
60  mirtkAttributeMacro(vtkSmartPointer<vtkAbstractPointLocator>, Locator);
61 
62  /// Copy attributes of this class from another instance
63  void CopyAttributes(const RepulsiveForce &);
64 
65  // ---------------------------------------------------------------------------
66  // Construction/Destruction
67 
68 public:
69 
70  /// Constructor
71  RepulsiveForce(const char * = "", double = 1.0);
72 
73  /// Copy constructor
75 
76  /// Assignment operator
78 
79  /// Destructor
80  virtual ~RepulsiveForce();
81 
82  /// Initialize force term once input and parameters have been set
83  virtual void Initialize();
84 
85  /// Reinitialize force term after change of input topology
86  ///
87  /// This function is called in particular when an input surface has been
88  /// reparameterized, e.g., by a local remeshing filter.
89  virtual void Reinitialize();
90 
91  // ---------------------------------------------------------------------------
92  // Configuration
93 
94 protected:
95 
96  /// Set parameter value from string
97  virtual bool SetWithoutPrefix(const char *, const char *);
98 
99 public:
100 
101  // Import other overloads
103 
104  /// Get parameter name/value pairs
105  virtual ParameterList Parameter() const;
106 
107  // ---------------------------------------------------------------------------
108  // Evaluation
109 
110  /// Update moving input points and internal state of force term
111  virtual void Update(bool = true);
112 
113 protected:
114 
115  /// Evaluate energy of internal force term
116  virtual double Evaluate();
117 
118  /// Evaluate internal force w.r.t. transformation parameters or surface nodes
119  virtual void EvaluateGradient(double *, double, double);
120 
121 };
122 
123 
124 } // namespace mirtk
125 
126 #endif // MIRTK_RepulsiveForce_H
virtual ParameterList Parameter() const
Get parameter name/value pairs.
virtual void Update(bool=true)
Update moving input points and internal state of force term.
RepulsiveForce & operator=(const RepulsiveForce &)
Assignment operator.
virtual bool SetWithoutPrefix(const char *, const char *)
Set parameter value from string.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
virtual double Evaluate()
Evaluate energy of internal force term.
virtual void Initialize()
Initialize force term once input and parameters have been set.
virtual ~RepulsiveForce()
Destructor.
Definition: IOConfig.h:41
RepulsiveForce(const char *="", double=1.0)
Constructor.
virtual void EvaluateGradient(double *, double, double)
Evaluate internal force w.r.t. transformation parameters or surface nodes.
virtual void Reinitialize()
Repels too close non-neighboring nodes.
Definition: EnergyMeasure.h:88
virtual ParameterList Parameter() const
Get parameter key/value as string map.