ITK  6.0.0
Insight Toolkit
itkSpatialObjectPoint.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkSpatialObjectPoint_h
19#define itkSpatialObjectPoint_h
20
21#include "itkSpatialObject.h"
22
23#include "itkPoint.h"
24#include "vnl/vnl_vector_fixed.h"
25#include "itkRGBAPixel.h"
26
27
28namespace itk
29{
40template <unsigned int TDimension, class TSpatialObjectPointType>
41class PointBasedSpatialObject;
42
43template <unsigned int TPointDimension = 3>
44class ITK_TEMPLATE_EXPORT SpatialObjectPoint
45{
46public:
48
49 using PointDimensionType = unsigned int;
50
51 static constexpr PointDimensionType PointDimension = TPointDimension;
52
55
57 virtual ~SpatialObjectPoint() = default;
58
60 itkVirtualGetNameOfClassMacro(SpatialObjectPoint);
61
63
65
67 using VectorType = vnl_vector<double>;
69
71 void
72 SetId(int id)
73 {
74 m_Id = id;
75 }
76
78 int
79 GetId() const
80 {
81 return m_Id;
82 }
83
85 void
86 SetPositionInObjectSpace(const PointType & newPositionInObjectSpace)
87 {
88 m_PositionInObjectSpace = newPositionInObjectSpace;
89 }
90
91 template <typename... TCoordinate>
92 void
93 SetPositionInObjectSpace(const double firstCoordinate, const TCoordinate... otherCoordinate)
94 {
95 static_assert((1 + sizeof...(otherCoordinate)) == TPointDimension,
96 "The number of coordinates must be equal to the dimensionality!");
97 const double coordinates[] = { firstCoordinate, static_cast<double>(otherCoordinate)... };
98 m_PositionInObjectSpace = coordinates;
99 }
100
102 const PointType &
104 {
105 return m_PositionInObjectSpace;
106 }
107
108 void
110 {
111 m_SpatialObject = so;
112 }
113
114 SpatialObjectType *
116 {
117 return m_SpatialObject;
118 }
119
122 void
124
129
131 void
133 {
134 m_Color = color;
135 }
136
137 ColorType
138 GetColor() const
139 {
140 return m_Color;
141 }
142
144 void
145 SetColor(double r, double g, double b, double a = 1);
146
148 void
149 SetRed(double r)
150 {
151 m_Color.SetRed(r);
152 }
153
154 double
155 GetRed() const
156 {
157 return m_Color.GetRed();
158 }
159
161 void
162 SetGreen(double g)
163 {
164 m_Color.SetGreen(g);
165 }
166
167 double
168 GetGreen() const
169 {
170 return m_Color.GetGreen();
171 }
172
174 void
175 SetBlue(double b)
176 {
177 m_Color.SetBlue(b);
178 }
179
180 double
181 GetBlue() const
182 {
183 return m_Color.GetBlue();
184 }
185
187 void
188 SetAlpha(double a)
189 {
190 m_Color.SetAlpha(a);
191 }
192
193 double
194 GetAlpha() const
195 {
196 return m_Color.GetAlpha();
197 }
198
199 void
200 SetTagScalarValue(const std::string & tag, double value);
201
202 bool
203 GetTagScalarValue(const std::string & tag, double & value) const;
204
205 double
206 GetTagScalarValue(const std::string & tag) const;
207
208 std::map<std::string, double> &
210
211 const std::map<std::string, double> &
213
214 void
215 SetTagScalarDictionary(const std::map<std::string, double> & dict);
216
218 void
219 Print(std::ostream & os) const
220 {
221 this->PrintSelf(os, 3);
222 }
223
224protected:
226 virtual void
227 PrintSelf(std::ostream & os, Indent indent) const;
228
230 int m_Id{};
231
233 PointType m_PositionInObjectSpace{};
234
236 ColorType m_Color{};
237
239 std::map<std::string, double> m_ScalarDictionary{};
240
241
242 // The SpatialObjectPoint keeps a reference to its owning parent
243 // spatial object for its spatial context. A WeakPointer is used to
244 // avoid a memory leak.
246};
247
248} // end of namespace itk
249
250#ifndef ITK_MANUAL_INSTANTIATION
251# include "itkSpatialObjectPoint.hxx"
252#endif
253
254#endif // itkSpatialObjectPoint_h
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Point used for spatial objects.
const std::map< std::string, double > & GetTagScalarDictionary() const
void SetColor(ColorType color)
virtual ~SpatialObjectPoint()=default
bool GetTagScalarValue(const std::string &tag, double &value) const
double GetTagScalarValue(const std::string &tag) const
ITK_DEFAULT_COPY_AND_MOVE(SpatialObjectPoint)
void SetPositionInObjectSpace(const double firstCoordinate, const TCoordinate... otherCoordinate)
std::map< std::string, double > & GetTagScalarDictionary()
void SetTagScalarValue(const std::string &tag, double value)
void SetPositionInObjectSpace(const PointType &newPositionInObjectSpace)
void SetColor(double r, double g, double b, double a=1)
PointType GetPositionInWorldSpace() const
void Print(std::ostream &os) const
void SetPositionInWorldSpace(const PointType &point)
SpatialObjectType * GetSpatialObject() const
const PointType & GetPositionInObjectSpace() const
virtual void PrintSelf(std::ostream &os, Indent indent) const
void SetTagScalarDictionary(const std::map< std::string, double > &dict)
void SetSpatialObject(SpatialObjectType *so)
vnl_vector< double > VectorType
Implementation of the composite pattern.
Implements a weak reference to an object.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents