HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_VDB.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  * COMMENTS:
7  */
8 
9 #ifndef __HOM_VDB_h__
10 #define __HOM_VDB_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_Prim.h"
15 #include <UT/UT_VDBUtils.h>
16 
17 
18 class HOM_BoundingBox;
19 class HOM_Vector3;
20 
21 
22 SWIGOUT(%rename(VDB) HOM_VDB;)
23 
24 
25 class HOM_API HOM_VDB : virtual public HOM_Prim
26 {
27 public:
29  { HOM_CONSTRUCT_OBJECT(this) }
30 
31  // Because the lowermost base classes initialize the virtual bases
32  // before any non-virtual bases, the correct thing to do here is
33  // explicitly call the constructor for HOM_Prim.
34  HOM_VDB(const HOM_VDB &volume)
35  : HOM_Prim(volume)
36  { HOM_CONSTRUCT_OBJECT(this) }
37 
38  ~HOM_VDB() override
39  { HOM_DESTRUCT_OBJECT(this) }
40 
41  // Let swig know we're overriding __repr__ for this class so it doesn't
42  // provide its own __repr__.
43  SWIGOUT(virtual std::string __repr__() = 0;)
44 
45  virtual double sample(const std::vector<double> &position) = 0;
46 
47  virtual HOM_Vector3 *samplev(const std::vector<double> &position) = 0;
48 
49  SWIGOUT(%newobject gradient;)
50  virtual HOM_Vector3 *gradient(const std::vector<double> &position) = 0;
51 
52  virtual double voxel(const std::vector<int> &index) = 0;
53 
54  virtual std::vector<int> resolution() = 0;
55 
56  SWIGOUT(%newobject indexToPos;)
57  virtual HOM_Vector3 *indexToPos(const std::vector<int> &index) = 0;
58 
59  virtual std::vector<int> posToIndex(const std::vector<double> &position) = 0;
60 
61  virtual bool isSDF() = 0;
62 
63  virtual bool isHeightField() = 0;
64 
65  virtual double volumeMax() = 0;
66 
67  virtual double volumeMin() = 0;
68 
69  virtual double volumeAverage() = 0;
70 
71  SWIGOUT(%newobject transform;)
72  virtual HOM_Matrix3 *transform() = 0;
73 
74  virtual double taper() = 0;
75 
76  SWIGOUT(%newobject vertex;)
77  virtual HOM_Vertex *vertex(int index) = 0;
78 
79  //
80  // VDB-specific accessors
81  //
82 
83  virtual bool isEmpty() = 0;
84 
85  virtual int activeVoxelCount() = 0;
86 
87  virtual HOM_BoundingBox activeVoxelBoundingBox() = 0;
88 
89  virtual HOM_Vector3 voxelSize() = 0;
90 
91  virtual HOM_EnumValue &dataType() = 0;
92 
93  virtual std::vector<bool> voxelRangeAsBool(HOM_BoundingBox &range) = 0;
94 
95  virtual std::vector<double> voxelRangeAsFloat(HOM_BoundingBox &range) = 0;
96 
97  virtual std::vector<int> voxelRangeAsInt(HOM_BoundingBox &range) = 0;
98 
99  virtual std::vector<HOM_Vector3> voxelRangeAsVector3(HOM_BoundingBox &range) = 0;
100 
101 #ifdef SWIG
102 %extend
103 {
104  InterpreterObject voxelRange(HOM_BoundingBox &range)
105  {
106  const HOM_EnumValue &data_type = self->dataType();
107  UT_ASSERT(data_type.enumClass() == typeid(HOM_vdbData));
108  switch (data_type.id())
109  {
110  case HOM_vdbData::Boolean_Id:
111  return swig::from(self->voxelRangeAsBool(range));
112  case HOM_vdbData::Float_Id:
113  return swig::from(self->voxelRangeAsFloat(range));
114  case HOM_vdbData::Int_Id:
115  return swig::from(self->voxelRangeAsInt(range));
116  case HOM_vdbData::Vector3_Id:
117  return swig::from(self->voxelRangeAsVector3(range));
118  }
119 
120  UT_ASSERT(!"Unknown vdb data type");
121  return SWIG_Py_Void();
122  }
123 }
124 #endif
125 
126 };
127 
128 #endif
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1238
HOM_VDB(const HOM_VDB &volume)
Definition: HOM_VDB.h:34
OIIO_API bool rename(string_view from, string_view to, std::string &err)
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:353
~HOM_VDB() override
Definition: HOM_VDB.h:38
GLuint GLenum GLenum transform
Definition: glew.h:15055
#define HOM_API
Definition: HOM_API.h:13
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1237
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HUSD_API const char * resolution()
INT GLenum dataType
Definition: wglew.h:145
const std::type_info & enumClass() const
Definition: HOM_EnumValue.h:78
GLuint index
Definition: glcorearb.h:785
ScalarToVectorConverter< GridType >::Type::Ptr gradient(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the gradient of the given scalar grid.
HOM_VDB()
Definition: HOM_VDB.h:28
GLenum GLint * range
Definition: glcorearb.h:1924
int id() const
Definition: HOM_EnumValue.h:82
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:171