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++)
1399 setValue(dstx+x, dsty+y, dstz+z,
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;
2819 w.
jid<ScalarType>());
2820 for (
int z = 0; z < zres(); z++)
2821 for (
int y = 0; y < yres(); y++)
2822 for (
int x = 0; x < xres(); x++)
2824 value = (*this)(
x,
y,
z);
2825 if constexpr (tuple_size == 1)
2831 for (
int i = 0; i < tuple_size; i++)
2843 char type = myCompressionType;
2845 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2853 switch (myCompressionType)
2856 len = myRes[2] * myRes[1] * myRes[0];
2860 case COMPRESS_FPREAL16:
2865 case COMPRESS_RAWFULL:
2866 len = TILESIZE * TILESIZE * myRes[2];
2870 case COMPRESS_CONSTANT:
2871 if constexpr (tuple_size == 1)
2882 template <
typename T>
2912 if (type >= 0 && type < compress.
entries())
2915 type = compress(type);
2918 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2922 if (type >= COMPRESS_ENGINE)
2925 myCompressionType =
type;
2927 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2930 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2936 bool engine_ok = engine->
load(p, *
this);
2938 return it.
atEnd() && engine_ok;
2949 myCompressionType =
type;
2951 switch (myCompressionType)
2954 len = myRes[2] * myRes[1] * myRes[0];
2961 case COMPRESS_FPREAL16:
2968 case COMPRESS_RAWFULL:
2969 len = TILESIZE * TILESIZE * myRes[2];
2976 case COMPRESS_CONSTANT:
2977 if (!inlineConstant())
2979 if constexpr (tuple_size == 1)
2996 template <
typename T>
3000 int16 ntype = getCompressionEngines().entries();
3003 ntype += COMPRESS_ENGINE;
3005 UTwrite(os, &ntype);
3013 ntype -= COMPRESS_ENGINE;
3014 for (i = 0; i < ntype; i++)
3020 template <
typename T>
3031 for (i = 0; i < ntype; i++)
3037 compress.
append(COMPRESS_RAW);
3038 else if (name ==
"rawfull")
3039 compress.
append(COMPRESS_RAWFULL);
3040 else if (name ==
"constant")
3041 compress.
append(COMPRESS_CONSTANT);
3042 else if (name ==
"fpreal16")
3043 compress.
append(COMPRESS_FPREAL16);
3046 idx = lookupCompressionEngine(name);
3056 template <
typename T>
3060 int16 ntype = getCompressionEngines().entries();
3064 ntype += COMPRESS_ENGINE;
3073 ntype -= COMPRESS_ENGINE;
3074 for (i = 0; i < ntype; i++)
3083 template <
typename T>
3097 if (!buffer.
strcmp(
"raw"))
3098 compress.
append(COMPRESS_RAW);
3099 else if (!buffer.
strcmp(
"rawfull"))
3100 compress.
append(COMPRESS_RAWFULL);
3101 else if (!buffer.
strcmp(
"constant"))
3102 compress.
append(COMPRESS_CONSTANT);
3103 else if (!buffer.
strcmp(
"fpreal16"))
3104 compress.
append(COMPRESS_FPREAL16);
3107 idx = lookupCompressionEngine(buffer.
buffer());
3124 template <
typename T>
3139 myBorderScale[0] = 0;
3140 myBorderScale[1] = 0;
3141 myBorderScale[2] = 0;
3145 mySharedMemView = 0;
3148 template <
typename T>
3154 template <
typename T>
3168 mySharedMemView = 0;
3173 template <
typename T>
3180 vit.splitByTile(info);
3181 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3183 int i = vit.getLinearTileNum();
3184 myTiles[i] = src.myTiles[i];
3188 template <
typename T>
3196 myBorderScale[0] = src.myBorderScale[0];
3197 myBorderScale[1] = src.myBorderScale[1];
3198 myBorderScale[2] = src.myBorderScale[2];
3199 myBorderValue = src.myBorderValue;
3200 myBorderType = src.myBorderType;
3202 myCompressionOptions = src.myCompressionOptions;
3206 size(src.myRes[0], src.myRes[1], src.myRes[2],
false);
3216 #define __MULTITHREADED_STRUCTORS__
3217 template <
typename T>
3221 #ifdef __MULTITHREADED_STRUCTORS__
3226 for(
int i = range.begin(); i < range.end(); i++)
3228 myTiles[i].~UT_VoxelTile<
T>();
3231 operator delete(myTiles, std::nothrow);
3237 myTileRes[0] = myTileRes[1] = myTileRes[2] = 0;
3238 myRes[0] = myRes[1] = myRes[2] = 0;
3240 delete mySharedMemView;
3241 mySharedMemView = 0;
3247 template <
typename T>
3252 if (myRes[0] == xres && myRes[1] == yres && myRes[2] == zres)
3267 tile_res[0] = (xres + TILEMASK) >> TILEBITS;
3268 tile_res[1] = (yres + TILEMASK) >> TILEBITS;
3269 tile_res[2] = (zres + TILEMASK) >> TILEBITS;
3271 exint ntiles = ((
exint)tile_res[0]) * tile_res[1] * tile_res[2];
3274 #ifdef __MULTITHREADED_STRUCTORS__
3288 for(
int k = range.begin(); k < range.end(); k++)
3293 int tilex = k % tile_res[0];
3294 int k2 = k / tile_res[0];
3295 int tiley = k2 % tile_res[1];
3296 int tilez = k2 / tile_res[1];
3297 myTiles[k].
setRes(
SYSmin(TILESIZE, xres - tilex * TILESIZE),
3298 SYSmin(TILESIZE, yres - tiley * TILESIZE),
3299 SYSmin(TILESIZE, zres - tilez * TILESIZE));
3313 myInvRes.x() = 1.0f / myRes[0];
3315 myInvRes.y() = 1.0f / myRes[1];
3317 myInvRes.z() = 1.0f / myRes[2];
3319 myTileRes[0] = tile_res[0];
3320 myTileRes[1] = tile_res[1];
3321 myTileRes[2] = tile_res[2];
3323 #ifndef __MULTITHREADED_STRUCTORS__
3325 for (
int tz = 0; tz < myTileRes[2]; tz++)
3328 if (tz < myTileRes[2]-1)
3331 zr = zres - tz * TILESIZE;
3333 for (
int ty = 0; ty < myTileRes[1]; ty++)
3336 if (ty < myTileRes[1]-1)
3339 yr = yres - ty * TILESIZE;
3341 int tx, xr = TILESIZE;
3342 for (tx = 0; tx < myTileRes[0]-1; tx++)
3344 myTiles[i].
setRes(xr, yr, zr);
3348 xr = xres - tx * TILESIZE;
3349 myTiles[i].setRes(xr, yr, zr);
3359 template <
typename T>
3368 myBorderType = src.myBorderType;
3369 myBorderScale[0] = src.myBorderScale[0];
3370 myBorderScale[1] = src.myBorderScale[1];
3371 myBorderScale[2] = src.myBorderScale[2];
3372 myBorderValue = src.myBorderValue;
3375 myCompressionOptions = src.myCompressionOptions;
3378 template <
typename T>
3382 int64 mem = inclusive ?
sizeof(*this) : 0;
3384 int ntiles = numTiles();
3385 for (
int i = 0; i < ntiles; i++)
3386 mem += myTiles[i].getMemoryUsage(
true);
3389 mem += mySharedMem->getMemoryUsage(
true);
3391 if (mySharedMemView)
3392 mem += mySharedMemView->getMemoryUsage(
true);
3397 template <
typename T>
3404 vit.setPartialRange(info.
job(), info.
numJobs());
3405 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3407 int i = vit.getLinearTileNum();
3408 myTiles[i].makeConstant(t);
3412 template <
typename T>
3421 ntiles = numTiles();
3422 for (i = 0; i < ntiles; i++)
3424 if (!myTiles[i].isConstant())
3432 cval = myTiles[i].rawConstVal();
3452 template <
typename T>
3458 ntiles = numTiles();
3459 for (i = 0; i < ntiles; i++)
3461 if (myTiles[i].hasNan())
3470 template <
typename T>
3476 pos.
x() *= myRes[0];
3477 pos.
y() *= myRes[1];
3478 pos.
z() *= myRes[2];
3483 return lerpVoxelCoord(pos);
3486 template <
typename T>
3494 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3496 return lerpVoxel(x, y, z, fx, fy, fz);
3499 template <
typename T>
3500 template <
int AXIS2D>
3508 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3510 return lerpVoxelAxis<AXIS2D>(
x,
y,
z, fx, fy, fz);
3513 template <
typename T>
3516 float fx,
float fy,
float fz)
const
3519 T vx, vx1, vy, vy1, vz;
3523 if ( !((x | y | z) < 0) &&
3524 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3537 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3540 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3542 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
3556 (*
this)(x+1, y+1, z),
3563 (*
this)(x+1, y, z+1),
3567 (*
this)(x+1, y+1, z+1),
3610 template <
typename T>
3611 template <
int AXIS2D>
3614 float fx,
float fy,
float fz)
const
3617 T vx, vx1, vy, vy1, vz;
3619 int lesscomp = 0, greatercomp = -1;
3624 greatercomp &= (x - myRes[0]+1);
3629 greatercomp &= (y - myRes[1]+1);
3634 greatercomp &= (z - myRes[2]+1);
3639 if ( !(lesscomp < 0) && (greatercomp < 0) )
3647 if ((AXIS2D == 0 || xm != TILEMASK) &&
3648 (AXIS2D == 1 || ym != TILEMASK) &&
3649 (AXIS2D == 2 || zm != TILEMASK))
3652 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3653 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3654 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3656 vz = tile->template lerpAxis<AXIS2D>(xm, ym, zm, fx, fy, fz);
3670 vx = (*this)(
x,
y,
z);
3677 (*
this)(x+1, y+1, z),
3680 vx1 = (*this)(
x, y+1,
z);
3692 (*
this)(x+1, y, z+1),
3695 vx = (*this)(
x,
y, z+1);
3702 (*
this)(x+1, y+1, z+1),
3705 vx1 = (*this)(
x, y+1, z+1);
3779 template <
typename T>
3786 pos.
x() *= myRes[0];
3787 pos.
y() *= myRes[1];
3788 pos.
z() *= myRes[2];
3793 lerpVoxelCoordMinMax(lerp, lmin, lmax, pos);
3796 template <
typename T>
3805 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3807 lerpVoxelMinMax(lerp, lmin, lmax, x, y, z, fx, fy, fz);
3811 template <
typename T>
3812 template <
int AXIS2D>
3821 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3823 lerpVoxelMinMaxAxis<AXIS2D>(
lerp, lmin, lmax,
x,
y,
z, fx, fy, fz);
3827 template <
typename T>
3831 int x,
int y,
int z,
3832 float fx,
float fy,
float fz)
const
3836 if (extractSample(x, y, z, samples))
3838 lerp = smin = smax = samples[0];
3842 lerp = lerpSample(samples, fx, fy, fz);
3846 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3848 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3851 smin =
SYSmin(smin, smin1);
3852 smax =
SYSmax(smax, smax1);
3855 template <
typename T>
3856 template <
int AXIS2D>
3860 int x,
int y,
int z,
3861 float fx,
float fy,
float fz)
const
3865 if (extractSampleAxis<AXIS2D>(x, y, z, samples))
3867 lerp = smin = smax = samples[0];
3871 lerp = lerpSampleAxis<AXIS2D>(
samples, fx, fy, fz);
3874 SYSminmax(samples[0], samples[2], samples[4], samples[6],
3876 else if (AXIS2D == 1)
3877 SYSminmax(samples[0], samples[1], samples[4], samples[5],
3879 else if (AXIS2D == 2)
3880 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3886 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3888 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3891 smin =
SYSmin(smin, smin1);
3892 smax =
SYSmax(smax, smax1);
3896 template <
typename T>
3903 if ( !((x | y | z) < 0) &&
3904 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3917 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3920 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3929 samples[0] = (*this)(
x,
y,
z);
3930 samples[1] = (*this)(x+1,
y,
z);
3931 samples[2+0] = (*this)(
x, y+1,
z);
3932 samples[2+1] = (*this)(x+1, y+1,
z);
3933 samples[4+0] = (*this)(
x,
y, z+1);
3934 samples[4+1] = (*this)(x+1,
y, z+1);
3935 samples[4+2+0] = (*this)(
x, y+1, z+1);
3936 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3943 samples[2+0] =
getValue(x, y+1, z);
3944 samples[2+1] =
getValue(x+1, y+1, z);
3945 samples[4+0] =
getValue(x, y, z+1);
3946 samples[4+1] =
getValue(x+1, y, z+1);
3947 samples[4+2+0] =
getValue(x, y+1, z+1);
3948 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3955 template <
typename T>
3956 template <
int AXIS2D>
3963 int lesscomp = 0, greatercomp = -1;
3968 greatercomp &= (x - myRes[0]+1);
3973 greatercomp &= (y - myRes[1]+1);
3978 greatercomp &= (z - myRes[2]+1);
3983 if ( !(lesscomp < 0) && (greatercomp < 0) )
3991 if ((AXIS2D == 0 || xm != TILEMASK) &&
3992 (AXIS2D == 1 || ym != TILEMASK) &&
3993 (AXIS2D == 2 || zm != TILEMASK))
3996 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3997 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3998 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
4000 return tile->template extractSampleAxis<AXIS2D>(xm, ym, zm,
samples);
4007 samples[0] = (*this)(
x,
y,
z);
4009 samples[1] = (*this)(x+1,
y,
z);
4012 samples[2+0] = (*this)(
x, y+1,
z);
4014 samples[2+1] = (*this)(x+1, y+1,
z);
4018 samples[4+0] = (*this)(
x,
y, z+1);
4020 samples[4+1] = (*this)(x+1,
y, z+1);
4023 samples[4+2+0] = (*this)(
x, y+1, z+1);
4025 samples[4+2+1] = (*this)(x+1, y+1, z+1);
4037 samples[2+0] =
getValue(x, y+1, z);
4039 samples[2+1] =
getValue(x+1, y+1, z);
4043 samples[4+0] =
getValue(x, y, z+1);
4045 samples[4+1] =
getValue(x+1, y, z+1);
4048 samples[4+2+0] =
getValue(x, y+1, z+1);
4050 samples[4+2+1] =
getValue(x+1, y+1, z+1);
4058 template <
typename T>
4065 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
4066 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4079 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4082 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4091 samples[0] = (*this)(x-1,
y,
z);
4092 samples[1] = (*this)(x+1,
y,
z);
4093 samples[2+0] = (*this)(
x, y-1,
z);
4094 samples[2+1] = (*this)(
x, y+1,
z);
4095 samples[4+0] = (*this)(
x,
y, z-1);
4096 samples[4+1] = (*this)(
x,
y, z+1);
4097 samples[6] = (*this)(
x,
y,
z);
4104 samples[2+0] =
getValue(x, y-1, z);
4105 samples[2+1] =
getValue(x, y+1, z);
4106 samples[4+0] =
getValue(x, y, z-1);
4107 samples[4+1] =
getValue(x, y, z+1);
4118 template <
typename T>
4125 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
4126 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4139 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4142 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4144 return tile->extractSampleCube(xm, ym, zm, samples);
4152 for (
int dz = -1; dz <= 1; dz++)
4154 for (
int dy = -1; dy <= 1; dy++)
4156 for (
int dx = -1; dx <= 1; dx++)
4158 samples[sampidx++] = (*this)(x+dx, y+dy, z+dz);
4167 for (
int dz = -1; dz <= 1; dz++)
4169 for (
int dy = -1; dy <= 1; dy++)
4171 for (
int dx = -1; dx <= 1; dx++)
4173 samples[sampidx++] =
getValue(x+dx, y+dy, z+dz);
4183 template <
typename T>
4186 float fx,
float fy,
float fz)
const
4190 T vx, vx1, vy, vy1, vz;
4220 v4uf a,
b, vfx, vfy, vfz;
4222 a =
v4uf(&samples[0]);
4223 b =
v4uf(&samples[4]);
4244 template <
typename T>
4245 template <
int AXIS2D>
4248 float fx,
float fy,
float fz)
const
4251 T vx, vx1, vy, vy1, vz;
4304 template <
typename T>
4314 pos.
x() *= myRes[0];
4315 pos.
y() *= myRes[1];
4316 pos.
z() *= myRes[2];
4323 SYSfastSplitFloat(fx, x);
4325 SYSfastSplitFloat(fy, y);
4327 SYSfastSplitFloat(fz, z);
4330 T vx, vx1, vy, vy1, vz;
4346 if ( !((x | y | z) < 0) &&
4347 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4359 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4362 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4364 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
4378 (*
this)(x+1, y+1, z),
4385 (*
this)(x+1, y, z+1),
4389 (*
this)(x+1, y+1, z+1),
4433 template <
typename T>
4443 pos *=
v4uf((
float) myRes[0], (
float) myRes[1], (
float) myRes[2], 0.0
f);
4472 if ( (x > 0) & (y > 0) & (z > 0) &
4473 (x < myRes[0]-1) & (y < myRes[1]-1) & (z < myRes[2]-1) &
4474 (xm != TILEMASK) & (ym != TILEMASK) & (zm != TILEMASK) )
4483 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4485 return tile->
lerp(pos, xm, ym, zm);
4499 fx = pos.
swizzle<0, 0, 0, 0>();
4500 fy = pos.
swizzle<1, 1, 1, 1>();
4501 fz = pos.
swizzle<2, 2, 2, 2>();
4519 firstTile(
int &
start,
int &
end,
int res)
4530 nextTile(
int &tile,
int &pstart,
int &start,
int &end,
int res)
4540 tile = pstart >> TILEBITS;
4541 pend =
SYSmin((tile+1) * TILESIZE, end, res);
4551 template <
typename T>
4554 fpreal radius,
int clampaxis)
const
4560 const float *weights[3];
4562 int start[3], end[3],
size[3];
4563 int pstart[3], pend[3];
4570 return myBorderValue;
4574 switch (myBorderType)
4585 for (i = 0; i < 3; i++)
4593 memset(&result, 0,
sizeof(result));
4600 for (i = 0; i < 3; i++)
4602 tpos[i] = tpos[i]*myRes[i];
4603 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4607 start[i] = win[i].
getStart() % myRes[i];
4613 end[i] = start[i] + size[i];
4618 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4619 while (pstart[2] < end[2])
4621 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4622 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4623 while (pstart[1] < end[1])
4625 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4626 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4627 while (pstart[0] < end[0])
4629 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4630 tile = getTile(tx, ty, tz);
4632 tile->
weightedSum(pstart, pend, weights, start, result);
4633 pstart[0] = pend[0];
4635 pstart[1] = pend[1];
4637 pstart[2] = pend[2];
4642 result += (1-visible)*myBorderValue;
4648 template <
typename T>
4651 fpreal radius,
int clampaxis)
const
4657 int start[3], end[3],
size[3];
4658 int pstart[3], pend[3];
4665 return myBorderValue;
4669 switch (myBorderType)
4680 for (i = 0; i < 3; i++)
4688 memset(&result, 0,
sizeof(result));
4694 for (i = 0; i < 3; i++)
4696 tpos[i] = tpos[i]*myRes[i];
4697 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4700 start[i] = win[i].
getStart() % myRes[i];
4706 end[i] = start[i] + size[i];
4710 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4711 while (pstart[2] < end[2])
4713 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4714 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4715 while (pstart[1] < end[1])
4717 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4718 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4719 while (pstart[0] < end[0])
4721 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4722 tile = getTile(tx, ty, tz);
4724 tile->
avgNonZero(pstart, pend, start, result);
4725 pstart[0] = pend[0];
4727 pstart[1] = pend[1];
4729 pstart[2] = pend[2];
4735 template <
typename T>
4739 float filterwidthscale,
4751 radius *= 0.5 * filterwidthscale;
4753 resamplethread(src, filter, radius, clampaxis);
4758 template <
typename T>
4759 template <
typename OP>
4766 for (
int tileidx =
range.begin(); tileidx !=
range.end(); tileidx++)
4783 template <
typename T>
4790 if (getXRes() == 1 && ystride == 1)
4792 flattenPartialAxis<0>(flatarray, zstride, info);
4794 else if (getYRes() == 1 && zstride == ystride)
4796 flattenPartialAxis<1>(flatarray, zstride, info);
4798 else if (getZRes() == 1)
4800 flattenPartialAxis<2>(flatarray, ystride, info);
4814 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4820 template <
typename T>
4821 template <
int AXIS2D>
4828 const int ax = (AXIS2D == 0) ? 1 : 0;
4829 const int ay = (AXIS2D == 2) ? 1 : 2;
4830 int tileidx[3] = { 0, 0, 0 };
4835 exint ystart = tiley * TILESIZE;
4836 if (ystart >= getRes(ay))
4839 T *stripe = &flatarray[ystart * ystride];
4841 int yres =
SYSmin(getRes(ay) - ystart, TILESIZE);
4843 for (
int tilex = 0, ntilex = getTileRes(ax); tilex < ntilex; tilex++)
4845 tileidx[ax] = tilex;
4846 tileidx[ay] = tiley;
4847 auto tile = getTile(tileidx[0], tileidx[1], tileidx[2]);
4849 int xres = tile->getRes(ax);
4850 T *stripey = stripe;
4851 if (tile->isConstant())
4853 const T *srcdata = tile->rawData();
4855 for (
int y = 0; y < yres; y++)
4857 for (
int x = 0; x < xres; x++)
4859 memcpy(&stripey[x], srcdata,
sizeof(
T));
4864 else if (tile->isSimpleCompression())
4866 const T *srcdata = tile->rawData();
4868 if (xres != TILESIZE)
4870 for (
int y = 0; y < yres; y++)
4872 memcpy(stripey, srcdata,
sizeof(
T) * xres);
4879 for (
int y = 0; y < yres; y++)
4881 memcpy(stripey, srcdata,
sizeof(
T) * TILESIZE);
4882 srcdata += TILESIZE;
4889 for (
int y = 0; y < yres; y++)
4891 int idx[3] = { 0, 0, 0 };
4893 for (
int x = 0; x < xres; x++)
4896 stripey[
x] = (*tile)(idx[0], idx[1], idx[2]);
4926 int idx = (vit.
x() + vit.
y()*ystride + vit.
z()*zstride) * 4;
4929 flatarray[idx+1] = (
uint8)
SYSclamp(v.
y() * 255.0f, 0.0f, 255.0f);
4930 flatarray[idx+2] = (
uint8)
SYSclamp(v.
z() * 255.0f, 0.0f, 255.0f);
4931 flatarray[idx+3] = (
uint8)
SYSclamp(v.
w() * 255.0f, 0.0f, 255.0f);
4935 template <
typename T>
4941 UT_ASSERT(!
"This template requires specific instantiations.");
4960 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4963 template <
typename T>
4969 UT_ASSERT(!
"This template requires specific instantiations.");
5004 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] =
v;
5008 template <
typename T>
5014 UT_ASSERT(!
"This template requires specific instantiations.");
5018 template <
typename T>
5032 vit.
setValue(flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride]);
5036 template <
typename T>
5037 template <
int SLICE,
typename S>
5041 int slice_res = getRes(SLICE);
5043 if (slice < 0 || slice >= slice_res ||
5044 (half_slice && slice == slice_res - 1))
5047 constexpr
int AXIS1 = SLICE == 0 ? 2 : 0;
5048 constexpr
int AXIS2 = SLICE == 1 ? 2 : 1;
5051 int a1_res = getRes(AXIS1);
5053 int a1_tiles = getTileRes(AXIS1);
5054 int a2_tiles = getTileRes(AXIS2);
5055 int ntiles = a1_tiles * a2_tiles;
5058 int tile_stride2 = (a1_res << TILEBITS);
5059 int tile_stride1 = TILESIZE;
5061 int tile_slice = (slice >> TILEBITS);
5062 int local_slice = (slice & TILEMASK);
5065 bool half_slice_st = half_slice && (local_slice != TILEMASK);
5068 bool half_slice_tb =
false;
5080 auto set_functor = [&](
const UT_VoxelTile<T>* tile,
int idx[3],
int vidx)
5084 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
5086 dstdata[vidx] = 0.5f * (dstdata[vidx] +
5087 (*tile)(idx[0], idx[1], idx[2]));
5090 else if (half_slice_tb)
5091 dstdata[vidx] = 0.5f * (dstdata[vidx] +
5092 (*tile)(idx[0], idx[1], idx[2]));
5094 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
5102 is[SLICE] = tile_slice;
5105 is_local[SLICE] = local_slice;
5107 for (
int i =
range.begin(); i <
range.end(); i++)
5110 is[AXIS1] = i % a1_tiles;
5111 is[AXIS2] = i / a1_tiles;
5115 int a1_tile_res = tile->
getRes(AXIS1);
5116 int a2_tile_res = tile->
getRes(AXIS2);
5118 int vcounter = is[AXIS2] * tile_stride2 + is[AXIS1] * tile_stride1;
5120 for (is_local[AXIS2] = 0; is_local[AXIS2] < a2_tile_res;
5123 for (is_local[AXIS1] = 0; is_local[AXIS1] < a1_tile_res;
5126 set_functor(tile, is_local, vcounter);
5130 vcounter += a1_res - a1_tile_res;
5140 if (half_slice && !half_slice_st)
5142 half_slice_tb =
true;
5151 template <
typename T>
5152 template <
typename S>
5157 for (
int i = 0; i < tilelist.
entries(); i++)
5159 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5162 tile->
flatten(dstdata, stride);
5168 template <
typename T>
5169 template <
typename S,
typename IDX>
5172 const IDX *ix,
const IDX *iy,
const IDX *iz,
5177 for (
auto && tiledata : tilelist)
5179 int tileidx = tiledata.tileidx;
5180 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5185 if (tilevoxel == tiledata.numvoxel)
5188 tile->
flatten(dstdata, stride);
5189 dstdata += tiledata.numvoxel *
stride;
5190 srcidx += tiledata.numvoxel;
5195 int basex, basey, basez;
5196 linearTileToXYZ(tileidx, basex, basey, basez);
5208 for (
int i = 0; i < tiledata.numvoxel; i++)
5217 int w = tile->
xres();
5218 int h = tile->
yres();
5219 for (
int i = 0; i < tiledata.numvoxel; i++)
5221 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5222 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5223 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5224 *dstdata = src[ (ix[srcidx] - basex)
5225 + (iy[srcidx] - basey) * w
5226 + (iz[srcidx] - basez) * w * h];
5234 for (
int i = 0; i < tiledata.numvoxel; i++)
5236 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5237 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5238 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5239 *dstdata = (*tile)(ix[srcidx] - basex,
5241 iz[srcidx] - basez);
5251 template <
typename T>
5252 template <
typename S>
5257 bool docompress = getCompressionOptions().compressionEnabled();
5258 for (
int i = 0; i < tilelist.
entries(); i++)
5260 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5271 template <
typename T>
5272 template <
typename S,
typename IDX>
5275 const IDX *ix,
const IDX *iy,
const IDX *iz,
5278 bool docompress = getCompressionOptions().compressionEnabled();
5281 for (
auto && tiledata : tilelist)
5283 int tileidx = tiledata.tileidx;
5284 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5289 if (tilevoxel == tiledata.numvoxel)
5292 srcdata += tiledata.numvoxel *
stride;
5293 srcidx += tiledata.numvoxel;
5298 int basex, basey, basez;
5299 linearTileToXYZ(tileidx, basex, basey, basez);
5305 for (
int i = 0; i < tiledata.numvoxel; i++)
5307 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5308 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5309 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5363 template <
typename T>
5366 int xoff,
int yoff,
int zoff)
5474 template <
typename T>
5477 int tileoffy,
int tileoffz)
5487 for (
int i = range.begin(); i < range.end(); i++)
5502 && tile->
zres() == srctile->
zres())
5507 UTswap(tile->myCompressionType, srctile->myCompressionType);
5508 UTswap(tile->myForeignData, srctile->myForeignData);
5513 int offv[] = {(xyz[0] + tileoffx) * TILESIZE,
5514 (xyz[1] + tileoffy) * TILESIZE,
5515 (xyz[2] + tileoffz) * TILESIZE};
5516 for (
int z = 0; z < tile->
zres(); z++)
5518 for (
int y = 0; y < tile->
yres(); y++)
5520 for (
int x = 0; x < tile->
xres(); x++)
5538 const int off[] = {tileoffx, tileoffy, tileoffz};
5547 for (
int i = range.begin(); i < range.end(); i++)
5555 bool outside =
false;
5556 for (
int j = 0;
j < 3;
j++)
5559 outside = outside || (xyz[
j] < 0 || xyz[
j] >= src_tileres[
j]);
5564 if (outside && const_src_border)
5571 int offv[] = {xyz[0] * TILESIZE, xyz[1] * TILESIZE, xyz[2] * TILESIZE};
5572 for (
int z = 0; z < tile->
zres(); z++)
5574 for (
int y = 0; y < tile->
yres(); y++)
5576 for (
int x = 0; x < tile->
xres(); x++)
5590 template <
typename T>
5593 int offx,
int offy,
int offz)
5618 copyWithOffsetInternal(src, offx, offy, offz);
5621 template <
typename T>
5624 int offx,
int offy,
int offz,
5629 bool can_copy_tiles = ((offx & TILEMASK) == 0) && ((offy & TILEMASK) == 0)
5630 && ((offz & TILEMASK) == 0);
5654 for (
int i = 0; i < 3; i++)
5656 srctileidx(i) = vit.
myTilePos[i] + (off(i) >> TILEBITS);
5657 inside = inside && srctileidx(i) >= 0
5664 srctile = src.
getTile(srctileidx.
x(), srctileidx.
y(), srctileidx.
z());
5666 && tile->
zres() == srctile->
zres())
5676 srctileidx.
x() >>= TILEBITS;
5677 srctileidx.
y() >>= TILEBITS;
5678 srctileidx.
z() >>= TILEBITS;
5679 srctileoff.
x() = off.x() & TILEMASK;
5680 srctileoff.
y() = off.y() & TILEMASK;
5681 srctileoff.
z() = off.z() & TILEMASK;
5686 srcend.
x() += tile->
xres() - 1;
5687 srcend.
y() += tile->
yres() - 1;
5688 srcend.
z() += tile->
zres() - 1;
5690 srcendtile = srcend;
5691 srcendtile.
x() >>= TILEBITS;
5692 srcendtile.
y() >>= TILEBITS;
5693 srcendtile.
z() >>= TILEBITS;
5696 srcendtile.
x() == srctileidx.
x()+1);
5698 srcendtile.
y() == srctileidx.
y()+1);
5700 srcendtile.
z() == srctileidx.
z()+1);
5703 if (srctileidx.
x() >= 0 &&
5704 srctileidx.
y() >= 0 &&
5705 srctileidx.
z() >= 0 &&
5713 bool allconst =
true, firsttile =
true;
5716 for (tz = srctileidx.
z(); allconst && tz <= srcendtile.
z(); tz++)
5717 for (ty = srctileidx.
y(); allconst && ty <= srcendtile.
y(); ty++)
5718 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5720 srctile = src.
getTile(tx, ty, tz);
5726 cval = (*srctile)(0, 0, 0);
5751 for (tz = srctileidx.
z(); tz <= srcendtile.
z(); tz++)
5752 for (ty = srctileidx.
y(); ty <= srcendtile.
y(); ty++)
5753 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5755 int destx, desty, destz;
5756 int srcx, srcy, srcz;
5758 destx = (tx == srctileidx.
x()) ? 0 : (TILESIZE-srctileoff.
x());
5759 desty = (ty == srctileidx.
y()) ? 0 : (TILESIZE-srctileoff.
y());
5760 destz = (tz == srctileidx.
z()) ? 0 : (TILESIZE-srctileoff.
z());
5761 srcx = (tx == srctileidx.
x()) ? srctileoff.
x() : 0;
5762 srcy = (ty == srctileidx.
y()) ? srctileoff.
y() : 0;
5763 srcz = (tz == srctileidx.
z()) ? srctileoff.
z() : 0;
5779 srctile = src.
getTile(tx, ty, tz);
5782 destx, desty, destz,
5797 for (
int z = destz; z < maxd; z++)
5799 for (
int y = desty; y < maxh; y++)
5801 for (
int x = destx; x < maxw; x++)
5807 z + vit.
z() + offz);
5817 template <
typename T>
5834 ratio.
x() = 1.0f / getXRes();
5835 ratio.
y() = 1.0f / getYRes();
5836 ratio.
z() = 1.0f / getZRes();
5840 pos.
x() = vit.
x()+0.5f;
5841 pos.
y() = vit.
y()+0.5f;
5842 pos.
z() = vit.
z()+0.5f;
5849 template <
typename T>
5855 pos.
x() *= myRes[0];
5856 pos.
y() *= myRes[1];
5857 pos.
z() *= myRes[2];
5867 return isValidIndex(x, y, z);
5870 template <
typename T>
5876 pos.
x() *= myRes[0];
5877 pos.
y() *= myRes[1];
5878 pos.
z() *= myRes[2];
5889 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5890 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5891 pos.
z() < 0 || pos.
z() >= myRes[2])
5897 template <
typename T>
5903 pos.
x() *= myRes[0];
5904 pos.
y() *= myRes[1];
5905 pos.
z() *= myRes[2];
5915 return isValidIndex(x, y, z);
5918 template <
typename T>
5924 pos.
x() *= myRes[0];
5925 pos.
y() *= myRes[1];
5926 pos.
z() *= myRes[2];
5937 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5938 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5939 pos.
z() < 0 || pos.
z() >= myRes[2])
5945 template <
typename T>
5962 return isValidIndex(x, y, z);
5965 template <
typename T>
5982 return isValidIndex(x, y, z);
5985 template <
typename T>
6000 template <
typename T>
6015 template <
typename T>
6019 myBorderType =
type;
6023 template <
typename T>
6027 myBorderScale[0] = sx;
6028 myBorderScale[1] = sy;
6029 myBorderScale[2] = sz;
6032 template <
typename T>
6041 myTiles[i].tryCompress(getCompressionOptions());
6045 template <
typename T>
6054 myTiles[i].uncompress();
6058 template <
typename T>
6067 if (!myTiles[i].isConstant())
6068 myTiles[i].uncompress();
6072 template <
typename T>
6080 if (isConstant(&cval))
6084 UTwrite(os, &version, 1);
6085 UTwrite<T>(os, &cval);
6091 UTwrite(os, &version, 1);
6098 ntiles = numTiles();
6099 for (i = 0; i < ntiles; i++)
6101 myTiles[i].save(os);
6106 template <
typename T>
6134 ntiles = numTiles();
6135 for (i = 0; i < ntiles; i++)
6137 myTiles[i].load(is, compressions);
6142 template <
typename T>
6153 if (isConstant(&cval))
6159 if constexpr (tuple_size == 1)
6167 if (shared_mem_owner)
6170 shm = copyToSharedMemory(shared_mem_owner);
6205 ntiles = numTiles();
6206 for (i = 0; i < ntiles; i++)
6208 ok = ok && myTiles[i].save(w);
6218 template <
typename T>
6228 bool array_error =
false;
6230 delete mySharedMemView;
6231 mySharedMemView = 0;
6244 if constexpr (tuple_size == 1)
6263 if (!populateFromSharedMemory(shm_id.
buffer()))
6298 ntiles = numTiles();
6304 if (!myTiles[i].load(p, compressions))
6310 dummy_tile.
setRes(TILESIZE, TILESIZE, TILESIZE);
6311 if (!dummy_tile.
load(p, compressions))
6319 p.
addWarning(
"Unexpected key for voxel data: %s",
6339 template<
typename T>
6347 ntiles = numTiles();
6350 exint total_mem_size;
6352 total_mem_size =
sizeof(
exint);
6357 for (
int i = 0; i < ntiles; i++)
6359 exint tile_size, block_size;
6360 if (myTiles[i].isConstant())
6361 tile_size =
sizeof(T);
6363 tile_size = myTiles[i].getDataLength();
6365 tile_sizes.
append(tile_size);
6367 block_size = SYSroundUpToMultipleOf<exint>(tile_size,
sizeof(
exint));
6368 block_size +=
sizeof(
exint) * 2;
6371 next_block_offsets.
append(block_size /
sizeof(
exint));
6373 next_block_offsets.
append(0);
6375 total_mem_size += block_size;
6382 shared_mem_key.
sprintf(
"%s:%p", shared_mem_owner,
this);
6384 shared_mem = shmgr.
get(shared_mem_key.
buffer());
6390 bool same_meta_data =
false;
6391 if (shared_mem->
size() >=
sizeof(
exint))
6393 same_meta_data =
true;
6398 if (*ptr_ds != ntiles)
6399 same_meta_data =
false;
6406 for (
int i = 0; i < ntiles; i++)
6412 if (ptr_tile[0] != next_block_offsets(i) ||
6413 ptr_tile[1] != (
exint)myTiles[i].myCompressionType)
6415 same_meta_data =
false;
6418 offset += next_block_offsets(i) *
sizeof(
exint);
6423 if (!same_meta_data)
6425 if (!shared_mem->
reset(total_mem_size) ||
6426 shared_mem->
size() != total_mem_size)
6440 for (
int i = 0; i < ntiles; i++)
6443 sizeof(
exint) * 2 + tile_sizes(i));
6448 ptr_tile[0] = next_block_offsets(i);
6449 ptr_tile[1] = myTiles[i].myCompressionType;
6451 ::memcpy(&ptr_tile[2], myTiles[i].rawData(), tile_sizes(i));
6453 offset += ptr_tile[0] *
sizeof(
exint);
6459 template<
typename T>
6464 if (!mySharedMem->size())
6474 ntiles = *(
const exint *)sv_tc.data();
6476 if (ntiles != numTiles())
6485 exint *data = (
exint *)mySharedMemView->data();
6487 for (
int i = 0; i < ntiles; i++)
6489 exint offset = data[0];
6492 myTiles[i].setForeignData(&data[2], ctype);
6506 template <
typename T>
6509 initializePrivate();
6512 template <
typename T>
6518 template <
typename T>
6521 initializePrivate();
6526 template <
typename T>
6549 myLevels.append(levels);
6551 for (level = 0; level < myNumLevels; level++)
6560 template <
typename T>
6567 functions.
append(
function);
6568 build(baselevel, functions);
6571 template <
typename T>
6579 myBaseLevel = baselevel;
6587 maxres =
SYSmax(myBaseLevel->getXRes(), myBaseLevel->getYRes());
6588 maxres =
SYSmax(maxres, myBaseLevel->getZRes());
6602 for (
int i = 0; i < functions.
entries(); i++)
6607 myLevels.append(levels);
6610 for (level = myNumLevels-1; level >= 0; level--)
6613 int xres = (lastlevel->
getXRes() + 1) >> 1;
6614 int yres = (lastlevel->
getYRes() + 1) >> 1;
6615 int zres = (lastlevel->
getZRes() + 1) >> 1;
6620 downsample(*levels[level], *lastlevel,
function);
6622 lastlevel = levels[
level];
6627 template <
typename T>
6632 mipmaptype
function,
6656 mixValues(sam[0], sam[1],
function),
6657 mixValues(sam[2], sam[3],
function),
function),
6659 mixValues(sam[4], sam[5],
function),
6660 mixValues(sam[6], sam[7],
function),
function),
6667 template <
typename T>
6671 int64 mem = inclusive ?
sizeof(*this) : 0;
6673 mem += myLevels.getMemoryUsage(
false);
6675 for (
exint j = 0;
j < myLevels.entries();
j++)
6677 for (
int i = 0; i < myNumLevels; i++)
6678 mem += myLevels(
j)[i]->getMemoryUsage(
true);
6684 template <
typename T>
6688 doTraverse(0, 0, 0, 0,
function, data);
6691 template <
typename T>
6694 Callback
function,
void *data)
const
6701 if (level == myNumLevels)
6705 tval[0] = (*vox)(
x,
y,
z);
6706 for (
int i = 1; i < myLevels.entries(); i++)
6712 for (
int i = 0; i < myLevels.entries(); i++)
6714 vox = myLevels(i)[
level];
6715 tval[i] = (*vox)(
x,
y,
z);
6719 shift = myNumLevels -
level;
6724 SYSmin(y << shift, myBaseLevel->getYRes()),
6725 SYSmin(z << shift, myBaseLevel->getZRes()));
6727 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6728 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6730 if (!
function(tval, box, isfinal, data))
6747 bool xinc, yinc, zinc;
6750 if ( ((x+1) << shift) < myBaseLevel->getXRes() )
6754 if ( ((y+1) << shift) < myBaseLevel->getYRes() )
6758 if ( ((z+1) << shift) < myBaseLevel->getZRes() )
6768 doTraverse(x, y, z, level,
function, data);
6772 doTraverse(x, y+1, z, level,
function, data);
6774 doTraverse(x, y+1, z+1, level,
function, data);
6777 doTraverse(x, y, z+1, level,
function, data);
6782 doTraverse(x+1, y, z+1, level,
function, data);
6783 doTraverse(x+1, y, z, level,
function, data);
6786 doTraverse(x+1, y+1, z, level,
function, data);
6788 doTraverse(x+1, y+1, z+1, level,
function, data);
6793 template <
typename T>
6794 template <
typename OP>
6798 doTraverse(0, 0, 0, numLevels()-1, op);
6801 template <
typename T>
6802 template <
typename OP>
6814 SYSmin(y << shift, myBaseLevel->getYRes()),
6815 SYSmin(z << shift, myBaseLevel->getZRes()));
6817 SYSmin((y+1) << shift, myBaseLevel->getYRes()),
6818 SYSmin((z+1) << shift, myBaseLevel->getZRes()));
6820 if (!
op(box, level))
6836 bool xinc, yinc, zinc;
6839 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6843 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6847 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6857 doTraverse(x, y, z, level, op);
6861 doTraverse(x, y+1, z, level, op);
6863 doTraverse(x, y+1, z+1, level, op);
6866 doTraverse(x, y, z+1, level, op);
6871 doTraverse(x+1, y, z+1, level, op);
6872 doTraverse(x+1, y, z, level, op);
6875 doTraverse(x+1, y+1, z, level, op);
6877 doTraverse(x+1, y+1, z+1, level, op);
6882 template <
typename T>
6883 template <
typename OP>
6887 doTraverseSorted(0, 0, 0, numLevels()-1, op);
6902 template <
typename T>
6903 template <
typename OP>
6911 SYSmin(y << level, myBaseLevel->getYRes()),
6912 SYSmin(z << level, myBaseLevel->getZRes()));
6917 if (!
op(box, level))
6933 bool xinc, yinc, zinc;
6936 if ( ((x+1) <<
level) < myBaseLevel->getXRes() )
6940 if ( ((y+1) << level) < myBaseLevel->getYRes() )
6944 if ( ((z+1) << level) < myBaseLevel->getZRes() )
6953 for (
int dz = 0; dz < 2; dz++)
6957 for (
int dy = 0; dy < 2; dy++)
6961 for (
int dx = 0; dx < 2; dx++)
6966 SYSmin((x+dx) << level, myBaseLevel->getXRes()),
6970 SYSmin((x+dx+1) << level, myBaseLevel->getXRes()),
6971 SYSmin((y+dy+1) <<
level, myBaseLevel->getYRes()),
6972 SYSmin((z+dz+1) <<
level, myBaseLevel->getZRes()));
6979 for (
int i = 0; i < numboxes; i++)
6981 sortstats[i].
value = op.sortValue(boxes[i], level);
6982 sortstats[i].
key = i;
6984 std::stable_sort(sortstats, &sortstats[numboxes]);
6986 for (
int i = 0; i < numboxes; i++)
6988 int whichbox = sortstats[i].
key;
6989 doTraverseSorted(boxes[whichbox](0,0)>>level, boxes[whichbox](1,0)>>level, boxes[whichbox](2,0)>>level, level, op);
6993 template <
typename T>
7002 template <
typename T>
7006 for (
exint i = 0; i < myLevels.entries(); i++)
7008 for (
exint level = 0; level < myNumLevels; level++)
7009 delete myLevels(i)[
level];
7010 delete [] myLevels(i);
7012 myLevels.entries(0);
7017 initializePrivate();
7023 template <
typename T>
7027 myHandle.resetHandle();
7029 myShouldCompressOnExit =
false;
7030 myUseTileList =
false;
7035 template <
typename T>
7038 myShouldCompressOnExit =
false;
7039 myUseTileList =
false;
7045 template <
typename T>
7048 myShouldCompressOnExit =
false;
7049 myUseTileList =
false;
7055 template <
typename T>
7060 template <
typename T>
7073 numtiles = myArray->numTiles();
7077 numtiles = myTileList.entries();
7088 if (idx < 0 || idx >= numranges)
7110 myTileEnd = (
int)
SYSfloor((idx+1) * tileperrange);
7114 if (idx == numranges-1)
7115 myTileEnd = numtiles;
7121 template <
typename T>
7137 template <
typename T>
7153 myArray->posToIndex(pmin, vmin);
7154 myArray->posToIndex(pmax, vmax);
7161 template <
typename T>
7167 int xres, yres, zres,
x,
y,
z;
7169 xres = myArray->getXRes();
7170 yres = myArray->getYRes();
7171 zres = myArray->getZRes();
7173 myTileList.entries(0);
7174 myUseTileList =
true;
7176 if (xmin < xres && xmax >= 0 &&
7177 ymin < yres && ymax >= 0 &&
7178 zmin < zres && zmax >= 0)
7181 myArray->clampIndex(xmin, ymin, zmin);
7182 myArray->clampIndex(xmax, ymax, zmax);
7193 if (myArray->numTiles() == (xmax-xmin+1)*(ymax-ymin+1)*(zmax-zmin+1))
7195 UT_ASSERT(xmin == 0 && ymin == 0 && zmin == 0);
7197 myUseTileList =
false;
7201 myTileList.setCapacity((
int64)(zmax-zmin+1) * (
int64)(ymax-ymin+1) * (
int64)(xmax-xmin+1));
7204 for (z = zmin; z <= zmax; z++)
7206 for (y = ymin; y <= ymax; y++)
7208 for (x = xmin; x <= xmax; x++)
7210 myTileList.append(myArray->xyzTileToLinear(x, y, z));
7219 setPartialRange(0, 1);
7223 template <
typename T>
7229 !myArray->getRes(0) || !myArray->getRes(1) || !myArray->getRes(2))
7238 myCurTileListIdx = myJobInfo->nextTask();
7240 myCurTileListIdx = myTileStart;
7241 if (myCurTileListIdx < 0 || myCurTileListIdx >= myTileEnd)
7246 myCurTile = myTileList(myCurTileListIdx);
7251 myCurTile = myJobInfo->nextTask();
7253 myCurTile = myTileStart;
7255 if (myCurTile < 0 || myCurTile >= myTileEnd)
7264 tile = myArray->getLinearTile(myCurTile);
7269 myArray->linearTileToXYZ(myCurTile,
7270 myTilePos[0], myTilePos[1], myTilePos[2]);
7271 myPos[0] = TILESIZE * myTilePos[0];
7272 myPos[1] = TILESIZE * myTilePos[1];
7273 myPos[2] = TILESIZE * myTilePos[2];
7285 myTileLocalPos[0] = 0;
7286 myTileLocalPos[1] = 0;
7287 myTileLocalPos[2] = 0;
7289 myTileSize[0] = tile->
xres();
7290 myTileSize[1] = tile->
yres();
7291 myTileSize[2] = tile->
zres();
7294 template <
typename T>
7298 if (myInterrupt && myInterrupt->opInterrupt())
7305 if (getCompressOnExit())
7308 if (myCurTile >= 0 && myCurTileListIdx < myTileEnd)
7310 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7316 myCurTileListIdx = myJobInfo->nextTask();
7319 if (myCurTileListIdx >= myTileEnd)
7325 myCurTile = myTileList(myCurTileListIdx);
7327 myArray->linearTileToXYZ(myCurTile,
7328 myTilePos[0], myTilePos[1], myTilePos[2]);
7332 tile = myArray->getLinearTile(myCurTile);
7333 myTileLocalPos[0] = 0;
7334 myTileLocalPos[1] = 0;
7335 myTileLocalPos[2] = 0;
7336 myTileSize[0] = tile->
xres();
7337 myTileSize[1] = tile->
yres();
7338 myTileSize[2] = tile->
zres();
7340 myPos[0] = TILESIZE * myTilePos[0];
7341 myPos[1] = TILESIZE * myTilePos[1];
7342 myPos[2] = TILESIZE * myTilePos[2];
7347 if (getCompressOnExit())
7350 if (myCurTile >= 0 && myCurTile < myTileEnd)
7352 myArray->getLinearTile(myCurTile)->tryCompress(myArray->getCompressionOptions());
7358 myCurTile = myJobInfo->nextTask();
7359 if (myCurTile >= myTileEnd)
7364 myArray->linearTileToXYZ(myCurTile,
7365 myTilePos[0], myTilePos[1], myTilePos[2]);
7371 if (myTilePos[0] >= myArray->getTileRes(0))
7375 if (myTilePos[1] >= myArray->getTileRes(1))
7379 if (myTilePos[2] >= myArray->getTileRes(2))
7387 myCurTile = myArray->xyzTileToLinear(myTilePos[0], myTilePos[1], myTilePos[2]);
7395 if (myCurTile >= myTileEnd)
7401 tile = myArray->getLinearTile(myCurTile);
7402 myTileLocalPos[0] = 0;
7403 myTileLocalPos[1] = 0;
7404 myTileLocalPos[2] = 0;
7405 myTileSize[0] = tile->
xres();
7406 myTileSize[1] = tile->
yres();
7407 myTileSize[2] = tile->
zres();
7409 myPos[0] = TILESIZE * myTilePos[0];
7410 myPos[1] = TILESIZE * myTilePos[1];
7411 myPos[2] = TILESIZE * myTilePos[2];
7415 template <
typename T>
7419 myTileLocalPos[0] = myTileSize[0];
7420 myTileLocalPos[1] = myTileSize[1];
7421 myTileLocalPos[2] = myTileSize[2];
7424 template <
typename T>
7425 template <
typename OP>
7435 tile = myArray->getLinearTile(myCurTile);
7457 for (
int i = 0; i <
n; i++)
7459 val[i] =
op(val[i], a);
7467 template <
typename T>
7468 template <
typename OP,
typename S>
7482 tile = myArray->getLinearTile(myCurTile);
7488 for (
int z = 0; z < tile->
zres(); z++)
7489 for (
int y = 0; y < tile->
yres(); y++)
7490 for (
int x = 0; x < tile->
xres(); x++)
7495 val = tile->operator()(
x,
y,
z);
7496 aval = atile->operator()(
x,
y,
z);
7498 val =
op(val, aval);
7513 if (op.isNoop(aval))
7534 val =
op(val, aval);
7556 for (
int i = 0; i <
n; i++)
7558 val[i] =
op(val[i], *aval);
7568 template <
typename T>
7569 template <
typename OP>
7582 applyOperation(op, a);
7585 template<
int OPERANDS,
bool USE_SELF,
7586 typename T,
typename OP,
typename S,
typename R,
typename Q>
7588 conditionalCallOperator(
const OP& op,
const T& a0,
const S& a1,
const R& a2,
const Q& a3)
7592 if constexpr (OPERANDS == 0 && USE_SELF)
7594 else if constexpr (OPERANDS == 1 && !USE_SELF)
7596 else if constexpr (OPERANDS == 1 && USE_SELF)
7598 else if constexpr (OPERANDS == 2 && !USE_SELF)
7600 else if constexpr (OPERANDS == 2 && USE_SELF)
7601 val = op(a0, a1, a2);
7602 else if constexpr (OPERANDS == 3 && !USE_SELF)
7603 val = op(a1, a2, a3);
7604 else if constexpr (OPERANDS == 3 && USE_SELF)
7605 val = op(a0, a1, a2, a3);
7613 template<
int OPERANDS,
bool MASKED,
bool USE_SELF,
7614 typename T, typename OP, typename S, typename R, typename Q, typename M,
7617 assignOperationOnIterator(ITERATOR &it, const OP& op, const
UT_VoxelArray<S>* a,
7635 int tileNum = it.getLinearTileNum();
7636 UT_VoxelTile<M> *mtile = MASKED ? mask->getLinearTile(tileNum) :
nullptr;
7637 UT_VoxelTile<S> *atile = OPERANDS > 0 ? a->getLinearTile(tileNum) :
nullptr;
7638 UT_VoxelTile<R> *btile = OPERANDS > 1 ? b->getLinearTile(tileNum) :
nullptr;
7639 UT_VoxelTile<Q> *ctile = OPERANDS > 2 ? c->getLinearTile(tileNum) :
nullptr;
7643 if (MASKED && mtile->
isConstant() && ((*mtile)(0, 0, 0) <= ((M) 0.5)))
7658 for (
int z = 0; z < tile->
zres(); z++)
7660 for (
int y = 0; y < tile->
yres(); y++)
7662 for (
int x = 0; x < tile->
xres(); x++)
7664 if (!MASKED || ((*mtile)(x, y, z) > ((M) 0.5)))
7669 cval = (*ctile)(
x,
y,
z);
7672 bval = (*btile)(
x,
y,
z);
7675 aval = (*atile)(
x,
y,
z);
7681 if (USE_SELF) val = (*tile)(
x,
y,
z);
7683 val = conditionalCallOperator<OPERANDS, USE_SELF>(
7684 op,
val, aval, bval, cval);
7693 int ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7694 int binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7695 int cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7696 int minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7701 ainc == 0 && binc == 0 && cinc == 0 && minc == 0)
7722 if (USE_SELF) val = tile->
rawData()[0];
7723 val = conditionalCallOperator<OPERANDS, USE_SELF>(
op,
7724 val, aval, bval, cval);
7734 ainc = (OPERANDS < 1 || atile->
isConstant()) ? 0 : 1;
7735 binc = (OPERANDS < 2 || btile->
isConstant()) ? 0 : 1;
7736 cinc = (OPERANDS < 3 || ctile->
isConstant()) ? 0 : 1;
7737 minc = (!MASKED || mtile->
isConstant()) ? 0 : 1;
7739 const S* a_array = OPERANDS > 0 ? atile->
rawData() :
nullptr;
7740 const R* b_array = OPERANDS > 1 ? btile->
rawData() :
nullptr;
7741 const Q* c_array = OPERANDS > 2 ? ctile->
rawData() :
nullptr;
7742 const M* m_array = MASKED ? mtile->
rawData() :
nullptr;
7743 T* val_array = tile->
rawData();
7746 for (
int i = 0; i <
n; i++)
7748 if (!MASKED || (*m_array > ((M) 0.5)))
7750 val_array[i] = conditionalCallOperator<OPERANDS, USE_SELF>(
op,
7751 val_array[i], OPERANDS > 0 ? *a_array : aval,
7752 OPERANDS > 1 ? *b_array : bval,
7753 OPERANDS > 2 ? *c_array : cval);
7781 template <
typename T>
7782 template <
typename OP>
7786 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
7787 (*
this,
op,
nullptr,
nullptr,
nullptr,
nullptr);
7790 template <
typename T>
7791 template <
typename OP,
typename S>
7798 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
7799 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
7802 template <
typename T>
7803 template <
typename OP,
typename S,
typename R>
7812 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
7813 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
7816 template <
typename T>
7817 template <
typename OP,
typename S,
typename R,
typename Q>
7828 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
7829 (*
this,
op, &
a, &
b, &
c,
nullptr);
7832 template <
typename T>
7833 template <
typename OP,
typename M>
7840 assignOperationOnIterator<0, true, true, T, OP, float, float, float, M>
7841 (*
this,
op,
nullptr,
nullptr,
nullptr, &
mask);
7844 template <
typename T>
7845 template <
typename OP,
typename S,
typename M>
7854 assignOperationOnIterator<1, true, true, T, OP, S, float, float, M>
7855 (*
this,
op, &
a,
nullptr,
nullptr, &
mask);
7858 template <
typename T>
7859 template <
typename OP,
typename S,
typename R,
typename M>
7870 assignOperationOnIterator<2, true, true, T, OP, S, R, float, M>
7871 (*
this,
op, &
a, &
b,
nullptr, &
mask);
7874 template <
typename T>
7875 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7888 assignOperationOnIterator<3, true, true, T, OP, S, R, Q, M>
7892 template <
typename T>
7893 template <
typename OP,
typename S>
7900 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
7901 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
7904 template <
typename T>
7905 template <
typename OP,
typename S,
typename R>
7914 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
7915 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
7918 template <
typename T>
7919 template <
typename OP,
typename S,
typename R,
typename Q>
7930 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
7931 (*
this,
op, &
a, &
b, &
c,
nullptr);
7934 template <
typename T>
7935 template <
typename OP,
typename S,
typename M>
7944 assignOperationOnIterator<1, true, false, T, OP, S, float, float, M>
7945 (*
this,
op, &
a,
nullptr,
nullptr, &
mask);
7948 template <
typename T>
7949 template <
typename OP,
typename S,
typename R,
typename M>
7960 assignOperationOnIterator<2, true, false, T, OP, S, R, float, M>
7961 (*
this,
op, &
a, &
b,
nullptr, &
mask);
7964 template <
typename T>
7965 template <
typename OP,
typename S,
typename R,
typename Q,
typename M>
7978 assignOperationOnIterator<3, true, false, T, OP, S, R, Q, M>
7982 template <
typename T>
7983 template <
typename OP>
7993 tile = myArray->getLinearTile(myCurTile);
7998 for (
int z = 0; z < tile->
zres(); z++)
7999 for (
int y = 0; y < tile->
yres(); y++)
8000 for (
int x = 0; x < tile->
xres(); x++)
8004 val = tile->operator()(
x,
y,
z);
8017 op.reduceMany(val, n);
8026 for (
int i = 0; i <
n; i++)
8039 template <
typename T>
8043 myLinearTileNum = -1;
8046 myShouldCompressOnExit =
false;
8049 template <
typename T>
8053 myLinearTileNum = -1;
8056 myShouldCompressOnExit =
false;
8060 template <
typename T>
8061 template <
typename S>
8065 myLinearTileNum = -1;
8068 myShouldCompressOnExit =
false;
8069 setTile(vit, array);
8072 template <
typename T>
8077 template <
typename T>
8083 !myCurTile->xres() || !myCurTile->yres() || !myCurTile->zres())
8089 myPos[0] = myTileStart[0];
8090 myPos[1] = myTileStart[1];
8091 myPos[2] = myTileStart[2];
8093 myTileLocalPos[0] = 0;
8094 myTileLocalPos[1] = 0;
8095 myTileLocalPos[2] = 0;
8097 myTileSize[0] = myCurTile->xres();
8098 myTileSize[1] = myCurTile->yres();
8099 myTileSize[2] = myCurTile->zres();
8104 template <
typename T>
8108 if (getCompressOnExit())
8113 myCurTile->tryCompress(myArray->getCompressionOptions());
8119 template <
typename T>
8120 template <
typename OP>
8124 assignOperationOnIterator<0, false, true, T, OP, float, float, float, float>
8125 (*
this,
op,
nullptr,
nullptr,
nullptr,
nullptr);
8128 template <
typename T>
8129 template <
typename OP,
typename S>
8136 assignOperationOnIterator<1, false, true, T, OP, S, float, float, float>
8137 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
8140 template <
typename T>
8141 template <
typename OP,
typename S,
typename R>
8150 assignOperationOnIterator<2, false, true, T, OP, S, R, float, float>
8151 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
8154 template <
typename T>
8155 template <
typename OP,
typename S,
typename R,
typename Q>
8166 assignOperationOnIterator<3, false, true, T, OP, S, R, Q, float>
8167 (*
this,
op, &
a, &
b, &
c,
nullptr);
8170 template <
typename T>
8171 template <
typename OP,
typename S>
8178 assignOperationOnIterator<1, false, false, T, OP, S, float, float, float>
8179 (*
this,
op, &
a,
nullptr,
nullptr,
nullptr);
8182 template <
typename T>
8183 template <
typename OP,
typename S,
typename R>
8192 assignOperationOnIterator<2, false, false, T, OP, S, R, float, float>
8193 (*
this,
op, &
a, &
b,
nullptr,
nullptr);
8196 template <
typename T>
8197 template <
typename OP,
typename S,
typename R,
typename Q>
8208 assignOperationOnIterator<3, false, false, T, OP, S, R, Q, float>
8209 (*
this,
op, &
a, &
b, &
c,
nullptr);
8212 template <
typename T>
8213 template <
typename OP>
8219 if (!myCurTile->isSimpleCompression())
8222 for (
int z = 0; z < myTileSize[2]; z++)
8223 for (
int y = 0; y < myTileSize[1]; y++)
8224 for (
int x = 0; x < myTileSize[0]; x++)
8228 val = myCurTile->operator()(
x,
y,
z);
8230 if (!op.reduce(val))
8234 else if (myCurTile->isConstant())
8239 val = myCurTile->rawData()[0];
8240 int n = myCurTile->numVoxels();
8242 if (!op.reduceMany(val, n))
8249 val = myCurTile->rawData();
8251 int n = myCurTile->numVoxels();
8252 for (
int i = 0; i <
n; i++)
8254 if (!op.reduce(val[i]))
8265 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8275 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8286 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8291 if (!TestForWrites ||
myDirty)
8300 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8305 if (!DoRead && (prex != 0 || postx != 0))
8307 UT_ASSERT(!
"Voxel probe cannot be padded if set to not read.");
8313 int prepad, postpad;
8317 prepad = (prex - 3) / 4;
8318 postpad = (postx + 3) / 4;
8335 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8364 if (!TestForWrites ||
myDirty)
8377 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8382 bool xout =
false, yout =
false, zout =
false;
8383 bool manualbuild =
false;
8399 if (myMaxValidX <= 0 || myMinValidX >=
myArray->getXRes())
8445 myArray->clampIndex(tx, y, z);
8462 if (xout || manualbuild)
8489 for (i =
myPreX; i < 0; i++)
8499 for (; i < TILESIZE; i++)
8507 for (; i < TILESIZE; i++)
8513 for (; i < TILESIZE +
myPostX; i++)
8526 int xtile, ytile, ztile, tileidx;
8530 xtile = x >> TILEBITS;
8531 ytile = y >> TILEBITS;
8532 ztile = z >> TILEBITS;
8539 tileidx = (ztile *
myArray->getTileRes(1) + ytile) *
myArray->getTileRes(0);
8546 tile =
myArray->getLinearTile(tileidx+xtile-1);
8547 for (i =
myPreX; i < 0; i++)
8558 int resx =
myArray->getXRes();
8567 for (i =
myPreX; i < 0; i++)
8577 int resx =
myArray->getXRes();
8578 int resx2 = resx * 2;
8581 int xpos =
myPreX % resx2;
8593 xpos = resx2 - xpos - 1;
8596 for (i =
myPreX; i < 0; i++)
8609 else if (xpos >= resx)
8622 tile =
myArray->getLinearTile(tileidx+xtile);
8623 value = (*tile)(0, ly, lz);
8626 value =
myArray->getBorderValue();
8629 for (i =
myPreX; i < 0; i++)
8637 int cachelen = TILESIZE;
8638 int resx =
myArray->getXRes();
8655 tile =
myArray->getLinearTile(tileidx+xtile+1);
8656 for (; i <
myPostX && xpos < resx; i++)
8697 else if (xpos >= resx)
8710 tile =
myArray->getLinearTile(tileidx+xtile);
8711 value = (*tile)(tile->
xres()-1, ly, lz);
8714 value =
myArray->getBorderValue();
8724 tile =
myArray->getLinearTile(tileidx+xtile+1);
8735 tile =
myArray->getLinearTile(tileidx+xtile);
8749 for (i = topad; i > 0; i--)
8764 value =
myArray->getBorderValue();
8766 for (i = topad; i > 0; i--)
8774 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8802 template <
typename T,
bool DoRead,
bool DoWrite,
bool TestForWrites>
8825 int xtile, ytile, ztile,
y,
z;
8828 xtile = myMinValidX >> TILEBITS;
8829 ytile =
myY >> TILEBITS;
8830 ztile =
myZ >> TILEBITS;
8834 tile =
myArray->getTile(xtile, ytile, ztile);
8843 template <
typename T>
8849 template <
typename T>
8854 template <
typename T>
8859 myLines[0][0].setConstArray(vox, -1, 1);
8860 myLines[0][1].setConstArray(vox, -1, 1);
8861 myLines[0][2].setConstArray(vox, -1, 1);
8863 myLines[1][0].setConstArray(vox, -1, 1);
8864 myLines[1][1].setConstArray(vox, -1, 1);
8865 myLines[1][2].setConstArray(vox, -1, 1);
8867 myLines[2][0].setConstArray(vox, -1, 1);
8868 myLines[2][1].setConstArray(vox, -1, 1);
8869 myLines[2][2].setConstArray(vox, -1, 1);
8874 template <
typename T>
8881 myLines[0][1].setConstArray(vox, -1, 1);
8883 myLines[1][0].setConstArray(vox, 0, 0);
8884 myLines[1][1].setConstArray(vox, -1, 1);
8885 myLines[1][2].setConstArray(vox, 0, 0);
8887 myLines[2][1].setConstArray(vox, -1, 1);
8892 template <
typename T>
8896 if (myValid && myZ == z)
8901 if (x < myMaxValidX && x == myX+1)
8904 myLines[0][0].advanceX();
8905 myLines[0][1].advanceX();
8906 myLines[0][2].advanceX();
8908 myLines[1][0].advanceX();
8909 myLines[1][1].advanceX();
8910 myLines[1][2].advanceX();
8912 myLines[2][0].advanceX();
8913 myLines[2][1].advanceX();
8914 myLines[2][2].advanceX();
8929 rotateLines(myLines[0][0], myLines[1][0], myLines[2][0]);
8930 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
8931 rotateLines(myLines[0][2], myLines[1][2], myLines[2][2]);
8935 myLines[0][0].resetX(x);
8936 myLines[0][1].resetX(x);
8937 myLines[0][2].resetX(x);
8939 myLines[1][0].resetX(x);
8940 myLines[1][1].resetX(x);
8941 myLines[1][2].resetX(x);
8944 myLines[2][0].setIndex(x, y+1, z-1);
8945 myLines[2][1].setIndex(x, y+1, z);
8946 myLines[2][2].setIndex(x, y+1, z+1);
8958 myLines[0][0].setIndex(x, y-1, z-1);
8959 myLines[0][1].setIndex(x, y-1, z);
8960 myLines[0][2].setIndex(x, y-1, z+1);
8962 myLines[1][0].setIndex(x, y, z-1);
8963 myLines[1][1].setIndex(x, y, z);
8964 myLines[1][2].setIndex(x, y, z+1);
8966 myLines[2][0].setIndex(x, y+1, z-1);
8967 myLines[2][1].setIndex(x, y+1, z);
8968 myLines[2][2].setIndex(x, y+1, z+1);
8975 myMinValidX = myLines[1][1].myMinValidX;
8976 myMaxValidX = myLines[1][1].myMaxValidX;
8981 template <
typename T>
8985 if (myValid && myZ == z)
8990 if (x < myMaxValidX && x == myX+1)
8993 myLines[0][1].advanceX();
8995 myLines[1][0].advanceX();
8996 myLines[1][1].advanceX();
8997 myLines[1][2].advanceX();
8999 myLines[2][1].advanceX();
9013 rotateLines(myLines[0][1], myLines[1][1], myLines[2][1]);
9015 myLines[0][1].resetX(x);
9016 myLines[1][1].resetX(x);
9018 myLines[1][0].setIndex(x, y, z-1);
9019 myLines[1][2].setIndex(x, y, z+1);
9021 myLines[2][1].setIndex(x, y+1, z);
9030 myLines[0][1].setIndex(x, y-1, z);
9032 myLines[1][0].setIndex(x, y, z-1);
9033 myLines[1][1].setIndex(x, y, z);
9034 myLines[1][2].setIndex(x, y, z+1);
9036 myLines[2][1].setIndex(x, y+1, z);
9043 myMinValidX = myLines[1][1].myMinValidX;
9044 myMaxValidX = myLines[1][1].myMaxValidX;
9049 template <
typename T>
9064 Px *= 0.5 * invvoxelsize.
x();
9067 Py *= 0.5 * invvoxelsize.
y();
9070 Pz *= 0.5 * invvoxelsize.
z();
9078 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
9083 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
9088 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
9093 Pxy *= 0.25 * invvoxelsize.
x() * invvoxelsize.
y();
9097 Pxz *= 0.25 * invvoxelsize.
x() * invvoxelsize.
z();
9101 Pyz *= 0.25 * invvoxelsize.
y() * invvoxelsize.
z();
9104 gradlen = SYSsqrt(Px * Px + Py * Py + Pz * Pz);
9112 k = Px*Px * (Pyy + Pzz) + Py*Py * (Pxx + Pzz) + Pz*Pz * (Pxx + Pyy);
9113 k -= 2 * (Pxy*Px*Py + Pyz*Py*Pz + Pxz*Px*Pz);
9119 k /= gradlen * gradlen * gradlen;
9133 template <
typename T>
9146 Pxx *= invvoxelsize.
x() * invvoxelsize.
x();
9151 Pyy *= invvoxelsize.
y() * invvoxelsize.
y();
9156 Pzz *= invvoxelsize.
z() * invvoxelsize.
z();
9158 return Pxx + Pyy + Pzz;
9161 template <
typename T>
9167 T *tmpcache, *tmpalloc;
9196 template <
typename T>
9202 template <
typename T>
9208 template <
typename T>
9213 myLines[0][0].setConstArray(vx, 0, 1);
9216 myLines[1][0].setConstArray(vy, 0, 0);
9217 myLines[1][1].setConstArray(vy, 0, 0);
9219 myLines[2][0].setConstArray(vz, 0, 0);
9220 myLines[2][1].setConstArray(vz, 0, 0);
9225 template <
typename T>
9231 myInvVoxelSize /= myVoxelSize;
9234 template <
typename T>
9238 if (myValid && myZ == z)
9243 if (x < myMaxValidX && x == myX+1)
9246 myLines[0][0].advanceX();
9248 myLines[1][0].advanceX();
9249 myLines[1][1].advanceX();
9251 myLines[2][0].advanceX();
9252 myLines[2][1].advanceX();
9265 swapLines(myLines[1][0], myLines[1][1]);
9267 myLines[1][0].resetX(x);
9270 myLines[0][0].setIndex(x, y, z);
9271 myLines[1][1].setIndex(x, y+1, z);
9273 myLines[2][0].setIndex(x, y, z);
9274 myLines[2][1].setIndex(x, y, z+1);
9283 myLines[0][0].setIndex(x, y, z);
9285 myLines[1][0].setIndex(x, y, z);
9286 myLines[1][1].setIndex(x, y+1, z);
9288 myLines[2][0].setIndex(x, y, z);
9289 myLines[2][1].setIndex(x, y, z+1);
9296 myMinValidX = myLines[0][0].myMinValidX;
9297 myMaxValidX = myLines[0][0].myMaxValidX;
9302 template <
typename T>
9307 T *tmpcache, *tmpalloc;
9330 template <
typename T,
int XStep,
int YStep,
int ZStep>
9334 int prex = (XStep < 0) ? XStep : 0;
9335 int postx = (XStep > 0) ? XStep : 0;
9350 template <
typename T,
int XStep,
int YStep,
int ZStep>
9365 result |= myLines[0][0].setIndex(x, y, z);
9368 result |= myLines[1][0].setIndex(x, y+1, z);
9370 result |= myLines[1][1].setIndex(x, y+1, z+1);
9373 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 SYSisEqual(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, S tol)
Componentwise equality.
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)
SYS_API fpreal32 SYSceil(const fpreal32 val)
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)
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)
bool setIndex(const UT_VoxelArrayIterator< S > &vit)
T operator()(UT_Vector3D pos) const
bool setIndex(const UT_VoxelArrayIterator< S > &vit)
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
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)
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)
bool setIndexPlus(const UT_VoxelArrayIterator< S > &vit)
SYS_FORCE_INLINE bool extractSampleAxis(int x, int y, int z, T *sample) const
void setVoxelSize(const UT_Vector3 &voxelsize)
PXL_API bool isRaw(const ColorSpace *s)
static UT_JID jid()
Returns the JID that matches the given type.
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
SYS_API fpreal32 SYSfloor(const fpreal32 val)
void makeRawUninitialized()
UT_VoxelTile< T > * getTile(int tx, int ty, int tz) const
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)
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
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
bool setIndexCube(const UT_VoxelArrayIterator< S > &vit)
virtual void findMinMax(const UT_VoxelTile< T > &tile, T &min, T &max) const
void setLinearTile(exint lineartilenum, UT_VoxelArray< T > *array)
GLsizeiptr const void GLenum usage
bool hasNan() const
Returns true if any element of the voxel array is NAN.
SYS_FORCE_INLINE void lerpVoxelMinMaxAxis(T &lerp, T &lmin, T &lmax, int x, int y, int z, float fx, float fy, float fz) const
SYS_STATIC_FORCE_INLINE T lerpValues(T v1, T v2, fpreal32 bias)
Lerps two numbers, templated to work with T.
T getValue(int x, int y, int z) const
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 setIndex(const UT_VoxelArrayIterator< S > &vit)
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 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
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
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