1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkParametricTorus.cxx
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 #include "vtkParametricTorus.h"
16 #include "vtkObjectFactory.h"
17 #include "vtkMath.h"
18
19 vtkStandardNewMacro(vtkParametricTorus);
20
21 //----------------------------------------------------------------------------
vtkParametricTorus()22 vtkParametricTorus::vtkParametricTorus() :
23 RingRadius(1.0), CrossSectionRadius(0.5)
24 {
25 this->MinimumU = 0;
26 this->MaximumU = 2 * vtkMath::Pi();
27 this->MinimumV = 0;
28 this->MaximumV = 2 * vtkMath::Pi();
29
30 this->JoinU = 1;
31 this->JoinV = 1;
32 this->TwistU = 0;
33 this->TwistV = 0;
34 this->ClockwiseOrdering = 0;
35 this->DerivativesAvailable = 1;
36 }
37
38 //----------------------------------------------------------------------------
39 vtkParametricTorus::~vtkParametricTorus() = default;
40
41 //----------------------------------------------------------------------------
Evaluate(double uvw[3],double Pt[3],double Duvw[9])42 void vtkParametricTorus::Evaluate(double uvw[3], double Pt[3],
43 double Duvw[9])
44 {
45 double u = uvw[0];
46 double v = uvw[1];
47 double *Du = Duvw;
48 double *Dv = Duvw + 3;
49
50 double cu = cos(u);
51 double su = sin(u);
52 double cv = cos(v);
53 double sv = sin(v);
54 double t = this->RingRadius + this->CrossSectionRadius * cv;
55
56 // The point
57 //Pt[0] = t * cu;
58 //Pt[1] = t * su;
59 Pt[0] = t * su;
60 Pt[1] = t * cu;
61 Pt[2] = this->CrossSectionRadius * sv;
62
63 //The derivatives are:
64 Du[0] = t * cu;
65 Du[1] = -t * su;
66 Du[2] = 0;
67 Dv[0] = -this->CrossSectionRadius * sv * su;
68 Dv[1] = -this->CrossSectionRadius * sv * cu;
69 Dv[2] = this->CrossSectionRadius * cv;
70 }
71
72 //----------------------------------------------------------------------------
EvaluateScalar(double * vtkNotUsed (uv[3]),double * vtkNotUsed (Pt[3]),double * vtkNotUsed (Duv[9]))73 double vtkParametricTorus::EvaluateScalar(double* vtkNotUsed(uv[3]),
74 double* vtkNotUsed(Pt[3]),
75 double* vtkNotUsed(Duv[9]))
76 {
77 return 0;
78 }
79
80 //----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)81 void vtkParametricTorus::PrintSelf(ostream& os, vtkIndent indent)
82 {
83 this->Superclass::PrintSelf(os, indent);
84
85 os << indent << "Ring Radius: " << this->RingRadius << "\n";
86 os << indent << "Cross-Sectional Radius: " << this->CrossSectionRadius
87 << "\n";
88 }
89