HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimInstance.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_PrimInstance.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimInstance__
12 #define __GT_PrimInstance__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 #include "GT_TransformArray.h"
17 #include "GT_GEODetailList.h"
18 #include "GT_GEOSupport.h"
19 
20 class UT_StringRef;
21 
22 /// A primitive which instances another primitive
23 ///
24 /// The instance primitive can have attribute lists:
25 /// - detail: one for the whole primitive
26 /// - uniform: one per instance
27 /// The instance primitive does *not* pass these down when it refines.
29 {
30 public:
32  GT_PrimInstance(const GT_PrimitiveHandle &geometry,
34  const GT_GEOOffsetList &packed_prim_offsets=GT_GEOOffsetList(),
39  virtual ~GT_PrimInstance();
40 
41  /// @{
42  /// Interface from GT_Primitive
43  virtual const char *className() const;
44  virtual int getPrimitiveType() const;
45  virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const
46  { doEnlargeBounds(boxes, nsegs, false); }
47  virtual void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const
48  { doEnlargeBounds(boxes, nsegs, true); }
49  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax,
50  const UT_StringRef &attribute_name) const;
51  virtual bool refine(GT_Refine &refiner,
52  const GT_RefineParms *parms=NULL) const;
53  virtual int getMotionSegments() const;
54  virtual int64 getMemoryUsage() const;
55  virtual bool save(UT_JSONWriter &w) const;
56  virtual fpreal computePerimeter(int seg=0) const;
57  virtual fpreal computeSurfaceArea(int seg=0) const;
58  virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const;
59  virtual GT_PrimitiveHandle doHarden() const;
60  virtual GT_PrimitiveHandle doSoftCopy() const;
61  virtual const GT_ViewportRefineOptions &viewportRefineOptions() const;
63  { return myUniform; }
65  { return myDetail; }
66  /// @}
67 
68  /// Check valid
69  bool isValid() const
70  { return myGeometry && myTransforms; }
71 
72  /// Return number of instances
73  GT_Size entries() const
74  { return myTransforms ? myTransforms->entries():0; }
75 
76  /// Return geometry to be instanced
78  { return myGeometry; }
79 
80  /// Return transforms for instances
82  { return myTransforms; }
83  /// Non-const transform access (for appending new transforms).
85  { return myTransforms; }
86  /// Return uniform attributes
88  { return myUniform; }
89  /// Return detail attributes
91  { return myDetail; }
92 
94  { return myPackedPrimOffsets; }
95 
96  /// Return the transforms for instances, but combined with the transform
97  /// for the primitive itself.
98  GT_TransformArrayHandle combinedTransforms() const;
99 
100  /// Refine geometry to create new instance primitives for each refined
101  /// primitive. For example, if you refine an instance primitive containing
102  /// a GT_PrimPolygonMesh, the poly mesh will be refined to create
103  /// individual polygons. Each of these will be added to the refiner
104  /// contained in an instance primitive.
105  bool refineToInstances(GT_Refine &refiner,
106  const GT_RefineParms *parms) const;
107  /// Refine to individual pieces of geometry. This will create transformed
108  /// copies of the geometry for each transform in the instance primitive
109  bool flattenInstances(GT_Refine &refiner,
110  const GT_RefineParms *parms) const;
111  /// If the geometry contained by this instance primitive is an instance
112  /// primitive itself this method will expand the instances, by permuting
113  /// the transform arrays, creating a single flattened array of transforms.
114  GT_PrimitiveHandle expandInstanceTransforms() const;
115 
116  /// When the generic refine method is called, if the primitive is a
117  /// "simple" primitive, flattenInstances() will be called instead of
118  /// refineToInstances().
119  ///
120  /// Default method considers the following to be "simple"
121  /// - GT_PRIM_POLYGON_MESH
122  /// - GT_PRIM_POLYGON
123  /// - GT_PRIM_SUBDIVISION_MESH
124  /// - GT_PRIM_CURVE_MESH
125  /// - GT_PRIM_CURVE
126  /// - GT_PRIM_POINT_MESH
127  /// - GT_PRIM_NUPATCH
128  /// - GT_PRIM_CIRCLE
129  /// - GT_PRIM_SPHERE
130  /// - GT_PRIM_TUBE
131  /// - GT_PRIM_HYPERBOLOID
132  /// - GT_PRIM_CIRCLE_MESH
133  /// - GT_PRIM_SPHERE_MESH
134  /// - GT_PRIM_TUBE_MESH
135  /// - GT_PRIM_HYPERBOLOID_MESH
136  virtual bool isSimplePrimitive(int primitive_type) const;
137 
138  /// @{
139  /// If the geometry being instanced comes from a GU_Detail, then the source
140  /// geometry should be set to point to this geometry. This lets viewport
141  /// decorations be rendered properly.
143  { return mySourceGeometry; }
145  { mySourceGeometry = g; }
146  /// @}
147 
148  virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
149  const GT_RefineParms &refine);
150 
151 protected:
152  void doEnlargeBounds(UT_BoundingBox boxes[], int nsegs,
153  bool forrender) const;
154 
161 };
162 
163 #endif
virtual int getMotionSegments() const =0
virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
update any cached data for geometry and its attributes
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
virtual const GT_ViewportRefineOptions & viewportRefineOptions() const
png_infop int transforms
Definition: png.h:2591
GT_TransformArrayHandle myTransforms
bool isValid() const
Check valid.
virtual int getPrimitiveType() const
virtual fpreal computePerimeter(int seg=0) const
virtual const GT_AttributeListHandle & getDetailAttributes() const
UT_IntrusivePtr< GT_AttributeList > GT_AttributeListHandle
Definition: GT_Handles.h:24
virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const
void setSourceGeometry(const GT_GEODetailListHandle &g)
GLboolean GLboolean g
Definition: glcorearb.h:1221
#define GT_API
Definition: GT_API.h:11
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
const GT_TransformArrayHandle & transforms() const
Return transforms for instances.
3D Vector class.
virtual const GT_AttributeListHandle & getUniformAttributes() const
const GT_GEOOffsetList & packedPrimOffsets() const
GT_GEOOffsetList myPackedPrimOffsets
long long int64
Definition: SYS_Types.h:107
GT_AttributeListHandle myDetail
virtual GT_PrimitiveHandle doSoftCopy() const =0
GT_PrimitiveHandle myGeometry
virtual fpreal computeSurfaceArea(int seg=0) const
const GT_AttributeListHandle & uniform() const
Return uniform attributes.
virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max, const UT_StringRef &attribute_name=GA_Names::v) const
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle doHarden() const
virtual int64 getMemoryUsage() const =0
GT_AttributeListHandle myUniform
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
double fpreal
Definition: SYS_Types.h:270
const GT_PrimitiveHandle & geometry() const
Return geometry to be instanced.
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const
GT_TransformArrayHandle & transforms()
Non-const transform access (for appending new transforms).
const GT_AttributeListHandle & detail() const
Return detail attributes.
virtual bool save(UT_JSONWriter &w) const
const GT_GEODetailListHandle & sourceGeometry() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GT_Size entries() const
Return number of instances.
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
int64 GT_Size
Definition: GT_Types.h:112
virtual void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const
virtual const char * className() const =0
GT_GEODetailListHandle mySourceGeometry
GLenum src
Definition: glcorearb.h:1792