KWStyle - itkChainCodePath.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkChainCodePath.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
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 DEF #ifndef _itkChainCodePath_txx
18 DEF #define _itkChainCodePath_txx
19
20 #include "itkChainCodePath.h"
21 #include "itkNumericTraits.h"
22
23 namespace itk
24 {
25
26 template <unsigned int VDimension>
27 typename ChainCodePath<VDimension>::IndexType
28 ChainCodePath<VDimension>
29 ::EvaluateToIndex( const InputType & input ) const
30 {
31   /* We could do something fancy here, such as "secretly" store the input and
32 IND **** total offset from the last time this function was called, and use such
33 IND **** information to speed up quasi-sequential access.  We would have to be
34 IND **** really, really careful about how we handle the "secret" member data,
35 IND **** though.
36   
37   **********************************
38   * Begin broken, uncompiled Code. *
39   **********************************
40
41   int numberOfSteps = input - m_CurrentPosition;
42   if( numberOfSteps > 0 ) 
43     {
44     const unsigned int steps = numberOfSteps;
45     for(unsigned int i=0; i<steps; i++)
46       {
47       this->operator++();
48       }
49     }
50   else
51     {
52     const unsigned int steps = -numberOfSteps;
53     for(unsigned int i=0; i<steps; i++)
54       {
55       this->operator--();
56       }
57     }
58   return m_CurrentIndex;
59   
60   ***********************************
61   * End of broken, uncompiled Code. *
62   **********************************/
63   
64   
65   
66   IndexType index = m_Start;
67   
68   // Iterate through the chaincode, summing the offsets as we go.
69   for(InputType i=0; i<input; i++)
70     {
71     index += m_Chain[i];
72     }
73
74   return index;
75 }
76
77
78 EML
79 template <unsigned int VDimension>
80 typename ChainCodePath<VDimension>::OffsetType
81 ChainCodePath<VDimension>
82 ::IncrementInput(InputType & input ) const
83 {
84   if( input < NumberOfSteps() )
85     {
86     return m_Chain[input++];
87     }
88   else
89     {
90     return this->GetZeroOffset();
91     }
92 }
93
94
95 EML
96 /**
97  * Constructor
98  */
99 template <unsigned int VDimension>
100 ChainCodePath<VDimension>
101 ::ChainCodePath()
102 {
103   m_Start = this->GetZeroIndex();
104 }
105
106
107 EML
108 /**
109  * Standard "PrintSelf" method
110  */
111 template <unsigned int VDimension>
112 void
113 ChainCodePath<VDimension>
114 ::PrintSelf( std::ostream& os, Indent indent) const
115 {
116   Superclass::PrintSelf( os, indent );
117   os << indent << "Start index:  " << m_Start << std::endl;
118 }
119
120
121 EML
122 // end namespace itk
123
124 #endif
125
126 EOF

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