[vtk-developers] [Paraview] 2D and 1D vtkImageData::FindPoint() bug.

David Gobbi david.gobbi at gmail.com
Fri Dec 17 09:14:19 EST 2010


Hi Felipe,

It isn't just FindPoint(), there are dozens of places in VTK where
a divide-by-spacing occurs.  Adding checks for 2D and 1D image
data at each of these places would be a large amount of work.
So up until now, it has always been the responsibility of the
application developer to ensure that the spacing is nonzero.

Hopefully some other developers can also give their thoughts on
this issue.

  David

On Fri, Dec 17, 2010 at 6:45 AM, Berk Geveci <berk.geveci at kitware.com> wrote:
> Forwarding to VTK developers.
>
> On Fri, Dec 17, 2010 at 5:52 AM, Felipe Bordeu <felipe.bordeu at ec-nantes.fr>
> wrote:
>>
>> 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
>> -------------------------------------
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>



More information about the vtk-developers mailing list