ExternalForceTerm.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_ExternalForceTerm_H
21 #define MIRTK_ExternalForceTerm_H
22 
23 #include "mirtk/EnergyMeasure.h"
24 
25 
26 namespace mirtk {
27 
28 
29 // -----------------------------------------------------------------------------
30 /// Enumeration of available external point set force terms
31 ///
32 /// \note This enumeration constains only a subset of all EnergyMeasure
33 /// enumeration values, whereby the integer value of corresponding
34 /// enumeration values is equal.
35 ///
36 /// \sa EnergyMeasure
38 {
39  EFT_Unknown = EFT_Begin,
40  EFT_BalloonForce = EM_BalloonForce,
41  EFT_ImageEdgeForce = EM_ImageEdgeForce,
42  EFT_ImageEdgeDistance = EM_ImageEdgeDistance,
43  EFT_ImplicitSurfaceDistance = EM_ImplicitSurfaceDistance
44 };
45 
46 // -----------------------------------------------------------------------------
47 template <>
48 inline string ToString(const ExternalForceTerm &eft, int w, char c, bool left)
49 {
50  EnergyMeasure em = static_cast<EnergyMeasure>(eft);
51  if (em <= EFT_Begin || em >= EFT_End) return ToString("Unknown", w, c, left);
52  return ToString(em, w, c, left);
53 }
54 
55 // -----------------------------------------------------------------------------
56 template <>
57 inline bool FromString(const char *str, ExternalForceTerm &eft)
58 {
60  if (FromString(str, em) && EFT_Begin < em && em < EFT_End) {
61  eft = static_cast<ExternalForceTerm>(em);
62  return true;
63  } else {
64  eft = EFT_Unknown;
65  return false;
66  }
67 }
68 
69 
70 } // namespace mirtk
71 
72 #endif // MIRTK_ExternalForceTerm_H
Balloon/inflation force.
Definition: EnergyMeasure.h:70
Implicit surface distance force.
Definition: EnergyMeasure.h:73
Definition: IOConfig.h:41
Image edge distance.
Definition: EnergyMeasure.h:72
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.
EnergyMeasure
Enumeration of all available energy terms.
Definition: EnergyMeasure.h:31
Unknown/invalid energy term.
Definition: EnergyMeasure.h:33
Image edge force.
Definition: EnergyMeasure.h:71