vtkParametricSuperToroid.h
上传用户:tma1234
上传日期:2008-07-23
资源大小:25834k
文件大小:5k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /*=========================================================================
  2.   Program:   Visualization Toolkit
  3.   Module:    $RCSfile: vtkParametricSuperToroid.h,v $
  4.   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 
  5.   All rights reserved.
  6.   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
  7.      This software is distributed WITHOUT ANY WARRANTY; without even 
  8.      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  9.      PURPOSE.  See the above copyright notice for more information.
  10. =========================================================================*/
  11. // .NAME vtkParametricSuperToroid - Generate a supertoroid.
  12. // .SECTION Description
  13. // vtkParametricSuperToroid generates a supertoroid.  Essentially a
  14. // supertoroid is a torus with the sine and cosine terms raised to a power.
  15. // A supertoroid is a versatile primitive that is controlled by four
  16. // parameters r0, r1, n1 and n2. r0, r1 determine the type of torus whilst
  17. // the value of n1 determines the shape of the torus ring and n2 determines
  18. // the shape of the cross section of the ring. It is the different values of
  19. // these powers which give rise to a family of 3D shapes that are all
  20. // basically toroidal in shape.
  21. //
  22. // For further information about this surface, please consult the 
  23. // technical description "Parametric surfaces" in http://www.vtk.org/documents.php 
  24. // in the "VTK Technical Documents" section in the VTk.org web pages.
  25. //
  26. // Also see: http://astronomy.swin.edu.au/~pbourke/surfaces/.
  27. //
  28. // .SECTION Caveats
  29. // Care needs to be taken specifying the bounds correctly. You may need to 
  30. // carefully adjust MinimumU, MinimumV, MaximumU, MaximumV.
  31. //
  32. // .SECTION Thanks
  33. // Andrew Maclean a.maclean@cas.edu.au for creating and contributing the
  34. // class.
  35. //
  36. #ifndef __vtkParametricSuperToroid_h
  37. #define __vtkParametricSuperToroid_h
  38. #include "vtkParametricFunction.h"
  39. class VTK_COMMON_EXPORT vtkParametricSuperToroid : public vtkParametricFunction
  40. {
  41. public:
  42.   vtkTypeRevisionMacro(vtkParametricSuperToroid,vtkParametricFunction);
  43.   void PrintSelf(ostream& os, vtkIndent indent);
  44.   
  45.   // Description:
  46.   // Construct a supertoroid with the following parameters: 
  47.   // MinimumU = 0, MaximumU = 2*Pi, 
  48.   // MinimumV = 0, MaximumV = 2*Pi, 
  49.   // JoinU = 1, JoinV = 1,
  50.   // TwistU = 0, TwistV = 0, 
  51.   // ClockwiseOrdering = 1, 
  52.   // DerivativesAvailable = 0,
  53.   // RingRadius = 1, CrossSectionRadius = 0.5, 
  54.   // N1 = 1, N2 = 1, XRadius = 1,
  55.   // YRadius = 1, ZRadius = 1, a torus in this case.
  56.   static vtkParametricSuperToroid *New();
  57.   // Description
  58.   // Return the parametric dimension of the class.
  59.   virtual int GetDimension() {return 2;}
  60.   // Description:
  61.   // Set/Get the radius from the center to the middle of the ring of the
  62.   // supertoroid.  Default = 1.
  63.   vtkSetMacro(RingRadius,double);
  64.   vtkGetMacro(RingRadius,double);
  65.   // Description:
  66.   // Set/Get the radius of the cross section of ring of the supertoroid.
  67.   // Default = 0.5.
  68.   vtkSetMacro(CrossSectionRadius,double);
  69.   vtkGetMacro(CrossSectionRadius,double);
  70.   // Description:
  71.   // Set/Get the scaling factor for the x-axis. Default = 1.
  72.   vtkSetMacro(XRadius,double);
  73.   vtkGetMacro(XRadius,double);
  74.   // Description:
  75.   // Set/Get the scaling factor for the y-axis. Default = 1.
  76.   vtkSetMacro(YRadius,double);
  77.   vtkGetMacro(YRadius,double);
  78.   // Description:
  79.   // Set/Get the scaling factor for the z-axis. Default = 1.
  80.   vtkSetMacro(ZRadius,double);
  81.   vtkGetMacro(ZRadius,double);
  82.   // Description:
  83.   // Set/Get the shape of the torus ring.  Default = 1.
  84.   vtkSetMacro(N1,double);
  85.   vtkGetMacro(N1,double);
  86.   // Description:
  87.   //  Set/Get the shape of the cross section of the ring. Default = 1.
  88.   vtkSetMacro(N2,double);
  89.   vtkGetMacro(N2,double);
  90.   // Description:
  91.   // A supertoroid.
  92.   //
  93.   // This function performs the mapping f$f(u,v) rightarrow (x,y,x)f$, returning it
  94.   // as Pt. It also returns the partial derivatives Du and Dv.
  95.   // f$Pt = (x, y, z), Du = (dx/du, dy/du, dz/du), Dv = (dx/dv, dy/dv, dz/dv)f$ .
  96.   // Then the normal is f$N = Du X Dvf$ .
  97.   virtual void Evaluate(double uvw[3], double Pt[3], double Duvw[9]);
  98.   // Description:
  99.   // Calculate a user defined scalar using one or all of uvw, Pt, Duvw.
  100.   //
  101.   // uvw are the parameters with Pt being the the cartesian point, 
  102.   // Duvw are the derivatives of this point with respect to u, v and w.
  103.   // Pt, Duvw are obtained from Evaluate().
  104.   //
  105.   // This function is only called if the ScalarMode has the value
  106.   // vtkParametricFunctionSource::SCALAR_FUNCTION_DEFINED
  107.   //
  108.   // If the user does not need to calculate a scalar, then the 
  109.   // instantiated function should return zero. 
  110.   //
  111.   virtual double EvaluateScalar(double uvw[3], double Pt[3], double Duvw[9]);
  112. protected:
  113.   vtkParametricSuperToroid();
  114.   ~vtkParametricSuperToroid();
  115.   // Variables
  116.   double RingRadius;
  117.   double CrossSectionRadius;
  118.   double XRadius;
  119.   double YRadius;
  120.   double ZRadius;
  121.   double N1;
  122.   double N2;
  123. private:
  124.   vtkParametricSuperToroid(const vtkParametricSuperToroid&);  // Not implemented.
  125.   void operator=(const vtkParametricSuperToroid&);  // Not implemented.
  126.   // Description:
  127.   // Calculate sign(x)*(abs(x)^n).
  128.   double Power ( double x, double n );
  129. };
  130. #endif