HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_GEOPrimitive.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_GEOPrimitive.h ( GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_GEOPrimitive__
12 #define __GT_GEOPrimitive__
13 
14 #include "GT_API.h"
15 #include <UT/UT_Assert.h>
16 #include <UT/UT_BoundingBox.h>
17 #include <GA/GA_Types.h>
18 #include <GU/GU_DetailHandle.h>
19 #include "GT_Primitive.h"
20 #include "GT_Handles.h"
21 
22 class GA_PrimitiveTypeId;
23 class GEO_Primitive;
24 class GEO_Primitive;
25 class GEO_Quadric;
26 class GEO_Curve;
27 class GEO_Face;
28 class GEO_Hull;
29 class GEO_TPSurf;
30 class GEO_PrimTube;
31 class GEO_PrimParticle;
32 class GT_GEOPrimCollect;
33 
34 /// Base class for many of the GEO_Primitive objects
36 {
37 public:
38  /// GT holds onto GU_DetailHandle objects. However, it's possible for a
39  /// user (SOP) to change the GU_Detail stored in the GU_DetailHandle
40  /// without changing the GU_DetailHandle. This can leave stale primitive
41  /// pointers. The GEOPrimitivePair object has a method to refresh the
42  /// pointer to ensure it remains valid.
44  {
45  public:
47  { init(nullptr); }
49  { init(prim); }
51  { init(gdh, idx); }
52 
53  void init(const GEO_Primitive *prim);
54  void init(const GU_ConstDetailHandle &gdh, GA_Index idx);
55  void init(const GU_Detail *gdp, GA_Index idx);
56 
57  /// @{
58  /// Reports true if the primitive pointer has changed
59  bool update(const GU_ConstDetailHandle &dtl);
60  bool update(const GU_Detail *gdp);
61  /// @}
62 
63  const GEO_Primitive *primitive() const { return myPrim; }
64  template <typename T> const T *primitiveAs() const
65  { return UTverify_cast<const T *>(myPrim); }
66  GA_Index mapIndex() const { return myMapIndex; }
67 
68  private:
69  const GEO_Primitive *myPrim;
70  GA_Index myMapIndex;
71  };
72 
74  const GEO_Primitive *const*primlist,
75  int nsegments)
76  : myDetails(NULL)
77  , myPrimitives(NULL)
78  , mySegmentCount(0)
79  {
80  init(dlist, primlist, nsegments);
81  }
83  : myDetails(NULL)
84  , myPrimitives(NULL)
85  , mySegmentCount(0)
86  , GT_Primitive(src)
87  {
88  init(src.myDetails, src.myPrimitives, src.mySegmentCount);
89  }
90  virtual ~GT_GEOPrimitive();
91 
92  virtual const char *className() const { return "GT_GEOPrimitive"; }
93 
94  /// Initialize the primitive lists
95  void init(const GU_ConstDetailHandle *dlist,
96  const GEO_Primitive *const*primlist,
97  int nsegments);
98  void init(const GU_ConstDetailHandle *dlist,
99  const GEOPrimitivePair *primlist,
100  int nsegments);
101 
102  /// @{
103  /// Interface from GT_Primitive implemented using methods on GEO_Primitive
104  virtual int getPrimitiveType() const
105  { return GT_GEO_PRIMITIVE; }
106  virtual void enlargeBounds(UT_BoundingBox boxes[],
107  int nsegments) const;
108  virtual int getMotionSegments() const
109  { return mySegmentCount; }
110  virtual int64 getMemoryUsage() const;
112  { return new GT_GEOPrimitive(*this); }
113  /// @}
114 
115  /// @{
116  /// Interface from GT_Primitive required by subclass
117  virtual bool refine(GT_Refine &refiner,
118  const GT_RefineParms *parms=NULL) const;
119  /// @}
120 
121  /// Update the primitive pointers
122  virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
123  const GT_RefineParms &refine);
124 
125  /// @{
126  /// Access to GEO primitives
127  const GU_ConstDetailHandle *detailHandles() const { return myDetails; }
128  const GU_ConstDetailHandle &detail(int seg) const
129  { return myDetails[seg];}
130  const GEO_Primitive *getPrimitive(int seg) const;
131  template <typename T> const T *getPrimAs(int seg) const
132  {
133  return UTverify_cast<const T *>(getPrimitive(seg));
134  }
135  /// @}
136 
137  /// Given a GEO_Quadric, create the GT transform
138  static GT_TransformHandle makeQuadricTransform(
139  const GEO_Quadric *prim
140  );
141 
142  /// Given a single-vertex primitive, create an attribute list for all
143  /// point, vertex and primitive attributes.
144  static GT_AttributeListHandle makeQuadricAttributes(
145  const GU_ConstDetailHandle &gdp,
146  const GEO_Primitive *prims
147  );
148 protected:
149  void clearLists();
150  /// Get an attribute list for the primitive attributes, optionally
151  /// including the detail attributes in the same list.
152  /// These attributes will be "shared" with the GEO objects.
153  GT_AttributeListHandle getPrimitiveAttributes(
154  bool include_detail_attributes=true) const;
155 
159 };
160 
161 #endif
GT_GEOPrimitive(const GT_GEOPrimitive &src)
Base class for many of the GEO_Primitive objects.
GEOPrimitivePair(const GEO_Primitive *prim)
virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
update any cached data for geometry and its attributes
const GEO_Primitive * primitive() const
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GEOPrimitivePair(const GU_ConstDetailHandle &gdh, GA_Index idx)
#define GT_API
Definition: GT_API.h:11
GEOPrimitivePair * myPrimitives
virtual GT_PrimitiveHandle doSoftCopy() const
long long int64
Definition: SYS_Types.h:100
const T * getPrimAs(int seg) const
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:175
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
The base class for all GT primitive types.
Definition: GT_Primitive.h:41
virtual int64 getMemoryUsage() const =0
const GU_ConstDetailHandle & detail(int seg) const
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
virtual int getMotionSegments() const
GU_ConstDetailHandle * myDetails
GT_GEOPrimitive(const GU_ConstDetailHandle *dlist, const GEO_Primitive *const *primlist, int nsegments)
virtual int getPrimitiveType() const
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
virtual const char * className() const
const GU_ConstDetailHandle * detailHandles() const
GLenum src
Definition: glcorearb.h:1792