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;
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>
2406 #define COUNT_NONZERO(VAL, COUNT) \
2407 if constexpr (SYS_IsSame_v<T, float>) \
2412 if constexpr (SYS_IsSame_v<T, UT_Vector2>) \
2414 if (!VAL.isZero()) \
2417 if constexpr (SYS_IsSame_v<T, UT_Vector3>) \
2419 if (!VAL.isZero()) \
2422 if constexpr (SYS_IsSame_v<T, UT_Vector4>) \
2424 if (!VAL.isZero()) \
2428 switch (myCompressionType)
2430 case COMPRESS_CONSTANT:
2432 result += rawConstVal();
2438 tstart[0] = pstart[0] & TILEMASK;
2439 tstart[1] = pstart[1] & TILEMASK;
2440 tstart[2] = pstart[2] & TILEMASK;
2441 ixstart = pstart[0]-start[0];
2442 ixend = pend[0]-start[0];
2447 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2451 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2453 px = ((pz * myRes[1]) + py) * myRes[0] + tstart[0];
2454 for (ix = ixstart; ix < ixend; ix++, px++)
2456 T val = ((
T*)myData)[px];
2462 result *= SYSsaferecip(
float(count));
2466 case COMPRESS_FPREAL16:
2471 int xinc = tuple_size;
2472 int yinc = myRes[0] * xinc;
2473 int zinc = myRes[1] * yinc;
2477 tstart[0] = pstart[0] & TILEMASK;
2478 tstart[1] = pstart[1] & TILEMASK;
2479 tstart[2] = pstart[2] & TILEMASK;
2480 ixstart = pstart[0]-start[0];
2481 ixend = pend[0]-start[0];
2486 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2490 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2492 px = pz * zinc + py * yinc + tstart[0] * xinc;
2493 for (ix = ixstart; ix < ixend; ix++, px += xinc)
2495 T val = convertFromFP16(src + px);
2501 result *= SYSsaferecip(
float(count));
2504 case COMPRESS_RAWFULL:
2506 tstart[0] = pstart[0] & TILEMASK;
2507 tstart[1] = pstart[1] & TILEMASK;
2508 tstart[2] = pstart[2] & TILEMASK;
2509 ixstart = pstart[0]-start[0];
2510 ixend = pend[0]-start[0];
2513 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2516 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2518 px = ((pz * TILESIZE) + py) * TILESIZE + tstart[0];
2519 for (ix = ixstart; ix < ixend; ix++, px++)
2521 T val = ((
T*)myData)[px];
2527 result *= SYSsaferecip(
float(count));
2536 tstart[0] = pstart[0] & TILEMASK;
2537 tstart[1] = pstart[1] & TILEMASK;
2538 tstart[2] = pstart[2] & TILEMASK;
2539 ixstart = pstart[0]-start[0];
2540 ixend = pend[0]-start[0];
2543 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2546 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2549 for (ix = ixstart; ix < ixend; ix++, px++)
2551 T val = (*this)(px,
py, pz);
2557 result *= SYSsaferecip(
float(count));
2563 template <
typename T>
2570 for (i = 0; i < getCompressionEngines().entries(); i++)
2572 if (!strcmp(engine->
getName(), getCompressionEngines()(i)->
getName()))
2574 getCompressionEngines()(i) = engine;
2579 getCompressionEngines().append(engine);
2582 template <
typename T>
2591 for (i = 0; i < getCompressionEngines().entries(); i++)
2593 if (!strcmp(name, getCompressionEngines()(i)->
getName()))
2595 return i + COMPRESS_ENGINE;
2602 template <
typename T>
2606 index -= COMPRESS_ENGINE;
2608 return getCompressionEngines()(
index);
2611 template <
typename T>
2616 if (myCompressionType >= COMPRESS_ENGINE)
2622 char type = myCompressionType;
2624 UTwrite(os, &type, 1);
2625 engine->
save(os, *
this);
2630 char type = COMPRESS_RAW;
2633 UTwrite(os, &type, 1);
2635 for (
int z = 0; z < zres(); z++)
2636 for (
int y = 0; y < yres(); y++)
2637 for (
int x = 0; x < xres(); x++)
2639 value = (*this)(
x,
y,
z);
2640 UTwrite<T>(os, &
value, 1);
2646 char type = myCompressionType;
2648 if (type == COMPRESS_RAWFULL &&
2649 myRes[0] == TILESIZE &&
2650 myRes[1] == TILESIZE &&
2651 myRes[2] != TILESIZE)
2655 type = COMPRESS_RAW;
2658 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2660 UTwrite(os, &type, 1);
2665 len = myRes[2] * myRes[1] * myRes[0];
2666 UTwrite<T>(os, (
T *) myData, len);
2669 case COMPRESS_FPREAL16:
2670 len = myRes[2] * myRes[1] * myRes[0]
2672 UTwrite(os, (
int16 *) myData, len);
2675 case COMPRESS_RAWFULL:
2676 len = TILESIZE * TILESIZE * TILESIZE;
2677 UTwrite<T>(os, (
T *) myData, len);
2680 case COMPRESS_CONSTANT:
2681 UTwrite<T>(os, rawConstData(), 1);
2684 case COMPRESS_ENGINE:
2690 template <
typename T>
2700 if (type >= 0 && type < compress.
entries())
2703 type = compress(type);
2706 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2710 if (type >= COMPRESS_ENGINE)
2713 myCompressionType =
type;
2715 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2718 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2724 engine->
load(is, *
this);
2737 myCompressionType =
type;
2742 len = myRes[2] * myRes[1] * myRes[0];
2744 is.
read<
T>((
T *) myData, len);
2747 case COMPRESS_FPREAL16:
2748 len = myRes[2] * myRes[1] * myRes[0]
2754 case COMPRESS_RAWFULL:
2755 len = TILESIZE * TILESIZE * TILESIZE;
2757 is.
read<
T>((
T *) myData, len);
2760 case COMPRESS_CONSTANT:
2761 if (!inlineConstant())
2763 is.
read<
T>(rawConstData(), 1);
2766 case COMPRESS_ENGINE:
2772 if (myCompressionType == COMPRESS_RAW &&
2773 myRes[0] == TILESIZE &&
2774 myRes[1] == TILESIZE)
2775 myCompressionType = COMPRESS_RAWFULL;
2778 template <
typename T>
2788 if (myCompressionType >= COMPRESS_ENGINE)
2794 char type = myCompressionType;
2802 ok = ok && engine->
save(w, *
this);
2808 char type = COMPRESS_RAW;
2821 for (
int z = 0; z < zres(); z++)
2822 for (
int y = 0; y < yres(); y++)
2823 for (
int x = 0; x < xres(); x++)
2825 value = (*this)(
x,
y,
z);
2826 if constexpr (tuple_size == 1)
2832 for (
int i = 0; i < tuple_size; i++)
2844 char type = myCompressionType;
2846 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2854 switch (myCompressionType)
2857 len = myRes[2] * myRes[1] * myRes[0];
2861 case COMPRESS_FPREAL16:
2866 case COMPRESS_RAWFULL:
2867 len = TILESIZE * TILESIZE * myRes[2];
2871 case COMPRESS_CONSTANT:
2872 if constexpr (tuple_size == 1)
2883 template <
typename T>
2913 if (type >= 0 && type < compress.
entries())
2916 type = compress(type);
2919 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2923 if (type >= COMPRESS_ENGINE)
2926 myCompressionType =
type;
2928 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2931 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2937 bool engine_ok = engine->
load(p, *
this);
2939 return it.
atEnd() && engine_ok;
2950 myCompressionType =
type;
2952 switch (myCompressionType)
2955 len = myRes[2] * myRes[1] * myRes[0];
2962 case COMPRESS_FPREAL16:
2969 case COMPRESS_RAWFULL:
2970 len = TILESIZE * TILESIZE * myRes[2];
2977 case COMPRESS_CONSTANT:
2978 if (!inlineConstant())
2980 if constexpr (tuple_size == 1)
2997 template <
typename T>
3001 int16 ntype = getCompressionEngines().entries();
3004 ntype += COMPRESS_ENGINE;
3006 UTwrite(os, &ntype);
3014 ntype -= COMPRESS_ENGINE;
3015 for (i = 0; i < ntype; i++)
3021 template <
typename T>
3032 for (i = 0; i < ntype; i++)
3038 compress.
append(COMPRESS_RAW);
3039 else if (name ==
"rawfull")
3040 compress.
append(COMPRESS_RAWFULL);
3041 else if (name ==
"constant")
3042 compress.
append(COMPRESS_CONSTANT);
3043 else if (name ==
"fpreal16")
3044 compress.
append(COMPRESS_FPREAL16);
3047 idx = lookupCompressionEngine(name);
3057 template <
typename T>
3061 int16 ntype = getCompressionEngines().entries();
3065 ntype += COMPRESS_ENGINE;
3074 ntype -= COMPRESS_ENGINE;
3075 for (i = 0; i < ntype; i++)
3084 template <
typename T>
3098 if (!buffer.
strcmp(
"raw"))
3099 compress.
append(COMPRESS_RAW);
3100 else if (!buffer.
strcmp(
"rawfull"))
3101 compress.
append(COMPRESS_RAWFULL);
3102 else if (!buffer.
strcmp(
"constant"))
3103 compress.
append(COMPRESS_CONSTANT);
3104 else if (!buffer.
strcmp(
"fpreal16"))
3105 compress.
append(COMPRESS_FPREAL16);
3108 idx = lookupCompressionEngine(buffer.
buffer());
3125 template <
typename T>
3140 myBorderScale[0] = 0;
3141 myBorderScale[1] = 0;
3142 myBorderScale[2] = 0;
3146 mySharedMemView = 0;
3149 template <
typename T>
3155 template <
typename T>
3169 mySharedMemView = 0;
3174 template <
typename T>
3181 vit.splitByTile(info);
3182 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3184 int i = vit.getLinearTileNum();
3185 myTiles[i] = src.myTiles[i];
3189 template <
typename T>
3197 myBorderScale[0] = src.myBorderScale[0];
3198 myBorderScale[1] = src.myBorderScale[1];
3199 myBorderScale[2] = src.myBorderScale[2];
3200 myBorderValue = src.myBorderValue;
3201 myBorderType = src.myBorderType;
3203 myCompressionOptions = src.myCompressionOptions;
3207 size(src.myRes[0], src.myRes[1], src.myRes[2],
false);
3217 #define __MULTITHREADED_STRUCTORS__
3218 template <
typename T>
3222 #ifdef __MULTITHREADED_STRUCTORS__
3227 for(
int i = range.begin(); i < range.end(); i++)
3229 myTiles[i].~UT_VoxelTile<
T>();
3232 operator delete(myTiles, std::nothrow);
3238 myTileRes[0] = myTileRes[1] = myTileRes[2] = 0;
3239 myRes[0] = myRes[1] = myRes[2] = 0;
3241 delete mySharedMemView;
3242 mySharedMemView = 0;
3248 template <
typename T>
3253 if (myRes[0] == xres && myRes[1] == yres && myRes[2] == zres)
3268 tile_res[0] = (xres + TILEMASK) >> TILEBITS;
3269 tile_res[1] = (yres + TILEMASK) >> TILEBITS;
3270 tile_res[2] = (zres + TILEMASK) >> TILEBITS;
3272 exint ntiles = ((
exint)tile_res[0]) * tile_res[1] * tile_res[2];
3275 #ifdef __MULTITHREADED_STRUCTORS__
3289 for(
int k = range.begin(); k < range.end(); k++)
3294 int tilex = k % tile_res[0];
3295 int k2 = k / tile_res[0];
3296 int tiley = k2 % tile_res[1];
3297 int tilez = k2 / tile_res[1];
3298 myTiles[k].
setRes(
SYSmin(TILESIZE, xres - tilex * TILESIZE),
3299 SYSmin(TILESIZE, yres - tiley * TILESIZE),
3300 SYSmin(TILESIZE, zres - tilez * TILESIZE));
3314 myInvRes.x() = 1.0f / myRes[0];
3316 myInvRes.y() = 1.0f / myRes[1];
3318 myInvRes.z() = 1.0f / myRes[2];
3320 myTileRes[0] = tile_res[0];
3321 myTileRes[1] = tile_res[1];
3322 myTileRes[2] = tile_res[2];
3324 #ifndef __MULTITHREADED_STRUCTORS__
3326 for (
int tz = 0; tz < myTileRes[2]; tz++)
3329 if (tz < myTileRes[2]-1)
3332 zr = zres - tz * TILESIZE;
3334 for (
int ty = 0; ty < myTileRes[1]; ty++)
3337 if (ty < myTileRes[1]-1)
3340 yr = yres - ty * TILESIZE;
3342 int tx, xr = TILESIZE;
3343 for (tx = 0; tx < myTileRes[0]-1; tx++)
3345 myTiles[i].
setRes(xr, yr, zr);
3349 xr = xres - tx * TILESIZE;
3350 myTiles[i].setRes(xr, yr, zr);
3360 template <
typename T>
3369 myBorderType = src.myBorderType;
3370 myBorderScale[0] = src.myBorderScale[0];
3371 myBorderScale[1] = src.myBorderScale[1];
3372 myBorderScale[2] = src.myBorderScale[2];
3373 myBorderValue = src.myBorderValue;
3376 myCompressionOptions = src.myCompressionOptions;
3379 template <
typename T>
3383 int64 mem = inclusive ?
sizeof(*this) : 0;
3385 int ntiles = numTiles();
3386 for (
int i = 0; i < ntiles; i++)
3387 mem += myTiles[i].getMemoryUsage(
true);
3390 mem += mySharedMem->getMemoryUsage(
true);
3392 if (mySharedMemView)
3393 mem += mySharedMemView->getMemoryUsage(
true);
3398 template <
typename T>
3405 vit.setPartialRange(info.
job(), info.
numJobs());
3406 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3408 int i = vit.getLinearTileNum();
3409 myTiles[i].makeConstant(t);
3413 template <
typename T>
3422 ntiles = numTiles();
3423 for (i = 0; i < ntiles; i++)
3425 if (!myTiles[i].isConstant())
3433 cval = myTiles[i].rawConstVal();
3453 template <
typename T>
3459 ntiles = numTiles();
3460 for (i = 0; i < ntiles; i++)
3462 if (myTiles[i].hasNan())
3471 template <
typename T>
3477 pos.
x() *= myRes[0];
3478 pos.
y() *= myRes[1];
3479 pos.
z() *= myRes[2];
3484 return lerpVoxelCoord(pos);
3487 template <
typename T>
3495 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3497 return lerpVoxel(x, y, z, fx, fy, fz);
3500 template <
typename T>
3501 template <
int AXIS2D>
3509 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3511 return lerpVoxelAxis<AXIS2D>(
x,
y,
z, fx, fy, fz);
3514 template <
typename T>
3517 float fx,
float fy,
float fz)
const
3520 T vx, vx1, vy, vy1, vz;
3524 if ( !((x | y | z) < 0) &&
3525 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3538 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3541 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3543 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
3557 (*
this)(x+1, y+1, z),
3564 (*
this)(x+1, y, z+1),
3568 (*
this)(x+1, y+1, z+1),
3611 template <
typename T>
3612 template <
int AXIS2D>
3615 float fx,
float fy,
float fz)
const
3618 T vx, vx1, vy, vy1, vz;
3620 int lesscomp = 0, greatercomp = -1;
3625 greatercomp &= (x - myRes[0]+1);
3630 greatercomp &= (y - myRes[1]+1);
3635 greatercomp &= (z - myRes[2]+1);
3640 if ( !(lesscomp < 0) && (greatercomp < 0) )
3648 if ((AXIS2D == 0 || xm != TILEMASK) &&
3649 (AXIS2D == 1 || ym != TILEMASK) &&
3650 (AXIS2D == 2 || zm != TILEMASK))
3653 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3654 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3655 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3657 vz = tile->template lerpAxis<AXIS2D>(xm, ym, zm, fx, fy, fz);
3671 vx = (*this)(
x,
y,
z);
3678 (*
this)(x+1, y+1, z),
3681 vx1 = (*this)(
x, y+1,
z);
3693 (*
this)(x+1, y, z+1),
3696 vx = (*this)(
x,
y, z+1);
3703 (*
this)(x+1, y+1, z+1),
3706 vx1 = (*this)(
x, y+1, z+1);
3780 template <
typename T>
3787 pos.
x() *= myRes[0];
3788 pos.
y() *= myRes[1];
3789 pos.
z() *= myRes[2];
3794 lerpVoxelCoordMinMax(lerp, lmin, lmax, pos);
3797 template <
typename T>
3806 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3808 lerpVoxelMinMax(lerp, lmin, lmax, x, y, z, fx, fy, fz);
3812 template <
typename T>
3813 template <
int AXIS2D>
3822 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3824 lerpVoxelMinMaxAxis<AXIS2D>(
lerp, lmin, lmax,
x,
y,
z, fx, fy, fz);
3828 template <
typename T>
3832 int x,
int y,
int z,
3833 float fx,
float fy,
float fz)
const
3837 if (extractSample(x, y, z, samples))
3839 lerp = smin = smax = samples[0];
3843 lerp = lerpSample(samples, fx, fy, fz);
3847 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3849 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3852 smin =
SYSmin(smin, smin1);
3853 smax =
SYSmax(smax, smax1);
3856 template <
typename T>
3857 template <
int AXIS2D>
3861 int x,
int y,
int z,
3862 float fx,
float fy,
float fz)
const
3866 if (extractSampleAxis<AXIS2D>(x, y, z, samples))
3868 lerp = smin = smax = samples[0];
3872 lerp = lerpSampleAxis<AXIS2D>(
samples, fx, fy, fz);
3875 SYSminmax(samples[0], samples[2], samples[4], samples[6],
3877 else if (AXIS2D == 1)
3878 SYSminmax(samples[0], samples[1], samples[4], samples[5],
3880 else if (AXIS2D == 2)
3881 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3887 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3889 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3892 smin =
SYSmin(smin, smin1);
3893 smax =
SYSmax(smax, smax1);
3897 template <
typename T>
3904 if ( !((x | y | z) < 0) &&
3905 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3918 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3921 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3930 samples[0] = (*this)(
x,
y,
z);
3931 samples[1] = (*this)(x+1,
y,
z);
3932 samples[2+0] = (*this)(
x, y+1,
z);
3933 samples[2+1] = (*this)(x+1, y+1,
z);
3934 samples[4+0] = (*this)(
x,
y, z+1);
3935 samples[4+1] = (*this)(x+1,
y, z+1);
3936 samples[4+2+0] = (*this)(
x, y+1, z+1);
3937 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3944 samples[2+0] =
getValue(x, y+1, z);
3945 samples[2+1] =
getValue(x+1, y+1, z);
3946 samples[4+0] =
getValue(x, y, z+1);
3947 samples[4+1] =
getValue(x+1, y, z+1);
3948 samples[4+2+0] =
getValue(x, y+1, z+1);
3949 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3956 template <
typename T>
3957 template <
int AXIS2D>
3964 int lesscomp = 0, greatercomp = -1;
3969 greatercomp &= (x - myRes[0]+1);
3974 greatercomp &= (y - myRes[1]+1);
3979 greatercomp &= (z - myRes[2]+1);
3984 if ( !(lesscomp < 0) && (greatercomp < 0) )
3992 if ((AXIS2D == 0 || xm != TILEMASK) &&
3993 (AXIS2D == 1 || ym != TILEMASK) &&
3994 (AXIS2D == 2 || zm != TILEMASK))
3997 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3998 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3999 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
4001 return tile->template extractSampleAxis<AXIS2D>(xm, ym, zm,
samples);
4008 samples[0] = (*this)(
x,
y,
z);
4010 samples[1] = (*this)(x+1,
y,
z);
4013 samples[2+0] = (*this)(
x, y+1,
z);
4015 samples[2+1] = (*this)(x+1, y+1,
z);
4019 samples[4+0] = (*this)(
x,
y, z+1);
4021 samples[4+1] = (*this)(x+1,
y, z+1);
4024 samples[4+2+0] = (*this)(
x, y+1, z+1);
4026 samples[4+2+1] = (*this)(x+1, y+1, z+1);
4038 samples[2+0] =
getValue(x, y+1, z);
4040 samples[2+1] =
getValue(x+1, y+1, z);
4044 samples[4+0] =
getValue(x, y, z+1);
4046 samples[4+1] =
getValue(x+1, y, z+1);
4049 samples[4+2+0] =
getValue(x, y+1, z+1);
4051 samples[4+2+1] =
getValue(x+1, y+1, z+1);
4059 template <
typename T>
4066 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
4067 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4080 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4083 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4092 samples[0] = (*this)(x-1,
y,
z);
4093 samples[1] = (*this)(x+1,
y,
z);
4094 samples[2+0] = (*this)(
x, y-1,
z);
4095 samples[2+1] = (*this)(
x, y+1,
z);
4096 samples[4+0] = (*this)(
x,
y, z-1);
4097 samples[4+1] = (*this)(
x,
y, z+1);
4098 samples[6] = (*this)(
x,
y,
z);
4105 samples[2+0] =
getValue(x, y-1, z);
4106 samples[2+1] =
getValue(x, y+1, z);
4107 samples[4+0] =
getValue(x, y, z-1);
4108 samples[4+1] =
getValue(x, y, z+1);
4119 template <
typename T>
4126 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
4127 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4140 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4143 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4145 return tile->extractSampleCube(xm, ym, zm, samples);
4153 for (
int dz = -1; dz <= 1; dz++)
4155 for (
int dy = -1; dy <= 1; dy++)
4157 for (
int dx = -1; dx <= 1; dx++)
4159 samples[sampidx++] = (*this)(x+dx, y+dy, z+dz);
4168 for (
int dz = -1; dz <= 1; dz++)
4170 for (
int dy = -1; dy <= 1; dy++)
4172 for (
int dx = -1; dx <= 1; dx++)
4174 samples[sampidx++] =
getValue(x+dx, y+dy, z+dz);
4184 template <
typename T>
4187 float fx,
float fy,
float fz)
const
4191 T vx, vx1, vy, vy1, vz;
4221 v4uf a,
b, vfx, vfy, vfz;
4223 a =
v4uf(&samples[0]);
4224 b =
v4uf(&samples[4]);
4245 template <
typename T>
4246 template <
int AXIS2D>
4249 float fx,
float fy,
float fz)
const
4252 T vx, vx1, vy, vy1, vz;
4305 template <
typename T>
4315 pos.
x() *= myRes[0];
4316 pos.
y() *= myRes[1];
4317 pos.
z() *= myRes[2];
4324 SYSfastSplitFloat(fx, x);
4326 SYSfastSplitFloat(fy, y);
4328 SYSfastSplitFloat(fz, z);
4331 T vx, vx1, vy, vy1, vz;
4347 if ( !((x | y | z) < 0) &&
4348 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4360 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4363 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4365 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
4379 (*
this)(x+1, y+1, z),
4386 (*
this)(x+1, y, z+1),
4390 (*
this)(x+1, y+1, z+1),
4434 template <
typename T>
4444 pos *=
v4uf((
float) myRes[0], (
float) myRes[1], (
float) myRes[2], 0.0
f);
4473 if ( (x > 0) & (y > 0) & (z > 0) &
4474 (x < myRes[0]-1) & (y < myRes[1]-1) & (z < myRes[2]-1) &
4475 (xm != TILEMASK) & (ym != TILEMASK) & (zm != TILEMASK) )
4484 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4486 return tile->
lerp(pos, xm, ym, zm);
4500 fx = pos.
swizzle<0, 0, 0, 0>();
4501 fy = pos.
swizzle<1, 1, 1, 1>();
4502 fz = pos.
swizzle<2, 2, 2, 2>();
4520 firstTile(
int &
start,
int &
end,
int res)
4531 nextTile(
int &tile,
int &pstart,
int &start,
int &end,
int res)
4541 tile = pstart >> TILEBITS;
4542 pend =
SYSmin((tile+1) * TILESIZE, end, res);
4552 template <
typename T>
4555 fpreal radius,
int clampaxis)
const
4561 const float *weights[3];
4563 int start[3], end[3],
size[3];
4564 int pstart[3], pend[3];
4571 return myBorderValue;
4575 switch (myBorderType)
4586 for (i = 0; i < 3; i++)
4594 memset(&result, 0,
sizeof(result));
4601 for (i = 0; i < 3; i++)
4603 tpos[i] = tpos[i]*myRes[i];
4604 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4608 start[i] = win[i].
getStart() % myRes[i];
4614 end[i] = start[i] + size[i];
4619 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4620 while (pstart[2] < end[2])
4622 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4623 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4624 while (pstart[1] < end[1])
4626 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4627 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4628 while (pstart[0] < end[0])
4630 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4631 tile = getTile(tx, ty, tz);
4633 tile->
weightedSum(pstart, pend, weights, start, result);
4634 pstart[0] = pend[0];
4636 pstart[1] = pend[1];
4638 pstart[2] = pend[2];
4643 result += (1-visible)*myBorderValue;
4649 template <
typename T>
4652 fpreal radius,
int clampaxis)
const
4658 int start[3], end[3],
size[3];
4659 int pstart[3], pend[3];
4666 return myBorderValue;
4670 switch (myBorderType)
4681 for (i = 0; i < 3; i++)
4689 memset(&result, 0,
sizeof(result));
4695 for (i = 0; i < 3; i++)
4697 tpos[i] = tpos[i]*myRes[i];
4698 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4701 start[i] = win[i].
getStart() % myRes[i];
4707 end[i] = start[i] + size[i];
4711 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4712 while (pstart[2] < end[2])
4714 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4715 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4716 while (pstart[1] < end[1])
4718 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4719 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4720 while (pstart[0] < end[0])
4722 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4723 tile = getTile(tx, ty, tz);
4725 tile->
avgNonZero(pstart, pend, start, result);
4726 pstart[0] = pend[0];
4728 pstart[1] = pend[1];
4730 pstart[2] = pend[2];
4736 template <
typename T>
4740 float filterwidthscale,
4752 radius *= 0.5 * filterwidthscale;
4754 resamplethread(src, filter, radius, clampaxis);
4759 template <
typename T>
4760 template <
typename OP>
4767 for (
int tileidx =
range.begin(); tileidx !=
range.end(); tileidx++)
4784 template <
typename T>
4791 if (getXRes() == 1 && ystride == 1)
4793 flattenPartialAxis<0>(flatarray, zstride, info);
4795 else if (getYRes() == 1 && zstride == ystride)
4797 flattenPartialAxis<1>(flatarray, zstride, info);
4799 else if (getZRes() == 1)
4801 flattenPartialAxis<2>(flatarray, ystride, info);
4815 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4821 template <
typename T>
4822 template <
int AXIS2D>
4829 const int ax = (AXIS2D == 0) ? 1 : 0;
4830 const int ay = (AXIS2D == 2) ? 1 : 2;
4831 int tileidx[3] = { 0, 0, 0 };
4836 exint ystart = tiley * TILESIZE;
4837 if (ystart >= getRes(ay))
4840 T *stripe = &flatarray[ystart * ystride];
4842 int yres =
SYSmin(getRes(ay) - ystart, TILESIZE);
4844 for (
int tilex = 0, ntilex = getTileRes(ax); tilex < ntilex; tilex++)
4846 tileidx[ax] = tilex;
4847 tileidx[ay] = tiley;
4848 auto tile = getTile(tileidx[0], tileidx[1], tileidx[2]);
4850 int xres = tile->getRes(ax);
4851 T *stripey = stripe;
4852 if (tile->isConstant())
4854 const T *srcdata = tile->rawData();
4856 for (
int y = 0; y < yres; y++)
4858 for (
int x = 0; x < xres; x++)
4860 memcpy(&stripey[x], srcdata,
sizeof(
T));
4865 else if (tile->isSimpleCompression())
4867 const T *srcdata = tile->rawData();
4869 if (xres != TILESIZE)
4871 for (
int y = 0; y < yres; y++)
4873 memcpy(stripey, srcdata,
sizeof(
T) * xres);
4880 for (
int y = 0; y < yres; y++)
4882 memcpy(stripey, srcdata,
sizeof(
T) * TILESIZE);
4883 srcdata += TILESIZE;
4890 for (
int y = 0; y < yres; y++)
4892 int idx[3] = { 0, 0, 0 };
4894 for (
int x = 0; x < xres; x++)
4897 stripey[
x] = (*tile)(idx[0], idx[1], idx[2]);
4927 int idx = (vit.
x() + vit.
y()*ystride + vit.
z()*zstride) * 4;
4930 flatarray[idx+1] = (
uint8)
SYSclamp(v.
y() * 255.0f, 0.0f, 255.0f);
4931 flatarray[idx+2] = (
uint8)
SYSclamp(v.
z() * 255.0f, 0.0f, 255.0f);
4932 flatarray[idx+3] = (
uint8)
SYSclamp(v.
w() * 255.0f, 0.0f, 255.0f);
4936 template <
typename T>
4942 UT_ASSERT(!
"This template requires specific instantiations.");
4961 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4964 template <
typename T>
4970 UT_ASSERT(!
"This template requires specific instantiations.");
5005 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] =
v;
5009 template <
typename T>
5015 UT_ASSERT(!
"This template requires specific instantiations.");
5019 template <
typename T>
5033 vit.
setValue(flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride]);
5037 template <
typename T>
5038 template <
int SLICE,
typename S>
5042 int slice_res = getRes(SLICE);
5044 if (slice < 0 || slice >= slice_res ||
5045 (half_slice && slice == slice_res - 1))
5048 constexpr
int AXIS1 = SLICE == 0 ? 2 : 0;
5049 constexpr
int AXIS2 = SLICE == 1 ? 2 : 1;
5052 int a1_res = getRes(AXIS1);
5054 int a1_tiles = getTileRes(AXIS1);
5055 int a2_tiles = getTileRes(AXIS2);
5056 int ntiles = a1_tiles * a2_tiles;
5059 int tile_stride2 = (a1_res << TILEBITS);
5060 int tile_stride1 = TILESIZE;
5062 int tile_slice = (slice >> TILEBITS);
5063 int local_slice = (slice & TILEMASK);
5066 bool half_slice_st = half_slice && (local_slice != TILEMASK);
5069 bool half_slice_tb =
false;
5081 auto set_functor = [&](
const UT_VoxelTile<T>* tile,
int idx[3],
int vidx)
5085 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
5087 dstdata[vidx] = 0.5f * (dstdata[vidx] +
5088 (*tile)(idx[0], idx[1], idx[2]));
5091 else if (half_slice_tb)
5092 dstdata[vidx] = 0.5f * (dstdata[vidx] +
5093 (*tile)(idx[0], idx[1], idx[2]));
5095 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
5103 is[SLICE] = tile_slice;
5106 is_local[SLICE] = local_slice;
5108 for (
int i =
range.begin(); i <
range.end(); i++)
5111 is[AXIS1] = i % a1_tiles;
5112 is[AXIS2] = i / a1_tiles;
5116 int a1_tile_res = tile->
getRes(AXIS1);
5117 int a2_tile_res = tile->
getRes(AXIS2);
5119 int vcounter = is[AXIS2] * tile_stride2 + is[AXIS1] * tile_stride1;
5121 for (is_local[AXIS2] = 0; is_local[AXIS2] < a2_tile_res;
5124 for (is_local[AXIS1] = 0; is_local[AXIS1] < a1_tile_res;
5127 set_functor(tile, is_local, vcounter);
5131 vcounter += a1_res - a1_tile_res;
5141 if (half_slice && !half_slice_st)
5143 half_slice_tb =
true;
5152 template <
typename T>
5153 template <
typename S>
5158 for (
int i = 0; i < tilelist.
entries(); i++)
5160 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5163 tile->
flatten(dstdata, stride);
5169 template <
typename T>
5170 template <
typename S,
typename IDX>
5173 const IDX *ix,
const IDX *iy,
const IDX *iz,
5178 for (
auto && tiledata : tilelist)
5180 int tileidx = tiledata.tileidx;
5181 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5186 if (tilevoxel == tiledata.numvoxel)
5189 tile->
flatten(dstdata, stride);
5190 dstdata += tiledata.numvoxel *
stride;
5191 srcidx += tiledata.numvoxel;
5196 int basex, basey, basez;
5197 linearTileToXYZ(tileidx, basex, basey, basez);
5209 for (
int i = 0; i < tiledata.numvoxel; i++)
5218 int w = tile->
xres();
5219 int h = tile->
yres();
5220 for (
int i = 0; i < tiledata.numvoxel; i++)
5222 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5223 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5224 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5225 *dstdata = src[ (ix[srcidx] - basex)
5226 + (iy[srcidx] - basey) * w
5227 + (iz[srcidx] - basez) * w * h];
5235 for (
int i = 0; i < tiledata.numvoxel; i++)
5237 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5238 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5239 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5240 *dstdata = (*tile)(ix[srcidx] - basex,
5242 iz[srcidx] - basez);
5252 template <
typename T>
5253 template <
typename S>
5258 bool docompress = getCompressionOptions().compressionEnabled();
5259 for (
int i = 0; i < tilelist.
entries(); i++)
5261 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5272 template <
typename T>
5273 template <
typename S,
typename IDX>
5276 const IDX *ix,
const IDX *iy,
const IDX *iz,
5279 bool docompress = getCompressionOptions().compressionEnabled();
5282 for (
auto && tiledata : tilelist)
5284 int tileidx = tiledata.tileidx;
5285 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5290 if (tilevoxel == tiledata.numvoxel)
5293 srcdata += tiledata.numvoxel *
stride;
5294 srcidx += tiledata.numvoxel;
5299 int basex, basey, basez;
5300 linearTileToXYZ(tileidx, basex, basey, basez);
5306 for (
int i = 0; i < tiledata.numvoxel; i++)
5308 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5309 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5310 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5364 template <
typename T>
5367 int xoff,
int yoff,
int zoff)
5475 template <
typename T>
5478 int tileoffy,
int tileoffz)
5488 for (
int i = range.begin(); i < range.end(); i++)
5503 && tile->
zres() == srctile->
zres())
5508 UTswap(tile->myCompressionType, srctile->myCompressionType);
5509 UTswap(tile->myForeignData, srctile->myForeignData);
5514 int offv[] = {(xyz[0] + tileoffx) * TILESIZE,
5515 (xyz[1] + tileoffy) * TILESIZE,
5516 (xyz[2] + tileoffz) * TILESIZE};
5517 for (
int z = 0; z < tile->
zres(); z++)
5519 for (
int y = 0; y < tile->
yres(); y++)
5521 for (
int x = 0; x < tile->
xres(); x++)
5539 const int off[] = {tileoffx, tileoffy, tileoffz};
5548 for (
int i = range.begin(); i < range.end(); i++)
5556 bool outside =
false;
5557 for (
int j = 0;
j < 3;
j++)
5560 outside = outside || (xyz[
j] < 0 || xyz[
j] >= src_tileres[
j]);
5565 if (outside && const_src_border)
5572 int offv[] = {xyz[0] * TILESIZE, xyz[1] * TILESIZE, xyz[2] * TILESIZE};
5573 for (
int z = 0; z < tile->
zres(); z++)
5575 for (
int y = 0; y < tile->
yres(); y++)
5577 for (
int x = 0; x < tile->
xres(); x++)
5591 template <
typename T>
5594 int offx,
int offy,
int offz)
5619 copyWithOffsetInternal(src, offx, offy, offz);
5622 template <
typename T>
5625 int offx,
int offy,
int offz,
5630 bool can_copy_tiles = ((offx & TILEMASK) == 0) && ((offy & TILEMASK) == 0)
5631 && ((offz & TILEMASK) == 0);
5655 for (
int i = 0; i < 3; i++)
5657 srctileidx(i) = vit.
myTilePos[i] + (off(i) >> TILEBITS);
5658 inside = inside && srctileidx(i) >= 0
5665 srctile = src.
getTile(srctileidx.
x(), srctileidx.
y(), srctileidx.
z());
5667 && tile->
zres() == srctile->
zres())
5677 srctileidx.
x() >>= TILEBITS;
5678 srctileidx.
y() >>= TILEBITS;
5679 srctileidx.
z() >>= TILEBITS;
5680 srctileoff.
x() = off.x() & TILEMASK;
5681 srctileoff.
y() = off.y() & TILEMASK;
5682 srctileoff.
z() = off.z() & TILEMASK;
5687 srcend.
x() += tile->
xres() - 1;
5688 srcend.
y() += tile->
yres() - 1;
5689 srcend.
z() += tile->
zres() - 1;
5691 srcendtile = srcend;
5692 srcendtile.
x() >>= TILEBITS;
5693 srcendtile.
y() >>= TILEBITS;
5694 srcendtile.
z() >>= TILEBITS;
5697 srcendtile.
x() == srctileidx.
x()+1);
5699 srcendtile.
y() == srctileidx.
y()+1);
5701 srcendtile.
z() == srctileidx.
z()+1);
5704 if (srctileidx.
x() >= 0 &&
5705 srctileidx.
y() >= 0 &&
5706 srctileidx.
z() >= 0 &&
5714 bool allconst =
true, firsttile =
true;
5717 for (tz = srctileidx.
z(); allconst && tz <= srcendtile.
z(); tz++)
5718 for (ty = srctileidx.
y(); allconst && ty <= srcendtile.
y(); ty++)
5719 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5721 srctile = src.
getTile(tx, ty, tz);
5727 cval = (*srctile)(0, 0, 0);
5752 for (tz = srctileidx.
z(); tz <= srcendtile.
z(); tz++)
5753 for (ty = srctileidx.
y(); ty <= srcendtile.
y(); ty++)
5754 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5756 int destx, desty, destz;
5757 int srcx, srcy, srcz;
5759 destx = (tx == srctileidx.
x()) ? 0 : (TILESIZE-srctileoff.
x());
5760 desty = (ty == srctileidx.
y()) ? 0 : (TILESIZE-srctileoff.
y());
5761 destz = (tz == srctileidx.
z()) ? 0 : (TILESIZE-srctileoff.
z());
5762 srcx = (tx == srctileidx.
x()) ? srctileoff.
x() : 0;
5763 srcy = (ty == srctileidx.
y()) ? srctileoff.
y() : 0;
5764 srcz = (tz == srctileidx.
z()) ? srctileoff.
z() : 0;
5780 srctile = src.
getTile(tx, ty, tz);
5783 destx, desty, destz,
5798 for (
int z = destz; z < maxd; z++)
5800 for (
int y = desty; y < maxh; y++)
5802 for (
int x = destx; x < maxw; x++)
5808 z + vit.
z() + offz);
5818 template <
typename T>
5835 ratio.
x() = 1.0f / getXRes();
5836 ratio.
y() = 1.0f / getYRes();
5837 ratio.
z() = 1.0f / getZRes();
5841 pos.
x() = vit.
x()+0.5f;
5842 pos.
y() = vit.
y()+0.5f;
5843 pos.
z() = vit.
z()+0.5f;
5850 template <
typename T>
5856 pos.
x() *= myRes[0];
5857 pos.
y() *= myRes[1];
5858 pos.
z() *= myRes[2];
5868 return isValidIndex(x, y, z);
5871 template <
typename T>
5877 pos.
x() *= myRes[0];
5878 pos.
y() *= myRes[1];
5879 pos.
z() *= myRes[2];
5890 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5891 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5892 pos.
z() < 0 || pos.
z() >= myRes[2])
5898 template <
typename T>
5904 pos.
x() *= myRes[0];
5905 pos.
y() *= myRes[1];
5906 pos.
z() *= myRes[2];
5916 return isValidIndex(x, y, z);
5919 template <
typename T>
5925 pos.
x() *= myRes[0];
5926 pos.
y() *= myRes[1];
5927 pos.
z() *= myRes[2];
5938 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5939 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5940 pos.
z() < 0 || pos.
z() >= myRes[2])
5946 template <
typename T>
5963 return isValidIndex(x, y, z);
5966 template <
typename T>
5983 return isValidIndex(x, y, z);
5986 template <
typename T>
6001 template <
typename T>
6016 template <
typename T>
6020 myBorderType =
type;
6024 template <
typename T>
6028 myBorderScale[0] = sx;
6029 myBorderScale[1] = sy;
6030 myBorderScale[2] = sz;
6033 template <
typename T>
6042 myTiles[i].tryCompress(getCompressionOptions());
6046 template <
typename T>
6055 myTiles[i].uncompress();
6059 template <
typename T>
6068 if (!myTiles[i].isConstant())
6069 myTiles[i].uncompress();
6073 template <
typename T>
6081 if (isConstant(&cval))
6085 UTwrite(os, &version, 1);
6086 UTwrite<T>(os, &cval);
6092 UTwrite(os, &version, 1);
6099 ntiles = numTiles();
6100 for (i = 0; i < ntiles; i++)
6102 myTiles[i].save(os);
6107 template <
typename T>
6135 ntiles = numTiles();
6136 for (i = 0; i < ntiles; i++)
6138 myTiles[i].load(is, compressions);
6143 template <
typename T>
6154 if (isConstant(&cval))
6160 if constexpr (tuple_size == 1)
6168 if (shared_mem_owner)
6171 shm = copyToSharedMemory(shared_mem_owner);
6206 ntiles = numTiles();
6207 for (i = 0; i < ntiles; i++)
6209 ok = ok && myTiles[i].save(w);
6219 template <
typename T>
6229 bool array_error =
false;
6231 delete mySharedMemView;
6232 mySharedMemView = 0;
6245 if constexpr (tuple_size == 1)
6264 if (!populateFromSharedMemory(shm_id.
buffer()))
6299 ntiles = numTiles();
6305 if (!myTiles[i].load(p, compressions))
6311 dummy_tile.
setRes(TILESIZE, TILESIZE, TILESIZE);
6312 if (!dummy_tile.
load(p, compressions))
6320 p.
addWarning(
"Unexpected key for voxel data: %s",
6340 template<
typename T>
6348 ntiles = numTiles();
6351 exint total_mem_size;
6353 total_mem_size =
sizeof(
exint);
6358 for (
int i = 0; i < ntiles; i++)
6360 exint tile_size, block_size;
6361 if (myTiles[i].isConstant())
6362 tile_size =
sizeof(T);
6364 tile_size = myTiles[i].getDataLength();
6366 tile_sizes.
append(tile_size);
6368 block_size = SYSroundUpToMultipleOf<exint>(tile_size,
sizeof(
exint));
6369 block_size +=
sizeof(
exint) * 2;
6372 next_block_offsets.
append(block_size /
sizeof(
exint));
6374 next_block_offsets.
append(0);
6376 total_mem_size += block_size;
6383 shared_mem_key.
sprintf(
"%s:%p", shared_mem_owner,
this);
6385 shared_mem = shmgr.
get(shared_mem_key.
buffer());
6391 bool same_meta_data =
false;
6392 if (shared_mem->
size() >=
sizeof(
exint))
6394 same_meta_data =
true;
6399 if (*ptr_ds != ntiles)
6400 same_meta_data =
false;
6407 for (
int i = 0; i < ntiles; i++)
6413 if (ptr_tile[0] != next_block_offsets(i) ||
6414 ptr_tile[1] != (
exint)myTiles[i].myCompressionType)
6416 same_meta_data =
false;
6419 offset += next_block_offsets(i) *
sizeof(
exint);
6424 if (!same_meta_data)
6426 if (!shared_mem->
reset(total_mem_size) ||
6427 shared_mem->
size() != total_mem_size)
6441 for (
int i = 0; i < ntiles; i++)
6444 sizeof(
exint) * 2 + tile_sizes(i));
6449 ptr_tile[0] = next_block_offsets(i);
6450 ptr_tile[1] = myTiles[i].myCompressionType;
6452 ::memcpy(&ptr_tile[2], myTiles[i].rawData(), tile_sizes(i));
6454 offset += ptr_tile[0] *
sizeof(
exint);
6460 template<
typename T>
6465 if (!mySharedMem->size())
6475 ntiles = *(
const exint *)sv_tc.data();
6477 if (ntiles != numTiles())
6486 exint *data = (
exint *)mySharedMemView->data();
6488 for (
int i = 0; i < ntiles; i++)
6490 exint offset = data[0];
6493 myTiles[i].setForeignData(&data[2], ctype);
6507 template <
typename T>
6510 initializePrivate();
6513 template <
typename T>
6519 template <
typename T>
6522 initializePrivate();
6527 template <
typename T>
6550 myLevels.append(levels);
6552 for (level = 0; level < myNumLevels; level++)
6561 template <
typename T>
6568 functions.
append(
function);
6569 build(baselevel, functions);
6572 template <
typename T>
6580 myBaseLevel = baselevel;
6588 maxres =
SYSmax(myBaseLevel->getXRes(), myBaseLevel->getYRes());
6589 maxres =
SYSmax(maxres, myBaseLevel->getZRes());
6603 for (
int i = 0; i < functions.
entries(); i++)
6608 myLevels.append(levels);
6611 for (level = myNumLevels-1; level >= 0; level--)
6614 int xres = (lastlevel->
getXRes() + 1) >> 1;
6615 int yres = (lastlevel->
getYRes() + 1) >> 1;
6616 int zres = (lastlevel->
getZRes() + 1) >> 1;
6621 downsample(*levels[level], *lastlevel,
function);
6623 lastlevel = levels[
level];
6628 template <
typename T>
6633 mipmaptype
function,
6657 mixValues(sam[0], sam[1],
function),
6658 mixValues(sam[2], sam[3],
function),
function),
6660 mixValues(sam[4], sam[5],
function),
6661 mixValues(sam[6], sam[7],
function),
function),
6668 template <
typename T>
6672 int64 mem = inclusive ?
sizeof(*this) : 0;
6674 mem += myLevels.getMemoryUsage(
false);
6676 for (
exint j = 0;
j < myLevels.entries();
j++)
6678 for (
int i = 0; i < myNumLevels; i++)
6679 mem += myLevels(
j)[i]->getMemoryUsage(
true);
6685 template <
typename T>
6689 doTraverse(0, 0, 0, 0,
function, data);
6692 template <
typename T>
6695 Callback
function,
void *data)
const
6702 if (level == myNumLevels)
6706 tval[0] = (*vox)(
x,
y,
z);
6707 for (
int i = 1; i < myLevels.entries(); i++)
6713 for (
int i = 0; i < myLevels.entries(); i++)
6715 vox = myLevels(i)[
level];
6716 tval[i] = (*vox)(
x,
y,
z);
6720 shift = myNumLevels -
level;
6725 SYSmin(y << shift, myBaseLevel->getYRes()),
6726 SYSmin(z << shift, myBaseLevel->getZRes()));
6728 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6729 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6731 if (!
function(tval, box, isfinal, data))
6748 bool xinc, yinc, zinc;
6751 if ( ((x+1) << shift) < myBaseLevel->getXRes() )
6755 if ( ((y+1) << shift) < myBaseLevel->getYRes() )
6759 if ( ((z+1) << shift) < myBaseLevel->getZRes() )
6769 doTraverse(x, y, z, level,
function, data);
6773 doTraverse(x, y+1, z, level,
function, data);
6775 doTraverse(x, y+1, z+1, level,
function, data);
6778 doTraverse(x, y, z+1, level,
function, data);
6783 doTraverse(x+1, y, z+1, level,
function, data);
6784 doTraverse(x+1, y, z, level,
function, data);
6787 doTraverse(x+1, y+1, z, level,
function, data);
6789 doTraverse(x+1, y+1, z+1, level,
function, data);
6794 template <
typename T>
6795 template <
typename OP>
6799 doTraverse(0, 0, 0, numLevels()-1, op);
6802 template <
typename T>
6803 template <
typename OP>
6815 SYSmin(y << shift, myBaseLevel->getYRes()),
6816 SYSmin(z << shift, myBaseLevel->getZRes()));
6818 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6819 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6821 if (!
op(box, level))
6837 bool xinc, yinc, zinc;
6840 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6844 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6848 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6858 doTraverse(x, y, z, level, op);
6862 doTraverse(x, y+1, z, level, op);
6864 doTraverse(x, y+1, z+1, level, op);
6867 doTraverse(x, y, z+1, level, op);
6872 doTraverse(x+1, y, z+1, level, op);
6873 doTraverse(x+1, y, z, level, op);
6876 doTraverse(x+1, y+1, z, level, op);
6878 doTraverse(x+1, y+1, z+1, level, op);
6883 template <
typename T>
6884 template <
typename OP>
6888 doTraverseSorted(0, 0, 0, numLevels()-1, op);
6903 template <
typename T>
6904 template <
typename OP>
6912 SYSmin(y << level, myBaseLevel->getYRes()),
6913 SYSmin(z << level, myBaseLevel->getZRes()));
6918 if (!
op(box, level))
6934 bool xinc, yinc, zinc;
6937 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6941 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6945 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6954 for (
int dz = 0; dz < 2; dz++)
6958 for (
int dy = 0; dy < 2; dy++)
6962 for (
int dx = 0; dx < 2; dx++)
6967 SYSmin((x+dx) << level, myBaseLevel->getXRes()),
6971 SYSmin((x+dx+1) << level, myBaseLevel->getXRes()),
6972 SYSmin((y+dy+1) <<
level, myBaseLevel->getYRes()),
6973 SYSmin((z+dz+1) <<
level, myBaseLevel->getZRes()));
6980 for (
int i = 0; i < numboxes; i++)
6982 sortstats[i].
value = op.sortValue(boxes[i], level);
6983 sortstats[i].
key = i;
6985 std::stable_sort(sortstats, &sortstats[numboxes]);
6987 for (
int i = 0; i < numboxes; i++)
6989 int whichbox = sortstats[i].
key;
6990 doTraverseSorted(boxes[whichbox](0,0)>>level, boxes[whichbox](1,0)>>level, boxes[whichbox](2,0)>>level, level, op);
6994 template <
typename T>
7003 template <
typename T>
7007 for (
exint i = 0; i < myLevels.entries(); i++)
7009 for (
exint level = 0; level < myNumLevels; level++)
7010 delete myLevels(i)[
level];
7011 delete [] myLevels(i);
7013 myLevels.entries(0);
7018 initializePrivate();
7024 template <
typename T>
7028 myHandle.resetHandle();
7030 myShouldCompressOnExit =
false;
7031 myUseTileList =
false;
7036 template <
typename T>
7039 myShouldCompressOnExit =
false;
7040 myUseTileList =
false;
7046 template <
typename T>
7049 myShouldCompressOnExit =
false;
7050 myUseTileList =
false;
7056 template <
typename T>
7061 template <
typename T>
7074 numtiles = myArray->numTiles();
7078 numtiles = myTileList.entries();
7089 if (idx < 0 || idx >= numranges)
7111 myTileEnd = (
int)
SYSfloor((idx+1) * tileperrange);
7115 if (idx == numranges-1)
7116 myTileEnd = numtiles;
7122 template <
typename T>
7138 template <
typename T>
7154 myArray->posToIndex(pmin, vmin);
7155 myArray->posToIndex(pmax, vmax);
7162 template <
typename T>
7168 int xres, yres, zres,
x,
y,
z;
7170 xres = myArray->getXRes();
7171 yres = myArray->getYRes();
7172 zres = myArray->getZRes();
7174 myTileList.entries(0);
7175 myUseTileList =
true;
7177 if (xmin < xres && xmax >= 0 &&
7178 ymin < yres && ymax >= 0 &&
7179 zmin < zres && zmax >= 0)
7182 myArray->clampIndex(xmin, ymin, zmin);
7183 myArray->clampIndex(xmax, ymax, zmax);
7194 if (myArray->numTiles() == (xmax-xmin+1)*(ymax-ymin+1)*(zmax-zmin+1))
7196 UT_ASSERT(xmin == 0 && ymin == 0 && zmin == 0);
7198 myUseTileList =
false;
7203 for (z = zmin; z <= zmax; z++)
7205 for (y = ymin; y <= ymax; y++)
7207 for (x = xmin; x <= xmax; x++)
7209 myTileList.append(myArray->xyzTileToLinear(x, y, z));
7218 setPartialRange(0, 1);
7222 template <
typename T>
7228 !myArray->getRes(0) || !myArray->getRes(1) || !myArray->getRes(2))
7237 myCurTileListIdx = myJobInfo->nextTask();
7239 myCurTileListIdx = myTileStart;
7240 if (myCurTileListIdx < 0 || myCurTileListIdx >= myTileEnd)
7245 myCurTile = myTileList(myCurTileListIdx);
7250 myCurTile = myJobInfo->nextTask();
7252 myCurTile = myTileStart;
7254 if (myCurTile < 0 || myCurTile >= myTileEnd)
7263 tile = myArray->getLinearTile(myCurTile);
7268 myArray->linearTileToXYZ(myCurTile,
7269 myTilePos[0], myTilePos[1], myTilePos[2]);
7270 myPos[0] = TILESIZE * myTilePos[0];
7271 myPos[1] = TILESIZE * myTilePos[1];
7272 myPos[2] = TILESIZE * myTilePos[2];
7284 myTileLocalPos[0] = 0;
7285 myTileLocalPos[1] = 0;
7286 myTileLocalPos[2] = 0;
7288 myTileSize[0] = tile->
xres();
7289 myTileSize[1] = tile->
yres();
7290 myTileSize[2] = tile->
zres();
7293 template <
typename T>
7297 if (myInterrupt && myInterrupt->opInterrupt())
7304 if (getCompressOnExit())
7307 if (myCurTile >= 0 && myCurTileListIdx < myTileEnd)
7309 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7315 myCurTileListIdx = myJobInfo->nextTask();
7318 if (myCurTileListIdx >= myTileEnd)
7324 myCurTile = myTileList(myCurTileListIdx);
7326 myArray->linearTileToXYZ(myCurTile,
7327 myTilePos[0], myTilePos[1], myTilePos[2]);
7331 tile = myArray->getLinearTile(myCurTile);
7332 myTileLocalPos[0] = 0;
7333 myTileLocalPos[1] = 0;
7334 myTileLocalPos[2] = 0;
7335 myTileSize[0] = tile->
xres();
7336 myTileSize[1] = tile->
yres();
7337 myTileSize[2] = tile->
zres();
7339 myPos[0] = TILESIZE * myTilePos[0];
7340 myPos[1] = TILESIZE * myTilePos[1];
7341 myPos[2] = TILESIZE * myTilePos[2];
7346 if (getCompressOnExit())
7349 if (myCurTile >= 0 && myCurTile < myTileEnd)
7351 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7357 myCurTile = myJobInfo->nextTask();
7358 if (myCurTile >= myTileEnd)
7363 myArray->linearTileToXYZ(myCurTile,
7364 myTilePos[0], myTilePos[1], myTilePos[2]);
7370 if (myTilePos[0] >= myArray->getTileRes(0))
7374 if (myTilePos[1] >= myArray->getTileRes(1))
7378 if (myTilePos[2] >= myArray->getTileRes(2))
7386 myCurTile = myArray->xyzTileToLinear(myTilePos[0], myTilePos[1], myTilePos[2]);
7394 if (myCurTile >= myTileEnd)
7400 tile = myArray->getLinearTile(myCurTile);
7401 myTileLocalPos[0] = 0;
7402 myTileLocalPos[1] = 0;
7403 myTileLocalPos[2] = 0;
7404 myTileSize[0] = tile->
xres();
7405 myTileSize[1] = tile->
yres();
7406 myTileSize[2] = tile->
zres();
7408 myPos[0] = TILESIZE * myTilePos[0];
7409 myPos[1] = TILESIZE * myTilePos[1];
7410 myPos[2] = TILESIZE * myTilePos[2];
7414 template <
typename T>
7418 myTileLocalPos[0] = myTileSize[0];
7419 myTileLocalPos[1] = myTileSize[1];
7420 myTileLocalPos[2] = myTileSize[2];
7423 template <
typename T>
7424 template <
typename OP>
7434 tile = myArray->getLinearTile(myCurTile);
7456 for (
int i = 0; i <
n; i++)
7458 val[i] =
op(val[i], a);
7466 template <
typename T>
7467 template <
typename OP,
typename S>
7481 tile = myArray->getLinearTile(myCurTile);
7487 for (
int z = 0; z < tile->
zres(); z++)
7488 for (
int y = 0; y < tile->
yres(); y++)
7489 for (
int x = 0; x < tile->
xres(); x++)
7494 val = tile->operator()(
x,
y,
z);
7495 aval = atile->operator()(
x,
y,
z);
7497 val =
op(val, aval);
7512 if (op.isNoop(aval))
7533 val =
op(val, aval);
7555 for (
int i = 0; i <
n; i++)
7557 val[i] =
op(val[i], *aval);
7567 template <
typename T>
7568 template <
typename OP>
7581 applyOperation(op, a);
7584 template<
int OPERANDS,
bool USE_SELF,
7585 typename T,
typename OP,
typename S,
typename R,
typename Q>
7587 conditionalCallOperator(
const OP& op,
const T& a0,
const S& a1,
const R& a2,
const Q& a3)
7591 if constexpr (OPERANDS == 0 && USE_SELF)
7593 else if constexpr (OPERANDS == 1 && !USE_SELF)
7595 else if constexpr (OPERANDS == 1 && USE_SELF)
7597 else if constexpr (OPERANDS == 2 && !USE_SELF)
7599 else if constexpr (OPERANDS == 2 && USE_SELF)
7600 val = op(a0, a1, a2);
7601 else if constexpr (OPERANDS == 3 && !USE_SELF)
7602 val = op(a1, a2, a3);
7603 else if constexpr (OPERANDS == 3 && USE_SELF)
7604 val = op(a0, a1, a2, a3);
7612 template<
int OPERANDS,
bool MASKED,
bool USE_SELF,
7613 typename T, typename OP, typename S, typename R, typename Q, typename M,
7616 assignOperationOnIterator(ITERATOR &it, const OP& op, const
UT_VoxelArray<S>* a,
7634 int tileNum = it.getLinearTileNum();
7635 UT_VoxelTile<M> *mtile = MASKED ? mask->getLinearTile(tileNum) :
nullptr;
7636 UT_VoxelTile<S> *atile = OPERANDS > 0 ? a->getLinearTile(tileNum) :
nullptr;
7637 UT_VoxelTile<R> *btile = OPERANDS > 1 ? b->getLinearTile(tileNum) :
nullptr;
7638 UT_VoxelTile<Q> *ctile = OPERANDS > 2 ? c->getLinearTile(tileNum) :
nullptr;
7642 if (MASKED && mtile->
isConstant() && ((*mtile)(0, 0, 0) <= ((M) 0.5)))
7657 for (
int z = 0; z < tile->
zres(); z++)
7659 for (
int y = 0; y < tile->
yres(); y++)
7661 for (
int x = 0; x < tile->
xres(); x++)
7663 if (!MASKED || ((*mtile)(x, y, z) > ((M) 0.5)))
7668 cval = (*ctile)(
x,
y,
z);
7671 bval = (*btile)(
x,
y,
z);
7674 aval = (*atile)(
x,
y,
z);
7680 if (USE_SELF) val = (*tile)(
x,
y,
z);
7682 val = conditionalCallOperator<OPERANDS, USE_SELF>(
7683 op,
val, aval, bval, cval);
7692 int ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7693 int binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7694 int cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7695 int minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7700 ainc == 0 && binc == 0 && cinc == 0 && minc == 0)
7721 if (USE_SELF) val = tile->
rawData()[0];
7722 val = conditionalCallOperator<OPERANDS, USE_SELF>(
op,
7723 val, aval, bval, cval);
7733 ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7734 binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7735 cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7736 minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7738 const S* a_array = OPERANDS > 0 ? atile->
rawData() :
nullptr;
7739 const R* b_array = OPERANDS > 1 ? btile->
rawData() :
nullptr;
7740 const Q* c_array = OPERANDS > 2 ? ctile->
rawData() :
nullptr;
7741 const M* m_array = MASKED ? mtile->
rawData() :
nullptr;
7742 T* val_array = tile->
rawData();
7745 for (
int i = 0; i <
n; i++)
7747 if (!MASKED || (*m_array > ((M) 0.5)))
7749 val_array[i] = conditionalCallOperator<OPERANDS, USE_SELF>(
op,
7750 val_array[i], OPERANDS > 0 ? *a_array : aval,
7751 OPERANDS > 1 ? *b_array : bval,
7752 OPERANDS > 2 ? *c_array : cval);
7780 template <
typename T>
7781 template <
typename OP>
7785 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
7786 (*
this,
op,
nullptr,
nullptr,
nullptr,
nullptr);
7789 template <
typename T>
7790 template <
typename OP,
typename S>
7797 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
7798 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
7801 template <
typename T>
7802 template <
typename OP,
typename S,
typename R>
7811 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
7812 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
7815 template <
typename T>
7816 template <
typename OP,
typename S,
typename R,
typename Q>
7827 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
7828 (*
this,
op, &
a, &
b, &
c,
nullptr);
7831 template <
typename T>
7832 template <
typename OP,
typename M>
7839 assignOperationOnIterator<0, true, true, T, OP, float, float, float, M>
7840 (*
this,
op,
nullptr,
nullptr,
nullptr, &
mask);
7843 template <
typename T>
7844 template <
typename OP,
typename S,
typename M>
7853 assignOperationOnIterator<1, true, true, T, OP, S, float, float, M>
7854 (*
this,
op, &
a,
nullptr,
nullptr, &
mask);
7857 template <
typename T>
7858 template <
typename OP,
typename S,
typename R,
typename M>
7869 assignOperationOnIterator<2, true, true, T, OP, S, R, float, M>
7870 (*
this,
op, &
a, &
b,
nullptr, &
mask);
7873 template <
typename T>
7874 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7887 assignOperationOnIterator<3, true, true, T, OP, S, R, Q, M>
7891 template <
typename T>
7892 template <
typename OP,
typename S>
7899 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
7900 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
7903 template <
typename T>
7904 template <
typename OP,
typename S,
typename R>
7913 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
7914 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
7917 template <
typename T>
7918 template <
typename OP,
typename S,
typename R,
typename Q>
7929 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
7930 (*
this,
op, &
a, &
b, &
c,
nullptr);
7933 template <
typename T>
7934 template <
typename OP,
typename S,
typename M>
7943 assignOperationOnIterator<1, true, false, T, OP, S, float, float, M>
7944 (*
this,
op, &
a,
nullptr,
nullptr, &
mask);
7947 template <
typename T>
7948 template <
typename OP,
typename S,
typename R,
typename M>
7959 assignOperationOnIterator<2, true, false, T, OP, S, R, float, M>
7960 (*
this,
op, &
a, &
b,
nullptr, &
mask);
7963 template <
typename T>
7964 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7977 assignOperationOnIterator<3, true, false, T, OP, S, R, Q, M>
7981 template <
typename T>
7982 template <
typename OP>
7992 tile = myArray->getLinearTile(myCurTile);
7997 for (
int z = 0; z < tile->
zres(); z++)
7998 for (
int y = 0; y < tile->
yres(); y++)
7999 for (
int x = 0; x < tile->
xres(); x++)
8003 val = tile->operator()(
x,
y,
z);
8016 op.reduceMany(val, n);
8025 for (
int i = 0; i <
n; i++)
8038 template <
typename T>
8042 myLinearTileNum = -1;
8045 myShouldCompressOnExit =
false;
8048 template <
typename T>
8052 myLinearTileNum = -1;
8055 myShouldCompressOnExit =
false;
8059 template <
typename T>
8060 template <
typename S>
8064 myLinearTileNum = -1;
8067 myShouldCompressOnExit =
false;
8068 setTile(vit, array);
8071 template <
typename T>
8076 template <
typename T>
8082 !myCurTile->xres() || !myCurTile->yres() || !myCurTile->zres())
8088 myPos[0] = myTileStart[0];
8089 myPos[1] = myTileStart[1];
8090 myPos[2] = myTileStart[2];
8092 myTileLocalPos[0] = 0;
8093 myTileLocalPos[1] = 0;
8094 myTileLocalPos[2] = 0;
8096 myTileSize[0] = myCurTile->xres();
8097 myTileSize[1] = myCurTile->yres();
8098 myTileSize[2] = myCurTile->zres();
8103 template <
typename T>
8107 if (getCompressOnExit())
8112 myCurTile->tryCompress(myArray->getCompressionOptions());
8118 template <
typename T>
8119 template <
typename OP>
8123 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
8124 (*
this,
op,
nullptr,
nullptr,
nullptr,
nullptr);
8127 template <
typename T>
8128 template <
typename OP,
typename S>
8135 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
8136 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
8139 template <
typename T>
8140 template <
typename OP,
typename S,
typename R>
8149 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
8150 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
8153 template <
typename T>
8154 template <
typename OP,
typename S,
typename R,
typename Q>
8165 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
8166 (*
this,
op, &
a, &
b, &
c,
nullptr);
8169 template <
typename T>
8170 template <
typename OP,
typename S>
8177 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
8178 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
8181 template <
typename T>
8182 template <
typename OP,
typename S,
typename R>
8191 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
8192 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
8195 template <
typename T>
8196 template <
typename OP,
typename S,
typename R,
typename Q>
8207 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
8208 (*
this,
op, &
a, &
b, &
c,
nullptr);
8211 template <
typename T>
8212 template <
typename OP>
8218 if (!myCurTile->isSimpleCompression())
8221 for (
int z = 0; z < myTileSize[2]; z++)
8222 for (
int y = 0; y < myTileSize[1]; y++)
8223 for (
int x = 0; x < myTileSize[0]; x++)
8227 val = myCurTile->operator()(
x,
y,
z);
8229 if (!op.reduce(val))
8233 else if (myCurTile->isConstant())
8238 val = myCurTile->rawData()[0];
8239 int n = myCurTile->numVoxels();
8241 if (!op.reduceMany(val, n))
8248 val = myCurTile->rawData();
8250 int n = myCurTile->numVoxels();
8251 for (
int i = 0; i <
n; i++)
8253 if (!op.reduce(val[i]))
8264 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8274 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8285 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8290 if (!TestForWrites ||
myDirty)
8299 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8304 if (!DoRead && (prex != 0 || postx != 0))
8306 UT_ASSERT(!
"Voxel probe cannot be padded if set to not read.");
8312 int prepad, postpad;
8316 prepad = (prex - 3) / 4;
8317 postpad = (postx + 3) / 4;
8334 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8363 if (!TestForWrites ||
myDirty)
8376 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8381 bool xout =
false, yout =
false, zout =
false;
8382 bool manualbuild =
false;
8398 if (myMaxValidX <= 0 || myMinValidX >=
myArray->getXRes())
8444 myArray->clampIndex(tx, y, z);
8461 if (xout || manualbuild)
8488 for (i =
myPreX; i < 0; i++)
8498 for (; i < TILESIZE; i++)
8506 for (; i < TILESIZE; i++)
8512 for (; i < TILESIZE +
myPostX; i++)
8525 int xtile, ytile, ztile, tileidx;
8529 xtile = x >> TILEBITS;
8530 ytile = y >> TILEBITS;
8531 ztile = z >> TILEBITS;
8538 tileidx = (ztile *
myArray->getTileRes(1) + ytile) *
myArray->getTileRes(0);
8545 tile =
myArray->getLinearTile(tileidx+xtile-1);
8546 for (i =
myPreX; i < 0; i++)
8557 int resx =
myArray->getXRes();
8566 for (i =
myPreX; i < 0; i++)
8576 int resx =
myArray->getXRes();
8577 int resx2 = resx * 2;
8580 int xpos =
myPreX % resx2;
8592 xpos = resx2 - xpos - 1;
8595 for (i =
myPreX; i < 0; i++)
8608 else if (xpos >= resx)
8621 tile =
myArray->getLinearTile(tileidx+xtile);
8622 value = (*tile)(0, ly, lz);
8625 value =
myArray->getBorderValue();
8628 for (i =
myPreX; i < 0; i++)
8636 int cachelen = TILESIZE;
8637 int resx =
myArray->getXRes();
8654 tile =
myArray->getLinearTile(tileidx+xtile+1);
8655 for (; i <
myPostX && xpos < resx; i++)
8696 else if (xpos >= resx)
8709 tile =
myArray->getLinearTile(tileidx+xtile);
8710 value = (*tile)(tile->
xres()-1, ly, lz);
8713 value =
myArray->getBorderValue();
8723 tile =
myArray->getLinearTile(tileidx+xtile+1);
8734 tile =
myArray->getLinearTile(tileidx+xtile);
8748 for (i = topad; i > 0; i--)
8763 value =
myArray->getBorderValue();
8765 for (i = topad; i > 0; i--)
8773 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8801 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8824 int xtile, ytile, ztile,
y,
z;
8827 xtile = myMinValidX >> TILEBITS;
8828 ytile =
myY >> TILEBITS;
8829 ztile =
myZ >> TILEBITS;
8833 tile =
myArray->getTile(xtile, ytile, ztile);
8842 template <
typename T>
8848 template <
typename T>
8853 template <
typename T>
8858 myLines[0][0].setConstArray(vox, -1, 1);
8859 myLines[0][1].setConstArray(vox, -1, 1);
8860 myLines[0][2].setConstArray(vox, -1, 1);
8862 myLines[1][0].setConstArray(vox, -1, 1);
8863 myLines[1][1].setConstArray(vox, -1, 1);
8864 myLines[1][2].setConstArray(vox, -1, 1);
8866 myLines[2][0].setConstArray(vox, -1, 1);
8867 myLines[2][1].setConstArray(vox, -1, 1);
8868 myLines[2][2].setConstArray(vox, -1, 1);
8873 template <
typename T>
8880 myLines[0][1].setConstArray(vox, -1, 1);
8882 myLines[1][0].setConstArray(vox, 0, 0);
8883 myLines[1][1].setConstArray(vox, -1, 1);
8884 myLines[1][2].setConstArray(vox, 0, 0);
8886 myLines[2][1].setConstArray(vox, -1, 1);
8891 template <
typename T>
8895 if (myValid && myZ == z)
8900 if (x < myMaxValidX && x == myX+1)
8903 myLines[0][0].advanceX();
8904 myLines[0][1].advanceX();
8905 myLines[0][2].advanceX();
8907 myLines[1][0].advanceX();
8908 myLines[1][1].advanceX();
8909 myLines[1][2].advanceX();
8911 myLines[2][0].advanceX();
8912 myLines[2][1].advanceX();
8913 myLines[2][2].advanceX();
8928 rotateLines(myLines[0][0], myLines[1][0], myLines[2][0]);
8929 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
8930 rotateLines(myLines[0][2], myLines[1][2], myLines[2][2]);
8934 myLines[0][0].resetX(x);
8935 myLines[0][1].resetX(x);
8936 myLines[0][2].resetX(x);
8938 myLines[1][0].resetX(x);
8939 myLines[1][1].resetX(x);
8940 myLines[1][2].resetX(x);
8943 myLines[2][0].setIndex(x, y+1, z-1);
8944 myLines[2][1].setIndex(x, y+1, z);
8945 myLines[2][2].setIndex(x, y+1, z+1);
8957 myLines[0][0].setIndex(x, y-1, z-1);
8958 myLines[0][1].setIndex(x, y-1, z);
8959 myLines[0][2].setIndex(x, y-1, z+1);
8961 myLines[1][0].setIndex(x, y, z-1);
8962 myLines[1][1].setIndex(x, y, z);
8963 myLines[1][2].setIndex(x, y, z+1);
8965 myLines[2][0].setIndex(x, y+1, z-1);
8966 myLines[2][1].setIndex(x, y+1, z);
8967 myLines[2][2].setIndex(x, y+1, z+1);
8974 myMinValidX = myLines[1][1].myMinValidX;
8975 myMaxValidX = myLines[1][1].myMaxValidX;
8980 template <
typename T>
8984 if (myValid && myZ == z)
8989 if (x < myMaxValidX && x == myX+1)
8992 myLines[0][1].advanceX();
8994 myLines[1][0].advanceX();
8995 myLines[1][1].advanceX();
8996 myLines[1][2].advanceX();
8998 myLines[2][1].advanceX();
9012 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
9014 myLines[0][1].resetX(x);
9015 myLines[1][1].resetX(x);
9017 myLines[1][0].setIndex(x, y, z-1);
9018 myLines[1][2].setIndex(x, y, z+1);
9020 myLines[2][1].setIndex(x, y+1, z);
9029 myLines[0][1].setIndex(x, y-1, z);
9031 myLines[1][0].setIndex(x, y, z-1);
9032 myLines[1][1].setIndex(x, y, z);
9033 myLines[1][2].setIndex(x, y, z+1);
9035 myLines[2][1].setIndex(x, y+1, z);
9042 myMinValidX = myLines[1][1].myMinValidX;
9043 myMaxValidX = myLines[1][1].myMaxValidX;
9048 template <
typename T>
9063 Px *= 0.5 * invvoxelsize.
x();
9066 Py *= 0.5 * invvoxelsize.
y();
9069 Pz *= 0.5 * invvoxelsize.
z();
9077 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
9082 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
9087 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
9092 Pxy *= 0.25 * invvoxelsize.
x() * invvoxelsize.
y();
9096 Pxz *= 0.25 * invvoxelsize.
x() * invvoxelsize.
z();
9100 Pyz *= 0.25 * invvoxelsize.
y() * invvoxelsize.
z();
9103 gradlen = SYSsqrt(Px * Px + Py * Py + Pz * Pz);
9111 k = Px*Px * (Pyy + Pzz) + Py*Py * (Pxx + Pzz) + Pz*Pz * (Pxx + Pyy);
9112 k -= 2 * (Pxy*Px*Py + Pyz*Py*Pz + Pxz*Px*Pz);
9118 k /= gradlen * gradlen * gradlen;
9132 template <
typename T>
9145 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
9150 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
9155 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
9157 return Pxx + Pyy + Pzz;
9160 template <
typename T>
9166 T *tmpcache, *tmpalloc;
9195 template <
typename T>
9201 template <
typename T>
9207 template <
typename T>
9212 myLines[0][0].setConstArray(vx, 0, 1);
9215 myLines[1][0].setConstArray(vy, 0, 0);
9216 myLines[1][1].setConstArray(vy, 0, 0);
9218 myLines[2][0].setConstArray(vz, 0, 0);
9219 myLines[2][1].setConstArray(vz, 0, 0);
9224 template <
typename T>
9230 myInvVoxelSize /= myVoxelSize;
9233 template <
typename T>
9237 if (myValid && myZ == z)
9242 if (x < myMaxValidX && x == myX+1)
9245 myLines[0][0].advanceX();
9247 myLines[1][0].advanceX();
9248 myLines[1][1].advanceX();
9250 myLines[2][0].advanceX();
9251 myLines[2][1].advanceX();
9264 swapLines(myLines[1][0], myLines[1][1]);
9266 myLines[1][0].resetX(x);
9269 myLines[0][0].setIndex(x, y, z);
9270 myLines[1][1].setIndex(x, y+1, z);
9272 myLines[2][0].setIndex(x, y, z);
9273 myLines[2][1].setIndex(x, y, z+1);
9282 myLines[0][0].setIndex(x, y, z);
9284 myLines[1][0].setIndex(x, y, z);
9285 myLines[1][1].setIndex(x, y+1, z);
9287 myLines[2][0].setIndex(x, y, z);
9288 myLines[2][1].setIndex(x, y, z+1);
9295 myMinValidX = myLines[0][0].myMinValidX;
9296 myMaxValidX = myLines[0][0].myMaxValidX;
9301 template <
typename T>
9306 T *tmpcache, *tmpalloc;
9329 template <
typename T,
int XStep,
int YStep,
int ZStep>
9333 int prex = (XStep < 0) ? XStep : 0;
9334 int postx = (XStep > 0) ? XStep : 0;
9349 template <
typename T,
int XStep,
int YStep,
int ZStep>
9364 result |= myLines[0][0].setIndex(x, y, z);
9367 result |= myLines[1][0].setIndex(x, y+1, z);
9369 result |= myLines[1][1].setIndex(x, y+1, z+1);
9372 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.
#define COUNT_NONZERO(VAL, COUNT)
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
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, float failrelative, float warnrelative, ROI roi={}, int nthreads=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)
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)
GLint GLint GLsizei GLint GLenum GLenum type
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.
section HDK_USDHydraEventScripts USD a python event script is run This gives the render delegate the opportunity to perform any required external initialization or other renderer specific action that may be required The script is found by searching the HOUDINI_SCRIPT_PATH for a file named scene DelegateName_Events py Within this file should be two functions
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
T avgNonZero(const UT_Vector3 &pos, const UT_Filter &filter, fpreal radius, int clampaxis=-1) const
average of non-zero values of the voxel array.
SYS_FORCE_INLINE T lerpVoxelAxis(int x, int y, int z, float fx, float fy, float fz) const
void setBorderScale(T scalex, T scaley, T scalez)
void avgNonZero(int pstart[3], int pend[3], int start[3], T &result)
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