HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_PrimCircle.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_PrimCircle.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimCircle__
12 #define __GT_PrimCircle__
13 
14 #include "GT_API.h"
15 #include "GT_PrimQuadric.h"
16 #include "GT_Parametric.h"
17 #include "GT_Transform.h"
18 
19 /// @brief A circle primitive
20 ///
21 /// The circle primitive represents a parametric patch of a circle/disk
22 /// primitive in the XY plane.
23 /// The circle is parametrized so @c u (0 to 1) represents radial
24 /// angle, while @c v (0 to 1) is goes from the center to the circumference.
25 /// That is: @code
26 /// theta = u * 2*PI
27 /// x = cos(u)*v
28 /// y = sin(u)*v
29 /// z = 0
30 /// @endcode
32 {
33 public:
34  /// Default constructor (full unit circle in the xz plane, no attributes)
36  {}
37  /// Useful constructor
41  : GT_PrimQuadric(attribs, transform, uv)
42  { }
43  /// Copy (but with a different parametric range)
45  : GT_PrimQuadric(src, uv)
46  {
47  }
48  /// Copy constructor
50  : GT_PrimQuadric(src)
51  {
52  }
53  /// Destructor
54  virtual ~GT_PrimCircle();
55 
56  virtual const char *className() const { return "GT_PrimCircle"; }
57  virtual bool save(UT_JSONWriter &w) const
58  { return saveQuadric(w, "Circle"); }
60  { return new GT_PrimCircle(*this); }
61  virtual GT_PrimitiveHandle doHarden() const;
62 
63  /// @{
64  /// Methods defined on GT_Primitive
65  virtual int getPrimitiveType() const;
66  /// @}
67 
68  /// When creating a polygon mesh from a circle, we can make a triangle fan
69  /// instead of a mesh.
71  const GT_RefineParms *parms) const;
72 
73  GT_PrimitiveHandle refineToCurve(
74  const GT_RefineParms *parms) const;
75  /// Initialize a circle with
76  /// @param attribs @n
77  /// Attributes defined on the circle
78  /// @param transform @n
79  /// The transform attribute list should contain a single transform
80  /// representing the 4x4 transform of the circle.
81  /// @param uv @n
82  /// The parametric range for the circle.
83  /// The circle is parametrized so @c u (0 to 1) represents radial angle,
84  /// while @c v (0 to 1) is goes from the center to the circumference.
85  bool init(const GT_AttributeListHandle &attribs,
86  const GT_TransformHandle &transform,
87  const GT_Parametric &uv)
88  {
89  if (!GT_PrimQuadric::init(attribs, transform, uv))
90  return false;
91  return true;
92  }
93 
94  /// Static method to compute bounds for a circle
95  static void computeCircleBounds(UT_BoundingBox &box,
96  const GT_Parametric &uv);
97 
98  /// Get a tesselation of a full circle with a given set of refinement
99  /// parameters.
100  static GT_PrimitiveHandle makePolygonMesh(const GT_RefineParms *parms,
102  fpreal axis_trans = 0.0f,
103  fpreal radius = 1.0f);
104  static GT_PrimitiveHandle makeCurve(const GT_RefineParms *parms,
106  fpreal axis_trans = 0.0f,
107  fpreal radius = 1.0f);
108 
109 protected:
110  virtual GT_PrimQuadric *clone(const GT_Parametric &uv) const
111  {
112  return new GT_PrimCircle(*this, uv);
113  }
114  /// @{
115  /// Methods defined on GT_PrimQuadric
116  virtual void getQBounds(UT_BoundingBox &box) const;
117  virtual void fillQP(UT_Vector3F *P, GT_Size n,
118  const fpreal *u, fpreal v) const;
119  virtual void fillQP(UT_Vector3D *P, GT_Size n,
120  const fpreal *u, fpreal v) const;
121  virtual void fillQN(UT_Vector3F *P, GT_Size n,
122  const fpreal *u, fpreal v) const;
123  virtual void fillQN(UT_Vector3D *P, GT_Size n,
124  const fpreal *u, fpreal v) const;
125  virtual void adjustTesselationCounts(GT_Size &nu, GT_Size &nv) const;
126  /// @}
127 };
128 
129 #endif
virtual void fillQN(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
virtual GT_PrimQuadric * clone(const GT_Parametric &uv) const
Create a split primitive.
A circle primitive.
Definition: GT_PrimCircle.h:31
virtual void adjustTesselationCounts(GT_Size &nu, GT_Size &nv) const
GT_PrimCircle(const GT_PrimCircle &src, const GT_Parametric &uv)
Copy (but with a different parametric range)
Definition: GT_PrimCircle.h:44
virtual int getPrimitiveType() const
GA_API const UT_StringHolder uv
const GLdouble * v
Definition: glcorearb.h:836
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:11
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)
virtual bool save(UT_JSONWriter &w) const
Definition: GT_PrimCircle.h:57
GLdouble n
Definition: glcorearb.h:2007
GLfloat f
Definition: glcorearb.h:1925
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
Definition: GT_PrimCircle.h:85
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
bool saveQuadric(UT_JSONWriter &w, const char *name) const
virtual GT_PrimitiveHandle refineToPolygonMesh(const GT_RefineParms *parms) const
Convenience method to refine to a polygon mesh.
double fpreal
Definition: SYS_Types.h:269
GT_PrimCircle(const GT_PrimCircle &src)
Copy constructor.
Definition: GT_PrimCircle.h:49
virtual void getQBounds(UT_BoundingBox &box) const =0
virtual GT_PrimitiveHandle doSoftCopy() const
Definition: GT_PrimCircle.h:59
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
int64 GT_Size
Definition: GT_Types.h:109
GT_PrimCircle()
Default constructor (full unit circle in the xz plane, no attributes)
Definition: GT_PrimCircle.h:35
GT_PrimCircle(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
Useful constructor.
Definition: GT_PrimCircle.h:38
virtual const char * className() const
Definition: GT_PrimCircle.h:56
GLenum src
Definition: glcorearb.h:1792