------------------------------------------------------------------------------
| 225 | |
| 226 | //------------------------------------------------------------------------------ |
| 227 | void 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 | //------------------------------------------------------------------------------ |
| 263 | void vtk3DCursorRepresentation::ReleaseGraphicsResources(vtkWindow* win) |
no test coverage detected