HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~HOM_VDB()
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  SWIGOUT(%newobject gradient;)
48  virtual HOM_Vector3 *gradient(const std::vector<double> &position) = 0;
49 
50  virtual double voxel(const std::vector<int> &index) = 0;
51 
52  virtual std::vector<int> resolution() = 0;
53 
54  SWIGOUT(%newobject indexToPos;)
55  virtual HOM_Vector3 *indexToPos(const std::vector<int> &index) = 0;
56 
57  virtual std::vector<int> posToIndex(const std::vector<double> &position) = 0;
58 
59  virtual bool isSDF() = 0;
60 
61  SWIGOUT(%newobject transform;)
62  virtual HOM_Matrix3 *transform() = 0;
63 
64  virtual double taper() = 0;
65 
66  SWIGOUT(%newobject vertex;)
67  virtual HOM_Vertex *vertex(int index) = 0;
68 
69  //
70  // VDB-specific accessors
71  //
72 
73  virtual bool isEmpty() = 0;
74 
75  virtual int activeVoxelCount() = 0;
76 
77  virtual HOM_BoundingBox activeVoxelBoundingBox() = 0;
78 
79  virtual HOM_Vector3 voxelSize() = 0;
80 
81  virtual HOM_EnumValue &dataType() = 0;
82 
83  virtual std::vector<bool> voxelRangeAsBool(HOM_BoundingBox &range) = 0;
84 
85  virtual std::vector<double> voxelRangeAsFloat(HOM_BoundingBox &range) = 0;
86 
87  virtual std::vector<int> voxelRangeAsInt(HOM_BoundingBox &range) = 0;
88 
89  virtual std::vector<HOM_Vector3> voxelRangeAsVector3(HOM_BoundingBox &range) = 0;
90 
91 #ifdef SWIG
92 %extend
93 {
94  InterpreterObject voxelRange(HOM_BoundingBox &range)
95  {
96  const HOM_EnumValue &data_type = self->dataType();
97  UT_ASSERT(data_type.enumClass() == typeid(HOM_vdbData));
98  switch (data_type.id())
99  {
100  case HOM_vdbData::Boolean_Id:
101  return swig::from(self->voxelRangeAsBool(range));
102  case HOM_vdbData::Float_Id:
103  return swig::from(self->voxelRangeAsFloat(range));
104  case HOM_vdbData::Int_Id:
105  return swig::from(self->voxelRangeAsInt(range));
106  case HOM_vdbData::Vector3_Id:
107  return swig::from(self->voxelRangeAsVector3(range));
108  }
109 
110  UT_ASSERT(!"Unknown vdb data type");
111  return SWIG_Py_Void();
112  }
113 }
114 #endif
115 
116 };
117 
118 #endif
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:983
GLenum GLint * range
Definition: glcorearb.h:1924
HOM_VDB(const HOM_VDB &volume)
Definition: HOM_VDB.h:34
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
virtual ~HOM_VDB()
Definition: HOM_VDB.h:38
#define HOM_API
Definition: HOM_API.h:13
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:982
GA_API const UT_StringHolder transform
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
int id() const
Definition: HOM_EnumValue.h:82
std::string __repr__()