/usr/include/vtk-7.1/vtkImplicitCylinderRepresentation.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkImplicitCylinderRepresentation.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkImplicitCylinderRepresentation
* @brief defining the representation for a vtkImplicitCylinderWidget
*
* This class is a concrete representation for the
* vtkImplicitCylinderWidget. It represents an infinite cylinder
* defined by a radius, a center, and an axis. The cylinder is placed
* within its associated bounding box and the intersection of the
* cylinder with the bounding box is shown to visually indicate the
* orientation and position of the representation. This cylinder
* representation can be manipulated by using the
* vtkImplicitCylinderWidget to adjust the cylinder radius, axis,
* and/or center point. (Note that the bounding box is defined during
* invocation of the superclass' PlaceWidget() method.)
*
* To use this representation, you normally specify a radius, center,
* and axis. Optionally you can specify a minimum and maximum radius,
* and a resolution for the cylinder. Finally, place the widget and
* its representation in the scene using PlaceWidget().
*
* @sa
* vtkImplicitCylinderWidget vtkImplicitPlaneWidget vtkImplicitPlaneWidget
*/
#ifndef vtkImplicitCylinderRepresentation_h
#define vtkImplicitCylinderRepresentation_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkWidgetRepresentation.h"
class vtkActor;
class vtkPolyDataMapper;
class vtkCellPicker;
class vtkConeSource;
class vtkLineSource;
class vtkSphereSource;
class vtkTubeFilter;
class vtkCylinder;
class vtkProperty;
class vtkImageData;
class vtkOutlineFilter;
class vtkFeatureEdges;
class vtkPolyData;
class vtkPolyDataAlgorithm;
class vtkTransform;
class vtkBox;
class vtkLookupTable;
#define VTK_MAX_CYL_RESOLUTION 2048
class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderRepresentation : public vtkWidgetRepresentation
{
public:
/**
* Instantiate the class.
*/
static vtkImplicitCylinderRepresentation *New();
//@{
/**
* Standard methods for the class.
*/
vtkTypeMacro(vtkImplicitCylinderRepresentation,vtkWidgetRepresentation);
void PrintSelf(ostream& os, vtkIndent indent);
//@}
//@{
/**
* Get the center of the cylinder. The center is located along the
* cylinder axis.
*/
void SetCenter(double x, double y, double z);
void SetCenter(double x[3]);
double* GetCenter();
void GetCenter(double xyz[3]);
//@}
//@{
/**
* Set/Get the axis of rotation for the cylinder. If the axis is not
* specified as a unit vector, it will be normalized.
*/
void SetAxis(double x, double y, double z);
void SetAxis(double a[3]);
double* GetAxis();
void GetAxis(double a[3]);
//@}
//@{
/**
* Set/Get the radius of the cylinder. Note that if the radius is
* too big the cylinder will be outside of the bounding box.
*/
void SetRadius(double r);
double GetRadius();
//@}
//@{
/**
* Set/Get the minimum and maximum radius of the cylinder. This
* helps prevent the cylinder from "disappearing" during
* interaction. Note that the minimum and maximum radius is
* specified as a fraction of the diagonal length of the widget
* bounding box.
*/
vtkSetClampMacro(MinRadius,double,0.001,0.25);
vtkGetMacro(MinRadius,double);
vtkSetClampMacro(MaxRadius,double,0.25,VTK_FLOAT_MAX);
vtkGetMacro(MaxRadius,double);
//@}
//@{
/**
* Force the cylinder widget to be aligned with one of the x-y-z axes.
* If one axis is set on, the other two will be set off.
* Remember that when the state changes, a ModifiedEvent is invoked.
* This can be used to snap the cylinder to the axes if it is originally
* not aligned.
*/
void SetAlongXAxis(int);
vtkGetMacro(AlongXAxis,int);
vtkBooleanMacro(AlongXAxis,int);
void SetAlongYAxis(int);
vtkGetMacro(AlongYAxis,int);
vtkBooleanMacro(AlongYAxis,int);
void SetAlongZAxis(int);
vtkGetMacro(AlongZAxis,int);
vtkBooleanMacro(AlongZAxis,int);
//@}
//@{
/**
* Enable/disable the drawing of the cylinder. In some cases the cylinder
* interferes with the object that it is operating on (e.g., the
* cylinder interferes with the cut surface it produces resulting in
* z-buffer artifacts.) By default it is off.
*/
void SetDrawCylinder(int drawCyl);
vtkGetMacro(DrawCylinder,int);
vtkBooleanMacro(DrawCylinder,int);
//@}
//@{
/**
* Set/Get the resolution of the cylinder. This is the number of
* polygonal facets used to approximate the curved cylindrical
* surface (for rendering purposes). An vtkCylinder is used under
* the hood to provide an exact surface representation.
*/
vtkSetClampMacro(Resolution,int,8,VTK_MAX_CYL_RESOLUTION);
vtkGetMacro(Resolution,int);
//@}
//@{
/**
* Turn on/off tubing of the wire outline of the cylinder
* intersecton (against the bounding box). The tube thickens the
* line by wrapping with a vtkTubeFilter.
*/
vtkSetMacro(Tubing,int);
vtkGetMacro(Tubing,int);
vtkBooleanMacro(Tubing,int);
//@}
//@{
/**
* Turn on/off the ability to translate the bounding box by moving it
* with the mouse.
*/
vtkSetMacro(OutlineTranslation,int);
vtkGetMacro(OutlineTranslation,int);
vtkBooleanMacro(OutlineTranslation,int);
//@}
//@{
/**
* Turn on/off the ability to move the widget outside of the bounds
* specified in the PlaceWidget() invocation.
*/
vtkSetMacro(OutsideBounds,int);
vtkGetMacro(OutsideBounds,int);
vtkBooleanMacro(OutsideBounds,int);
//@}
//@{
/**
* Set/Get the bounds of the widget representation. PlaceWidget can also be
* used to set the bounds of the widget but it may also have other effects
* on the internal state of the represenation. Use this function when only
* the widget bounds are needs to be modified.
*/
vtkSetVector6Macro(WidgetBounds, double);
vtkGetVector6Macro(WidgetBounds, double);
//@}
//@{
/**
* Turn on/off whether the cylinder should be constrained to the widget bounds.
* If on, the center will not be allowed to move outside the set widget bounds
* and the radius will be limited by MinRadius and MaxRadius. This is the
* default behaviour.
* If off, the center can be freely moved and the radius can be set to
* arbitrary values. The widget outline will change accordingly.
*/
vtkSetMacro(ConstrainToWidgetBounds, int);
vtkGetMacro(ConstrainToWidgetBounds, int);
vtkBooleanMacro(ConstrainToWidgetBounds, int);
//@}
//@{
/**
* Turn on/off the ability to scale the widget with the mouse.
*/
vtkSetMacro(ScaleEnabled,int);
vtkGetMacro(ScaleEnabled,int);
vtkBooleanMacro(ScaleEnabled,int);
//@}
/**
* Get the implicit function for the cylinder. The user must provide the
* instance of the class vtkCylinder. Note that vtkCylinder is a subclass of
* vtkImplicitFunction, meaning that it can be used by a variety of filters
* to perform clipping, cutting, and selection of data.
*/
void GetCylinder(vtkCylinder *cyl);
/**
* Grab the polydata that defines the cylinder. The polydata contains
* polygons that are clipped by the bounding box.
*/
void GetPolyData(vtkPolyData *pd);
/**
* Satisfies the superclass API. This will change the state of the widget
* to match changes that have been made to the underlying PolyDataSource.
*/
void UpdatePlacement(void);
//@{
/**
* Get the properties on the axis (line and cone).
*/
vtkGetObjectMacro(AxisProperty,vtkProperty);
vtkGetObjectMacro(SelectedAxisProperty,vtkProperty);
//@}
//@{
/**
* Get the cylinder properties. The properties of the cylinder when selected
* and unselected can be manipulated.
*/
vtkGetObjectMacro(CylinderProperty,vtkProperty);
vtkGetObjectMacro(SelectedCylinderProperty,vtkProperty);
//@}
//@{
/**
* Get the property of the outline.
*/
vtkGetObjectMacro(OutlineProperty,vtkProperty);
vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
//@}
//@{
/**
* Get the property of the intersection edges. (This property also
* applies to the edges when tubed.)
*/
vtkGetObjectMacro(EdgesProperty,vtkProperty);
//@}
//@{
/**
* Set color to the edge
*/
void SetEdgeColor(vtkLookupTable*);
void SetEdgeColor(double, double, double);
void SetEdgeColor(double x[3]);
//@}
//@{
/**
* Methods to interface with the vtkImplicitCylinderWidget.
*/
virtual int ComputeInteractionState(int X, int Y, int modify=0);
virtual void PlaceWidget(double bounds[6]);
virtual void BuildRepresentation();
virtual void StartWidgetInteraction(double eventPos[2]);
virtual void WidgetInteraction(double newEventPos[2]);
virtual void EndWidgetInteraction(double newEventPos[2]);
//@}
//@{
/**
* Methods supporting the rendering process.
*/
virtual double *GetBounds();
virtual void GetActors(vtkPropCollection *pc);
virtual void ReleaseGraphicsResources(vtkWindow*);
virtual int RenderOpaqueGeometry(vtkViewport*);
virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
virtual int HasTranslucentPolygonalGeometry();
//@}
//@{
/**
* Specify a translation distance used by the BumpCylinder() method. Note that the
* distance is normalized; it is the fraction of the length of the bounding
* box of the wire outline.
*/
vtkSetClampMacro(BumpDistance,double,0.000001,1);
vtkGetMacro(BumpDistance,double);
//@}
/**
* Translate the cylinder in the direction of the view vector by the
* specified BumpDistance. The dir parameter controls which
* direction the pushing occurs, either in the same direction as the
* view vector, or when negative, in the opposite direction. The factor
* controls what percentage of the bump is used.
*/
void BumpCylinder(int dir, double factor);
/**
* Push the cylinder the distance specified along the view
* vector. Positive values are in the direction of the view vector;
* negative values are in the opposite direction. The distance value
* is expressed in world coordinates.
*/
void PushCylinder(double distance);
// Manage the state of the widget
enum _InteractionState
{
Outside=0,
Moving,
MovingOutline,
MovingCenter,
RotatingAxis,
AdjustingRadius,
Scaling,
TranslatingCenter
};
//@{
/**
* The interaction state may be set from a widget (e.g.,
* vtkImplicitCylinderWidget) or other object. This controls how the
* interaction with the widget proceeds. Normally this method is used as
* part of a handshaking process with the widget: First
* ComputeInteractionState() is invoked that returns a state based on
* geometric considerations (i.e., cursor near a widget feature), then
* based on events, the widget may modify this further.
*/
vtkSetClampMacro(InteractionState,int,Outside,TranslatingCenter);
//@}
//@{
/**
* Sets the visual appearance of the representation based on the
* state it is in. This state is usually the same as InteractionState.
*/
virtual void SetRepresentationState(int);
vtkGetMacro(RepresentationState, int);
//@}
protected:
vtkImplicitCylinderRepresentation();
~vtkImplicitCylinderRepresentation();
int RepresentationState;
// Keep track of event positions
double LastEventPosition[3];
// Control the radius
double MinRadius;
double MaxRadius;
// Controlling the push operation
double BumpDistance;
// Controlling ivars
int AlongXAxis;
int AlongYAxis;
int AlongZAxis;
// The actual cylinder which is being manipulated
vtkCylinder *Cylinder;
// The facet resolution for rendering purposes.
int Resolution;
// The bounding box is represented by a single voxel image data
vtkImageData *Box;
vtkOutlineFilter *Outline;
vtkPolyDataMapper *OutlineMapper;
vtkActor *OutlineActor;
void HighlightOutline(int highlight);
int OutlineTranslation; //whether the outline can be moved
int ScaleEnabled; //whether the widget can be scaled
int OutsideBounds; //whether the widget can be moved outside input's bounds
double WidgetBounds[6];
int ConstrainToWidgetBounds;
// The cut cylinder is produced with a vtkCutter
vtkPolyData *Cyl;
vtkPolyDataMapper *CylMapper;
vtkActor *CylActor;
int DrawCylinder;
void HighlightCylinder(int highlight);
// Optional tubes are represented by extracting boundary edges and tubing
vtkFeatureEdges *Edges;
vtkTubeFilter *EdgesTuber;
vtkPolyDataMapper *EdgesMapper;
vtkActor *EdgesActor;
int Tubing; //control whether tubing is on
// The + normal cone (i.e., in positive direction along normal)
vtkConeSource *ConeSource;
vtkPolyDataMapper *ConeMapper;
vtkActor *ConeActor;
void HighlightNormal(int highlight);
// The + normal line
vtkLineSource *LineSource;
vtkPolyDataMapper *LineMapper;
vtkActor *LineActor;
// The - normal cone
vtkConeSource *ConeSource2;
vtkPolyDataMapper *ConeMapper2;
vtkActor *ConeActor2;
// The - normal line
vtkLineSource *LineSource2;
vtkPolyDataMapper *LineMapper2;
vtkActor *LineActor2;
// The center positioning handle
vtkSphereSource *Sphere;
vtkPolyDataMapper *SphereMapper;
vtkActor *SphereActor;
// Do the picking
vtkCellPicker *Picker;
vtkCellPicker *CylPicker;
// Register internal Pickers within PickingManager
virtual void RegisterPickers();
// Transform the normal (used for rotation)
vtkTransform *Transform;
// Methods to manipulate the cylinder
void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
void TranslateCylinder(double *p1, double *p2);
void TranslateOutline(double *p1, double *p2);
void TranslateCenter(double *p1, double *p2);
void TranslateCenterOnAxis(double *p1, double *p2);
void ScaleRadius(double *p1, double *p2);
void AdjustRadius(double X, double Y, double *p1, double *p2);
void Scale(double *p1, double *p2, double X, double Y);
void SizeHandles();
// Properties used to control the appearance of selected objects and
// the manipulator in general.
vtkProperty *AxisProperty;
vtkProperty *SelectedAxisProperty;
vtkProperty *CylinderProperty;
vtkProperty *SelectedCylinderProperty;
vtkProperty *OutlineProperty;
vtkProperty *SelectedOutlineProperty;
vtkProperty *EdgesProperty;
void CreateDefaultProperties();
// Intersect oriented infinite cylinder against bounding box
void BuildCylinder();
// Support GetBounds() method
vtkBox *BoundingBox;
private:
vtkImplicitCylinderRepresentation(const vtkImplicitCylinderRepresentation&) VTK_DELETE_FUNCTION;
void operator=(const vtkImplicitCylinderRepresentation&) VTK_DELETE_FUNCTION;
};
#endif
|