HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GT_PrimCircle() override;
55 
56  const char *className() const override { return "GT_PrimCircle"; }
57  bool save(UT_JSONWriter &w) const override
58  { return saveQuadric(w, "Circle"); }
59  GT_PrimitiveHandle doSoftCopy() const override
60  { return new GT_PrimCircle(*this); }
61  GT_PrimitiveHandle doHarden() const override;
62 
63  /// @{
64  /// Methods defined on GT_Primitive
65  int getPrimitiveType() const override;
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 override;
72 
73  GT_PrimitiveHandle refineToCurve(const GT_RefineParms *parms) const;
74 
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  GT_PrimQuadric *clone(const GT_Parametric &uv) const override
111  {
112  return new GT_PrimCircle(*this, uv);
113  }
114  /// @{
115  /// Methods defined on GT_PrimQuadric
116  void getQBounds(UT_BoundingBox &box) const override;
117  void fillQP(UT_Vector3F *P, GT_Size n,
118  const fpreal *u, fpreal v) const override;
119  void fillQP(UT_Vector3D *P, GT_Size n,
120  const fpreal *u, fpreal v) const override;
121  void fillQN(UT_Vector3F *P, GT_Size n,
122  const fpreal *u, fpreal v) const override;
123  void fillQN(UT_Vector3D *P, GT_Size n,
124  const fpreal *u, fpreal v) const override;
126  GT_Size &nu, GT_Size &nv) const override;
127  /// @}
128 };
129 
130 #endif
virtual void fillQN(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
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:837
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
GT_PrimQuadric * clone(const GT_Parametric &uv) const override
Create a split primitive.
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
Definition: GT_PrimCircle.h:85
GT_PrimitiveHandle doSoftCopy() const override
Definition: GT_PrimCircle.h:59
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.
int64 GT_Size
Definition: GT_Types.h:128
fpreal64 fpreal
Definition: SYS_Types.h:277
GT_PrimCircle(const GT_PrimCircle &src)
Copy constructor.
Definition: GT_PrimCircle.h:49
virtual void getQBounds(UT_BoundingBox &box) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GT_PrimCircle()
Default constructor (full unit circle in the xz plane, no attributes)
Definition: GT_PrimCircle.h:35
bool save(UT_JSONWriter &w) const override
Definition: GT_PrimCircle.h:57
const char * className() const override
Definition: GT_PrimCircle.h:56
GT_PrimCircle(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
Useful constructor.
Definition: GT_PrimCircle.h:38
GLenum src
Definition: glcorearb.h:1793