KWStyle - itkQuadrilateralCell.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkQuadrilateralCell.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:46 $
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 _itkQuadrilateralCell_txx
18 DEF #define _itkQuadrilateralCell_txx
19 #include "itkQuadrilateralCell.h"
20
21 namespace itk
22 {
23
24 /**
25  * Standard CellInterface:
26  */
27 template <typename TCellInterface>
28 void
29 QuadrilateralCell< TCellInterface >
30 ::MakeCopy(CellAutoPointer & cellPointer) const
31 {
32   cellPointer.TakeOwnership( new Self );
33   cellPointer->SetPointIds(this->GetPointIds());
34 }
35
36   
37 /**
38  * Standard CellInterface:
39  * Get the topological dimension of this cell.
40  */
41 template <typename TCellInterface>
42 unsigned int
43 QuadrilateralCell< TCellInterface >
44 ::GetDimension(void) const
45 {
46   return Self::CellDimension;
47 }
48
49
50 /**
51  * Standard CellInterface:
52  * Get the number of points required to define the cell.
53  */
54 template <typename TCellInterface>
55 unsigned int
56 QuadrilateralCell< TCellInterface >
57 ::GetNumberOfPoints(void) const
58 {
59   return Self::NumberOfPoints;
60 }  
61
62
63 /**
64  * Standard CellInterface:
65  * Get the number of boundary features of the given dimension.
66  */
67 template <typename TCellInterface>
68 typename QuadrilateralCell< TCellInterface >::CellFeatureCount
69 QuadrilateralCell< TCellInterface >
70 ::GetNumberOfBoundaryFeatures(int dimension) const
71 {
72   switch (dimension)
73     {
74     case 0: return GetNumberOfVertices();
75     case 1: return GetNumberOfEdges();
76     default: return 0;
77     }
78 }
79
80
81 /**
82  * Standard CellInterface:
83  * Get the boundary feature of the given dimension specified by the given
84  * cell feature Id.
85  * The Id can range from 0 to GetNumberOfBoundaryFeatures(dimension)-1.
86  */
87 template <typename TCellInterface>
88 bool
89 QuadrilateralCell< TCellInterface >
90 LEN ::GetBoundaryFeature(int dimension, CellFeatureIdentifier featureId,CellAutoPointer & cellPointer)
91 {
92   switch (dimension)
93     {
94     case 0: 
95 IND ****{
96 IND ****VertexAutoPointer vertexPointer;
97 IND ****if( this->GetVertex(featureId,vertexPointer) )
98 IND ******{
99 IND ******TransferAutoPointer(cellPointer,vertexPointer);
100 IND ******return true;
101 IND ******}
102 IND ****else
103 IND ******{
104 IND ******cellPointer.Reset();
105 IND ******return false;
106 IND ******}
107 IND ****break;
108 IND ****}
109     case 1: 
110 IND ****{
111 IND ****EdgeAutoPointer edgePointer;
112 IND ****if( this->GetEdge(featureId,edgePointer) )
113 IND ******{
114 IND ******TransferAutoPointer(cellPointer,edgePointer);
115 IND ******return true;
116 IND ******}
117 IND ****else
118 IND ******{
119 IND ******cellPointer.Reset();
120 IND ******return false;
121 IND ******}
122 IND ****break;
123 IND ****}
124
125     default: 
126 IND ****{
127 IND ****cellPointer.Reset();
128 IND ****return false;
129 IND ****}
130     }
131   return false;
132 }
133
134
135 /**
136  * Standard CellInterface:
137  * Set the point id list used by the cell.  It is assumed that the given
138  * iterator can be incremented and safely de-referenced enough times to 
139  * get all the point ids needed by the cell.
140  */
141 template <typename TCellInterface>
142 void
143 QuadrilateralCell< TCellInterface >
144 ::SetPointIds(PointIdConstIterator first)
145 {
146   PointIdConstIterator ii(first);
147 SEM   for(unsigned int i=0; i < Self::NumberOfPoints ; ++i)
148     {
149     m_PointIds[i] = *ii++;
150     }
151 }
152
153
154 /**
155  * Standard CellInterface:
156  * Set the point id list used by the cell.  It is assumed that the range
157  * of iterators [first, last) contains the correct number of points needed to
158  * define the cell.  The position *last is NOT referenced, so it can safely
159  * be one beyond the end of an array or other container.
160  */
161 template <typename TCellInterface>
162 void
163 QuadrilateralCell< TCellInterface >
164 ::SetPointIds(PointIdConstIterator first, PointIdConstIterator last)
165 {
166   int localId=0;
167   PointIdConstIterator ii(first);
168   
169   while(ii != last)
170     {
171     m_PointIds[localId++] = *ii++;
172     }
173 }
174
175
176 /**
177  * Standard CellInterface:
178  * Set an individual point identifier in the cell.
179  */
180 template <typename TCellInterface>
181 void
182 QuadrilateralCell< TCellInterface >
183 ::SetPointId(int localId, PointIdentifier ptId)
184 {
185   m_PointIds[localId] = ptId;
186 }
187
188
189 /**
190  * Standard CellInterface:
191  * Get a begin iterator to the list of point identifiers used by the cell.
192  */
193 template <typename TCellInterface >
194 typename QuadrilateralCell< TCellInterface >::PointIdIterator
195 QuadrilateralCell< TCellInterface >
196 ::PointIdsBegin(void)
197 {
198   return &m_PointIds[0];
199 }
200
201
202 /**
203  * Standard CellInterface:
204  * Get a const begin iterator to the list of point identifiers used
205  * by the cell.
206  */
207 template <typename TCellInterface>
208 typename QuadrilateralCell< TCellInterface >::PointIdConstIterator
209 QuadrilateralCell< TCellInterface >
210 ::PointIdsBegin(void) const
211 {
212   return &m_PointIds[0];
213 }
214
215
216 /**
217  * Standard CellInterface:
218  * Get an end iterator to the list of point identifiers used by the cell.
219  */
220 template <typename TCellInterface>
221 typename QuadrilateralCell< TCellInterface >::PointIdIterator
222 QuadrilateralCell< TCellInterface >
223 ::PointIdsEnd(void)
224 {
225   return &m_PointIds[Self::NumberOfPoints];
226 }
227
228 /**
229  * Standard CellInterface:
230  * Get a const end iterator to the list of point identifiers used
231  * by the cell.
232  */
233 template <typename TCellInterface >
234 typename QuadrilateralCell< TCellInterface >::PointIdConstIterator
235 QuadrilateralCell< TCellInterface >
236 ::PointIdsEnd(void) const
237 {
238   return &m_PointIds[Self::NumberOfPoints];
239 }
240
241 /**
242  * Quadrilateral-specific:
243  * Get the number of vertices defining the quadrilateral.
244  */
245 template <typename TCellInterface>
246 typename QuadrilateralCell< TCellInterface >::CellFeatureCount
247 QuadrilateralCell< TCellInterface >
248 ::GetNumberOfVertices(void) const
249 {
250   return NumberOfVertices;
251 }
252
253 /**
254  * Quadrilateral-specific:
255  * Get the number of edges defined for the quadrilateral.
256  */
257 template <typename TCellInterface>
258 typename QuadrilateralCell< TCellInterface >::CellFeatureCount
259 QuadrilateralCell< TCellInterface >
260 ::GetNumberOfEdges(void) const
261 {
262   return Self::NumberOfEdges;
263 }
264
265 /**
266  * Quadrilateral-specific:
267  * Get the vertex specified by the given cell feature Id.
268  * The Id can range from 0 to GetNumberOfVertices()-1.
269  */
270 template <typename TCellInterface>
271 bool
272 QuadrilateralCell< TCellInterface >
273 ::GetVertex(CellFeatureIdentifier vertexId,VertexAutoPointer & vertexPointer )
274 {
275   VertexType * vert = new VertexType;
276   vert->SetPointId(0, m_PointIds[vertexId]);
277   vertexPointer.TakeOwnership( vert );
278   return true;  
279 }
280
281 /**
282  * Quadrilateral-specific:
283  * Get the edge specified by the given cell feature Id.
284  * The Id can range from 0 to GetNumberOfEdges()-1.
285  */
286 template <typename TCellInterface>
287 bool
288 QuadrilateralCell< TCellInterface >
289 ::GetEdge(CellFeatureIdentifier edgeId, EdgeAutoPointer & edgePointer )
290 {
291   EdgeType * edge = new EdgeType;
292   for(int i=0; i < EdgeType::NumberOfPoints; ++i)
293     {
294     edge->SetPointId(i, m_PointIds[ m_Edges[edgeId][i] ]);
295     }
296   edgePointer.TakeOwnership( edge ); 
297   return true;
298 }
299
300
301 // end namespace itk
302
303 #endif
304

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