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