KWStyle - itkCorrespondenceDataStructureIterator.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkCorrespondenceDataStructureIterator.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:34 $
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 _itkCorrespondenceDataStructureIterator_txx
18 DEF #define _itkCorrespondenceDataStructureIterator_txx
19
20 #include "itkCorrespondenceDataStructureIterator.h"
21
22 namespace itk
23 {
24 /**
25  * Constructor.  Initializes iterators, pointers, and m_IsAtEnd.
26  */
27 template <typename TStructureType>
28 CorrespondenceDataStructureIterator<TStructureType>
29 ::CorrespondenceDataStructureIterator(TStructureType *StructurePtr)
30 {
31   m_Structure = StructurePtr;
32   m_NodeListPointer = StructurePtr->m_NodeList;
33   m_NodeListIterator = m_NodeListPointer->begin();
34   m_SecondaryListPointer = &(*m_NodeListIterator);
35   m_SecondaryListIterator = m_SecondaryListPointer->begin();
36   m_CorrespondingListPointer = &(*m_SecondaryListIterator);
37   m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
38   
39   m_IsAtEnd = false;
40 }
41
42 /**
43  * Destructor.
44  */
45 template <typename TStructureType>
46 CorrespondenceDataStructureIterator<TStructureType>
47 ::~CorrespondenceDataStructureIterator()
48 {
49 }
50
51 /**
52  * Used to verify that the iterator is at the end of the data structure.
53  */
54 template <typename TStructureType>
55 bool
56 CorrespondenceDataStructureIterator<TStructureType>
57 ::IsAtEnd()
58 {
59   return m_IsAtEnd;
60 }
61
62 /**
63 LEN  * Goes to the next corresponding node clique in the structure, moving on to the next base node clique if necessary. 
64  */
65 template <typename TStructureType>
66 void
67 CorrespondenceDataStructureIterator<TStructureType>
68 ::GoToNext()
69 {
70   m_CorrespondingListIterator++;
71   
72   if(m_CorrespondingListIterator == m_CorrespondingListPointer->end())
73     {
74     m_SecondaryListIterator++;
75     if(m_SecondaryListIterator != m_SecondaryListPointer->end())
76       {
77       m_CorrespondingListPointer = &(*m_SecondaryListIterator);
78       m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
79       }
80     else if(m_SecondaryListIterator == m_SecondaryListPointer->end())
81       {
82       m_NodeListIterator++;
83
84       if(m_NodeListIterator != m_NodeListPointer->end())
85         {
86         m_SecondaryListPointer = &(*m_NodeListIterator);
87         m_SecondaryListIterator = m_SecondaryListPointer->begin();
88     
89         m_CorrespondingListPointer = &(*m_SecondaryListIterator);
90         m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
91         }
92       else if(m_NodeListIterator == m_NodeListPointer->end())
93         {
94         m_IsAtEnd = true;
95         }
96       }
97     }
98 }
99
100 /**
101  * Goes to the next base node clique. 
102  */
103 template <typename TStructureType>
104 void
105 CorrespondenceDataStructureIterator<TStructureType>
106 ::GoToNextBaseGroup()
107 {
108   m_SecondaryListIterator++;
109   if(m_SecondaryListIterator != m_SecondaryListPointer->end())
110     {
111     m_CorrespondingListPointer = &(*m_SecondaryListIterator);
112     m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
113     }
114   else if(m_SecondaryListIterator == m_SecondaryListPointer->end())
115     {
116     m_NodeListIterator++;
117
118     if(m_NodeListIterator != m_NodeListPointer->end())
119       {
120       m_SecondaryListPointer = &(*m_NodeListIterator);
121       m_SecondaryListIterator = m_SecondaryListPointer->begin();
122     
123       m_CorrespondingListPointer = &(*m_SecondaryListIterator);
124       m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
125       }
126     else if(m_NodeListIterator == m_NodeListPointer->end())
127       {
128       m_IsAtEnd = true;
129       }
130     }
131 }
132
133 /**
134  * Resets the iterator to the default settings/placement.
135  */
136 template <typename TStructureType>
137 void
138 CorrespondenceDataStructureIterator<TStructureType>
139 ::Reset()
140 {
141   m_IsAtEnd = false;
142
143   m_NodeListPointer = m_Structure->m_NodeList;
144   m_NodeListIterator = m_NodeListPointer->begin();
145
146   m_SecondaryListPointer = &(*m_NodeListIterator);
147   m_SecondaryListIterator = m_SecondaryListPointer->begin();
148
149   m_CorrespondingListPointer = &(*m_SecondaryListIterator);
150   m_CorrespondingListIterator = m_CorrespondingListPointer->begin();
151 }
152
153 // end namespace itk
154
155 #endif
156

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