Commit f845bd70 authored by Andrew Maclean's avatar Andrew Maclean
Browse files

ENH: - new parametric surfaces added,

parent 199130b2
......@@ -96,6 +96,9 @@ vtkOverrideInformation.cxx
vtkOverrideInformationCollection.cxx
vtkParametricBoy.cxx
vtkParametricConicSpiral.cxx
vtkParametricCrossCap.cxx
vtkParametricDini.cxx
vtkParametricEnneper.cxx
vtkParametricFigure8Klein.cxx
vtkParametricFunction.cxx
vtkParametricKlein.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricCrossCap.cxx
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.
=========================================================================*/
#include "vtkParametricCrossCap.h"
#include "vtkObjectFactory.h"
#include "vtkMath.h"
vtkCxxRevisionMacro(vtkParametricCrossCap, "1.1");
vtkStandardNewMacro(vtkParametricCrossCap);
vtkParametricCrossCap::vtkParametricCrossCap()
{
// Preset triangulation parameters
this->MinimumU = 0;
this->MinimumV = 0;
this->MaximumU = vtkMath::Pi();
this->MaximumV = vtkMath::Pi();
this->JoinU = 1;
this->JoinV = 1;
this->TwistU = 1;
this->TwistV = 1;
this->ClockwiseOrdering = 1;
this->DerivativesAvailable = 1;
}
vtkParametricCrossCap::~vtkParametricCrossCap()
{
}
void vtkParametricCrossCap::Evaluate(double uvw[3], double Pt[3], double Duvw[9])
{
double u = uvw[0];
double v = uvw[1];
double *Du = Duvw;
double *Dv = Duvw + 3;
double cu = cos(u);
double su = sin(u);
double cv = cos(v);
double c2v = cos(2 * v);
double sv = sin(v);
double s2v = sin(2 * v);
// The point
Pt[0] = cu * s2v;
Pt[1] = su * s2v;
Pt[2] = cv * cv - cu * cu * sv * sv;
//The derivatives are:
Du[0] = -Pt[1];
Du[1] = Pt[0];
Du[2] = 2 * cu * su * sv * sv;
Dv[0] = 2 * cu * c2v;
Dv[1] = 2 * su * c2v;
Dv[2] = -2 * cv * sv * (1 + cu * cu);
}
double vtkParametricCrossCap::EvaluateScalar(double *, double *, double *)
{
return 0;
}
void vtkParametricCrossCap::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricCrossCap.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.
=========================================================================*/
// .NAME vtkParametricCrossCap - Generate a cross-cap.
// .SECTION Description
// vtkParametricCrossCap generates a cross-cap which is a
// non-orientable self-intersecting single-sided surface.
// This is one possible image of a projective plane in three-space.
// .SECTION Thanks
// Andrew Maclean a.maclean@cas.edu.au for
// creating and contributing the class.
//
#ifndef __vtkParametricCrossCap_h
#define __vtkParametricCrossCap_h
#include "vtkParametricFunction.h"
class VTK_COMMON_EXPORT vtkParametricCrossCap : public vtkParametricFunction
{
public:
vtkTypeRevisionMacro(vtkParametricCrossCap,vtkParametricFunction);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct a cross-cap with the following parameters:
// MinimumU = 0, MaximumU = Pi,
// MinimumV = 0, MaximumV = Pi,
// JoinU = 1, JoinV = 1,
// TwistU = 1, TwistV = 1;
// ClockwiseOrdering = 1,
// DerivativesAvailable = 1
static vtkParametricCrossCap *New();
// Description
// Return the parametric dimension of the class.
virtual int GetDimension() {return 2;}
// Description:
// A cross-cap is a self intersecting single-sided surface.
//
// The parametric form of the equations for a cross cap are:
// - x = cos(u) * sin(2*v)
// - y = sin(u) * sin(2*v)
// - z = cos(v) * cos(v) - cos(u) * cos(u) * sin(v) * sin(v)
//
// for: 0 <= u <= PI and 0 <= v <= PI
//
// Derivatives are:
// - d(x(u,v))/du = -sin(u) * sin(2*v) = -y
// - d(x(u,v))/dv = 2 * cos(u) * cos(2*v)
// - d(y(u,v))/du = cos(u) * sin(2*v) = x
// - d(y(u,v))/dv = 2 * sin(u) * cos(2*v)
// - d(z(u,v))/du = 2 * cos(u) * sin(u) * sin(v) * sin(v)
// - d(z(u,v))/dv = -2 * cos(v) * sin(v) * (1 + cos(u) * cos(u))
//
// Let Du = (dx/du, dy/du, dz/du)
//
// Let Dv = (dx/dv, dy/dv, dz/dv)
//
// Then the normal n = Du X Dv
//
//
// This function performs the mapping fn(u,v)->(x,y,x), returning it
// as Pt. It also returns the partial derivatives Du and Dv.
// Pt = (x, y, z), Du = (dx/du, dy/du, dz/du), Dv = (dx/dv, dy/dv, dz/dv)
void Evaluate(double uvw[3], double Pt[3], double Duvw[9]);
// Description:
// Calculate a user defined scalar using one or all of uvw,Pt,Duvw.
//
// uvw are the parameters with Pt being the the cartesian point,
// Duvw are the derivatives of this point with respect to u, v and w.
// Pt, Duvw are obtained from Evaluate().
//
// This function is only called if the ScalarMode has the value
// vtkParametricTriangulator::userDefined
//
// If the user does not need to calculate a scalar, then the
// instantiated function should return zero.
//
double EvaluateScalar(double uvw[3], double Pt[3], double Duvw[9]);
protected:
vtkParametricCrossCap();
~vtkParametricCrossCap();
private:
vtkParametricCrossCap(const vtkParametricCrossCap&); // Not implemented.
void operator=(const vtkParametricCrossCap&); // Not implemented.
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricDini.cxx
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.
=========================================================================*/
#include "vtkParametricDini.h"
#include "vtkObjectFactory.h"
#include "vtkMath.h"
vtkCxxRevisionMacro(vtkParametricDini, "1.1");
vtkStandardNewMacro(vtkParametricDini);
vtkParametricDini::vtkParametricDini()
{
// Preset triangulation parameters
this->MinimumU = 0;
this->MinimumV = 0.001;
this->MaximumU = 4*vtkMath::Pi();
this->MaximumV = 2.0;
this->JoinU = 0;
this->JoinV = 0;
this->TwistU = 0;
this->TwistV = 0;
this->ClockwiseOrdering = 1;
this->DerivativesAvailable = 1;
this->A = 1.0;
this->B = 0.2;
}
vtkParametricDini::~vtkParametricDini()
{
}
void vtkParametricDini::Evaluate(double uvw[3], double Pt[3], double Duvw[9])
{
double u = uvw[0];
double v = uvw[1];
double *Du = Duvw;
double *Dv = Duvw + 3;
double cu = cos(u);
double cv = cos(v);
double su = sin(u);
double sv = sin(v);
// The point
Pt[0] = this->A*cu*sv;
Pt[1] = this->A*su*sv;
Pt[2] = this->A*(cos(v)+log(tan((v/2))))+this->B*u;
//The derivatives are:
Du[0] = -Pt[1];
Dv[0] = this->A*cu*cv;
Du[1] = Pt[0];
Dv[1] = this->A*su*cv;
Du[2] = this->B;
double tv2 = tan(0.5*v);
if ( tv2 != 0 )
Dv[2] = this->A*(-sv+(0.5+0.5*tv2*tv2)/tv2);
else
Dv[2] = this->A*(-sv+(0.5+0.5*tv2*tv2)/0.0001); // Avoid division by zero.
}
double vtkParametricDini::EvaluateScalar(double *, double *, double *)
{
return 0;
}
void vtkParametricDini::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "A: " << this->A << "\n";
os << indent << "B: " << this->B << "\n";
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricDini.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.
=========================================================================*/
// .NAME vtkParametricDini - Generate Dini's surface.
// .SECTION Description
// vtkParametricDini generates Dini's surface.
// Dini's surface is a surface that posesses constant negative
// Gaussian curvature
// .SECTION Thanks
// Andrew Maclean a.maclean@cas.edu.au for
// creating and contributing the class.
//
#ifndef __vtkParametricDini_h
#define __vtkParametricDini_h
#include "vtkParametricFunction.h"
class VTK_COMMON_EXPORT vtkParametricDini : public vtkParametricFunction
{
public:
vtkTypeRevisionMacro(vtkParametricDini,vtkParametricFunction);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct Dini's surface with the following parameters:
// MinimumU = 0, MaximumU = 4*Pi,
// MinimumV = 0.001, MaximumV = 2,
// JoinU = 0, JoinV = 0,
// TwistU = 0, TwistV = 0,
// ClockwiseOrdering = 1,
// DerivativesAvailable = 1
// A = 1, B = 0.2
static vtkParametricDini *New();
// Description
// Return the parametric dimension of the class.
virtual int GetDimension() {return 2;}
// Description:
// Set/Get the scale factor.
// Default = 1.
vtkSetMacro(A,double);
vtkGetMacro(A,double);
// Description:
// Set/Get the scale factor.
// Default = 0.2
vtkSetMacro(B,double);
vtkGetMacro(B,double);
// Description:
// Dini's surface is an example of a surface that posesses
// constant negative Gaussian curvature.
//
// A parametric representation of Dini's surface
// Define:
// - X(u,v) = a*cos(u)*sin(v)
// - Y(u,v) = a*sin(u)*sin(v)
// - Z(u,v) = a*(cos(v)+log(tan((v/2))))+b*u
//
// Then
// - S(u,v) = (X(u,v),Y(u,v),Z(u,v)) defines the surface.
//
// The derivatives are given by:
// - d(X(u,v)/du = -Y(u,v)
// - d(X(u,v)/dv = a*cos(u)*cos(v)
// - d(Y(u,v)/du = X(u,v)
// - d(Y(u,v)/dv = a*sin(u)*cos(v)
// - d(Z(u,v)/du = b
// - d(Z(u,v)/dv = a*(-sin(v)+(1/2+1/2*tan(1/2*v)^2)/tan(1/2*v))
//
// Let Du = (dy/du, dy/du, dy/du)
//
// Let Dv = (dx/dv, dy/dv, dz/dv)
//
// Then the normal n = Du X Dv
//
// Warning: This function may fail if tan(1/2*v) = 0;
//
// This function performs the mapping fn(u,v)->(x,y,x), returning it
// as Pt. It also returns the partial derivatives Du and Dv.
// Pt = (x, y, z), Du = (dx/du, dy/du, dz/du), Dv = (dx/dv, dy/dv, dz/dv)
void Evaluate(double uvw[3], double Pt[3], double Duvw[9]);
// Description:
// Calculate a user defined scalar using one or all of uvw,Pt,Duvw.
//
// uvw are the parameters with Pt being the the cartesian point,
// Duvw are the derivatives of this point with respect to u, v and w.
// Pt, Duvw are obtained from Evaluate().
//
// This function is only called if the ScalarMode has the value
// vtkParametricTriangulator::userDefined
//
// If the user does not need to calculate a scalar, then the
// instantiated function should return zero.
//
double EvaluateScalar(double uvw[3], double Pt[3], double Duvw[9]);
protected:
vtkParametricDini();
~vtkParametricDini();
// Variables
double A;
double B;
private:
vtkParametricDini(const vtkParametricDini&); // Not implemented.
void operator=(const vtkParametricDini&); // Not implemented.
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricEnneper.cxx
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.
=========================================================================*/
#include "vtkParametricEnneper.h"
#include "vtkObjectFactory.h"
#include "vtkMath.h"
vtkCxxRevisionMacro(vtkParametricEnneper, "1.1");
vtkStandardNewMacro(vtkParametricEnneper);
vtkParametricEnneper::vtkParametricEnneper()
{
// Preset triangulation parameters
this->MinimumU = -2.0;
this->MinimumV = -2.0;
this->MaximumU = 2.0;
this->MaximumV = 2.0;
this->JoinU = 0;
this->JoinV = 0;
this->TwistU = 0;
this->TwistV = 0;
this->ClockwiseOrdering = 1;
this->DerivativesAvailable = 1;
}
vtkParametricEnneper::~vtkParametricEnneper()
{
}
void vtkParametricEnneper::Evaluate(double uvw[3], double Pt[3], double Duvw[9])
{
double u = uvw[0];
double v = uvw[1];
double *Du = Duvw;
double *Dv = Duvw + 3;
// The point
Pt[0] = u-u*u*u/3+u*v*v;
Pt[1] = v-v*v*v/3+u*u*v;
Pt[2] = u*u-v*v;
//The derivatives are:
Du[0] = 1-u*u+v*v;
Dv[0] = 2*u*v;
Du[1] = 2*u*v;
Dv[1] = 1-v*v+u*u;
Du[2] = 2*u;
Dv[2] = -2*v;
}
double vtkParametricEnneper::EvaluateScalar(double *, double *, double *)
{
return 0;
}
void vtkParametricEnneper::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParametricEnneper.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.
=========================================================================*/
// .NAME vtkParametricEnneper - Generate Enneper's surface.
// .SECTION Description
// vtkParametricEnneper generates Enneper's surface.
// Enneper's surface is a a self-intersecting minimal surface
// posessing constant negative Gaussian curvature
// .SECTION Thanks
// Andrew Maclean a.maclean@cas.edu.au for
// creating and contributing the class.
//
#ifndef __vtkParametricEnneper_h
#define __vtkParametricEnneper_h
#include "vtkParametricFunction.h"
class VTK_COMMON_EXPORT vtkParametricEnneper : public vtkParametricFunction
{
public:
vtkTypeRevisionMacro(vtkParametricEnneper,vtkParametricFunction);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct Enneper's surface with the following parameters:
// MinimumU = -2, MaximumU = 2,
// MinimumV = -2, MaximumV = 2,
// JoinU = 0, JoinV = 0,
// TwistU = 0, TwistV = 0,
// ClockwiseOrdering = 1,
// DerivativesAvailable = 1
static vtkParametricEnneper *New();
// Description
// Return the parametric dimension of the class.
virtual int GetDimension() {return 2;}
// Description:
// Enneper's surface is an example of a self-intersecting minimal
// surface. Enneper's surface is a well-known minimal surface. Though
// it has a fairly uncomplicated parameterization , it is somewhat
// hard to visualize because of its self-intersections. The plot suggests
// the self-intersections exhibited by the surface, but the plot range
// has been kept small enough that the structure of the surface's center
// is also visible.
//
// Note that the self-intersection curves are subsets of the planes
// y = 0 and x = 0. The surface is a special case of the more general Enneper's
// surface of degree n. These surfaces tend to be even more complicated and
// difficult to visualize.
//
// A parametric representation of Enneper's surface
// Define:
// - X(u,v) = u-u^3/3+u*v^2
// - Y(u,v) = v-v^3/3+v*u^2
// - Z(u,v) = u^2-v^2
//
// Then
// - S(u,v) = (X(u,v),Y(u,v),Z(u,v)) defines the surface.
//
// The derivatives are given by:
// - d(X(u,v)/du = 1-u^2+v^2
// - d(X(u,v)/dv = 2*u*v
// - d(Y(u,v)/du = 2*u*v
// - d(Y(u,v)/dv = 1-v^2+u^2
// - d(Z(u,v)/du = 2*u
// - d(Z(u,v)/dv = -2*v
//
// Let Du = (dy/du, dy/du, dy/du)
//
// Let Dv = (dx/dv, dy/dv, dz/dv)
//
// Then the normal n = Du X Dv
//
// This function performs the mapping fn(u,v)->(x,y,x), returning it
// as Pt. It also returns the partial derivatives Du and Dv.
// Pt = (x, y, z), Du = (dx/du, dy/du, dz/du), Dv = (dx/dv, dy/dv, dz/dv)
void Evaluate(double uvw[3], double Pt[3], double Duvw[9]);
// Description:
// Calculate a user defined scalar using one or all of uvw,Pt,Duvw.
//
// uv are the parameters with Pt being the the cartesian point,
// Duvw are the derivatives of this point with respect to u, v and w.
// Pt, Duvw are obtained from Evaluate().
//
// This function is only called if the ScalarMode has the value
// vtkParametricTriangulator::userDefined
//
// If the user does not need to calculate a scalar, then the
// instantiated function should return zero.
//
double EvaluateScalar(double uvw[3], double Pt[3], double Duvw[9]);
protected:
vtkParametricEnneper();
~vtkParametricEnneper();
private:
vtkParametricEnneper(const vtkParametricEnneper&); // Not implemented.
void operator=(const vtkParametricEnneper&); // Not implemented.
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment