[vtkusers] vtkImageData::FindCell

David Doria daviddoria at gmail.com
Tue Nov 30 09:40:20 EST 2010


The following code returns -1. I would expect it to return the index
of the cell that is closest to the point (1.0, 1.0, 1.0).

#include <vtkSmartPointer.h>
#include <vtkImageData.h>

int main(int, char *[])
{
  int dims[3] = {1,2,3};
  double spacing[3] = {1.0, 1.0, 1.0};
  vtkSmartPointer<vtkImageData> image =
    vtkSmartPointer<vtkImageData>::New();
  image->SetDimensions(dims);
  image->SetSpacing(spacing);

  double p[3] = {1.0,1.0,1.0};
  int subId;
  double pcoords[3] = {0,0,0};
  double weights[8];
  int index = image->FindCell(p, NULL, 0, 10.0, subId, pcoords, weights);
  std::cout << "index: " << index << std::endl;

  return EXIT_SUCCESS;
}

Am I missing something?

David



More information about the vtkusers mailing list