we are trying to use the vtkHardwarePicker to give information about a user hovered location in a data set. With unstructured grids this seems to be working correctly. However with vtkImageData when the user hovers over a cell (cell centered data) I get information from the extracted surface instead of the cell centered data. I am wondering if we are just using this incorrectly or if there are special hoops I need to jump through when using a vtkImageData?
We use a vtkImageToStructuredGrid
and vtkDataSetMapper
to show the data on screen. Then here is our function to attempt to get information from the vtkHardwarePicker:
std::string GenerateHoverString()
{
int* clickPos = m_VisualizationWidget->renderWindow()->GetInteractor()->GetEventPosition();
vtkNew<vtkHardwarePicker> picker;
// pick a dataset
picker->SetSnapToMeshPoint(m_PointPickerOn);
int const pickResult = picker->Pick(clickPos[0], clickPos[1], 0, m_Renderer);
if(pickResult == 1)
{
vtkDataSet* pickedDataSet = picker->GetDataSet();
if(pickedDataSet != nullptr)
{
vtkIdType cellId = picker->GetCellId();
vtkIdType pointId = picker->GetPointId();
if(m_PointPickerOn)
{
return printDataValues(pickedDataSet->GetPointData(), pointId, "Point");
}
if(m_CellPickerOn)
{
return printDataValues(pickedDataSet->GetCellData(), cellId, "Cell");
}
}
}
return {""};
}
I am hoping this is just a simple misunderstanding on my part on how to use the vtkHardwarePicker. Maybe I need to work my way back up through the vtk pipeline to find the original source instead of what comes out of the vtkImageToStructuredGrid
filter?