2 * Progam made by Olivier Bernard, associate professor
3 * at Institut National des Sciences Appliquees (INSA) Lyon,
4 * CREATIS-LRMN Laboratory,
5 * 69621 Villeurbanne, France,
9 #ifndef __vtkOptimizedImageData_h__
10 #define __vtkOptimizedImageData_h__
12 #include <vtkObjectFactory.h>
13 #include <vtkImageData.h>
14 #include <vtkPointData.h>
20 class VTK_EXPORT vtkOptimizedImageData : public vtkImageData
32 vtkOptimizedImageData() : data(NULL) {}
33 ~vtkOptimizedImageData() {}
37 static vtkOptimizedImageData *New()
39 vtkObject* ret = vtkObjectFactory::CreateInstance("vtkOptimizedImageData");
40 if(ret) { return (vtkOptimizedImageData*)ret; }
41 // If the factory was unable to create the object, then create it here.
42 return (new vtkOptimizedImageData);
45 vtkOptimizedImageData& operator=(vtkImageData &m)
51 T& operator()(int x, int y, int z)
54 data = static_cast<T*>(this->PointData->GetScalars()->GetVoidPointer(0));
55 dimX = this->GetDimensions()[0];
56 dimY = this->GetDimensions()[1];
57 dimZ = this->GetDimensions()[2];
59 return data[x+y*dimX+z*dimX*dimY];
60 // if ( (x>=0 && x<dimX) && (y>=0 && y<dimY) && (z>=0 && z<dimZ) )
61 // return data[x+y*dimX+z*dimX*dimY];
64 // cout << "Take care, try to access a point out of the volume" << endl;
69 double operator()(double x, double y, double z) // added by Daniel
72 data = static_cast<T*>(this->PointData->GetScalars()->GetVoidPointer(0));
73 dimX = this->GetDimensions()[0];
74 dimY = this->GetDimensions()[1];
75 dimZ = this->GetDimensions()[2];
83 // cout << x << " " << y << " " << z << " " << endl;
84 // cout << x0 << " " << y0 << " " << z0 << " " << endl;
92 // cout << x1 << " " << y1 << " " << z1 << " " << endl;
99 // cout << xd << " " << yd << " " << zd << " " << endl;
105 double c00, c10, c01, c11;
106 c00 = data[x0+y0*dimX+z0*dimX*dimY]*xdi+data[x1+y0*dimX+z0*dimX*dimY]*xd;
107 c10 = data[x0+y1*dimX+z0*dimX*dimY]*xdi+data[x1+y1*dimX+z0*dimX*dimY]*xd;
108 c01 = data[x0+y0*dimX+z1*dimX*dimY]*xdi+data[x1+y0*dimX+z1*dimX*dimY]*xd;
109 c11 = data[x0+y1*dimX+z1*dimX*dimY]*xdi+data[x1+y1*dimX+z1*dimX*dimY]*xd;
119 T& operator()(int x, int y)
122 data = static_cast<T*>(this->PointData->GetScalars()->GetVoidPointer(0));
123 dimX = this->GetDimensions()[0];
124 dimY = this->GetDimensions()[1];
127 if ( (x>=0 && x<dimX) && (y>=0 && y<dimY) )
128 return data[x+y*dimX];
131 cout << "Take care, try to access a point out of the volume" << endl;
139 data = static_cast<T*>(this->PointData->GetScalars()->GetVoidPointer(0));
140 dimX = this->GetDimensions()[0];
141 dimY = this->GetDimensions()[1];
142 dimZ = this->GetDimensions()[2];
144 if (k>=0 && k<dimX*dimY*dimZ)
148 cout << "Take care, try to access a point out of the volume" << endl;
153 void PrintDataPointer()
155 cout << "data = " << this->PointData->GetScalars()->GetVoidPointer(0) << endl;
162 this->Superclass::Update();
168 void CopyImage(vtkDataObject *src)
171 data = static_cast<T*>(this->PointData->GetScalars()->GetVoidPointer(0));
172 dimX = this->GetDimensions()[0];
173 dimY = this->GetDimensions()[1];
174 dimZ = this->GetDimensions()[2];