VTK  9.0.20201023
vtkImplicitCylinderRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitCylinderRepresentation.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 =========================================================================*/
39 #ifndef vtkImplicitCylinderRepresentation_h
40 #define vtkImplicitCylinderRepresentation_h
41 
42 #include "vtkInteractionWidgetsModule.h" // For export macro
44 
45 class vtkActor;
46 class vtkPolyDataMapper;
47 class vtkCellPicker;
48 class vtkConeSource;
49 class vtkLineSource;
50 class vtkSphereSource;
51 class vtkTubeFilter;
52 class vtkCylinder;
53 class vtkProperty;
54 class vtkImageData;
55 class vtkOutlineFilter;
56 class vtkFeatureEdges;
57 class vtkPolyData;
59 class vtkTransform;
60 class vtkBox;
61 class vtkLookupTable;
62 
63 #define VTK_MAX_CYL_RESOLUTION 2048
64 
65 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation
67 {
68 public:
73 
75 
79  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
83 
87  void SetCenter(double x, double y, double z);
88  void SetCenter(double x[3]);
89  double* GetCenter() VTK_SIZEHINT(3);
90  void GetCenter(double xyz[3]);
92 
94 
98  void SetAxis(double x, double y, double z);
99  void SetAxis(double a[3]);
100  double* GetAxis() VTK_SIZEHINT(3);
101  void GetAxis(double a[3]);
103 
105 
109  void SetRadius(double r);
110  double GetRadius();
112 
114 
121  vtkSetClampMacro(MinRadius, double, 0.001, 0.25);
122  vtkGetMacro(MinRadius, double);
123  vtkSetClampMacro(MaxRadius, double, 0.25, VTK_FLOAT_MAX);
124  vtkGetMacro(MaxRadius, double);
126 
128 
135  void SetAlongXAxis(vtkTypeBool);
136  vtkGetMacro(AlongXAxis, vtkTypeBool);
137  vtkBooleanMacro(AlongXAxis, vtkTypeBool);
138  void SetAlongYAxis(vtkTypeBool);
139  vtkGetMacro(AlongYAxis, vtkTypeBool);
140  vtkBooleanMacro(AlongYAxis, vtkTypeBool);
141  void SetAlongZAxis(vtkTypeBool);
142  vtkGetMacro(AlongZAxis, vtkTypeBool);
143  vtkBooleanMacro(AlongZAxis, vtkTypeBool);
145 
147 
153  void SetDrawCylinder(vtkTypeBool drawCyl);
154  vtkGetMacro(DrawCylinder, vtkTypeBool);
155  vtkBooleanMacro(DrawCylinder, vtkTypeBool);
157 
159 
165  vtkSetClampMacro(Resolution, int, 8, VTK_MAX_CYL_RESOLUTION);
166  vtkGetMacro(Resolution, int);
168 
170 
175  vtkSetMacro(Tubing, vtkTypeBool);
176  vtkGetMacro(Tubing, vtkTypeBool);
177  vtkBooleanMacro(Tubing, vtkTypeBool);
179 
181 
185  vtkSetMacro(OutlineTranslation, vtkTypeBool);
186  vtkGetMacro(OutlineTranslation, vtkTypeBool);
187  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
189 
191 
195  vtkSetMacro(OutsideBounds, vtkTypeBool);
196  vtkGetMacro(OutsideBounds, vtkTypeBool);
197  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
199 
201 
207  vtkSetVector6Macro(WidgetBounds, double);
208  vtkGetVector6Macro(WidgetBounds, double);
210 
212 
220  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
221  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
222  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
224 
226 
229  vtkSetMacro(ScaleEnabled, vtkTypeBool);
230  vtkGetMacro(ScaleEnabled, vtkTypeBool);
231  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
233 
240  void GetCylinder(vtkCylinder* cyl);
241 
246  void GetPolyData(vtkPolyData* pd);
247 
252  void UpdatePlacement(void);
253 
255 
258  vtkGetObjectMacro(AxisProperty, vtkProperty);
259  vtkGetObjectMacro(SelectedAxisProperty, vtkProperty);
261 
263 
267  vtkGetObjectMacro(CylinderProperty, vtkProperty);
268  vtkGetObjectMacro(SelectedCylinderProperty, vtkProperty);
270 
272 
275  vtkGetObjectMacro(OutlineProperty, vtkProperty);
276  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
278 
280 
284  vtkGetObjectMacro(EdgesProperty, vtkProperty);
286 
287 
290  void SetEdgeColor(vtkLookupTable*);
291  void SetEdgeColor(double, double, double);
292  void SetEdgeColor(double c[3]);
294 
296 
299  int ComputeInteractionState(int X, int Y, int modify = 0) override;
300  void PlaceWidget(double bounds[6]) override;
301  void BuildRepresentation() override;
302  void StartWidgetInteraction(double eventPos[2]) override;
303  void WidgetInteraction(double newEventPos[2]) override;
304  void EndWidgetInteraction(double newEventPos[2]) override;
306 
308 
311  double* GetBounds() override;
312  void GetActors(vtkPropCollection* pc) override;
313  void ReleaseGraphicsResources(vtkWindow*) override;
314  int RenderOpaqueGeometry(vtkViewport*) override;
315  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
316  vtkTypeBool HasTranslucentPolygonalGeometry() override;
318 
320 
325  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
326  vtkGetMacro(BumpDistance, double);
328 
336  void BumpCylinder(int dir, double factor);
337 
344  void PushCylinder(double distance);
345 
346  // Manage the state of the widget
348  {
349  Outside = 0,
356  TranslatingCenter
357  };
358 
360 
369  vtkSetClampMacro(InteractionState, int, Outside, TranslatingCenter);
371 
373 
377  virtual void SetRepresentationState(int);
378  vtkGetMacro(RepresentationState, int);
380 
381  /*
382  * Register internal Pickers within PickingManager
383  */
384  void RegisterPickers() override;
385 
387 
391  vtkGetMacro(TranslationAxis, int);
392  vtkSetClampMacro(TranslationAxis, int, -1, 2);
394 
396 
399  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
400  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
401  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
402  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
404 
406 
409  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
411 
412 protected:
415 
417 
419 
420  // Keep track of event positions
421  double LastEventPosition[3];
422 
423  // Control the radius
424  double MinRadius;
425  double MaxRadius;
426 
427  // Controlling the push operation
428  double BumpDistance;
429 
430  // Controlling ivars
434 
435  // The actual cylinder which is being manipulated
437 
438  // The facet resolution for rendering purposes.
440 
441  // The bounding box is represented by a single voxel image data
446  void HighlightOutline(int highlight);
447  vtkTypeBool OutlineTranslation; // whether the outline can be moved
448  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
449  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
450  double WidgetBounds[6];
452 
453  // The cut cylinder is produced with a vtkCutter
458  void HighlightCylinder(int highlight);
459 
460  // Optional tubes are represented by extracting boundary edges and tubing
465  vtkTypeBool Tubing; // control whether tubing is on
466 
467  // The + normal cone (i.e., in positive direction along normal)
471  void HighlightNormal(int highlight);
472 
473  // The + normal line
477 
478  // The - normal cone
482 
483  // The - normal line
487 
488  // The center positioning handle
492 
493  // Do the picking
496 
497  // Transform the normal (used for rotation)
499 
500  // Methods to manipulate the cylinder
501  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
502  void TranslateCylinder(double* p1, double* p2);
503  void TranslateOutline(double* p1, double* p2);
504  void TranslateCenter(double* p1, double* p2);
505  void TranslateCenterOnAxis(double* p1, double* p2);
506  void ScaleRadius(double* p1, double* p2);
507  void AdjustRadius(double X, double Y, double* p1, double* p2);
508  void Scale(double* p1, double* p2, double X, double Y);
509  void SizeHandles();
510 
511  // Properties used to control the appearance of selected objects and
512  // the manipulator in general.
520  void CreateDefaultProperties();
521 
522  // Intersect oriented infinite cylinder against bounding box
523  void BuildCylinder();
524 
525  // Support GetBounds() method
527 
528 private:
530  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
531 };
532 
533 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkImplicitCylinderRepresentation::Resolution
int Resolution
Definition: vtkImplicitCylinderRepresentation.h:439
vtkWidgetRepresentation.h
vtkImplicitCylinderRepresentation::ConeActor
vtkActor * ConeActor
Definition: vtkImplicitCylinderRepresentation.h:470
vtkImplicitCylinderRepresentation::Edges
vtkFeatureEdges * Edges
Definition: vtkImplicitCylinderRepresentation.h:461
vtkImplicitCylinderRepresentation::MovingOutline
Definition: vtkImplicitCylinderRepresentation.h:351
vtkImplicitCylinderRepresentation::MovingCenter
Definition: vtkImplicitCylinderRepresentation.h:352
vtkImplicitCylinderRepresentation
defining the representation for a vtkImplicitCylinderWidget
Definition: vtkImplicitCylinderRepresentation.h:65
vtkImplicitCylinderRepresentation::SelectedCylinderProperty
vtkProperty * SelectedCylinderProperty
Definition: vtkImplicitCylinderRepresentation.h:516
vtkImplicitCylinderRepresentation::EdgesTuber
vtkTubeFilter * EdgesTuber
Definition: vtkImplicitCylinderRepresentation.h:462
vtkImplicitCylinderRepresentation::ConstrainToWidgetBounds
int ConstrainToWidgetBounds
Definition: vtkImplicitCylinderRepresentation.h:451
vtkImplicitCylinderRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Definition: vtkImplicitCylinderRepresentation.h:400
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkImplicitCylinderRepresentation::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkImplicitCylinderRepresentation.h:444
vtkImplicitCylinderRepresentation::Outline
vtkOutlineFilter * Outline
Definition: vtkImplicitCylinderRepresentation.h:443
vtkImplicitCylinderRepresentation::Moving
Definition: vtkImplicitCylinderRepresentation.h:350
vtkImplicitCylinderRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkImplicitCylinderRepresentation.h:490
vtkImplicitCylinderRepresentation::EdgesMapper
vtkPolyDataMapper * EdgesMapper
Definition: vtkImplicitCylinderRepresentation.h:463
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkImplicitCylinderRepresentation::AlongZAxis
vtkTypeBool AlongZAxis
Definition: vtkImplicitCylinderRepresentation.h:433
vtkImplicitCylinderRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkImplicitCylinderRepresentation.h:526
vtkImplicitCylinderRepresentation::LineSource2
vtkLineSource * LineSource2
Definition: vtkImplicitCylinderRepresentation.h:484
vtkX3D::dir
Definition: vtkX3D.h:330
vtkImplicitCylinderRepresentation::EdgesActor
vtkActor * EdgesActor
Definition: vtkImplicitCylinderRepresentation.h:464
vtkImplicitCylinderRepresentation::CylinderProperty
vtkProperty * CylinderProperty
Definition: vtkImplicitCylinderRepresentation.h:515
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkImplicitCylinderRepresentation::LineMapper2
vtkPolyDataMapper * LineMapper2
Definition: vtkImplicitCylinderRepresentation.h:485
vtkImplicitCylinderRepresentation::DrawCylinder
vtkTypeBool DrawCylinder
Definition: vtkImplicitCylinderRepresentation.h:457
vtkImplicitCylinderRepresentation::Cylinder
vtkCylinder * Cylinder
Definition: vtkImplicitCylinderRepresentation.h:436
vtkImplicitCylinderRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkImplicitCylinderRepresentation.h:409
vtkCylinder
implicit function for a cylinder
Definition: vtkCylinder.h:41
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkImplicitCylinderRepresentation::Transform
vtkTransform * Transform
Definition: vtkImplicitCylinderRepresentation.h:498
vtkTubeFilter
filter that generates tubes around lines
Definition: vtkTubeFilter.h:79
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkImplicitCylinderRepresentation::OutlineTranslation
vtkTypeBool OutlineTranslation
Definition: vtkImplicitCylinderRepresentation.h:447
vtkImplicitCylinderRepresentation::LineSource
vtkLineSource * LineSource
Definition: vtkImplicitCylinderRepresentation.h:474
vtkImplicitCylinderRepresentation::RepresentationState
int RepresentationState
Definition: vtkImplicitCylinderRepresentation.h:416
vtkImplicitCylinderRepresentation::OutsideBounds
vtkTypeBool OutsideBounds
Definition: vtkImplicitCylinderRepresentation.h:449
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:41
vtkImplicitCylinderRepresentation::AxisProperty
vtkProperty * AxisProperty
Definition: vtkImplicitCylinderRepresentation.h:513
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
vtkImplicitCylinderRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Definition: vtkImplicitCylinderRepresentation.h:401
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkImplicitCylinderRepresentation::ConeSource
vtkConeSource * ConeSource
Definition: vtkImplicitCylinderRepresentation.h:468
vtkImplicitCylinderRepresentation::MinRadius
double MinRadius
Definition: vtkImplicitCylinderRepresentation.h:424
vtkFeatureEdges
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:47
vtkImplicitCylinderRepresentation::ConeSource2
vtkConeSource * ConeSource2
Definition: vtkImplicitCylinderRepresentation.h:479
vtkImplicitCylinderRepresentation::_InteractionState
_InteractionState
Definition: vtkImplicitCylinderRepresentation.h:347
vtkImplicitCylinderRepresentation::ScaleEnabled
vtkTypeBool ScaleEnabled
Definition: vtkImplicitCylinderRepresentation.h:448
vtkImplicitCylinderRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkImplicitCylinderRepresentation.h:491
vtkImplicitCylinderRepresentation::ConeActor2
vtkActor * ConeActor2
Definition: vtkImplicitCylinderRepresentation.h:481
vtkImplicitCylinderRepresentation::Cyl
vtkPolyData * Cyl
Definition: vtkImplicitCylinderRepresentation.h:454
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:155
vtkImplicitCylinderRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkImplicitCylinderRepresentation.h:518
vtkImplicitCylinderRepresentation::EdgesProperty
vtkProperty * EdgesProperty
Definition: vtkImplicitCylinderRepresentation.h:519
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:60
vtkImplicitCylinderRepresentation::BumpDistance
double BumpDistance
Definition: vtkImplicitCylinderRepresentation.h:428
vtkImplicitCylinderRepresentation::ConeMapper2
vtkPolyDataMapper * ConeMapper2
Definition: vtkImplicitCylinderRepresentation.h:480
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkImplicitCylinderRepresentation::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkImplicitCylinderRepresentation.h:475
vtkImplicitCylinderRepresentation::CylPicker
vtkCellPicker * CylPicker
Definition: vtkImplicitCylinderRepresentation.h:495
vtkImplicitCylinderRepresentation::Picker
vtkCellPicker * Picker
Definition: vtkImplicitCylinderRepresentation.h:494
vtkImplicitCylinderRepresentation::SelectedAxisProperty
vtkProperty * SelectedAxisProperty
Definition: vtkImplicitCylinderRepresentation.h:514
vtkImplicitCylinderRepresentation::AdjustingRadius
Definition: vtkImplicitCylinderRepresentation.h:354
vtkImplicitCylinderRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkImplicitCylinderRepresentation.h:399
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:68
vtkImplicitCylinderRepresentation::AlongXAxis
vtkTypeBool AlongXAxis
Definition: vtkImplicitCylinderRepresentation.h:431
vtkImplicitCylinderRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Definition: vtkImplicitCylinderRepresentation.h:402
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:38
vtkImplicitCylinderRepresentation::AlongYAxis
vtkTypeBool AlongYAxis
Definition: vtkImplicitCylinderRepresentation.h:432
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkOutlineFilter
create wireframe outline for an arbitrary data set or composite dataset
Definition: vtkOutlineFilter.h:41
vtkImplicitCylinderRepresentation::CylActor
vtkActor * CylActor
Definition: vtkImplicitCylinderRepresentation.h:456
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkImplicitCylinderRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkImplicitCylinderRepresentation.h:418
VTK_MAX_CYL_RESOLUTION
#define VTK_MAX_CYL_RESOLUTION
Definition: vtkImplicitCylinderRepresentation.h:63
vtkImplicitCylinderRepresentation::Box
vtkImageData * Box
Definition: vtkImplicitCylinderRepresentation.h:442
vtkImplicitCylinderRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkImplicitCylinderRepresentation.h:517
vtkImplicitCylinderRepresentation::ConeMapper
vtkPolyDataMapper * ConeMapper
Definition: vtkImplicitCylinderRepresentation.h:469
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkImplicitCylinderRepresentation::Sphere
vtkSphereSource * Sphere
Definition: vtkImplicitCylinderRepresentation.h:489
vtkImplicitCylinderRepresentation::LineActor2
vtkActor * LineActor2
Definition: vtkImplicitCylinderRepresentation.h:486
vtkImplicitCylinderRepresentation::Tubing
vtkTypeBool Tubing
Definition: vtkImplicitCylinderRepresentation.h:465
vtkImplicitCylinderRepresentation::CylMapper
vtkPolyDataMapper * CylMapper
Definition: vtkImplicitCylinderRepresentation.h:455
vtkImplicitCylinderRepresentation::LineActor
vtkActor * LineActor
Definition: vtkImplicitCylinderRepresentation.h:476
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImplicitCylinderRepresentation::OutlineActor
vtkActor * OutlineActor
Definition: vtkImplicitCylinderRepresentation.h:445
vtkImplicitCylinderRepresentation::RotatingAxis
Definition: vtkImplicitCylinderRepresentation.h:353
vtkImplicitCylinderRepresentation::Scaling
Definition: vtkImplicitCylinderRepresentation.h:355
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImplicitCylinderRepresentation::MaxRadius
double MaxRadius
Definition: vtkImplicitCylinderRepresentation.h:425
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41