OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / include / vtk / vtkSuperquadricSource.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkSuperquadricSource.h,v $
5   Language:  C++
6   Date:      $Date: 2002/01/22 15:29:50 $
7   Version:   $Revision: 1.18 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
17 =========================================================================*/
18 // .NAME vtkSuperquadricSource - create a polygonal superquadric centered 
19 // at the origin
20 // .SECTION Description
21 // vtkSuperquadricSource creates a superquadric (represented by polygons) 
22 // of specified
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 
32 // superquadric.
33 //
34 // This code is based on "Rigid physically based superquadrics", A. H. Barr,
35 // in "Graphics Gems III", David Kirk, ed., Academic Press, 1992.
36 //
37 // .SECTION Caveats
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.  
41 //
42 // Texture coordinates are not equally distributed around all superquadrics.
43 // 
44 // The Size and Thickness parameters control coefficients of superquadric
45 // generation, and may do not exactly describe the size of the superquadric.
46 //
47
48 #ifndef __vtkSuperquadricSource_h
49 #define __vtkSuperquadricSource_h
50
51 #include "vtkPolyDataSource.h"
52
53 #define VTK_MAX_SUPERQUADRIC_RESOLUTION 1024
54 #define VTK_MIN_SUPERQUADRIC_THICKNESS  1e-4
55 #define VTK_MIN_SUPERQUADRIC_ROUNDNESS  1e-24
56
57 class VTK_GRAPHICS_EXPORT vtkSuperquadricSource : public vtkPolyDataSource 
58 {
59 public:
60   // Description:
61   // Create a default superquadric with a radius of 0.5, non-toroidal, 
62   // spherical, and centered at the origin.
63   static vtkSuperquadricSource *New();
64
65   vtkTypeRevisionMacro(vtkSuperquadricSource,vtkPolyDataSource);
66   void PrintSelf(ostream& os, vtkIndent indent);
67
68   // Description:
69   // Set the center of the superquadric. Default is 0,0,0.
70   vtkSetVector3Macro(Center,float);
71   vtkGetVectorMacro(Center,float,3);
72
73   // Description:
74   // Set the scale factors of the superquadric. Default is 1,1,1.
75   vtkSetVector3Macro(Scale,float);
76   vtkGetVectorMacro(Scale,float,3);
77
78   // Description:
79   // Set the number of points in the longitude direction.
80   vtkGetMacro(ThetaResolution,int);
81   void SetThetaResolution(int i);
82
83   // Description:
84   // Set the number of points in the latitude direction.
85   vtkGetMacro(PhiResolution,int);
86   void SetPhiResolution(int i);
87
88   // Description:
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);
93
94   // Description:
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); 
99
100   // Description:
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);
105
106   // Description:
107   // Set/Get Superquadric isotropic size.
108   vtkSetMacro(Size,float);
109   vtkGetMacro(Size,float);
110
111   // Description:
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);
116
117 protected:
118   vtkSuperquadricSource(int res=16);
119   ~vtkSuperquadricSource() {};
120
121   int Toroidal;
122   float Thickness;
123   float Size;
124   float PhiRoundness;
125   float ThetaRoundness;
126   void Execute();
127   float Center[3];
128   float Scale[3];
129   int ThetaResolution;
130   int PhiResolution;
131
132 private:
133   vtkSuperquadricSource(const vtkSuperquadricSource&);  // Not implemented.
134   void operator=(const vtkSuperquadricSource&);  // Not implemented.
135 };
136
137 #endif
138
139