HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimVDB.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_PrimVDB.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef GT_PrimVDB_h
12 #define GT_PrimVDB_h
13 
14 #include "GT_API.h"
15 #include "GT_DataArray.h"
16 #include "GT_Primitive.h"
17 #include "GT_GEOPrimCollect.h"
18 #include <GEO/GEO_PrimVDB.h>
19 #include <UT/UT_VectorTypes.h>
20 #include <SYS/SYS_Inline.h>
21 
22 #include <openvdb/Grid.h>
23 
24 
26 {
27 public:
28  GT_PrimVDB(const GU_ConstDetailHandle &gdh, const GEO_Primitive *prim);
29  ~GT_PrimVDB() override;
30 
31  int getPrimitiveType() const override
32  { return GT_PRIM_VDB_VOLUME; }
33 
34  const char *className() const override { return "GT_PrimVDB"; }
35 
36  bool isLevelSet() const { return myLevelSetFlag; }
37  bool isVolume() const { return myVolumeFlag; }
38  bool isInvisible() const { return myIsInvisible; }
39 
40  // Compute list of voxel coords with corresponding leaf node edge masks.
41  // Returns coords.entries().
42  exint getLeafCoords(
44  UT_Int16Array &masks) const;
45 
46  /// Returns a GT_PrimPointMesh with 1 point containing the VDB's 1 point.
47  /// Contains all of the VDBs attributes as point or uniform attributes.
48  GT_PrimitiveHandle getPointPrimitive() const;
49 
50  GEO_PrimVolumeXform getVolumeTransform() const;
51  GEO_PrimVolumeXform getVolumeIndexTransform() const;
52 
53  UT_Vector3I getRes() const;
54 
55  /// Viewport refinement options -- changes on LOD
56  const GT_ViewportRefineOptions &viewportRefineOptions() const override;
57 
58  bool refine(GT_Refine &refiner,
59  const GT_RefineParms *parms=NULL) const override;
60 
61  void enlargeBounds(UT_BoundingBox boxes[],
62  int nsegments) const override;
63  int getMotionSegments() const override { return 1; }
64  int64 getMemoryUsage() const override
65  { return sizeof(GEO_Primitive *);}
66  GT_PrimitiveHandle doSoftCopy() const override
67  { return new GT_PrimVDB(*this); }
68 
69  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
70  const GT_RefineParms &refine) override;
71 
72  GA_Offset getPrimitiveOffset() const { return myPrimID; }
73  GA_Offset getPointOffset() const { return myPointID; }
74  UT_Vector3F getPrimColor() const { return myPrimColor; }
75 
76  GT_TransformHandle getGridTransform();
77 
78  /// Set the list of uniform attributes.
80  {
81  myUniformList = uniform;
82  }
83 
85  { return myUniformList; }
86 
88  const openvdb::GridBase * getGrid() { return &myVDB->getGrid(); }
89 
90  const GEO_PrimVDB *getGeoPrimitive() const { return myVDB; }
91  const GU_ConstDetailHandle &getDetail() const { return myDetail; }
92 
93 private:
94  const GEO_PrimVDB * myVDB;
95 
96  GU_ConstDetailHandle myDetail;
97  GT_AttributeListHandle myUniformList;
98  GA_Offset myPrimID;
99  GA_Offset myPointID;
100  UT_Vector3F myPrimColor;
101  bool myVolumeFlag;
102  bool myLevelSetFlag;
103  bool myIsInvisible;
104 };
105 
106 /// Trivial collector class for VDBs - 1 GT_PrimVDB per VDB primitive
108 {
109 public:
111  ~GT_GEOPrimCollectVDB() override {}
112 
114  const GEO_Primitive *const* prim_list,
115  int,
116  GT_GEOPrimCollectData *) const override
117  {
118  GT_PrimitiveHandle vdbh;
119  vdbh = new GT_PrimVDB(g->getGeometry(0), prim_list[0]);
120  return vdbh;
121  }
122 };
123 
124 #endif
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
GLboolean GLboolean g
Definition: glcorearb.h:1222
#define GT_API
Definition: GT_API.h:11
int64 exint
Definition: SYS_Types.h:125
int getMotionSegments() const override
Definition: GT_PrimVDB.h:63
Collection data container.
GA_Size GA_Offset
Definition: GA_Types.h:640
Trivial collector class for VDBs - 1 GT_PrimVDB per VDB primitive.
Definition: GT_PrimVDB.h:107
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE const openvdb::GridBase * getGrid()
Definition: GT_PrimVDB.h:88
UT_Vector3F getPrimColor() const
Definition: GT_PrimVDB.h:74
long long int64
Definition: SYS_Types.h:116
const char * className() const override
Definition: GT_PrimVDB.h:34
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
bool isInvisible() const
Definition: GT_PrimVDB.h:38
const GEO_PrimVDB * getGeoPrimitive() const
Definition: GT_PrimVDB.h:90
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
void setUniformAttributes(const GT_AttributeListHandle &uniform)
Set the list of uniform attributes.
Definition: GT_PrimVDB.h:79
bool isVolume() const
Definition: GT_PrimVDB.h:37
GT_PrimitiveHandle doSoftCopy() const override
Definition: GT_PrimVDB.h:66
GT_PrimitiveHandle collect(const GT_GEODetailListHandle &g, const GEO_Primitive *const *prim_list, int, GT_GEOPrimCollectData *) const override
Definition: GT_PrimVDB.h:113
~GT_GEOPrimCollectVDB() override
Definition: GT_PrimVDB.h:111
GA_Offset getPointOffset() const
Definition: GT_PrimVDB.h:73
const GU_ConstDetailHandle & getDetail() const
Definition: GT_PrimVDB.h:91
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
GA_Offset getPrimitiveOffset() const
Definition: GT_PrimVDB.h:72
bool isLevelSet() const
Definition: GT_PrimVDB.h:36
const GT_AttributeListHandle & getUniformAttributes() const override
Definition: GT_PrimVDB.h:84
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
int64 getMemoryUsage() const override
Definition: GT_PrimVDB.h:64
GLenum GLuint coords
Definition: glew.h:7936
int getPrimitiveType() const override
Definition: GT_PrimVDB.h:31