16 #ifndef __GEO_VOLUMESAMPLER_H_INCLUDED__
17 #define __GEO_VOLUMESAMPLER_H_INCLUDED__
33 virtual bool isActive(
const UT_Vector3 &pos) = 0;
34 virtual bool isActiveAtIndex(
int ix,
int iy,
int iz) = 0;
42 template <
typename BASE>
45 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
46 return getValueV4(pos);
47 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
48 return getValueV3(pos);
49 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
50 return getValueV2(pos);
51 if constexpr (SYS_IsSame_v<float, BASE>)
52 return getValueF(pos);
53 if constexpr (SYS_IsSame_v<int64, BASE>)
54 return getValueI(pos);
57 virtual fpreal getValueAtIndexF(
int ix,
int iy,
int iz) = 0;
58 virtual UT_Vector2D getValueAtIndexV2(
int ix,
int iy,
int iz) = 0;
59 virtual UT_Vector3D getValueAtIndexV3(
int ix,
int iy,
int iz) = 0;
60 virtual UT_Vector4D getValueAtIndexV4(
int ix,
int iy,
int iz) = 0;
61 virtual exint getValueAtIndexI(
int ix,
int iy,
int iz) = 0;
63 virtual fpreal getConstantIndexRegionF(
UT_BoundingBox &indexbox,
bool *isconstant,
bool *isactive) = 0;
67 virtual exint getConstantIndexRegionI(
UT_BoundingBox &indexbox,
bool *isconstant,
bool *isactive) = 0;
108 return myVol != NULL || myVdb != NULL;
115 return myVol->getStoresIntegers();
130 mySamplerCache.reset();
138 mySamplerCache = createVolumeCache(myVol);
145 myVectorSize = myVdb->getTupleSize();
146 mySamplerCache = createVDBCache(myVdb);
160 myVol->indexToPos(x,y,z,pos);
162 myVdb->indexToPos(x,y,z,pos);
167 myVol->findexToPos(index, pos);
169 myVdb->findexToPos(index, pos);
174 myVol->indexToPos(x,y,z,pos);
176 myVdb->indexToPos(x,y,z,pos);
181 myVol->findexToPos(index,pos);
183 myVdb->findexToPos(index,pos);
190 myVol->posToIndex(pos,x,y,z);
192 myVdb->posToIndex(pos,x,y,z);
197 myVol->posToIndex(pos,index);
199 myVdb->posToIndex(pos,index);
204 myVol->posToIndex(pos,x,y,z);
206 myVdb->posToIndex(pos,x,y,z);
211 myVol->posToIndex(pos,index);
213 myVdb->posToIndex(pos,index);
218 return myVol->getSpaceTransform();
220 return myVdb->getSpaceTransform();
227 return myVol->getIndexSpaceTransform();
229 return myVdb->getIndexSpaceTransform();
238 return mySamplerCache->isActive(pos);
248 return mySamplerCache->isActiveAtIndex(ix, iy, iz);
256 return mySamplerCache->getValueF(pos);
264 return mySamplerCache->getValueAtIndexF(ix, iy, iz);
286 return mySamplerCache->getValueV2(pos);
294 return mySamplerCache->getValueAtIndexV2(ix, iy, iz);
302 return mySamplerCache->getValueV3(pos);
310 return mySamplerCache->getValueAtIndexV3(ix, iy, iz);
318 return mySamplerCache->getValueV4(pos);
326 return mySamplerCache->getValueAtIndexV4(ix, iy, iz);
334 return mySamplerCache->getValueI(pos);
342 return mySamplerCache->getValueAtIndexI(ix, iy, iz);
347 template <
typename BASE>
350 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
351 return getValueV4(pos);
352 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
353 return getValueV3(pos);
354 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
355 return getValueV2(pos);
356 if constexpr (SYS_IsSame_v<float, BASE>)
357 return getValueF(pos);
358 if constexpr (SYS_IsSame_v<int64, BASE>)
359 return getValueI(pos);
377 if constexpr (SYS_IsSame_v<T, fpreal32>)
378 vox = mySamplerCache->getHandleF();
379 if constexpr (SYS_IsSame_v<T, UT_Vector2F>)
380 vox = mySamplerCache->getHandleV2();
381 if constexpr (SYS_IsSame_v<T, UT_Vector3F>)
382 vox = mySamplerCache->getHandleV3();
383 if constexpr (SYS_IsSame_v<T, UT_Vector4F>)
384 vox = mySamplerCache->getHandleV4();
385 if constexpr (SYS_IsSame_v<T, exint>)
386 vox = mySamplerCache->getHandleI();
390 return vox->getValues(bbox, values, size);
393 bool allconstant =
true;
395 for (
int k = bbox.
zmin(); k < bbox.
zmax(); k++)
399 for (
int i = bbox.
xmin(); i < bbox.
xmax(); i++, idx++)
401 if constexpr (tuplesize == 1)
403 if constexpr (SYS_IsIntegral_v<T>)
404 values[idx] = mySamplerCache->getValueAtIndexI(i,
j, k);
406 values[idx] = mySamplerCache->getValueAtIndexF(i,
j, k);
408 if constexpr (tuplesize == 2)
409 values[idx] = mySamplerCache->getValueAtIndexV2(i,
j, k);
410 if constexpr (tuplesize == 3)
411 values[idx] = mySamplerCache->getValueAtIndexV3(i,
j, k);
412 if constexpr (tuplesize == 4)
413 values[idx] = mySamplerCache->getValueAtIndexV4(i,
j, k);
415 allconstant &= (values[0] == values[idx]);
437 #endif // __GEO_VOLUMESAMPLER_H_INCLUDED__
int getVectorSize() const
exint getValueI(const UT_Vector3 &pos)
void posToIndex(UT_Vector3 pos, int &x, int &y, int &z) const
Convert a 3d position into the closest index value.
GEO_VolumeSampler & operator=(const GEO_VolumeSampler &src)
#define SYS_STATIC_ASSERT(expr)
void indexToPos(exint x, exint y, exint z, UT_Vector3D &pos) const
void posToIndex(UT_Vector3 pos, UT_Vector3 &index) const
BASE getValueByType(const UT_Vector3 &pos)
virtual ~GEO_VolumeSamplerCache()
void findexToPos(UT_Vector3D index, UT_Vector3D &pos) const
UT_Vector2T< fpreal64 > UT_Vector2D
UT_Vector2D getValueAtIndexV2(int ix, int iy, int iz)
void findexToPos(UT_Vector3 index, UT_Vector3 &pos) const
UT_Vector2D getValueV2(const UT_Vector3 &pos)
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)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
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)
UT_Vector4D getValueV4(const UT_Vector3 &pos)
const GEO_PrimVDB * myVdb
SYS_FORCE_INLINE int getTupleSize() const
Get the tuple size, usually 1 or 3.
UT_Vector3T< fpreal64 > UT_Vector3D
UT_UniquePtr< GEO_VolumeSamplerCache > mySamplerCache
void indexToPos(int x, int y, int z, UT_Vector3 &pos) const
BASE getValueByType(const UT_Vector3 &pos)
GLenum GLsizei GLsizei GLint * values
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)
UT_Vector4T< fpreal64 > UT_Vector4D
const GEO_PrimVolume * myVol
UT_Vector4D getValueAtIndexV4(int ix, int iy, int iz)
exint getValueAtIndexI(int ix, int iy, int iz)
void posToIndex(UT_Vector3D pos, exint &x, exint &y, exint &z) const