| 979 | #define VTKCELLPICKER_VOXEL_TOL 1e-6 |
| 980 | |
| 981 | double vtkCellPicker::IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1, |
| 982 | double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper) |
| 983 | { |
| 984 | vtkImageData* data = vtkImageData::SafeDownCast(mapper->GetDataSetInput()); |
| 985 | |
| 986 | if (data == nullptr) |
| 987 | { |
| 988 | // This picker only works with image inputs |
| 989 | return VTK_DOUBLE_MAX; |
| 990 | } |
| 991 | |
| 992 | // Convert ray to structured coordinates |
| 993 | double spacing[3], origin[3]; |
| 994 | int extent[6]; |
| 995 | data->GetSpacing(spacing); |
| 996 | data->GetOrigin(origin); |
| 997 | data->GetExtent(extent); |
| 998 | |
| 999 | double x1[3], x2[3]; |
| 1000 | for (int i = 0; i < 3; i++) |
| 1001 | { |
| 1002 | x1[i] = (p1[i] - origin[i]) / spacing[i]; |
| 1003 | x2[i] = (p2[i] - origin[i]) / spacing[i]; |
| 1004 | } |
| 1005 | |
| 1006 | // Clip the ray with the extent, results go in s1 and s2 |
| 1007 | int planeId; |
| 1008 | double s1, s2; |
| 1009 | if (!vtkCellPicker::ClipLineWithExtent(extent, x1, x2, s1, s2, planeId)) |
| 1010 | { |
| 1011 | return VTK_DOUBLE_MAX; |
| 1012 | } |
| 1013 | t1 = std::max(s1, t1); |
| 1014 | t2 = std::min(s2, t2); |
| 1015 | |
| 1016 | // Sanity check |
| 1017 | if (t2 < t1) |
| 1018 | { |
| 1019 | return VTK_DOUBLE_MAX; |
| 1020 | } |
| 1021 | |
| 1022 | // Get the property from the volume or the LOD |
| 1023 | vtkVolumeProperty* property = nullptr; |
| 1024 | vtkVolume* volume = nullptr; |
| 1025 | vtkLODProp3D* lodVolume = nullptr; |
| 1026 | if ((volume = vtkVolume::SafeDownCast(prop))) |
| 1027 | { |
| 1028 | property = volume->GetProperty(); |
| 1029 | } |
| 1030 | else if ((lodVolume = vtkLODProp3D::SafeDownCast(prop))) |
| 1031 | { |
| 1032 | int lodId = lodVolume->GetPickLODID(); |
| 1033 | lodVolume->GetLODProperty(lodId, &property); |
| 1034 | } |
| 1035 | |
| 1036 | // Get the threshold for the opacity |
| 1037 | double opacityThreshold = this->VolumeOpacityIsovalue; |
| 1038 |
no test coverage detected