[Paraview] 2D and 1D vtkImageData::FindPoint() bug.
Felipe Bordeu
felipe.bordeu at ec-nantes.fr
Fri Dec 17 05:52:37 EST 2010
hi everybody,
I use the vtkImageData::findpoint(double x[3]) function to retrieve the
id of a point.
in the case the data is 2D ( the dimension of z is 1) the spacing of the
z in not relevant. Then if i put 0 in the spacing for z, then the
findpoint function fails to find the point.
After looking at the code, it became clear.
for know I can put a positive value into the z Spacing to bypass the bug.
this problem also happens for a 1D image data.
vtkImageData.cxx:706
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vtkIdType vtkImageData::FindPoint(double x[3])
{
int i, loc[3];
double d;
const double *origin = this->Origin;
const double *spacing = this->Spacing;
const int* extent = this->Extent;
vtkIdType dims[3];
dims[0] = extent[1] - extent[0] + 1;
dims[1] = extent[3] - extent[2] + 1;
dims[2] = extent[5] - extent[4] + 1;
//
// Compute the ijk location
//
for (i=0; i<3; i++)
{
d = x[i] - origin[i];
loc[i] = static_cast<int>((d / spacing[i]) + 0.5); <--------------
use of an irrelevant value
if ( loc[i] < extent[i*2] || loc[i] > extent[i*2+1] )
{
return -1;
}
// since point id is relative to the first point actually stored
loc[i] -= extent[i*2];
}
//
// From this location get the point id
//
return loc[2]*dims[0]*dims[1] + loc[1]*dims[0] + loc[0];
}
--
Felipe Bordeu Weldt
Ingénieur de Recherche
-------------------------------------
Tél. : 33 (0)2 40 37 16 57
Fax. : 33 (0)2 40 74 74 06
Felipe.Bordeu at ec-nantes.fr
Intitut GeM - UMR CNRS 6183
École Centrale Nantes
1 Rue de La Noë, 44321 Nantes, FRANCE
-------------------------------------
More information about the ParaView
mailing list