HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
21 // For quick testing of codepaths with no VDB support.
22 //#undef OPENVDB_ENABLED
23 
24 #ifdef OPENVDB_ENABLED
25 #include <openvdb/Grid.h>
26 #endif
27 
29 {
30 public:
31  GT_PrimVDB(const GU_ConstDetailHandle &gdh, const GEO_Primitive *prim);
32  virtual ~GT_PrimVDB();
33 
34  virtual int getPrimitiveType() const { return GT_PRIM_VDB_VOLUME; }
35 
36  virtual const char *className() const { return "GT_PrimVDB"; }
37 
38  bool isLevelSet() const { return myLevelSetFlag; }
39  bool isVolume() const { return myVolumeFlag; }
40 
41  // Compute list of voxel coords with corresponding leaf node edge masks.
42  // Returns coords.entries().
43  exint getLeafCoords(
44  UT_Vector3FArray &coords,
45  UT_Int16Array &masks) const;
46 
47  /// Returns a GT_PrimPointMesh with 1 point containing the VDB's 1 point.
48  /// Contains all of the VDBs attributes as point or uniform attributes.
49  GT_PrimitiveHandle getPointPrimitive() const;
50 
51  GEO_PrimVolumeXform getVolumeTransform() const;
52  GEO_PrimVolumeXform getVolumeIndexTransform() const;
53 
54  UT_Vector3I getRes() const;
55 
56  /// Viewport refinement options -- changes on LOD
57  virtual const GT_ViewportRefineOptions &viewportRefineOptions() const;
58 
59  virtual bool refine(GT_Refine &refiner,
60  const GT_RefineParms *parms=NULL) const;
61 
62  virtual void enlargeBounds(UT_BoundingBox boxes[],
63  int nsegments) const;
64  virtual int getMotionSegments() const { return 1; }
65  virtual int64 getMemoryUsage() const { return sizeof(GEO_Primitive *);}
67  { return new GT_PrimVDB(*this); }
68 
69  virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
70  const GT_RefineParms &refine);
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 
79  { return myUniformList; }
80 #ifdef OPENVDB_ENABLED
81  const openvdb::GridBase * getGrid();
82  const GEO_PrimVDB *getGeoPrimitive() const { return myVDB; }
83 #endif
84 
85 private:
86 #ifdef OPENVDB_ENABLED
87  static GT_TransformHandle getPrimitiveTransformFromGrid(
88  const openvdb::GridBase &grid);
89 
90  const GEO_PrimVDB *myVDB;
91 #endif
92 
93  GU_ConstDetailHandle myDetail;
94  GT_AttributeListHandle myUniformList;
95  GA_Offset myPrimID;
96  GA_Offset myPointID;
97  UT_Vector3F myPrimColor;
98  bool myVolumeFlag;
99  bool myLevelSetFlag;
100 };
101 
102 /// Trivial collector class for VDBs - 1 GT_PrimVDB per VDB primitive
104 {
105 public:
108 
110  const GEO_Primitive *const* prim_list,
111  int,
112  GT_GEOPrimCollectData *) const
113  {
114  GT_PrimitiveHandle vdbh;
115 #ifdef OPENVDB_ENABLED
116  if(static_cast<const GEO_PrimVDB *>(prim_list[0])->getVisualization()
118  vdbh = new GT_PrimVDB(g->getGeometry(0), prim_list[0]);
119 #endif
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:1221
#define GT_API
Definition: GT_API.h:11
virtual const char * className() const
Definition: GT_PrimVDB.h:36
Collection data container.
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:100
Trivial collector class for VDBs - 1 GT_PrimVDB per VDB primitive.
Definition: GT_PrimVDB.h:103
int64 exint
Definition: SYS_Types.h:109
UT_Vector3F getPrimColor() const
Definition: GT_PrimVDB.h:74
The base class for all GT primitive types.
Definition: GT_Primitive.h:41
virtual int64 getMemoryUsage() const
Definition: GT_PrimVDB.h:65
const GEO_PrimVDB * getGeoPrimitive() const
Definition: GT_PrimVDB.h:82
virtual GT_PrimitiveHandle collect(const GT_GEODetailListHandle &g, const GEO_Primitive *const *prim_list, int, GT_GEOPrimCollectData *) const
Definition: GT_PrimVDB.h:109
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
virtual const GT_AttributeListHandle & getUniformAttributes() const
Definition: GT_PrimVDB.h:78
bool isVolume() const
Definition: GT_PrimVDB.h:39
GA_Offset getPointOffset() const
Definition: GT_PrimVDB.h:73
virtual int getPrimitiveType() const
Definition: GT_PrimVDB.h:34
GA_Offset getPrimitiveOffset() const
Definition: GT_PrimVDB.h:72
virtual ~GT_GEOPrimCollectVDB()
Definition: GT_PrimVDB.h:107
bool isLevelSet() const
Definition: GT_PrimVDB.h:38
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
virtual GT_PrimitiveHandle doSoftCopy() const
Definition: GT_PrimVDB.h:66
virtual int getMotionSegments() const
Definition: GT_PrimVDB.h:64