VTK
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 : public vtkWidgetRepresentation
66 {
67 public:
72 
74 
78  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
82 
86  void SetCenter(double x, double y, double z);
87  void SetCenter(double x[3]);
88  double* GetCenter() VTK_SIZEHINT(3);
89  void GetCenter(double xyz[3]);
91 
93 
97  void SetAxis(double x, double y, double z);
98  void SetAxis(double a[3]);
99  double* GetAxis() VTK_SIZEHINT(3);
100  void GetAxis(double a[3]);
102 
104 
108  void SetRadius(double r);
109  double GetRadius();
111 
113 
120  vtkSetClampMacro(MinRadius,double,0.001,0.25);
121  vtkGetMacro(MinRadius,double);
122  vtkSetClampMacro(MaxRadius,double,0.25,VTK_FLOAT_MAX);
123  vtkGetMacro(MaxRadius,double);
125 
127 
134  void SetAlongXAxis(vtkTypeBool);
135  vtkGetMacro(AlongXAxis,vtkTypeBool);
136  vtkBooleanMacro(AlongXAxis,vtkTypeBool);
137  void SetAlongYAxis(vtkTypeBool);
138  vtkGetMacro(AlongYAxis,vtkTypeBool);
139  vtkBooleanMacro(AlongYAxis,vtkTypeBool);
140  void SetAlongZAxis(vtkTypeBool);
141  vtkGetMacro(AlongZAxis,vtkTypeBool);
142  vtkBooleanMacro(AlongZAxis,vtkTypeBool);
144 
146 
152  void SetDrawCylinder(vtkTypeBool drawCyl);
153  vtkGetMacro(DrawCylinder,vtkTypeBool);
154  vtkBooleanMacro(DrawCylinder,vtkTypeBool);
156 
158 
164  vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
165  vtkGetMacro(Resolution,int);
167 
169 
174  vtkSetMacro(Tubing,vtkTypeBool);
175  vtkGetMacro(Tubing,vtkTypeBool);
176  vtkBooleanMacro(Tubing,vtkTypeBool);
178 
180 
184  vtkSetMacro(OutlineTranslation,vtkTypeBool);
185  vtkGetMacro(OutlineTranslation,vtkTypeBool);
186  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
188 
190 
194  vtkSetMacro(OutsideBounds,vtkTypeBool);
195  vtkGetMacro(OutsideBounds,vtkTypeBool);
196  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
198 
200 
206  vtkSetVector6Macro(WidgetBounds, double);
207  vtkGetVector6Macro(WidgetBounds, double);
209 
211 
219  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
220  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
221  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
223 
225 
228  vtkSetMacro(ScaleEnabled, vtkTypeBool);
229  vtkGetMacro(ScaleEnabled, vtkTypeBool);
230  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
232 
239  void GetCylinder(vtkCylinder *cyl);
240 
245  void GetPolyData(vtkPolyData *pd);
246 
251  void UpdatePlacement(void);
252 
254 
257  vtkGetObjectMacro(AxisProperty,vtkProperty);
258  vtkGetObjectMacro(SelectedAxisProperty,vtkProperty);
260 
262 
266  vtkGetObjectMacro(CylinderProperty,vtkProperty);
267  vtkGetObjectMacro(SelectedCylinderProperty,vtkProperty);
269 
271 
274  vtkGetObjectMacro(OutlineProperty,vtkProperty);
275  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
277 
279 
283  vtkGetObjectMacro(EdgesProperty,vtkProperty);
285 
286 
289  void SetEdgeColor(vtkLookupTable*);
290  void SetEdgeColor(double, double, double);
291  void SetEdgeColor(double x[3]);
293 
295 
298  int ComputeInteractionState(int X, int Y, int modify=0) override;
299  void PlaceWidget(double bounds[6]) override;
300  void BuildRepresentation() override;
301  void StartWidgetInteraction(double eventPos[2]) override;
302  void WidgetInteraction(double newEventPos[2]) override;
303  void EndWidgetInteraction(double newEventPos[2]) override;
305 
307 
310  double *GetBounds() override;
311  void GetActors(vtkPropCollection *pc) override;
312  void ReleaseGraphicsResources(vtkWindow*) override;
313  int RenderOpaqueGeometry(vtkViewport*) override;
314  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
315  int HasTranslucentPolygonalGeometry() override;
317 
319 
324  vtkSetClampMacro(BumpDistance,double,0.000001,1);
325  vtkGetMacro(BumpDistance,double);
327 
335  void BumpCylinder(int dir, double factor);
336 
343  void PushCylinder(double distance);
344 
345  // Manage the state of the widget
347  {
348  Outside=0,
355  TranslatingCenter
356  };
357 
359 
368  vtkSetClampMacro(InteractionState,int,Outside,TranslatingCenter);
370 
372 
376  virtual void SetRepresentationState(int);
377  vtkGetMacro(RepresentationState, int);
379 
380  /*
381  * Register internal Pickers within PickingManager
382  */
383  void RegisterPickers() override;
384 
385 protected:
388 
390 
391  // Keep track of event positions
392  double LastEventPosition[3];
393 
394  // Control the radius
395  double MinRadius;
396  double MaxRadius;
397 
398  // Controlling the push operation
399  double BumpDistance;
400 
401  // Controlling ivars
405 
406  // The actual cylinder which is being manipulated
408 
409  // The facet resolution for rendering purposes.
411 
412  // The bounding box is represented by a single voxel image data
417  void HighlightOutline(int highlight);
418  vtkTypeBool OutlineTranslation; //whether the outline can be moved
419  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
420  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
421  double WidgetBounds[6];
423 
424  // The cut cylinder is produced with a vtkCutter
429  void HighlightCylinder(int highlight);
430 
431  // Optional tubes are represented by extracting boundary edges and tubing
436  vtkTypeBool Tubing; //control whether tubing is on
437 
438  // The + normal cone (i.e., in positive direction along normal)
442  void HighlightNormal(int highlight);
443 
444  // The + normal line
448 
449  // The - normal cone
453 
454  // The - normal line
458 
459  // The center positioning handle
463 
464  // Do the picking
467 
468  // Transform the normal (used for rotation)
470 
471  // Methods to manipulate the cylinder
472  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
473  void TranslateCylinder(double *p1, double *p2);
474  void TranslateOutline(double *p1, double *p2);
475  void TranslateCenter(double *p1, double *p2);
476  void TranslateCenterOnAxis(double *p1, double *p2);
477  void ScaleRadius(double *p1, double *p2);
478  void AdjustRadius(double X, double Y, double *p1, double *p2);
479  void Scale(double *p1, double *p2, double X, double Y);
480  void SizeHandles();
481 
482  // Properties used to control the appearance of selected objects and
483  // the manipulator in general.
491  void CreateDefaultProperties();
492 
493  // Intersect oriented infinite cylinder against bounding box
494  void BuildCylinder();
495 
496  // Support GetBounds() method
498 
499 private:
501  void operator=(const vtkImplicitCylinderRepresentation&) = delete;
502 };
503 
504 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkImplicitCylinderRepresentation::Resolution
int Resolution
Definition: vtkImplicitCylinderRepresentation.h:410
vtkWidgetRepresentation.h
vtkImplicitCylinderRepresentation::ConeActor
vtkActor * ConeActor
Definition: vtkImplicitCylinderRepresentation.h:441
vtkImplicitCylinderRepresentation::Edges
vtkFeatureEdges * Edges
Definition: vtkImplicitCylinderRepresentation.h:432
vtkImplicitCylinderRepresentation::MovingOutline
Definition: vtkImplicitCylinderRepresentation.h:350
vtkImplicitCylinderRepresentation::MovingCenter
Definition: vtkImplicitCylinderRepresentation.h:351
vtkImplicitCylinderRepresentation
defining the representation for a vtkImplicitCylinderWidget
Definition: vtkImplicitCylinderRepresentation.h:65
vtkImplicitCylinderRepresentation::SelectedCylinderProperty
vtkProperty * SelectedCylinderProperty
Definition: vtkImplicitCylinderRepresentation.h:487
vtkImplicitCylinderRepresentation::EdgesTuber
vtkTubeFilter * EdgesTuber
Definition: vtkImplicitCylinderRepresentation.h:433
vtkImplicitCylinderRepresentation::ConstrainToWidgetBounds
int ConstrainToWidgetBounds
Definition: vtkImplicitCylinderRepresentation.h:422
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:415
vtkImplicitCylinderRepresentation::Outline
vtkOutlineFilter * Outline
Definition: vtkImplicitCylinderRepresentation.h:414
vtkImplicitCylinderRepresentation::Moving
Definition: vtkImplicitCylinderRepresentation.h:349
vtkImplicitCylinderRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkImplicitCylinderRepresentation.h:461
vtkImplicitCylinderRepresentation::EdgesMapper
vtkPolyDataMapper * EdgesMapper
Definition: vtkImplicitCylinderRepresentation.h:434
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkImplicitCylinderRepresentation::AlongZAxis
vtkTypeBool AlongZAxis
Definition: vtkImplicitCylinderRepresentation.h:404
vtkImplicitCylinderRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkImplicitCylinderRepresentation.h:497
vtkImplicitCylinderRepresentation::LineSource2
vtkLineSource * LineSource2
Definition: vtkImplicitCylinderRepresentation.h:455
vtkX3D::dir
Definition: vtkX3D.h:324
vtkImplicitCylinderRepresentation::EdgesActor
vtkActor * EdgesActor
Definition: vtkImplicitCylinderRepresentation.h:435
vtkImplicitCylinderRepresentation::CylinderProperty
vtkProperty * CylinderProperty
Definition: vtkImplicitCylinderRepresentation.h:486
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkImplicitCylinderRepresentation::LineMapper2
vtkPolyDataMapper * LineMapper2
Definition: vtkImplicitCylinderRepresentation.h:456
vtkImplicitCylinderRepresentation::DrawCylinder
vtkTypeBool DrawCylinder
Definition: vtkImplicitCylinderRepresentation.h:428
vtkImplicitCylinderRepresentation::Cylinder
vtkCylinder * Cylinder
Definition: vtkImplicitCylinderRepresentation.h:407
vtkCylinder
implicit function for a cylinder
Definition: vtkCylinder.h:41
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkImplicitCylinderRepresentation::Transform
vtkTransform * Transform
Definition: vtkImplicitCylinderRepresentation.h:469
vtkTubeFilter
filter that generates tubes around lines
Definition: vtkTubeFilter.h:77
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkImplicitCylinderRepresentation::OutlineTranslation
vtkTypeBool OutlineTranslation
Definition: vtkImplicitCylinderRepresentation.h:418
vtkImplicitCylinderRepresentation::LineSource
vtkLineSource * LineSource
Definition: vtkImplicitCylinderRepresentation.h:445
vtkImplicitCylinderRepresentation::RepresentationState
int RepresentationState
Definition: vtkImplicitCylinderRepresentation.h:389
vtkImplicitCylinderRepresentation::OutsideBounds
vtkTypeBool OutsideBounds
Definition: vtkImplicitCylinderRepresentation.h:420
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkImplicitCylinderRepresentation::AxisProperty
vtkProperty * AxisProperty
Definition: vtkImplicitCylinderRepresentation.h:484
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:39
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:439
vtkImplicitCylinderRepresentation::MinRadius
double MinRadius
Definition: vtkImplicitCylinderRepresentation.h:395
vtkFeatureEdges
extract boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:46
vtkImplicitCylinderRepresentation::ConeSource2
vtkConeSource * ConeSource2
Definition: vtkImplicitCylinderRepresentation.h:450
vtkImplicitCylinderRepresentation::_InteractionState
_InteractionState
Definition: vtkImplicitCylinderRepresentation.h:346
vtkImplicitCylinderRepresentation::ScaleEnabled
vtkTypeBool ScaleEnabled
Definition: vtkImplicitCylinderRepresentation.h:419
vtkImplicitCylinderRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkImplicitCylinderRepresentation.h:462
vtkImplicitCylinderRepresentation::ConeActor2
vtkActor * ConeActor2
Definition: vtkImplicitCylinderRepresentation.h:452
vtkImplicitCylinderRepresentation::Cyl
vtkPolyData * Cyl
Definition: vtkImplicitCylinderRepresentation.h:425
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
vtkImplicitCylinderRepresentation::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkImplicitCylinderRepresentation.h:489
vtkImplicitCylinderRepresentation::EdgesProperty
vtkProperty * EdgesProperty
Definition: vtkImplicitCylinderRepresentation.h:490
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkImplicitCylinderRepresentation::BumpDistance
double BumpDistance
Definition: vtkImplicitCylinderRepresentation.h:399
vtkImplicitCylinderRepresentation::ConeMapper2
vtkPolyDataMapper * ConeMapper2
Definition: vtkImplicitCylinderRepresentation.h:451
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkImplicitCylinderRepresentation::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkImplicitCylinderRepresentation.h:446
vtkImplicitCylinderRepresentation::CylPicker
vtkCellPicker * CylPicker
Definition: vtkImplicitCylinderRepresentation.h:466
vtkImplicitCylinderRepresentation::Picker
vtkCellPicker * Picker
Definition: vtkImplicitCylinderRepresentation.h:465
vtkImplicitCylinderRepresentation::SelectedAxisProperty
vtkProperty * SelectedAxisProperty
Definition: vtkImplicitCylinderRepresentation.h:485
vtkImplicitCylinderRepresentation::AdjustingRadius
Definition: vtkImplicitCylinderRepresentation.h:353
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:68
vtkImplicitCylinderRepresentation::AlongXAxis
vtkTypeBool AlongXAxis
Definition: vtkImplicitCylinderRepresentation.h:402
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:38
vtkImplicitCylinderRepresentation::AlongYAxis
vtkTypeBool AlongYAxis
Definition: vtkImplicitCylinderRepresentation.h:403
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkOutlineFilter
create wireframe outline for arbitrary data set
Definition: vtkOutlineFilter.h:32
vtkImplicitCylinderRepresentation::CylActor
vtkActor * CylActor
Definition: vtkImplicitCylinderRepresentation.h:427
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
VTK_MAX_CYL_RESOLUTION
#define VTK_MAX_CYL_RESOLUTION
Definition: vtkImplicitCylinderRepresentation.h:63
vtkImplicitCylinderRepresentation::Box
vtkImageData * Box
Definition: vtkImplicitCylinderRepresentation.h:413
vtkImplicitCylinderRepresentation::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkImplicitCylinderRepresentation.h:488
vtkImplicitCylinderRepresentation::ConeMapper
vtkPolyDataMapper * ConeMapper
Definition: vtkImplicitCylinderRepresentation.h:440
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkImplicitCylinderRepresentation::Sphere
vtkSphereSource * Sphere
Definition: vtkImplicitCylinderRepresentation.h:460
vtkImplicitCylinderRepresentation::LineActor2
vtkActor * LineActor2
Definition: vtkImplicitCylinderRepresentation.h:457
vtkImplicitCylinderRepresentation::Tubing
vtkTypeBool Tubing
Definition: vtkImplicitCylinderRepresentation.h:436
vtkImplicitCylinderRepresentation::CylMapper
vtkPolyDataMapper * CylMapper
Definition: vtkImplicitCylinderRepresentation.h:426
vtkImplicitCylinderRepresentation::LineActor
vtkActor * LineActor
Definition: vtkImplicitCylinderRepresentation.h:447
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImplicitCylinderRepresentation::OutlineActor
vtkActor * OutlineActor
Definition: vtkImplicitCylinderRepresentation.h:416
vtkImplicitCylinderRepresentation::RotatingAxis
Definition: vtkImplicitCylinderRepresentation.h:352
vtkImplicitCylinderRepresentation::Scaling
Definition: vtkImplicitCylinderRepresentation.h:354
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:396
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41