16 #ifndef __GEO_VOLUMESAMPLER_H_INCLUDED__
17 #define __GEO_VOLUMESAMPLER_H_INCLUDED__
31 virtual bool isActive(
const UT_Vector3 &pos) = 0;
32 virtual bool isActiveAtIndex(
int ix,
int iy,
int iz) = 0;
34 virtual fpreal getValueAtIndexF(
int ix,
int iy,
int iz) = 0;
36 virtual UT_Vector3D getValueAtIndexV3(
int ix,
int iy,
int iz) = 0;
37 virtual fpreal getConstantIndexRegionF(
UT_BoundingBox &indexbox,
bool *isconstant,
bool *isactive) = 0;
76 return myVol != NULL || myVdb != NULL;
90 myHandle = myVol->getVoxelHandle();
96 myVDBCache = createVDBCache(myVdb);
110 myVol->indexToPos(x,y,z,pos);
112 myVdb->indexToPos(x,y,z,pos);
117 myVol->findexToPos(index, pos);
119 myVdb->findexToPos(index, pos);
124 myVol->indexToPos(x,y,z,pos);
126 myVdb->indexToPos(x,y,z,pos);
131 myVol->findexToPos(index,pos);
133 myVdb->findexToPos(index,pos);
140 myVol->posToIndex(pos,x,y,z);
142 myVdb->posToIndex(pos,x,y,z);
147 myVol->posToIndex(pos,index);
149 myVdb->posToIndex(pos,index);
154 myVol->posToIndex(pos,x,y,z);
156 myVdb->posToIndex(pos,x,y,z);
161 myVol->posToIndex(pos,index);
163 myVdb->posToIndex(pos,index);
168 return myVol->getSpaceTransform();
170 return myVdb->getSpaceTransform();
177 return myVol->getIndexSpaceTransform();
179 return myVdb->getIndexSpaceTransform();
188 return myVol->isInsideStrict(pos, myHandle);
190 return myVDBCache->isActive(pos);
200 return myHandle->isValidIndex(ix, iy, iz);
202 return myVDBCache->isActiveAtIndex(ix, iy, iz);
210 return myVol->getValue(pos, myHandle);
212 return myVDBCache->getValueF(pos);
220 return myHandle->getValue(ix, iy, iz);
222 return myVDBCache->getValueAtIndexF(ix, iy, iz);
241 return UT_Vector3D(myVol->getValue(pos, myHandle), 0, 0);
243 return myVDBCache->getValueV3(pos);
251 return UT_Vector3D(myHandle->getValue(ix, iy, iz), 0, 0);
253 return myVDBCache->getValueAtIndexV3(ix, iy, iz);
268 constexpr
bool IS_SCALAR = SYS_IsFloatingPoint_v<T>;
271 SYS_IsFloatingPoint_v<T> ||
274 "Return value has to be scalar or three dimensional vector!");
278 if constexpr (IS_SCALAR){
279 return myHandle->getValues(bbox, values, size);
284 sizeof(
T) >=
sizeof(
float),
285 "This implementation assumes that sizeof(T) >= "
286 "sizeof(float). Memory leak happens otherwise.");
289 float *
data =
reinterpret_cast<float*
>(
values);
290 const bool isconstant = myHandle->getValues(bbox, data, size);
292 for(
int i=n-1; i>=0; i--){
293 values[i] =
T{data[i], 0.f, 0.f};
302 for (
int k = bbox.
zmin(); k < bbox.
zmax(); k++)
306 for (
int i = bbox.
xmin(); i < bbox.
xmax(); i++)
308 if constexpr (IS_SCALAR)
310 values[
id++] = myVDBCache->getValueAtIndexF(i,
j, k);
314 values[
id++] = myVDBCache->getValueAtIndexV3(i,
j, k);
334 #endif // __GEO_VOLUMESAMPLER_H_INCLUDED__
int getVectorSize() const
void posToIndex(UT_Vector3 pos, int &x, int &y, int &z) const
Convert a 3d position into the closest index value.
GEO_VolumeSamplerVDBCache * myVDBCache
GEO_VolumeSampler & operator=(const GEO_VolumeSampler &src)
void indexToPos(exint x, exint y, exint z, UT_Vector3D &pos) const
void posToIndex(UT_Vector3 pos, UT_Vector3 &index) const
void findexToPos(UT_Vector3D index, UT_Vector3D &pos) const
UT_VoxelArrayReadHandleF myHandle
void findexToPos(UT_Vector3 index, UT_Vector3 &pos) const
GLdouble GLdouble GLdouble z
void posToIndex(UT_Vector3D pos, UT_Vector3D &index) const
fpreal getValueAtIndexF(int ix, int iy, int iz)
UT_Vector3D getValueAtIndexV3(int ix, int iy, int iz)
bool isActive(const UT_Vector3 &pos)
bool isActiveAtIndex(int ix, int iy, int iz)
GEO_PrimVolumeXform getIndexSpaceTransform() const
GEO_VolumeSampler(const GEO_Primitive *prim)
GEO_VolumeSampler(const GEO_VolumeSampler &src)
const GEO_PrimVDB * myVdb
GEO_VolumeSamplerVDBCache()
SYS_FORCE_INLINE int getTupleSize() const
Get the tuple size, usually 1 or 3.
UT_Vector3T< fpreal64 > UT_Vector3D
void indexToPos(int x, int y, int z, UT_Vector3 &pos) const
GLenum GLsizei GLsizei GLint * values
virtual ~GEO_VolumeSamplerVDBCache()
const GEO_Primitive * myPrim
bool getValues(const UT_BoundingBoxI &bbox, T *values, const exint size)
void bindPrim(const GEO_Primitive *prim)
GEO_PrimVolumeXform getSpaceTransform() const
fpreal getValueF(const UT_Vector3 &pos)
UT_Vector3D getValueV3(const UT_Vector3 &pos)
const GEO_PrimVolume * myVol
void posToIndex(UT_Vector3D pos, exint &x, exint &y, exint &z) const