KWStyle - itkQuadraticEdgeCell.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkQuadraticEdgeCell.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 _itkQuadraticEdgeCell_txx
18 DEF #define _itkQuadraticEdgeCell_txx
19 #include "itkQuadraticEdgeCell.h"
20
21 namespace itk
22 {
23
24 /**
25  * Standard CellInterface:
26  */
27 template <typename TCellInterface>
28 void
29 QuadraticEdgeCell< TCellInterface >
30 ::MakeCopy(CellAutoPointer & cellPointer) const
31 {
32   cellPointer.TakeOwnership( new Self );
33   cellPointer->SetPointIds(this->GetPointIds());
34 }
35
36
37   
38 /**
39  * Standard CellInterface:
40  * Get the topological dimension of this cell.
41  */
42 template <typename TCellInterface>
43 unsigned int
44 QuadraticEdgeCell< TCellInterface >
45 ::GetDimension(void) const
46 {
47   return Self::CellDimension;
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 QuadraticEdgeCell< TCellInterface >
57 ::GetNumberOfPoints(void) const
58 {
59   return Self::NumberOfPoints;
60 }  
61
62
63 /**
64  * Standard CellInterface:
65  * Get the number of boundary entities of the given dimension.
66  */
67 template <typename TCellInterface>
68 typename QuadraticEdgeCell< TCellInterface >::CellFeatureCount
69 QuadraticEdgeCell< TCellInterface >
70 ::GetNumberOfBoundaryFeatures(int dimension) const
71 {
72   switch (dimension)
73     {
74     case 0: return GetNumberOfVertices();
75     default: return 0;
76     }
77 }
78
79
80 /**
81  * Standard CellInterface:
82  * Get the boundary feature of the given dimension specified by the given
83  * cell feature Id.
84  * The Id can range from 0 to GetNumberOfBoundaryFeatures(dimension)-1.
85  */
86 template <typename TCellInterface>
87 bool
88 QuadraticEdgeCell< TCellInterface >
89 ::GetBoundaryFeature(int dimension, CellFeatureIdentifier featureId, 
90                      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     default: 
110 IND ****{
111 IND ****cellPointer.Reset();
112 IND ****return false;
113 IND ****}
114     }
115   return false;
116 }
117
118
119 /**
120  * Standard CellInterface:
121  * Set the point id list used by the cell.  It is assumed that the given
122  * iterator can be incremented and safely de-referenced enough times to 
123  * get all the point ids needed by the cell.
124  */
125 template <typename TCellInterface>
126 void
127 QuadraticEdgeCell< TCellInterface >
128 ::SetPointIds(PointIdConstIterator first)
129 {
130   PointIdConstIterator ii(first);
131 SEM   for(unsigned int i=0; i < Self::NumberOfPoints ; ++i)
132     m_PointIds[i] = *ii++;
133 }
134
135
136 /**
137  * Standard CellInterface:
138  * Set the point id list used by the cell.  It is assumed that the range
139  * of iterators [first, last) contains the correct number of points needed to
140  * define the cell.  The position *last is NOT referenced, so it can safely
141  * be one beyond the end of an array or other container.
142  */
143 template <typename TCellInterface>
144 void
145 QuadraticEdgeCell< TCellInterface >
146 ::SetPointIds(PointIdConstIterator first, PointIdConstIterator last)
147 {
148   int localId=0;
149   PointIdConstIterator ii(first);
150   
151   while(ii != last)
152     {
153     m_PointIds[localId++] = *ii++;
154     }
155 }
156
157
158 /**
159  * Standard CellInterface:
160  * Set an individual point identifier in the cell.
161  */
162 template <typename TCellInterface>
163 void
164 QuadraticEdgeCell< TCellInterface >
165 ::SetPointId(int localId, PointIdentifier ptId)
166 {
167   m_PointIds[localId] = ptId;
168 }
169
170
171 /**
172  * Standard CellInterface:
173  * Get a begin iterator to the list of point identifiers used by the cell.
174  */
175 template <typename TCellInterface>
176 typename QuadraticEdgeCell< TCellInterface >::PointIdIterator
177 QuadraticEdgeCell< TCellInterface >
178 ::PointIdsBegin(void)
179 {
180   return &m_PointIds[0];
181 }
182
183
184 /**
185  * Standard CellInterface:
186  * Get a const begin iterator to the list of point identifiers used
187  * by the cell.
188  */
189 template <typename TCellInterface>
190 typename QuadraticEdgeCell< TCellInterface >::PointIdConstIterator
191 QuadraticEdgeCell< TCellInterface >
192 ::PointIdsBegin(void) const
193 {
194   return &m_PointIds[0];
195 }
196
197
198 /**
199  * Standard CellInterface:
200  * Get an end iterator to the list of point identifiers used by the cell.
201  */
202 template <typename TCellInterface>
203 typename QuadraticEdgeCell< TCellInterface >::PointIdIterator
204 QuadraticEdgeCell< TCellInterface >
205 ::PointIdsEnd(void)
206 {
207   return &m_PointIds[Self::NumberOfPoints];
208 }
209
210
211 /**
212  * Standard CellInterface:
213  * Get a const end iterator to the list of point identifiers used
214  * by the cell.
215  */
216 template <typename TCellInterface>
217 typename QuadraticEdgeCell< TCellInterface >::PointIdConstIterator
218 QuadraticEdgeCell< TCellInterface >
219 ::PointIdsEnd(void) const
220 {
221   return &m_PointIds[Self::NumberOfPoints];
222 }
223
224
225 /**
226  * QuadraticEdge-specific:
227  * Get the number of vertices for this line.
228  */
229 template <typename TCellInterface>
230 typename QuadraticEdgeCell< TCellInterface >::CellFeatureCount
231 QuadraticEdgeCell< TCellInterface >
232 ::GetNumberOfVertices(void) const
233 {
234   return Self::NumberOfVertices;
235 }
236
237
238 /**
239  * QuadraticEdge-specific:
240  * Get the vertex specified by the given cell feature Id.
241  * The Id can range from 0 to GetNumberOfVertices()-1.
242  */
243 template <typename TCellInterface>
244 bool
245 QuadraticEdgeCell< TCellInterface >
246 ::GetVertex(CellFeatureIdentifier vertexId, VertexAutoPointer & vertexPointer )
247 {
248   VertexType * vert = new VertexType;
249   vert->SetPointId(0, m_PointIds[vertexId]);
250   vertexPointer.TakeOwnership( vert );
251   return true;  
252 }
253
254
255 template <typename TCellInterface>
256 void 
257 QuadraticEdgeCell< TCellInterface >
258 ::EvaluateShapeFunctions( 
259   const ParametricCoordArrayType & parametricCoordinates,
260   ShapeFunctionsArrayType  & weights ) const
261 {
262
263   CoordRepType x = parametricCoordinates[0]; // one-dimensional cell
264   
265   if( weights.Size() != this->GetNumberOfPoints() )
266     {
267     weights = ShapeFunctionsArrayType( this->GetNumberOfPoints() );
268     }
269
270   weights[0] =     ( 2*x - 1.0 ) * ( x-1.0 );
271   weights[1] =     ( 2*x - 1.0 ) * ( x     );
272   weights[2] = 4 * ( 1.0 -   x ) * ( x     );
273
274 }
275
276
277 // end namespace itk
278
279 #endif
280
281 EOF

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