vtkOBBTree crashes with non-polydata datasets due to unsafe pointer cast.
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
This line in vtkOBBTree::ComputeOBB(vtkIdList*,...) ... ((vtkPolyData *)this->DataSet)->GetCellPoints( cellId, numPts, ptIds ); ... causes obbtree to crash with e.g. unstructured grid datasets. (Short term) fixes:
- The line should be replaced by: vtkPolyData *polydata; polydata = vtkPolyData::SafeDownCast(this->DataSet); if (polydata == NULL) { vtkErrorMacro(<< "Input dataset not vtkPolyData"); return; } polydata->GetCellPoints( cellId, numPts, ptIds );
- The limitation should be documented.
- Alternatively, the method vtkOBBTree::SetDataSet(vtkPolyData *) should be defined thus preventing the user from calling the base class method (using the C++ no-overloading-across-scopes feature). (Longer term) fixes:
- Modify the locator to use the vtkOBBTree::ComputeOBB(vtkPoints*,...) when the input is not polydata.
- Wait for vtkMesh :-)