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 =========================================================================*/
41 #ifndef vtkImplicitCylinderRepresentation_h
42 #define vtkImplicitCylinderRepresentation_h
43 
44 #include "vtkInteractionWidgetsModule.h" // For export macro
46 
47 class vtkActor;
48 class vtkPolyDataMapper;
49 class vtkCellPicker;
50 class vtkConeSource;
51 class vtkLineSource;
52 class vtkSphereSource;
53 class vtkTubeFilter;
54 class vtkCylinder;
55 class vtkProperty;
56 class vtkImageData;
57 class vtkOutlineFilter;
58 class vtkFeatureEdges;
59 class vtkPolyData;
61 class vtkTransform;
62 class vtkBox;
63 class vtkLookupTable;
64 
65 #define VTK_MAX_CYL_RESOLUTION 2048
66 
68 {
69 public:
72 
74 
76  void PrintSelf(ostream& os, vtkIndent indent);
78 
80 
82  void SetCenter(double x, double y, double z);
83  void SetCenter(double x[3]);
84  double* GetCenter();
85  void GetCenter(double xyz[3]);
87 
89 
91  void SetAxis(double x, double y, double z);
92  void SetAxis(double a[3]);
93  double* GetAxis();
94  void GetAxis(double a[3]);
96 
98 
100  void SetRadius(double r);
101  double GetRadius();
103 
105 
109  vtkSetClampMacro(MinRadius,double,0.001,0.25);
110  vtkGetMacro(MinRadius,double);
111  vtkSetClampMacro(MaxRadius,double,0.25,VTK_FLOAT_MAX);
112  vtkGetMacro(MaxRadius,double);
114 
116 
120  void SetAlongXAxis(int);
121  vtkGetMacro(AlongXAxis,int);
122  vtkBooleanMacro(AlongXAxis,int);
123  void SetAlongYAxis(int);
124  vtkGetMacro(AlongYAxis,int);
125  vtkBooleanMacro(AlongYAxis,int);
126  void SetAlongZAxis(int);
127  vtkGetMacro(AlongZAxis,int);
128  vtkBooleanMacro(AlongZAxis,int);
130 
132 
136  void SetDrawCylinder(int plane);
137  vtkGetMacro(DrawCylinder,int);
138  vtkBooleanMacro(DrawCylinder,int);
140 
142 
146  vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
147  vtkGetMacro(Resolution,int);
149 
151 
154  vtkSetMacro(Tubing,int);
155  vtkGetMacro(Tubing,int);
156  vtkBooleanMacro(Tubing,int);
158 
160 
162  vtkSetMacro(OutlineTranslation,int);
163  vtkGetMacro(OutlineTranslation,int);
164  vtkBooleanMacro(OutlineTranslation,int);
166 
168 
170  vtkSetMacro(OutsideBounds,int);
171  vtkGetMacro(OutsideBounds,int);
172  vtkBooleanMacro(OutsideBounds,int);
174 
176 
177  vtkSetMacro(ScaleEnabled,int);
178  vtkGetMacro(ScaleEnabled,int);
179  vtkBooleanMacro(ScaleEnabled,int);
181 
187  void GetCylinder(vtkCylinder *cyl);
188 
191  void GetPolyData(vtkPolyData *pd);
192 
196  void UpdatePlacement(void);
197 
199 
200  vtkGetObjectMacro(AxisProperty,vtkProperty);
201  vtkGetObjectMacro(SelectedAxisProperty,vtkProperty);
203 
205 
207  vtkGetObjectMacro(CylinderProperty,vtkProperty);
208  vtkGetObjectMacro(SelectedCylinderProperty,vtkProperty);
210 
212 
213  vtkGetObjectMacro(OutlineProperty,vtkProperty);
214  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
216 
218 
220  vtkGetObjectMacro(EdgesProperty,vtkProperty);
222 
223 
224  void SetEdgeColor(vtkLookupTable*);
225  void SetEdgeColor(double, double, double);
226  void SetEdgeColor(double x[3]);
228 
230 
231  virtual int ComputeInteractionState(int X, int Y, int modify=0);
232  virtual void PlaceWidget(double bounds[6]);
233  virtual void BuildRepresentation();
234  virtual void StartWidgetInteraction(double eventPos[2]);
235  virtual void WidgetInteraction(double newEventPos[2]);
236  virtual void EndWidgetInteraction(double newEventPos[2]);
238 
240 
241  virtual double *GetBounds();
242  virtual void GetActors(vtkPropCollection *pc);
243  virtual void ReleaseGraphicsResources(vtkWindow*);
244  virtual int RenderOpaqueGeometry(vtkViewport*);
246  virtual int HasTranslucentPolygonalGeometry();
248 
250 
253  vtkSetClampMacro(BumpDistance,double,0.000001,1);
254  vtkGetMacro(BumpDistance,double);
256 
262  void BumpCylinder(int dir, double factor);
263 
268  void PushCylinder(double distance);
269 
270  // Manage the state of the widget
272  {
273  Outside=0,
279  Scaling
280  };
281 
283 
290  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
292 
294 
296  virtual void SetRepresentationState(int);
297  vtkGetMacro(RepresentationState, int);
299 
300 protected:
303 
305 
306  // Keep track of event positions
307  double LastEventPosition[3];
308 
309  // Control the radius
310  double MinRadius;
311  double MaxRadius;
312 
313  // Controlling the push operation
314  double BumpDistance;
315 
316  // Controlling ivars
320 
321  // The actual plane which is being manipulated
323 
324  // The facet resolution for rendering purposes.
326 
327  // The bounding box is represented by a single voxel image data
332  void HighlightOutline(int highlight);
333  int OutlineTranslation; //whether the outline can be moved
334  int ScaleEnabled; //whether the widget can be scaled
335  int OutsideBounds; //whether the widget can be moved outside input's bounds
336 
337  // The cut plane is produced with a vtkCutter
342  void HighlightCylinder(int highlight);
343 
344  // Optional tubes are represented by extracting boundary edges and tubing
349  int Tubing; //control whether tubing is on
350 
351  // The + normal cone (i.e., in positive direction along normal)
355  void HighlightNormal(int highlight);
356 
357  // The + normal line
361 
362  // The - normal cone
366 
367  // The - normal line
371 
372  // The origin positioning handle
376 
377  // Do the picking
380 
381  // Register internal Pickers within PickingManager
382  virtual void RegisterPickers();
383 
384  // Transform the normal (used for rotation)
386 
387  // Methods to manipulate the plane
388  void ConstrainCenter(double x[3]);
389  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
390  void TranslateCylinder(double *p1, double *p2);
391  void TranslateOutline(double *p1, double *p2);
392  void TranslateCenter(double *p1, double *p2);
393  void ScaleRadius(double *p1, double *p2);
394  void AdjustRadius(double X, double Y, double *p1, double *p2);
395  void Scale(double *p1, double *p2, double X, double Y);
396  void SizeHandles();
397 
398  // Properties used to control the appearance of selected objects and
399  // the manipulator in general.
407  void CreateDefaultProperties();
408 
409  // Intersect oriented infinite cylinder against bounding box
410  void BuildCylinder();
411 
412  // Support GetBounds() method
414 
415 private:
417  void operator=(const vtkImplicitCylinderRepresentation&); //Not implemented
418 };
419 
420 #endif
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
virtual void StartWidgetInteraction(double eventPos[2])
defining the representation for a vtkImplicitCylinderWidget
map scalar values into colors via a lookup table
generate polygonal cone
Definition: vtkConeSource.h:43
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
#define VTKINTERACTIONWIDGETS_EXPORT
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
#define VTK_FLOAT_MAX
Definition: vtkType.h:138
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:82
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void RegisterPickers()
extract boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
virtual void WidgetInteraction(double newEventPos[2])
virtual void GetActors(vtkPropCollection *)
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
void PrintSelf(ostream &os, vtkIndent indent)
implicit function for a cylinder
Definition: vtkCylinder.h:43
static vtkObject * New()
implicit function for a bounding box
Definition: vtkBox.h:40
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
#define VTK_MAX_CYL_RESOLUTION