HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 /// A primitive made of multiple fragments that are coalesced into one geometry
20 ///
21 /// For each fragment, you can query:
22 /// - The transform for the fragment
23 /// - The untransformed bounding box
24 /// - The transformed bounding box
25 /// - The fragment's __primitive_id
26 /// - The fragment's __point_id
27 /// These properties are only used for information, not for refinement or
28 /// rendering. The single geometry is composed of the transformed fragments.
29 ///
30 /// Attributes are:
31 /// - detail: one for the whole primitive
32 /// The instance primitive does *not* pass these down when it refines.
34 {
35 public:
37  GT_PrimFragments(const GT_PrimitiveHandle &geometry,
40  virtual ~GT_PrimFragments();
41 
42  /// @{
43  /// Interface from GT_Primitive
44  virtual const char *className() const;
45  virtual int getPrimitiveType() const;
46  virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const
47  { doEnlargeBounds(boxes, nsegs, false); }
48  virtual void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const
49  { doEnlargeBounds(boxes, nsegs, true); }
50  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax,
51  const char *attribute_name) const;
52  virtual bool refine(GT_Refine &refiner,
53  const GT_RefineParms *parms=NULL) const;
54  virtual int getMotionSegments() const;
55  virtual int64 getMemoryUsage() const;
56  virtual bool save(UT_JSONWriter &w) const;
57  virtual fpreal computePerimeter(int seg=0) const;
58  virtual fpreal computeSurfaceArea(int seg=0) const;
59  virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const;
60  virtual GT_PrimitiveHandle doHarden() const;
61  virtual GT_PrimitiveHandle doSoftCopy() const;
62  virtual const GT_ViewportRefineOptions &viewportRefineOptions() const;
64  { return myAttributes; }
65  /// @}
66 
67  /// Set up __primitive_id, __point_id and transforms based on fragment
68  /// primitives. This assumes that the primitives are all packed primitives
69  /// of some kind (and have a single point).
70  ///
71  /// The centroids should likely be in the center of the transformed
72  /// bounding box.
73  void setupFragments(const GT_GEOOffsetList &primitives,
74  const GT_GEOOffsetList &vertices,
75  const GT_GEOOffsetList &points,
76  const GT_DataArrayHandle &centroids);
77 
78  /// Return number of fragments
79  GT_Size entries() const
80  { return myCentroids ? myCentroids->entries():0; }
81 
82  /// Return combined geometry
84  { return myGeometry; }
85 
86  /// Return fragment centroids (where to render decorations)
88  { return myCentroids; }
89  /// @{
90  /// If the geometry being instanced comes from a GU_Detail, then the source
91  /// geometry should be set to point to this geometry. This lets viewport
92  /// decorations be rendered properly.
94  { return mySourceGeometry; }
96  { mySourceGeometry = g; }
97  /// @}
98 
99 protected:
100  /// Set up __primitive_id, __point_id and __vertex_id explicitly
101  /// The arrays can be NULL.
102  void setFragmentAttributes(const GT_DataArrayHandle &prim_ids,
103  const GT_DataArrayHandle &vertex_ids,
104  const GT_DataArrayHandle &point_ids);
105 
106  void doEnlargeBounds(UT_BoundingBox boxes[], int nsegs,
107  bool forrender) const;
112 };
113 
114 #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
virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max, const char *attribute_name="v") const
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:100
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
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
The base class for all GT primitive types.
Definition: GT_Primitive.h:41
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:263
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:109
virtual const char * className() const =0
void setSourceGeometry(const GT_GEODetailListHandle &g)
GLenum src
Definition: glcorearb.h:1792