[vtkusers] vtkImageData::FindCell

David Gobbi david.gobbi at gmail.com
Tue Nov 30 11:04:19 EST 2010


On Tue, Nov 30, 2010 at 7:40 AM, David Doria <daviddoria at gmail.com> wrote:

> 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?
>

FindCell does what it is supposed to.  The documentation says:
"Returns cellId >= 0 if inside, < 0 otherwise."

  - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101130/f5180112/attachment.htm>


More information about the vtkusers mailing list