82 for (z = 0; z < tile.
zres(); z++)
84 for (y = 0; y < tile.
yres(); y++)
86 for (x = 0; x < tile.
xres(); x++)
106 myCompressionType = COMPRESS_CONSTANT;
107 myForeignData =
false;
109 if (
sizeof(
T) <=
sizeof(
T*))
121 ((
T *)myData)[0] = 0;
125 template <
typename T>
131 template <
typename T>
140 template <
typename T>
149 myRes[0] = src.myRes[0];
150 myRes[1] = src.myRes[1];
151 myRes[2] = src.myRes[2];
153 myCompressionType = src.myCompressionType;
154 switch (myCompressionType)
158 sizeof(
T) * myRes[0] * myRes[1] * myRes[2]);
159 memcpy(myData, src.
myData,
sizeof(
T) * myRes[0] * myRes[1] * myRes[2]);
161 case COMPRESS_CONSTANT:
162 if (inlineConstant())
169 memcpy(myData, src.
myData,
sizeof(
T));
172 case COMPRESS_RAWFULL:
174 sizeof(
T) * TILESIZE * TILESIZE * myRes[2]);
175 memcpy(myData, src.
myData,
176 sizeof(
T) * TILESIZE * TILESIZE * myRes[2]);
178 case COMPRESS_FPREAL16:
182 sizeof(
fpreal16) * myRes[0] * myRes[1] * myRes[2] * tuple_size);
183 memcpy(myData, src.
myData,
184 sizeof(
fpreal16) * myRes[0] * myRes[1] * myRes[2] * tuple_size);
191 engine = getCompressionEngine(myCompressionType);
201 template <
typename T>
205 switch (myCompressionType)
209 ((
T *)myData)[ ((z * myRes[1]) + y) * myRes[0] +
x ] =
t;
212 case COMPRESS_CONSTANT:
213 if (rawConstVal() ==
t)
220 case COMPRESS_RAWFULL:
221 ((
T *)myData)[ ((z * TILESIZE) + y) * TILESIZE +
x ] =
t;
224 case COMPRESS_FPREAL16:
231 engine = getCompressionEngine(myCompressionType);
235 template <
typename T>
240 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
242 switch (myCompressionType)
245 return ((
T *)myData)[
246 ((z * myRes[1]) + y) * myRes[0] +
x ];
248 case COMPRESS_CONSTANT:
249 return rawConstVal();
251 case COMPRESS_RAWFULL:
252 return ((
T *)myData)[
253 ((z * TILESIZE) + y) * TILESIZE +
x ];
255 case COMPRESS_FPREAL16:
260 int offset = ((z * myRes[1] +
y) * myRes[0] + x)
262 T result = convertFromFP16(data + offset);
270 engine = getCompressionEngine(myCompressionType);
271 return engine->
getValue(*
this, x, y, z);
274 template <
typename T>
278 T vx, vx1, vy, vy1, vz;
280 switch (myCompressionType)
285 int offset = (z * myRes[1] +
y) * myRes[0] + x;
287 int zinc = myRes[0] * myRes[1];
290 vx = lerpValues(data[offset], data[offset+1], fx);
292 vx1 = lerpValues(data[offset+yinc], data[offset+yinc+1], fx);
295 vy = lerpValues(vx, vx1, fy);
298 vx = lerpValues(data[offset+zinc], data[offset+zinc+1], fx);
300 vx1 = lerpValues(data[offset+zinc+yinc], data[offset+zinc+yinc+1], fx);
303 vy1 = lerpValues(vx, vx1, fy);
306 vz = lerpValues(vy, vy1, fz);
309 case COMPRESS_RAWFULL:
312 int offset = (z * TILESIZE +
y) * TILESIZE + x;
314 int zinc = TILESIZE * TILESIZE;
317 vx = lerpValues(data[offset], data[offset+1], fx);
319 vx1 = lerpValues(data[offset+yinc], data[offset+yinc+1], fx);
322 vy = lerpValues(vx, vx1, fy);
325 vx = lerpValues(data[offset+zinc], data[offset+zinc+1], fx);
327 vx1 = lerpValues(data[offset+zinc+yinc], data[offset+zinc+yinc+1], fx);
330 vy1 = lerpValues(vx, vx1, fy);
333 vz = lerpValues(vy, vy1, fz);
336 case COMPRESS_FPREAL16:
342 int xinc = tuple_size;
343 int yinc = myRes[0] * xinc;
344 int zinc = myRes[1] * yinc;
345 int offset = z * zinc + y * yinc + x * xinc;
349 for (
int j = 0;
j < tuple_size;
j++, offset++)
352 vx =
SYSlerp(data[offset], data[offset+xinc], fx);
354 vx1 =
SYSlerp(data[offset+yinc], data[offset+yinc+xinc], fx);
360 vx =
SYSlerp(data[offset+zinc], data[offset+zinc+xinc], fx);
362 vx1 =
SYSlerp(data[offset+zinc+yinc], data[offset+zinc+yinc+xinc], fx);
371 return convertFromFP16(result);
373 case COMPRESS_CONSTANT:
384 engine = getCompressionEngine(myCompressionType);
386 vx = lerpValues(engine->
getValue(*
this, x, y, z),
390 vx1 = lerpValues(engine->
getValue(*
this, x, y+1, z),
391 engine->
getValue(*
this, x+1, y+1, z),
395 vy = lerpValues(vx, vx1, fy);
398 vx = lerpValues(engine->
getValue(*
this, x, y, z+1),
399 engine->
getValue(*
this, x+1, y, z+1),
402 vx1 = lerpValues(engine->
getValue(*
this, x, y+1, z+1),
403 engine->
getValue(*
this, x+1, y+1, z+1),
407 vy1 = lerpValues(vx, vx1, fy);
410 vz = lerpValues(vy, vy1, fz);
418 template <
typename T>
419 template <
int AXIS2D>
423 T vx, vx1, vy, vy1, vz;
425 switch (myCompressionType)
430 int offset = (z * myRes[1] +
y) * myRes[0] + x;
432 int zinc = myRes[0] * myRes[1];
436 vx = lerpValues(data[offset],
446 vx1= lerpValues(data[offset+yinc],
450 vx1 = data[offset+yinc];
452 vy = lerpValues(vx, vx1, fy);
461 vx = lerpValues(data[offset+zinc],
465 vx = data[offset+zinc];
471 vx1= lerpValues(data[offset+zinc+yinc],
472 data[offset+zinc+yinc+1],
475 vx1 = data[offset+zinc+yinc];
477 vy1 = lerpValues(vx, vx1, fy);
483 vz = lerpValues(vy, vy1, fz);
489 case COMPRESS_RAWFULL:
492 int offset = (z * TILESIZE +
y) * TILESIZE + x;
494 int zinc = TILESIZE * TILESIZE;
498 vx = lerpValues(data[offset],
508 vx1= lerpValues(data[offset+yinc],
512 vx1 = data[offset+yinc];
514 vy = lerpValues(vx, vx1, fy);
523 vx = lerpValues(data[offset+zinc],
527 vx = data[offset+zinc];
533 vx1= lerpValues(data[offset+zinc+yinc],
534 data[offset+zinc+yinc+1],
537 vx1 = data[offset+zinc+yinc];
539 vy1 = lerpValues(vx, vx1, fy);
545 vz = lerpValues(vy, vy1, fz);
551 case COMPRESS_FPREAL16:
557 int xinc = tuple_size;
558 int yinc = myRes[0] * xinc;
559 int zinc = myRes[1] * yinc;
560 int offset = z * zinc + y * yinc + x * xinc;
564 for (
int j = 0;
j < tuple_size;
j++, offset++)
578 vx1=
SYSlerp(data[offset+yinc],
579 data[offset+yinc+xinc],
582 vx1 = data[offset+yinc];
593 vx =
SYSlerp(data[offset+zinc],
594 data[offset+zinc+xinc],
597 vx = data[offset+zinc];
603 vx1=
SYSlerp(data[offset+zinc+yinc],
604 data[offset+zinc+yinc+xinc],
607 vx1 = data[offset+zinc+yinc];
621 return convertFromFP16(result);
623 case COMPRESS_CONSTANT:
634 engine = getCompressionEngine(myCompressionType);
637 vx = lerpValues(engine->
getValue(*
this, x, y, z),
641 vx = engine->
getValue(*
this, x, y, z);
647 vx1= lerpValues(engine->
getValue(*
this, x, y+1, z),
648 engine->
getValue(*
this, x+1, y+1, z),
651 vx1 = engine->
getValue(*
this, x, y+1, z);
653 vy = lerpValues(vx, vx1, fy);
662 vx = lerpValues(engine->
getValue(*
this, x, y, z+1),
663 engine->
getValue(*
this, x+1, y, z+1),
666 vx = engine->
getValue(*
this, x, y, z+1);
672 vx1= lerpValues(engine->
getValue(*
this, x, y+1, z+1),
673 engine->
getValue(*
this, x+1, y+1, z+1),
676 vx1 = engine->
getValue(*
this, x, y+1, z+1);
678 vy1 = lerpValues(vx, vx1, fy);
684 vz = lerpValues(vy, vy1, fz);
695 template <
typename T>
699 switch (myCompressionType)
704 int offset = (z * myRes[1] +
y) * myRes[0] + x;
706 int zinc = myRes[0] * myRes[1];
709 sample[1] = data[offset+1];
710 sample[2+0] = data[offset+yinc];
711 sample[2+1] = data[offset+yinc+1];
712 sample[4+0] = data[offset+zinc];
713 sample[4+1] = data[offset+zinc+1];
714 sample[4+2+0] = data[offset+zinc+yinc];
715 sample[4+2+1] = data[offset+zinc+yinc+1];
718 case COMPRESS_RAWFULL:
721 int offset = (z * TILESIZE +
y) * TILESIZE + x;
723 int zinc = TILESIZE * TILESIZE;
726 sample[1] = data[offset+1];
727 sample[2+0] = data[offset+yinc];
728 sample[2+1] = data[offset+yinc+1];
729 sample[4+0] = data[offset+zinc];
730 sample[4+1] = data[offset+zinc+1];
731 sample[4+2+0] = data[offset+zinc+yinc];
732 sample[4+2+1] = data[offset+zinc+yinc+1];
735 case COMPRESS_FPREAL16:
741 int xinc = tuple_size;
742 int yinc = myRes[0] * xinc;
743 int zinc = myRes[1] * yinc;
744 int offset = z * zinc + y * yinc + x * xinc;
747 sample[0] = convertFromFP16(data);
748 sample[1] = convertFromFP16(data + xinc);
749 sample[2+0] = convertFromFP16(data + yinc);
750 sample[2+1] = convertFromFP16(data + yinc + xinc);
751 sample[4+0] = convertFromFP16(data + zinc);
752 sample[4+1] = convertFromFP16(data + zinc + xinc);
753 sample[4+2+0] = convertFromFP16(data + zinc + yinc);
754 sample[4+2+1] = convertFromFP16(data + zinc + yinc + xinc);
757 case COMPRESS_CONSTANT:
759 sample[0] = rawConstVal();
767 engine = getCompressionEngine(myCompressionType);
769 sample[0] = engine->
getValue(*
this, x, y, z);
770 sample[1] = engine->
getValue(*
this, x+1, y, z);
771 sample[2+0] = engine->
getValue(*
this, x, y+1, z);
772 sample[2+1] = engine->
getValue(*
this, x+1, y+1, z);
773 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
774 sample[4+1] = engine->
getValue(*
this, x+1, y, z+1);
775 sample[4+2+0] = engine->
getValue(*
this, x, y+1, z+1);
776 sample[4+2+1] = engine->
getValue(*
this, x+1, y+1, z+1);
783 template <
typename T>
787 switch (myCompressionType)
792 int offset = (z * myRes[1] +
y) * myRes[0] + x;
794 int zinc = myRes[0] * myRes[1];
796 sample[0] = data[offset-1];
797 sample[1] = data[offset+1];
798 sample[2+0] = data[offset-yinc];
799 sample[2+1] = data[offset+yinc];
800 sample[4+0] = data[offset-zinc];
801 sample[4+1] = data[offset+zinc];
805 case COMPRESS_RAWFULL:
808 int offset = (z * TILESIZE +
y) * TILESIZE + x;
810 int zinc = TILESIZE * TILESIZE;
812 sample[0] = data[offset-1];
813 sample[1] = data[offset+1];
814 sample[2+0] = data[offset-yinc];
815 sample[2+1] = data[offset+yinc];
816 sample[4+0] = data[offset-zinc];
817 sample[4+1] = data[offset+zinc];
821 case COMPRESS_FPREAL16:
827 int xinc = tuple_size;
828 int yinc = myRes[0] * xinc;
829 int zinc = myRes[1] * yinc;
830 int offset = z * zinc + y * yinc + x * xinc;
833 sample[0] = convertFromFP16(data - xinc);
834 sample[1] = convertFromFP16(data + xinc);
835 sample[2+0] = convertFromFP16(data - yinc);
836 sample[2+1] = convertFromFP16(data + yinc);
837 sample[4+0] = convertFromFP16(data - zinc);
838 sample[4+1] = convertFromFP16(data + zinc);
839 sample[6] = convertFromFP16(data);
842 case COMPRESS_CONSTANT:
844 sample[0] = rawConstVal();
852 engine = getCompressionEngine(myCompressionType);
854 sample[0] = engine->
getValue(*
this, x-1, y, z);
855 sample[1] = engine->
getValue(*
this, x+1, y, z);
856 sample[2+0] = engine->
getValue(*
this, x, y-1, z);
857 sample[2+1] = engine->
getValue(*
this, x, y+1, z);
858 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
859 sample[4+1] = engine->
getValue(*
this, x, y, z-1);
860 sample[6] = engine->
getValue(*
this, x, y, z);
874 template <
typename T>
878 switch (myCompressionType)
883 int offset = (z * myRes[1] +
y) * myRes[0] + x;
885 int zinc = myRes[0] * myRes[1];
889 for (
int dz = -1; dz <= 1; dz++)
892 for (
int dy = -1; dy <= 1; dy++)
894 sample[sampidx] = data[offset-1];
895 sample[sampidx+1] = data[
offset];
896 sample[sampidx+2] = data[offset+1];
905 case COMPRESS_RAWFULL:
907 T *data = (
T *) myData;
908 int offset = (z * TILESIZE +
y) * TILESIZE + x;
910 int zinc = TILESIZE * TILESIZE;
914 for (
int dz = -1; dz <= 1; dz++)
917 for (
int dy = -1; dy <= 1; dy++)
919 sample[sampidx] = data[offset-1];
920 sample[sampidx+1] = data[
offset];
921 sample[sampidx+2] = data[offset+1];
930 case COMPRESS_FPREAL16:
933 int offset = (z * myRes[1] +
y) * myRes[0] + x;
935 int zinc = myRes[0] * myRes[1];
939 for (
int dz = -1; dz <= 1; dz++)
942 for (
int dy = -1; dy <= 1; dy++)
944 sample[sampidx] = data[offset-1];
945 sample[sampidx+1] = data[
offset];
946 sample[sampidx+2] = data[offset+1];
955 case COMPRESS_CONSTANT:
957 sample[0] = rawConstVal();
965 engine = getCompressionEngine(myCompressionType);
968 for (
int dz = -1; dz <= 1; dz++)
970 for (
int dy = -1; dy <= 1; dy++)
972 for (
int dx = -1; dx <= 1; dx++)
974 sample[sampidx++] = engine->
getValue(*
this, x+dx, y+dy, z+dz);
985 template <
typename T>
986 template <
int AXIS2D>
990 switch (myCompressionType)
994 T *data = (
T *) myData;
995 int offset = (z * myRes[1] +
y) * myRes[0] + x;
997 int zinc = myRes[0] * myRes[1];
1001 sample[1] = data[offset+1];
1004 sample[2+0] = data[offset+yinc];
1006 sample[2+1] = data[offset+yinc+1];
1010 sample[4+0] = data[offset+zinc];
1012 sample[4+1] = data[offset+zinc+1];
1015 sample[4+2+0] = data[offset+zinc+yinc];
1017 sample[4+2+1] = data[offset+zinc+yinc+1];
1022 case COMPRESS_RAWFULL:
1024 T *data = (
T *) myData;
1025 int offset = (z * TILESIZE +
y) * TILESIZE + x;
1026 int yinc = TILESIZE;
1027 int zinc = TILESIZE * TILESIZE;
1029 sample[0] = data[
offset];
1031 sample[1] = data[offset+1];
1034 sample[2+0] = data[offset+yinc];
1036 sample[2+1] = data[offset+yinc+1];
1040 sample[4+0] = data[offset+zinc];
1042 sample[4+1] = data[offset+zinc+1];
1045 sample[4+2+0] = data[offset+zinc+yinc];
1047 sample[4+2+1] = data[offset+zinc+yinc+1];
1052 case COMPRESS_FPREAL16:
1058 int xinc = tuple_size;
1059 int yinc = myRes[0] * xinc;
1060 int zinc = myRes[1] * yinc;
1061 int offset = z * zinc + y * yinc + x * xinc;
1064 sample[0] = convertFromFP16(data);
1066 sample[1] = convertFromFP16(data + xinc);
1069 sample[2+0] = convertFromFP16(data + yinc);
1071 sample[2+1] = convertFromFP16(data + yinc + xinc);
1075 sample[4+0] = convertFromFP16(data + zinc);
1077 sample[4+1] = convertFromFP16(data + zinc + xinc);
1080 sample[4+2+0] = convertFromFP16(data + zinc + yinc);
1082 sample[4+2+1] = convertFromFP16(data + zinc + yinc + xinc);
1087 case COMPRESS_CONSTANT:
1089 sample[0] = rawConstVal();
1097 engine = getCompressionEngine(myCompressionType);
1099 sample[0] = engine->
getValue(*
this, x, y, z);
1101 sample[1] = engine->
getValue(*
this, x+1, y, z);
1104 sample[2+0] = engine->
getValue(*
this, x, y+1, z);
1106 sample[2+1] = engine->
getValue(*
this, x+1, y+1, z);
1110 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
1112 sample[4+1] = engine->
getValue(*
this, x+1, y, z+1);
1115 sample[4+2+0] = engine->
getValue(*
this, x, y+1, z+1);
1117 sample[4+2+1] = engine->
getValue(*
this, x+1, y+1, z+1);
1127 template <
typename T>
1133 switch (myCompressionType)
1136 case COMPRESS_RAWFULL:
1138 T *data = (
T *) myData;
1139 int offset = (z * myRes[1] +
y) * myRes[0] + x;
1140 int yinc = myRes[0];
1141 int zinc = myRes[0] * myRes[1];
1143 a =
v4uf( data[offset],
1146 data[offset+yinc+zinc] );
1147 b =
v4uf( data[offset+1],
1148 data[offset+zinc+1],
1149 data[offset+yinc+1],
1150 data[offset+yinc+zinc+1] );
1154 case COMPRESS_CONSTANT:
1157 return rawConstVal();
1164 engine = getCompressionEngine(myCompressionType);
1167 engine->
getValue(*
this, x, y, z+1),
1168 engine->
getValue(*
this, x, y+1, z),
1169 engine->
getValue(*
this, x, y+1, z+1) );
1171 engine->
getValue(*
this, x+1, y, z+1),
1172 engine->
getValue(*
this, x+1, y+1, z),
1173 engine->
getValue(*
this, x+1, y+1, z+1) );
1180 fx = frac.
swizzle<0, 0, 0, 0>();
1181 fy = frac.
swizzle<1, 1, 1, 1>();
1182 fz = frac.
swizzle<2, 2, 2, 2>();
1199 template <
typename T>
1204 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
1207 int i, xres = myRes[0];
1210 switch (myCompressionType)
1214 src = (
T *)myData + (z * myRes[1] + y) * xres;
1218 for (i = 0; i < xres; i++)
1219 cacheline[i] = src[i];
1221 return &cacheline[
x];
1223 case COMPRESS_FPREAL16:
1229 int xinc = tuple_size;
1230 int yinc = myRes[0] * xinc;
1231 int zinc = myRes[1] * yinc;
1232 int offset = z * zinc + y * yinc + x * xinc;
1237 for (i = 0; i < xres; i++, src += xinc)
1238 cacheline[i] = convertFromFP16(src);
1240 return &cacheline[
x];
1244 case COMPRESS_CONSTANT:
1245 src = rawConstData();
1246 if (!forcecopy && !strideofone)
1253 for (i = 0; i < xres; i++)
1254 cacheline[i] = *src;
1256 return &cacheline[
x];
1259 case COMPRESS_RAWFULL:
1261 src = (
T *)myData + (z * TILESIZE + y) * TILESIZE;
1265 for (i = 0; i < xres; i++)
1266 cacheline[i] = src[i];
1268 return &cacheline[
x];
1274 engine = getCompressionEngine(myCompressionType);
1279 for (i = 0; i < xres; i++)
1280 cacheline[i] = engine->
getValue(*
this, i, y, z);
1282 return &cacheline[
x];
1285 template <
typename T>
1293 int i, xres = myRes[0];
1296 switch (myCompressionType)
1299 dst = (
T *)myData + (z * myRes[1] + y) * xres;
1300 for (i = 0; i < xres; i++)
1301 *dst++ = *cacheline++;
1304 case COMPRESS_CONSTANT:
1305 value = rawConstVal();
1306 for (i = 0; i < xres; i++)
1307 if (cacheline[i] != value)
1315 case COMPRESS_RAWFULL:
1316 dst = (
T *)myData + (z * TILESIZE + y) * TILESIZE;
1317 for (i = 0; i < TILESIZE; i++)
1318 *dst++ = *cacheline++;
1325 for (i = 0; i < xres; i++)
1326 if (!writeThrough(i, y, z, cacheline[i]))
1334 writeCacheLine(cacheline, y, z);
1338 template <
typename T>
1342 int srcx,
int srcy,
int srcz)
1344 int w =
SYSmin(xres() - dstx, srctile.
xres() - srcx);
1345 int h =
SYSmin(yres() - dsty, srctile.
yres() - srcy);
1346 int d =
SYSmin(zres() - dstz, srctile.
zres() - srcz);
1362 dst += dstx + (dsty + dstz*yres())*xres();
1365 src += srcx + (srcy + srcz*srctile.
yres())*srctile.
xres();
1367 for (
int z = 0; z < d; z++)
1369 for (
int y = 0; y <
h; y++)
1373 for (
int x = 0; x <
w; x++)
1378 for (
int x = 0; x <
w; x++)
1383 src += srctile.
xres();
1385 dst += (yres()-
h) * xres();
1387 src += (srctile.
yres() -
h) * srctile.
xres();
1395 for (
int z = 0; z < d; z++)
1396 for (
int y = 0; y <
h; y++)
1397 for (
int x = 0; x <
w; x++)
1400 srctile(srcx+x, srcy+y, srcz+z));
1404 template <
typename T>
1405 template <
typename S>
1413 if (isSimpleCompression())
1419 srcinc = isConstant() ? 0 : 1;
1426 for (
int i = 0; i < w * h * d; i++)
1436 for (
int i = 0; i < w * h * d; i++)
1444 for (
int z = 0; z < d; z++)
1446 for (
int y = 0; y <
h; y++)
1450 for (
int x = 0; x <
w; x++)
1458 for (
int x = 0; x <
w; x++)
1474 for (
int z = 0; z < d; z++)
1475 for (
int y = 0; y <
h; y++)
1476 for (
int x = 0; x <
w; x++)
1478 *dst =
S((*
this)(x, y, z));
1483 template <
typename T>
1484 template <
typename S>
1491 int i,
n = w * h * d;
1495 int srcoff = srcstride;
1500 makeConstant(
T(compare));
1504 for (i = 1; i <
n; i++)
1506 if (srcdata[srcoff] != compare)
1508 srcoff += srcstride;
1514 makeConstant(compare);
1524 for (i = 0; i <
n; i++)
1526 *dst++ =
T(*srcdata++);
1534 for (i = 0; i <
n; i++)
1536 dst[i] =
T(srcdata[srcoff]);
1537 srcoff += srcstride;
1542 template <
typename T>
1547 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
1551 if (writeThrough(x, y, z, t))
1564 template <
typename T>
1568 switch (myCompressionType)
1574 case COMPRESS_CONSTANT:
1580 cval = rawConstVal();
1583 myCompressionType = COMPRESS_RAW;
1585 if (myRes[0] == TILESIZE &&
1586 myRes[1] == TILESIZE)
1589 myCompressionType = COMPRESS_RAWFULL;
1592 n = myRes[0] * myRes[1] * myRes[2];
1595 for (i = 0; i <
n; i++)
1597 ((
T *)myData)[i] = cval;
1601 case COMPRESS_RAWFULL:
1606 if (myRes[0] == TILESIZE &&
1607 myRes[1] == TILESIZE)
1614 n = myRes[0] * myRes[1] * myRes[2];
1617 for (z = 0; z < myRes[2]; z++)
1619 for (y = 0; y < myRes[1]; y++)
1621 for (x = 0; x < myRes[0]; x++)
1623 raw[i++] = ((
T *)myData)[x+(y+z*TILESIZE)*TILESIZE];
1629 myCompressionType = COMPRESS_RAW;
1635 case COMPRESS_FPREAL16:
1644 n = myRes[0] * myRes[1] * myRes[2];
1647 for (z = 0; z < myRes[2]; z++)
1649 for (y = 0; y < myRes[1]; y++)
1651 for (x = 0; x < myRes[0]; x++, src += tuple_size)
1653 raw[i] = convertFromFP16(src);
1659 myCompressionType = COMPRESS_RAW;
1668 engine = getCompressionEngine(myCompressionType);
1676 for (z = 0; z < myRes[2]; z++)
1678 for (y = 0; y < myRes[1]; y++)
1680 for (x = 0; x < myRes[0]; x++)
1682 raw[i++] = engine->
getValue(*
this, x, y, z);
1690 myCompressionType = COMPRESS_RAW;
1691 if (myRes[0] == TILESIZE &&
1692 myRes[1] == TILESIZE)
1695 myCompressionType = COMPRESS_RAWFULL;
1701 template <
typename T>
1708 if (myCompressionType == COMPRESS_RAWFULL)
1713 UT_ASSERT(myCompressionType == COMPRESS_RAW);
1717 if (myRes[0] < TILESIZE || myRes[1] < TILESIZE)
1721 for (z = 0; z < myRes[2]; z++)
1723 for (y = 0; y < myRes[1]; y++)
1725 for (x = 0; x < myRes[0]; x++)
1727 raw[x+(y+z*TILESIZE)*TILESIZE] = ((
T *)myData)[i++];
1734 myCompressionType = COMPRESS_RAWFULL;
1737 template <
typename T>
1741 if (isRaw() || isRawFull())
1746 if (myRes[0] == TILESIZE && myRes[1] == TILESIZE)
1747 myCompressionType = COMPRESS_RAWFULL;
1749 myCompressionType = COMPRESS_RAW;
1754 template <
typename T>
1758 float irx, iry, irz;
1760 irx = 1.0 / myRes[0];
1761 iry = 1.0 / myRes[1];
1762 irz = 1.0 / myRes[2];
1763 switch (myCompressionType)
1768 const T *data = (
const T*) myData;
1773 for (
int z = 0; z < myRes[2]; z++)
1777 for (
int y = 0; y < myRes[1]; y++)
1781 for (
int x = 0; x < myRes[0]; x++)
1797 case COMPRESS_FPREAL16:
1810 static_assert(tuple_size <= 4);
1812 for (
int z = 0; z < myRes[2]; z++)
1815 for (
int y = 0; y < myRes[1]; y++)
1818 for (
int x = 0; x < myRes[0]; x++)
1820 for (
int j = 0;
j < tuple_size;
j++)
1822 xavg[
j] += data[i++];
1825 for (
int j = 0;
j < tuple_size;
j++)
1831 for (
int j = 0;
j < tuple_size;
j++)
1837 for (
int j = 0;
j < tuple_size;
j++)
1842 avg = convertFromFP16(zavg);
1846 case COMPRESS_CONSTANT:
1847 avg = rawConstVal();
1850 case COMPRESS_RAWFULL:
1853 const T *data = (
const T*) myData;
1858 for (
int z = 0; z < myRes[2]; z++)
1862 for (
int y = 0; y < myRes[1]; y++)
1866 for (
int x = 0; x < myRes[0]; x++)
1887 for (
int z = 0; z < myRes[2]; z++)
1891 for (
int y = 0; y < myRes[1]; y++)
1895 for (
int x = 0; x < myRes[0]; x++)
1897 xavg += (*this)(
x,
y,
z);
1913 template <
typename T>
1917 switch (myCompressionType)
1921 int n = myRes[0] * myRes[1] * myRes[2];
1924 min = max = *(
T*)myData;
1925 for (i = 1; i <
n; i++)
1927 expandMinMax( ((
T*)myData)[i], min, max );
1932 case COMPRESS_FPREAL16:
1937 int n = myRes[0] * myRes[1] * myRes[2];
1942 for (i = 1; i <
n; i++, src += tuple_size)
1944 T val = convertFromFP16(src);
1945 expandMinMax( val, min, max );
1950 case COMPRESS_CONSTANT:
1951 min = max = rawConstVal();
1954 case COMPRESS_RAWFULL:
1958 min = max = *(
T*)myData;
1960 for (z = 0; z < myRes[2]; z++)
1962 for (y = 0; y < myRes[1]; y++)
1964 for (x = 0; x < myRes[0]; x++)
1967 ((
T*)myData)[x+offset],
1981 engine = getCompressionEngine(myCompressionType);
1989 template <
typename T>
1993 switch (myCompressionType)
1996 case COMPRESS_RAWFULL:
1998 int n = myRes[0] * myRes[1] * myRes[2];
2001 for (i = 0; i <
n; i++)
2009 case COMPRESS_FPREAL16:
2014 case COMPRESS_CONSTANT:
2025 engine = getCompressionEngine(myCompressionType);
2027 for (z = 0; z < myRes[2]; z++)
2028 for (y = 0; y < myRes[1]; y++)
2029 for (x = 0; x < myRes[0]; x++)
2040 template <
typename T>
2050 if (myCompressionType == COMPRESS_CONSTANT)
2053 findMinMax(min, max);
2059 if (myCompressionType == COMPRESS_CONSTANT)
2080 if (myCompressionType == COMPRESS_RAW ||
2081 myCompressionType == COMPRESS_RAWFULL)
2088 for (i = 0; i < getCompressionEngines().entries(); i++)
2090 engine = getCompressionEngines()(i);
2096 if (engine->
tryCompress(*
this, options, min, max))
2098 myCompressionType = i + COMPRESS_ENGINE;
2107 if (myCompressionType == COMPRESS_RAW)
2109 if (myRes[0] == TILESIZE && myRes[1] == TILESIZE)
2111 myCompressionType = COMPRESS_RAWFULL;
2119 template <
typename T>
2127 if (!inlineConstant())
2131 myCompressionType = COMPRESS_CONSTANT;
2132 *rawConstData() =
t;
2135 template <
typename T>
2147 if (myCompressionType == COMPRESS_FPREAL16)
2151 int len = myRes[2] * myRes[1] * myRes[0] * tuple_size;
2154 if (myCompressionType == COMPRESS_RAW ||
2155 myCompressionType == COMPRESS_RAWFULL)
2157 for (
int i = 0; i < len; i++)
2167 for (
int z = 0; z < myRes[2]; z++)
2169 for (
int y = 0; y < myRes[1]; y++)
2171 for (
int x = 0; x < myRes[0]; x++)
2173 if constexpr (tuple_size == 1)
2178 for (
int j = 0;
j < tuple_size;
j++)
2190 myCompressionType = COMPRESS_FPREAL16;
2193 template <
typename T>
2197 int64 mem = inclusive ?
sizeof(*this) : 0;
2198 mem += getDataLength();
2202 template <
typename T>
2208 switch (myCompressionType)
2211 usage =
sizeof(
T) * xres() * yres() * zres();
2213 case COMPRESS_FPREAL16:
2214 usage =
sizeof(
fpreal16) * xres() * yres() * zres()
2217 case COMPRESS_CONSTANT:
2218 if (inlineConstant())
2223 case COMPRESS_RAWFULL:
2224 usage =
sizeof(
T) * TILESIZE * TILESIZE * zres();
2230 engine = getCompressionEngine(myCompressionType);
2238 template <
typename T>
2241 const float *weights[3],
int start[3],
2251 switch (myCompressionType)
2253 case COMPRESS_CONSTANT:
2256 for (i = 0; i < 3; i++)
2259 for (ix = 0; ix < pend[i]-pstart[i]; ix++)
2260 pw += weights[i][ix+pstart[i]-start[i]];
2263 result += w * rawConstVal();
2269 tstart[0] = pstart[0] & TILEMASK;
2270 tstart[1] = pstart[1] & TILEMASK;
2271 tstart[2] = pstart[2] & TILEMASK;
2272 ixstart = pstart[0]-start[0];
2273 ixend = pend[0]-start[0];
2277 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2282 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2285 px = ((pz * myRes[1]) + py) * myRes[0] + tstart[0];
2286 for (ix = ixstart; ix < ixend; ix++, px++)
2288 psumx += weights[0][ix]* ((
T*)myData)[px];
2290 psumy += weights[1][iy-start[1]] * psumx;
2292 result += weights[2][iz-start[2]] * psumy;
2297 case COMPRESS_FPREAL16:
2302 int xinc = tuple_size;
2303 int yinc = myRes[0] * xinc;
2304 int zinc = myRes[1] * yinc;
2308 tstart[0] = pstart[0] & TILEMASK;
2309 tstart[1] = pstart[1] & TILEMASK;
2310 tstart[2] = pstart[2] & TILEMASK;
2311 ixstart = pstart[0]-start[0];
2312 ixend = pend[0]-start[0];
2316 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2321 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2324 px = pz * zinc + py * yinc + tstart[0] * xinc;
2325 for (ix = ixstart; ix < ixend; ix++, px += xinc)
2327 T val = convertFromFP16(src + px);
2328 psumx += weights[0][ix]*
val;
2330 psumy += weights[1][iy-start[1]] * psumx;
2332 result += weights[2][iz-start[2]] * psumy;
2336 case COMPRESS_RAWFULL:
2338 tstart[0] = pstart[0] & TILEMASK;
2339 tstart[1] = pstart[1] & TILEMASK;
2340 tstart[2] = pstart[2] & TILEMASK;
2341 ixstart = pstart[0]-start[0];
2342 ixend = pend[0]-start[0];
2344 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2348 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2351 px = ((pz * TILESIZE) + py) * TILESIZE + tstart[0];
2352 for (ix = ixstart; ix < ixend; ix++, px++)
2354 psumx += weights[0][ix]* ((
T*)myData)[px];
2356 psumy += weights[1][iy-start[1]] * psumx;
2358 result += weights[2][iz-start[2]] * psumy;
2368 tstart[0] = pstart[0] & TILEMASK;
2369 tstart[1] = pstart[1] & TILEMASK;
2370 tstart[2] = pstart[2] & TILEMASK;
2371 ixstart = pstart[0]-start[0];
2372 ixend = pend[0]-start[0];
2374 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2378 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2382 for (ix = ixstart; ix < ixend; ix++, px++)
2384 psumx += weights[0][ix] *
2385 (*this)(px,
py, pz);
2387 psumy += weights[1][iy-start[1]] * psumx;
2389 result += weights[2][iz-start[2]] * psumy;
2396 template <
typename T>
2403 for (i = 0; i < getCompressionEngines().entries(); i++)
2405 if (!strcmp(engine->
getName(), getCompressionEngines()(i)->
getName()))
2407 getCompressionEngines()(i) = engine;
2412 getCompressionEngines().append(engine);
2415 template <
typename T>
2424 for (i = 0; i < getCompressionEngines().entries(); i++)
2426 if (!strcmp(name, getCompressionEngines()(i)->
getName()))
2428 return i + COMPRESS_ENGINE;
2435 template <
typename T>
2439 index -= COMPRESS_ENGINE;
2441 return getCompressionEngines()(
index);
2444 template <
typename T>
2449 if (myCompressionType >= COMPRESS_ENGINE)
2455 char type = myCompressionType;
2457 UTwrite(os, &type, 1);
2458 engine->
save(os, *
this);
2463 char type = COMPRESS_RAW;
2466 UTwrite(os, &type, 1);
2468 for (
int z = 0; z < zres(); z++)
2469 for (
int y = 0; y < yres(); y++)
2470 for (
int x = 0; x < xres(); x++)
2472 value = (*this)(
x,
y,
z);
2473 UTwrite<T>(os, &
value, 1);
2479 char type = myCompressionType;
2481 if (type == COMPRESS_RAWFULL &&
2482 myRes[0] == TILESIZE &&
2483 myRes[1] == TILESIZE &&
2484 myRes[2] != TILESIZE)
2488 type = COMPRESS_RAW;
2491 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2493 UTwrite(os, &type, 1);
2498 len = myRes[2] * myRes[1] * myRes[0];
2499 UTwrite<T>(os, (
T *) myData, len);
2502 case COMPRESS_FPREAL16:
2503 len = myRes[2] * myRes[1] * myRes[0]
2505 UTwrite(os, (
int16 *) myData, len);
2508 case COMPRESS_RAWFULL:
2509 len = TILESIZE * TILESIZE * TILESIZE;
2510 UTwrite<T>(os, (
T *) myData, len);
2513 case COMPRESS_CONSTANT:
2514 UTwrite<T>(os, rawConstData(), 1);
2517 case COMPRESS_ENGINE:
2523 template <
typename T>
2533 if (type >= 0 && type < compress.
entries())
2536 type = compress(type);
2539 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2543 if (type >= COMPRESS_ENGINE)
2546 myCompressionType =
type;
2548 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2551 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2557 engine->
load(is, *
this);
2570 myCompressionType =
type;
2575 len = myRes[2] * myRes[1] * myRes[0];
2577 is.
read<
T>((
T *) myData, len);
2580 case COMPRESS_FPREAL16:
2581 len = myRes[2] * myRes[1] * myRes[0]
2587 case COMPRESS_RAWFULL:
2588 len = TILESIZE * TILESIZE * TILESIZE;
2590 is.
read<
T>((
T *) myData, len);
2593 case COMPRESS_CONSTANT:
2594 if (!inlineConstant())
2596 is.
read<
T>(rawConstData(), 1);
2599 case COMPRESS_ENGINE:
2605 if (myCompressionType == COMPRESS_RAW &&
2606 myRes[0] == TILESIZE &&
2607 myRes[1] == TILESIZE)
2608 myCompressionType = COMPRESS_RAWFULL;
2611 template <
typename T>
2621 if (myCompressionType >= COMPRESS_ENGINE)
2627 char type = myCompressionType;
2635 ok = ok && engine->
save(w, *
this);
2641 char type = COMPRESS_RAW;
2654 for (
int z = 0; z < zres(); z++)
2655 for (
int y = 0; y < yres(); y++)
2656 for (
int x = 0; x < xres(); x++)
2658 value = (*this)(
x,
y,
z);
2659 if constexpr (tuple_size == 1)
2665 for (
int i = 0; i < tuple_size; i++)
2677 char type = myCompressionType;
2679 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2687 switch (myCompressionType)
2690 len = myRes[2] * myRes[1] * myRes[0];
2694 case COMPRESS_FPREAL16:
2699 case COMPRESS_RAWFULL:
2700 len = TILESIZE * TILESIZE * myRes[2];
2704 case COMPRESS_CONSTANT:
2705 if constexpr (tuple_size == 1)
2716 template <
typename T>
2746 if (type >= 0 && type < compress.
entries())
2749 type = compress(type);
2752 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2756 if (type >= COMPRESS_ENGINE)
2759 myCompressionType =
type;
2761 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2764 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2770 bool engine_ok = engine->
load(p, *
this);
2772 return it.
atEnd() && engine_ok;
2783 myCompressionType =
type;
2785 switch (myCompressionType)
2788 len = myRes[2] * myRes[1] * myRes[0];
2795 case COMPRESS_FPREAL16:
2802 case COMPRESS_RAWFULL:
2803 len = TILESIZE * TILESIZE * myRes[2];
2810 case COMPRESS_CONSTANT:
2811 if (!inlineConstant())
2813 if constexpr (tuple_size == 1)
2830 template <
typename T>
2834 int16 ntype = getCompressionEngines().entries();
2837 ntype += COMPRESS_ENGINE;
2839 UTwrite(os, &ntype);
2847 ntype -= COMPRESS_ENGINE;
2848 for (i = 0; i < ntype; i++)
2854 template <
typename T>
2865 for (i = 0; i < ntype; i++)
2871 compress.
append(COMPRESS_RAW);
2872 else if (name ==
"rawfull")
2873 compress.
append(COMPRESS_RAWFULL);
2874 else if (name ==
"constant")
2875 compress.
append(COMPRESS_CONSTANT);
2876 else if (name ==
"fpreal16")
2877 compress.
append(COMPRESS_FPREAL16);
2880 idx = lookupCompressionEngine(name);
2890 template <
typename T>
2894 int16 ntype = getCompressionEngines().entries();
2898 ntype += COMPRESS_ENGINE;
2907 ntype -= COMPRESS_ENGINE;
2908 for (i = 0; i < ntype; i++)
2917 template <
typename T>
2931 if (!buffer.
strcmp(
"raw"))
2932 compress.
append(COMPRESS_RAW);
2933 else if (!buffer.
strcmp(
"rawfull"))
2934 compress.
append(COMPRESS_RAWFULL);
2935 else if (!buffer.
strcmp(
"constant"))
2936 compress.
append(COMPRESS_CONSTANT);
2937 else if (!buffer.
strcmp(
"fpreal16"))
2938 compress.
append(COMPRESS_FPREAL16);
2941 idx = lookupCompressionEngine(buffer.
buffer());
2958 template <
typename T>
2973 myBorderScale[0] = 0;
2974 myBorderScale[1] = 0;
2975 myBorderScale[2] = 0;
2979 mySharedMemView = 0;
2982 template <
typename T>
2988 template <
typename T>
3002 mySharedMemView = 0;
3007 template <
typename T>
3014 vit.splitByTile(info);
3015 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3017 int i = vit.getLinearTileNum();
3018 myTiles[i] = src.myTiles[i];
3022 template <
typename T>
3030 myBorderScale[0] = src.myBorderScale[0];
3031 myBorderScale[1] = src.myBorderScale[1];
3032 myBorderScale[2] = src.myBorderScale[2];
3033 myBorderValue = src.myBorderValue;
3034 myBorderType = src.myBorderType;
3036 myCompressionOptions = src.myCompressionOptions;
3040 size(src.myRes[0], src.myRes[1], src.myRes[2],
false);
3050 #define __MULTITHREADED_STRUCTORS__
3051 template <
typename T>
3055 #ifdef __MULTITHREADED_STRUCTORS__
3060 for(
int i = range.begin(); i < range.end(); i++)
3062 myTiles[i].~UT_VoxelTile<
T>();
3065 operator delete(myTiles, std::nothrow);
3071 myTileRes[0] = myTileRes[1] = myTileRes[2] = 0;
3072 myRes[0] = myRes[1] = myRes[2] = 0;
3074 delete mySharedMemView;
3075 mySharedMemView = 0;
3081 template <
typename T>
3086 if (myRes[0] == xres && myRes[1] == yres && myRes[2] == zres)
3101 tile_res[0] = (xres + TILEMASK) >> TILEBITS;
3102 tile_res[1] = (yres + TILEMASK) >> TILEBITS;
3103 tile_res[2] = (zres + TILEMASK) >> TILEBITS;
3105 exint ntiles = ((
exint)tile_res[0]) * tile_res[1] * tile_res[2];
3108 #ifdef __MULTITHREADED_STRUCTORS__
3122 for(
int k = range.begin(); k < range.end(); k++)
3127 int tilex = k % tile_res[0];
3128 int k2 = k / tile_res[0];
3129 int tiley = k2 % tile_res[1];
3130 int tilez = k2 / tile_res[1];
3131 myTiles[k].
setRes(
SYSmin(TILESIZE, xres - tilex * TILESIZE),
3132 SYSmin(TILESIZE, yres - tiley * TILESIZE),
3133 SYSmin(TILESIZE, zres - tilez * TILESIZE));
3147 myInvRes.x() = 1.0f / myRes[0];
3149 myInvRes.y() = 1.0f / myRes[1];
3151 myInvRes.z() = 1.0f / myRes[2];
3153 myTileRes[0] = tile_res[0];
3154 myTileRes[1] = tile_res[1];
3155 myTileRes[2] = tile_res[2];
3157 #ifndef __MULTITHREADED_STRUCTORS__
3159 for (
int tz = 0; tz < myTileRes[2]; tz++)
3162 if (tz < myTileRes[2]-1)
3165 zr = zres - tz * TILESIZE;
3167 for (
int ty = 0; ty < myTileRes[1]; ty++)
3170 if (ty < myTileRes[1]-1)
3173 yr = yres - ty * TILESIZE;
3175 int tx, xr = TILESIZE;
3176 for (tx = 0; tx < myTileRes[0]-1; tx++)
3178 myTiles[i].
setRes(xr, yr, zr);
3182 xr = xres - tx * TILESIZE;
3183 myTiles[i].setRes(xr, yr, zr);
3193 template <
typename T>
3202 myBorderType = src.myBorderType;
3203 myBorderScale[0] = src.myBorderScale[0];
3204 myBorderScale[1] = src.myBorderScale[1];
3205 myBorderScale[2] = src.myBorderScale[2];
3206 myBorderValue = src.myBorderValue;
3209 myCompressionOptions = src.myCompressionOptions;
3212 template <
typename T>
3216 int64 mem = inclusive ?
sizeof(*this) : 0;
3218 int ntiles = numTiles();
3219 for (
int i = 0; i < ntiles; i++)
3220 mem += myTiles[i].getMemoryUsage(
true);
3223 mem += mySharedMem->getMemoryUsage(
true);
3225 if (mySharedMemView)
3226 mem += mySharedMemView->getMemoryUsage(
true);
3231 template <
typename T>
3238 vit.setPartialRange(info.
job(), info.
numJobs());
3239 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3241 int i = vit.getLinearTileNum();
3242 myTiles[i].makeConstant(t);
3246 template <
typename T>
3255 ntiles = numTiles();
3256 for (i = 0; i < ntiles; i++)
3258 if (!myTiles[i].isConstant())
3266 cval = myTiles[i].rawConstVal();
3286 template <
typename T>
3292 ntiles = numTiles();
3293 for (i = 0; i < ntiles; i++)
3295 if (myTiles[i].hasNan())
3304 template <
typename T>
3310 pos.
x() *= myRes[0];
3311 pos.
y() *= myRes[1];
3312 pos.
z() *= myRes[2];
3317 return lerpVoxelCoord(pos);
3320 template <
typename T>
3328 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3330 return lerpVoxel(x, y, z, fx, fy, fz);
3333 template <
typename T>
3334 template <
int AXIS2D>
3342 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3344 return lerpVoxelAxis<AXIS2D>(
x,
y,
z, fx, fy, fz);
3347 template <
typename T>
3350 float fx,
float fy,
float fz)
const
3353 T vx, vx1, vy, vy1, vz;
3357 if ( !((x | y | z) < 0) &&
3358 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3371 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3374 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3376 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
3390 (*
this)(x+1, y+1, z),
3397 (*
this)(x+1, y, z+1),
3401 (*
this)(x+1, y+1, z+1),
3444 template <
typename T>
3445 template <
int AXIS2D>
3448 float fx,
float fy,
float fz)
const
3451 T vx, vx1, vy, vy1, vz;
3453 int lesscomp = 0, greatercomp = -1;
3458 greatercomp &= (x - myRes[0]+1);
3463 greatercomp &= (y - myRes[1]+1);
3468 greatercomp &= (z - myRes[2]+1);
3473 if ( !(lesscomp < 0) && (greatercomp < 0) )
3481 if ((AXIS2D == 0 || xm != TILEMASK) &&
3482 (AXIS2D == 1 || ym != TILEMASK) &&
3483 (AXIS2D == 2 || zm != TILEMASK))
3486 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3487 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3488 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3490 vz = tile->template lerpAxis<AXIS2D>(xm, ym, zm, fx, fy, fz);
3504 vx = (*this)(
x,
y,
z);
3511 (*
this)(x+1, y+1, z),
3514 vx1 = (*this)(
x, y+1,
z);
3526 (*
this)(x+1, y, z+1),
3529 vx = (*this)(
x,
y, z+1);
3536 (*
this)(x+1, y+1, z+1),
3539 vx1 = (*this)(
x, y+1, z+1);
3613 template <
typename T>
3620 pos.
x() *= myRes[0];
3621 pos.
y() *= myRes[1];
3622 pos.
z() *= myRes[2];
3627 lerpVoxelCoordMinMax(lerp, lmin, lmax, pos);
3630 template <
typename T>
3639 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3641 lerpVoxelMinMax(lerp, lmin, lmax, x, y, z, fx, fy, fz);
3645 template <
typename T>
3646 template <
int AXIS2D>
3655 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3657 lerpVoxelMinMaxAxis<AXIS2D>(
lerp, lmin, lmax,
x,
y,
z, fx, fy, fz);
3661 template <
typename T>
3665 int x,
int y,
int z,
3666 float fx,
float fy,
float fz)
const
3670 if (extractSample(x, y, z, samples))
3672 lerp = smin = smax = samples[0];
3676 lerp = lerpSample(samples, fx, fy, fz);
3680 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3682 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3685 smin =
SYSmin(smin, smin1);
3686 smax =
SYSmax(smax, smax1);
3689 template <
typename T>
3690 template <
int AXIS2D>
3694 int x,
int y,
int z,
3695 float fx,
float fy,
float fz)
const
3699 if (extractSampleAxis<AXIS2D>(x, y, z, samples))
3701 lerp = smin = smax = samples[0];
3705 lerp = lerpSampleAxis<AXIS2D>(
samples, fx, fy, fz);
3708 SYSminmax(samples[0], samples[2], samples[4], samples[6],
3710 else if (AXIS2D == 1)
3711 SYSminmax(samples[0], samples[1], samples[4], samples[5],
3713 else if (AXIS2D == 2)
3714 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3720 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3722 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3725 smin =
SYSmin(smin, smin1);
3726 smax =
SYSmax(smax, smax1);
3730 template <
typename T>
3737 if ( !((x | y | z) < 0) &&
3738 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3751 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3754 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3763 samples[0] = (*this)(
x,
y,
z);
3764 samples[1] = (*this)(x+1,
y,
z);
3765 samples[2+0] = (*this)(
x, y+1,
z);
3766 samples[2+1] = (*this)(x+1, y+1,
z);
3767 samples[4+0] = (*this)(
x,
y, z+1);
3768 samples[4+1] = (*this)(x+1,
y, z+1);
3769 samples[4+2+0] = (*this)(
x, y+1, z+1);
3770 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3777 samples[2+0] =
getValue(x, y+1, z);
3778 samples[2+1] =
getValue(x+1, y+1, z);
3779 samples[4+0] =
getValue(x, y, z+1);
3780 samples[4+1] =
getValue(x+1, y, z+1);
3781 samples[4+2+0] =
getValue(x, y+1, z+1);
3782 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3789 template <
typename T>
3790 template <
int AXIS2D>
3797 int lesscomp = 0, greatercomp = -1;
3802 greatercomp &= (x - myRes[0]+1);
3807 greatercomp &= (y - myRes[1]+1);
3812 greatercomp &= (z - myRes[2]+1);
3817 if ( !(lesscomp < 0) && (greatercomp < 0) )
3825 if ((AXIS2D == 0 || xm != TILEMASK) &&
3826 (AXIS2D == 1 || ym != TILEMASK) &&
3827 (AXIS2D == 2 || zm != TILEMASK))
3830 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3831 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3832 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3834 return tile->template extractSampleAxis<AXIS2D>(xm, ym, zm,
samples);
3841 samples[0] = (*this)(
x,
y,
z);
3843 samples[1] = (*this)(x+1,
y,
z);
3846 samples[2+0] = (*this)(
x, y+1,
z);
3848 samples[2+1] = (*this)(x+1, y+1,
z);
3852 samples[4+0] = (*this)(
x,
y, z+1);
3854 samples[4+1] = (*this)(x+1,
y, z+1);
3857 samples[4+2+0] = (*this)(
x, y+1, z+1);
3859 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3871 samples[2+0] =
getValue(x, y+1, z);
3873 samples[2+1] =
getValue(x+1, y+1, z);
3877 samples[4+0] =
getValue(x, y, z+1);
3879 samples[4+1] =
getValue(x+1, y, z+1);
3882 samples[4+2+0] =
getValue(x, y+1, z+1);
3884 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3892 template <
typename T>
3899 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
3900 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3913 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3916 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3925 samples[0] = (*this)(x-1,
y,
z);
3926 samples[1] = (*this)(x+1,
y,
z);
3927 samples[2+0] = (*this)(
x, y-1,
z);
3928 samples[2+1] = (*this)(
x, y+1,
z);
3929 samples[4+0] = (*this)(
x,
y, z-1);
3930 samples[4+1] = (*this)(
x,
y, z+1);
3931 samples[6] = (*this)(
x,
y,
z);
3938 samples[2+0] =
getValue(x, y-1, z);
3939 samples[2+1] =
getValue(x, y+1, z);
3940 samples[4+0] =
getValue(x, y, z-1);
3941 samples[4+1] =
getValue(x, y, z+1);
3952 template <
typename T>
3959 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
3960 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3973 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3976 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3978 return tile->extractSampleCube(xm, ym, zm, samples);
3986 for (
int dz = -1; dz <= 1; dz++)
3988 for (
int dy = -1; dy <= 1; dy++)
3990 for (
int dx = -1; dx <= 1; dx++)
3992 samples[sampidx++] = (*this)(x+dx, y+dy, z+dz);
4001 for (
int dz = -1; dz <= 1; dz++)
4003 for (
int dy = -1; dy <= 1; dy++)
4005 for (
int dx = -1; dx <= 1; dx++)
4007 samples[sampidx++] =
getValue(x+dx, y+dy, z+dz);
4017 template <
typename T>
4020 float fx,
float fy,
float fz)
const
4024 T vx, vx1, vy, vy1, vz;
4054 v4uf a,
b, vfx, vfy, vfz;
4056 a =
v4uf(&samples[0]);
4057 b =
v4uf(&samples[4]);
4078 template <
typename T>
4079 template <
int AXIS2D>
4082 float fx,
float fy,
float fz)
const
4085 T vx, vx1, vy, vy1, vz;
4138 template <
typename T>
4148 pos.
x() *= myRes[0];
4149 pos.
y() *= myRes[1];
4150 pos.
z() *= myRes[2];
4157 SYSfastSplitFloat(fx, x);
4159 SYSfastSplitFloat(fy, y);
4161 SYSfastSplitFloat(fz, z);
4164 T vx, vx1, vy, vy1, vz;
4180 if ( !((x | y | z) < 0) &&
4181 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4193 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4196 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4198 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
4212 (*
this)(x+1, y+1, z),
4219 (*
this)(x+1, y, z+1),
4223 (*
this)(x+1, y+1, z+1),
4267 template <
typename T>
4277 pos *=
v4uf((
float) myRes[0], (
float) myRes[1], (
float) myRes[2], 0.0
f);
4306 if ( (x > 0) & (y > 0) & (z > 0) &
4307 (x < myRes[0]-1) & (y < myRes[1]-1) & (z < myRes[2]-1) &
4308 (xm != TILEMASK) & (ym != TILEMASK) & (zm != TILEMASK) )
4317 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4319 return tile->
lerp(pos, xm, ym, zm);
4333 fx = pos.
swizzle<0, 0, 0, 0>();
4334 fy = pos.
swizzle<1, 1, 1, 1>();
4335 fz = pos.
swizzle<2, 2, 2, 2>();
4353 firstTile(
int &
start,
int &
end,
int res)
4364 nextTile(
int &tile,
int &pstart,
int &start,
int &end,
int res)
4374 tile = pstart >> TILEBITS;
4375 pend =
SYSmin((tile+1) * TILESIZE, end, res);
4385 template <
typename T>
4388 fpreal radius,
int clampaxis)
const
4394 const float *weights[3];
4396 int start[3], end[3],
size[3];
4397 int pstart[3], pend[3];
4404 return myBorderValue;
4408 switch (myBorderType)
4419 for (i = 0; i < 3; i++)
4427 memset(&result, 0,
sizeof(result));
4434 for (i = 0; i < 3; i++)
4436 tpos[i] = tpos[i]*myRes[i];
4437 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4441 start[i] = win[i].
getStart() % myRes[i];
4447 end[i] = start[i] + size[i];
4452 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4453 while (pstart[2] < end[2])
4455 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4456 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4457 while (pstart[1] < end[1])
4459 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4460 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4461 while (pstart[0] < end[0])
4463 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4464 tile = getTile(tx, ty, tz);
4466 tile->
weightedSum(pstart, pend, weights, start, result);
4467 pstart[0] = pend[0];
4469 pstart[1] = pend[1];
4471 pstart[2] = pend[2];
4476 result += (1-visible)*myBorderValue;
4482 template <
typename T>
4486 float filterwidthscale,
4498 radius *= 0.5 * filterwidthscale;
4500 resamplethread(src, filter, radius, clampaxis);
4505 template <
typename T>
4506 template <
typename OP>
4513 for (
int tileidx =
range.begin(); tileidx !=
range.end(); tileidx++)
4530 template <
typename T>
4537 if (getXRes() == 1 && ystride == 1)
4539 flattenPartialAxis<0>(flatarray, zstride, info);
4541 else if (getYRes() == 1 && zstride == ystride)
4543 flattenPartialAxis<1>(flatarray, zstride, info);
4545 else if (getZRes() == 1)
4547 flattenPartialAxis<2>(flatarray, ystride, info);
4561 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4567 template <
typename T>
4568 template <
int AXIS2D>
4575 const int ax = (AXIS2D == 0) ? 1 : 0;
4576 const int ay = (AXIS2D == 2) ? 1 : 2;
4577 int tileidx[3] = { 0, 0, 0 };
4582 exint ystart = tiley * TILESIZE;
4583 if (ystart >= getRes(ay))
4586 T *stripe = &flatarray[ystart * ystride];
4588 int yres =
SYSmin(getRes(ay) - ystart, TILESIZE);
4590 for (
int tilex = 0, ntilex = getTileRes(ax); tilex < ntilex; tilex++)
4592 tileidx[ax] = tilex;
4593 tileidx[ay] = tiley;
4594 auto tile = getTile(tileidx[0], tileidx[1], tileidx[2]);
4596 int xres = tile->getRes(ax);
4597 T *stripey = stripe;
4598 if (tile->isConstant())
4600 const T *srcdata = tile->rawData();
4602 for (
int y = 0; y < yres; y++)
4604 for (
int x = 0; x < xres; x++)
4606 memcpy(&stripey[x], srcdata,
sizeof(
T));
4611 else if (tile->isSimpleCompression())
4613 const T *srcdata = tile->rawData();
4615 if (xres != TILESIZE)
4617 for (
int y = 0; y < yres; y++)
4619 memcpy(stripey, srcdata,
sizeof(
T) * xres);
4626 for (
int y = 0; y < yres; y++)
4628 memcpy(stripey, srcdata,
sizeof(
T) * TILESIZE);
4629 srcdata += TILESIZE;
4636 for (
int y = 0; y < yres; y++)
4638 int idx[3] = { 0, 0, 0 };
4640 for (
int x = 0; x < xres; x++)
4643 stripey[
x] = (*tile)(idx[0], idx[1], idx[2]);
4673 int idx = (vit.
x() + vit.
y()*ystride + vit.
z()*zstride) * 4;
4676 flatarray[idx+1] = (
uint8)
SYSclamp(v.
y() * 255.0f, 0.0f, 255.0f);
4677 flatarray[idx+2] = (
uint8)
SYSclamp(v.
z() * 255.0f, 0.0f, 255.0f);
4678 flatarray[idx+3] = (
uint8)
SYSclamp(v.
w() * 255.0f, 0.0f, 255.0f);
4682 template <
typename T>
4688 UT_ASSERT(!
"This template requires specific instantiations.");
4707 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4710 template <
typename T>
4716 UT_ASSERT(!
"This template requires specific instantiations.");
4751 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] =
v;
4755 template <
typename T>
4761 UT_ASSERT(!
"This template requires specific instantiations.");
4765 template <
typename T>
4779 vit.
setValue(flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride]);
4783 template <
typename T>
4784 template <
int SLICE,
typename S>
4788 int slice_res = getRes(SLICE);
4790 if (slice < 0 || slice >= slice_res ||
4791 (half_slice && slice == slice_res - 1))
4794 constexpr
int AXIS1 = (SLICE == 0 ? 1 : 0);
4795 constexpr
int AXIS2 = (SLICE == 1 ? 2 : 1);
4798 int a1_res = getRes(AXIS1);
4800 int a1_tiles = getTileRes(AXIS1);
4801 int a2_tiles = getTileRes(AXIS2);
4802 int ntiles = a1_tiles * a2_tiles;
4805 int tile_stride2 = (a1_res << TILEBITS);
4806 int tile_stride1 = TILESIZE;
4808 int tile_slice = (slice >> TILEBITS);
4809 int local_slice = (slice & TILEMASK);
4812 bool half_slice_st = half_slice && (local_slice != TILEMASK);
4815 bool half_slice_tb =
false;
4827 auto set_functor = [&](
const UT_VoxelTile<T>* tile,
int idx[3],
int vidx)
4831 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
4833 dstdata[vidx] = 0.5f * (dstdata[vidx] +
4834 (*tile)(idx[0], idx[1], idx[2]));
4837 else if (half_slice_tb)
4838 dstdata[vidx] = 0.5f * (dstdata[vidx] +
4839 (*tile)(idx[0], idx[1], idx[2]));
4841 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
4849 is[SLICE] = tile_slice;
4852 is_local[SLICE] = local_slice;
4854 for (
int i =
range.begin(); i <
range.end(); i++)
4857 is[AXIS1] = i % a1_tiles;
4858 is[AXIS2] = i / a1_tiles;
4862 int a1_tile_res = tile->
getRes(AXIS1);
4863 int a2_tile_res = tile->
getRes(AXIS2);
4865 int vcounter = is[AXIS2] * tile_stride2 + is[AXIS1] * tile_stride1;
4867 for (is_local[AXIS2] = 0; is_local[AXIS2] < a2_tile_res;
4870 for (is_local[AXIS1] = 0; is_local[AXIS1] < a1_tile_res;
4873 set_functor(tile, is_local, vcounter);
4877 vcounter += a1_res - a1_tile_res;
4887 if (half_slice && !half_slice_st)
4889 half_slice_tb =
true;
4898 template <
typename T>
4899 template <
typename S>
4904 for (
int i = 0; i < tilelist.
entries(); i++)
4906 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
4909 tile->
flatten(dstdata, stride);
4915 template <
typename T>
4916 template <
typename S,
typename IDX>
4919 const IDX *ix,
const IDX *iy,
const IDX *iz,
4924 for (
auto && tiledata : tilelist)
4926 int tileidx = tiledata.tileidx;
4927 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
4932 if (tilevoxel == tiledata.numvoxel)
4935 tile->
flatten(dstdata, stride);
4936 dstdata += tiledata.numvoxel *
stride;
4937 srcidx += tiledata.numvoxel;
4942 int basex, basey, basez;
4943 linearTileToXYZ(tileidx, basex, basey, basez);
4955 for (
int i = 0; i < tiledata.numvoxel; i++)
4964 int w = tile->
xres();
4965 int h = tile->
yres();
4966 for (
int i = 0; i < tiledata.numvoxel; i++)
4968 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
4969 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
4970 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
4971 *dstdata = src[ (ix[srcidx] - basex)
4972 + (iy[srcidx] - basey) * w
4973 + (iz[srcidx] - basez) * w * h];
4981 for (
int i = 0; i < tiledata.numvoxel; i++)
4983 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
4984 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
4985 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
4986 *dstdata = (*tile)(ix[srcidx] - basex,
4988 iz[srcidx] - basez);
4998 template <
typename T>
4999 template <
typename S>
5004 bool docompress = getCompressionOptions().compressionEnabled();
5005 for (
int i = 0; i < tilelist.
entries(); i++)
5007 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5018 template <
typename T>
5019 template <
typename S,
typename IDX>
5022 const IDX *ix,
const IDX *iy,
const IDX *iz,
5025 bool docompress = getCompressionOptions().compressionEnabled();
5028 for (
auto && tiledata : tilelist)
5030 int tileidx = tiledata.tileidx;
5031 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5036 if (tilevoxel == tiledata.numvoxel)
5039 srcdata += tiledata.numvoxel *
stride;
5040 srcidx += tiledata.numvoxel;
5045 int basex, basey, basez;
5046 linearTileToXYZ(tileidx, basex, basey, basez);
5052 for (
int i = 0; i < tiledata.numvoxel; i++)
5054 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5055 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5056 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5110 template <
typename T>
5113 int xoff,
int yoff,
int zoff)
5221 template <
typename T>
5224 int tileoffy,
int tileoffz)
5234 for (
int i = range.begin(); i < range.end(); i++)
5249 && tile->
zres() == srctile->
zres())
5254 UTswap(tile->myCompressionType, srctile->myCompressionType);
5255 UTswap(tile->myForeignData, srctile->myForeignData);
5260 int offv[] = {(xyz[0] + tileoffx) * TILESIZE,
5261 (xyz[1] + tileoffy) * TILESIZE,
5262 (xyz[2] + tileoffz) * TILESIZE};
5263 for (
int z = 0; z < tile->
zres(); z++)
5265 for (
int y = 0; y < tile->
yres(); y++)
5267 for (
int x = 0; x < tile->
xres(); x++)
5285 const int off[] = {tileoffx, tileoffy, tileoffz};
5294 for (
int i = range.begin(); i < range.end(); i++)
5302 bool outside =
false;
5303 for (
int j = 0;
j < 3;
j++)
5306 outside = outside || (xyz[
j] < 0 || xyz[
j] >= src_tileres[
j]);
5311 if (outside && const_src_border)
5318 int offv[] = {xyz[0] * TILESIZE, xyz[1] * TILESIZE, xyz[2] * TILESIZE};
5319 for (
int z = 0; z < tile->
zres(); z++)
5321 for (
int y = 0; y < tile->
yres(); y++)
5323 for (
int x = 0; x < tile->
xres(); x++)
5337 template <
typename T>
5340 int offx,
int offy,
int offz)
5365 copyWithOffsetInternal(src, offx, offy, offz);
5368 template <
typename T>
5371 int offx,
int offy,
int offz,
5376 bool can_copy_tiles = ((offx & TILEMASK) == 0) && ((offy & TILEMASK) == 0)
5377 && ((offz & TILEMASK) == 0);
5401 for (
int i = 0; i < 3; i++)
5403 srctileidx(i) = vit.
myTilePos[i] + (off(i) >> TILEBITS);
5404 inside = inside && srctileidx(i) >= 0
5411 srctile = src.
getTile(srctileidx.
x(), srctileidx.
y(), srctileidx.
z());
5413 && tile->
zres() == srctile->
zres())
5423 srctileidx.
x() >>= TILEBITS;
5424 srctileidx.
y() >>= TILEBITS;
5425 srctileidx.
z() >>= TILEBITS;
5426 srctileoff.
x() = off.x() & TILEMASK;
5427 srctileoff.
y() = off.y() & TILEMASK;
5428 srctileoff.
z() = off.z() & TILEMASK;
5433 srcend.
x() += tile->
xres() - 1;
5434 srcend.
y() += tile->
yres() - 1;
5435 srcend.
z() += tile->
zres() - 1;
5437 srcendtile = srcend;
5438 srcendtile.
x() >>= TILEBITS;
5439 srcendtile.
y() >>= TILEBITS;
5440 srcendtile.
z() >>= TILEBITS;
5443 srcendtile.
x() == srctileidx.
x()+1);
5445 srcendtile.
y() == srctileidx.
y()+1);
5447 srcendtile.
z() == srctileidx.
z()+1);
5450 if (srctileidx.
x() >= 0 &&
5451 srctileidx.
y() >= 0 &&
5452 srctileidx.
z() >= 0 &&
5460 bool allconst =
true, firsttile =
true;
5463 for (tz = srctileidx.
z(); allconst && tz <= srcendtile.
z(); tz++)
5464 for (ty = srctileidx.
y(); allconst && ty <= srcendtile.
y(); ty++)
5465 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5467 srctile = src.
getTile(tx, ty, tz);
5473 cval = (*srctile)(0, 0, 0);
5498 for (tz = srctileidx.
z(); tz <= srcendtile.
z(); tz++)
5499 for (ty = srctileidx.
y(); ty <= srcendtile.
y(); ty++)
5500 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5502 int destx, desty, destz;
5503 int srcx, srcy, srcz;
5505 destx = (tx == srctileidx.
x()) ? 0 : (TILESIZE-srctileoff.
x());
5506 desty = (ty == srctileidx.
y()) ? 0 : (TILESIZE-srctileoff.
y());
5507 destz = (tz == srctileidx.
z()) ? 0 : (TILESIZE-srctileoff.
z());
5508 srcx = (tx == srctileidx.
x()) ? srctileoff.
x() : 0;
5509 srcy = (ty == srctileidx.
y()) ? srctileoff.
y() : 0;
5510 srcz = (tz == srctileidx.
z()) ? srctileoff.
z() : 0;
5526 srctile = src.
getTile(tx, ty, tz);
5529 destx, desty, destz,
5544 for (
int z = destz; z < maxd; z++)
5546 for (
int y = desty; y < maxh; y++)
5548 for (
int x = destx; x < maxw; x++)
5554 z + vit.
z() + offz);
5564 template <
typename T>
5581 ratio.
x() = 1.0f / getXRes();
5582 ratio.
y() = 1.0f / getYRes();
5583 ratio.
z() = 1.0f / getZRes();
5587 pos.
x() = vit.
x()+0.5f;
5588 pos.
y() = vit.
y()+0.5f;
5589 pos.
z() = vit.
z()+0.5f;
5596 template <
typename T>
5602 pos.
x() *= myRes[0];
5603 pos.
y() *= myRes[1];
5604 pos.
z() *= myRes[2];
5614 return isValidIndex(x, y, z);
5617 template <
typename T>
5623 pos.
x() *= myRes[0];
5624 pos.
y() *= myRes[1];
5625 pos.
z() *= myRes[2];
5636 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5637 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5638 pos.
z() < 0 || pos.
z() >= myRes[2])
5644 template <
typename T>
5650 pos.
x() *= myRes[0];
5651 pos.
y() *= myRes[1];
5652 pos.
z() *= myRes[2];
5662 return isValidIndex(x, y, z);
5665 template <
typename T>
5671 pos.
x() *= myRes[0];
5672 pos.
y() *= myRes[1];
5673 pos.
z() *= myRes[2];
5684 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5685 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5686 pos.
z() < 0 || pos.
z() >= myRes[2])
5692 template <
typename T>
5709 return isValidIndex(x, y, z);
5712 template <
typename T>
5729 return isValidIndex(x, y, z);
5732 template <
typename T>
5747 template <
typename T>
5762 template <
typename T>
5766 myBorderType =
type;
5770 template <
typename T>
5774 myBorderScale[0] = sx;
5775 myBorderScale[1] = sy;
5776 myBorderScale[2] = sz;
5779 template <
typename T>
5788 myTiles[i].tryCompress(getCompressionOptions());
5792 template <
typename T>
5801 myTiles[i].uncompress();
5805 template <
typename T>
5814 if (!myTiles[i].isConstant())
5815 myTiles[i].uncompress();
5819 template <
typename T>
5827 if (isConstant(&cval))
5831 UTwrite(os, &version, 1);
5832 UTwrite<T>(os, &cval);
5838 UTwrite(os, &version, 1);
5845 ntiles = numTiles();
5846 for (i = 0; i < ntiles; i++)
5848 myTiles[i].save(os);
5853 template <
typename T>
5881 ntiles = numTiles();
5882 for (i = 0; i < ntiles; i++)
5884 myTiles[i].load(is, compressions);
5889 template <
typename T>
5900 if (isConstant(&cval))
5906 if constexpr (tuple_size == 1)
5914 if (shared_mem_owner)
5917 shm = copyToSharedMemory(shared_mem_owner);
5952 ntiles = numTiles();
5953 for (i = 0; i < ntiles; i++)
5955 ok = ok && myTiles[i].save(w);
5965 template <
typename T>
5975 bool array_error =
false;
5977 delete mySharedMemView;
5978 mySharedMemView = 0;
5991 if constexpr (tuple_size == 1)
6010 if (!populateFromSharedMemory(shm_id.
buffer()))
6045 ntiles = numTiles();
6051 if (!myTiles[i].load(p, compressions))
6057 dummy_tile.
setRes(TILESIZE, TILESIZE, TILESIZE);
6058 if (!dummy_tile.
load(p, compressions))
6066 p.
addWarning(
"Unexpected key for voxel data: %s",
6086 template<
typename T>
6094 ntiles = numTiles();
6097 exint total_mem_size;
6099 total_mem_size =
sizeof(
exint);
6104 for (
int i = 0; i < ntiles; i++)
6106 exint tile_size, block_size;
6107 if (myTiles[i].isConstant())
6108 tile_size =
sizeof(T);
6110 tile_size = myTiles[i].getDataLength();
6112 tile_sizes.
append(tile_size);
6114 block_size = SYSroundUpToMultipleOf<exint>(tile_size,
sizeof(
exint));
6115 block_size +=
sizeof(
exint) * 2;
6118 next_block_offsets.
append(block_size /
sizeof(
exint));
6120 next_block_offsets.
append(0);
6122 total_mem_size += block_size;
6129 shared_mem_key.
sprintf(
"%s:%p", shared_mem_owner,
this);
6131 shared_mem = shmgr.
get(shared_mem_key.
buffer());
6137 bool same_meta_data =
false;
6138 if (shared_mem->
size() >=
sizeof(
exint))
6140 same_meta_data =
true;
6145 if (*ptr_ds != ntiles)
6146 same_meta_data =
false;
6153 for (
int i = 0; i < ntiles; i++)
6159 if (ptr_tile[0] != next_block_offsets(i) ||
6160 ptr_tile[1] != (
exint)myTiles[i].myCompressionType)
6162 same_meta_data =
false;
6165 offset += next_block_offsets(i) *
sizeof(
exint);
6170 if (!same_meta_data)
6172 if (!shared_mem->
reset(total_mem_size) ||
6173 shared_mem->
size() != total_mem_size)
6187 for (
int i = 0; i < ntiles; i++)
6190 sizeof(
exint) * 2 + tile_sizes(i));
6195 ptr_tile[0] = next_block_offsets(i);
6196 ptr_tile[1] = myTiles[i].myCompressionType;
6198 ::memcpy(&ptr_tile[2], myTiles[i].rawData(), tile_sizes(i));
6200 offset += ptr_tile[0] *
sizeof(
exint);
6206 template<
typename T>
6211 if (!mySharedMem->size())
6221 ntiles = *(
const exint *)sv_tc.data();
6223 if (ntiles != numTiles())
6232 exint *data = (
exint *)mySharedMemView->data();
6234 for (
int i = 0; i < ntiles; i++)
6236 exint offset = data[0];
6239 myTiles[i].setForeignData(&data[2], ctype);
6253 template <
typename T>
6256 initializePrivate();
6259 template <
typename T>
6265 template <
typename T>
6268 initializePrivate();
6273 template <
typename T>
6296 myLevels.append(levels);
6298 for (level = 0; level < myNumLevels; level++)
6307 template <
typename T>
6314 functions.
append(
function);
6315 build(baselevel, functions);
6318 template <
typename T>
6326 myBaseLevel = baselevel;
6334 maxres =
SYSmax(myBaseLevel->getXRes(), myBaseLevel->getYRes());
6335 maxres =
SYSmax(maxres, myBaseLevel->getZRes());
6349 for (
int i = 0; i < functions.
entries(); i++)
6354 myLevels.append(levels);
6357 for (level = myNumLevels-1; level >= 0; level--)
6360 int xres = (lastlevel->
getXRes() + 1) >> 1;
6361 int yres = (lastlevel->
getYRes() + 1) >> 1;
6362 int zres = (lastlevel->
getZRes() + 1) >> 1;
6367 downsample(*levels[level], *lastlevel,
function);
6369 lastlevel = levels[
level];
6374 template <
typename T>
6379 mipmaptype
function,
6403 mixValues(sam[0], sam[1],
function),
6404 mixValues(sam[2], sam[3],
function),
function),
6406 mixValues(sam[4], sam[5],
function),
6407 mixValues(sam[6], sam[7],
function),
function),
6414 template <
typename T>
6418 int64 mem = inclusive ?
sizeof(*this) : 0;
6420 mem += myLevels.getMemoryUsage(
false);
6422 for (
exint j = 0;
j < myLevels.entries();
j++)
6424 for (
int i = 0; i < myNumLevels; i++)
6425 mem += myLevels(
j)[i]->getMemoryUsage(
true);
6431 template <
typename T>
6435 doTraverse(0, 0, 0, 0,
function, data);
6438 template <
typename T>
6441 Callback
function,
void *data)
const
6448 if (level == myNumLevels)
6452 tval[0] = (*vox)(
x,
y,
z);
6453 for (
int i = 1; i < myLevels.entries(); i++)
6459 for (
int i = 0; i < myLevels.entries(); i++)
6461 vox = myLevels(i)[
level];
6462 tval[i] = (*vox)(
x,
y,
z);
6466 shift = myNumLevels -
level;
6471 SYSmin(y << shift, myBaseLevel->getYRes()),
6472 SYSmin(z << shift, myBaseLevel->getZRes()));
6474 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6475 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6477 if (!
function(tval, box, isfinal, data))
6494 bool xinc, yinc, zinc;
6497 if ( ((x+1) << shift) < myBaseLevel->getXRes() )
6501 if ( ((y+1) << shift) < myBaseLevel->getYRes() )
6505 if ( ((z+1) << shift) < myBaseLevel->getZRes() )
6515 doTraverse(x, y, z, level,
function, data);
6519 doTraverse(x, y+1, z, level,
function, data);
6521 doTraverse(x, y+1, z+1, level,
function, data);
6524 doTraverse(x, y, z+1, level,
function, data);
6529 doTraverse(x+1, y, z+1, level,
function, data);
6530 doTraverse(x+1, y, z, level,
function, data);
6533 doTraverse(x+1, y+1, z, level,
function, data);
6535 doTraverse(x+1, y+1, z+1, level,
function, data);
6540 template <
typename T>
6541 template <
typename OP>
6545 doTraverse(0, 0, 0, numLevels()-1, op);
6548 template <
typename T>
6549 template <
typename OP>
6561 SYSmin(y << shift, myBaseLevel->getYRes()),
6562 SYSmin(z << shift, myBaseLevel->getZRes()));
6564 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6565 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6567 if (!op(box, level))
6583 bool xinc, yinc, zinc;
6586 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6590 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6594 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6604 doTraverse(x, y, z, level, op);
6608 doTraverse(x, y+1, z, level, op);
6610 doTraverse(x, y+1, z+1, level, op);
6613 doTraverse(x, y, z+1, level, op);
6618 doTraverse(x+1, y, z+1, level, op);
6619 doTraverse(x+1, y, z, level, op);
6622 doTraverse(x+1, y+1, z, level, op);
6624 doTraverse(x+1, y+1, z+1, level, op);
6629 template <
typename T>
6630 template <
typename OP>
6634 doTraverseSorted(0, 0, 0, numLevels()-1, op);
6649 template <
typename T>
6650 template <
typename OP>
6658 SYSmin(y << level, myBaseLevel->getYRes()),
6659 SYSmin(z << level, myBaseLevel->getZRes()));
6664 if (!op(box, level))
6680 bool xinc, yinc, zinc;
6683 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6687 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6691 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6700 for (
int dz = 0; dz < 2; dz++)
6704 for (
int dy = 0; dy < 2; dy++)
6708 for (
int dx = 0; dx < 2; dx++)
6713 SYSmin((x+dx) << level, myBaseLevel->getXRes()),
6717 SYSmin((x+dx+1) << level, myBaseLevel->getXRes()),
6718 SYSmin((y+dy+1) <<
level, myBaseLevel->getYRes()),
6719 SYSmin((z+dz+1) <<
level, myBaseLevel->getZRes()));
6726 for (
int i = 0; i < numboxes; i++)
6728 sortstats[i].
value = op.sortValue(boxes[i], level);
6729 sortstats[i].
key = i;
6731 std::stable_sort(sortstats, &sortstats[numboxes]);
6733 for (
int i = 0; i < numboxes; i++)
6735 int whichbox = sortstats[i].
key;
6736 doTraverseSorted(boxes[whichbox](0,0)>>level, boxes[whichbox](1,0)>>level, boxes[whichbox](2,0)>>level, level, op);
6740 template <
typename T>
6749 template <
typename T>
6753 for (
exint i = 0; i < myLevels.entries(); i++)
6755 for (
exint level = 0; level < myNumLevels; level++)
6756 delete myLevels(i)[
level];
6757 delete [] myLevels(i);
6759 myLevels.entries(0);
6764 initializePrivate();
6770 template <
typename T>
6774 myHandle.resetHandle();
6776 myShouldCompressOnExit =
false;
6777 myUseTileList =
false;
6782 template <
typename T>
6785 myShouldCompressOnExit =
false;
6786 myUseTileList =
false;
6792 template <
typename T>
6795 myShouldCompressOnExit =
false;
6796 myUseTileList =
false;
6802 template <
typename T>
6807 template <
typename T>
6820 numtiles = myArray->numTiles();
6824 numtiles = myTileList.entries();
6835 if (idx < 0 || idx >= numranges)
6857 myTileEnd = (
int)
SYSfloor((idx+1) * tileperrange);
6861 if (idx == numranges-1)
6862 myTileEnd = numtiles;
6868 template <
typename T>
6884 template <
typename T>
6900 myArray->posToIndex(pmin, vmin);
6901 myArray->posToIndex(pmax, vmax);
6908 template <
typename T>
6914 int xres, yres, zres,
x,
y,
z;
6916 xres = myArray->getXRes();
6917 yres = myArray->getYRes();
6918 zres = myArray->getZRes();
6920 myTileList.entries(0);
6921 myUseTileList =
true;
6923 if (xmin < xres && xmax >= 0 &&
6924 ymin < yres && ymax >= 0 &&
6925 zmin < zres && zmax >= 0)
6928 myArray->clampIndex(xmin, ymin, zmin);
6929 myArray->clampIndex(xmax, ymax, zmax);
6940 if (myArray->numTiles() == (xmax-xmin+1)*(ymax-ymin+1)*(zmax-zmin+1))
6942 UT_ASSERT(xmin == 0 && ymin == 0 && zmin == 0);
6944 myUseTileList =
false;
6949 for (z = zmin; z <= zmax; z++)
6951 for (y = ymin; y <= ymax; y++)
6953 for (x = xmin; x <= xmax; x++)
6955 myTileList.append(myArray->xyzTileToLinear(x, y, z));
6964 setPartialRange(0, 1);
6968 template <
typename T>
6974 !myArray->getRes(0) || !myArray->getRes(1) || !myArray->getRes(2))
6983 myCurTileListIdx = myJobInfo->nextTask();
6985 myCurTileListIdx = myTileStart;
6986 if (myCurTileListIdx < 0 || myCurTileListIdx >= myTileEnd)
6991 myCurTile = myTileList(myCurTileListIdx);
6996 myCurTile = myJobInfo->nextTask();
6998 myCurTile = myTileStart;
7000 if (myCurTile < 0 || myCurTile >= myTileEnd)
7009 tile = myArray->getLinearTile(myCurTile);
7014 myArray->linearTileToXYZ(myCurTile,
7015 myTilePos[0], myTilePos[1], myTilePos[2]);
7016 myPos[0] = TILESIZE * myTilePos[0];
7017 myPos[1] = TILESIZE * myTilePos[1];
7018 myPos[2] = TILESIZE * myTilePos[2];
7030 myTileLocalPos[0] = 0;
7031 myTileLocalPos[1] = 0;
7032 myTileLocalPos[2] = 0;
7034 myTileSize[0] = tile->
xres();
7035 myTileSize[1] = tile->
yres();
7036 myTileSize[2] = tile->
zres();
7039 template <
typename T>
7043 if (myInterrupt && myInterrupt->opInterrupt())
7050 if (getCompressOnExit())
7053 if (myCurTile >= 0 && myCurTileListIdx < myTileEnd)
7055 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7061 myCurTileListIdx = myJobInfo->nextTask();
7064 if (myCurTileListIdx >= myTileEnd)
7070 myCurTile = myTileList(myCurTileListIdx);
7072 myArray->linearTileToXYZ(myCurTile,
7073 myTilePos[0], myTilePos[1], myTilePos[2]);
7077 tile = myArray->getLinearTile(myCurTile);
7078 myTileLocalPos[0] = 0;
7079 myTileLocalPos[1] = 0;
7080 myTileLocalPos[2] = 0;
7081 myTileSize[0] = tile->
xres();
7082 myTileSize[1] = tile->
yres();
7083 myTileSize[2] = tile->
zres();
7085 myPos[0] = TILESIZE * myTilePos[0];
7086 myPos[1] = TILESIZE * myTilePos[1];
7087 myPos[2] = TILESIZE * myTilePos[2];
7092 if (getCompressOnExit())
7095 if (myCurTile >= 0 && myCurTile < myTileEnd)
7097 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7103 myCurTile = myJobInfo->nextTask();
7104 if (myCurTile >= myTileEnd)
7109 myArray->linearTileToXYZ(myCurTile,
7110 myTilePos[0], myTilePos[1], myTilePos[2]);
7116 if (myTilePos[0] >= myArray->getTileRes(0))
7120 if (myTilePos[1] >= myArray->getTileRes(1))
7124 if (myTilePos[2] >= myArray->getTileRes(2))
7132 myCurTile = myArray->xyzTileToLinear(myTilePos[0], myTilePos[1], myTilePos[2]);
7140 if (myCurTile >= myTileEnd)
7146 tile = myArray->getLinearTile(myCurTile);
7147 myTileLocalPos[0] = 0;
7148 myTileLocalPos[1] = 0;
7149 myTileLocalPos[2] = 0;
7150 myTileSize[0] = tile->
xres();
7151 myTileSize[1] = tile->
yres();
7152 myTileSize[2] = tile->
zres();
7154 myPos[0] = TILESIZE * myTilePos[0];
7155 myPos[1] = TILESIZE * myTilePos[1];
7156 myPos[2] = TILESIZE * myTilePos[2];
7160 template <
typename T>
7164 myTileLocalPos[0] = myTileSize[0];
7165 myTileLocalPos[1] = myTileSize[1];
7166 myTileLocalPos[2] = myTileSize[2];
7169 template <
typename T>
7170 template <
typename OP>
7180 tile = myArray->getLinearTile(myCurTile);
7202 for (
int i = 0; i <
n; i++)
7204 val[i] = op(val[i], a);
7212 template <
typename T>
7213 template <
typename OP,
typename S>
7227 tile = myArray->getLinearTile(myCurTile);
7233 for (
int z = 0; z < tile->
zres(); z++)
7234 for (
int y = 0; y < tile->
yres(); y++)
7235 for (
int x = 0; x < tile->
xres(); x++)
7240 val = tile->operator()(
x,
y,
z);
7241 aval = atile->operator()(
x,
y,
z);
7243 val = op(val, aval);
7258 if (op.isNoop(aval))
7279 val = op(val, aval);
7301 for (
int i = 0; i <
n; i++)
7303 val[i] = op(val[i], *aval);
7313 template <
typename T>
7314 template <
typename OP>
7327 applyOperation(op, a);
7330 template<
int OPERANDS,
bool USE_SELF,
7331 typename T,
typename OP,
typename S,
typename R,
typename Q>
7333 conditionalCallOperator(
const OP& op,
const T& a0,
const S& a1,
const R& a2,
const Q& a3)
7337 if constexpr (OPERANDS == 0 && USE_SELF)
7339 else
if constexpr (OPERANDS == 1 && !USE_SELF)
7341 else
if constexpr (OPERANDS == 1 && USE_SELF)
7343 else
if constexpr (OPERANDS == 2 && !USE_SELF)
7345 else
if constexpr (OPERANDS == 2 && USE_SELF)
7346 val = op(a0, a1, a2);
7347 else
if constexpr (OPERANDS == 3 && !USE_SELF)
7348 val = op(a1, a2, a3);
7349 else
if constexpr (OPERANDS == 3 && USE_SELF)
7350 val = op(a0, a1, a2, a3);
7358 template<
int OPERANDS,
bool MASKED,
bool USE_SELF,
7359 typename T, typename OP, typename S, typename R, typename Q, typename M,
7362 assignOperationOnIterator(ITERATOR &it, const OP& op, const
UT_VoxelArray<S>* a,
7380 int tileNum = it.getLinearTileNum();
7381 UT_VoxelTile<M> *mtile = MASKED ? mask->getLinearTile(tileNum) :
nullptr;
7382 UT_VoxelTile<S> *atile = OPERANDS > 0 ? a->getLinearTile(tileNum) :
nullptr;
7383 UT_VoxelTile<R> *btile = OPERANDS > 1 ? b->getLinearTile(tileNum) :
nullptr;
7384 UT_VoxelTile<Q> *ctile = OPERANDS > 2 ? c->getLinearTile(tileNum) :
nullptr;
7388 if (MASKED && mtile->
isConstant() && ((*mtile)(0, 0, 0) <= ((M) 0.5)))
7403 for (
int z = 0; z < tile->
zres(); z++)
7405 for (
int y = 0; y < tile->
yres(); y++)
7407 for (
int x = 0; x < tile->
xres(); x++)
7409 if (!MASKED || ((*mtile)(x, y, z) > ((M) 0.5)))
7414 cval = (*ctile)(
x,
y,
z);
7417 bval = (*btile)(
x,
y,
z);
7420 aval = (*atile)(
x,
y,
z);
7426 if (USE_SELF) val = (*tile)(
x,
y,
z);
7428 val = conditionalCallOperator<OPERANDS, USE_SELF>(
7429 op,
val, aval, bval, cval);
7438 int ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7439 int binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7440 int cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7441 int minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7446 ainc == 0 && binc == 0 && cinc == 0 && minc == 0)
7467 if (USE_SELF) val = tile->
rawData()[0];
7468 val = conditionalCallOperator<OPERANDS, USE_SELF>(op,
7469 val, aval, bval, cval);
7479 ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7480 binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7481 cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7482 minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7484 const S* a_array = OPERANDS > 0 ? atile->
rawData() :
nullptr;
7485 const R* b_array = OPERANDS > 1 ? btile->
rawData() :
nullptr;
7486 const Q* c_array = OPERANDS > 2 ? ctile->
rawData() :
nullptr;
7487 const M* m_array = MASKED ? mtile->
rawData() :
nullptr;
7488 T* val_array = tile->
rawData();
7491 for (
int i = 0; i <
n; i++)
7493 if (!MASKED || (*m_array > ((M) 0.5)))
7495 val_array[i] = conditionalCallOperator<OPERANDS, USE_SELF>(op,
7496 val_array[i], OPERANDS > 0 ? *a_array : aval,
7497 OPERANDS > 1 ? *b_array : bval,
7498 OPERANDS > 2 ? *c_array : cval);
7526 template <
typename T>
7527 template <
typename OP>
7531 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
7532 (*
this, op,
nullptr,
nullptr,
nullptr,
nullptr);
7535 template <
typename T>
7536 template <
typename OP,
typename S>
7543 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
7544 (*
this, op, &
a,
nullptr,
nullptr,
nullptr);
7547 template <
typename T>
7548 template <
typename OP,
typename S,
typename R>
7557 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
7558 (*
this, op, &
a, &
b,
nullptr,
nullptr);
7561 template <
typename T>
7562 template <
typename OP,
typename S,
typename R,
typename Q>
7573 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
7574 (*
this, op, &
a, &
b, &
c,
nullptr);
7577 template <
typename T>
7578 template <
typename OP,
typename M>
7585 assignOperationOnIterator<0, true, true, T, OP, float, float, float, M>
7586 (*
this, op,
nullptr,
nullptr,
nullptr, &
mask);
7589 template <
typename T>
7590 template <
typename OP,
typename S,
typename M>
7599 assignOperationOnIterator<1, true, true, T, OP, S, float, float, M>
7600 (*
this, op, &
a,
nullptr,
nullptr, &
mask);
7603 template <
typename T>
7604 template <
typename OP,
typename S,
typename R,
typename M>
7615 assignOperationOnIterator<2, true, true, T, OP, S, R, float, M>
7616 (*
this, op, &
a, &
b,
nullptr, &
mask);
7619 template <
typename T>
7620 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7633 assignOperationOnIterator<3, true, true, T, OP, S, R, Q, M>
7634 (*
this, op, &
a, &
b, &
c, &
mask);
7637 template <
typename T>
7638 template <
typename OP,
typename S>
7645 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
7646 (*
this, op, &
a,
nullptr,
nullptr,
nullptr);
7649 template <
typename T>
7650 template <
typename OP,
typename S,
typename R>
7659 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
7660 (*
this, op, &
a, &
b,
nullptr,
nullptr);
7663 template <
typename T>
7664 template <
typename OP,
typename S,
typename R,
typename Q>
7675 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
7676 (*
this, op, &
a, &
b, &
c,
nullptr);
7679 template <
typename T>
7680 template <
typename OP,
typename S,
typename M>
7689 assignOperationOnIterator<1, true, false, T, OP, S, float, float, M>
7690 (*
this, op, &
a,
nullptr,
nullptr, &
mask);
7693 template <
typename T>
7694 template <
typename OP,
typename S,
typename R,
typename M>
7705 assignOperationOnIterator<2, true, false, T, OP, S, R, float, M>
7706 (*
this, op, &
a, &
b,
nullptr, &
mask);
7709 template <
typename T>
7710 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7723 assignOperationOnIterator<3, true, false, T, OP, S, R, Q, M>
7724 (*
this, op, &
a, &
b, &
c, &
mask);
7727 template <
typename T>
7728 template <
typename OP>
7738 tile = myArray->getLinearTile(myCurTile);
7743 for (
int z = 0; z < tile->
zres(); z++)
7744 for (
int y = 0; y < tile->
yres(); y++)
7745 for (
int x = 0; x < tile->
xres(); x++)
7749 val = tile->operator()(
x,
y,
z);
7762 op.reduceMany(val, n);
7771 for (
int i = 0; i <
n; i++)
7784 template <
typename T>
7788 myLinearTileNum = -1;
7791 myShouldCompressOnExit =
false;
7794 template <
typename T>
7798 myLinearTileNum = -1;
7801 myShouldCompressOnExit =
false;
7805 template <
typename T>
7806 template <
typename S>
7810 myLinearTileNum = -1;
7813 myShouldCompressOnExit =
false;
7814 setTile(vit, array);
7817 template <
typename T>
7822 template <
typename T>
7828 !myCurTile->xres() || !myCurTile->yres() || !myCurTile->zres())
7834 myPos[0] = myTileStart[0];
7835 myPos[1] = myTileStart[1];
7836 myPos[2] = myTileStart[2];
7838 myTileLocalPos[0] = 0;
7839 myTileLocalPos[1] = 0;
7840 myTileLocalPos[2] = 0;
7842 myTileSize[0] = myCurTile->xres();
7843 myTileSize[1] = myCurTile->yres();
7844 myTileSize[2] = myCurTile->zres();
7849 template <
typename T>
7853 if (getCompressOnExit())
7858 myCurTile->tryCompress(myArray->getCompressionOptions());
7864 template <
typename T>
7865 template <
typename OP>
7869 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
7870 (*
this, op,
nullptr,
nullptr,
nullptr,
nullptr);
7873 template <
typename T>
7874 template <
typename OP,
typename S>
7881 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
7882 (*
this, op, &
a,
nullptr,
nullptr,
nullptr);
7885 template <
typename T>
7886 template <
typename OP,
typename S,
typename R>
7895 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
7896 (*
this, op, &
a, &
b,
nullptr,
nullptr);
7899 template <
typename T>
7900 template <
typename OP,
typename S,
typename R,
typename Q>
7911 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
7912 (*
this, op, &
a, &
b, &
c,
nullptr);
7915 template <
typename T>
7916 template <
typename OP,
typename S>
7923 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
7924 (*
this, op, &
a,
nullptr,
nullptr,
nullptr);
7927 template <
typename T>
7928 template <
typename OP,
typename S,
typename R>
7937 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
7938 (*
this, op, &
a, &
b,
nullptr,
nullptr);
7941 template <
typename T>
7942 template <
typename OP,
typename S,
typename R,
typename Q>
7953 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
7954 (*
this, op, &
a, &
b, &
c,
nullptr);
7957 template <
typename T>
7958 template <
typename OP>
7964 if (!myCurTile->isSimpleCompression())
7967 for (
int z = 0; z < myTileSize[2]; z++)
7968 for (
int y = 0; y < myTileSize[1]; y++)
7969 for (
int x = 0; x < myTileSize[0]; x++)
7973 val = myCurTile->operator()(
x,
y,
z);
7975 if (!op.reduce(val))
7979 else if (myCurTile->isConstant())
7984 val = myCurTile->rawData()[0];
7985 int n = myCurTile->numVoxels();
7987 if (!op.reduceMany(val, n))
7994 val = myCurTile->rawData();
7996 int n = myCurTile->numVoxels();
7997 for (
int i = 0; i <
n; i++)
7999 if (!op.reduce(val[i]))
8010 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8020 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8031 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8036 if (!TestForWrites ||
myDirty)
8045 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8050 if (!DoRead && (prex != 0 || postx != 0))
8052 UT_ASSERT(!
"Voxel probe cannot be padded if set to not read.");
8058 int prepad, postpad;
8062 prepad = (prex - 3) / 4;
8063 postpad = (postx + 3) / 4;
8080 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8109 if (!TestForWrites ||
myDirty)
8122 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8127 bool xout =
false, yout =
false, zout =
false;
8128 bool manualbuild =
false;
8144 if (myMaxValidX <= 0 || myMinValidX >=
myArray->getXRes())
8190 myArray->clampIndex(tx, y, z);
8207 if (xout || manualbuild)
8234 for (i =
myPreX; i < 0; i++)
8244 for (; i < TILESIZE; i++)
8252 for (; i < TILESIZE; i++)
8258 for (; i < TILESIZE +
myPostX; i++)
8271 int xtile, ytile, ztile, tileidx;
8275 xtile = x >> TILEBITS;
8276 ytile = y >> TILEBITS;
8277 ztile = z >> TILEBITS;
8284 tileidx = (ztile *
myArray->getTileRes(1) + ytile) *
myArray->getTileRes(0);
8291 tile =
myArray->getLinearTile(tileidx+xtile-1);
8292 for (i =
myPreX; i < 0; i++)
8303 int resx =
myArray->getXRes();
8312 for (i =
myPreX; i < 0; i++)
8322 int resx =
myArray->getXRes();
8323 int resx2 = resx * 2;
8326 int xpos =
myPreX % resx2;
8338 xpos = resx2 - xpos - 1;
8341 for (i =
myPreX; i < 0; i++)
8354 else if (xpos >= resx)
8367 tile =
myArray->getLinearTile(tileidx+xtile);
8368 value = (*tile)(0, ly, lz);
8371 value =
myArray->getBorderValue();
8374 for (i =
myPreX; i < 0; i++)
8382 int cachelen = TILESIZE;
8383 int resx =
myArray->getXRes();
8400 tile =
myArray->getLinearTile(tileidx+xtile+1);
8401 for (; i <
myPostX && xpos < resx; i++)
8442 else if (xpos >= resx)
8455 tile =
myArray->getLinearTile(tileidx+xtile);
8456 value = (*tile)(tile->
xres()-1, ly, lz);
8459 value =
myArray->getBorderValue();
8469 tile =
myArray->getLinearTile(tileidx+xtile+1);
8480 tile =
myArray->getLinearTile(tileidx+xtile);
8494 for (i = topad; i > 0; i--)
8509 value =
myArray->getBorderValue();
8511 for (i = topad; i > 0; i--)
8519 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8547 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8570 int xtile, ytile, ztile,
y,
z;
8573 xtile = myMinValidX >> TILEBITS;
8574 ytile =
myY >> TILEBITS;
8575 ztile =
myZ >> TILEBITS;
8579 tile =
myArray->getTile(xtile, ytile, ztile);
8588 template <
typename T>
8594 template <
typename T>
8599 template <
typename T>
8604 myLines[0][0].setConstArray(vox, -1, 1);
8605 myLines[0][1].setConstArray(vox, -1, 1);
8606 myLines[0][2].setConstArray(vox, -1, 1);
8608 myLines[1][0].setConstArray(vox, -1, 1);
8609 myLines[1][1].setConstArray(vox, -1, 1);
8610 myLines[1][2].setConstArray(vox, -1, 1);
8612 myLines[2][0].setConstArray(vox, -1, 1);
8613 myLines[2][1].setConstArray(vox, -1, 1);
8614 myLines[2][2].setConstArray(vox, -1, 1);
8619 template <
typename T>
8626 myLines[0][1].setConstArray(vox, -1, 1);
8628 myLines[1][0].setConstArray(vox, 0, 0);
8629 myLines[1][1].setConstArray(vox, -1, 1);
8630 myLines[1][2].setConstArray(vox, 0, 0);
8632 myLines[2][1].setConstArray(vox, -1, 1);
8637 template <
typename T>
8641 if (myValid && myZ == z)
8646 if (x < myMaxValidX && x == myX+1)
8649 myLines[0][0].advanceX();
8650 myLines[0][1].advanceX();
8651 myLines[0][2].advanceX();
8653 myLines[1][0].advanceX();
8654 myLines[1][1].advanceX();
8655 myLines[1][2].advanceX();
8657 myLines[2][0].advanceX();
8658 myLines[2][1].advanceX();
8659 myLines[2][2].advanceX();
8674 rotateLines(myLines[0][0], myLines[1][0], myLines[2][0]);
8675 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
8676 rotateLines(myLines[0][2], myLines[1][2], myLines[2][2]);
8680 myLines[0][0].resetX(x);
8681 myLines[0][1].resetX(x);
8682 myLines[0][2].resetX(x);
8684 myLines[1][0].resetX(x);
8685 myLines[1][1].resetX(x);
8686 myLines[1][2].resetX(x);
8689 myLines[2][0].setIndex(x, y+1, z-1);
8690 myLines[2][1].setIndex(x, y+1, z);
8691 myLines[2][2].setIndex(x, y+1, z+1);
8703 myLines[0][0].setIndex(x, y-1, z-1);
8704 myLines[0][1].setIndex(x, y-1, z);
8705 myLines[0][2].setIndex(x, y-1, z+1);
8707 myLines[1][0].setIndex(x, y, z-1);
8708 myLines[1][1].setIndex(x, y, z);
8709 myLines[1][2].setIndex(x, y, z+1);
8711 myLines[2][0].setIndex(x, y+1, z-1);
8712 myLines[2][1].setIndex(x, y+1, z);
8713 myLines[2][2].setIndex(x, y+1, z+1);
8720 myMinValidX = myLines[1][1].myMinValidX;
8721 myMaxValidX = myLines[1][1].myMaxValidX;
8726 template <
typename T>
8730 if (myValid && myZ == z)
8735 if (x < myMaxValidX && x == myX+1)
8738 myLines[0][1].advanceX();
8740 myLines[1][0].advanceX();
8741 myLines[1][1].advanceX();
8742 myLines[1][2].advanceX();
8744 myLines[2][1].advanceX();
8758 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
8760 myLines[0][1].resetX(x);
8761 myLines[1][1].resetX(x);
8763 myLines[1][0].setIndex(x, y, z-1);
8764 myLines[1][2].setIndex(x, y, z+1);
8766 myLines[2][1].setIndex(x, y+1, z);
8775 myLines[0][1].setIndex(x, y-1, z);
8777 myLines[1][0].setIndex(x, y, z-1);
8778 myLines[1][1].setIndex(x, y, z);
8779 myLines[1][2].setIndex(x, y, z+1);
8781 myLines[2][1].setIndex(x, y+1, z);
8788 myMinValidX = myLines[1][1].myMinValidX;
8789 myMaxValidX = myLines[1][1].myMaxValidX;
8794 template <
typename T>
8809 Px *= 0.5 * invvoxelsize.
x();
8812 Py *= 0.5 * invvoxelsize.
y();
8815 Pz *= 0.5 * invvoxelsize.
z();
8823 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
8828 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
8833 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
8838 Pxy *= 0.25 * invvoxelsize.
x() * invvoxelsize.
y();
8842 Pxz *= 0.25 * invvoxelsize.
x() * invvoxelsize.
z();
8846 Pyz *= 0.25 * invvoxelsize.
y() * invvoxelsize.
z();
8849 gradlen = SYSsqrt(Px * Px + Py * Py + Pz * Pz);
8857 k = Px*Px * (Pyy + Pzz) + Py*Py * (Pxx + Pzz) + Pz*Pz * (Pxx + Pyy);
8858 k -= 2 * (Pxy*Px*Py + Pyz*Py*Pz + Pxz*Px*Pz);
8864 k /= gradlen * gradlen * gradlen;
8878 template <
typename T>
8891 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
8896 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
8901 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
8903 return Pxx + Pyy + Pzz;
8906 template <
typename T>
8912 T *tmpcache, *tmpalloc;
8941 template <
typename T>
8947 template <
typename T>
8953 template <
typename T>
8958 myLines[0][0].setConstArray(vx, 0, 1);
8961 myLines[1][0].setConstArray(vy, 0, 0);
8962 myLines[1][1].setConstArray(vy, 0, 0);
8964 myLines[2][0].setConstArray(vz, 0, 0);
8965 myLines[2][1].setConstArray(vz, 0, 0);
8970 template <
typename T>
8976 myInvVoxelSize /= myVoxelSize;
8979 template <
typename T>
8983 if (myValid && myZ == z)
8988 if (x < myMaxValidX && x == myX+1)
8991 myLines[0][0].advanceX();
8993 myLines[1][0].advanceX();
8994 myLines[1][1].advanceX();
8996 myLines[2][0].advanceX();
8997 myLines[2][1].advanceX();
9010 swapLines(myLines[1][0], myLines[1][1]);
9012 myLines[1][0].resetX(x);
9015 myLines[0][0].setIndex(x, y, z);
9016 myLines[1][1].setIndex(x, y+1, z);
9018 myLines[2][0].setIndex(x, y, z);
9019 myLines[2][1].setIndex(x, y, z+1);
9028 myLines[0][0].setIndex(x, y, z);
9030 myLines[1][0].setIndex(x, y, z);
9031 myLines[1][1].setIndex(x, y+1, z);
9033 myLines[2][0].setIndex(x, y, z);
9034 myLines[2][1].setIndex(x, y, z+1);
9041 myMinValidX = myLines[0][0].myMinValidX;
9042 myMaxValidX = myLines[0][0].myMaxValidX;
9047 template <
typename T>
9052 T *tmpcache, *tmpalloc;
9075 template <
typename T,
int XStep,
int YStep,
int ZStep>
9079 int prex = (XStep < 0) ? XStep : 0;
9080 int postx = (XStep > 0) ? XStep : 0;
9095 template <
typename T,
int XStep,
int YStep,
int ZStep>
9110 result |= myLines[0][0].setIndex(x, y, z);
9113 result |= myLines[1][0].setIndex(x, y+1, z);
9115 result |= myLines[1][1].setIndex(x, y+1, z+1);
9118 result |= myLines[0][1].setIndex(x, y, z+1);
bool uniformWrite(bool value)
bool readBinaryString(UT_String &str, UT_ISTREAM_RLE_IO startbits)
int x() const
Retrieve the current location of the iterator.
void applyOperation(const OP &op)
bool jsonValue(bool value)
bool beginUniformArray(int64 length, UT_JID id)
void findexToPos(UT_Vector3F ipos, UT_Vector3F &pos) const
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GA_API const UT_StringHolder dist
SYS_FORCE_INLINE T lerpSample(T *samples, float fx, float fy, float fz) const
Lerps the given sample using trilinear interpolation.
void UTparallelFor(const Range &range, const Body &body, const int subscribe_ratio=2, const int min_grain_size=1, const bool force_use_task_scope=true)
const UT_VoxelTile< T > & operator=(const UT_VoxelTile< T > &src)
void setArray(UT_VoxelArray< T > *vox, int prex=0, int postx=0)
UT_VoxelTile< T > * getTile() const
Returns the VoxelTile we are currently processing.
void findAverage(T &avg) const
Determines the average value of the tile.
bool parseString(UT_WorkBuffer &v)
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
void splitByTile(const UT_JobInfo &info)
exint getDataLength() const
Returns the amount of data used by the tile myData pointer.
UT_FromUnbounded creates a V from an unbounded array-like type.
bool atEnd() const
Returns true if we have iterated over all of the voxels.
void match(const UT_VoxelArray< T > &src)
static UT_JID jidFromValue(const bool *)
Returns the JID that matches the given type.
virtual const char * getName()=0
void restrictToBBox(const UT_BoundingBox &bbox)
void traverseTopDownSorted(OP &op) 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.
int64 getMemoryUsage(bool inclusive) const
Return the amount of memory used by this array.
constexpr SYS_FORCE_INLINE T & y() noexcept
void UTparallelForEachNumber(IntType nitems, const Body &body, const bool force_use_task_scope=true)
T operator()(UT_Vector3D pos) const
GLsizei const GLfloat * value
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);
#define UT_VOXEL_ALLOC(x)
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
GLdouble GLdouble GLdouble z
exint size() const
Returns the size of the shared memory, in bytes.
void traverseTopDown(Callback function, void *data) const
void reloadCache(int x, int y, int z)
UT_VoxelArray< T > * myBaseLevel
constexpr SYS_FORCE_INLINE T & z() noexcept
UT_Vector3T< T > maxvec() const
constexpr bool SYSisNan(const F f)
SYS_FORCE_INLINE const char * buffer() const
void setValue(T t) const
Sets the voxel we are currently pointing to the given value.
GLboolean GLboolean GLboolean GLboolean a
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)
void setConstPlusArray(const UT_VoxelArray< T > *vox)
UT_VoxelArray< T > * myArray
void setArray(UT_VoxelArray< T > *vox)
Class which writes ASCII or binary JSON streams.
int myTilePos[3]
Which tile we are as per tx,ty,tz rather than linear index.
void UTparallelForLightItems(const Range &range, const Body &body, const bool force_use_task_scope=true)
void UTserialForEachNumber(IntType nitems, const Body &body, bool usetaskscope=true)
void copyWithOffset(const UT_VoxelArray< T > &src, int offx, int offy, int offz)
**But if you need a result
__hostdev__ void setValue(uint32_t offset, bool v)
bool isConstant(T *cval=0) const
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
void toLinearBP(int k, int &x, int &y, int &z) const
UT_Matrix2T< T > SYSlerp(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2, S t)
bool setIndex(UT_VoxelArrayIterator< S > &vit)
void setArray(const UT_VoxelArray< T > *vox)
int myMinValidX
Half inclusive [,) range of valid x queries for current cache.
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.
const float * getWeights() const
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
bool jsonString(const char *value, int64 length=0)
__hostdev__ float getValue(uint32_t i) const
virtual bool writeThrough(UT_VoxelTile< T > &tile, int x, int y, int z, T t) const =0
static int getArrayID(const char *symbol)
void rewind()
Resets the iterator to point to the first voxel.
SYS_FORCE_INLINE bool extractSample(int x, int y, int z, T *sample) 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)
void setConstCubeArray(const UT_VoxelArray< T > *vox)
void moveTilesWithOffset(UT_VoxelArray< T > &src, int tileoffx, int tileoffy, int tileoffz)
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
void setPartialRange(int idx, int numranges)
const UT_VoxelMipMap< T > & operator=(const UT_VoxelMipMap< T > &src)
Assignment operator:
__linearTileIndexConverter(const UT_VoxelArray< T > *dst, const UT_VoxelArray< T > *src, int xoff, int yoff, int zoff)
const S * writeTiles(const S *srcdata, int srcstride, const UT_IntArray &tilelist)
bool hasNan() const
Returns true if any NANs are in this tile.
static const char * getToken(ArrayTokenID id)
SYS_FORCE_INLINE bool extractSampleAxis(int x, int y, int z, T *sample) const
void setVoxelSize(const UT_Vector3 &voxelsize)
static UT_Filter * getFilter(UT_FilterType type)
fpreal64 laplacian(const UT_Vector3 &invvoxelsize) const
static void rotateLines(UT_VoxelProbe< T, true, false, false > &ym, UT_VoxelProbe< T, true, false, false > &y0, UT_VoxelProbe< T, true, false, false > &yp)
virtual void load(UT_IStream &is, UT_VoxelTile< T > &tile) const
void rewind()
Resets the iterator to point to the first voxel.
int64 getMemoryUsage(bool inclusive) const
Returns the amount of memory used by this tile.
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
int getLinearTileNum() const
constexpr SYS_FORCE_INLINE T & z() noexcept
void build(UT_VoxelArray< T > *baselevel, mipmaptype function)
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.
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
static int mirrorCoordinates(int x, int res)
UT_API void UTsaveStringBinary(std::ostream &os, const char *str, UT_STRING_BINARY_IO minbits)
bool reset(exint size, const char *id=nullptr)
int getNTilesBP() const
Returns the number of tiles in each part.
exint read(bool *array, exint sz=1)
virtual void save(std::ostream &os, const UT_VoxelTile< T > &tile) const
static UT_SharedMemoryManager & get()
fpreal16 UTvoxelConvertFP16(fpreal16 a)
const UT_VoxelArray< T > & operator=(const UT_VoxelArray< T > &src)
Assignment operator:
void setArray(const UT_VoxelArray< T > *vx, const UT_VoxelArray< T > *vy, const UT_VoxelArray< T > *vz)
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Traverse an array object in the parser.
bool skipNextObject()
Simple convenience method to skip the next object in the stream.
GLint GLenum GLboolean GLsizei stride
void makeRawUninitialized()
UT_VoxelTile< T > * getTile(int tx, int ty, int tz) const
constexpr enabler dummy
An instance to use in EnableIf.
OIIO_FORCEINLINE OIIO_HOSTDEVICE float madd(float a, float b, float c)
Fused multiply and add: (a*b + c)
static void releaseFilter(UT_Filter *filter)
void setCompressOnExit(bool shouldcompress)
T evaluate(const UT_Vector3 &pos, const UT_Filter &filter, fpreal radius, int clampaxis=-1) const
SYS_NO_DISCARD_RESULT SYS_FORCE_INLINE bool extractSampleAxis(int x, int y, int z, T *sample) const
bool tryCompress(const UT_VoxelCompressOptions &options)
void void addWarning(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
bool jsonKey(const char *value, int64 length=0)
virtual bool canSave() const
Does this engine support saving and loading?
int getRes(int dim) const
void setRes(int xr, int yr, int zr)
SYS_API fpreal32 SYSfloor(fpreal32 val)
bool setIndex(UT_VoxelArrayIterator< S > &vit)
GLuint const GLchar * name
virtual bool isLossless() const
Returns true if the compression type is lossless.
bool jsonEndArray(bool newline=true)
GLboolean GLboolean GLboolean b
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
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.
static void _toRegularLinear(int k, int xdim, int ydim, int &x, int &y, int &z)
void setValue(int x, int y, int z, T t)
SYS_FORCE_INLINE T lerpVoxelCoordAxis(UT_Vector3F pos) const
virtual int getDataLength(const UT_VoxelTile< T > &tile) const =0
bool parseNumber(int8 &v)
Generic parsing of a number (int)
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
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.
void buildConstantCache(T value)
GT_API const UT_StringHolder version
SYS_FORCE_INLINE T lerpVoxelCoord(UT_Vector3F pos) const
bool setIndex(UT_VoxelArrayIterator< S > &vit)
exint entries() const
Alias of size(). size() is preferred.
void applyOperationCheckNoop(const OP &op, const UT_VoxelArray< S > &a)
int64 parseUniformArray(T *data, int64 len)
static UT_VoxelTileCompress< T > * getCompressionEngine(int index)
SYS_FORCE_INLINE int strcmp(const char *src) const
GLfloat GLfloat GLfloat GLfloat h
virtual void findMinMax(const UT_VoxelTile< T > &tile, T &min, T &max) const
void setLinearTile(exint lineartilenum, UT_VoxelArray< T > *array)
GLsizeiptr const void GLenum usage
bool hasNan() const
Returns true if any element of the voxel array is NAN.
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
void UTparallelInvoke(bool parallel, F1 &&f1, F2 &&f2)
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.
void reduceOperation(OP &op)
void maskedAssignOperation(const OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< M > &mask)
bool parseEndArray(bool &error)
UT_Vector3T< T > minvec() const
void toLinearIP(int k, int &x, int &y, int &z) const
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
void forEachTile(const OP &op, bool shouldthread=true)
#define UT_VERIFY_P(expr)
constexpr SYS_FORCE_INLINE T & w() noexcept
void saveData(std::ostream &os) const
UT_ValArray< UT_VoxelArray< T > ** > myLevels
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 jsonBeginArray()
Begin a generic array object.
SYS_FORCE_INLINE void initBounds()
int64 getMemoryUsage(bool inclusive) const
Return the amount of memory used by this mipmap.
bool parseBeginArray(bool &error)
static void swapLines(UT_VoxelProbe< T, true, false, false > &ym, UT_VoxelProbe< T, true, false, false > &yp)
void save(std::ostream &os) const
void maskedApplyOperation(const OP &op, const UT_VoxelArray< M > &mask)
SYS_FORCE_INLINE v4uf swizzle() const
static int getTileID(const char *symbol)
UT_VoxelTile< T > * getLinearTile(int idx) const
void load(UT_IStream &is, const UT_IntArray &compression)
static int lookupCompressionEngine(const char *name)
GLubyte GLubyte GLubyte GLubyte w
bool readChar(char &result)
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 jsonUniformArray(int64 length, const int8 *value)
Efficent method of writing a uniform array of int8 values.
void uncompressFull()
Turns a tile into a raw full tile.
bool endUniformArray(int64 *nwritten=0)
void setBorder(UT_VoxelBorderType type, T t)
SYS_FORCE_INLINE T operator()(int x, int y, int z) const
void assignOperation(const OP &op, const UT_VoxelArray< S > &a)
virtual bool tryCompress(UT_VoxelTile< T > &tile, const UT_VoxelCompressOptions &options, T min, T max) const =0
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.
void assignOperation(const OP &op, const UT_VoxelArray< S > &a)
constexpr SYS_FORCE_INLINE T & y() noexcept
bool SYSisEqual(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, S tol=SYS_FTOLERANCE)
Componentwise equality.
void findMinMax(T &min, T &max) const
Finds the minimum and maximum T values.
constexpr SYS_FORCE_INLINE T maxComponent() const noexcept
ImageBuf OIIO_API zero(ROI roi, int nthreads=0)
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)
int xres() const
Read the current resolution.
fpreal64 curvature(const UT_Vector3 &invvoxelsize) const
S * extractTiles(S *dstdata, int stride, const UT_IntArray &tilelist) const
bool getLowerKey(T &key)
Get a lower case map key (for case insensitive maps)
void writeData(const S *src, int srcstride)
bool isSimpleCompression() const
bool reduceOperation(OP &op)
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)
int getTileRes(int dim) const
SYS_API fpreal32 SYSceil(fpreal32 val)
void evaluateMinMax(T &lerp, T &lmin, T &lmax, UT_Vector3F pos) const
bool jsonInt(int32 value)
Write an integer value.
bool operator<(const ut_VoxelMipMapSortCompare &lhs, const ut_VoxelMipMapSortCompare &rhs)
void flattenPartialAxis(T *flatarray, exint ystride, const UT_JobInfo &info) const
void advance()
Advances the iterator to point to the next voxel.
void applyOperation(const OP &op)
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