| 46 | // same method in the superclass, this method will look for cropping planes. |
| 47 | |
| 48 | double vtkVolumePicker::IntersectVolumeWithLine(const double p1[3], const double p2[3], double t1, |
| 49 | double t2, vtkProp3D* prop, vtkAbstractVolumeMapper* mapper) |
| 50 | { |
| 51 | double tMin = VTK_DOUBLE_MAX; |
| 52 | |
| 53 | vtkImageData* data = vtkImageData::SafeDownCast(mapper->GetDataSetInput()); |
| 54 | vtkVolumeMapper* vmapper = vtkVolumeMapper::SafeDownCast(mapper); |
| 55 | |
| 56 | if (data == nullptr) |
| 57 | { |
| 58 | // This picker only works with image inputs |
| 59 | return VTK_DOUBLE_MAX; |
| 60 | } |
| 61 | |
| 62 | // Convert ray to structured coordinates |
| 63 | double spacing[3], origin[3]; |
| 64 | int extent[6]; |
| 65 | data->GetSpacing(spacing); |
| 66 | data->GetOrigin(origin); |
| 67 | data->GetExtent(extent); |
| 68 | |
| 69 | double x1[3], x2[3]; |
| 70 | for (int i = 0; i < 3; i++) |
| 71 | { |
| 72 | x1[i] = (p1[i] - origin[i]) / spacing[i]; |
| 73 | x2[i] = (p2[i] - origin[i]) / spacing[i]; |
| 74 | } |
| 75 | |
| 76 | // These are set to the plane that the ray enters through |
| 77 | int planeId = -1; |
| 78 | int extentPlaneId = -1; |
| 79 | |
| 80 | // There might be multiple regions, depending on cropping flags |
| 81 | int numSegments = 1; |
| 82 | double t1List[16], t2List[16], s1List[16]; |
| 83 | int planeIdList[16]; |
| 84 | t1List[0] = t1; |
| 85 | t2List[0] = t2; |
| 86 | // s1 is the cropping plane intersection, initialize to large value |
| 87 | double s1 = s1List[0] = VTK_DOUBLE_MAX; |
| 88 | planeIdList[0] = -1; |
| 89 | |
| 90 | // Find the cropping bounds in structured coordinates |
| 91 | double bounds[6]; |
| 92 | for (int j = 0; j < 6; j++) |
| 93 | { |
| 94 | bounds[j] = extent[j]; |
| 95 | } |
| 96 | |
| 97 | if (vmapper && vmapper->GetCropping()) |
| 98 | { |
| 99 | vmapper->GetCroppingRegionPlanes(bounds); |
| 100 | for (int j = 0; j < 3; j++) |
| 101 | { |
| 102 | double b1 = (bounds[2 * j] - origin[j]) / spacing[j]; |
| 103 | double b2 = (bounds[2 * j + 1] - origin[j]) / spacing[j]; |
| 104 | bounds[2 * j] = (b1 < b2 ? b1 : b2); |
| 105 | bounds[2 * j + 1] = (b1 < b2 ? b2 : b1); |
nothing calls this directly
no test coverage detected