[vtkusers] Correct implementation of vtkImageData -> FindCell (...)

dean.inglis at camris.ca dean.inglis at camris.ca
Wed Jan 23 16:41:20 EST 2008


Hi Jake,

could be segfaulting due to
double * fweights;
which can be fixed with 

double  fweights[8];

see how vtkImageData calls FindCell at line 747...

Dean


/********************begin code**********************/
...
  //double p[3] is initialized
...
  vtkEmptyCell * femptycell = vtkEmptyCell::New();
  vtkCell * fcell = femptycell->NewInstance();
  vtkIdType fcellID;
  double ftol2;
  int fsubId;
  double fpcoords[3];
  double * fweights;

  vtkIdType fFindCell = [instance of vtkImageData *]->FindCell(p, fcell,
fcellID, ftol2, fsubId, fpcoords, fweights);

  std::cout << "cellID returned from FindCell() = " << fFindCell <<
std::endl;
/********************end code**********************/

When I click on one of the orthogonal slices, my application successfully
prints out the cellId, for instance:

"cellID returned from FindCell() = 42196578"

However, it then crashes with a Segmentation Fault.  I have narrowed the
problem down to this chunk of code because when I replace it with similar
code to compute the cell ID (pasted below), it runs fine without any seg
fault.



More information about the vtkusers mailing list