1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkCylinder.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 =========================================================================*/ 15 /** 16 * @class vtkCylinder 17 * @brief implicit function for a cylinder 18 * 19 * vtkCylinder computes the implicit function and function gradient 20 * for a cylinder using F(r)=r^2-Radius^2. vtkCylinder is a concrete 21 * implementation of vtkImplicitFunction. By default the Cylinder is 22 * centered at the origin and the axis of rotation is along the 23 * y-axis. You can redefine the center and axis of rotation by setting 24 * the Center and Axis data members. (Note that it is also possible to 25 * use the superclass' vtkImplicitFunction transformation matrix if 26 * necessary to reposition by using FunctionValue() and 27 * FunctionGradient().) 28 * 29 * @warning 30 * The cylinder is infinite in extent. To truncate the cylinder in 31 * modeling operations use the vtkImplicitBoolean in combination with 32 * clipping planes. 33 */ 34 35 #ifndef vtkCylinder_h 36 #define vtkCylinder_h 37 38 #include "vtkCommonDataModelModule.h" // For export macro 39 #include "vtkImplicitFunction.h" 40 41 class VTKCOMMONDATAMODEL_EXPORT vtkCylinder : public vtkImplicitFunction 42 { 43 public: 44 vtkTypeMacro(vtkCylinder, vtkImplicitFunction); 45 void PrintSelf(ostream& os, vtkIndent indent) override; 46 47 /** 48 * Construct cylinder radius of 0.5; centered at origin with axis 49 * along y coordinate axis. 50 */ 51 static vtkCylinder* New(); 52 53 ///@{ 54 /** 55 * Evaluate cylinder equation F(r) = r^2 - Radius^2. 56 */ 57 using vtkImplicitFunction::EvaluateFunction; 58 double EvaluateFunction(double x[3]) override; 59 ///@} 60 61 /** 62 * Evaluate cylinder function gradient. 63 */ 64 void EvaluateGradient(double x[3], double g[3]) override; 65 66 ///@{ 67 /** 68 * Set/Get the cylinder radius. 69 */ 70 vtkSetMacro(Radius, double); 71 vtkGetMacro(Radius, double); 72 ///@} 73 74 ///@{ 75 /** 76 * Set/Get the cylinder center. 77 */ 78 vtkSetVector3Macro(Center, double); 79 vtkGetVector3Macro(Center, double); 80 ///@} 81 82 ///@{ 83 /** 84 * Set/Get the axis of the cylinder. If the axis is not specified as 85 * a unit vector, it will be normalized. If zero-length axis vector 86 * is used as input to this method, it will be ignored. 87 */ 88 void SetAxis(double ax, double ay, double az); 89 void SetAxis(double a[3]); 90 vtkGetVector3Macro(Axis, double); 91 ///@} 92 93 protected: 94 vtkCylinder(); 95 ~vtkCylinder() override = default; 96 97 double Radius; 98 double Center[3]; 99 double Axis[3]; 100 101 private: 102 vtkCylinder(const vtkCylinder&) = delete; 103 void operator=(const vtkCylinder&) = delete; 104 }; 105 106 #endif 107