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

Method UpdateDiscreteCursor

Interaction/Widgets/vtkImagePlaneWidget.cxx:2125–2167  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2123
2124//------------------------------------------------------------------------------
2125int vtkImagePlaneWidget::UpdateDiscreteCursor(double* q)
2126{
2127 // vtkImageData will find the nearest implicit point to q
2128 //
2129 vtkIdType ptId = this->ImageData->FindPoint(q);
2130
2131 if (ptId == -1)
2132 {
2133 return 0;
2134 }
2135
2136 double closestPt[3];
2137 this->ImageData->GetPoint(ptId, closestPt);
2138
2139 double origin[3];
2140 this->ImageData->GetOrigin(origin);
2141 double spacing[3];
2142 this->ImageData->GetSpacing(spacing);
2143 int extent[6];
2144 this->ImageData->GetExtent(extent);
2145
2146 int iq[3];
2147 int iqtemp;
2148 for (int i = 0; i < 3; i++)
2149 {
2150 // compute world to image coords
2151 iqtemp = static_cast<int>(std::round((closestPt[i] - origin[i]) / spacing[i]));
2152
2153 // we have a valid pick already, just enforce bounds check
2154 iq[i] = std::min(std::max(iqtemp, extent[2 * i]), extent[2 * i + 1]);
2155
2156 // compute image to world coords
2157 q[i] = iq[i] * spacing[i] + origin[i];
2158
2159 this->CurrentCursorPosition[i] = iq[i];
2160 }
2161
2162 this->CurrentImageValue =
2163 this->ImageData->GetScalarComponentAsDouble(static_cast<int>(this->CurrentCursorPosition[0]),
2164 static_cast<int>(this->CurrentCursorPosition[1]),
2165 static_cast<int>(this->CurrentCursorPosition[2]), 0);
2166 return 1;
2167}
2168
2169//------------------------------------------------------------------------------
2170void vtkImagePlaneWidget::SetOrigin(double x, double y, double z)

Callers 1

UpdateCursorMethod · 0.95

Calls 9

roundFunction · 0.50
minFunction · 0.50
maxFunction · 0.50
FindPointMethod · 0.45
GetPointMethod · 0.45
GetOriginMethod · 0.45
GetSpacingMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected