VTK  9.7.1
vtkImplicitCylinderRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
30 #ifndef vtkImplicitCylinderRepresentation_h
31 #define vtkImplicitCylinderRepresentation_h
32 
34 #include "vtkInteractionWidgetsModule.h" // For export macro
35 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkActor;
39 class vtkPolyDataMapper;
40 class vtkCellPicker;
41 class vtkConeSource;
42 class vtkLineSource;
43 class vtkSphereSource;
44 class vtkTubeFilter;
45 class vtkCylinder;
46 class vtkProperty;
47 class vtkImageData;
48 class vtkOutlineFilter;
49 class vtkFeatureEdges;
50 class vtkPolyData;
52 class vtkTransform;
53 class vtkBox;
54 class vtkLookupTable;
55 
56 #define VTK_MAX_CYL_RESOLUTION 2048
57 
58 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitCylinderRepresentation
60 {
61 public:
66 
68 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
76 
80  void SetCenter(double x, double y, double z);
81  void SetCenter(double x[3]);
82  double* GetCenter() VTK_SIZEHINT(3);
83  void GetCenter(double xyz[3]);
85 
87 
91  void SetAxis(double x, double y, double z);
92  void SetAxis(double a[3]);
93  double* GetAxis() VTK_SIZEHINT(3);
94  void GetAxis(double a[3]);
96 
98 
102  void SetRadius(double r);
103  double GetRadius();
105 
107 
114  vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
115  vtkGetMacro(MinRadius, double);
116  vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
117  vtkGetMacro(MaxRadius, double);
119 
121 
128  void SetAlongXAxis(vtkTypeBool);
129  vtkGetMacro(AlongXAxis, vtkTypeBool);
130  vtkBooleanMacro(AlongXAxis, vtkTypeBool);
131  void SetAlongYAxis(vtkTypeBool);
132  vtkGetMacro(AlongYAxis, vtkTypeBool);
133  vtkBooleanMacro(AlongYAxis, vtkTypeBool);
134  void SetAlongZAxis(vtkTypeBool);
135  vtkGetMacro(AlongZAxis, vtkTypeBool);
136  vtkBooleanMacro(AlongZAxis, vtkTypeBool);
138 
140 
146  void SetDrawCylinder(vtkTypeBool drawCyl);
147  vtkGetMacro(DrawCylinder, vtkTypeBool);
148  vtkBooleanMacro(DrawCylinder, vtkTypeBool);
150 
152 
158  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
159  vtkGetMacro(Resolution, int);
161 
163 
168  vtkSetMacro(Tubing, vtkTypeBool);
169  vtkGetMacro(Tubing, vtkTypeBool);
170  vtkBooleanMacro(Tubing, vtkTypeBool);
172 
174 
177  vtkSetMacro(ScaleEnabled, vtkTypeBool);
178  vtkGetMacro(ScaleEnabled, vtkTypeBool);
179  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
181 
188  void GetCylinder(vtkCylinder* cyl);
189 
194  void GetPolyData(vtkPolyData* pd);
195 
200  void UpdatePlacement();
201 
203 
206  vtkGetObjectMacro(AxisProperty, vtkProperty);
207  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
209 
211 
215  vtkGetObjectMacro(CylinderProperty, vtkProperty);
216  vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
218 
220 
224  vtkGetObjectMacro(EdgesProperty, vtkProperty);
226 
228 
233  void SetInteractionColor(double, double, double);
234  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
235  void SetHandleColor(double, double, double);
236  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
237  void SetForegroundColor(double, double, double);
238  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
240 
242 
245  int ComputeInteractionState(int X, int Y, int modify = 0) override;
246  void PlaceWidget(double bounds[6]) override;
247  void BuildRepresentation() override;
248  void StartWidgetInteraction(double eventPos[2]) override;
249  void WidgetInteraction(double newEventPos[2]) override;
250  void EndWidgetInteraction(double newEventPos[2]) override;
252 
254 
257  double* GetBounds() override;
258  void GetActors(vtkPropCollection* pc) override;
259  void ReleaseGraphicsResources(vtkWindow*) override;
260  int RenderOpaqueGeometry(vtkViewport*) override;
264 
266 
271  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
272  vtkGetMacro(BumpDistance, double);
274 
282  void BumpCylinder(int dir, double factor);
283 
290  void PushCylinder(double distance);
291 
292  // Manage the state of the widget
294  {
295  Outside = 0,
302  TranslatingCenter
303  };
304 
306 
315  vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
317 
319 
323  virtual void SetRepresentationState(int);
324  vtkGetMacro(RepresentationState, int);
326 
327  /*
328  * Register internal Pickers within PickingManager
329  */
330  void RegisterPickers() override;
331 
332 protected:
335 
336  void TranslateRepresentation(const vtkVector3d& move) override;
337 
339 
340  // Keep track of event positions
341  double LastEventPosition[3];
342 
343  // Control the radius
344  double MinRadius;
345  double MaxRadius;
346 
347  // Controlling the push operation
348  double BumpDistance;
349 
350  // Controlling ivars
354 
355  // The actual cylinder which is being manipulated
357 
358  // The facet resolution for rendering purposes.
360 
361  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
362 
363  // The cut cylinder is produced with a vtkCutter
368  void HighlightCylinder(int highlight);
369 
370  // Optional tubes are represented by extracting boundary edges and tubing
375  vtkTypeBool Tubing; // control whether tubing is on
376 
377  // The + normal cone (i.e., in positive direction along normal)
381  void HighlightNormal(int highlight);
382 
383  // The + normal line
387 
388  // The - normal cone
392 
393  // The - normal line
397 
398  // The center positioning handle
402 
403  // Do the picking
406 
407  // Transform the normal (used for rotation)
409 
410  // Methods to manipulate the cylinder
411  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
412  void TranslateCylinder(double* p1, double* p2);
413  void TranslateCenter(double* p1, double* p2);
414  void TranslateCenterOnAxis(double* p1, double* p2);
415  void ScaleRadius(double* p1, double* p2);
416  void AdjustRadius(double X, double Y, double* p1, double* p2);
417  void Scale(double* p1, double* p2, double X, double Y);
418  void SizeHandles();
419 
420  // Properties used to control the appearance of selected objects and
421  // the manipulator in general.
427  void CreateDefaultProperties() override;
428 
429  // Intersect oriented infinite cylinder against bounding box
430  void BuildCylinder();
431 
432  // Support GetBounds() method
434 
435 private:
437  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
438 };
439 
440 VTK_ABI_NAMESPACE_END
441 #endif
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
virtual void PlaceWidget(double bounds[6])
The following is a suggested API for widget representations.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
virtual void CreateDefaultProperties()
Create and initialize properties with default values.
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual void StartWidgetInteraction(double eventPos[2])
defining the representation for a vtkImplicitCylinderWidget
map scalar values into colors via a lookup table
void SetForegroundColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
generate polygonal cone
Definition: vtkConeSource.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:200
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:75
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void SetInteractionColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void TranslateRepresentation(const vtkVector3d &)
Translate the representation, to be implemented in derived class.
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:53
map vtkPolyData to graphics primitives
Extends the vtkWidgetRepresentation to help positioning widget in space and how it should be displaye...
void SetHandleColor(double c[3])
Set the color of all the widgets handles (edges, axis, selected cylinder) and their color during inte...
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
#define VTK_MARSHALAUTO
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
implicit function for a cylinder
Definition: vtkCylinder.h:36
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:30
#define VTK_MAX_CYL_RESOLUTION