KWStyle - itkPath.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkPath.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
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
18 DEF #ifndef _itkPath_h
19 DEF #define _itkPath_h
20
21 //#include "itkFunctionBase.h"
22 #include "itkDataObject.h"
23 #include "itkIndex.h"
24 #include "itkOffset.h"
25 #include "itkNumericTraits.h"
26
27 namespace itk
28 {
29
30
31 /** \class Path
32  * \brief  Represent a path through ND Space
33  *
34  * This base class is intended to represent a path through an image.   As a
35  * path, it maps a 1D parameter (such as time or arc length, etc) to an index
36  * (or possibly an offset or a point) in ND space.  This mapping is done via the
37  * abstract Evaluate() method, which must be overridden in all instantiable
38  * subclasses. The only geometric requirement for a gerneral path is that it be
39  * continuous. A path may be open or closed, and may cross itself several
40  * times.  A classic application of this class is the representation of contours
41  * in 2D images using chaincodes or freeman codes.  Another use of a path is to
42  * guide the movement of an iterator through an image.
43  *
44  * \sa Index
45  * \sa Point
46  * \sa ContinuousIndex
47  *
48  * \ingroup PathObjects
49  */
50 template <class TInput, class TOutput, unsigned int VDimension>
51 class ITK_EXPORT Path : public DataObject
52 {
53 public:
54   /** Standard class typedefs. */
55   typedef Path                      Self;
56   typedef DataObject                Superclass;
57   typedef SmartPointer<Self>        Pointer;
58   typedef SmartPointer<const Self>  ConstPointer;
59   
60   /** Run-time type information (and related methods). */
61   itkTypeMacro(Path, FunctionBase);
62   
63   /** Input type */
64   typedef TInput  InputType;
65   
66   /** Output type */
67   typedef TOutput OutputType;
68   
69   
70   /** All paths must be mapable to index space */
71   typedef Index<  VDimension >  IndexType;
72   typedef Offset< VDimension >  OffsetType;
73
74
75   /** Where does the path begin?  For most types of paths, the path will begin
76    * at zero.  This value can be overridden in children, and is necessary for
77    * iterators to know how to go to the beginning of a path. */
78   virtual inline InputType StartOfInput() const
79     {
80     return NumericTraits<InputType>::Zero;
81     }
82
83   /** Where does the path end (what is the last valid input value)?  This value
84    * is sometimes used by IncrementInput() to go to the end of a path. */
85   virtual inline InputType EndOfInput() const
86     {
87     return NumericTraits<InputType>::One;
88     }
89   
90   /** Evaluate the path at specified location along the path.
91 IND ***** Return data is the path's "natural" format. */
92   virtual OutputType Evaluate( const InputType & input ) const = 0;
93   
94   /** Like Evaluate(), except always returns an index */
95   virtual IndexType EvaluateToIndex( const InputType & input ) const = 0;
96
97   /** Increment the input variable passed by reference such that the
98    * ND index of the path moves to its next vertex-connected
99    * (8-connected in 2D) neighbor.  Return the Index-space offset of
100    * the path from its prior input to its new input.  If the path is
101    * unable to increment, input is not changed and an offset of Zero
102    * is returned. Children are not required to implement general
103    * bounds checking, but are required to return an offset of zero
104    * when trying to increment from the final valid input value. */
105   virtual OffsetType IncrementInput(InputType & input) const = 0;
106   
107   
108 protected:
109   Path();
110   ~Path(){}
111
112   void PrintSelf(std::ostream& os, Indent indent) const;
113
114   itkGetConstMacro(ZeroOffset,OffsetType);
115   itkGetConstMacro(ZeroIndex,IndexType);
116
117 private:
118   Path(const Self&); //purposely not implemented
119   void operator=(const Self&); //purposely not implemented
120   
121   // These "constants" are initialized in the constructor
122   OffsetType  m_ZeroOffset; // = 0 for all dimensions
123   IndexType   m_ZeroIndex;  // = 0 for all dimensions
124   
125 };
126
127 // namespace itk
128
129 #ifndef ITK_MANUAL_INSTANTIATION
130 #include "itkPath.txx"
131 #endif
132   
133 #endif
134

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