15 #ifndef __UT_VoxelArray__
16 #define __UT_VoxelArray__
42 #ifdef VOXEL_USE_TBB_ALLOC
44 #include <tbb/scalable_allocator.h>
46 #define UT_VOXEL_ALLOC(x) scalable_malloc(x)
47 #define UT_VOXEL_FREE(x) scalable_free(x)
51 #define UT_VOXEL_ALLOC(x) SYSamalloc((x), 128)
52 #define UT_VOXEL_FREE(x) SYSafree(x)
60 static const int TILEBITS = 4;
61 static const int TILESIZE = 1 << TILEBITS;
62 static const int TILEMASK = TILESIZE-1;
77 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrite>
class UT_VoxelProbe;
131 template <
typename T>
141 int x,
int y,
int z,
T t)
const = 0;
146 int x,
int y,
int z)
const = 0;
166 virtual bool canSave()
const {
return false; }
177 virtual const char *
getName() = 0;
192 #define DEFINE_STD_FUNC(TYPE) \
194 UTvoxelTileExpandMinMax(TYPE v, TYPE &min, TYPE &max) \
203 UTvoxelTileDist(TYPE a, TYPE b) \
205 return (fpreal) SYSabs(a - b); \
217 #undef DEFINE_STD_FUNC
292 template <
typename T>
320 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
322 switch (myCompressionType)
326 ((z * myRes[1]) + y) * myRes[0] +
x ];
333 ((z * TILESIZE) + y) * TILESIZE +
x ];
339 ((z * myRes[1]) + y) * myRes[0] +
x ]);
348 return engine->
getValue(*
this, x, y, z);
354 return v1 + (v2 -
v1) * bias;
361 template <
int AXIS2D>
372 template <
int AXIS2D>
408 int srcx,
int srcy,
int srcz);
411 template <
typename S>
416 template <
typename S>
448 if (
isRaw())
return true;
450 if (
isRawFull() && myRes[0] == TILESIZE && myRes[1] == TILESIZE)
491 {
return (
const T *) &
myData; }
495 int xres()
const {
return myRes[0]; }
496 int yres()
const {
return myRes[1]; }
497 int zres()
const {
return myRes[2]; }
499 int getRes(
int dim)
const {
return myRes[dim]; }
502 int numVoxels()
const {
return myRes[0] * myRes[1] * myRes[2]; }
544 void save(std::ostream &os)
const;
572 { myRes[0] = xr; myRes[1] = yr; myRes[2] = zr; }
576 return (
sizeof(
T) <=
sizeof(
T*));
589 myCompressionType = compress_type;
598 myForeignData =
true;
612 else if (
myData && !myForeignData)
617 myForeignData =
false;
630 int8 myCompressionType;
641 template <
typename S,
bool DoWrite,
bool DoRead,
bool TestForWrites>
654 template <
typename T>
671 void size(
int xres,
int yres,
int zres,
bool reset =
true);
678 template <
typename S>
689 int getRes(
int axis)
const {
return myRes[axis]; }
737 float fx,
float fy,
float fz) const;
738 template <
int AXIS2D>
740 template <
int AXIS2D>
742 float fx,
float fy,
float fz) const;
749 template <
int AXIS2D>
756 T &lerp,
T &lmin,
T &lmax,
758 float fx,
float fy,
float fz) const;
759 template <
int AXIS2D>
761 T &lerp,
T &lmin,
T &lmax,
763 float fx,
float fy,
float fz) const;
769 template <
int AXIS2D>
784 float fx,
float fy,
float fz) const;
785 template <
int AXIS2D>
787 float fx,
float fy,
float fz) const;
790 float &fx,
float &fy,
float &fz)
const
794 SYSfastSplitFloat(fx, x);
796 SYSfastSplitFloat(fy, y);
798 SYSfastSplitFloat(fz, z);
800 template <
int AXIS2D>
802 float &fx,
float &fy,
float &fz)
const
808 SYSfastSplitFloat(fx, x);
818 SYSfastSplitFloat(fy, y);
828 SYSfastSplitFloat(fz, z);
843 fpreal radius,
int clampaxis = -1)
const;
848 float filterwidthscale = 1.0
f,
866 template <
int AXIS2D>
879 void flattenGLFixed8Partial(uint8 *flatarray,
880 exint ystride, exint zstride,
893 void flattenGL16FPartial(UT_Vector4H *flatarray,
894 exint ystride, exint zstride,
909 void flattenGL32FPartial(UT_Vector4F *flatarray,
910 exint ystride, exint zstride,
917 extractFromFlattened,
918 const T *, flatarray,
921 void extractFromFlattenedPartial(const T *flatarray,
922 exint ystride, exint zstride,
931 copyWithOffsetInternal,
936 void copyWithOffsetInternalPartial(const
UT_VoxelArray<T> &src,
937 int offx,
int offy,
int offz,
957 template <typename
S>
960 template <typename
S, typename IDX>
962 const IDX *ix, const IDX *iy, const IDX *iz,
968 template <typename S>
969 const S *
writeTiles(const S *srcdata,
int srcstride,
971 template <typename S, typename IDX>
972 const S *
writeTiles(const S *srcdata,
int srcstride,
973 const IDX *ix, const IDX *iy, const IDX *iz,
1006 return !((x | y |
z) < 0) &&
1007 (((x - myRes[0]) & (y - myRes[1]) & (z - myRes[2])) < 0);
1014 return (*
this)(index[0], index[1], index[2]);
1019 return (*
getTile(x >> TILEBITS,
1022 (x & TILEMASK, y & TILEMASK, z & TILEMASK);
1027 setValue(index[0], index[1], index[2], value);
1035 z >> TILEBITS)->setValue(
1036 x & TILEMASK, y & TILEMASK, z & TILEMASK, t);
1045 return (*
this)(
x,
y,
z);
1049 return myBorderValue;
1052 switch (myBorderType)
1055 return myBorderValue;
1086 cx =
x; cy =
y; cz =
z;
1089 result = (*this)(cx, cy, cz);
1090 result += (x - cx) * myBorderScale[0] +
1091 (y - cy) * myBorderScale[1] +
1092 (z - cz) * myBorderScale[2];
1098 return (*
this)(
x,
y,
z);
1115 {bbox.
xmin() >> TILEBITS,
1116 bbox.
ymin() >> TILEBITS,
1117 bbox.
zmin() >> TILEBITS,
1118 ((bbox.
xmax() - 1) >> TILEBITS) + 1,
1119 ((bbox.
ymax() - 1) >> TILEBITS) + 1,
1120 ((bbox.
zmax() - 1) >> TILEBITS) + 1};
1122 bool allconstant =
true;
1126 for (
int kt = tiles.
zmin(); kt < tiles.
zmax(); kt++)
1129 tilesamples.
vals[2][0] = TILESIZE * kt;
1130 tilesamples.
vals[2][1] = TILESIZE * (kt + 1);
1132 if (kt == tiles.
zmin())
1133 tilesamples.
vals[2][0] = bbox.
zmin();
1134 if (kt == tiles.
zmax() - 1)
1135 tilesamples.
vals[2][1] = bbox.
zmax();
1137 for (
int jt = tiles.
ymin(); jt < tiles.
ymax(); jt++)
1140 tilesamples.
vals[1][0] = TILESIZE * jt;
1141 tilesamples.
vals[1][1] = TILESIZE * (jt + 1);
1143 if (jt == tiles.
ymin())
1144 tilesamples.
vals[1][0] = bbox.
ymin();
1145 if (jt == tiles.
ymax() - 1)
1146 tilesamples.
vals[1][1] = bbox.
ymax();
1148 for (
int it = tiles.
xmin(); it < tiles.
xmax(); it++)
1151 tilesamples.
vals[0][0] = TILESIZE * it;
1152 tilesamples.
vals[0][1] = TILESIZE * (it + 1);
1154 if (it == tiles.
xmin())
1155 tilesamples.
vals[0][0] = bbox.
xmin();
1156 if (it == tiles.
xmax() - 1)
1157 tilesamples.
vals[0][1] = bbox.
xmax();
1159 const bool inbounds = tilesamples.
isInside(bounds);
1165 for (
int k = tilesamples.
zmin();
1166 k < tilesamples.
zmax(); k++)
1168 for (
int j = tilesamples.
ymin();
1169 j < tilesamples.
ymax(); j++)
1171 for (
int i = tilesamples.
xmin();
1172 i < tilesamples.
xmax(); i++)
1179 const int locallinindex
1181 + bbox.
xsize() * (localindex.
y()
1182 + bbox.
ysize() * localindex.
z());
1184 values[locallinindex] = (*tile)(
1190 && (values[0] != values[locallinindex]))
1192 allconstant =
false;
1200 for (
int k = tilesamples.
zmin(); k < tilesamples.
zmax(); k++)
1202 for (
int j = tilesamples.
ymin();
1203 j < tilesamples.
ymax(); j++)
1205 for (
int i = tilesamples.
xmin();
1206 i < tilesamples.
xmax(); i++)
1213 const int locallinindex
1215 + bbox.
xsize() * (localindex.
y()
1216 + bbox.
ysize() * localindex.
z());
1218 values[locallinindex] =
getValue(i, j, k);
1221 && (values[0] != values[locallinindex]))
1223 allconstant =
false;
1264 expandAllNonConstTiles)
1272 {
return &myTiles[idx]; }
1275 x = idx % myTileRes[0];
1277 idx /= myTileRes[0];
1278 y = idx % myTileRes[1];
1280 idx /= myTileRes[1];
1286 tileindex[0] = idx % myTileRes[0];
1287 idx -= tileindex[0];
1288 idx /= myTileRes[0];
1289 tileindex[1] = idx % myTileRes[1];
1290 idx -= tileindex[1];
1291 idx /= myTileRes[1];
1298 {
return (z * myTileRes[1] + y) * myTileRes[0] +
x; }
1301 {
return ((z >> TILEBITS) * myTileRes[1] + (y >> TILEBITS)) * myTileRes[0] + (x >> TILEBITS); }
1310 start.
x() = x * TILESIZE;
1311 start.
y() = y * TILESIZE;
1312 start.
z() = z * TILESIZE;
1314 end.
x() += myTiles[idx].xres();
1315 end.
y() += myTiles[idx].yres();
1316 end.
z() += myTiles[idx].zres();
1330 {
return myTileRes[0] * myTileRes[1] * myTileRes[2]; }
1332 {
return ((
exint)myRes[0]) * myRes[1] * myRes[2]; }
1335 { myCompressionOptions = options; }
1337 {
return myCompressionOptions; }
1347 void saveData(std::ostream &os)
const;
1349 const char *shared_mem_owner = 0)
const;
1372 const UT_Filter *filter,
1378 void deleteVoxels();
1381 bool populateFromSharedMemory(const
char *
id);
1421 template <typename T>
1427 enum mipmaptype { MIPMAP_MAXIMUM=0, MIPMAP_AVERAGE=1, MIPMAP_MINIMUM=2 };
1442 mipmaptype
function);
1459 typedef bool (*Callback)(
const T *funcs,
1461 bool baselevel,
void *
data);
1462 void traverseTopDown(Callback
function,
1472 template <
typename OP>
1473 void traverseTopDown(OP&op)
const;
1480 template <
typename OP>
1481 void traverseTopDownSorted(OP&op)
const;
1496 return myLevels(
function)[numLevels() - 1 -
level];
1500 void doTraverse(
int x,
int y,
int z,
int level,
1505 template <
typename OP>
1506 void doTraverse(
int x,
int y,
int z,
int level,
1508 template <
typename OP>
1509 void doTraverseSorted(
int x,
int y,
int z,
int level,
1512 void initializePrivate();
1513 void destroyPrivate();
1518 const UT_VoxelArray<T> &,
src,
1519 mipmaptype,
function)
1520 void downsamplePartial(UT_VoxelArray<T> &dst,
1521 const UT_VoxelArray<T> &src,
1522 mipmaptype
function,
1530 case MIPMAP_MAXIMUM:
1533 case MIPMAP_AVERAGE:
1534 return (t1 + t2) / 2;
1536 case MIPMAP_MINIMUM:
1583 template <
typename T>
1595 myHandle.resetHandle();
1598 setPartialRange(0, 1);
1618 setPartialRange(0, 1);
1626 void setPartialRange(
int idx,
int numranges);
1635 template <
typename S>
1643 myTileEnd = myTileStart+1;
1666 void restrictToBBox(
int xmin,
int xmax,
1668 int zmin,
int zmax);
1675 {
return myCurTile < 0; }
1683 myTileLocalPos[0]++;
1684 if (myTileLocalPos[0] >= myTileSize[0])
1687 myPos[0] -= myTileLocalPos[0];
1688 myTileLocalPos[0] = 0;
1691 myTileLocalPos[1]++;
1692 if (myTileLocalPos[1] >= myTileSize[1])
1695 myPos[1] -= myTileLocalPos[1];
1696 myTileLocalPos[1] = 0;
1699 myTileLocalPos[2]++;
1700 if (myTileLocalPos[2] >= myTileSize[2])
1710 int x()
const {
return myPos[0]; }
1711 int y()
const {
return myPos[1]; }
1712 int z()
const {
return myPos[2]; }
1713 int idx(
int idx)
const {
return myPos[
idx]; }
1724 tile = myArray->getLinearTile(myCurTile);
1725 return (*tile)(myTileLocalPos[0],
1737 tile = myArray->getLinearTile(myCurTile);
1741 myTileLocalPos[2], t);
1751 tile = myArray->getLinearTile(myCurTile);
1758 start.
x() = myTilePos[0] * TILESIZE;
1759 start.
y() = myTilePos[1] * TILESIZE;
1760 start.
z() = myTilePos[2] * TILESIZE;
1762 end.
x() += myTileSize[0];
1763 end.
y() += myTileSize[1];
1764 end.
z() += myTileSize[2];
1778 {
return !(myTileLocalPos[0] ||
1779 myTileLocalPos[1] ||
1780 myTileLocalPos[2]); }
1786 return myArray->getLinearTile(myCurTile);
1802 void skipToEndOfTile();
1808 { myShouldCompressOnExit = shouldcompress; }
1819 template <
typename OP>
1820 void applyOperation(OP &op);
1821 template <
typename OP,
typename S>
1823 template <
typename OP>
1824 void applyOperation(OP &op, T
a);
1825 template <
typename OP,
typename S,
typename R>
1828 template <
typename OP,
typename S,
typename R,
typename Q>
1836 template <
typename OP,
typename S>
1838 template <
typename OP>
1839 void applyOperationCheckNoop(OP &op, T
a);
1843 template <
typename OP,
typename M>
1844 void maskedApplyOperation(OP &op,
1846 template <
typename OP,
typename S,
typename M>
1849 template <
typename OP,
typename S,
typename R,
typename M>
1853 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1863 template <
typename OP,
typename S>
1865 template <
typename OP,
typename S,
typename R>
1868 template <
typename OP,
typename S,
typename R,
typename Q>
1876 template <
typename OP,
typename S,
typename M>
1879 template <
typename OP,
typename S,
typename R,
typename M>
1883 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1892 template <
typename OP>
1893 void reduceOperation(OP &op);
1929 int myTileLocalPos[3];
1954 template <
typename T>
1960 template <
typename S>
1965 template <
typename S>
1972 myTileStart[0] = vit.
x();
1973 myTileStart[1] = vit.
y();
1974 myTileStart[2] = vit.
z();
1988 myTileStart[0], myTileStart[1], myTileStart[2]);
1989 myTileStart[0] <<= TILEBITS;
1990 myTileStart[1] <<= TILEBITS;
1991 myTileStart[2] <<= TILEBITS;
1999 {
return myCurTile == 0 || myAtEnd; }
2007 myTileLocalPos[0]++;
2008 if (myTileLocalPos[0] >= myTileSize[0])
2011 myPos[0] -= myTileLocalPos[0];
2012 myTileLocalPos[0] = 0;
2015 myTileLocalPos[1]++;
2016 if (myTileLocalPos[1] >= myTileSize[1])
2019 myPos[1] -= myTileLocalPos[1];
2020 myTileLocalPos[1] = 0;
2023 myTileLocalPos[2]++;
2024 if (myTileLocalPos[2] >= myTileSize[2])
2035 int x()
const {
return myPos[0]; }
2036 int y()
const {
return myPos[1]; }
2037 int z()
const {
return myPos[2]; }
2038 int idx(
int idx)
const {
return myPos[
idx]; }
2047 return (*myCurTile)(myTileLocalPos[0],
2057 myCurTile->setValue(myTileLocalPos[0],
2059 myTileLocalPos[2], t);
2067 return myCurTile->isConstant();
2072 {
return !(myTileLocalPos[0] ||
2073 myTileLocalPos[1] ||
2074 myTileLocalPos[2]); }
2090 { myShouldCompressOnExit = shouldcompress; }
2096 template <
typename OP>
2097 bool reduceOperation(OP &op);
2119 int myTileLocalPos[3];
2141 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2151 int prex = 0,
int postx = 0)
2167 return myCurLine[myStride*
offset];
2183 template <
typename S>
2185 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2186 template <
typename S>
2188 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2190 bool setIndex(
int x,
int y,
int z);
2195 myCurLine += myStride;
2204 myCurLine += myStride * (x - myX);
2206 UT_ASSERT_P(myX < myMaxValidX && myX >= myMinValidX);
2210 void reloadCache(
int x,
int y,
int z);
2212 void writeCacheLine();
2214 void buildConstantCache(T
value);
2246 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2253 { setArray(vx, vy, vz); }
2259 myLines[0].setArray(vx);
2260 myLines[1].setArray(vy);
2261 myLines[2].setArray(vz);
2275 return myLines[axis].getValue();
2280 myLines[0].setValue(v.
x());
2281 myLines[1].setValue(v.
y());
2282 myLines[2].setValue(v.
z());
2287 myLines[axis].setValue(val);
2294 template <
typename S>
2296 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2297 template <
typename S>
2299 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2303 if (myLines[0].setIndex(x, y, z))
2305 myLines[1].setIndex(x, y, z);
2306 myLines[2].setIndex(x, y, z);
2309 myLines[1].advanceX();
2310 myLines[2].advanceX();
2315 { myLines[0].advanceX(); myLines[1].advanceX(); myLines[2].advanceX(); }
2321 template <
typename T>
2340 y >= -1 && y <= 1 &&
2343 return myLines[y+1][z+1].getValue(x);
2350 return getValue(offset[0], offset[1], offset[2]);
2353 template <
typename S>
2355 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2356 template <
typename S>
2358 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2359 bool setIndexCube(
int x,
int y,
int z);
2361 template <
typename S>
2363 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2364 template <
typename S>
2366 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2367 bool setIndexPlus(
int x,
int y,
int z);
2407 template <
typename T>
2415 template <
typename S>
2418 template <
typename S>
2439 template <
typename T,
int XStep,
int YStep,
int ZStep>
2449 template <
typename S>
2451 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2452 template <
typename S>
2454 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2455 bool setIndex(
int x,
int y,
int z);
2462 return (valueZ(1) + valueZ(0)) * 0.5;
2470 return (valueYZ(1, z) + valueYZ(0, z)) * 0.5;
2471 return valueYZ(0, z);
2480 return myLines[
y][
z].getValue();
2493 template <
typename T>
2502 void setVoxelSize(
const UT_Vector3 &voxelsize);
2504 template <
typename S>
2506 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2507 template <
typename S>
2509 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2510 bool setIndex(
int x,
int y,
int z);
2515 inline T
face(
int axis,
int side)
const
2518 return myLines[0][0].getValue(side);
2520 return myLines[axis][side].getValue();
2535 return (
face(0,1)-
face(0,0)) * myVoxelSize.x()
2536 + (
face(1,1)-
face(1,0)) * myVoxelSize.y()
2537 + (
face(2,1)-
face(2,0)) * myVoxelSize.z();
UT_COWWriteHandle< UT_VoxelArray< UT_Vector4 > > UT_VoxelArrayWriteHandleV4
void setTile(const UT_VoxelArrayIterator< T > &vit)
exint exint const UT_JobInfo &info const
int x() const
Retrieve the current location of the iterator.
UT_Interrupt * myInterrupt
UT_Vector3I getVoxelRes() const
int xyzTileToLinear(int x, int y, int z) const
void findexToPos(UT_Vector3F ipos, UT_Vector3F &pos) const
UT_VoxelCompressOptions()
SYS_FORCE_INLINE T lerpSample(T *samples, float fx, float fy, float fz) const
Lerps the given sample using trilinear interpolation.
GLboolean GLboolean GLboolean b
const UT_VoxelTile< T > & operator=(const UT_VoxelTile< T > &src)
UT_VoxelTile< T > * getTile() const
Returns the VoxelTile we are currently processing.
void findAverage(T &avg) const
Determines the average value of the tile.
#define SYS_STATIC_ASSERT(expr)
UT_Vector3I linearTileToXYZ(int idx) const
UT_VoxelProbe< fpreal32, true, true, true > UT_VoxelRWTProbeF
void setInterrupt(UT_Interrupt *interrupt)
void loadData(UT_IStream &is)
Load an array, requires you have already size()d this array.
UT_VoxelBorderType getBorder() const
exint getDataLength() const
Returns the amount of data used by the tile myData pointer.
bool atEnd() const
Returns true if we have iterated over all of the voxels.
UT_COWHandle< UT_VoxelArray< fpreal32 > > UT_VoxelArrayHandleF
void match(const UT_VoxelArray< T > &src)
SYS_FORCE_INLINE T getValue(const UT_Vector3I &offset) const
bool isMatching(const UT_VoxelArray< S > &src) const
Axis-aligned bounding box (AABB).
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
void setValue(UT_Vector3I index, T value)
virtual const char * getName()=0
T valueYZ(int y, int z) const
void resample(const UT_VoxelArray< T > &src, UT_FilterType filtertype=UT_FILTER_POINT, float filterwidthscale=1.0f, int clampaxis=-1)
Fills this by resampling the given voxel array.
const UT_VoxelCompressOptions & getCompressionOptions() const
UT_VoxelTile< T > * getTile() const
Returns the VoxelTile we are currently processing.
int64 getMemoryUsage(bool inclusive) const
Return the amount of memory used by this array.
int myMinValidX
Half inclusive [,) range of valid x queries for current cache.
bool setIndex(UT_VoxelTileIterator< S > &vit)
SYS_FORCE_INLINE void freeData()
bool myShouldCompressOnExit
T operator()(UT_Vector3D pos) const
THREADED_METHOD3_CONST(UT_VoxelArray< T >, numTiles() > 16, flatten, T *, flatarray, exint, ystride, exint, zstride) void flattenPartial(T *flatarray
UT_Vector3 gradient() const
UT_COWReadHandle< UT_VoxelArray< T > > myHandle
UT_VoxelArray< fpreal32 > UT_VoxelArrayF
void clampIndex(int &x, int &y, int &z) const
UT_COWReadHandle< UT_VoxelArray< fpreal32 > > UT_VoxelArrayReadHandleF
virtual T getValue(const UT_VoxelTile< T > &tile, int x, int y, int z) const =0
T * fillCacheLine(T *cacheline, int &stride, int x, int y, int z, bool forcecopy, bool strideofone) const
static void registerCompressionEngine(UT_VoxelTileCompress< T > *engine)
fpreal myQuantizeTol
Tolerance for quantizing to reduced bit depth.
virtual bool lerp(GA_AttributeOperand &d, GA_AttributeOperand &a, GA_AttributeOperand &b, GA_AttributeOperand &t) const
d = SYSlerp(a, b, t);
UT_VoxelVectorProbe< fpreal32, true, true, true > UT_VoxelVectorRWTProbeF
UT_Vector3T< float > UT_Vector3
UT_VoxelTile< T > * myCurTile
Current processing tile.
UT_VoxelVectorProbe(UT_VoxelArray< T > *vx, UT_VoxelArray< T > *vy, UT_VoxelArray< T > *vz)
UT_VoxelArray< T > * myBaseLevel
constexpr SYS_FORCE_INLINE T & z() noexcept
T divergence() const
Returns the divergence of this cell.
SYS_FORCE_INLINE void splitVoxelCoordAxis(UT_Vector3F pos, int &x, int &y, int &z, float &fx, float &fy, float &fz) const
void setValue(T t) const
Sets the voxel we are currently pointing to the given value.
bool isStartOfTile() const
Returns true if we are at the start of a new tile.
bool myOwnBase
If true, we will delete the base level when we are done.
UT_VoxelArray< UT_Vector4 > UT_VoxelArrayV4
JSON reader class which handles parsing of JSON or bJSON files.
bool posToIndex(UT_Vector3 pos, int &x, int &y, int &z) const
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
UT_VoxelArray< T > * myArray
fpreal UTvoxelTileDist(const UT_Vector2 &a, const UT_Vector2 &b)
void setArray(UT_VoxelArray< T > *vox)
T mixValues(T t1, T t2, mipmaptype function) const
Class which writes ASCII or binary JSON streams.
ImageBuf OIIO_API flatten(const ImageBuf &src, ROI roi={}, int nthreads=0)
void copyWithOffset(const UT_VoxelArray< T > &src, int offx, int offy, int offz)
int indexToLinearTile(int x, int y, int z) const
GLuint const GLchar * name
UT_VoxelTileIterator< int64 > UT_VoxelTileIteratorI
bool isConstant(T *cval=0) const
UT_Vector3T< int64 > UT_Vector3I
void makeConstant(T t)
Turns this tile into a constant tile of the given value.
bool indexToPos(int x, int y, int z, UT_Vector3F &pos) const
T face(int axis, int side) const
bool setIndex(UT_VoxelArrayIterator< S > &vit)
UT_VoxelVectorProbe< fpreal32, true, true, false > UT_VoxelVectorRWProbeF
SYS_FORCE_INLINE T rawConstVal() const
void UTvoxelTileExpandMinMax(UT_Vector2 v, UT_Vector2 &min, UT_Vector2 &max)
bool atEnd() const
Returns true if we have iterated over all of the voxels.
void setCompressionOptions(const UT_VoxelCompressOptions &options)
virtual bool load(UT_JSONParser &p, UT_VoxelTile< T > &tile) const
UT_VoxelArray< T > * getArray() const
int myCurTile
Our current linear tile idx. A value of -1 implies at end.
int myMinValidX
Half inclusive [,) range of valid x queries for current cache.
void setCompressionTolerance(fpreal tol)
void setHandle(UT_COWReadHandle< UT_VoxelArray< T > > handle)
void flatten(S *dst, int dststride) const
Flattens ourself into the given destination buffer.
void makeFpreal16()
Explicit compress to fpreal16. Lossy. No-op if already constant.
void size(int xres, int yres, int zres, bool reset=true)
SYS_FORCE_INLINE T operator()(int x, int y, int z) const
virtual bool writeThrough(UT_VoxelTile< T > &tile, int x, int y, int z, T t) const =0
UT_VoxelProbeCube< fpreal32 > UT_VoxelROProbeCubeF
UT_VoxelVectorProbe< fpreal32, true, false, false > UT_VoxelVectorProbeF
GLenum GLsizei GLsizei GLint * values
SYS_FORCE_INLINE bool extractSample(int x, int y, int z, T *sample) const
virtual ~UT_VoxelTileCompress()
GLubyte GLubyte GLubyte GLubyte w
static fpreal dist(T a, T b)
bool setIndex(int x, int y, int z)
ImageBuf OIIO_API laplacian(const ImageBuf &src, ROI roi={}, int nthreads=0)
bool getCompressOnExit() const
SYS_NO_DISCARD_RESULT SYS_FORCE_INLINE bool extractSample(int x, int y, int z, T *sample) const
bool writeThrough(int x, int y, int z, T t)
UT_VoxelTileIterator< fpreal32 > UT_VoxelTileIteratorF
void moveTilesWithOffset(UT_VoxelArray< T > &src, int tileoffx, int tileoffy, int tileoffz)
const T * rawData() const
T getBorderScale(int axis) const
const S * writeTiles(const S *srcdata, int srcstride, const UT_IntArray &tilelist)
bool hasNan() const
Returns true if any NANs are in this tile.
void setArray(UT_VoxelArray< T > *vx, UT_VoxelArray< T > *vy, UT_VoxelArray< T > *vz)
void advance()
Advances the iterator to point to the next voxel.
SYS_FORCE_INLINE bool extractSampleAxis(int x, int y, int z, T *sample) const
void setTile(const UT_VoxelArrayIterator< S > &vit, UT_VoxelArray< T > *array)
THREADED_METHOD4(UT_VoxelArray< T >, numTiles() > 4, copyWithOffsetInternal, const UT_VoxelArray< T > &, src, int, offx, int, offy, int, offz) void copyWithOffsetInternalPartial(const UT_VoxelArray< T > &src
int myCurTileListIdx
Our current index into the tile list.
void setValue(T t) const
Sets the voxel we are currently pointing to the given value.
virtual void load(UT_IStream &is, UT_VoxelTile< T > &tile) const
GLfloat GLfloat GLfloat v2
int64 getMemoryUsage(bool inclusive) const
Returns the amount of memory used by this tile.
THREADED_METHOD4_CONST(UT_VoxelArray< T >, numTiles() > 16, flattenGLFixed8, uint8 *, flatarray, exint, ystride, exint, zstride, T, dummy) void flattenGLFixed8Partial(uint8 *flatarray
void weightedSum(int pstart[3], int pend[3], const float *weights[3], int start[3], T &result)
SYS_FORCE_INLINE T lerpAxis(int x, int y, int z, float fx, float fy, float fz) const
UT_BoundingBoxI getTileBBox() const
int getLinearTileNum() const
bool getValues(const UT_BoundingBoxI &bbox, T *values, const exint size) const
SYS_FORCE_INLINE bool extractSamplePlus(int x, int y, int z, T *sample) const
static void saveCompressionTypes(std::ostream &os)
Stores a list of compresson engines to os.
UT_VoxelArray< T > * myArray
The array we belong to.
GLboolean GLboolean GLboolean GLboolean a
virtual void save(std::ostream &os, const UT_VoxelTile< T > &tile) const
const UT_VoxelArray< T > & operator=(const UT_VoxelArray< T > &src)
Assignment operator:
UT_VoxelArray< T > * getArray() const
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
GLuint GLfloat GLfloat y0
void makeRawUninitialized()
void setTile(const UT_VoxelArrayIterator< S > &vit, UT_VoxelArray< T > *array)
void setValue(int x, int y, int z, T t)
UT_VoxelTile< T > * getTile(int tx, int ty, int tz) const
GLdouble GLdouble GLdouble z
UT_VoxelProbe< UT_Vector4, true, true, true > UT_VoxelRWTProbeV4
void setCompressOnExit(bool shouldcompress)
T evaluate(const UT_Vector3 &pos, const UT_Filter &filter, fpreal radius, int clampaxis=-1) const
UT_VoxelMipMap< fpreal32 > UT_VoxelMipMapF
SYS_NO_DISCARD_RESULT SYS_FORCE_INLINE bool extractSampleAxis(int x, int y, int z, T *sample) const
bool setIndex(UT_VoxelTileIterator< S > &vit)
#define SYS_NO_DISCARD_RESULT
#define SYS_STATIC_FORCE_INLINE
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
bool tryCompress(const UT_VoxelCompressOptions &options)
virtual bool canSave() const
Does this engine support saving and loading?
int getRes(int dim) const
THREADED_METHOD(UT_VoxelArray< T >, numTiles() > 100, collapseAllTiles) void collapseAllTilesPartial(const UT_JobInfo &info)
void setRes(int xr, int yr, int zr)
UT_VoxelArray< int64 > UT_VoxelArrayI
THREADED_METHOD1(UT_VoxelArray< T >, numTiles() > 100, constant, T, t) void const antPartial(T t
bool setIndexPlus(UT_VoxelTileIterator< S > &vit)
UT_API UT_ValArray< UT_VoxelTileCompress< fpreal16 > * > & UTvoxelTileGetCompressionEngines(fpreal16 *dummy)
bool setIndex(UT_VoxelArrayIterator< S > &vit)
virtual bool isLossless() const
Returns true if the compression type is lossless.
void getTileVoxels(int idx, UT_Vector3I &start, UT_Vector3I &end) const
idxth tile represents the voxels indexed [start,end).
SYS_FORCE_INLINE bool extractSampleCube(int x, int y, int z, T *sample) const
SYS_FORCE_INLINE bool inlineConstant() const
void writeCacheLine(T *cacheline, int y, int z)
Fills a cache line from an external buffer into our own data.
void advanceX()
Blindly advances our current pointer.
bool isStartOfTile() const
Returns true if we are at the start of a new tile.
void setValue(int x, int y, int z, T t)
SYS_FORCE_INLINE T lerpVoxelCoordAxis(UT_Vector3F pos) const
UT_VoxelArrayIterator< int64 > UT_VoxelArrayIteratorI
virtual int getDataLength(const UT_VoxelTile< T > &tile) const =0
bool isTileConstant() const
Returns true if the tile we are currently in is a constant tile.
void getTileVoxels(UT_Vector3I &start, UT_Vector3I &end) const
This tile will iterate over the voxels indexed [start,end).
bool myAllowFP16
Conversion to fpreal16, only valid for scalar data.
SYS_FORCE_INLINE T lerpVoxelCoord(UT_Vector3F pos) const
bool setIndex(UT_VoxelArrayIterator< S > &vit)
const UT_JobInfo * myJobInfo
The job info to use for tilefetching.
void setConstArray(const UT_VoxelArray< T > *vox, int prex=0, int postx=0)
static UT_VoxelTileCompress< T > * getCompressionEngine(int index)
bool getCompressOnExit() const
UT_VoxelTileIterator< UT_Vector4 > UT_VoxelTileIteratorV4
UT_VoxelProbe< fpreal32, false, true, false > UT_VoxelWOProbeF
virtual void findMinMax(const UT_VoxelTile< T > &tile, T &min, T &max) const
void setLinearTile(exint lineartilenum, UT_VoxelArray< T > *array)
void setTile(const UT_VoxelArrayIterator< T > &vit)
bool isRawFull() const
Returns if this tile is in raw full format.
bool hasNan() const
Returns true if any element of the voxel array is NAN.
int myMinValidX
Half inclusive [,) range of valid x queries for current cache.
UT_VoxelVectorProbe< fpreal32, false, true, false > UT_VoxelVectorWOProbeF
UT_VoxelProbe< UT_Vector4, true, false, false > UT_VoxelProbeV4
T operator()(UT_Vector3I index) const
GLsizei const GLint box[]
SYS_FORCE_INLINE void lerpVoxelMinMaxAxis(T &lerp, T &lmin, T &lmax, int x, int y, int z, float fx, float fy, float fz) const
SYS_STATIC_FORCE_INLINE T lerpValues(T v1, T v2, fpreal32 bias)
Lerps two numbers, templated to work with T.
T getValue(int x, int y, int z) const
bool setIndexPlus(UT_VoxelArrayIterator< S > &vit)
SYS_FORCE_INLINE T lerpVoxel(int x, int y, int z, float fx, float fy, float fz) const
T getValue(int offset) const
void copyFragment(int dstx, int dsty, int dstz, const UT_VoxelTile< T > &srctile, int srcx, int srcy, int srcz)
void uncompress()
Turns a compressed tile into a raw tile.
UT_VoxelArray< T > * myArray
THREADED_METHOD3(UT_VoxelArray< T >, numTiles() > 16, extractFromFlattened, const T *, flatarray, exint, ystride, exint, zstride) void extractFromFlattenedPartial(const T *flatarray
UT_COWReadHandle< UT_VoxelArray< UT_Vector4 > > UT_VoxelArrayReadHandleV4
void setConstArray(const UT_VoxelArray< T > *vox)
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
SYS_FORCE_INLINE void splitVoxelCoord(UT_Vector3F pos, int &x, int &y, int &z, float &fx, float &fy, float &fz) const
T getValue(int axis) const
UT_VoxelProbe< fpreal32, true, false, false > UT_VoxelProbeF
UT_BoundingBoxT< int64 > UT_BoundingBoxI
SYS_FORCE_INLINE T getValue(int x, int y, int z) const
UT_VoxelProbe< fpreal32, true, true, false > UT_VoxelRWProbeF
bool isRaw() const
Returns if this tile is in raw format.
void saveData(std::ostream &os) const
UT_ValArray< UT_VoxelArray< T > ** > myLevels
int getRes(int axis) const
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
SYS_FORCE_INLINE void lerpVoxelCoordMinMax(T &lerp, T &lmin, T &lmax, UT_Vector3F pos) const
bool setIndex(UT_VoxelArrayIterator< S > &vit)
UT_BoundingBoxI getTileBBox(int idx) const
void linearTileToXYZ(int idx, int &x, int &y, int &z) const
GLsizei const GLfloat * value
UT_VoxelProbe< UT_Vector4, true, true, false > UT_VoxelRWProbeV4
void save(std::ostream &os) const
#define DEFINE_STD_FUNC(TYPE)
bool isTileConstant() const
Returns true if the tile we are currently in is a constant tile.
T operator()(int x, int y, int z) const
UT_COWHandle< UT_VoxelArray< UT_Vector4 > > UT_VoxelArrayHandleV4
int isInside(const UT_Vector3T< T > &pt) const
UT_VoxelTile< T > * getLinearTile(int idx) const
void load(UT_IStream &is, const UT_IntArray &compression)
UT_VoxelProbe< UT_Vector4, false, true, false > UT_VoxelWOProbeV4
void setCompressOnExit(bool shouldcompress)
static int lookupCompressionEngine(const char *name)
UT_COWWriteHandle< UT_VoxelArray< fpreal32 > > UT_VoxelArrayWriteHandleF
void setValue(const UT_Vector3 &v)
SYS_FORCE_INLINE void lerpVoxelMinMax(T &lerp, T &lmin, T &lmax, int x, int y, int z, float fx, float fy, float fz) const
bool setIndexCube(UT_VoxelArrayIterator< S > &vit)
bool setIndexCube(UT_VoxelTileIterator< S > &vit)
void uncompressFull()
Turns a tile into a raw full tile.
void setBorder(UT_VoxelBorderType type, T t)
UT_Vector3 getValue() const
T * rawFullData()
Returns the raw full data of the tile.
GLint GLenum GLboolean GLsizei stride
UT_VoxelArrayIterator< fpreal32 > UT_VoxelArrayIteratorF
virtual bool tryCompress(UT_VoxelTile< T > &tile, const UT_VoxelCompressOptions &options, T min, T max) const =0
void setForeignData(void *data, int8 compress_type)
SYS_FORCE_INLINE void lerpVoxelCoordMinMaxAxis(T &lerp, T &lmin, T &lmax, UT_Vector3F pos) const
static void expandMinMax(T v, T &min, T &max)
Designed to be specialized according to T.
constexpr SYS_FORCE_INLINE T & y() noexcept
bool extractSampleCube(int x, int y, int z, T *sample) const
void findMinMax(T &min, T &max) const
Finds the minimum and maximum T values.
bool isValidIndex(int x, int y, int z) const
Returns true if the given x, y, z values lie inside the valid index.
void setComponent(int axis, T val)
virtual bool save(UT_JSONWriter &w, const UT_VoxelTile< T > &tile) const
SYS_FORCE_INLINE T lerpVoxelAxis(int x, int y, int z, float fx, float fy, float fz) const
void setBorderScale(T scalex, T scaley, T scalez)
bool setIndex(UT_VoxelTileIterator< S > &vit)
bool setIndex(UT_VoxelTileIterator< S > &vit)
void setConstArray(const UT_VoxelArray< T > *vx, const UT_VoxelArray< T > *vy, const UT_VoxelArray< T > *vz)
const UT_VoxelArray< T > * level(int level, int function) const
int xres() const
Read the current resolution.
bool compressionEnabled() const
S * extractTiles(S *dstdata, int stride, const UT_IntArray &tilelist) const
bool setIndex(int x, int y, int z)
bool setIndex(UT_VoxelArrayIterator< S > &vit)
void writeData(const S *src, int srcstride)
SYS_FORCE_INLINE T * rawConstData() const
bool isSimpleCompression() const
SYS_FORCE_INLINE bool extractSamplePlus(int x, int y, int z, T *sample) const
bool isConstant() const
Returns if this tile is constant.
SYS_FORCE_INLINE T lerpSampleAxis(T *samples, float fx, float fy, float fz) const
GLenum GLuint GLint GLenum face
static void loadCompressionTypes(UT_IStream &is, UT_IntArray &compressions)
UT_VoxelArrayIterator< UT_Vector4 > UT_VoxelArrayIteratorV4
bool myShouldCompressOnExit
int getTileRes(int dim) const
void evaluateMinMax(T &lerp, T &lmin, T &lmax, UT_Vector3F pos) const
bool setIndex(UT_VoxelTileIterator< S > &vit)
fpreal getCompressionTolerance() const
void flattenPartialAxis(T *flatarray, exint ystride, const UT_JobInfo &info) const
void advance()
Advances the iterator to point to the next voxel.
SYS_FORCE_INLINE T lerp(int x, int y, int z, float fx, float fy, float fz) const
constexpr SYS_FORCE_INLINE T & x() noexcept