VTK  9.1.0
vtkTensorRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkTensorRepresentation.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
43#ifndef vtkTensorRepresentation_h
44#define vtkTensorRepresentation_h
45
46#include "vtkInteractionWidgetsModule.h" // For export macro
48
49class vtkActor;
51class vtkLineSource;
52class vtkSphereSource;
53class vtkCellPicker;
54class vtkProperty;
55class vtkPolyData;
56class vtkPoints;
59class vtkTransform;
60class vtkMatrix4x4;
61class vtkPlane;
62class vtkPlanes;
63class vtkBox;
64class vtkDoubleArray;
65
66class VTKINTERACTIONWIDGETS_EXPORT vtkTensorRepresentation : public vtkWidgetRepresentation
67{
68public:
70
75 void PrintSelf(ostream& os, vtkIndent indent) override;
77
79
93 void SetTensor(double tensor[9]);
94 void SetSymmetricTensor(double symTensor[6]);
95 void GetTensor(double tensor[9]) { std::copy(this->Tensor, this->Tensor + 9, tensor); }
96 void GetSymmetricTensor(double symTensor[6])
97 {
98 symTensor[0] = this->Tensor[0];
99 symTensor[1] = this->Tensor[4];
100 symTensor[2] = this->Tensor[8];
101 symTensor[3] = this->Tensor[1];
102 symTensor[4] = this->Tensor[2];
103 symTensor[5] = this->Tensor[5];
104 }
106
108
113 void GetEigenvalues(double evals[3])
114 {
115 std::copy(this->Eigenvalues, this->Eigenvalues + 3, evals);
116 }
117 void GetEigenvector(int n, double ev[3])
118 {
119 n = (n < 0 ? 0 : (n > 2 ? 2 : n));
120 std::copy(this->Eigenvectors[n], this->Eigenvectors[n] + 3, ev);
121 }
123
125
130 void SetPosition(double pos[3]);
131 void GetPosition(double pos[3])
132 {
133 std::copy(this->TensorPosition, this->TensorPosition + 3, pos);
134 }
136
148
150
155 vtkGetObjectMacro(HandleProperty, vtkProperty);
156 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
158
160
165 vtkGetObjectMacro(FaceProperty, vtkProperty);
166 vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
168
170
175 vtkGetObjectMacro(OutlineProperty, vtkProperty);
176 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
178
180
184 vtkGetObjectMacro(EllipsoidProperty, vtkProperty);
186
188
193 vtkGetMacro(OutlineFaceWires, bool);
194 void OutlineFaceWiresOn() { this->SetOutlineFaceWires(true); }
195 void OutlineFaceWiresOff() { this->SetOutlineFaceWires(false); }
197
199
205 vtkGetMacro(OutlineCursorWires, bool);
206 void OutlineCursorWiresOn() { this->SetOutlineCursorWires(true); }
207 void OutlineCursorWiresOff() { this->SetOutlineCursorWires(false); }
209
211
215 virtual void HandlesOn();
216 virtual void HandlesOff();
218
220
224 vtkGetMacro(TensorEllipsoid, bool);
225 void TensorEllipsoidOn() { this->SetTensorEllipsoid(true); }
226 void TensorEllipsoidOff() { this->SetTensorEllipsoid(false); }
228
235 void PlaceTensor(double tensor[9], double position[3]);
236
238
241 void PlaceWidget(double bounds[6]) override;
242 void BuildRepresentation() override;
243 int ComputeInteractionState(int X, int Y, int modify = 0) override;
244 void StartWidgetInteraction(double e[2]) override;
245 void WidgetInteraction(double e[2]) override;
246 double* GetBounds() VTK_SIZEHINT(6) override;
247 void StartComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
248 unsigned long event, void* calldata) override;
249 void ComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
250 unsigned long event, void* calldata) override;
251 int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
252 unsigned long event, void* calldata, int modify = 0) override;
253 void EndComplexInteraction(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
254 unsigned long event, void* calldata) override;
256
258
261 void ReleaseGraphicsResources(vtkWindow*) override;
262 int RenderOpaqueGeometry(vtkViewport*) override;
263 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
264 vtkTypeBool HasTranslucentPolygonalGeometry() override;
266
267 // Used to manage the state of the widget
268 enum
269 {
270 Outside = 0,
279 Scaling
280 };
281
291 void SetInteractionState(int state);
292
294
298 vtkGetMacro(SnapToAxes, bool);
299 vtkSetMacro(SnapToAxes, bool);
301
303
310
311 /*
312 * Register internal Pickers within PickingManager
313 */
314 void RegisterPickers() override;
315
317
321 vtkGetMacro(TranslationAxis, int);
322 vtkSetClampMacro(TranslationAxis, int, -1, 2);
324
326
329 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
330 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
331 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
332 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
334
336
339 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
341
342protected:
345
346 // Core data
347 double Tensor[9]; // stored as 3x3 symmetric matrix
348 double Eigenvalues[3];
349 double Eigenvectors[3][3];
350 double TensorPosition[3];
351
352 // Manage how the representation appears
353 double LastEventPosition[3];
354 double LastEventOrientation[4];
355 double StartEventOrientation[4];
356 double SnappedEventOrientations[3][4];
357 bool SnappedOrientation[3];
359
360 // Constraint axis translation
362
363 // the hexahedron (6 faces)
367 vtkPoints* Points; // used by others as well
368 double N[6][3]; // the normals of the faces
369
370 // A face of the hexahedron
374
375 // glyphs representing hot spots (e.g., handles)
379 virtual void PositionHandles();
380 int HighlightHandle(vtkProp* prop); // returns cell id
381 void HighlightFace(int cellId);
382 void HighlightOutline(int highlight);
383 virtual void ComputeNormals();
384 virtual void SizeHandles();
385
386 // wireframe outline
390
391 // the tensor ellipsoid and transforms
397
398 // Do the picking
404
405 // Transform the hexahedral points (used for rotations)
409
410 // Support GetBounds() method
412
413 // Properties used to control the appearance of selected objects and
414 // the manipulator in general.
423
424 // Control the orientation of the normals
430 void UpdateTensorFromWidget(); // tensor information updated from widget state
431 void UpdateWidgetFromTensor(); // widget state updated from tensor specification
432 void UpdateTensorEigenfunctions(double tensor[3][3]);
433
434 // Helper methods
435 virtual void Translate(const double* p1, const double* p2);
436 virtual void Scale(const double* p1, const double* p2, int X, int Y);
437 virtual void Rotate(int X, int Y, const double* p1, const double* p2, const double* vpn);
438 void MovePlusXFace(const double* p1, const double* p2, bool entry);
439 void MoveMinusXFace(const double* p1, const double* p2, bool entry);
440 void MovePlusYFace(const double* p1, const double* p2, bool entry);
441 void MoveMinusYFace(const double* p1, const double* p2, bool entry);
442 void MovePlusZFace(const double* p1, const double* p2, bool entry);
443 void MoveMinusZFace(const double* p1, const double* p2, bool entry);
444 void UpdatePose(const double* p1, const double* d1, const double* p2, const double* d2);
445
446 // Internal ivars for performance
449
450 // The actual planes which are being manipulated
451 vtkPlane* Planes[6];
452
453 //"dir" is the direction in which the face can be moved i.e. the axis passing
454 // through the center
455 void MoveFace(const double* p1, const double* p2, const double* dir, double* x1, double* x2,
456 double* x3, double* x4, double* x5);
457
458 // Helper method to obtain the direction in which the face is to be moved.
459 // Handles special cases where some of the scale factors are 0.
460 void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
461
462private:
464 void operator=(const vtkTensorRepresentation&) = delete;
465};
466
467#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
implicit function for a bounding box
Definition: vtkBox.h:138
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:113
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
perform various plane computations
Definition: vtkPlane.h:143
implicit function for convex set of planes
Definition: vtkPlanes.h:159
represent the position of a point in 3D space
represent and manipulate 3D points
Definition: vtkPoints.h:143
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:67
represent surface properties of a geometric object
Definition: vtkProperty.h:171
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
class defining a representation for the vtkTensorWidget
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void OutlineCursorWiresOn()
Control the representation of the outline.
virtual void SizeHandles()
void GetEigenvalues(double evals[3])
These are methods used to retrieve derived information about the tensor.
void MovePlusXFace(const double *p1, const double *p2, bool entry)
int HighlightHandle(vtkProp *prop)
void SetOutlineFaceWires(bool)
Control the representation of the outline.
void MoveFace(const double *p1, const double *p2, const double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
void SetPosition(double pos[3])
Set/Get a position for the location of the tensor.
void HighlightFace(int cellId)
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void MovePlusZFace(const double *p1, const double *p2, bool entry)
void SetTensor(double tensor[9])
These are the basic methods used to define the tensor (these methods coordinate with the overloaded P...
void SetOutlineCursorWires(bool)
Control the representation of the outline.
virtual void HandlesOn()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
virtual void HandlesOff()
Switches handles (the spheres) on or off by manipulating the underlying actor visibility.
~vtkTensorRepresentation() override
void TensorEllipsoidOn()
Indicate whether to show the tensor ellipsoid.
virtual void PositionHandles()
vtkPolyDataMapper * OutlineMapper
void UpdateTensorEigenfunctions(double tensor[3][3])
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, obtaining type information, and printing.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
vtkPolyDataMapper * HexFaceMapper
void MoveMinusXFace(const double *p1, const double *p2, bool entry)
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void MovePlusYFace(const double *p1, const double *p2, bool entry)
vtkPolyDataMapper ** HandleMapper
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the representation.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetEigenvector(int n, double ev[3])
These are methods used to retrieve derived information about the tensor.
static vtkTensorRepresentation * New()
Standard methods for instantiation, obtaining type information, and printing.
void UpdatePose(const double *p1, const double *d1, const double *p2, const double *d2)
virtual void ComputeNormals()
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
void PlaceTensor(double tensor[9], double position[3])
This is a specialized place widget method for a tensor.
void GetSymmetricTensor(double symTensor[6])
These are the basic methods used to define the tensor (these methods coordinate with the overloaded P...
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
virtual void Rotate(int X, int Y, const double *p1, const double *p2, const double *vpn)
virtual void CreateDefaultProperties()
void MoveMinusZFace(const double *p1, const double *p2, bool entry)
vtkPolyDataMapper * EllipsoidMapper
void OutlineCursorWiresOff()
Control the representation of the outline.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void StepForward()
For complex events should we snap orientations to be aligned with the x y z axes.
void GetPosition(double pos[3])
Set/Get a position for the location of the tensor.
void TensorEllipsoidOff()
Indicate whether to show the tensor ellipsoid.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void OutlineFaceWiresOff()
Control the representation of the outline.
void SetSymmetricTensor(double symTensor[6])
These are the basic methods used to define the tensor (these methods coordinate with the overloaded P...
virtual void Translate(const double *p1, const double *p2)
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void StepBackward()
For complex events should we snap orientations to be aligned with the x y z axes.
void OutlineFaceWiresOn()
Control the representation of the outline.
void GetTensor(double tensor[9])
These are the basic methods used to define the tensor (these methods coordinate with the overloaded P...
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkTensorWidget) or other object.
void SetTensorEllipsoid(bool)
Indicate whether to show the tensor ellipsoid.
void MoveMinusYFace(const double *p1, const double *p2, bool entry)
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void Scale(const double *p1, const double *p2, int X, int Y)
void HighlightOutline(int highlight)
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
abstract specification for Viewports
Definition: vtkViewport.h:47
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ dir
Definition: vtkX3D.h:330
@ position
Definition: vtkX3D.h:267
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)