HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimFragments.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_PrimFragments.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimFragments__
12 #define __GT_PrimFragments__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 #include "GT_TransformArray.h"
17 #include "GT_GEODetailList.h"
18 
19 class UT_StringRef;
20 
21 
22 /// A primitive made of multiple fragments that are coalesced into one geometry
23 ///
24 /// For each fragment, you can query:
25 /// - The transform for the fragment
26 /// - The untransformed bounding box
27 /// - The transformed bounding box
28 /// - The fragment's __primitive_id
29 /// - The fragment's __point_id
30 /// These properties are only used for information, not for refinement or
31 /// rendering. The single geometry is composed of the transformed fragments.
32 ///
33 /// Attributes are:
34 /// - detail: one for the whole primitive
35 /// The instance primitive does *not* pass these down when it refines.
37 {
38 public:
40  GT_PrimFragments(const GT_PrimitiveHandle &geometry,
43  virtual ~GT_PrimFragments();
44 
45  /// @{
46  /// Interface from GT_Primitive
47  virtual const char *className() const;
48  virtual int getPrimitiveType() const;
49  virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const
50  { doEnlargeBounds(boxes, nsegs, false); }
51  virtual void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const
52  { doEnlargeBounds(boxes, nsegs, true); }
53  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax,
54  const UT_StringRef &attribute_name) const;
55  virtual bool refine(GT_Refine &refiner,
56  const GT_RefineParms *parms=NULL) const;
57  virtual int getMotionSegments() const;
58  virtual int64 getMemoryUsage() const;
59  virtual bool save(UT_JSONWriter &w) const;
60  virtual fpreal computePerimeter(int seg=0) const;
61  virtual fpreal computeSurfaceArea(int seg=0) const;
62  virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const;
63  virtual GT_PrimitiveHandle doHarden() const;
64  virtual GT_PrimitiveHandle doSoftCopy() const;
65  virtual const GT_ViewportRefineOptions &viewportRefineOptions() const;
67  { return myAttributes; }
68  /// @}
69 
70  /// Set up __primitive_id, __point_id and transforms based on fragment
71  /// primitives. This assumes that the primitives are all packed primitives
72  /// of some kind (and have a single point).
73  ///
74  /// The centroids should likely be in the center of the transformed
75  /// bounding box.
76  void setupFragments(const GT_GEOOffsetList &primitives,
77  const GT_GEOOffsetList &vertices,
78  const GT_GEOOffsetList &points,
79  const GT_DataArrayHandle &centroids);
80 
81  /// Return number of fragments
82  GT_Size entries() const
83  { return myCentroids ? myCentroids->entries():0; }
84 
85  /// Return combined geometry
87  { return myGeometry; }
88 
89  /// Return fragment centroids (where to render decorations)
91  { return myCentroids; }
92  /// @{
93  /// If the geometry being instanced comes from a GU_Detail, then the source
94  /// geometry should be set to point to this geometry. This lets viewport
95  /// decorations be rendered properly.
97  { return mySourceGeometry; }
99  { mySourceGeometry = g; }
100  /// @}
101 
102 protected:
103  /// Set up __primitive_id, __point_id and __vertex_id explicitly
104  /// The arrays can be NULL.
105  void setFragmentAttributes(const GT_DataArrayHandle &prim_ids,
106  const GT_DataArrayHandle &vertex_ids,
107  const GT_DataArrayHandle &point_ids);
108 
109  void doEnlargeBounds(UT_BoundingBox boxes[], int nsegs,
110  bool forrender) const;
115 };
116 
117 #endif
virtual int getMotionSegments() const =0
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
virtual const GT_ViewportRefineOptions & viewportRefineOptions() const
virtual int getPrimitiveType() const
virtual fpreal computePerimeter(int seg=0) const
virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const
const GT_GEODetailListHandle & sourceGeometry() const
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
3D Vector class.
GT_AttributeListHandle myAttributes
long long int64
Definition: SYS_Types.h:107
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const
virtual GT_PrimitiveHandle doSoftCopy() const =0
GT_GEODetailListHandle mySourceGeometry
virtual fpreal computeSurfaceArea(int seg=0) const
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
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
const GT_PrimitiveHandle & geometry() const
Return combined geometry.
double fpreal
Definition: SYS_Types.h:270
const GT_DataArrayHandle & centroids() const
Return fragment centroids (where to render decorations)
GT_Size entries() const
Return number of fragments.
GT_PrimitiveHandle myGeometry
virtual bool save(UT_JSONWriter &w) const
virtual void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const
virtual const GT_AttributeListHandle & getUniformAttributes() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GT_DataArrayHandle myCentroids
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
int64 GT_Size
Definition: GT_Types.h:112
virtual const char * className() const =0
void setSourceGeometry(const GT_GEODetailListHandle &g)
GLenum src
Definition: glcorearb.h:1792