28 #define READ() gvl_read_char(pos[i]++, gvl->isosurf[i]->data)
95 int cols, rows, depths;
98 float xres, yres, zres;
101 int j, p, num, c_ndx, crnt_ev;
106 int *check_color, *check_transp, *check_material, *check_emis, *check_shin;
107 float *kem, *ksh, pkem, pksh;
108 unsigned int *ktrans, *curcolor;
111 int *pos, *nz, *e_dl, tmp_pos, edge_pos[13];
113 GLdouble modelMatrix[16], projMatrix[16];
121 check_color =
G_malloc(n_i *
sizeof(
int));
122 check_transp =
G_malloc(n_i *
sizeof(
int));
123 check_material =
G_malloc(n_i *
sizeof(
int));
124 check_emis =
G_malloc(n_i *
sizeof(
int));
125 check_shin =
G_malloc(n_i *
sizeof(
int));
127 kem =
G_malloc(n_i *
sizeof(
float));
128 ksh =
G_malloc(n_i *
sizeof(
float));
130 ktrans =
G_malloc(n_i *
sizeof(
unsigned int));
131 curcolor =
G_malloc(n_i *
sizeof(
unsigned int));
139 G_debug(5,
" start : gvl: %s isosurf : %d\n",
169 window[0] += (int)(yres * 2);
170 window[1] -= (int)(yres * 2);
171 window[2] -= (int)(xres * 2);
172 window[3] += (int)(xres * 2);
191 ktrans[i] = (255U << 24);
236 (check_shin[i] || check_emis[i] || (kem[i] && check_color[i]));
245 for (z = 0; z < depths - 1; z++) {
250 G_debug(5,
" break : isosurf : %d datalength : %d B\n", i,
262 for (y = 0; y < rows - 1; y++) {
263 yc = ((rows - 1) * yres) - (y * yres);
265 for (
x = 0;
x < cols - 1;
x++) {
282 c_ndx = (c_ndx - 1) * 256 +
READ();
296 pos[i] + j * e_dl[i];
300 if (check_transp[i] || (ktrans[i] >> 24) < 255) {
317 for (j = 0; j < 3; j++) {
320 pos[i] = edge_pos[crnt_ev];
324 pt[
X] = xc + (
READ() / 255. * xres);
325 pt[
Y] = yc + (-(
READ() / 255. * yres));
326 pt[
Z] = zc + (
READ() / 255. * zres);
329 pt[edge_vert_pos[crnt_ev][0]] =
READ() / 255.;
330 pt[edge_vert_pos[crnt_ev][1]] =
331 edge_vert_pos[crnt_ev][2];
332 pt[edge_vert_pos[crnt_ev][3]] =
333 edge_vert_pos[crnt_ev][4];
335 pt[
X] = xc + (pt[
X] * xres);
336 pt[
Y] = yc + (-(pt[
Y] * yres));
337 pt[
Z] = zc + (pt[
Z] * zres);
340 n[
X] = (
READ() / 127. - 1.) / xres;
341 n[
Y] = (-(
READ() / 127. - 1.)) / yres;
342 n[
Z] = (
READ() / 127. - 1.) / zres;
350 if (check_color[i]) {
354 curcolor[i] = (
r & 0xff) | ((
g & 0xff) << 8) |
359 ktrans[i] =
READ() << 24;
363 ksh[i] = ((float)
READ()) / 255.;
366 kem[i] = ((float)
READ()) / 255.;
368 if (pksh != ksh[i] || pkem != kem[i] ||
369 (kem[i] && check_color[i])) {
392 G_debug(5,
" end : isosurf : %d datalength : %d B\n", i, pos[i]);
420 #define DISTANCE_2(x1, y1, x2, y2) \
421 sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
435 GLdouble modelMatrix[16], projMatrix[16];
455 for (i = 0; i < gvl->
n_slices; i++) {
463 for (i = 0; i < gvl->
n_slices; i++) {
491 int color, offset, transp;
493 float x, nextx, y, nexty, z, stepx, stepy, stepz;
494 int cols, rows, c,
r;
495 float f_cols, f_rows, distxy, distz, modx, mody, modz, modxy;
497 double resx, resy, resz;
500 slice = gvl->
slice[ndx];
504 distz = fabsf(slice->
z2 - slice->
z1);
507 if (distxy == 0. || distz == 0.) {
512 if (slice->
dir ==
X) {
523 else if (slice->
dir ==
Y) {
548 (slice->
y2 - slice->
y1) / distxy * mody, 0., 0.);
551 f_cols = distxy / modxy;
552 cols = f_cols > (int)f_cols ? (
int)f_cols + 1 : (int)f_cols;
554 f_rows = distz / modz;
555 rows = f_rows > (int)f_rows ? (
int)f_rows + 1 : (int)f_rows;
558 stepx = (slice->
x2 - slice->
x1) / f_cols;
559 stepy = (slice->
y2 - slice->
y1) / f_cols;
560 stepz = (slice->
z2 - slice->
z1) / f_rows;
568 nextx =
x + stepx * f_cols;
569 nexty = y + stepy * f_cols;
578 transp = (255 - slice->
transp) << 24;
585 for (c = 0; c < cols; c++) {
594 for (
r = 0;
r < rows + 1;
r++) {
596 offset = (c + 1) * (rows + 1) * 3 +
r * 3;
599 color = (slice->
data[offset] & 0xff) |
600 ((slice->
data[offset + 1] & 0xff) << 8) |
601 ((slice->
data[offset + 2] & 0xff) << 16);
604 pt[ptX] = nextx * resx;
605 pt[ptY] = nexty * resy;
612 offset = c * (rows + 1) * 3 +
r * 3;
615 color = (slice->
data[offset] & 0xff) |
616 ((slice->
data[offset + 1] & 0xff) << 8) |
617 ((slice->
data[offset + 2] & 0xff) << 16);
627 if (
r + 1 > f_rows) {
628 z += stepz * (f_rows - (float)
r);
638 if (c + 2 > f_cols) {
640 nextx += stepx * (f_cols - (float)(c + 1));
642 nexty += stepy * (f_cols - (float)(c + 1));
670 double resx, resy, resz;
674 G_debug(5,
"gvld_wire_slices");
691 for (i = 0; i < gvl->
n_slices; i++) {
692 slice = gvl->
slice[i];
695 if (slice->
dir ==
X) {
703 else if (slice->
dir ==
Y) {
723 pt[ptX] = slice->
x1 * resx;
724 pt[ptY] = slice->
y1 * resy;
725 pt[ptZ] = slice->
z1 * resz;
730 pt[ptX] = slice->
x1 * resx;
731 pt[ptY] = slice->
y1 * resy;
732 pt[ptZ] = slice->
z2 * resz;
737 pt[ptX] = slice->
x2 * resx;
738 pt[ptY] = slice->
y2 * resy;
739 pt[ptZ] = slice->
z2 * resz;
744 pt[ptX] = slice->
x2 * resx;
745 pt[ptY] = slice->
y2 * resy;
746 pt[ptZ] = slice->
z1 * resz;
751 pt[ptX] = slice->
x1 * resx;
752 pt[ptY] = slice->
y1 * resy;
753 pt[ptZ] = slice->
z1 * resz;
CELL_ENTRY cell_table[256]
int G_debug(int, const char *,...) __attribute__((format(printf
void gsd_endtmesh(void)
ADD.
void gsd_pushmatrix(void)
Push the current matrix stack.
char * gvl_file_get_name(int)
Get file name for given handle.
void gsd_getwindow(int *, int *, double *, double *)
Get viewport.
void gsd_do_scale(int)
Set current scale.
int gvl_slices_calc(geovol *)
Calculate slices for given volume set.
void gsd_shademodel(int)
Set shaded model.
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
int gvl_isosurf_calc(geovol *)
Fill data structure with computed isosurfaces polygons.
void gsd_color_func(unsigned int)
Set current color.
void gsd_translate(float, float, float)
Multiply the current matrix by a translation matrix.
void gsd_popmatrix(void)
Pop the current matrix stack.
void gsd_zwritemask(unsigned long)
Write out z-mask.
void gsd_linewidth(short)
Set width of rasterized lines.
void gsd_endline(void)
End line.
void gsd_colormode(int)
Set color mode.
void GS_get_scale(float *, float *, float *, int)
Get axis scale.
void gsd_set_material(int, int, float, float, int)
Set material.
void gsd_bgnline(void)
Begin line.
void gsd_blend(int)
Specify pixel arithmetic.
void gsd_vert_func(float *)
ADD.
void gsd_bgntmesh(void)
ADD.
int GS_check_cancel(void)
Check for cancel.
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void gsd_litvert_func(float *, unsigned long, float *)
Set the current normal vector & specify vertex.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
#define DISTANCE_2(x1, y1, x2, y2)
int gvld_isosurf(geovol *gvl)
Draw volume isosurfaces.
int gvld_slice(geovol *gvl, int ndx)
Draw slice.
int gvld_wire_isosurf(geovol *gvl UNUSED)
Draw volume isosurface in draw mode.
int gvld_wire_slices(geovol *gvl)
Draw wire slices.
int gvld_wind3_box(geovol *gvl)
Draw volume bounding box.
int gvld_slices(geovol *gvl)
Draw slices.
int gvld_wire_vol(geovol *gvl)
Draw volume in wire mode (bounding box)
int gvld_vol(geovol *gvl)
Draw volume set (slices and isosurfaces)
geovol_slice * slice[MAX_SLICES]
geovol_isosurf * isosurf[MAX_ISOSURFS]
geovol_isosurf_att att[MAX_ATTS]