HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimTube.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_PrimTube.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimTube__
12 #define __GT_PrimTube__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 #include "GT_Transform.h"
17 #include <SYS/SYS_Math.h>
18 
19 /// @brief A tapered tube primitive (mapping to GEO_PrimTube)
20 ///
21 /// The tube primitive represents a tapered tube along the @b Z axis. Unlike
22 /// the GEO counterpart, this primitive's axis is aligned along the Z axis (not
23 /// the Y axis).
25 {
26 public:
27  /// Default constructor
29  {}
30  /// Useful constructor
33  fpreal taper,
34  bool caps)
35  : myTaper(SYSmax(0.0, taper))
36  , myCaps(caps)
37  , myAttributes(attribs)
38  , GT_Primitive()
39  { setPrimitiveTransform(transform); }
40  /// Copy constructor
42  : GT_Primitive(src)
43  , myTaper(src.myTaper)
44  , myCaps(src.myCaps)
45  , myAttributes(src.myAttributes)
46  {
47  }
48  /// Destructor
49  ~GT_PrimTube() override;
50 
51  const char *className() const override { return "GT_PrimTube"; }
52  bool save(UT_JSONWriter &w) const override;
53 
54  /// @{
55  /// Methods defined on GT_Primitive
56  int getPrimitiveType() const override;
57  /// @}
58 
59  /// Initialize a tube with
60  /// - @c attribs @n
61  /// Attributes defined on the tube
62  /// - @c transform @n
63  /// The transform attribute list should contain a single transform
64  /// representing the 4x4 transform of the tube.
65  bool init(const GT_AttributeListHandle &attribs,
67  fpreal taper,
68  bool caps)
69  {
70  myTaper = SYSmax(0.0, taper);
71  myCaps = caps;
72  myAttributes = attribs;
73  setPrimitiveTransform(transform);
74  return true;
75  }
76 
77  /// Get a tesselation of a tube with a given set of refinement
78  /// parameters.
79  static GT_PrimitiveHandle makePolygonMesh(const GT_RefineParms *parms,
80  fpreal taper = 1.0f);
81 
82  /// @{
83  /// Accessors
85  { return myAttributes; }
86  const fpreal &getTaper() const
87  { return myTaper; }
88  const bool &getCaps() const
89  { return myCaps; }
90  /// @}
91 
92  /// @{
93  /// Access attributes
95  { return myAttributes; }
96  /// @}
97 
98  /// @{
99  /// Methods defined on GT_Primitive
100  void enlargeBounds(UT_BoundingBox boxes[],
101  int nsegments) const override;
102  int getMotionSegments() const override;
103  int64 getMemoryUsage() const override;
104  bool refine(GT_Refine &refiner,
105  const GT_RefineParms *parms) const override;
106  GT_PrimitiveHandle doHarden() const override;
108  { return new GT_PrimTube(*this); }
109  /// @}
110 
111  /// Convenience method to refine to a polygon mesh
112  GT_PrimitiveHandle refineToPolygonMesh(
113  const GT_RefineParms *parms) const;
114 
115 protected:
118  bool myCaps;
119 };
120 
121 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1570
virtual int getMotionSegments() const =0
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
virtual int getPrimitiveType() const
A tapered tube primitive (mapping to GEO_PrimTube)
Definition: GT_PrimTube.h:24
GT_PrimTube(const GT_PrimTube &src)
Copy constructor.
Definition: GT_PrimTube.h:41
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
GT_AttributeListHandle myAttributes
Definition: GT_PrimTube.h:116
const bool & getCaps() const
Definition: GT_PrimTube.h:88
GLfloat f
Definition: glcorearb.h:1926
GT_PrimTube()
Default constructor.
Definition: GT_PrimTube.h:28
long long int64
Definition: SYS_Types.h:116
const char * className() const override
Definition: GT_PrimTube.h:51
GA_API const UT_StringHolder transform
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle doHarden() const
virtual int64 getMemoryUsage() const =0
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
void setPrimitiveTransform(const GT_TransformHandle &x)
Set the transform for a the primitive.
Definition: GT_Primitive.h:114
GT_PrimitiveHandle doSoftCopy() const override
Definition: GT_PrimTube.h:107
fpreal64 fpreal
Definition: SYS_Types.h:277
GT_PrimTube(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, fpreal taper, bool caps)
Useful constructor.
Definition: GT_PrimTube.h:31
virtual bool save(UT_JSONWriter &w) const
const GT_AttributeListHandle & getDetailAttributes() const override
Definition: GT_PrimTube.h:94
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, fpreal taper, bool caps)
Definition: GT_PrimTube.h:65
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
const GT_AttributeListHandle & getAttributes() const
Definition: GT_PrimTube.h:84
fpreal myTaper
Definition: GT_PrimTube.h:117
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
const fpreal & getTaper() const
Definition: GT_PrimTube.h:86
GLenum src
Definition: glcorearb.h:1793