ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSpatialObjectPoint.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
28 namespace itk
29 {
39 template < unsigned int TDimension, class TSpatialObjectPointType>
40 class PointBasedSpatialObject;
41 
42 template< unsigned int TPointDimension = 3>
43 class ITK_TEMPLATE_EXPORT SpatialObjectPoint
44 {
45 public:
46 
49 
51  virtual ~SpatialObjectPoint() = default;
52 
54 
56 
58  using VectorType = vnl_vector< double >;
60 
62  void SetId( int id )
63  { m_Id = id; }
64 
66  int GetId() const
67  { return m_Id; }
68 
70  void SetPositionInObjectSpace(const PointType & newPositionInObjectSpace)
71  { m_PositionInObjectSpace = newPositionInObjectSpace; }
72 
73  template <typename... TCoordinate>
75  const double firstCoordinate,
76  const TCoordinate... otherCoordinate)
77  {
78  static_assert((1 + sizeof...(otherCoordinate)) == TPointDimension,
79  "The number of coordinates must be equal to the dimensionality!");
80  const double coordinates[] =
81  {
82  firstCoordinate, static_cast<double>(otherCoordinate)...
83  };
84  m_PositionInObjectSpace = coordinates;
85  }
86 
89  { return m_PositionInObjectSpace; }
90 
92  { m_SpatialObject = so; }
93 
96  void SetPositionInWorldSpace( const PointType & point );
97 
100  PointType GetPositionInWorldSpace() const;
101 
103  Self & operator=(const SpatialObjectPoint & rhs );
104 
106  void SetColor( ColorType color )
107  { m_Color = color; }
108 
110  { return m_Color; }
111 
113  void SetColor(double r, double g, double b, double a = 1);
114 
116  void SetRed(double r)
117  { m_Color.SetRed( r ); }
118 
119  double GetRed() const
120  { return m_Color.GetRed(); }
121 
123  void SetGreen(double g)
124  { m_Color.SetGreen( g ); }
125 
126  double GetGreen() const
127  { return m_Color.GetGreen(); }
128 
130  void SetBlue(double b)
131  { m_Color.SetBlue( b ); }
132 
133  double GetBlue() const
134  { return m_Color.GetBlue(); }
135 
137  void SetAlpha(double a)
138  { m_Color.SetAlpha( a ); }
139 
140  double GetAlpha() const
141  { return m_Color.GetAlpha(); }
142 
144  void Print(std::ostream & os) const
145  { this->PrintSelf( os, 3 ); }
146 
147 protected:
148 
150  virtual void PrintSelf(std::ostream & os, Indent indent) const;
151 
153  int m_Id;
154 
157 
160 
162 };
163 
164 } // end of namespace itk
165 
166 #ifndef ITK_MANUAL_INSTANTIATION
167 #include "itkSpatialObjectPoint.hxx"
168 #endif
169 
170 #endif // itkSpatialObjectPoint_h
void SetPositionInObjectSpace(const PointType &newPositionInObjectSpace)
SpatialObjectType::Pointer m_SpatialObject
void SetColor(ColorType color)
void SetPositionInObjectSpace(const double firstCoordinate, const TCoordinate...otherCoordinate)
const PointType & GetPositionInObjectSpace() const
void SetSpatialObject(SpatialObjectType *so)
Implementation of the composite pattern.
vnl_vector< double > VectorType
Point used for spatial objets.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void Print(std::ostream &os) const