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) VTK_OVERRIDE;
80 
82 
86  void SetCenter(double x, double y, double z);
87  void SetCenter(double x[3]);
88  double* GetCenter();
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();
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(int);
135  vtkGetMacro(AlongXAxis,int);
136  vtkBooleanMacro(AlongXAxis,int);
137  void SetAlongYAxis(int);
138  vtkGetMacro(AlongYAxis,int);
139  vtkBooleanMacro(AlongYAxis,int);
140  void SetAlongZAxis(int);
141  vtkGetMacro(AlongZAxis,int);
142  vtkBooleanMacro(AlongZAxis,int);
144 
146 
152  void SetDrawCylinder(int drawCyl);
153  vtkGetMacro(DrawCylinder,int);
154  vtkBooleanMacro(DrawCylinder,int);
156 
158 
164  vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
165  vtkGetMacro(Resolution,int);
167 
169 
174  vtkSetMacro(Tubing,int);
175  vtkGetMacro(Tubing,int);
176  vtkBooleanMacro(Tubing,int);
178 
180 
184  vtkSetMacro(OutlineTranslation,int);
185  vtkGetMacro(OutlineTranslation,int);
186  vtkBooleanMacro(OutlineTranslation,int);
188 
190 
194  vtkSetMacro(OutsideBounds,int);
195  vtkGetMacro(OutsideBounds,int);
196  vtkBooleanMacro(OutsideBounds,int);
198 
200 
206  vtkSetVector6Macro(WidgetBounds, double);
207  vtkGetVector6Macro(WidgetBounds, double);
209 
211 
219  vtkSetMacro(ConstrainToWidgetBounds, int);
220  vtkGetMacro(ConstrainToWidgetBounds, int);
221  vtkBooleanMacro(ConstrainToWidgetBounds, int);
223 
225 
228  vtkSetMacro(ScaleEnabled,int);
229  vtkGetMacro(ScaleEnabled,int);
230  vtkBooleanMacro(ScaleEnabled,int);
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) VTK_OVERRIDE;
299  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
300  void BuildRepresentation() VTK_OVERRIDE;
301  void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
302  void WidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
303  void EndWidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
305 
307 
310  double *GetBounds() VTK_OVERRIDE;
311  void GetActors(vtkPropCollection *pc) VTK_OVERRIDE;
312  void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
313  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
314  int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE;
315  int HasTranslucentPolygonalGeometry() VTK_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 protected:
382  ~vtkImplicitCylinderRepresentation() VTK_OVERRIDE;
383 
384  int RepresentationState;
385 
386  // Keep track of event positions
387  double LastEventPosition[3];
388 
389  // Control the radius
390  double MinRadius;
391  double MaxRadius;
392 
393  // Controlling the push operation
394  double BumpDistance;
395 
396  // Controlling ivars
397  int AlongXAxis;
398  int AlongYAxis;
399  int AlongZAxis;
400 
401  // The actual cylinder which is being manipulated
403 
404  // The facet resolution for rendering purposes.
405  int Resolution;
406 
407  // The bounding box is represented by a single voxel image data
410  vtkPolyDataMapper *OutlineMapper;
411  vtkActor *OutlineActor;
412  void HighlightOutline(int highlight);
413  int OutlineTranslation; //whether the outline can be moved
414  int ScaleEnabled; //whether the widget can be scaled
415  int OutsideBounds; //whether the widget can be moved outside input's bounds
416  double WidgetBounds[6];
417  int ConstrainToWidgetBounds;
418 
419  // The cut cylinder is produced with a vtkCutter
421  vtkPolyDataMapper *CylMapper;
422  vtkActor *CylActor;
423  int DrawCylinder;
424  void HighlightCylinder(int highlight);
425 
426  // Optional tubes are represented by extracting boundary edges and tubing
428  vtkTubeFilter *EdgesTuber;
429  vtkPolyDataMapper *EdgesMapper;
430  vtkActor *EdgesActor;
431  int Tubing; //control whether tubing is on
432 
433  // The + normal cone (i.e., in positive direction along normal)
434  vtkConeSource *ConeSource;
435  vtkPolyDataMapper *ConeMapper;
436  vtkActor *ConeActor;
437  void HighlightNormal(int highlight);
438 
439  // The + normal line
440  vtkLineSource *LineSource;
441  vtkPolyDataMapper *LineMapper;
442  vtkActor *LineActor;
443 
444  // The - normal cone
445  vtkConeSource *ConeSource2;
446  vtkPolyDataMapper *ConeMapper2;
447  vtkActor *ConeActor2;
448 
449  // The - normal line
450  vtkLineSource *LineSource2;
451  vtkPolyDataMapper *LineMapper2;
452  vtkActor *LineActor2;
453 
454  // The center positioning handle
456  vtkPolyDataMapper *SphereMapper;
457  vtkActor *SphereActor;
458 
459  // Do the picking
460  vtkCellPicker *Picker;
461  vtkCellPicker *CylPicker;
462 
463  // Register internal Pickers within PickingManager
464  void RegisterPickers() VTK_OVERRIDE;
465 
466  // Transform the normal (used for rotation)
468 
469  // Methods to manipulate the cylinder
470  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
471  void TranslateCylinder(double *p1, double *p2);
472  void TranslateOutline(double *p1, double *p2);
473  void TranslateCenter(double *p1, double *p2);
474  void TranslateCenterOnAxis(double *p1, double *p2);
475  void ScaleRadius(double *p1, double *p2);
476  void AdjustRadius(double X, double Y, double *p1, double *p2);
477  void Scale(double *p1, double *p2, double X, double Y);
478  void SizeHandles();
479 
480  // Properties used to control the appearance of selected objects and
481  // the manipulator in general.
482  vtkProperty *AxisProperty;
483  vtkProperty *SelectedAxisProperty;
484  vtkProperty *CylinderProperty;
485  vtkProperty *SelectedCylinderProperty;
486  vtkProperty *OutlineProperty;
487  vtkProperty *SelectedOutlineProperty;
488  vtkProperty *EdgesProperty;
489  void CreateDefaultProperties();
490 
491  // Intersect oriented infinite cylinder against bounding box
492  void BuildCylinder();
493 
494  // Support GetBounds() method
495  vtkBox *BoundingBox;
496 
497 private:
499  void operator=(const vtkImplicitCylinderRepresentation&) VTK_DELETE_FUNCTION;
500 };
501 
502 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:58
defining the representation for a vtkImplicitCylinderWidget
map scalar values into colors via a lookup table
generate polygonal cone
Definition: vtkConeSource.h:38
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
abstract class defines interface between the widget and widget representation classes ...
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:77
a simple class to control print indentation
Definition: vtkIndent.h:33
extract boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create a line defined by two end points
Definition: vtkLineSource.h:36
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
implicit function for a cylinder
Definition: vtkCylinder.h:41
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:38
#define VTK_MAX_CYL_RESOLUTION
Transform
Definition: ADIOSDefs.h:39