KWStyle - itkQuadraticTriangleCell.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkQuadraticTriangleCell.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 _itkQuadraticTriangleCell_txx
18 DEF #define _itkQuadraticTriangleCell_txx
19 #include "itkQuadraticTriangleCell.h"
20
21 namespace itk
22 {
23
24 /**
25  * Standard CellInterface:
26  */
27 template <typename TCellInterface>
28 void
29 QuadraticTriangleCell< 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 QuadraticTriangleCell< 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 QuadraticTriangleCell< 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 QuadraticTriangleCell< TCellInterface >::CellFeatureCount
69 QuadraticTriangleCell< 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 QuadraticTriangleCell< TCellInterface >
90 ::GetBoundaryFeature(int dimension, CellFeatureIdentifier featureId,
91                      CellAutoPointer& cellPointer )
92 {
93   switch (dimension)
94     {
95     case 0: 
96 IND ****{
97 IND ****VertexAutoPointer vertexPointer;
98 IND ****if( this->GetVertex(featureId,vertexPointer) )
99 IND ******{
100 IND ******TransferAutoPointer(cellPointer,vertexPointer);
101 IND ******return true;
102 IND ******}
103 IND ****else
104 IND ******{
105 IND ******cellPointer.Reset();
106 IND ******return false;
107 IND ******}
108 IND ****break;
109 IND ****}
110     case 1: 
111 IND ****{
112 IND ****EdgeAutoPointer edgePointer;
113 IND ****if( this->GetEdge(featureId,edgePointer) )
114 IND ******{
115 IND ******TransferAutoPointer(cellPointer,edgePointer);
116 IND ******return true;
117 IND ******}
118 IND ****else
119 IND ******{
120 IND ******cellPointer.Reset();
121 IND ******return false;
122 IND ******}
123 IND ****break;
124 IND ****}
125
126     default: 
127 IND ****{
128 IND ****cellPointer.Reset();
129 IND ****return false;
130 IND ****}
131     }
132   return false;
133 }
134
135
136 /**
137  * Standard CellInterface:
138  * Set the point id list used by the cell.  It is assumed that the given
139  * iterator can be incremented and safely de-referenced enough times to 
140  * get all the point ids needed by the cell.
141  */
142 template <typename TCellInterface>
143 void
144 QuadraticTriangleCell< TCellInterface >
145 ::SetPointIds(PointIdConstIterator first)
146 {
147   PointIdConstIterator ii(first);
148 SEM   for(unsigned int i=0; i < Self::NumberOfPoints ; ++i)
149     {
150     m_PointIds[i] = *ii++;
151     }
152 }
153
154
155 /**
156  * Standard CellInterface:
157  * Set the point id list used by the cell.  It is assumed that the range
158  * of iterators [first, last) contains the correct number of points needed to
159  * define the cell.  The position *last is NOT referenced, so it can safely
160  * be one beyond the end of an array or other container.
161  */
162 template <typename TCellInterface>
163 void
164 QuadraticTriangleCell< TCellInterface >
165 ::SetPointIds(PointIdConstIterator first, PointIdConstIterator last)
166 {
167   int localId=0;
168   PointIdConstIterator ii(first);
169   
170   while(ii != last)
171     {
172     m_PointIds[localId++] = *ii++;
173     }
174 }
175
176
177 /**
178  * Standard CellInterface:
179  * Set an individual point identifier in the cell.
180  */
181 template <typename TCellInterface>
182 void
183 QuadraticTriangleCell< TCellInterface >
184 ::SetPointId(int localId, PointIdentifier ptId)
185 {
186   m_PointIds[localId] = ptId;
187 }
188
189
190 /**
191  * Standard CellInterface:
192  * Get a begin iterator to the list of point identifiers used by the cell.
193  */
194 template <typename TCellInterface>
195 typename QuadraticTriangleCell< TCellInterface >::PointIdIterator
196 QuadraticTriangleCell< TCellInterface >
197 ::PointIdsBegin(void)
198 {
199   return &m_PointIds[0];
200 }
201
202
203 /**
204  * Standard CellInterface:
205  * Get a const begin iterator to the list of point identifiers used
206  * by the cell.
207  */
208 template <typename TCellInterface>
209 typename QuadraticTriangleCell< TCellInterface >::PointIdConstIterator
210 QuadraticTriangleCell< TCellInterface >
211 ::PointIdsBegin(void) const
212 {
213   return &m_PointIds[0];
214 }
215
216
217 /**
218  * Standard CellInterface:
219  * Get an end iterator to the list of point identifiers used by the cell.
220  */
221 template <typename TCellInterface>
222 typename QuadraticTriangleCell< TCellInterface >::PointIdIterator
223 QuadraticTriangleCell< TCellInterface >
224 ::PointIdsEnd(void)
225 {
226   return &m_PointIds[Self::NumberOfPoints];
227 }
228
229
230 /**
231  * Standard CellInterface:
232  * Get a const end iterator to the list of point identifiers used
233  * by the cell.
234  */
235 template <typename TCellInterface>
236 typename QuadraticTriangleCell< TCellInterface >::PointIdConstIterator
237 QuadraticTriangleCell< TCellInterface >
238 ::PointIdsEnd(void) const
239 {
240   return &m_PointIds[Self::NumberOfPoints];
241 }
242
243
244 /**
245  * Triangle-specific:
246  * Get the number of vertices defining the triangle.
247  */
248 template <typename TCellInterface>
249 typename QuadraticTriangleCell< TCellInterface >::CellFeatureCount
250 QuadraticTriangleCell< TCellInterface >
251 ::GetNumberOfVertices(void) const
252 {
253   return Self::NumberOfVertices;
254 }
255
256
257 /**
258  * Triangle-specific:
259  * Get the number of edges defined for the triangle.
260  */
261 template <typename TCellInterface>
262 typename QuadraticTriangleCell< TCellInterface >::CellFeatureCount
263 QuadraticTriangleCell< TCellInterface >
264 ::GetNumberOfEdges(void) const
265 {
266   return Self::NumberOfEdges;
267 }
268
269 /**
270  * Triangle-specific:
271  * Get the vertex specified by the given cell feature Id.
272  * The Id can range from 0 to GetNumberOfVertices()-1.
273  */
274 template <typename TCellInterface>
275 bool
276 QuadraticTriangleCell< TCellInterface >
277 ::GetVertex(CellFeatureIdentifier vertexId,VertexAutoPointer & vertexPointer )
278 {
279   VertexType * vert = new VertexType;
280   vert->SetPointId(0, m_PointIds[vertexId]);
281   vertexPointer.TakeOwnership( vert );
282   return true;  
283 }
284
285 /**
286  * Triangle-specific:
287  * Get the edge specified by the given cell feature Id.
288  * The Id can range from 0 to GetNumberOfEdges()-1.
289  */
290 template <typename TCellInterface>
291 bool
292 QuadraticTriangleCell< TCellInterface >
293 ::GetEdge(CellFeatureIdentifier edgeId, EdgeAutoPointer & edgePointer )
294 {
295   EdgeType * edge = new EdgeType;
296   for(unsigned int i=0; i < EdgeType::NumberOfPoints; ++i)
297     {
298     edge->SetPointId(i, m_PointIds[ m_Edges[edgeId][i] ]);
299     }
300   edgePointer.TakeOwnership( edge );
301   return true;
302 }
303
304
305 /** Given the parametric coordinates of a point in the cell
306  *  determine the value of its Shape Functions
307  *  returned through an itkArray<InterpolationWeightType>).  */
308 template <typename TCellInterface>
309 void 
310 QuadraticTriangleCell< TCellInterface >
311 ::EvaluateShapeFunctions( 
312   const ParametricCoordArrayType & parametricCoordinates,
313   ShapeFunctionsArrayType  & weights) const
314 {
315
316   if( parametricCoordinates.size() != 3 )
317     {
318 LEN     itkGenericExceptionMacro(<<"QuadraticTriangleCell expect three coordinates"); 
319     }
320     
321   const double L1 = parametricCoordinates[0];
322   const double L2 = parametricCoordinates[1];
323   const double L3 = parametricCoordinates[2];
324
325   weights = ShapeFunctionsArrayType(6);
326
327   weights[0] = L1 * ( 2.0 * L1 - 1.0 );
328   weights[1] = L2 * ( 2.0 * L2 - 1.0 );
329   weights[2] = L3 * ( 2.0 * L3 - 1.0 );
330   weights[3] = 4.0 * L1 * L3;
331   weights[4] = 4.0 * L1 * L2;
332   weights[5] = 4.0 * L2 * L3;
333
334 }
335
336
337 EML
338 EML
339 EML
340 // end namespace itk
341
342 #endif
343

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