1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkSuperquadricSource.h,v $
6 Date: $Date: 2002/01/22 15:29:50 $
7 Version: $Revision: 1.18 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkSuperquadricSource - create a polygonal superquadric centered
20 // .SECTION Description
21 // vtkSuperquadricSource creates a superquadric (represented by polygons)
23 // size centered at the origin. The resolution (polygonal discretization)
24 // in both the latitude (phi) and longitude (theta) directions can be
25 // specified. Roundness parameters (PhiRoundness and ThetaRoundness) control
26 // the shape of the superquadric. The Toroidal boolean controls whether
27 // a toroidal superquadric is produced. If so, the Thickness parameter
28 // controls the thickness of the toroid: 0 is the thinnest allowable
29 // toroid, and 1 has a minimum sized hole. The Scale parameters allow
30 // the superquadric to be scaled in x, y, and z (normal vectors are correctly
31 // generated in any case). The Size parameter controls size of the
34 // This code is based on "Rigid physically based superquadrics", A. H. Barr,
35 // in "Graphics Gems III", David Kirk, ed., Academic Press, 1992.
38 // Resolution means the number of latitude or longitude lines for a complete
39 // superquadric. The resolution parameters are rounded to the nearest 4
40 // in phi and 8 in theta.
42 // Texture coordinates are not equally distributed around all superquadrics.
44 // The Size and Thickness parameters control coefficients of superquadric
45 // generation, and may do not exactly describe the size of the superquadric.
48 #ifndef __vtkSuperquadricSource_h
49 #define __vtkSuperquadricSource_h
51 #include "vtkPolyDataSource.h"
53 #define VTK_MAX_SUPERQUADRIC_RESOLUTION 1024
54 #define VTK_MIN_SUPERQUADRIC_THICKNESS 1e-4
55 #define VTK_MIN_SUPERQUADRIC_ROUNDNESS 1e-24
57 class VTK_GRAPHICS_EXPORT vtkSuperquadricSource : public vtkPolyDataSource
61 // Create a default superquadric with a radius of 0.5, non-toroidal,
62 // spherical, and centered at the origin.
63 static vtkSuperquadricSource *New();
65 vtkTypeRevisionMacro(vtkSuperquadricSource,vtkPolyDataSource);
66 void PrintSelf(ostream& os, vtkIndent indent);
69 // Set the center of the superquadric. Default is 0,0,0.
70 vtkSetVector3Macro(Center,float);
71 vtkGetVectorMacro(Center,float,3);
74 // Set the scale factors of the superquadric. Default is 1,1,1.
75 vtkSetVector3Macro(Scale,float);
76 vtkGetVectorMacro(Scale,float,3);
79 // Set the number of points in the longitude direction.
80 vtkGetMacro(ThetaResolution,int);
81 void SetThetaResolution(int i);
84 // Set the number of points in the latitude direction.
85 vtkGetMacro(PhiResolution,int);
86 void SetPhiResolution(int i);
89 // Set/Get Superquadric ring thickness (toroids only).
90 // Changing thickness maintains the outside diameter of the toroid.
91 vtkGetMacro(Thickness,float);
92 vtkSetClampMacro(Thickness,float,VTK_MIN_SUPERQUADRIC_THICKNESS,1.0);
95 // Set/Get Superquadric north/south roundness.
96 // Values range from 0 (rectangular) to 1 (circular) to higher orders.
97 vtkGetMacro(PhiRoundness,float);
98 void SetPhiRoundness(float e);
101 // Set/Get Superquadric east/west roundness.
102 // Values range from 0 (rectangular) to 1 (circular) to higher orders.
103 vtkGetMacro(ThetaRoundness,float);
104 void SetThetaRoundness(float e);
107 // Set/Get Superquadric isotropic size.
108 vtkSetMacro(Size,float);
109 vtkGetMacro(Size,float);
112 // Set/Get whether or not the superquadric is toroidal (1) or ellipsoidal (0).
113 vtkBooleanMacro(Toroidal,int);
114 vtkGetMacro(Toroidal,int);
115 vtkSetMacro(Toroidal,int);
118 vtkSuperquadricSource(int res=16);
119 ~vtkSuperquadricSource() {};
125 float ThetaRoundness;
133 vtkSuperquadricSource(const vtkSuperquadricSource&); // Not implemented.
134 void operator=(const vtkSuperquadricSource&); // Not implemented.