ClosestPointLabel.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 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_ClosestPointLabel_H
21 #define MIRTK_ClosestPointLabel_H
22 
23 #include "mirtk/ClosestPoint.h"
24 
25 #include "mirtk/UnorderedMap.h"
26 
27 #include "vtkSmartPointer.h"
28 #include "vtkIdTypeArray.h"
29 
30 
31 namespace mirtk {
32 
33 
34 /**
35  * Closest point correspondence map
36  *
37  * This class establishes point correspondence based on a known parcellation
38  * of the surfaces, i.e., the discrete "Labels" point data array
39  * (cf. MIRTK polydataassignlabels tool). A source point is said to correspond
40  * to a target point if it is the closest point on the source surface which
41  * has the same label as the target point. If no such point is found,
42  * the target point is marked as outlier.
43  */
45 {
46  mirtkObjectMacro(ClosestPointLabel);
47 
48  typedef UnorderedMap<int, int> LabelToComponentIndexMap;
49 
50  // ---------------------------------------------------------------------------
51  // Attributes
52 
53  /// IDs of points on the target surface closest to each respective surface label
54  mirtkAttributeMacro(vtkSmartPointer<vtkIdTypeArray>, TargetIds);
55 
56  /// Map of target surface label to target ID array component index
57  mirtkAttributeMacro(LabelToComponentIndexMap, TargetComponent);
58 
59  /// IDs of points on the source surface closest to each respective surface label
60  mirtkAttributeMacro(vtkSmartPointer<vtkIdTypeArray>, SourceIds);
61 
62  /// Map of target surface label to target ID array component index
63  mirtkAttributeMacro(LabelToComponentIndexMap, SourceComponent);
64 
65  // ---------------------------------------------------------------------------
66  // Construction/Destruction
67 public:
68 
69  /// Constructor
71 
72  /// Copy constructor
74 
75  /// Copy construct a new instance
76  virtual PointCorrespondence *NewInstance() const;
77 
78  /// Destructor
79  virtual ~ClosestPointLabel();
80 
81  /// Type enumeration value
82  virtual TypeId Type() const;
83 
84  // ---------------------------------------------------------------------------
85  // Correspondences
86 
87 protected:
88 
89  /// Common (re-)initialization steps of this class
90  /// \note Must be a non-virtual function!
91  void Init();
92 
93 public:
94 
95  /// Initialize correspondence map after input and parameters are set
96  virtual void Initialize();
97 
98  /// Reinitialize correspondence map after change of input topology
99  virtual void Reinitialize();
100 
101  /// Update correspondence map
102  virtual void Update();
103 
104 };
105 
106 
107 } // namespace mirtk
108 
109 #endif // MIRTK_ClosestPointLabel_H
TypeId
Enumeration of available point correspondence maps.
virtual void Update()
Update correspondence map.
virtual void Initialize()
Initialize correspondence map after input and parameters are set.
virtual TypeId Type() const
Type enumeration value.
Definition: IOConfig.h:41
virtual void Reinitialize()
Reinitialize correspondence map after change of input topology.
virtual PointCorrespondence * NewInstance() const
Copy construct a new instance.
ClosestPointLabel()
Constructor.
virtual ~ClosestPointLabel()
Destructor.