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],
521 void save(std::ostream &os)
const;
549 { myRes[0] = xr; myRes[1] = yr; myRes[2] = zr; }
553 return (
sizeof(
T) <=
sizeof(
T*));
566 myCompressionType = compress_type;
575 myForeignData =
true;
589 else if (
myData && !myForeignData)
594 myForeignData =
false;
607 int8 myCompressionType;
618 template <
typename S,
bool DoWrite,
bool DoRead,
bool TestForWrites>
631 template <
typename T>
650 void size(
int xres,
int yres,
int zres,
bool reset =
true);
657 template <
typename S>
668 int getRes(
int axis)
const {
return myRes[axis]; }
716 float fx,
float fy,
float fz) const;
717 template <
int AXIS2D>
719 template <
int AXIS2D>
721 float fx,
float fy,
float fz) const;
728 template <
int AXIS2D>
735 T &lerp,
T &lmin,
T &lmax,
737 float fx,
float fy,
float fz) const;
738 template <
int AXIS2D>
740 T &lerp,
T &lmin,
T &lmax,
742 float fx,
float fy,
float fz) const;
748 template <
int AXIS2D>
767 float fx,
float fy,
float fz)
const;
768 template <
int AXIS2D>
770 float fx,
float fy,
float fz)
const;
773 float &fx,
float &fy,
float &fz)
const
777 SYSfastSplitFloat(fx, x);
779 SYSfastSplitFloat(fy, y);
781 SYSfastSplitFloat(fz, z);
783 template <
int AXIS2D>
785 float &fx,
float &fy,
float &fz)
const
791 SYSfastSplitFloat(fx, x);
801 SYSfastSplitFloat(fy, y);
811 SYSfastSplitFloat(fz, z);
826 fpreal radius,
int clampaxis = -1)
const;
831 float filterwidthscale = 1.0
f,
837 template <
typename OP>
838 void forEachTile(
const OP &op,
bool shouldthread =
true);
844 template <
typename OP>
865 template <
int AXIS2D>
878 void flattenGLFixed8Partial(uint8 *flatarray,
879 exint ystride, exint zstride,
892 void flattenGL16FPartial(UT_Vector4H *flatarray,
893 exint ystride, exint zstride,
908 void flattenGL32FPartial(UT_Vector4F *flatarray,
909 exint ystride, exint zstride,
916 extractFromFlattened,
917 const T *, flatarray,
920 void extractFromFlattenedPartial(const T *flatarray,
921 exint ystride, exint zstride,
930 copyWithOffsetInternal,
935 void copyWithOffsetInternalPartial(const
UT_VoxelArray<T> &src,
936 int offx,
int offy,
int offz,
956 template <typename
S>
959 template <typename
S, typename IDX>
961 const IDX *ix, const IDX *iy, const IDX *iz,
969 template <
int SLICE_AXIS, typename S>
970 S *
extractSlice(S *dstdata,
int slice,
bool half_slice) const;
975 template <typename S>
976 const S *
writeTiles(const S *srcdata,
int srcstride,
978 template <typename S, typename IDX>
979 const S *
writeTiles(const S *srcdata,
int srcstride,
980 const IDX *ix, const IDX *iy, const IDX *iz,
1013 return !((x | y |
z) < 0) &&
1014 (((x - myRes[0]) & (y - myRes[1]) & (z - myRes[2])) < 0);
1021 return (*
this)(index[0], index[1], index[2]);
1026 return (*
getTile(x >> TILEBITS,
1029 (x & TILEMASK, y & TILEMASK, z & TILEMASK);
1034 setValue(index[0], index[1], index[2], value);
1042 z >> TILEBITS)->setValue(
1043 x & TILEMASK, y & TILEMASK, z & TILEMASK, t);
1065 return (*
this)(
x,
y,
z);
1069 return myBorderValue;
1072 switch (myBorderType)
1075 return myBorderValue;
1114 cx =
x; cy =
y; cz =
z;
1117 result = (*this)(cx, cy, cz);
1118 result += (x - cx) * myBorderScale[0] +
1119 (y - cy) * myBorderScale[1] +
1120 (z - cz) * myBorderScale[2];
1126 return (*
this)(
x,
y,
z);
1143 {bbox.
xmin() >> TILEBITS,
1144 bbox.
ymin() >> TILEBITS,
1145 bbox.
zmin() >> TILEBITS,
1146 ((bbox.
xmax() - 1) >> TILEBITS) + 1,
1147 ((bbox.
ymax() - 1) >> TILEBITS) + 1,
1148 ((bbox.
zmax() - 1) >> TILEBITS) + 1};
1150 bool allconstant =
true;
1154 for (
int kt = tiles.
zmin(); kt < tiles.
zmax(); kt++)
1157 tilesamples.
vals[2][0] = TILESIZE * kt;
1158 tilesamples.
vals[2][1] = TILESIZE * (kt + 1);
1160 if (kt == tiles.
zmin())
1161 tilesamples.
vals[2][0] = bbox.
zmin();
1162 if (kt == tiles.
zmax() - 1)
1163 tilesamples.
vals[2][1] = bbox.
zmax();
1165 for (
int jt = tiles.
ymin(); jt < tiles.
ymax(); jt++)
1168 tilesamples.
vals[1][0] = TILESIZE * jt;
1169 tilesamples.
vals[1][1] = TILESIZE * (jt + 1);
1171 if (jt == tiles.
ymin())
1172 tilesamples.
vals[1][0] = bbox.
ymin();
1173 if (jt == tiles.
ymax() - 1)
1174 tilesamples.
vals[1][1] = bbox.
ymax();
1176 for (
int it = tiles.
xmin(); it < tiles.
xmax(); it++)
1179 tilesamples.
vals[0][0] = TILESIZE * it;
1180 tilesamples.
vals[0][1] = TILESIZE * (it + 1);
1182 if (it == tiles.
xmin())
1183 tilesamples.
vals[0][0] = bbox.
xmin();
1184 if (it == tiles.
xmax() - 1)
1185 tilesamples.
vals[0][1] = bbox.
xmax();
1187 const bool inbounds = tilesamples.
isInside(bounds);
1193 for (
int k = tilesamples.
zmin();
1194 k < tilesamples.
zmax(); k++)
1196 for (
int j = tilesamples.
ymin();
1197 j < tilesamples.
ymax();
j++)
1199 for (
int i = tilesamples.
xmin();
1200 i < tilesamples.
xmax(); i++)
1207 const int locallinindex
1209 + bbox.
xsize() * (localindex.
y()
1210 + bbox.
ysize() * localindex.
z());
1212 values[locallinindex] = (*tile)(
1218 && (values[0] != values[locallinindex]))
1220 allconstant =
false;
1228 for (
int k = tilesamples.
zmin(); k < tilesamples.
zmax(); k++)
1230 for (
int j = tilesamples.
ymin();
1231 j < tilesamples.
ymax();
j++)
1233 for (
int i = tilesamples.
xmin();
1234 i < tilesamples.
xmax(); i++)
1241 const int locallinindex
1243 + bbox.
xsize() * (localindex.
y()
1244 + bbox.
ysize() * localindex.
z());
1246 values[locallinindex] =
getValue(i,
j, k);
1249 && (values[0] != values[locallinindex]))
1251 allconstant =
false;
1286 void expandAllTilesPartial(const
UT_JobInfo &info);
1292 expandAllNonConstTiles)
1293 void expandAllNonConstTilesPartial(const
UT_JobInfo &info);
1300 {
return &myTiles[idx]; }
1303 x = idx % myTileRes[0];
1305 idx /= myTileRes[0];
1306 y = idx % myTileRes[1];
1308 idx /= myTileRes[1];
1314 tileindex[0] = idx % myTileRes[0];
1315 idx -= tileindex[0];
1316 idx /= myTileRes[0];
1317 tileindex[1] = idx % myTileRes[1];
1318 idx -= tileindex[1];
1319 idx /= myTileRes[1];
1326 {
return (z * myTileRes[1] + y) * myTileRes[0] +
x; }
1329 {
return ((z >> TILEBITS) * myTileRes[1] + (y >> TILEBITS)) * myTileRes[0] + (x >> TILEBITS); }
1338 start.
x() = x * TILESIZE;
1339 start.
y() = y * TILESIZE;
1340 start.
z() = z * TILESIZE;
1342 end.
x() += myTiles[idx].xres();
1343 end.
y() += myTiles[idx].yres();
1344 end.
z() += myTiles[idx].zres();
1358 {
return myTileRes[0] * myTileRes[1] * myTileRes[2]; }
1360 {
return ((
exint)myRes[0]) * myRes[1] * myRes[2]; }
1363 { myCompressionOptions = options; }
1365 {
return myCompressionOptions; }
1375 void saveData(std::ostream &os)
const;
1377 const char *shared_mem_owner = 0)
const;
1400 const UT_Filter *filter,
1406 void deleteVoxels();
1409 bool populateFromSharedMemory(const
char *
id);
1449 template <typename T>
1455 enum mipmaptype { MIPMAP_MAXIMUM=0, MIPMAP_AVERAGE=1, MIPMAP_MINIMUM=2 };
1470 mipmaptype
function);
1487 typedef bool (*Callback)(
const T *funcs,
1489 bool baselevel,
void *
data);
1490 void traverseTopDown(Callback
function,
1500 template <
typename OP>
1501 void traverseTopDown(OP&op)
const;
1508 template <
typename OP>
1509 void traverseTopDownSorted(OP&op)
const;
1524 return myLevels(
function)[numLevels() - 1 -
level];
1528 void doTraverse(
int x,
int y,
int z,
int level,
1533 template <
typename OP>
1534 void doTraverse(
int x,
int y,
int z,
int level,
1536 template <
typename OP>
1537 void doTraverseSorted(
int x,
int y,
int z,
int level,
1540 void initializePrivate();
1541 void destroyPrivate();
1546 const UT_VoxelArray<T> &,
src,
1547 mipmaptype,
function)
1548 void downsamplePartial(UT_VoxelArray<T> &dst,
1549 const UT_VoxelArray<T> &src,
1550 mipmaptype
function,
1558 case MIPMAP_MAXIMUM:
1561 case MIPMAP_AVERAGE:
1562 return (t1 + t2) / 2;
1564 case MIPMAP_MINIMUM:
1611 template <
typename T>
1623 myHandle.resetHandle();
1626 setPartialRange(0, 1);
1646 setPartialRange(0, 1);
1654 void setPartialRange(
int idx,
int numranges);
1663 template <
typename S>
1671 myTileEnd = myTileStart+1;
1694 void restrictToBBox(
int xmin,
int xmax,
1696 int zmin,
int zmax);
1703 {
return myCurTile < 0; }
1711 myTileLocalPos[0]++;
1712 if (myTileLocalPos[0] >= myTileSize[0])
1715 myPos[0] -= myTileLocalPos[0];
1716 myTileLocalPos[0] = 0;
1719 myTileLocalPos[1]++;
1720 if (myTileLocalPos[1] >= myTileSize[1])
1723 myPos[1] -= myTileLocalPos[1];
1724 myTileLocalPos[1] = 0;
1727 myTileLocalPos[2]++;
1728 if (myTileLocalPos[2] >= myTileSize[2])
1738 int x()
const {
return myPos[0]; }
1739 int y()
const {
return myPos[1]; }
1740 int z()
const {
return myPos[2]; }
1741 int idx(
int idx)
const {
return myPos[
idx]; }
1752 tile = myArray->getLinearTile(myCurTile);
1753 return (*tile)(myTileLocalPos[0],
1765 tile = myArray->getLinearTile(myCurTile);
1769 myTileLocalPos[2], t);
1779 tile = myArray->getLinearTile(myCurTile);
1786 start.
x() = myTilePos[0] * TILESIZE;
1787 start.
y() = myTilePos[1] * TILESIZE;
1788 start.
z() = myTilePos[2] * TILESIZE;
1790 end.
x() += myTileSize[0];
1791 end.
y() += myTileSize[1];
1792 end.
z() += myTileSize[2];
1806 {
return !(myTileLocalPos[0] ||
1807 myTileLocalPos[1] ||
1808 myTileLocalPos[2]); }
1814 return myArray->getLinearTile(myCurTile);
1830 void skipToEndOfTile();
1836 { myShouldCompressOnExit = shouldcompress; }
1847 template <
typename OP>
1848 void applyOperation(
const OP &op);
1849 template <
typename OP,
typename S>
1851 template <
typename OP>
1852 void applyOperation(
const OP &op, T
a);
1853 template <
typename OP,
typename S,
typename R>
1856 template <
typename OP,
typename S,
typename R,
typename Q>
1864 template <
typename OP,
typename S>
1866 template <
typename OP>
1867 void applyOperationCheckNoop(
const OP &op, T
a);
1871 template <
typename OP,
typename M>
1872 void maskedApplyOperation(
const OP &op,
1874 template <
typename OP,
typename S,
typename M>
1877 template <
typename OP,
typename S,
typename R,
typename M>
1881 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1891 template <
typename OP,
typename S>
1893 template <
typename OP,
typename S,
typename R>
1896 template <
typename OP,
typename S,
typename R,
typename Q>
1904 template <
typename OP,
typename S,
typename M>
1907 template <
typename OP,
typename S,
typename R,
typename M>
1911 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
1920 template <
typename OP>
1921 void reduceOperation(OP &op);
1957 int myTileLocalPos[3];
1982 template <
typename T>
1988 template <
typename S>
1993 template <
typename S>
2001 myTileStart[0] = vit.
x();
2002 myTileStart[1] = vit.
y();
2003 myTileStart[2] = vit.
z();
2014 myLinearTileNum = lineartilenum;
2018 myTileStart[0], myTileStart[1], myTileStart[2]);
2019 myTileStart[0] <<= TILEBITS;
2020 myTileStart[1] <<= TILEBITS;
2021 myTileStart[2] <<= TILEBITS;
2029 {
return myCurTile == 0 || myAtEnd; }
2037 myTileLocalPos[0]++;
2038 if (myTileLocalPos[0] >= myTileSize[0])
2041 myPos[0] -= myTileLocalPos[0];
2042 myTileLocalPos[0] = 0;
2045 myTileLocalPos[1]++;
2046 if (myTileLocalPos[1] >= myTileSize[1])
2049 myPos[1] -= myTileLocalPos[1];
2050 myTileLocalPos[1] = 0;
2053 myTileLocalPos[2]++;
2054 if (myTileLocalPos[2] >= myTileSize[2])
2065 int x()
const {
return myPos[0]; }
2066 int y()
const {
return myPos[1]; }
2067 int z()
const {
return myPos[2]; }
2068 int idx(
int idx)
const {
return myPos[
idx]; }
2077 return (*myCurTile)(myTileLocalPos[0],
2087 myCurTile->setValue(myTileLocalPos[0],
2089 myTileLocalPos[2], t);
2097 return myCurTile->isConstant();
2102 {
return !(myTileLocalPos[0] ||
2103 myTileLocalPos[1] ||
2104 myTileLocalPos[2]); }
2113 return myLinearTileNum;
2125 { myShouldCompressOnExit = shouldcompress; }
2136 template <
typename OP>
2137 void applyOperation(
const OP &op);
2138 template <
typename OP,
typename S>
2140 template <
typename OP>
2141 void applyOperation(
const OP &op, T
a);
2142 template <
typename OP,
typename S,
typename R>
2145 template <
typename OP,
typename S,
typename R,
typename Q>
2154 template <
typename OP,
typename S>
2156 template <
typename OP,
typename S,
typename R>
2159 template <
typename OP,
typename S,
typename R,
typename Q>
2169 template <
typename OP>
2170 bool reduceOperation(OP &op);
2195 int myTileLocalPos[3];
2217 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2227 int prex = 0,
int postx = 0)
2243 return myCurLine[myStride*
offset];
2259 template <
typename S>
2261 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2262 template <
typename S>
2264 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2266 bool setIndex(
int x,
int y,
int z);
2271 myCurLine += myStride;
2280 myCurLine += myStride * (x - myX);
2282 UT_ASSERT_P(myX < myMaxValidX && myX >= myMinValidX);
2286 void reloadCache(
int x,
int y,
int z);
2288 void writeCacheLine();
2290 void buildConstantCache(T
value);
2322 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
2329 { setArray(vx, vy, vz); }
2335 myLines[0].setArray(vx);
2336 myLines[1].setArray(vy);
2337 myLines[2].setArray(vz);
2351 return myLines[axis].getValue();
2356 myLines[0].setValue(v.
x());
2357 myLines[1].setValue(v.
y());
2358 myLines[2].setValue(v.
z());
2363 myLines[axis].setValue(val);
2370 template <
typename S>
2372 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2373 template <
typename S>
2375 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2379 if (myLines[0].setIndex(x, y, z))
2381 myLines[1].setIndex(x, y, z);
2382 myLines[2].setIndex(x, y, z);
2385 myLines[1].advanceX();
2386 myLines[2].advanceX();
2391 { myLines[0].advanceX(); myLines[1].advanceX(); myLines[2].advanceX(); }
2397 template <
typename T>
2416 y >= -1 && y <= 1 &&
2419 return myLines[y+1][z+1].getValue(x);
2426 return getValue(offset[0], offset[1], offset[2]);
2429 template <
typename S>
2431 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2432 template <
typename S>
2434 {
return setIndexCube(vit.
x(), vit.
y(), vit.
z()); }
2435 bool setIndexCube(
int x,
int y,
int z);
2437 template <
typename S>
2439 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2440 template <
typename S>
2442 {
return setIndexPlus(vit.
x(), vit.
y(), vit.
z()); }
2443 bool setIndexPlus(
int x,
int y,
int z);
2483 template <
typename T>
2491 template <
typename S>
2494 template <
typename S>
2515 template <
typename T,
int XStep,
int YStep,
int ZStep>
2525 template <
typename S>
2527 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2528 template <
typename S>
2530 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2531 bool setIndex(
int x,
int y,
int z);
2538 return (valueZ(1) + valueZ(0)) * 0.5;
2546 return (valueYZ(1, z) + valueYZ(0, z)) * 0.5;
2547 return valueYZ(0, z);
2556 return myLines[
y][
z].getValue();
2569 template <
typename T>
2578 void setVoxelSize(
const UT_Vector3 &voxelsize);
2580 template <
typename S>
2582 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2583 template <
typename S>
2585 {
return setIndex(vit.
x(), vit.
y(), vit.
z()); }
2586 bool setIndex(
int x,
int y,
int z);
2591 inline T
face(
int axis,
int side)
const
2594 return myLines[0][0].getValue(side);
2596 return myLines[axis][side].getValue();
2603 return UT_Vector3(0.5
f * (face(0, 0) + face(0, 1)),
2604 0.5
f * (face(1, 0) + face(1, 1)),
2605 0.5
f * (face(2, 0) + face(2, 1)));
2611 return (face(0,1)-face(0,0)) * myVoxelSize.x()
2612 + (face(1,1)-face(1,0)) * myVoxelSize.y()
2613 + (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)
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.
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
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