GaussCurvatureConstraint.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2016 Imperial College London
5  * Copyright 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_GaussCurvatureConstraint_H
21 #define MIRTK_GaussCurvatureConstraint_H
22 
23 #include "mirtk/SurfaceConstraint.h"
24 
25 #include "vtkSmartPointer.h"
26 #include "vtkDataArray.h"
27 
28 
29 namespace mirtk {
30 
31 
32 /**
33  * This force attempts to remove saddle points with negative Gauss curvature
34  */
36 {
37  mirtkEnergyTermMacro(GaussCurvatureConstraint, EM_GaussCurvature);
38 
39  // ---------------------------------------------------------------------------
40  // Types
41 
42 public:
43 
44  /// Enumeration of possible actions for reducing negative Gauss curvature
45  enum Action
46  {
47  DefaultAction,
48  NoAction,
49  Deflate,
50  Inflate
51  };
52 
53  // ---------------------------------------------------------------------------
54  // Attributes
55 
56 private:
57 
58  /// Minimum Gauss curvature threshold
59  mirtkPublicAttributeMacro(double, MinGaussCurvature);
60 
61  /// Maximum Gauss curvature threshold
62  mirtkPublicAttributeMacro(double, MaxGaussCurvature);
63 
64  /// Action to take for negative Gauss curvature points
65  mirtkPublicAttributeMacro(Action, NegativeGaussCurvatureAction);
66 
67  /// Action to take for positive Gauss curvature points
68  mirtkPublicAttributeMacro(Action, PositiveGaussCurvatureAction);
69 
70  /// Whether to scale force proportional to mean curvature
71  mirtkPublicAttributeMacro(bool, UseMeanCurvature);
72 
73  /// Copy attributes of this class from another instance
74  void CopyAttributes(const GaussCurvatureConstraint &);
75 
76  // ---------------------------------------------------------------------------
77  // Construction/Destruction
78 
79 public:
80 
81  /// Constructor
82  GaussCurvatureConstraint(const char * = "", double = 1.0);
83 
84  /// Copy constructor
86 
87  /// Assignment operator
89 
90  /// Destructor
91  virtual ~GaussCurvatureConstraint();
92 
93  // ---------------------------------------------------------------------------
94  // Evaluation
95 
96  /// Initialize force term once input and parameters have been set
97  virtual void Initialize();
98 
99  /// Update internal force data structures
100  virtual void Update(bool);
101 
102 protected:
103 
104  /// Evaluate energy of internal force term
105  virtual double Evaluate();
106 
107  /// Evaluate internal force w.r.t. transformation parameters or surface nodes
108  virtual void EvaluateGradient(double *, double, double);
109 
110 };
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 // Enum <-> string conversion
114 ////////////////////////////////////////////////////////////////////////////////
115 
116 template <> bool FromString(const char *, enum GaussCurvatureConstraint::Action &);
117 template <> string ToString(const enum GaussCurvatureConstraint::Action &, int, char, bool);
118 
119 
120 } // namespace mirtk
121 
122 #endif // MIRTK_GaussCurvatureConstraint_H
GaussCurvatureConstraint(const char *="", double=1.0)
Constructor.
GaussCurvatureConstraint & operator=(const GaussCurvatureConstraint &)
Assignment operator.
Gauss curvature constraint.
Definition: EnergyMeasure.h:84
virtual void Initialize()
Initialize force term once input and parameters have been set.
Definition: IOConfig.h:41
Action
Enumeration of possible actions for reducing negative Gauss curvature.
virtual void Update(bool)
Update internal force data structures.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
bool FromString(const char *str, EnergyMeasure &value)
Convert energy measure string to enumeration value.
virtual double Evaluate()
Evaluate energy of internal force term.
virtual ~GaussCurvatureConstraint()
Destructor.
virtual void EvaluateGradient(double *, double, double)
Evaluate internal force w.r.t. transformation parameters or surface nodes.