KWStyle - itkPointLocator.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkPointLocator.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
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   Portions of this code are covered under the VTK copyright.
13   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
14
15      This software is distributed WITHOUT ANY WARRANTY; without even 
16      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
17 IND *****PURPOSE.  See the above copyright notices for more information.
18
19 =========================================================================*/
20 DEF #ifndef _itkPointLocator_txx
21 DEF #define _itkPointLocator_txx
22 #include "itkPointLocator.h"
23
24 namespace itk
25 {
26
27 template <typename TPointIdentifier, int VPointDimension,
28           typename TCoordRep, typename TPointsContainer>
29 void 
30 PointLocator<TPointIdentifier,VPointDimension,TCoordRep,TPointsContainer>
31 ::InitPointInsertion(PointsContainer *newPts, BoundingBoxPointer)
32 {
33   // Check the input
34   m_Points = newPts;
35 #if 0
36   if ( newPts )
37     {
38     this->Points = newPts;
39     }
40   else
41     {
42     //throw an exception and return
43     return;
44     }
45 #endif
46 }
47
48 template <typename TPointIdentifier, int VPointDimension,
49           typename TCoordRep, typename TPointsContainer>
50 void 
51 PointLocator<TPointIdentifier,VPointDimension,TCoordRep,TPointsContainer>
52 LEN ::InitIncrementalPointInsertion(PointsContainer *newPts, BoundingBoxPointer bbox)
53 {
54   // Check the input
55   m_Points = newPts;
56 #if 0
57   if ( newPts )
58     {
59     this->Points = newPts;
60     }
61   else
62     {
63     //throw an exception and return
64     return;
65     }
66 #endif
67 }
68
69 #if 0
70 int i;
71 int maxDivs;
72 typedef vtkIdList *vtkIdListPtr;
73 float hmin;
74 int ndivs[3];
75 float level;
76
77 if ( this->HashTable )
78 {
79   this->FreeSearchStructure();
80 }
81 if ( !newPts  )
82 {
83   vtkErrorMacro(<<"Must define points for point insertion");
84   return 0;
85 }
86 if (this->Points)
87 {
88   this->Points->UnRegister(this);
89 }
90 this->Points = newPts;
91 this->Points->Register(this);
92
93 for (i=0; i<3; i++)
94 {
95   this->Bounds[2*i] = bounds[2*i];
96   this->Bounds[2*i+1] = bounds[2*i+1];
97   if ( this->Bounds[2*i+1] <= this->Bounds[2*i] )
98     {
99     this->Bounds[2*i+1] = this->Bounds[2*i] + 1.0;
100     }
101 }
102
103 if ( this->Automatic && (estNumPts > 0) )
104 {
105   level = (float) estNumPts / this->NumberOfPointsPerBucket;
106   level = ::ceil( pow((double)level,(double)0.33333333) );
107   for (i=0; i<3; i++)
108     {
109     ndivs[i] = (int) level;
110     }
111
112 else 
113 {
114   for (i=0; i<3; i++)
115     {
116     ndivs[i] = (int) this->Divisions[i];
117     }
118 }
119
120 for (i=0; i<3; i++) 
121 {
122   ndivs[i] = (ndivs[i] > 0 ? ndivs[i] : 1);
123   this->Divisions[i] = ndivs[i];
124 }
125
126 this->NumberOfBuckets = ndivs[0]*ndivs[1]*ndivs[2];
127 this->HashTable = new vtkIdListPtr[this->NumberOfBuckets];
128 memset (this->HashTable, 0, this->NumberOfBuckets*
129         sizeof(vtkIdListPtr));
130 //
131 //  Compute width of bucket in three directions
132 //
133 for (i=0; i<3; i++) 
134 {
135 SEM   this->H[i] = (this->Bounds[2*i+1] - this->Bounds[2*i]) / ndivs[i] ;
136 }
137
138 this->InsertionTol2 = this->Tolerance * this->Tolerance;
139
140 for (maxDivs=0, hmin=VTK_LARGE_FLOAT, i=0; i<3; i++) 
141 {
142   hmin = (this->H[i] < hmin ? this->H[i] : hmin);
143   maxDivs = (maxDivs > this->Divisions[i] ? maxDivs : this->Divisions[i]);
144 }
145 this->InsertionLevel = ::ceil ((double) this->Tolerance / hmin);
146 LEN this->InsertionLevel = (this->InsertionLevel > maxDivs ? maxDivs : this->InsertionLevel);
147 return 1;
148 #endif
149
150
151 /******************************************************************************
152  * PROTECTED METHOD DEFINITIONS
153  *****************************************************************************/
154
155 template <typename TPointIdentifier, int VPointDimension,
156           typename TCoordRep, typename TPointsContainer>
157 PointLocator<TPointIdentifier,VPointDimension,TCoordRep,TPointsContainer>
158 ::PointLocator():
159 IND **m_Points(NULL)
160 {
161   m_Divisions = new unsigned long [PointDimension];
162   m_NumberOfPointsPerBucket = 3;
163 }
164
165 template <typename TPointIdentifier, int VPointDimension,
166           typename TCoordRep, typename TPointsContainer>
167 PointLocator<TPointIdentifier,VPointDimension,TCoordRep,TPointsContainer>
168 ::~PointLocator()
169 {
170   delete [] m_Divisions;
171 }
172
173 /**
174  * Print out the bounding box.
175  */
176 template <typename TPointIdentifier, int VPointDimension,
177           typename TCoordRep, typename TPointsContainer>
178 void
179 PointLocator<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
180 ::PrintSelf(std::ostream& os, Indent indent) const
181 {
182   Superclass::PrintSelf(os, indent);
183   os << indent << "Divisions: " << m_Divisions << "\n";
184 LEN   os << indent << "NumberOfPointsPerBucket: " << m_NumberOfPointsPerBucket << "\n";
185 }
186
187 // end namespace itk
188
189 #endif
190

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