MCPcopy Create free account
hub / github.com/Kitware/VTK / IntersectVolumeWithLine

Method IntersectVolumeWithLine

Rendering/Core/vtkCellPicker.cxx:981–1265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979#define VTKCELLPICKER_VOXEL_TOL 1e-6
980
981double 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

Callers 1

IntersectWithLineMethod · 0.95

Calls 15

ComputeVolumeOpacityMethod · 0.95
ResetPickInfoMethod · 0.95
SetImageDataPickInfoMethod · 0.95
GetPickLODIDMethod · 0.80
GetLODPropertyMethod · 0.80
GetScalarSizeMethod · 0.80
GetScalarPointerMethod · 0.80
GetScalarOpacityMethod · 0.80
GetGradientOpacityMethod · 0.80
SetVoidArrayMethod · 0.80
GetVoxelGradientMethod · 0.80

Tested by

no test coverage detected