15 #ifndef __UT_VoxelArray__
16 #define __UT_VoxelArray__
43 #ifdef VOXEL_USE_TBB_ALLOC
45 #include <tbb/scalable_allocator.h>
47 #define UT_VOXEL_ALLOC(x) scalable_malloc(x)
48 #define UT_VOXEL_FREE(x) scalable_free(x)
52 #define UT_VOXEL_ALLOC(x) SYSamalloc((x), 128)
53 #define UT_VOXEL_FREE(x) SYSafree(x)
63 static const int TILEBITS = 4;
64 static const int TILESIZE = 1 << TILEBITS;
65 static const int TILEMASK = TILESIZE-1;
81 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrite>
class UT_VoxelProbe;
135 template <
typename T>
145 int x,
int y,
int z,
T t)
const = 0;
150 int x,
int y,
int z)
const = 0;
170 virtual bool canSave()
const {
return false; }
181 virtual const char *
getName() = 0;
196 #define DEFINE_STD_FUNC(TYPE) \
198 UTvoxelTileExpandMinMax(TYPE v, TYPE &min, TYPE &max) \
207 UTvoxelTileDist(TYPE a, TYPE b) \
209 return (fpreal) SYSabs(a - b); \
221 #undef DEFINE_STD_FUNC
296 template <
typename T>
326 return v1 + (v2 -
v1) * bias;
333 template <
int AXIS2D>
344 template <
int AXIS2D>
358 bool extractSampleCube(
int x,
int y,
int z,
385 int srcx,
int srcy,
int srcz);
388 template <
typename S>
393 template <
typename S>
425 if (
isRaw())
return true;
427 if (
isRawFull() && myRes[0] == TILESIZE && myRes[1] == TILESIZE)
468 {
return (
const T *) &
myData; }
472 int xres()
const {
return myRes[0]; }
473 int yres()
const {
return myRes[1]; }
474 int zres()
const {
return myRes[2]; }
476 int getRes(
int dim)
const {
return myRes[dim]; }
479 int numVoxels()
const {
return myRes[0] * myRes[1] * myRes[2]; }
493 const float *weights[3],
int start[3],
524 void save(std::ostream &os)
const;
552 { myRes[0] = xr; myRes[1] = yr; myRes[2] = zr; }
556 return (
sizeof(
T) <=
sizeof(
T*));
569 myCompressionType = compress_type;
578 myForeignData =
true;
592 else if (
myData && !myForeignData)
597 myForeignData =
false;
610 int8 myCompressionType;
621 template <
typename S,
bool DoWrite,
bool DoRead,
bool TestForWrites>
634 template <
typename T>
653 void size(
int xres,
int yres,
int zres,
bool reset =
true);
660 template <
typename S>
671 int getRes(
int axis)
const {
return myRes[axis]; }
719 float fx,
float fy,
float fz) const;
720 template <
int AXIS2D>
722 template <
int AXIS2D>
724 float fx,
float fy,
float fz) const;
731 template <
int AXIS2D>
738 T &lerp,
T &lmin,
T &lmax,
740 float fx,
float fy,
float fz) const;
741 template <
int AXIS2D>
743 T &lerp,
T &lmin,
T &lmax,
745 float fx,
float fy,
float fz) const;
751 template <
int AXIS2D>
770 float fx,
float fy,
float fz)
const;
771 template <
int AXIS2D>
773 float fx,
float fy,
float fz)
const;
776 float &fx,
float &fy,
float &fz)
const
780 SYSfastSplitFloat(fx, x);
782 SYSfastSplitFloat(fy, y);
784 SYSfastSplitFloat(fz, z);
786 template <
int AXIS2D>
788 float &fx,
float &fy,
float &fz)
const
794 SYSfastSplitFloat(fx, x);
804 SYSfastSplitFloat(fy, y);
814 SYSfastSplitFloat(fz, z);
829 fpreal radius,
int clampaxis = -1)
const;
833 fpreal radius,
int clampaxis = -1)
const;
838 float filterwidthscale = 1.0
f,
844 template <
typename OP>
851 template <
typename OP>
872 template <
int AXIS2D>
885 void flattenGLFixed8Partial(uint8 *flatarray,
886 exint ystride, exint zstride,
899 void flattenGL16FPartial(UT_Vector4H *flatarray,
900 exint ystride, exint zstride,
915 void flattenGL32FPartial(UT_Vector4F *flatarray,
916 exint ystride, exint zstride,
923 extractFromFlattened,
924 const T *, flatarray,
927 void extractFromFlattenedPartial(const T *flatarray,
928 exint ystride, exint zstride,
937 copyWithOffsetInternal,
942 void copyWithOffsetInternalPartial(const
UT_VoxelArray<T> &src,
943 int offx,
int offy,
int offz,
963 template <typename
S>
966 template <typename
S, typename IDX>
968 const IDX *ix, const IDX *iy, const IDX *iz,
976 template <
int SLICE_AXIS, typename S>
977 S *
extractSlice(S *dstdata,
int slice,
bool half_slice) const;
982 template <typename S>
983 const S *
writeTiles(const S *srcdata,
int srcstride,
985 template <typename S, typename IDX>
986 const S *
writeTiles(const S *srcdata,
int srcstride,
987 const IDX *ix, const IDX *iy, const IDX *iz,
1020 return !((x | y |
z) < 0) &&
1021 (((x - myRes[0]) & (y - myRes[1]) & (z - myRes[2])) < 0);
1028 return (*
this)(index[0], index[1], index[2]);
1033 return (*
getTile(x >> TILEBITS,
1036 (x & TILEMASK, y & TILEMASK, z & TILEMASK);
1041 setValue(index[0], index[1], index[2], value);
1049 z >> TILEBITS)->setValue(
1050 x & TILEMASK, y & TILEMASK, z & TILEMASK, t);
1072 return (*
this)(
x,
y,
z);
1076 return myBorderValue;
1079 switch (myBorderType)
1082 return myBorderValue;
1121 cx =
x; cy =
y; cz =
z;
1124 result = (*this)(cx, cy, cz);
1125 result += (x - cx) * myBorderScale[0] +
1126 (y - cy) * myBorderScale[1] +
1127 (z - cz) * myBorderScale[2];
1133 return (*
this)(
x,
y,
z);
1150 {bbox.
xmin() >> TILEBITS,
1151 bbox.
ymin() >> TILEBITS,
1152 bbox.
zmin() >> TILEBITS,
1153 ((bbox.
xmax() - 1) >> TILEBITS) + 1,
1154 ((bbox.
ymax() - 1) >> TILEBITS) + 1,
1155 ((bbox.
zmax() - 1) >> TILEBITS) + 1};
1157 bool allconstant =
true;
1161 for (
int kt = tiles.
zmin(); kt < tiles.
zmax(); kt++)
1164 tilesamples.
vals[2][0] = TILESIZE * kt;
1165 tilesamples.
vals[2][1] = TILESIZE * (kt + 1);
1167 if (kt == tiles.
zmin())
1168 tilesamples.
vals[2][0] = bbox.
zmin();
1169 if (kt == tiles.
zmax() - 1)
1170 tilesamples.
vals[2][1] = bbox.
zmax();
1172 for (
int jt = tiles.
ymin(); jt < tiles.
ymax(); jt++)
1175 tilesamples.
vals[1][0] = TILESIZE * jt;
1176 tilesamples.
vals[1][1] = TILESIZE * (jt + 1);
1178 if (jt == tiles.
ymin())
1179 tilesamples.
vals[1][0] = bbox.
ymin();
1180 if (jt == tiles.
ymax() - 1)
1181 tilesamples.
vals[1][1] = bbox.
ymax();
1183 for (
int it = tiles.
xmin(); it < tiles.
xmax(); it++)
1186 tilesamples.
vals[0][0] = TILESIZE * it;
1187 tilesamples.
vals[0][1] = TILESIZE * (it + 1);
1189 if (it == tiles.
xmin())
1190 tilesamples.
vals[0][0] = bbox.
xmin();
1191 if (it == tiles.
xmax() - 1)
1192 tilesamples.
vals[0][1] = bbox.
xmax();
1194 const bool inbounds = tilesamples.
isInside(bounds);
1200 for (
int k = tilesamples.
zmin();
1201 k < tilesamples.
zmax(); k++)
1203 for (
int j = tilesamples.
ymin();
1204 j < tilesamples.
ymax();
j++)
1206 for (
int i = tilesamples.
xmin();
1207 i < tilesamples.
xmax(); i++)
1214 const int locallinindex
1216 + bbox.
xsize() * (localindex.
y()
1217 + bbox.
ysize() * localindex.
z());
1219 values[locallinindex] = (*tile)(
1225 && (values[0] != values[locallinindex]))
1227 allconstant =
false;
1235 for (
int k = tilesamples.
zmin(); k < tilesamples.
zmax(); k++)
1237 for (
int j = tilesamples.
ymin();
1238 j < tilesamples.
ymax();
j++)
1240 for (
int i = tilesamples.
xmin();
1241 i < tilesamples.
xmax(); i++)
1248 const int locallinindex
1250 + bbox.
xsize() * (localindex.
y()
1251 + bbox.
ysize() * localindex.
z());
1253 values[locallinindex] =
getValue(i,
j, k);
1256 && (values[0] != values[locallinindex]))
1258 allconstant =
false;
1293 void expandAllTilesPartial(const
UT_JobInfo &info);
1299 expandAllNonConstTiles)
1300 void expandAllNonConstTilesPartial(const
UT_JobInfo &info);
1307 {
return &myTiles[idx]; }
1310 x = idx % myTileRes[0];
1312 idx /= myTileRes[0];
1313 y = idx % myTileRes[1];
1315 idx /= myTileRes[1];
1321 tileindex[0] = idx % myTileRes[0];
1322 idx -= tileindex[0];
1323 idx /= myTileRes[0];
1324 tileindex[1] = idx % myTileRes[1];
1325 idx -= tileindex[1];
1326 idx /= myTileRes[1];
1333 {
return (z * myTileRes[1] + y) * myTileRes[0] +
x; }
1336 {
return ((z >> TILEBITS) * myTileRes[1] + (y >> TILEBITS)) * myTileRes[0] + (x >> TILEBITS); }
1345 start.
x() = x * TILESIZE;
1346 start.
y() = y * TILESIZE;
1347 start.
z() = z * TILESIZE;
1349 end.
x() += myTiles[idx].xres();
1350 end.
y() += myTiles[idx].yres();
1351 end.
z() += myTiles[idx].zres();
1365 {
return myTileRes[0] * myTileRes[1] * myTileRes[2]; }
1367 {
return ((
exint)myRes[0]) * myRes[1] * myRes[2]; }
1370 { myCompressionOptions = options; }
1372 {
return myCompressionOptions; }
1382 void saveData(std::ostream &os)
const;
1384 const char *shared_mem_owner = 0)
const;
1407 const UT_Filter *filter,
1413 void deleteVoxels();
1416 bool populateFromSharedMemory(const
char *
id);
1456 template <typename T>
1462 enum mipmaptype { MIPMAP_MAXIMUM=0, MIPMAP_AVERAGE=1, MIPMAP_MINIMUM=2 };
1477 mipmaptype
function);
1494 typedef bool (*Callback)(
const T *funcs,
1496 bool baselevel,
void *
data);
1497 void traverseTopDown(Callback
function,
1507 template <
typename OP>
1508 void traverseTopDown(OP&
op)
const;
1515 template <
typename OP>
1516 void traverseTopDownSorted(OP&
op)
const;
1531 return myLevels(
function)[numLevels() - 1 -
level];
1535 void doTraverse(
int x,
int y,
int z,
int level,
1540 template <
typename OP>
1541 void doTraverse(
int x,
int y,
int z,
int level,
1543 template <
typename OP>
1544 void doTraverseSorted(
int x,
int y,
int z,
int level,
1547 void initializePrivate();
1548 void destroyPrivate();
1553 const UT_VoxelArray<T> &,
src,
1554 mipmaptype,
function)
1555 void downsamplePartial(UT_VoxelArray<T> &dst,
1556 const UT_VoxelArray<T> &src,
1557 mipmaptype
function,
1565 case MIPMAP_MAXIMUM:
1568 case MIPMAP_AVERAGE:
1569 return (t1 + t2) / 2;
1571 case MIPMAP_MINIMUM:
1618 template <
typename T>
1630 myHandle.resetHandle();
1633 setPartialRange(0, 1);
1653 setPartialRange(0, 1);
1661 void setPartialRange(
int idx,
int numranges);
1670 template <
typename S>
1678 myTileEnd = myTileStart+1;
1701 void restrictToBBox(
int xmin,
int xmax,
1703 int zmin,
int zmax);
1710 {
return myCurTile < 0; }
1718 myTileLocalPos[0]++;
1719 if (myTileLocalPos[0] >= myTileSize[0])
1722 myPos[0] -= myTileLocalPos[0];
1723 myTileLocalPos[0] = 0;
1726 myTileLocalPos[1]++;
1727 if (myTileLocalPos[1] >= myTileSize[1])
1730 myPos[1] -= myTileLocalPos[1];
1731 myTileLocalPos[1] = 0;
1734 myTileLocalPos[2]++;
1735 if (myTileLocalPos[2] >= myTileSize[2])
1745 int x()
const {
return myPos[0]; }
1746 int y()
const {
return myPos[1]; }
1747 int z()
const {
return myPos[2]; }
1748 int idx(
int idx)
const {
return myPos[
idx]; }
1759 tile = myArray->getLinearTile(myCurTile);
1760 return (*tile)(myTileLocalPos[0],
1772 tile = myArray->getLinearTile(myCurTile);
1776 myTileLocalPos[2], t);
1786 tile = myArray->getLinearTile(myCurTile);
1793 start.
x() = myTilePos[0] * TILESIZE;
1794 start.
y() = myTilePos[1] * TILESIZE;
1795 start.
z() = myTilePos[2] * TILESIZE;
1797 end.
x() += myTileSize[0];
1798 end.
y() += myTileSize[1];
1799 end.
z() += myTileSize[2];
1813 {
return !(myTileLocalPos[0] ||
1814 myTileLocalPos[1] ||
1815 myTileLocalPos[2]); }
1821 return myArray->getLinearTile(myCurTile);
1837 void skipToEndOfTile();
1843 { myShouldCompressOnExit = shouldcompress; }
1854 template <
typename OP>
1855 void applyOperation(
const OP &
op);
1856 template <
typename OP,
typename S>
1858 template <
typename OP>
1859 void applyOperation(
const OP &
op, T
a);
1860 template <
typename OP,
typename S,
typename R>
1863 template <
typename OP,
typename S,
typename R,
typename Q>
1871 template <
typename OP,
typename S>
1873 template <
typename OP>
1874 void applyOperationCheckNoop(
const OP &
op, T
a);
1878 template <
typename OP,
typename M>
1879 void maskedApplyOperation(
const OP &
op,
1881 template <
typename OP,
typename S,
typename M>
1884 template <
typename OP,
typename S,
typename R,
typename M>
1888 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1898 template <
typename OP,
typename S>
1900 template <
typename OP,
typename S,
typename R>
1903 template <
typename OP,
typename S,
typename R,
typename Q>
1911 template <
typename OP,
typename S,
typename M>
1914 template <
typename OP,
typename S,
typename R,
typename M>
1918 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1927 template <
typename OP>
1928 void reduceOperation(OP &
op);
1964 int myTileLocalPos[3];
1989 template <
typename T>
1995 template <
typename S>
2000 template <
typename S>
2008 myTileStart[0] = vit.
x();
2009 myTileStart[1] = vit.
y();
2010 myTileStart[2] = vit.
z();
2021 myLinearTileNum = lineartilenum;
2025 myTileStart[0], myTileStart[1], myTileStart[2]);
2026 myTileStart[0] <<= TILEBITS;
2027 myTileStart[1] <<= TILEBITS;
2028 myTileStart[2] <<= TILEBITS;
2036 {
return myCurTile == 0 || myAtEnd; }
2044 myTileLocalPos[0]++;
2045 if (myTileLocalPos[0] >= myTileSize[0])
2048 myPos[0] -= myTileLocalPos[0];
2049 myTileLocalPos[0] = 0;
2052 myTileLocalPos[1]++;
2053 if (myTileLocalPos[1] >= myTileSize[1])
2056 myPos[1] -= myTileLocalPos[1];
2057 myTileLocalPos[1] = 0;
2060 myTileLocalPos[2]++;
2061 if (myTileLocalPos[2] >= myTileSize[2])
2072 int x()
const {
return myPos[0]; }
2073 int y()
const {
return myPos[1]; }
2074 int z()
const {
return myPos[2]; }
2075 int idx(
int idx)
const {
return myPos[
idx]; }
2084 return (*myCurTile)(myTileLocalPos[0],
2094 myCurTile->setValue(myTileLocalPos[0],
2096 myTileLocalPos[2], t);
2104 return myCurTile->isConstant();
2109 {
return !(myTileLocalPos[0] ||
2110 myTileLocalPos[1] ||
2111 myTileLocalPos[2]); }
2120 return myLinearTileNum;
2132 { myShouldCompressOnExit = shouldcompress; }
2143 template <
typename OP>
2144 void applyOperation(
const OP &
op);
2145 template <
typename OP,
typename S>
2147 template <
typename OP>
2148 void applyOperation(
const OP &
op, T
a);
2149 template <
typename OP,
typename S,
typename R>
2152 template <
typename OP,
typename S,
typename R,
typename Q>
2161 template <
typename OP,
typename S>
2163 template <
typename OP,
typename S,
typename R>
2166 template <
typename OP,
typename S,
typename R,
typename Q>
2176 template <
typename OP>
2177 bool reduceOperation(OP &
op);
2202 int myTileLocalPos[3];
2224 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2234 int prex = 0,
int postx = 0)
2250 return myCurLine[myStride*
offset];
2266 template <
typename S>
2268 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2269 template <
typename S>
2271 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2273 bool setIndex(
int x,
int y,
int z);
2278 myCurLine += myStride;
2287 myCurLine += myStride * (x - myX);
2289 UT_ASSERT_P(myX < myMaxValidX && myX >= myMinValidX);
2293 void reloadCache(
int x,
int y,
int z);
2295 void writeCacheLine();
2297 void buildConstantCache(T
value);
2329 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2336 { setArray(vx, vy, vz); }
2342 myLines[0].setArray(vx);
2343 myLines[1].setArray(vy);
2344 myLines[2].setArray(vz);
2358 return myLines[axis].getValue();
2363 myLines[0].setValue(v.
x());
2364 myLines[1].setValue(v.
y());
2365 myLines[2].setValue(v.
z());
2370 myLines[axis].setValue(val);
2377 template <
typename S>
2379 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2380 template <
typename S>
2382 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2386 if (myLines[0].setIndex(x, y, z))
2388 myLines[1].setIndex(x, y, z);
2389 myLines[2].setIndex(x, y, z);
2392 myLines[1].advanceX();
2393 myLines[2].advanceX();
2398 { myLines[0].advanceX(); myLines[1].advanceX(); myLines[2].advanceX(); }
2404 template <
typename T>
2423 y >= -1 && y <= 1 &&
2426 return myLines[y+1][z+1].getValue(x);
2433 return getValue(offset[0], offset[1], offset[2]);
2436 template <
typename S>
2438 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2439 template <
typename S>
2441 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2442 bool setIndexCube(
int x,
int y,
int z);
2444 template <
typename S>
2446 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2447 template <
typename S>
2449 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2450 bool setIndexPlus(
int x,
int y,
int z);
2490 template <
typename T>
2498 template <
typename S>
2501 template <
typename S>
2522 template <
typename T,
int XStep,
int YStep,
int ZStep>
2532 template <
typename S>
2534 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2535 template <
typename S>
2537 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2538 bool setIndex(
int x,
int y,
int z);
2545 return (valueZ(1) + valueZ(0)) * 0.5;
2553 return (valueYZ(1, z) + valueYZ(0, z)) * 0.5;
2554 return valueYZ(0, z);
2563 return myLines[
y][
z].getValue();
2576 template <
typename T>
2585 void setVoxelSize(
const UT_Vector3 &voxelsize);
2587 template <
typename S>
2589 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2590 template <
typename S>
2592 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2593 bool setIndex(
int x,
int y,
int z);
2598 inline T
face(
int axis,
int side)
const
2601 return myLines[0][0].getValue(side);
2603 return myLines[axis][side].getValue();
2610 return UT_Vector3(0.5
f * (face(0, 0) + face(0, 1)),
2611 0.5
f * (face(1, 0) + face(1, 1)),
2612 0.5
f * (face(2, 0) + face(2, 1)));
2618 return (face(0,1)-face(0,0)) * myVoxelSize.x()
2619 + (face(1,1)-face(1,0)) * myVoxelSize.y()
2620 + (face(2,1)-face(2,0)) * myVoxelSize.z();
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.
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.
UT_VoxelProbe< UT_Vector3, false, true, false > UT_VoxelWOProbeV3
#define SYS_STATIC_ASSERT(expr)
UT_Vector3I linearTileToXYZ(int idx) const
UT_VoxelProbe< fpreal32, true, true, true > UT_VoxelRWTProbeF
void setInterrupt(UT_Interrupt *interrupt)
int myLinearTileNum
Current's tile linear number.
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.
void match(const UT_VoxelArray< T > &src)
UT_VoxelArray< UT_Vector3 > UT_VoxelArrayV3
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.
constexpr SYS_FORCE_INLINE T & y() noexcept
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
GLsizei const GLfloat * value
UT_COWReadHandle< UT_VoxelArray< T > > myHandle
UT_VoxelArray< fpreal32 > UT_VoxelArrayF
void clampIndex(int &x, int &y, int &z) const
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
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
UT_VoxelTile< T > * myCurTile
Current processing tile.
GLdouble GLdouble GLdouble z
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.
GLboolean GLboolean GLboolean GLboolean a
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)
UT_VoxelArray< T > * myArray
fpreal UTvoxelTileDist(const UT_Vector2 &a, const UT_Vector2 &b)
UT_VoxelTileIterator< UT_Vector2 > UT_VoxelTileIteratorV2
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
**But if you need a result
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
GLfloat GLfloat GLfloat v2
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)
S * extractSlice(S *dstdata, int slice, bool half_slice) const
constexpr SYS_FORCE_INLINE T & x() noexcept
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
SYS_FORCE_INLINE bool extractSample(int x, int y, int z, T *sample) const
UT_VoxelArrayIterator< UT_Vector3 > UT_VoxelArrayIteratorV3
virtual ~UT_VoxelTileCompress()
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)
constexpr SYS_FORCE_INLINE T & x() noexcept
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
UT_VoxelArray< UT_Vector2 > UT_VoxelArrayV2
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)
GLint GLint GLsizei GLint GLenum GLenum type
bool hasNan() const
Returns true if any NANs are in this tile.
UT_VoxelProbe< UT_Vector2, true, true, false > UT_VoxelRWProbeV2
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)
UT_VoxelArrayIterator< UT_Vector2 > UT_VoxelArrayIteratorV2
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
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
constexpr SYS_FORCE_INLINE T & z() noexcept
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.
static int mirrorCoordinates(int x, int res)
UT_VoxelProbe< UT_Vector2, true, false, false > UT_VoxelProbeV2
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)
GLint GLenum GLboolean GLsizei stride
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
UT_VoxelProbe< UT_Vector2, false, true, false > UT_VoxelWOProbeV2
constexpr enabler dummy
An instance to use in EnableIf.
UT_VoxelProbe< UT_Vector2, true, true, true > UT_VoxelRWTProbeV2
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)
UT_VoxelProbe< UT_Vector3, true, false, false > UT_VoxelProbeV3
#define SYS_NO_DISCARD_RESULT
#define SYS_STATIC_FORCE_INLINE
UT_VoxelProbe< UT_Vector3, true, true, false > UT_VoxelRWProbeV3
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)
GLuint const GLchar * name
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).
GLboolean GLboolean GLboolean b
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
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
UT_VoxelProbe< UT_Vector3, true, true, true > UT_VoxelRWTProbeV3
GLenum GLsizei GLsizei GLint * values
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
void setConstArray(const UT_VoxelArray< T > *vox)
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
void forEachTile(const OP &op, bool shouldthread=true)
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
constexpr SYS_FORCE_INLINE T & w() noexcept
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
UT_VoxelTileIterator< UT_Vector3 > UT_VoxelTileIteratorV3
void linearTileToXYZ(int idx, int &x, int &y, int &z) const
UT_VoxelProbe< UT_Vector4, true, true, false > UT_VoxelRWProbeV4
int getLinearTileNum() const
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
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)
GLubyte GLubyte GLubyte GLubyte w
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.
SYS_FORCE_INLINE T operator()(int x, int y, int z) const
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
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.
T avgNonZero(const UT_Vector3 &pos, const UT_Filter &filter, fpreal radius, int clampaxis=-1) const
average of non-zero values of the voxel array.
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)
void avgNonZero(int pstart[3], int pend[3], int start[3], T &result)
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
constexpr SYS_FORCE_INLINE T & y() noexcept
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
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 forEachTileConst(const OP &op, bool shouldthread=true) 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
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
constexpr SYS_FORCE_INLINE T & x() noexcept