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

Method BuildRepresentation

Interaction/Widgets/vtk3DCursorRepresentation.cxx:227–260  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

225
226//------------------------------------------------------------------------------
227void vtk3DCursorRepresentation::BuildRepresentation()
228{
229 this->Internals->UpdateCursor();
230
231 // Target size = HandleSize in world coordinates
232 double cursorPos[3] = { 0.0 };
233 this->Internals->Cursor->GetPosition(cursorPos);
234 double targetSize = this->SizeHandlesInPixels(1.0, cursorPos);
235
236 double cursorBounds[6] = { 0.0 };
237 this->Internals->Cursor->GetBounds(cursorBounds);
238
239 // Safety check
240 if (cursorBounds[1] - cursorBounds[0] == 0)
241 {
242 return;
243 }
244
245 const double sizeRatio = 2 * targetSize / (cursorBounds[1] - cursorBounds[0]);
246
247 // Hardware Picker can return NaN position when the ray cast picking do not find any
248 // intersection due to floating-point arithmetic imprecisions (for example, when hitting
249 // the border of a cell)
250 if (std::isnan(sizeRatio))
251 {
252 return;
253 }
254
255 // Rescale the actor to fit the target size
256 double scale[3] = { 0.0 };
257 this->Internals->Cursor->GetScale(scale);
258 vtkMath::MultiplyScalar(scale, sizeRatio);
259 this->Internals->Cursor->SetScale(scale);
260}
261
262//------------------------------------------------------------------------------
263void vtk3DCursorRepresentation::ReleaseGraphicsResources(vtkWindow* win)

Callers 1

RenderOpaqueGeometryMethod · 0.95

Calls 8

SizeHandlesInPixelsMethod · 0.80
isnanFunction · 0.50
MultiplyScalarFunction · 0.50
UpdateCursorMethod · 0.45
GetPositionMethod · 0.45
GetBoundsMethod · 0.45
GetScaleMethod · 0.45
SetScaleMethod · 0.45

Tested by

no test coverage detected