82 for (z = 0; z < tile.
zres(); z++)
84 for (y = 0; y < tile.
yres(); y++)
86 for (x = 0; x < tile.
xres(); x++)
106 myCompressionType = COMPRESS_CONSTANT;
107 myForeignData =
false;
109 if (
sizeof(
T) <=
sizeof(
T*))
121 ((
T *)myData)[0] = 0;
125 template <
typename T>
131 template <
typename T>
140 template <
typename T>
149 myRes[0] = src.myRes[0];
150 myRes[1] = src.myRes[1];
151 myRes[2] = src.myRes[2];
153 myCompressionType = src.myCompressionType;
154 switch (myCompressionType)
158 sizeof(
T) * myRes[0] * myRes[1] * myRes[2]);
159 memcpy(myData, src.
myData,
sizeof(
T) * myRes[0] * myRes[1] * myRes[2]);
161 case COMPRESS_CONSTANT:
162 if (inlineConstant())
169 memcpy(myData, src.
myData,
sizeof(
T));
172 case COMPRESS_RAWFULL:
174 sizeof(
T) * TILESIZE * TILESIZE * myRes[2]);
175 memcpy(myData, src.
myData,
176 sizeof(
T) * TILESIZE * TILESIZE * myRes[2]);
178 case COMPRESS_FPREAL16:
182 sizeof(
fpreal16) * myRes[0] * myRes[1] * myRes[2] * tuple_size);
183 memcpy(myData, src.
myData,
184 sizeof(
fpreal16) * myRes[0] * myRes[1] * myRes[2] * tuple_size);
191 engine = getCompressionEngine(myCompressionType);
201 template <
typename T>
205 switch (myCompressionType)
209 ((
T *)myData)[ ((z * myRes[1]) + y) * myRes[0] +
x ] =
t;
212 case COMPRESS_CONSTANT:
213 if (rawConstVal() ==
t)
220 case COMPRESS_RAWFULL:
221 ((
T *)myData)[ ((z * TILESIZE) + y) * TILESIZE +
x ] =
t;
224 case COMPRESS_FPREAL16:
231 engine = getCompressionEngine(myCompressionType);
235 template <
typename T>
240 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
242 switch (myCompressionType)
245 return ((
T *)myData)[
246 ((z * myRes[1]) + y) * myRes[0] +
x ];
248 case COMPRESS_CONSTANT:
249 return rawConstVal();
251 case COMPRESS_RAWFULL:
252 return ((
T *)myData)[
253 ((z * TILESIZE) + y) * TILESIZE +
x ];
255 case COMPRESS_FPREAL16:
260 int offset = ((z * myRes[1] +
y) * myRes[0] + x)
262 T result = convertFromFP16(data + offset);
270 engine = getCompressionEngine(myCompressionType);
271 return engine->
getValue(*
this, x, y, z);
274 template <
typename T>
278 T vx, vx1, vy, vy1, vz;
280 switch (myCompressionType)
285 int offset = (z * myRes[1] +
y) * myRes[0] + x;
287 int zinc = myRes[0] * myRes[1];
290 vx = lerpValues(data[offset], data[offset+1], fx);
292 vx1 = lerpValues(data[offset+yinc], data[offset+yinc+1], fx);
295 vy = lerpValues(vx, vx1, fy);
298 vx = lerpValues(data[offset+zinc], data[offset+zinc+1], fx);
300 vx1 = lerpValues(data[offset+zinc+yinc], data[offset+zinc+yinc+1], fx);
303 vy1 = lerpValues(vx, vx1, fy);
306 vz = lerpValues(vy, vy1, fz);
309 case COMPRESS_RAWFULL:
312 int offset = (z * TILESIZE +
y) * TILESIZE + x;
314 int zinc = TILESIZE * TILESIZE;
317 vx = lerpValues(data[offset], data[offset+1], fx);
319 vx1 = lerpValues(data[offset+yinc], data[offset+yinc+1], fx);
322 vy = lerpValues(vx, vx1, fy);
325 vx = lerpValues(data[offset+zinc], data[offset+zinc+1], fx);
327 vx1 = lerpValues(data[offset+zinc+yinc], data[offset+zinc+yinc+1], fx);
330 vy1 = lerpValues(vx, vx1, fy);
333 vz = lerpValues(vy, vy1, fz);
336 case COMPRESS_FPREAL16:
342 int xinc = tuple_size;
343 int yinc = myRes[0] * xinc;
344 int zinc = myRes[1] * yinc;
345 int offset = z * zinc + y * yinc + x * xinc;
349 for (
int j = 0;
j < tuple_size;
j++, offset++)
352 vx =
SYSlerp(data[offset], data[offset+xinc], fx);
354 vx1 =
SYSlerp(data[offset+yinc], data[offset+yinc+xinc], fx);
360 vx =
SYSlerp(data[offset+zinc], data[offset+zinc+xinc], fx);
362 vx1 =
SYSlerp(data[offset+zinc+yinc], data[offset+zinc+yinc+xinc], fx);
371 return convertFromFP16(result);
373 case COMPRESS_CONSTANT:
384 engine = getCompressionEngine(myCompressionType);
386 vx = lerpValues(engine->
getValue(*
this, x, y, z),
390 vx1 = lerpValues(engine->
getValue(*
this, x, y+1, z),
391 engine->
getValue(*
this, x+1, y+1, z),
395 vy = lerpValues(vx, vx1, fy);
398 vx = lerpValues(engine->
getValue(*
this, x, y, z+1),
399 engine->
getValue(*
this, x+1, y, z+1),
402 vx1 = lerpValues(engine->
getValue(*
this, x, y+1, z+1),
403 engine->
getValue(*
this, x+1, y+1, z+1),
407 vy1 = lerpValues(vx, vx1, fy);
410 vz = lerpValues(vy, vy1, fz);
418 template <
typename T>
419 template <
int AXIS2D>
423 T vx, vx1, vy, vy1, vz;
425 switch (myCompressionType)
430 int offset = (z * myRes[1] +
y) * myRes[0] + x;
432 int zinc = myRes[0] * myRes[1];
436 vx = lerpValues(data[offset],
446 vx1= lerpValues(data[offset+yinc],
450 vx1 = data[offset+yinc];
452 vy = lerpValues(vx, vx1, fy);
461 vx = lerpValues(data[offset+zinc],
465 vx = data[offset+zinc];
471 vx1= lerpValues(data[offset+zinc+yinc],
472 data[offset+zinc+yinc+1],
475 vx1 = data[offset+zinc+yinc];
477 vy1 = lerpValues(vx, vx1, fy);
483 vz = lerpValues(vy, vy1, fz);
489 case COMPRESS_RAWFULL:
492 int offset = (z * TILESIZE +
y) * TILESIZE + x;
494 int zinc = TILESIZE * TILESIZE;
498 vx = lerpValues(data[offset],
508 vx1= lerpValues(data[offset+yinc],
512 vx1 = data[offset+yinc];
514 vy = lerpValues(vx, vx1, fy);
523 vx = lerpValues(data[offset+zinc],
527 vx = data[offset+zinc];
533 vx1= lerpValues(data[offset+zinc+yinc],
534 data[offset+zinc+yinc+1],
537 vx1 = data[offset+zinc+yinc];
539 vy1 = lerpValues(vx, vx1, fy);
545 vz = lerpValues(vy, vy1, fz);
551 case COMPRESS_FPREAL16:
557 int xinc = tuple_size;
558 int yinc = myRes[0] * xinc;
559 int zinc = myRes[1] * yinc;
560 int offset = z * zinc + y * yinc + x * xinc;
564 for (
int j = 0;
j < tuple_size;
j++, offset++)
578 vx1=
SYSlerp(data[offset+yinc],
579 data[offset+yinc+xinc],
582 vx1 = data[offset+yinc];
593 vx =
SYSlerp(data[offset+zinc],
594 data[offset+zinc+xinc],
597 vx = data[offset+zinc];
603 vx1=
SYSlerp(data[offset+zinc+yinc],
604 data[offset+zinc+yinc+xinc],
607 vx1 = data[offset+zinc+yinc];
621 return convertFromFP16(result);
623 case COMPRESS_CONSTANT:
634 engine = getCompressionEngine(myCompressionType);
637 vx = lerpValues(engine->
getValue(*
this, x, y, z),
641 vx = engine->
getValue(*
this, x, y, z);
647 vx1= lerpValues(engine->
getValue(*
this, x, y+1, z),
648 engine->
getValue(*
this, x+1, y+1, z),
651 vx1 = engine->
getValue(*
this, x, y+1, z);
653 vy = lerpValues(vx, vx1, fy);
662 vx = lerpValues(engine->
getValue(*
this, x, y, z+1),
663 engine->
getValue(*
this, x+1, y, z+1),
666 vx = engine->
getValue(*
this, x, y, z+1);
672 vx1= lerpValues(engine->
getValue(*
this, x, y+1, z+1),
673 engine->
getValue(*
this, x+1, y+1, z+1),
676 vx1 = engine->
getValue(*
this, x, y+1, z+1);
678 vy1 = lerpValues(vx, vx1, fy);
684 vz = lerpValues(vy, vy1, fz);
695 template <
typename T>
699 switch (myCompressionType)
704 int offset = (z * myRes[1] +
y) * myRes[0] + x;
706 int zinc = myRes[0] * myRes[1];
709 sample[1] = data[offset+1];
710 sample[2+0] = data[offset+yinc];
711 sample[2+1] = data[offset+yinc+1];
712 sample[4+0] = data[offset+zinc];
713 sample[4+1] = data[offset+zinc+1];
714 sample[4+2+0] = data[offset+zinc+yinc];
715 sample[4+2+1] = data[offset+zinc+yinc+1];
718 case COMPRESS_RAWFULL:
721 int offset = (z * TILESIZE +
y) * TILESIZE + x;
723 int zinc = TILESIZE * TILESIZE;
726 sample[1] = data[offset+1];
727 sample[2+0] = data[offset+yinc];
728 sample[2+1] = data[offset+yinc+1];
729 sample[4+0] = data[offset+zinc];
730 sample[4+1] = data[offset+zinc+1];
731 sample[4+2+0] = data[offset+zinc+yinc];
732 sample[4+2+1] = data[offset+zinc+yinc+1];
735 case COMPRESS_FPREAL16:
741 int xinc = tuple_size;
742 int yinc = myRes[0] * xinc;
743 int zinc = myRes[1] * yinc;
744 int offset = z * zinc + y * yinc + x * xinc;
747 sample[0] = convertFromFP16(data);
748 sample[1] = convertFromFP16(data + xinc);
749 sample[2+0] = convertFromFP16(data + yinc);
750 sample[2+1] = convertFromFP16(data + yinc + xinc);
751 sample[4+0] = convertFromFP16(data + zinc);
752 sample[4+1] = convertFromFP16(data + zinc + xinc);
753 sample[4+2+0] = convertFromFP16(data + zinc + yinc);
754 sample[4+2+1] = convertFromFP16(data + zinc + yinc + xinc);
757 case COMPRESS_CONSTANT:
759 sample[0] = rawConstVal();
767 engine = getCompressionEngine(myCompressionType);
769 sample[0] = engine->
getValue(*
this, x, y, z);
770 sample[1] = engine->
getValue(*
this, x+1, y, z);
771 sample[2+0] = engine->
getValue(*
this, x, y+1, z);
772 sample[2+1] = engine->
getValue(*
this, x+1, y+1, z);
773 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
774 sample[4+1] = engine->
getValue(*
this, x+1, y, z+1);
775 sample[4+2+0] = engine->
getValue(*
this, x, y+1, z+1);
776 sample[4+2+1] = engine->
getValue(*
this, x+1, y+1, z+1);
783 template <
typename T>
787 switch (myCompressionType)
792 int offset = (z * myRes[1] +
y) * myRes[0] + x;
794 int zinc = myRes[0] * myRes[1];
796 sample[0] = data[offset-1];
797 sample[1] = data[offset+1];
798 sample[2+0] = data[offset-yinc];
799 sample[2+1] = data[offset+yinc];
800 sample[4+0] = data[offset-zinc];
801 sample[4+1] = data[offset+zinc];
805 case COMPRESS_RAWFULL:
808 int offset = (z * TILESIZE +
y) * TILESIZE + x;
810 int zinc = TILESIZE * TILESIZE;
812 sample[0] = data[offset-1];
813 sample[1] = data[offset+1];
814 sample[2+0] = data[offset-yinc];
815 sample[2+1] = data[offset+yinc];
816 sample[4+0] = data[offset-zinc];
817 sample[4+1] = data[offset+zinc];
821 case COMPRESS_FPREAL16:
827 int xinc = tuple_size;
828 int yinc = myRes[0] * xinc;
829 int zinc = myRes[1] * yinc;
830 int offset = z * zinc + y * yinc + x * xinc;
833 sample[0] = convertFromFP16(data - xinc);
834 sample[1] = convertFromFP16(data + xinc);
835 sample[2+0] = convertFromFP16(data - yinc);
836 sample[2+1] = convertFromFP16(data + yinc);
837 sample[4+0] = convertFromFP16(data - zinc);
838 sample[4+1] = convertFromFP16(data + zinc);
839 sample[6] = convertFromFP16(data);
842 case COMPRESS_CONSTANT:
844 sample[0] = rawConstVal();
852 engine = getCompressionEngine(myCompressionType);
854 sample[0] = engine->
getValue(*
this, x-1, y, z);
855 sample[1] = engine->
getValue(*
this, x+1, y, z);
856 sample[2+0] = engine->
getValue(*
this, x, y-1, z);
857 sample[2+1] = engine->
getValue(*
this, x, y+1, z);
858 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
859 sample[4+1] = engine->
getValue(*
this, x, y, z-1);
860 sample[6] = engine->
getValue(*
this, x, y, z);
874 template <
typename T>
878 switch (myCompressionType)
883 int offset = (z * myRes[1] +
y) * myRes[0] + x;
885 int zinc = myRes[0] * myRes[1];
889 for (
int dz = -1; dz <= 1; dz++)
892 for (
int dy = -1; dy <= 1; dy++)
894 sample[sampidx] = data[offset-1];
895 sample[sampidx+1] = data[
offset];
896 sample[sampidx+2] = data[offset+1];
905 case COMPRESS_RAWFULL:
907 T *data = (
T *) myData;
908 int offset = (z * TILESIZE +
y) * TILESIZE + x;
910 int zinc = TILESIZE * TILESIZE;
914 for (
int dz = -1; dz <= 1; dz++)
917 for (
int dy = -1; dy <= 1; dy++)
919 sample[sampidx] = data[offset-1];
920 sample[sampidx+1] = data[
offset];
921 sample[sampidx+2] = data[offset+1];
930 case COMPRESS_FPREAL16:
933 int offset = (z * myRes[1] +
y) * myRes[0] + x;
935 int zinc = myRes[0] * myRes[1];
939 for (
int dz = -1; dz <= 1; dz++)
942 for (
int dy = -1; dy <= 1; dy++)
944 sample[sampidx] = data[offset-1];
945 sample[sampidx+1] = data[
offset];
946 sample[sampidx+2] = data[offset+1];
955 case COMPRESS_CONSTANT:
957 sample[0] = rawConstVal();
965 engine = getCompressionEngine(myCompressionType);
968 for (
int dz = -1; dz <= 1; dz++)
970 for (
int dy = -1; dy <= 1; dy++)
972 for (
int dx = -1; dx <= 1; dx++)
974 sample[sampidx++] = engine->
getValue(*
this, x+dx, y+dy, z+dz);
985 template <
typename T>
986 template <
int AXIS2D>
990 switch (myCompressionType)
994 T *data = (
T *) myData;
995 int offset = (z * myRes[1] +
y) * myRes[0] + x;
997 int zinc = myRes[0] * myRes[1];
1001 sample[1] = data[offset+1];
1004 sample[2+0] = data[offset+yinc];
1006 sample[2+1] = data[offset+yinc+1];
1010 sample[4+0] = data[offset+zinc];
1012 sample[4+1] = data[offset+zinc+1];
1015 sample[4+2+0] = data[offset+zinc+yinc];
1017 sample[4+2+1] = data[offset+zinc+yinc+1];
1022 case COMPRESS_RAWFULL:
1024 T *data = (
T *) myData;
1025 int offset = (z * TILESIZE +
y) * TILESIZE + x;
1026 int yinc = TILESIZE;
1027 int zinc = TILESIZE * TILESIZE;
1029 sample[0] = data[
offset];
1031 sample[1] = data[offset+1];
1034 sample[2+0] = data[offset+yinc];
1036 sample[2+1] = data[offset+yinc+1];
1040 sample[4+0] = data[offset+zinc];
1042 sample[4+1] = data[offset+zinc+1];
1045 sample[4+2+0] = data[offset+zinc+yinc];
1047 sample[4+2+1] = data[offset+zinc+yinc+1];
1052 case COMPRESS_FPREAL16:
1058 int xinc = tuple_size;
1059 int yinc = myRes[0] * xinc;
1060 int zinc = myRes[1] * yinc;
1061 int offset = z * zinc + y * yinc + x * xinc;
1064 sample[0] = convertFromFP16(data);
1066 sample[1] = convertFromFP16(data + xinc);
1069 sample[2+0] = convertFromFP16(data + yinc);
1071 sample[2+1] = convertFromFP16(data + yinc + xinc);
1075 sample[4+0] = convertFromFP16(data + zinc);
1077 sample[4+1] = convertFromFP16(data + zinc + xinc);
1080 sample[4+2+0] = convertFromFP16(data + zinc + yinc);
1082 sample[4+2+1] = convertFromFP16(data + zinc + yinc + xinc);
1087 case COMPRESS_CONSTANT:
1089 sample[0] = rawConstVal();
1097 engine = getCompressionEngine(myCompressionType);
1099 sample[0] = engine->
getValue(*
this, x, y, z);
1101 sample[1] = engine->
getValue(*
this, x+1, y, z);
1104 sample[2+0] = engine->
getValue(*
this, x, y+1, z);
1106 sample[2+1] = engine->
getValue(*
this, x+1, y+1, z);
1110 sample[4+0] = engine->
getValue(*
this, x, y, z+1);
1112 sample[4+1] = engine->
getValue(*
this, x+1, y, z+1);
1115 sample[4+2+0] = engine->
getValue(*
this, x, y+1, z+1);
1117 sample[4+2+1] = engine->
getValue(*
this, x+1, y+1, z+1);
1127 template <
typename T>
1133 switch (myCompressionType)
1136 case COMPRESS_RAWFULL:
1138 T *data = (
T *) myData;
1139 int offset = (z * myRes[1] +
y) * myRes[0] + x;
1140 int yinc = myRes[0];
1141 int zinc = myRes[0] * myRes[1];
1143 a =
v4uf( data[offset],
1146 data[offset+yinc+zinc] );
1147 b =
v4uf( data[offset+1],
1148 data[offset+zinc+1],
1149 data[offset+yinc+1],
1150 data[offset+yinc+zinc+1] );
1154 case COMPRESS_CONSTANT:
1157 return rawConstVal();
1164 engine = getCompressionEngine(myCompressionType);
1167 engine->
getValue(*
this, x, y, z+1),
1168 engine->
getValue(*
this, x, y+1, z),
1169 engine->
getValue(*
this, x, y+1, z+1) );
1171 engine->
getValue(*
this, x+1, y, z+1),
1172 engine->
getValue(*
this, x+1, y+1, z),
1173 engine->
getValue(*
this, x+1, y+1, z+1) );
1180 fx = frac.
swizzle<0, 0, 0, 0>();
1181 fy = frac.
swizzle<1, 1, 1, 1>();
1182 fz = frac.
swizzle<2, 2, 2, 2>();
1199 template <
typename T>
1204 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
1207 int i, xres = myRes[0];
1210 switch (myCompressionType)
1214 src = (
T *)myData + (z * myRes[1] + y) * xres;
1218 for (i = 0; i < xres; i++)
1219 cacheline[i] = src[i];
1221 return &cacheline[
x];
1223 case COMPRESS_FPREAL16:
1229 int xinc = tuple_size;
1230 int yinc = myRes[0] * xinc;
1231 int zinc = myRes[1] * yinc;
1232 int offset = z * zinc + y * yinc + x * xinc;
1237 for (i = 0; i < xres; i++, src += xinc)
1238 cacheline[i] = convertFromFP16(src);
1240 return &cacheline[
x];
1244 case COMPRESS_CONSTANT:
1245 src = rawConstData();
1246 if (!forcecopy && !strideofone)
1253 for (i = 0; i < xres; i++)
1254 cacheline[i] = *src;
1256 return &cacheline[
x];
1259 case COMPRESS_RAWFULL:
1261 src = (
T *)myData + (z * TILESIZE + y) * TILESIZE;
1265 for (i = 0; i < xres; i++)
1266 cacheline[i] = src[i];
1268 return &cacheline[
x];
1274 engine = getCompressionEngine(myCompressionType);
1279 for (i = 0; i < xres; i++)
1280 cacheline[i] = engine->
getValue(*
this, i, y, z);
1282 return &cacheline[
x];
1285 template <
typename T>
1293 int i, xres = myRes[0];
1296 switch (myCompressionType)
1299 dst = (
T *)myData + (z * myRes[1] + y) * xres;
1300 for (i = 0; i < xres; i++)
1301 *dst++ = *cacheline++;
1304 case COMPRESS_CONSTANT:
1305 value = rawConstVal();
1306 for (i = 0; i < xres; i++)
1307 if (cacheline[i] != value)
1315 case COMPRESS_RAWFULL:
1316 dst = (
T *)myData + (z * TILESIZE + y) * TILESIZE;
1317 for (i = 0; i < TILESIZE; i++)
1318 *dst++ = *cacheline++;
1325 for (i = 0; i < xres; i++)
1326 if (!writeThrough(i, y, z, cacheline[i]))
1334 writeCacheLine(cacheline, y, z);
1338 template <
typename T>
1342 int srcx,
int srcy,
int srcz)
1344 int w =
SYSmin(xres() - dstx, srctile.
xres() - srcx);
1345 int h =
SYSmin(yres() - dsty, srctile.
yres() - srcy);
1346 int d =
SYSmin(zres() - dstz, srctile.
zres() - srcz);
1362 dst += dstx + (dsty + dstz*yres())*xres();
1365 src += srcx + (srcy + srcz*srctile.
yres())*srctile.
xres();
1367 for (
int z = 0; z < d; z++)
1369 for (
int y = 0; y <
h; y++)
1373 for (
int x = 0; x <
w; x++)
1378 for (
int x = 0; x <
w; x++)
1383 src += srctile.
xres();
1385 dst += (yres()-
h) * xres();
1387 src += (srctile.
yres() -
h) * srctile.
xres();
1395 for (
int z = 0; z < d; z++)
1396 for (
int y = 0; y <
h; y++)
1397 for (
int x = 0; x <
w; x++)
1400 srctile(srcx+x, srcy+y, srcz+z));
1404 template <
typename T>
1405 template <
typename S>
1413 if (isSimpleCompression())
1419 srcinc = isConstant() ? 0 : 1;
1426 for (
int i = 0; i < w * h * d; i++)
1436 for (
int i = 0; i < w * h * d; i++)
1444 for (
int z = 0; z < d; z++)
1446 for (
int y = 0; y <
h; y++)
1450 for (
int x = 0; x <
w; x++)
1458 for (
int x = 0; x <
w; x++)
1474 for (
int z = 0; z < d; z++)
1475 for (
int y = 0; y <
h; y++)
1476 for (
int x = 0; x <
w; x++)
1478 *dst =
S((*
this)(x, y, z));
1483 template <
typename T>
1484 template <
typename S>
1491 int i,
n = w * h * d;
1495 int srcoff = srcstride;
1500 makeConstant(
T(compare));
1504 for (i = 1; i <
n; i++)
1506 if (srcdata[srcoff] != compare)
1508 srcoff += srcstride;
1514 makeConstant(compare);
1524 for (i = 0; i <
n; i++)
1526 *dst++ =
T(*srcdata++);
1534 for (i = 0; i <
n; i++)
1536 dst[i] =
T(srcdata[srcoff]);
1537 srcoff += srcstride;
1542 template <
typename T>
1547 UT_ASSERT_P(x < myRes[0] && y < myRes[1] && z < myRes[2]);
1551 if (writeThrough(x, y, z, t))
1564 template <
typename T>
1568 switch (myCompressionType)
1574 case COMPRESS_CONSTANT:
1580 cval = rawConstVal();
1583 myCompressionType = COMPRESS_RAW;
1585 if (myRes[0] == TILESIZE &&
1586 myRes[1] == TILESIZE)
1589 myCompressionType = COMPRESS_RAWFULL;
1592 n = myRes[0] * myRes[1] * myRes[2];
1595 for (i = 0; i <
n; i++)
1597 ((
T *)myData)[i] = cval;
1601 case COMPRESS_RAWFULL:
1606 if (myRes[0] == TILESIZE &&
1607 myRes[1] == TILESIZE)
1614 n = myRes[0] * myRes[1] * myRes[2];
1617 for (z = 0; z < myRes[2]; z++)
1619 for (y = 0; y < myRes[1]; y++)
1621 for (x = 0; x < myRes[0]; x++)
1623 raw[i++] = ((
T *)myData)[x+(y+z*TILESIZE)*TILESIZE];
1629 myCompressionType = COMPRESS_RAW;
1635 case COMPRESS_FPREAL16:
1644 n = myRes[0] * myRes[1] * myRes[2];
1647 for (z = 0; z < myRes[2]; z++)
1649 for (y = 0; y < myRes[1]; y++)
1651 for (x = 0; x < myRes[0]; x++, src += tuple_size)
1653 raw[i] = convertFromFP16(src);
1659 myCompressionType = COMPRESS_RAW;
1668 engine = getCompressionEngine(myCompressionType);
1676 for (z = 0; z < myRes[2]; z++)
1678 for (y = 0; y < myRes[1]; y++)
1680 for (x = 0; x < myRes[0]; x++)
1682 raw[i++] = engine->
getValue(*
this, x, y, z);
1690 myCompressionType = COMPRESS_RAW;
1691 if (myRes[0] == TILESIZE &&
1692 myRes[1] == TILESIZE)
1695 myCompressionType = COMPRESS_RAWFULL;
1701 template <
typename T>
1708 if (myCompressionType == COMPRESS_RAWFULL)
1713 UT_ASSERT(myCompressionType == COMPRESS_RAW);
1717 if (myRes[0] < TILESIZE || myRes[1] < TILESIZE)
1721 for (z = 0; z < myRes[2]; z++)
1723 for (y = 0; y < myRes[1]; y++)
1725 for (x = 0; x < myRes[0]; x++)
1727 raw[x+(y+z*TILESIZE)*TILESIZE] = ((
T *)myData)[i++];
1734 myCompressionType = COMPRESS_RAWFULL;
1737 template <
typename T>
1741 if (isRaw() || isRawFull())
1746 if (myRes[0] == TILESIZE && myRes[1] == TILESIZE)
1747 myCompressionType = COMPRESS_RAWFULL;
1749 myCompressionType = COMPRESS_RAW;
1754 template <
typename T>
1758 float irx, iry, irz;
1760 irx = 1.0 / myRes[0];
1761 iry = 1.0 / myRes[1];
1762 irz = 1.0 / myRes[2];
1763 switch (myCompressionType)
1768 const T *data = (
const T*) myData;
1773 for (
int z = 0; z < myRes[2]; z++)
1777 for (
int y = 0; y < myRes[1]; y++)
1781 for (
int x = 0; x < myRes[0]; x++)
1797 case COMPRESS_FPREAL16:
1810 static_assert(tuple_size <= 4);
1812 for (
int z = 0; z < myRes[2]; z++)
1815 for (
int y = 0; y < myRes[1]; y++)
1818 for (
int x = 0; x < myRes[0]; x++)
1820 for (
int j = 0;
j < tuple_size;
j++)
1822 xavg[
j] += data[i++];
1825 for (
int j = 0;
j < tuple_size;
j++)
1831 for (
int j = 0;
j < tuple_size;
j++)
1837 for (
int j = 0;
j < tuple_size;
j++)
1842 avg = convertFromFP16(zavg);
1846 case COMPRESS_CONSTANT:
1847 avg = rawConstVal();
1850 case COMPRESS_RAWFULL:
1853 const T *data = (
const T*) myData;
1858 for (
int z = 0; z < myRes[2]; z++)
1862 for (
int y = 0; y < myRes[1]; y++)
1866 for (
int x = 0; x < myRes[0]; x++)
1887 for (
int z = 0; z < myRes[2]; z++)
1891 for (
int y = 0; y < myRes[1]; y++)
1895 for (
int x = 0; x < myRes[0]; x++)
1897 xavg += (*this)(
x,
y,
z);
1913 template <
typename T>
1917 switch (myCompressionType)
1921 int n = myRes[0] * myRes[1] * myRes[2];
1924 min = max = *(
T*)myData;
1925 for (i = 1; i <
n; i++)
1927 expandMinMax( ((
T*)myData)[i], min, max );
1932 case COMPRESS_FPREAL16:
1937 int n = myRes[0] * myRes[1] * myRes[2];
1942 for (i = 1; i <
n; i++, src += tuple_size)
1944 T val = convertFromFP16(src);
1945 expandMinMax( val, min, max );
1950 case COMPRESS_CONSTANT:
1951 min = max = rawConstVal();
1954 case COMPRESS_RAWFULL:
1958 min = max = *(
T*)myData;
1960 for (z = 0; z < myRes[2]; z++)
1962 for (y = 0; y < myRes[1]; y++)
1964 for (x = 0; x < myRes[0]; x++)
1967 ((
T*)myData)[x+offset],
1981 engine = getCompressionEngine(myCompressionType);
1989 template <
typename T>
1993 switch (myCompressionType)
1996 case COMPRESS_RAWFULL:
1998 int n = myRes[0] * myRes[1] * myRes[2];
2001 for (i = 0; i <
n; i++)
2009 case COMPRESS_FPREAL16:
2014 case COMPRESS_CONSTANT:
2025 engine = getCompressionEngine(myCompressionType);
2027 for (z = 0; z < myRes[2]; z++)
2028 for (y = 0; y < myRes[1]; y++)
2029 for (x = 0; x < myRes[0]; x++)
2040 template <
typename T>
2050 if (myCompressionType == COMPRESS_CONSTANT)
2053 findMinMax(min, max);
2059 if (myCompressionType == COMPRESS_CONSTANT)
2080 if (myCompressionType == COMPRESS_RAW ||
2081 myCompressionType == COMPRESS_RAWFULL)
2088 for (i = 0; i < getCompressionEngines().entries(); i++)
2090 engine = getCompressionEngines()(i);
2096 if (engine->
tryCompress(*
this, options, min, max))
2098 myCompressionType = i + COMPRESS_ENGINE;
2107 if (myCompressionType == COMPRESS_RAW)
2109 if (myRes[0] == TILESIZE && myRes[1] == TILESIZE)
2111 myCompressionType = COMPRESS_RAWFULL;
2119 template <
typename T>
2127 if (!inlineConstant())
2131 myCompressionType = COMPRESS_CONSTANT;
2132 *rawConstData() =
t;
2135 template <
typename T>
2147 if (myCompressionType == COMPRESS_FPREAL16)
2151 int len = myRes[2] * myRes[1] * myRes[0] * tuple_size;
2154 if (myCompressionType == COMPRESS_RAW ||
2155 myCompressionType == COMPRESS_RAWFULL)
2157 for (
int i = 0; i < len; i++)
2167 for (
int z = 0; z < myRes[2]; z++)
2169 for (
int y = 0; y < myRes[1]; y++)
2171 for (
int x = 0; x < myRes[0]; x++)
2173 if constexpr (tuple_size == 1)
2178 for (
int j = 0;
j < tuple_size;
j++)
2190 myCompressionType = COMPRESS_FPREAL16;
2193 template <
typename T>
2197 int64 mem = inclusive ?
sizeof(*this) : 0;
2198 mem += getDataLength();
2202 template <
typename T>
2208 switch (myCompressionType)
2211 usage =
sizeof(
T) * xres() * yres() * zres();
2213 case COMPRESS_FPREAL16:
2214 usage =
sizeof(
fpreal16) * xres() * yres() * zres()
2217 case COMPRESS_CONSTANT:
2218 if (inlineConstant())
2223 case COMPRESS_RAWFULL:
2224 usage =
sizeof(
T) * TILESIZE * TILESIZE * zres();
2230 engine = getCompressionEngine(myCompressionType);
2238 template <
typename T>
2241 const float *weights[3],
int start[3],
2251 switch (myCompressionType)
2253 case COMPRESS_CONSTANT:
2256 for (i = 0; i < 3; i++)
2259 for (ix = 0; ix < pend[i]-pstart[i]; ix++)
2260 pw += weights[i][ix+pstart[i]-start[i]];
2263 result += w * rawConstVal();
2269 tstart[0] = pstart[0] & TILEMASK;
2270 tstart[1] = pstart[1] & TILEMASK;
2271 tstart[2] = pstart[2] & TILEMASK;
2272 ixstart = pstart[0]-start[0];
2273 ixend = pend[0]-start[0];
2277 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2282 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2285 px = ((pz * myRes[1]) + py) * myRes[0] + tstart[0];
2286 for (ix = ixstart; ix < ixend; ix++, px++)
2288 psumx += weights[0][ix]* ((
T*)myData)[px];
2290 psumy += weights[1][iy-start[1]] * psumx;
2292 result += weights[2][iz-start[2]] * psumy;
2297 case COMPRESS_FPREAL16:
2302 int xinc = tuple_size;
2303 int yinc = myRes[0] * xinc;
2304 int zinc = myRes[1] * yinc;
2308 tstart[0] = pstart[0] & TILEMASK;
2309 tstart[1] = pstart[1] & TILEMASK;
2310 tstart[2] = pstart[2] & TILEMASK;
2311 ixstart = pstart[0]-start[0];
2312 ixend = pend[0]-start[0];
2316 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2321 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2324 px = pz * zinc + py * yinc + tstart[0] * xinc;
2325 for (ix = ixstart; ix < ixend; ix++, px += xinc)
2327 T val = convertFromFP16(src + px);
2328 psumx += weights[0][ix]*
val;
2330 psumy += weights[1][iy-start[1]] * psumx;
2332 result += weights[2][iz-start[2]] * psumy;
2336 case COMPRESS_RAWFULL:
2338 tstart[0] = pstart[0] & TILEMASK;
2339 tstart[1] = pstart[1] & TILEMASK;
2340 tstart[2] = pstart[2] & TILEMASK;
2341 ixstart = pstart[0]-start[0];
2342 ixend = pend[0]-start[0];
2344 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2348 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2351 px = ((pz * TILESIZE) + py) * TILESIZE + tstart[0];
2352 for (ix = ixstart; ix < ixend; ix++, px++)
2354 psumx += weights[0][ix]* ((
T*)myData)[px];
2356 psumy += weights[1][iy-start[1]] * psumx;
2358 result += weights[2][iz-start[2]] * psumy;
2368 tstart[0] = pstart[0] & TILEMASK;
2369 tstart[1] = pstart[1] & TILEMASK;
2370 tstart[2] = pstart[2] & TILEMASK;
2371 ixstart = pstart[0]-start[0];
2372 ixend = pend[0]-start[0];
2374 for (iz = pstart[2]; iz < pend[2]; iz++, pz++)
2378 for (iy = pstart[1]; iy < pend[1]; iy++, py++)
2382 for (ix = ixstart; ix < ixend; ix++, px++)
2384 psumx += weights[0][ix] *
2385 (*this)(px,
py, pz);
2387 psumy += weights[1][iy-start[1]] * psumx;
2389 result += weights[2][iz-start[2]] * psumy;
2396 template <
typename T>
2403 for (i = 0; i < getCompressionEngines().entries(); i++)
2405 if (!strcmp(engine->
getName(), getCompressionEngines()(i)->
getName()))
2407 getCompressionEngines()(i) = engine;
2412 getCompressionEngines().append(engine);
2415 template <
typename T>
2424 for (i = 0; i < getCompressionEngines().entries(); i++)
2426 if (!strcmp(name, getCompressionEngines()(i)->
getName()))
2428 return i + COMPRESS_ENGINE;
2435 template <
typename T>
2439 index -= COMPRESS_ENGINE;
2441 return getCompressionEngines()(
index);
2444 template <
typename T>
2449 if (myCompressionType >= COMPRESS_ENGINE)
2455 char type = myCompressionType;
2457 UTwrite(os, &type, 1);
2458 engine->
save(os, *
this);
2463 char type = COMPRESS_RAW;
2466 UTwrite(os, &type, 1);
2468 for (
int z = 0; z < zres(); z++)
2469 for (
int y = 0; y < yres(); y++)
2470 for (
int x = 0; x < xres(); x++)
2472 value = (*this)(
x,
y,
z);
2473 UTwrite<T>(os, &
value, 1);
2479 char type = myCompressionType;
2481 if (type == COMPRESS_RAWFULL &&
2482 myRes[0] == TILESIZE &&
2483 myRes[1] == TILESIZE &&
2484 myRes[2] != TILESIZE)
2488 type = COMPRESS_RAW;
2491 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2493 UTwrite(os, &type, 1);
2498 len = myRes[2] * myRes[1] * myRes[0];
2499 UTwrite<T>(os, (
T *) myData, len);
2502 case COMPRESS_FPREAL16:
2503 len = myRes[2] * myRes[1] * myRes[0]
2505 UTwrite(os, (
int16 *) myData, len);
2508 case COMPRESS_RAWFULL:
2509 len = TILESIZE * TILESIZE * TILESIZE;
2510 UTwrite<T>(os, (
T *) myData, len);
2513 case COMPRESS_CONSTANT:
2514 UTwrite<T>(os, rawConstData(), 1);
2517 case COMPRESS_ENGINE:
2523 template <
typename T>
2533 if (type >= 0 && type < compress.
entries())
2536 type = compress(type);
2539 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2543 if (type >= COMPRESS_ENGINE)
2546 myCompressionType =
type;
2548 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2551 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2557 engine->
load(is, *
this);
2570 myCompressionType =
type;
2575 len = myRes[2] * myRes[1] * myRes[0];
2577 is.
read<
T>((
T *) myData, len);
2580 case COMPRESS_FPREAL16:
2581 len = myRes[2] * myRes[1] * myRes[0]
2587 case COMPRESS_RAWFULL:
2588 len = TILESIZE * TILESIZE * TILESIZE;
2590 is.
read<
T>((
T *) myData, len);
2593 case COMPRESS_CONSTANT:
2594 if (!inlineConstant())
2596 is.
read<
T>(rawConstData(), 1);
2599 case COMPRESS_ENGINE:
2605 if (myCompressionType == COMPRESS_RAW &&
2606 myRes[0] == TILESIZE &&
2607 myRes[1] == TILESIZE)
2608 myCompressionType = COMPRESS_RAWFULL;
2611 template <
typename T>
2621 if (myCompressionType >= COMPRESS_ENGINE)
2627 char type = myCompressionType;
2635 ok = ok && engine->
save(w, *
this);
2641 char type = COMPRESS_RAW;
2654 for (
int z = 0; z < zres(); z++)
2655 for (
int y = 0; y < yres(); y++)
2656 for (
int x = 0; x < xres(); x++)
2658 value = (*this)(
x,
y,
z);
2659 if constexpr (tuple_size == 1)
2665 for (
int i = 0; i < tuple_size; i++)
2677 char type = myCompressionType;
2679 UT_ASSERT(type >= 0 && type < COMPRESS_ENGINE);
2687 switch (myCompressionType)
2690 len = myRes[2] * myRes[1] * myRes[0];
2694 case COMPRESS_FPREAL16:
2699 case COMPRESS_RAWFULL:
2700 len = TILESIZE * TILESIZE * myRes[2];
2704 case COMPRESS_CONSTANT:
2705 if constexpr (tuple_size == 1)
2716 template <
typename T>
2746 if (type >= 0 && type < compress.
entries())
2749 type = compress(type);
2752 std::cerr <<
"Missing compression engine " << (
int) otype <<
"\n";
2756 if (type >= COMPRESS_ENGINE)
2759 myCompressionType =
type;
2761 if (type - COMPRESS_ENGINE >= getCompressionEngines().entries())
2764 std::cerr <<
"Invalid compression engine " << (
int) otype <<
"\n";
2770 bool engine_ok = engine->
load(p, *
this);
2772 return it.
atEnd() && engine_ok;
2783 myCompressionType =
type;
2785 switch (myCompressionType)
2788 len = myRes[2] * myRes[1] * myRes[0];
2795 case COMPRESS_FPREAL16:
2802 case COMPRESS_RAWFULL:
2803 len = TILESIZE * TILESIZE * myRes[2];
2810 case COMPRESS_CONSTANT:
2811 if (!inlineConstant())
2813 if constexpr (tuple_size == 1)
2830 template <
typename T>
2834 int16 ntype = getCompressionEngines().entries();
2837 ntype += COMPRESS_ENGINE;
2839 UTwrite(os, &ntype);
2847 ntype -= COMPRESS_ENGINE;
2848 for (i = 0; i < ntype; i++)
2854 template <
typename T>
2865 for (i = 0; i < ntype; i++)
2871 compress.
append(COMPRESS_RAW);
2872 else if (name ==
"rawfull")
2873 compress.
append(COMPRESS_RAWFULL);
2874 else if (name ==
"constant")
2875 compress.
append(COMPRESS_CONSTANT);
2876 else if (name ==
"fpreal16")
2877 compress.
append(COMPRESS_FPREAL16);
2880 idx = lookupCompressionEngine(name);
2890 template <
typename T>
2894 int16 ntype = getCompressionEngines().entries();
2898 ntype += COMPRESS_ENGINE;
2907 ntype -= COMPRESS_ENGINE;
2908 for (i = 0; i < ntype; i++)
2917 template <
typename T>
2931 if (!buffer.
strcmp(
"raw"))
2932 compress.
append(COMPRESS_RAW);
2933 else if (!buffer.
strcmp(
"rawfull"))
2934 compress.
append(COMPRESS_RAWFULL);
2935 else if (!buffer.
strcmp(
"constant"))
2936 compress.
append(COMPRESS_CONSTANT);
2937 else if (!buffer.
strcmp(
"fpreal16"))
2938 compress.
append(COMPRESS_FPREAL16);
2941 idx = lookupCompressionEngine(buffer.
buffer());
2958 template <
typename T>
2973 myBorderScale[0] = 0;
2974 myBorderScale[1] = 0;
2975 myBorderScale[2] = 0;
2979 mySharedMemView = 0;
2982 template <
typename T>
2988 template <
typename T>
3002 mySharedMemView = 0;
3007 template <
typename T>
3014 vit.splitByTile(info);
3015 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3017 int i = vit.getLinearTileNum();
3018 myTiles[i] = src.myTiles[i];
3022 template <
typename T>
3030 myBorderScale[0] = src.myBorderScale[0];
3031 myBorderScale[1] = src.myBorderScale[1];
3032 myBorderScale[2] = src.myBorderScale[2];
3033 myBorderValue = src.myBorderValue;
3034 myBorderType = src.myBorderType;
3036 myCompressionOptions = src.myCompressionOptions;
3040 size(src.myRes[0], src.myRes[1], src.myRes[2],
false);
3050 #define __MULTITHREADED_STRUCTORS__
3051 template <
typename T>
3055 #ifdef __MULTITHREADED_STRUCTORS__
3060 for(
int i = range.begin(); i < range.end(); i++)
3062 myTiles[i].~UT_VoxelTile<
T>();
3065 operator delete(myTiles, std::nothrow);
3071 myTileRes[0] = myTileRes[1] = myTileRes[2] = 0;
3072 myRes[0] = myRes[1] = myRes[2] = 0;
3074 delete mySharedMemView;
3075 mySharedMemView = 0;
3081 template <
typename T>
3086 if (myRes[0] == xres && myRes[1] == yres && myRes[2] == zres)
3101 tile_res[0] = (xres + TILEMASK) >> TILEBITS;
3102 tile_res[1] = (yres + TILEMASK) >> TILEBITS;
3103 tile_res[2] = (zres + TILEMASK) >> TILEBITS;
3105 exint ntiles = ((
exint)tile_res[0]) * tile_res[1] * tile_res[2];
3108 #ifdef __MULTITHREADED_STRUCTORS__
3122 for(
int k = range.begin(); k < range.end(); k++)
3127 int tilex = k % tile_res[0];
3128 int k2 = k / tile_res[0];
3129 int tiley = k2 % tile_res[1];
3130 int tilez = k2 / tile_res[1];
3131 myTiles[k].
setRes(
SYSmin(TILESIZE, xres - tilex * TILESIZE),
3132 SYSmin(TILESIZE, yres - tiley * TILESIZE),
3133 SYSmin(TILESIZE, zres - tilez * TILESIZE));
3147 myInvRes.x() = 1.0f / myRes[0];
3149 myInvRes.y() = 1.0f / myRes[1];
3151 myInvRes.z() = 1.0f / myRes[2];
3153 myTileRes[0] = tile_res[0];
3154 myTileRes[1] = tile_res[1];
3155 myTileRes[2] = tile_res[2];
3157 #ifndef __MULTITHREADED_STRUCTORS__
3159 for (
int tz = 0; tz < myTileRes[2]; tz++)
3162 if (tz < myTileRes[2]-1)
3165 zr = zres - tz * TILESIZE;
3167 for (
int ty = 0; ty < myTileRes[1]; ty++)
3170 if (ty < myTileRes[1]-1)
3173 yr = yres - ty * TILESIZE;
3175 int tx, xr = TILESIZE;
3176 for (tx = 0; tx < myTileRes[0]-1; tx++)
3178 myTiles[i].
setRes(xr, yr, zr);
3182 xr = xres - tx * TILESIZE;
3183 myTiles[i].setRes(xr, yr, zr);
3193 template <
typename T>
3202 myBorderType = src.myBorderType;
3203 myBorderScale[0] = src.myBorderScale[0];
3204 myBorderScale[1] = src.myBorderScale[1];
3205 myBorderScale[2] = src.myBorderScale[2];
3206 myBorderValue = src.myBorderValue;
3209 myCompressionOptions = src.myCompressionOptions;
3212 template <
typename T>
3216 int64 mem = inclusive ?
sizeof(*this) : 0;
3218 int ntiles = numTiles();
3219 for (
int i = 0; i < ntiles; i++)
3220 mem += myTiles[i].getMemoryUsage(
true);
3223 mem += mySharedMem->getMemoryUsage(
true);
3225 if (mySharedMemView)
3226 mem += mySharedMemView->getMemoryUsage(
true);
3231 template <
typename T>
3238 vit.setPartialRange(info.
job(), info.
numJobs());
3239 for (vit.rewind(); !vit.atEnd(); vit.advanceTile())
3241 int i = vit.getLinearTileNum();
3242 myTiles[i].makeConstant(t);
3246 template <
typename T>
3255 ntiles = numTiles();
3256 for (i = 0; i < ntiles; i++)
3258 if (!myTiles[i].isConstant())
3266 cval = myTiles[i].rawConstVal();
3286 template <
typename T>
3292 ntiles = numTiles();
3293 for (i = 0; i < ntiles; i++)
3295 if (myTiles[i].hasNan())
3304 template <
typename T>
3310 pos.
x() *= myRes[0];
3311 pos.
y() *= myRes[1];
3312 pos.
z() *= myRes[2];
3317 return lerpVoxelCoord(pos);
3320 template <
typename T>
3328 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3330 return lerpVoxel(x, y, z, fx, fy, fz);
3333 template <
typename T>
3334 template <
int AXIS2D>
3342 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3344 return lerpVoxelAxis<AXIS2D>(
x,
y,
z, fx, fy, fz);
3347 template <
typename T>
3350 float fx,
float fy,
float fz)
const
3353 T vx, vx1, vy, vy1, vz;
3357 if ( !((x | y | z) < 0) &&
3358 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3371 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3374 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3376 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
3390 (*
this)(x+1, y+1, z),
3397 (*
this)(x+1, y, z+1),
3401 (*
this)(x+1, y+1, z+1),
3444 template <
typename T>
3445 template <
int AXIS2D>
3448 float fx,
float fy,
float fz)
const
3451 T vx, vx1, vy, vy1, vz;
3453 int lesscomp = 0, greatercomp = -1;
3458 greatercomp &= (x - myRes[0]+1);
3463 greatercomp &= (y - myRes[1]+1);
3468 greatercomp &= (z - myRes[2]+1);
3473 if ( !(lesscomp < 0) && (greatercomp < 0) )
3481 if ((AXIS2D == 0 || xm != TILEMASK) &&
3482 (AXIS2D == 1 || ym != TILEMASK) &&
3483 (AXIS2D == 2 || zm != TILEMASK))
3486 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3487 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3488 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3490 vz = tile->template lerpAxis<AXIS2D>(xm, ym, zm, fx, fy, fz);
3504 vx = (*this)(
x,
y,
z);
3511 (*
this)(x+1, y+1, z),
3514 vx1 = (*this)(
x, y+1,
z);
3526 (*
this)(x+1, y, z+1),
3529 vx = (*this)(
x,
y, z+1);
3536 (*
this)(x+1, y+1, z+1),
3539 vx1 = (*this)(
x, y+1, z+1);
3613 template <
typename T>
3620 pos.
x() *= myRes[0];
3621 pos.
y() *= myRes[1];
3622 pos.
z() *= myRes[2];
3627 lerpVoxelCoordMinMax(lerp, lmin, lmax, pos);
3630 template <
typename T>
3639 splitVoxelCoord(pos, x, y, z, fx, fy, fz);
3641 lerpVoxelMinMax(lerp, lmin, lmax, x, y, z, fx, fy, fz);
3645 template <
typename T>
3646 template <
int AXIS2D>
3655 splitVoxelCoordAxis<AXIS2D>(pos,
x,
y,
z, fx, fy, fz);
3657 lerpVoxelMinMaxAxis<AXIS2D>(
lerp, lmin, lmax,
x,
y,
z, fx, fy, fz);
3661 template <
typename T>
3665 int x,
int y,
int z,
3666 float fx,
float fy,
float fz)
const
3670 if (extractSample(x, y, z, samples))
3672 lerp = smin = smax = samples[0];
3676 lerp = lerpSample(samples, fx, fy, fz);
3680 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3682 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3685 smin =
SYSmin(smin, smin1);
3686 smax =
SYSmax(smax, smax1);
3689 template <
typename T>
3690 template <
int AXIS2D>
3694 int x,
int y,
int z,
3695 float fx,
float fy,
float fz)
const
3699 if (extractSampleAxis<AXIS2D>(x, y, z, samples))
3701 lerp = smin = smax = samples[0];
3705 lerp = lerpSampleAxis<AXIS2D>(
samples, fx, fy, fz);
3708 SYSminmax(samples[0], samples[2], samples[4], samples[6],
3710 else if (AXIS2D == 1)
3711 SYSminmax(samples[0], samples[1], samples[4], samples[5],
3713 else if (AXIS2D == 2)
3714 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3720 SYSminmax(samples[0], samples[1], samples[2], samples[3],
3722 SYSminmax(samples[4+0], samples[4+1], samples[4+2], samples[4+3],
3725 smin =
SYSmin(smin, smin1);
3726 smax =
SYSmax(smax, smax1);
3730 template <
typename T>
3737 if ( !((x | y | z) < 0) &&
3738 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3751 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3754 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3763 samples[0] = (*this)(
x,
y,
z);
3764 samples[1] = (*this)(x+1,
y,
z);
3765 samples[2+0] = (*this)(
x, y+1,
z);
3766 samples[2+1] = (*this)(x+1, y+1,
z);
3767 samples[4+0] = (*this)(
x,
y, z+1);
3768 samples[4+1] = (*this)(x+1,
y, z+1);
3769 samples[4+2+0] = (*this)(
x, y+1, z+1);
3770 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3777 samples[2+0] =
getValue(x, y+1, z);
3778 samples[2+1] =
getValue(x+1, y+1, z);
3779 samples[4+0] =
getValue(x, y, z+1);
3780 samples[4+1] =
getValue(x+1, y, z+1);
3781 samples[4+2+0] =
getValue(x, y+1, z+1);
3782 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3789 template <
typename T>
3790 template <
int AXIS2D>
3797 int lesscomp = 0, greatercomp = -1;
3802 greatercomp &= (x - myRes[0]+1);
3807 greatercomp &= (y - myRes[1]+1);
3812 greatercomp &= (z - myRes[2]+1);
3817 if ( !(lesscomp < 0) && (greatercomp < 0) )
3825 if ((AXIS2D == 0 || xm != TILEMASK) &&
3826 (AXIS2D == 1 || ym != TILEMASK) &&
3827 (AXIS2D == 2 || zm != TILEMASK))
3830 getTile( (AXIS2D == 0) ? 0 : (x >> TILEBITS),
3831 (AXIS2D == 1) ? 0 : (y >> TILEBITS),
3832 (AXIS2D == 2) ? 0 : (z >> TILEBITS) );
3834 return tile->template extractSampleAxis<AXIS2D>(xm, ym, zm,
samples);
3841 samples[0] = (*this)(
x,
y,
z);
3843 samples[1] = (*this)(x+1,
y,
z);
3846 samples[2+0] = (*this)(
x, y+1,
z);
3848 samples[2+1] = (*this)(x+1, y+1,
z);
3852 samples[4+0] = (*this)(
x,
y, z+1);
3854 samples[4+1] = (*this)(x+1,
y, z+1);
3857 samples[4+2+0] = (*this)(
x, y+1, z+1);
3859 samples[4+2+1] = (*this)(x+1, y+1, z+1);
3871 samples[2+0] =
getValue(x, y+1, z);
3873 samples[2+1] =
getValue(x+1, y+1, z);
3877 samples[4+0] =
getValue(x, y, z+1);
3879 samples[4+1] =
getValue(x+1, y, z+1);
3882 samples[4+2+0] =
getValue(x, y+1, z+1);
3884 samples[4+2+1] =
getValue(x+1, y+1, z+1);
3892 template <
typename T>
3899 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
3900 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3913 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3916 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3925 samples[0] = (*this)(x-1,
y,
z);
3926 samples[1] = (*this)(x+1,
y,
z);
3927 samples[2+0] = (*this)(
x, y-1,
z);
3928 samples[2+1] = (*this)(
x, y+1,
z);
3929 samples[4+0] = (*this)(
x,
y, z-1);
3930 samples[4+1] = (*this)(
x,
y, z+1);
3931 samples[6] = (*this)(
x,
y,
z);
3938 samples[2+0] =
getValue(x, y-1, z);
3939 samples[2+1] =
getValue(x, y+1, z);
3940 samples[4+0] =
getValue(x, y, z-1);
3941 samples[4+1] =
getValue(x, y, z+1);
3952 template <
typename T>
3959 if ( !(((x-1) | (y-1) | (z-1)) < 0) &&
3960 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
3973 if (xm && ym && zm && (xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
3976 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
3978 return tile->extractSampleCube(xm, ym, zm, samples);
3986 for (
int dz = -1; dz <= 1; dz++)
3988 for (
int dy = -1; dy <= 1; dy++)
3990 for (
int dx = -1; dx <= 1; dx++)
3992 samples[sampidx++] = (*this)(x+dx, y+dy, z+dz);
4001 for (
int dz = -1; dz <= 1; dz++)
4003 for (
int dy = -1; dy <= 1; dy++)
4005 for (
int dx = -1; dx <= 1; dx++)
4007 samples[sampidx++] =
getValue(x+dx, y+dy, z+dz);
4017 template <
typename T>
4020 float fx,
float fy,
float fz)
const
4024 T vx, vx1, vy, vy1, vz;
4054 v4uf a,
b, vfx, vfy, vfz;
4056 a =
v4uf(&samples[0]);
4057 b =
v4uf(&samples[4]);
4078 template <
typename T>
4079 template <
int AXIS2D>
4082 float fx,
float fy,
float fz)
const
4085 T vx, vx1, vy, vy1, vz;
4138 template <
typename T>
4148 pos.
x() *= myRes[0];
4149 pos.
y() *= myRes[1];
4150 pos.
z() *= myRes[2];
4157 SYSfastSplitFloat(fx, x);
4159 SYSfastSplitFloat(fy, y);
4161 SYSfastSplitFloat(fz, z);
4164 T vx, vx1, vy, vy1, vz;
4180 if ( !((x | y | z) < 0) &&
4181 (((x - myRes[0]+1) & (y - myRes[1]+1) & (z - myRes[2]+1)) < 0))
4193 if ((xm != TILEMASK) && (ym != TILEMASK) && (zm != TILEMASK))
4196 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4198 vz = tile->
lerp(xm, ym, zm, fx, fy, fz);
4212 (*
this)(x+1, y+1, z),
4219 (*
this)(x+1, y, z+1),
4223 (*
this)(x+1, y+1, z+1),
4267 template <
typename T>
4277 pos *=
v4uf((
float) myRes[0], (
float) myRes[1], (
float) myRes[2], 0.0
f);
4306 if ( (x > 0) & (y > 0) & (z > 0) &
4307 (x < myRes[0]-1) & (y < myRes[1]-1) & (z < myRes[2]-1) &
4308 (xm != TILEMASK) & (ym != TILEMASK) & (zm != TILEMASK) )
4317 getTile(x >> TILEBITS, y >> TILEBITS, z >> TILEBITS);
4319 return tile->
lerp(pos, xm, ym, zm);
4333 fx = pos.
swizzle<0, 0, 0, 0>();
4334 fy = pos.
swizzle<1, 1, 1, 1>();
4335 fz = pos.
swizzle<2, 2, 2, 2>();
4353 firstTile(
int &
start,
int &
end,
int res)
4364 nextTile(
int &tile,
int &pstart,
int &start,
int &end,
int res)
4374 tile = pstart >> TILEBITS;
4375 pend =
SYSmin((tile+1) * TILESIZE, end, res);
4385 template <
typename T>
4388 fpreal radius,
int clampaxis)
const
4394 const float *weights[3];
4396 int start[3], end[3],
size[3];
4397 int pstart[3], pend[3];
4404 return myBorderValue;
4408 switch (myBorderType)
4419 for (i = 0; i < 3; i++)
4427 memset(&result, 0,
sizeof(result));
4434 for (i = 0; i < 3; i++)
4436 tpos[i] = tpos[i]*myRes[i];
4437 if (!win[i].setWeights(filter, tpos[i], radius, myRes[i], wrap[i]))
4441 start[i] = win[i].
getStart() % myRes[i];
4447 end[i] = start[i] + size[i];
4452 pstart[2] = firstTile(start[2], end[2], myRes[2]);
4453 while (pstart[2] < end[2])
4455 pend[2] = nextTile(tz, pstart[2], start[2], end[2], myRes[2]);
4456 pstart[1] = firstTile(start[1], end[1], myRes[1]);
4457 while (pstart[1] < end[1])
4459 pend[1] = nextTile(ty, pstart[1], start[1], end[1], myRes[1]);
4460 pstart[0] = firstTile(start[0], end[0], myRes[0]);
4461 while (pstart[0] < end[0])
4463 pend[0] = nextTile(tx, pstart[0], start[0], end[0], myRes[0]);
4464 tile = getTile(tx, ty, tz);
4466 tile->
weightedSum(pstart, pend, weights, start, result);
4467 pstart[0] = pend[0];
4469 pstart[1] = pend[1];
4471 pstart[2] = pend[2];
4476 result += (1-visible)*myBorderValue;
4482 template <
typename T>
4486 float filterwidthscale,
4498 radius *= 0.5 * filterwidthscale;
4500 resamplethread(src, filter, radius, clampaxis);
4505 template <
typename T>
4506 template <
typename OP>
4513 for (
int tileidx =
range.begin(); tileidx !=
range.end(); tileidx++)
4530 template <
typename T>
4537 if (getXRes() == 1 && ystride == 1)
4539 flattenPartialAxis<0>(flatarray, zstride, info);
4541 else if (getYRes() == 1 && zstride == ystride)
4543 flattenPartialAxis<1>(flatarray, zstride, info);
4545 else if (getZRes() == 1)
4547 flattenPartialAxis<2>(flatarray, ystride, info);
4561 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4567 template <
typename T>
4568 template <
int AXIS2D>
4575 const int ax = (AXIS2D == 0) ? 1 : 0;
4576 const int ay = (AXIS2D == 2) ? 1 : 2;
4577 int tileidx[3] = { 0, 0, 0 };
4582 exint ystart = tiley * TILESIZE;
4583 if (ystart >= getRes(ay))
4586 T *stripe = &flatarray[ystart * ystride];
4588 int yres =
SYSmin(getRes(ay) - ystart, TILESIZE);
4590 for (
int tilex = 0, ntilex = getTileRes(ax); tilex < ntilex; tilex++)
4592 tileidx[ax] = tilex;
4593 tileidx[ay] = tiley;
4594 auto tile = getTile(tileidx[0], tileidx[1], tileidx[2]);
4596 int xres = tile->getRes(ax);
4597 T *stripey = stripe;
4598 if (tile->isConstant())
4600 const T *srcdata = tile->rawData();
4602 for (
int y = 0; y < yres; y++)
4604 for (
int x = 0; x < xres; x++)
4606 memcpy(&stripey[x], srcdata,
sizeof(
T));
4611 else if (tile->isSimpleCompression())
4613 const T *srcdata = tile->rawData();
4615 if (xres != TILESIZE)
4617 for (
int y = 0; y < yres; y++)
4619 memcpy(stripey, srcdata,
sizeof(
T) * xres);
4626 for (
int y = 0; y < yres; y++)
4628 memcpy(stripey, srcdata,
sizeof(
T) * TILESIZE);
4629 srcdata += TILESIZE;
4636 for (
int y = 0; y < yres; y++)
4638 int idx[3] = { 0, 0, 0 };
4640 for (
int x = 0; x < xres; x++)
4643 stripey[
x] = (*tile)(idx[0], idx[1], idx[2]);
4673 int idx = (vit.
x() + vit.
y()*ystride + vit.
z()*zstride) * 4;
4676 flatarray[idx+1] = (
uint8)
SYSclamp(v.
y() * 255.0f, 0.0f, 255.0f);
4677 flatarray[idx+2] = (
uint8)
SYSclamp(v.
z() * 255.0f, 0.0f, 255.0f);
4678 flatarray[idx+3] = (
uint8)
SYSclamp(v.
w() * 255.0f, 0.0f, 255.0f);
4682 template <
typename T>
4688 UT_ASSERT(!
"This template requires specific instantiations.");
4707 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] = vit.
getValue();
4710 template <
typename T>
4716 UT_ASSERT(!
"This template requires specific instantiations.");
4751 flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride] =
v;
4755 template <
typename T>
4761 UT_ASSERT(!
"This template requires specific instantiations.");
4765 template <
typename T>
4779 vit.
setValue(flatarray[vit.
x() + vit.
y()*ystride + vit.
z()*zstride]);
4783 template <
typename T>
4784 template <
int SLICE,
typename S>
4788 int slice_res = getRes(SLICE);
4790 if (slice < 0 || slice >= slice_res ||
4791 (half_slice && slice == slice_res - 1))
4794 constexpr
int AXIS1 = (SLICE == 0 ? 1 : 0);
4795 constexpr
int AXIS2 = (SLICE == 1 ? 2 : 1);
4798 int a1_res = getRes(AXIS1);
4800 int a1_tiles = getTileRes(AXIS1);
4801 int a2_tiles = getTileRes(AXIS2);
4802 int ntiles = a1_tiles * a2_tiles;
4805 int tile_stride2 = (a1_res << TILEBITS);
4806 int tile_stride1 = TILESIZE;
4808 int tile_slice = (slice >> TILEBITS);
4809 int local_slice = (slice & TILEMASK);
4812 bool half_slice_st = half_slice && (local_slice != TILEMASK);
4815 bool half_slice_tb =
false;
4827 auto set_functor = [&](
const UT_VoxelTile<T>* tile,
int idx[3],
int vidx)
4831 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
4833 dstdata[vidx] = 0.5f * (dstdata[vidx] +
4834 (*tile)(idx[0], idx[1], idx[2]));
4837 else if (half_slice_tb)
4838 dstdata[vidx] = 0.5f * (dstdata[vidx] +
4839 (*tile)(idx[0], idx[1], idx[2]));
4841 dstdata[vidx] = (*tile)(idx[0], idx[1], idx[2]);
4849 is[SLICE] = tile_slice;
4852 is_local[SLICE] = local_slice;
4854 for (
int i =
range.begin(); i <
range.end(); i++)
4857 is[AXIS1] = i % a1_tiles;
4858 is[AXIS2] = i / a1_tiles;
4862 int a1_tile_res = tile->
getRes(AXIS1);
4863 int a2_tile_res = tile->
getRes(AXIS2);
4865 int vcounter = is[AXIS2] * tile_stride2 + is[AXIS1] * tile_stride1;
4867 for (is_local[AXIS2] = 0; is_local[AXIS2] < a2_tile_res;
4870 for (is_local[AXIS1] = 0; is_local[AXIS1] < a1_tile_res;
4873 set_functor(tile, is_local, vcounter);
4877 vcounter += a1_res - a1_tile_res;
4887 if (half_slice && !half_slice_st)
4889 half_slice_tb =
true;
4898 template <
typename T>
4899 template <
typename S>
4904 for (
int i = 0; i < tilelist.
entries(); i++)
4906 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
4909 tile->
flatten(dstdata, stride);
4915 template <
typename T>
4916 template <
typename S,
typename IDX>
4919 const IDX *ix,
const IDX *iy,
const IDX *iz,
4924 for (
auto && tiledata : tilelist)
4926 int tileidx = tiledata.tileidx;
4927 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
4932 if (tilevoxel == tiledata.numvoxel)
4935 tile->
flatten(dstdata, stride);
4936 dstdata += tiledata.numvoxel *
stride;
4937 srcidx += tiledata.numvoxel;
4942 int basex, basey, basez;
4943 linearTileToXYZ(tileidx, basex, basey, basez);
4955 for (
int i = 0; i < tiledata.numvoxel; i++)
4964 int w = tile->
xres();
4965 int h = tile->
yres();
4966 for (
int i = 0; i < tiledata.numvoxel; i++)
4968 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
4969 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
4970 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
4971 *dstdata = src[ (ix[srcidx] - basex)
4972 + (iy[srcidx] - basey) * w
4973 + (iz[srcidx] - basez) * w * h];
4981 for (
int i = 0; i < tiledata.numvoxel; i++)
4983 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
4984 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
4985 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
4986 *dstdata = (*tile)(ix[srcidx] - basex,
4988 iz[srcidx] - basez);
4998 template <
typename T>
4999 template <
typename S>
5004 bool docompress = getCompressionOptions().compressionEnabled();
5005 for (
int i = 0; i < tilelist.
entries(); i++)
5007 UT_ASSERT(tilelist(i) >= 0 && tilelist(i) < numTiles());
5018 template <
typename T>
5019 template <
typename S,
typename IDX>
5022 const IDX *ix,
const IDX *iy,
const IDX *iz,
5025 bool docompress = getCompressionOptions().compressionEnabled();
5028 for (
auto && tiledata : tilelist)
5030 int tileidx = tiledata.tileidx;
5031 UT_ASSERT(tileidx >= 0 && tileidx < numTiles());
5036 if (tilevoxel == tiledata.numvoxel)
5039 srcdata += tiledata.numvoxel *
stride;
5040 srcidx += tiledata.numvoxel;
5045 int basex, basey, basez;
5046 linearTileToXYZ(tileidx, basex, basey, basez);
5052 for (
int i = 0; i < tiledata.numvoxel; i++)
5054 UT_ASSERT_P(ix[srcidx] >= basex && ix[srcidx] < basex+TILESIZE);
5055 UT_ASSERT_P(iy[srcidx] >= basey && iy[srcidx] < basey+TILESIZE);
5056 UT_ASSERT_P(iz[srcidx] >= basez && iz[srcidx] < basez+TILESIZE);
5110 template <
typename T>
5113 int xoff,
int yoff,
int zoff)
5221 template <
typename T>
5224 int tileoffy,
int tileoffz)
5234 for (
int i = range.begin(); i < range.end(); i++)
5249 && tile->
zres() == srctile->
zres())
5254 UTswap(tile->myCompressionType, srctile->myCompressionType);
5255 UTswap(tile->myForeignData, srctile->myForeignData);
5260 int offv[] = {(xyz[0] + tileoffx) * TILESIZE,
5261 (xyz[1] + tileoffy) * TILESIZE,
5262 (xyz[2] + tileoffz) * TILESIZE};
5263 for (
int z = 0; z < tile->
zres(); z++)
5265 for (
int y = 0; y < tile->
yres(); y++)
5267 for (
int x = 0; x < tile->
xres(); x++)
5285 const int off[] = {tileoffx, tileoffy, tileoffz};
5294 for (
int i = range.begin(); i < range.end(); i++)
5302 bool outside =
false;
5303 for (
int j = 0;
j < 3;
j++)
5306 outside = outside || (xyz[
j] < 0 || xyz[
j] >= src_tileres[
j]);
5311 if (outside && const_src_border)
5318 int offv[] = {xyz[0] * TILESIZE, xyz[1] * TILESIZE, xyz[2] * TILESIZE};
5319 for (
int z = 0; z < tile->
zres(); z++)
5321 for (
int y = 0; y < tile->
yres(); y++)
5323 for (
int x = 0; x < tile->
xres(); x++)
5337 template <
typename T>
5340 int offx,
int offy,
int offz)
5365 copyWithOffsetInternal(src, offx, offy, offz);
5368 template <
typename T>
5371 int offx,
int offy,
int offz,
5376 bool can_copy_tiles = ((offx & TILEMASK) == 0) && ((offy & TILEMASK) == 0)
5377 && ((offz & TILEMASK) == 0);
5401 for (
int i = 0; i < 3; i++)
5403 srctileidx(i) = vit.
myTilePos[i] + (off(i) >> TILEBITS);
5404 inside = inside && srctileidx(i) >= 0
5411 srctile = src.
getTile(srctileidx.
x(), srctileidx.
y(), srctileidx.
z());
5413 && tile->
zres() == srctile->
zres())
5423 srctileidx.
x() >>= TILEBITS;
5424 srctileidx.
y() >>= TILEBITS;
5425 srctileidx.
z() >>= TILEBITS;
5426 srctileoff.
x() = off.x() & TILEMASK;
5427 srctileoff.
y() = off.y() & TILEMASK;
5428 srctileoff.
z() = off.z() & TILEMASK;
5433 srcend.
x() += tile->
xres() - 1;
5434 srcend.
y() += tile->
yres() - 1;
5435 srcend.
z() += tile->
zres() - 1;
5437 srcendtile = srcend;
5438 srcendtile.
x() >>= TILEBITS;
5439 srcendtile.
y() >>= TILEBITS;
5440 srcendtile.
z() >>= TILEBITS;
5443 srcendtile.
x() == srctileidx.
x()+1);
5445 srcendtile.
y() == srctileidx.
y()+1);
5447 srcendtile.
z() == srctileidx.
z()+1);
5450 if (srctileidx.
x() >= 0 &&
5451 srctileidx.
y() >= 0 &&
5452 srctileidx.
z() >= 0 &&
5460 bool allconst =
true, firsttile =
true;
5463 for (tz = srctileidx.
z(); allconst && tz <= srcendtile.
z(); tz++)
5464 for (ty = srctileidx.
y(); allconst && ty <= srcendtile.
y(); ty++)
5465 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5467 srctile = src.
getTile(tx, ty, tz);
5473 cval = (*srctile)(0, 0, 0);
5498 for (tz = srctileidx.
z(); tz <= srcendtile.
z(); tz++)
5499 for (ty = srctileidx.
y(); ty <= srcendtile.
y(); ty++)
5500 for (tx = srctileidx.
x(); tx <= srcendtile.
x(); tx++)
5502 int destx, desty, destz;
5503 int srcx, srcy, srcz;
5505 destx = (tx == srctileidx.
x()) ? 0 : (TILESIZE-srctileoff.
x());
5506 desty = (ty == srctileidx.
y()) ? 0 : (TILESIZE-srctileoff.
y());
5507 destz = (tz == srctileidx.
z()) ? 0 : (TILESIZE-srctileoff.
z());
5508 srcx = (tx == srctileidx.
x()) ? srctileoff.
x() : 0;
5509 srcy = (ty == srctileidx.
y()) ? srctileoff.
y() : 0;
5510 srcz = (tz == srctileidx.
z()) ? srctileoff.
z() : 0;
5526 srctile = src.
getTile(tx, ty, tz);
5529 destx, desty, destz,
5544 for (
int z = destz; z < maxd; z++)
5546 for (
int y = desty; y < maxh; y++)
5548 for (
int x = destx; x < maxw; x++)
5554 z + vit.
z() + offz);
5564 template <
typename T>
5581 ratio.
x() = 1.0f / getXRes();
5582 ratio.
y() = 1.0f / getYRes();
5583 ratio.
z() = 1.0f / getZRes();
5587 pos.
x() = vit.
x()+0.5f;
5588 pos.
y() = vit.
y()+0.5f;
5589 pos.
z() = vit.
z()+0.5f;
5596 template <
typename T>
5602 pos.
x() *= myRes[0];
5603 pos.
y() *= myRes[1];
5604 pos.
z() *= myRes[2];
5614 return isValidIndex(x, y, z);
5617 template <
typename T>
5623 pos.
x() *= myRes[0];
5624 pos.
y() *= myRes[1];
5625 pos.
z() *= myRes[2];
5636 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5637 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5638 pos.
z() < 0 || pos.
z() >= myRes[2])
5644 template <
typename T>
5650 pos.
x() *= myRes[0];
5651 pos.
y() *= myRes[1];
5652 pos.
z() *= myRes[2];
5662 return isValidIndex(x, y, z);
5665 template <
typename T>
5671 pos.
x() *= myRes[0];
5672 pos.
y() *= myRes[1];
5673 pos.
z() *= myRes[2];
5684 if (pos.
x() < 0 || pos.
x() >= myRes[0] ||
5685 pos.
y() < 0 || pos.
y() >= myRes[1] ||
5686 pos.
z() < 0 || pos.
z() >= myRes[2])
5692 template <
typename T>
5709 return isValidIndex(x, y, z);
5712 template <
typename T>
5729 return isValidIndex(x, y, z);
5732 template <
typename T>
5747 template <
typename T>
5762 template <
typename T>
5766 myBorderType =
type;
5770 template <
typename T>
5774 myBorderScale[0] = sx;
5775 myBorderScale[1] = sy;
5776 myBorderScale[2] = sz;
5779 template <
typename T>
5788 myTiles[i].tryCompress(getCompressionOptions());
5792 template <
typename T>
5801 myTiles[i].uncompress();
5805 template <
typename T>
5814 if (!myTiles[i].isConstant())
5815 myTiles[i].uncompress();
5819 template <
typename T>
5827 if (isConstant(&cval))
5831 UTwrite(os, &version, 1);
5832 UTwrite<T>(os, &cval);
5838 UTwrite(os, &version, 1);
5845 ntiles = numTiles();
5846 for (i = 0; i < ntiles; i++)
5848 myTiles[i].save(os);
5853 template <
typename T>
5881 ntiles = numTiles();
5882 for (i = 0; i < ntiles; i++)
5884 myTiles[i].load(is, compressions);
5889 template <
typename T>
5900 if (isConstant(&cval))
5906 if constexpr (tuple_size == 1)
5914 if (shared_mem_owner)
5917 shm = copyToSharedMemory(shared_mem_owner);
5952 ntiles = numTiles();
5953 for (i = 0; i < ntiles; i++)
5955 ok = ok && myTiles[i].save(w);
5965 template <
typename T>
5975 bool array_error =
false;
5977 delete mySharedMemView;
5978 mySharedMemView = 0;
5991 if constexpr (tuple_size == 1)
6010 if (!populateFromSharedMemory(shm_id.
buffer()))
6045 ntiles = numTiles();
6051 if (!myTiles[i].load(p, compressions))
6057 dummy_tile.
setRes(TILESIZE, TILESIZE, TILESIZE);
6058 if (!dummy_tile.
load(p, compressions))
6066 p.
addWarning(
"Unexpected key for voxel data: %s",
6086 template<
typename T>
6094 ntiles = numTiles();
6097 exint total_mem_size;
6099 total_mem_size =
sizeof(
exint);
6104 for (
int i = 0; i < ntiles; i++)
6106 exint tile_size, block_size;
6107 if (myTiles[i].isConstant())
6108 tile_size =
sizeof(T);
6110 tile_size = myTiles[i].getDataLength();
6112 tile_sizes.
append(tile_size);
6114 block_size = SYSroundUpToMultipleOf<exint>(tile_size,
sizeof(
exint));
6115 block_size +=
sizeof(
exint) * 2;
6118 next_block_offsets.
append(block_size /
sizeof(
exint));
6120 next_block_offsets.
append(0);
6122 total_mem_size += block_size;
6129 shared_mem_key.
sprintf(
"%s:%p", shared_mem_owner,
this);
6131 shared_mem = shmgr.
get(shared_mem_key.
buffer());
6137 bool same_meta_data =
false;
6138 if (shared_mem->
size() >=
sizeof(
exint))
6140 same_meta_data =
true;
6145 if (*ptr_ds != ntiles)
6146 same_meta_data =
false;
6153 for (
int i = 0; i < ntiles; i++)
6159 if (ptr_tile[0] != next_block_offsets(i) ||
6160 ptr_tile[1] != (
exint)myTiles[i].myCompressionType)
6162 same_meta_data =
false;
6165 offset += next_block_offsets(i) *
sizeof(
exint);
6170 if (!same_meta_data)
6172 if (!shared_mem->
reset(total_mem_size) ||
6173 shared_mem->
size() != total_mem_size)
6187 for (
int i = 0; i < ntiles; i++)
6190 sizeof(
exint) * 2 + tile_sizes(i));
6195 ptr_tile[0] = next_block_offsets(i);
6196 ptr_tile[1] = myTiles[i].myCompressionType;
6198 ::memcpy(&ptr_tile[2], myTiles[i].rawData(), tile_sizes(i));
6200 offset += ptr_tile[0] *
sizeof(
exint);
6206 template<
typename T>
6211 if (!mySharedMem->size())
6221 ntiles = *(
const exint *)sv_tc.data();
6223 if (ntiles != numTiles())
6232 exint *data = (
exint *)mySharedMemView->data();
6234 for (
int i = 0; i < ntiles; i++)
6236 exint offset = data[0];
6239 myTiles[i].setForeignData(&data[2], ctype);
6253 template <
typename T>
6256 initializePrivate();
6259 template <
typename T>
6265 template <
typename T>
6268 initializePrivate();
6273 template <
typename T>
6296 myLevels.append(levels);
6298 for (level = 0; level < myNumLevels; level++)
6307 template <
typename T>
6314 functions.
append(
function);
6315 build(baselevel, functions);
6318 template <
typename T>