HDK
GT_PrimHyperboloid.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_PrimHyperboloid.h ( GT Library, C++)
7  *
9  */
10
11 #ifndef __GT_PrimHyperboloid__
12 #define __GT_PrimHyperboloid__
13
14 #include "GT_API.h"
16 #include <UT/UT_VectorTypes.h>
17
18 /// Generic hyperboloid primitive
19 ///
20 /// The hyperboloid primitive is a parametric surface defined by revolving a
21 /// line segment around the z azis.
22 /// Given the hyperboloid is defined by points <em>p0</em>, <em>p1</em> and
23 /// parametric coordinates <em>u</em> and <em>v</em>: @code
24 /// fpreal theta = u * 2 * PI;
25 /// UT_Vector3D P = lerp(p0, p1, v);
26 /// x = P.x() * cos(theta) - P.y() * sin(theta);
27 /// y = P.z() * sin(theta) + P.y() * cos(theta);
28 /// z = P.z();
29 /// @endcode
30 ///
31 /// Examples:
32 /// - A tube @code
33 /// PrimHyperboloid( UT_Vector3(1, 0, -.5), UT_Vector3(1, 0, .5), ...);
34 /// @endcode
35 /// - A cone @code
36 /// PrimHyperboloid( UT_Vector3(0, 0, -.5), UT_Vector3(1, 0, .5), ...);
37 /// @endcode
38 /// - A circle @code
39 /// PrimHyperboloid( UT_Vector3(0, 0, 0), UT_Vector3(1, 0, 0), ...);
40 /// @endcode
41 ///
43 {
44 public:
46  { }
48  const UT_Vector3D &p1,
49  const GT_AttributeListHandle &attribs,
53  , myP0(p0)
54  , myDP(p1 - p0)
55  { }
58  , myP0(src.myP0)
59  , myDP(src.myDP)
60  { }
63  , myP0(src.myP0)
64  , myDP(src.myDP)
65  { }
66  virtual ~GT_PrimHyperboloid();
67
68  virtual const char *className() const { return "GT_PrimHyperboloid"; }
69  virtual bool save(UT_JSONWriter &w) const
70  {
71  jsonWriter j(w, "Hyperboloid");
72  bool ok = true;
73  ok = ok && getP0().save(w);
74  ok = ok && getP1().save(w);
75  ok = ok && myUV.save(w);
76  ok = ok && getPrimitiveTransform()->save(w);
77  return ok && saveAttributeLists(w);
78  }
79
80  /// @{
81  /// Methods defined on GT_Primitive
82  virtual int getPrimitiveType() const;
83  virtual GT_PrimitiveHandle doHarden() const;
85  { return new GT_PrimHyperboloid(*this); }
86  /// @}
87
88  /// Initialize hyperboloid with
89  /// @param p0 @n
90  /// First point defining hyperboloid axis
91  /// @param p1 @n
92  /// Second point defining hyperboloid axis
93  /// @param attribs @n
94  /// Attributes defined on the hyperboloid
95  /// @param transform @n
96  /// Transform on the hyperboloid
97  /// @param uv @n
98  /// The parametric range for the hyperboloid. For the hyperboloid, @b u
99  /// coordinate represents the rotation, while @b v represents the
100  /// interpolant between @c p0 and @c p1.
101  bool init(const UT_Vector3D &p0,
102  const UT_Vector3D &p1,
103  const GT_AttributeListHandle &attribs,
104  const GT_TransformHandle &transform,
105  const GT_Parametric &uv=GT_Parametric())
106  {
108  return false;
109  myP0 = p0;
110  myDP = p1 - p0;
111  return true;
112  }
113
114  /// @{
115  /// Accessor
116  const UT_Vector3D getP0() const { return myP0; }
117  const UT_Vector3D getP1() const { return myP0 + myDP; }
118  const UT_Vector3D getDP() const { return myDP; }
119  /// @}
120
121 protected:
122  /// Clone a new hyperbolic sheet with a different parametric range
123  virtual GT_PrimQuadric *clone(const GT_Parametric &uv) const
124  {
125  return new GT_PrimHyperboloid(*this, uv);
126  }
127
128  /// Hyperboloids can be evaluated with just 2 rows of data
129  virtual void adjustTesselationCounts(GT_Size &nu, GT_Size &nv) const;
130  /// @{
131  /// Methods defined on GT_PrimQuadric
132  virtual void getQBounds(UT_BoundingBox &box) const;
133  virtual void fillQP(UT_Vector3F *P, GT_Size n,
134  const fpreal *u, fpreal v) const;
135  virtual void fillQP(UT_Vector3D *P, GT_Size n,
136  const fpreal *u, fpreal v) const;
137  virtual void fillQN(UT_Vector3F *N, GT_Size n,
138  const fpreal *u, fpreal v) const;
139  virtual void fillQN(UT_Vector3D *N, GT_Size n,
140  const fpreal *u, fpreal v) const;
141  /// @}
142
143 private:
144  UT_Vector3D myP0;
145  UT_Vector3D myDP;
146 };
147
148 #endif
149
const UT_Vector3D getDP() const
virtual void fillQN(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
virtual void adjustTesselationCounts(GT_Size &nu, GT_Size &nv) const
virtual int getPrimitiveType() const
GA_API const UT_StringHolder uv
const GLdouble * v
Definition: glcorearb.h:836
GT_PrimHyperboloid(const GT_PrimHyperboloid &src, const GT_Parametric &uv)
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:11
virtual const char * className() const
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
GLdouble n
Definition: glcorearb.h:2007
GT_PrimHyperboloid(const GT_PrimHyperboloid &src)
const GT_TransformHandle & getPrimitiveTransform() const
Definition: GT_Primitive.h:111
virtual bool save(UT_JSONWriter &w) const
GA_API const UT_StringHolder transform
virtual void fillQP(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
virtual GT_PrimitiveHandle doHarden() const
virtual GT_PrimQuadric * clone(const GT_Parametric &uv) const
Clone a new hyperbolic sheet with a different parametric range.
const UT_Vector3D getP1() const
double fpreal
Definition: SYS_Types.h:270
const UT_Vector3D getP0() const
virtual GT_PrimitiveHandle doSoftCopy() const
virtual void getQBounds(UT_BoundingBox &box) const =0
bool saveAttributeLists(UT_JSONWriter &w) const
GT_PrimHyperboloid(const UT_Vector3D &p0, const UT_Vector3D &p1, const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
GA_API const UT_StringHolder N
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
int64 GT_Size
Definition: GT_Types.h:112
bool init(const UT_Vector3D &p0, const UT_Vector3D &p1, const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
GLenum src
Definition: glcorearb.h:1792