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

Berk Geveci berk.geveci at kitware.com
Fri Dec 17 08:45:49 EST 2010


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20101217/8342e317/attachment.htm>


More information about the ParaView mailing list