BoundarySegmentMapper.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_BoundarySegmentMapper_H
21 #define MIRTK_BoundarySegmentMapper_H
22 
23 #include "mirtk/BoundaryMapper.h"
24 
25 #include "mirtk/Memory.h"
26 #include "mirtk/BoundarySegmentParameterizer.h"
27 
28 
29 namespace mirtk {
30 
31 
32 /**
33  * Base class of filters which assign map values to one surface boundary segment
34  */
36 {
37  mirtkAbstractMacro(BoundarySegmentMapper);
38 
39  // ---------------------------------------------------------------------------
40  // Attributes
41 
42  /// Closed boundary segment parameterizer
43  mirtkPublicAttributeMacro(SharedPtr<BoundarySegmentParameterizer>, Parameterizer);
44 
45  /// Copy attributes of this class from another instance
46  void CopyAttributes(const BoundarySegmentMapper &);
47 
48  // ---------------------------------------------------------------------------
49  // Construction/Destruction
50 
51 protected:
52 
53  /// Default constructor
55 
56  /// Copy constructor
58 
59  /// Assignment operator
61 
62 public:
63 
64  /// Destructor
65  virtual ~BoundarySegmentMapper();
66 
67  // ---------------------------------------------------------------------------
68  // Execution
69 
70  /// Initialize filter after input and parameters are set
71  virtual void Initialize();
72 
73  /// Process longest boundary segment
74  void MapLongest();
75 
76  /// Process boundary segment with the most number of points
77  void MapLargest();
78 
79  /// Process specified boundary segment
80  ///
81  /// \param[in] n Index of boundary segment.
82  void MapSegment(int n);
83 
84  /// Finalize boundary map
85  virtual void Finalize();
86 
87 protected:
88 
89  /// Assign map values to longest boundary of input surface
90  ///
91  /// When the surface has more than one boundary segment and a different boundary
92  /// segment should be processed or when multiple boundary segments should be
93  /// processed with different boundary map settings, perform the following steps
94  /// instead of calling the Run() function.
95  ///
96  /// 1. Initialize() filter
97  /// 2. Repeat the following steps for each boundary segment to be mapped:
98  /// a) Set selected boundary segment points and map parameters.
99  /// b) MapSegment() to assign map values to current segment.
100  /// 3. Finalize() boundary map
101  virtual void ComputeMap();
102 
103  /// Map boundary segment
104  ///
105  /// \param[in] n Index of boundary segment.
106  /// \param[in] indices Indices of boundary points forming a closed line strip
107  /// that discretizes the current surface boundary segment.
108  /// \param[in] tvalues Curve parameter in [0, 1) for each boundary segment point,
109  /// where the first point has value t=0 and the parameter value
110  /// for consecutive points is proportional to the distance of
111  /// the point from the first point along the boundary curve.
112  /// \param[in] selection Indices in \p i and \p t arrays corresponding to
113  /// selected boundary points.
114  virtual void MapBoundarySegment(int n, const Array<int> &indices,
115  const Array<double> &tvalues,
116  const Array<int> &selection) = 0;
117 
118 };
119 
120 
121 } // namespace mirtk
122 
123 #endif // MIRTK_BoundarySegmentMapper_H
virtual void MapBoundarySegment(int n, const Array< int > &indices, const Array< double > &tvalues, const Array< int > &selection)=0
void MapLongest()
Process longest boundary segment.
Definition: IOConfig.h:41
virtual ~BoundarySegmentMapper()
Destructor.
virtual void Finalize()
Finalize boundary map.
BoundarySegmentMapper()
Default constructor.
virtual void Initialize()
Initialize filter after input and parameters are set.
BoundarySegmentMapper & operator=(const BoundarySegmentMapper &)
Assignment operator.
void MapLargest()
Process boundary segment with the most number of points.