KWStyle - itkScalarVector.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkScalarVector.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:47 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkScalarVector_h
18 #define __itkScalarVector_h
19
20 #include "itkMacro.h"
21 #include "vnl/vnl_vector_fixed.h"
22
23 #include <memory>
24
25 namespace itk
26 {
27
28 /** \class ScalarVector
29  * \brief A templated class holding bot scalar and vector values and
30  *         responding to the GetScalar() and GetVector() methods.
31  * 
32  * ScalarVector is a templated class that holds a scalar value plus an
33  * array of values (a vector).  ScalarVector can be used as the data type
34  * held at each pixel in an Image or at each vertex of an Mesh. There
35  * are three template parameters: the type of scalar, the type of vector, and
36  * the number of components of the vector. The types can be any data type
37  * that behaves like a primitive (or atomic) data type (int, short, float,
38  * complex).  itk filters that rely on scalar data assume the data type held
39  * at each pixel or each vertex responds to GetScalar()/SetScalar()
40  * methods. itk filters that rely on vector data assume the data type held at
41  * each pixel or each vertex responds to GetVector()/SetVector() methods. If
42  * not, a compile time error will occur.
43  *
44  * ScalarVector is not a dynamically extendible array like std::vector. It
45  * is intended to be used like a mathematical vector.
46  *
47  * If you wish a simpler pixel types, you can use Scalar, which represents
48  * a single data value at a pixel. YOu can also use Vector, which supports
49  * (for a given pixel) an array of vector values.
50  * 
51  * \sa Image
52  * \sa Mesh
53  * \sa Scalar
54  * \sa Vector 
55  * \ingroup DataRepresentation
56  */
57 template<class TScalar, class TVector, unsigned int TVectorDimension=3>
58 class ITK_EXPORT ScalarVector
59 {
60 public:
61   /** Standard class typedefs. */
62   typedef ScalarVector  Self;
63   
64   /** ValueType can be used to declare a variable that is the same type
65    * as the data held in the scalar portion of the ScalarVector.   */
66   typedef TScalar ValueType;
67
68   /** ValueType can be used to declare a variable that is the same type
69    * as the data held in the scalar portion of the ScalarVector.   */
70   typedef TScalar ScalarValueType;
71
72   /** ValueType can be used to declare a variable that is the same type
73    * as the data held in the scalar portion of the ScalarVector.   */
74   typedef TVector VectorValueType;
75
76   /** VectorType can be used to declare a variable that is the same type
77    * as the internal vector.   */
78   typedef vnl_vector_fixed<TVector, TVectorDimension> VectorType;
79
80   /** Get the scalar value. \sa SetScalar() */
81   TScalar GetScalar() const 
82     { return m_Scalar; }
83
84   /** Set the scalar value. \sa GetScalar() */
85   void SetScalar(const TScalar &val) 
86     { m_Scalar = val; }
87
88   /** Get the dimension (size) of the vector. */
89   static unsigned int GetVectorDimension() 
90     { return TVectorDimension; }
91   
92   /** Get the vector. This provides a read only reference to the vector.
93    * \sa SetVector(). */
94   const VectorType &GetVector() const 
95     { return m_Vector; }
96
97   /** Get the vector. This provides a read/write reference to the vector.
98    * \sa SetVector */
99   VectorType &GetVector()  
100     { return m_Vector; }
101
102   /** Set the vector. \sa GetVector */
103   void SetVector(const VectorType &vec)
104     { m_Vector = vec; }
105
106 private:
107   TScalar m_Scalar;
108   VectorType m_Vector;
109 };
110
111   
112 // end namespace itk
113   
114 #endif 
115

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:43PM
© Kitware Inc.