KWStyle - itkVertexCell.txx
 
Matrix View
Description

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

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