I am trying to know the min_voxel / max_voxel for vtkImageConnectivityFilter::SetSizeRange for bones, and I don’t know from where I taken … and I thinking (maybe is stupid) to get those values from a vtkPropPicker … it is possible ? if it is, how can do that ?
To get values from my model (probing) I used vtkCellPicker in addition to vtkPropPicker:
(...)
// Get the cell of a 3D object under the 2D screen coordinates (ray casting).
vtkSmartPointer<vtkCellPicker> cellPicker = vtkSmartPointer<vtkCellPicker>::New();
cellPicker->Pick(clickPos[0], clickPos[1], 0, this->GetDefaultRenderer());
//if something was picked
if( picker->GetActor() && cellPicker->GetCellId() != -1 ) {
// Output the probed value at the picked location.
vtkDataSet* dataSet = cellPicker->GetDataSet();
vtkCellData* cellData = dataSet->GetCellData();
vtkDataArray* dataArray = cellData->GetScalars();
if( dataArray->GetNumberOfComponents() <= 200 ){
double values[200]; //200 is a fairly large number of scalar fields.
dataArray->GetTuple( cellPicker->GetCellId(), values );
QString valuesText = "NO VALUES";
for( int i = 0; i < dataArray->GetNumberOfComponents(); ++i )
if( i == 0)
valuesText = QString::number(values[0]);
else
valuesText = valuesText + "; " + QString::number(values[i]);
std::cout << "Picked value(s): " << valuesText.toStdString() << std::endl;
} else
std::err << "Probing not possible if VTK object has more than 200 scalar fields in it." << std::endl;
}
(...)
For the complete example how I do probing can be found here.
Since your case is a volume, maybe the object you’re picking is not a subclass of vtkActor. If you are picking volume slices (vtkImageSlice), then GetActor() will return nullptr indeed.
Take a look at the vtkProp family. Then locate the visual VTK class that you’re using to render your image there. After that, you have to call the adequate method instead of getActor(). Maybe GetProp3D() will do.
but has the same result … didn’t used the right picker ? if I didn’t, what should be the right picker ?
Thank you for any response, this my main source of VTK learning (beside VTK documentation and examples) … so, don’t hesitate to write me anything of what I could learn here
Have you tried GetProp3D() instead of GetActor()? If the visual object you’re picking is not a vtkActor you have to use some other Get*() method of pPicker.