BoundarySegmentParameterizer.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_BoundarySegmentParameterizer_H
21 #define MIRTK_BoundarySegmentParameterizer_H
22 
23 #include "mirtk/Object.h"
24 
25 #include "mirtk/Memory.h"
26 #include "mirtk/Array.h"
27 
28 #include "mirtk/BoundarySegment.h"
29 
30 
31 namespace mirtk {
32 
33 
34 /**
35  * Base class of filters which parameterize a closed boundary segment
36  *
37  * A boundary segment parameterizer is used to assign each point of a closed
38  * surface boundary segment a value t in [0, 1), with strictly increasing
39  * (or decreasing) values along the boundary curve. This parameterization is
40  * used in particular by a boundary mapper to assign fixed map values to the
41  * boundary points.
42  *
43  * For example, the BoundaryToSquareMapper maps points with a t value in
44  * [0, .25) to the first side of the square, points with a t value in [.25, .5)
45  * to the second side, and so on. Note that the t value is proportional to the
46  * distance of the point from the curve point at t=0 along the mapped curve.
47  * Note further that the boundary segment point with index 0 need not be the
48  * point with parameter value t=0. It is also not required that there exists
49  * even a discrete curve point with parameter t=0.
50  *
51  * Specialized boundary parameterizers may assign parameter values to the
52  * boundary segment of a given surface mesh not only based on this surface
53  * and possibly related imaging data, but also other surface meshes with
54  * known or to be determined correspondences between surface boundaries.
55  * Such parameterizer will assign equal t values to corresponding boundary
56  * points such that these points are mapped to the same value by the boundary
57  * mapper. Other parameterizers may take an ordered/labeled list of manually
58  * selected boundary points as input and assign parameter values based on
59  * this selection.
60  *
61  * In a nutshell, a boundary parameterizer indirectly establishes
62  * correspondences between boundary points of 2D manifolds, while the
63  * boundary mapper itself only defines the shape of the parametric domain,
64  * i.e., the codomain of the boundary map.
65  *
66  * Subclasses may further consider the ordered (not sorted!) list of user
67  * selected boundary segment points (see BoundarySegment::IsSelected).
68  *
69  * How many points need to be selected depends on the specific parameterizer.
70  * In general, no points have to be selected, but selecting boundary points
71  * can be used to orient the curve, i.e., to decide in which direction along
72  * the closed boundary the t values are increasing. The curve orientation is
73  * generally defined by the order of the selected points. The first point in
74  * the selection usually defines the boundary point with parameter value t=0.
75  *
76  * \sa BoundaryMapper, BoundarySegment
77  */
79 {
80  mirtkAbstractMacro(BoundarySegmentParameterizer);
81 
82  // ---------------------------------------------------------------------------
83  // Attributes
84 
85  /// Surface boundary segment
86  mirtkPublicAttributeMacro(BoundarySegment, Boundary);
87 
88  /// Parameter value at boundary segment points
89  mirtkReadOnlyAttributeMacro(Array<double>, Values);
90 
91  /// Copy attributes of this class from another instance
92  void CopyAttributes(const BoundarySegmentParameterizer &);
93 
94  // ---------------------------------------------------------------------------
95  // Construction/Destruction
96 
97 protected:
98 
99  /// Default constructor
101 
102  /// Copy constructor
104 
105  /// Assignment operator
107 
108 public:
109 
110  /// Destructor
112 
113  /// New copy of this parameterizer
114  virtual BoundarySegmentParameterizer *NewCopy() const = 0;
115 
116  // ---------------------------------------------------------------------------
117  // Execution
118 
119 public:
120 
121  /// Parameterize boundary segment
122  virtual void Run();
123 
124  /// Get parameter value of i-th boundary segment point
125  ///
126  /// \param[in] i Index of boundary segment point.
127  ///
128  /// \returns Parameter value of i-th boundary segment point
129  double Value(int i) const;
130 
131 protected:
132 
133  /// Initialize parameterizer after input and parameters are set
134  virtual void Initialize();
135 
136  /// Parameterize boundary curve
137  virtual void Parameterize() = 0;
138 
139  /// Finalize parameterization
140  virtual void Finalize();
141 
142 };
143 
144 ////////////////////////////////////////////////////////////////////////////////
145 // Inline definitions
146 ////////////////////////////////////////////////////////////////////////////////
147 
148 // -----------------------------------------------------------------------------
149 inline double BoundarySegmentParameterizer::Value(int i) const
150 {
151  return _Values[i];
152 }
153 
154 
155 } // namespace mirtk
156 
157 #endif // MIRTK_BoundarySegmentParameterizer_H
virtual ~BoundarySegmentParameterizer()
Destructor.
virtual void Parameterize()=0
Parameterize boundary curve.
virtual void Run()
Parameterize boundary segment.
BoundarySegmentParameterizer & operator=(const BoundarySegmentParameterizer &)
Assignment operator.
virtual void Finalize()
Finalize parameterization.
Definition: IOConfig.h:41
BoundarySegmentParameterizer()
Default constructor.
virtual void Initialize()
Initialize parameterizer after input and parameters are set.
virtual BoundarySegmentParameterizer * NewCopy() const =0
New copy of this parameterizer.