GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
gvld.c
Go to the documentation of this file.
1 /*!
2  \file lib/ogsf/gvld.c
3 
4  \brief OGSF library - loading and manipulating volumes (lower level
5  functions)
6 
7  GRASS OpenGL gsurf OGSF Library
8 
9  (C) 1999-2008 by the GRASS Development Team
10 
11  This program is free software under the
12  GNU General Public License (>=v2).
13  Read the file COPYING that comes with GRASS
14  for details.
15 
16  \author Tomas Paudits (February 2004)
17  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
18  */
19 
20 #include <math.h>
21 
22 #include <grass/gis.h>
23 #include <grass/ogsf.h>
24 
25 #include "mc33_table.h"
26 
27 /* useful macros */
28 #define READ() gvl_read_char(pos[i]++, gvl->isosurf[i]->data)
29 
30 /*!
31  \brief Draw volume set (slices and isosurfaces)
32 
33  \param gvl pointer to geovol struct
34 
35  \return -1 on failure
36  \return 1 on success
37  */
38 int gvld_vol(geovol *gvl)
39 {
40  G_debug(5, "gvld_vol(): id=%d", gvl->gvol_id);
41 
42  /* SLICES */
43  /* calculate slices data, if slices changed */
44  if (0 > gvl_slices_calc(gvl))
45  return (-1);
46  /* draw slices */
47  if (0 > gvld_slices(gvl))
48  return (-1);
49 
50  /* ISOSURFACES */
51  /* calculate isosurfaces data, if isosurfaces changed */
52  if (0 > gvl_isosurf_calc(gvl))
53  return (-1);
54  /* draw isosurfaces */
55  if (0 > gvld_isosurf(gvl))
56  return (-1);
57 
58  return (1);
59 }
60 
61 /*!
62  \brief Draw volume in wire mode (bounding box)
63 
64  \param gvl pointer to geovol struct
65 
66  \return -1 on failure
67  \return 1 on success
68  */
70 {
71  G_debug(5, "gvld_wire_vol(): id=%d", gvl->gvol_id);
72 
73  gvld_wind3_box(gvl);
74 
75  if (0 > gvld_wire_slices(gvl))
76  return (-1);
77 
78  if (0 > gvld_wire_isosurf(gvl))
79  return (-1);
80 
81  return (1);
82 }
83 
84 /*!
85  \brief Draw volume isosurfaces
86 
87  \param gvl pointer to geovol struct
88 
89  \return -1 on failure
90  \return 1 on success
91  */
93 {
94  float tx, ty, tz;
95  int cols, rows, depths;
96  int x, y, z, i, iv;
97  float xc, yc, zc;
98  float xres, yres, zres;
99  unsigned r, g, b;
100 
101  int j, p, num, c_ndx, crnt_ev;
102  float n[3], pt[4];
103 
104  int n_i = gvl->n_isosurfs;
105 
106  int *check_color, *check_transp, *check_material, *check_emis, *check_shin;
107  float *kem, *ksh, pkem, pksh;
108  unsigned int *ktrans, *curcolor;
109  int pktransp = 0;
110 
111  int *pos, *nz, *e_dl, tmp_pos, edge_pos[13];
112 
113  GLdouble modelMatrix[16], projMatrix[16];
114  GLint viewport[4];
115  GLint window[4];
116 
117  geovol_isosurf *isosurf;
118 
119  /* Allocate memory for arrays */
120 
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));
126 
127  kem = G_malloc(n_i * sizeof(float));
128  ksh = G_malloc(n_i * sizeof(float));
129 
130  ktrans = G_malloc(n_i * sizeof(unsigned int));
131  curcolor = G_malloc(n_i * sizeof(unsigned int));
132 
133  pos = G_malloc(n_i * sizeof(int));
134  nz = G_malloc(n_i * sizeof(int));
135  e_dl = G_malloc(n_i * sizeof(int));
136 
137  G_debug(5, "gvld_isosurf():");
138  for (i = 0; i < gvl->n_isosurfs; i++) {
139  G_debug(5, " start : gvl: %s isosurf : %d\n",
140  gvl_file_get_name(gvl->hfile), i);
141  }
142 
143  /* shade */
145 
146  /* scaling */
147  GS_get_scale(&tx, &ty, &tz, 1);
148 
149  /* set number of cols, rows, dephs */
150  cols = gvl->cols / gvl->isosurf_x_mod;
151  rows = gvl->rows / gvl->isosurf_y_mod;
152  depths = gvl->depths / gvl->isosurf_z_mod;
153 
154  /* set x,y,z resolution */
155  xres =
156  /*((float) gvl->cols) / ((float) cols) */ gvl->isosurf_x_mod *
157  gvl->xres;
158  yres =
159  /*((float) gvl->rows) / ((float) rows) */ gvl->isosurf_y_mod *
160  gvl->yres;
161  zres =
162  /*((float) gvl->depths) / ((float) depths) */ gvl->isosurf_z_mod *
163  gvl->zres;
164 
165  /* get viewport */
166  gsd_getwindow(window, viewport, modelMatrix, projMatrix);
167 
168  /* adjust window */
169  window[0] += (int)(yres * 2);
170  window[1] -= (int)(yres * 2);
171  window[2] -= (int)(xres * 2);
172  window[3] += (int)(xres * 2);
173 
175  gsd_pushmatrix();
176  gsd_do_scale(1);
177  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
178 
179  pkem = 1.0;
180  pksh = 1.0;
181 
182  /* set default attribute values for isosurfaces */
183  for (i = 0; i < gvl->n_isosurfs; i++) {
184  isosurf = gvl->isosurf[i];
185 
186  /* init isosurf one cube edge datalength */
187  e_dl[i] = 4;
188 
189  /* transparency */
190  check_transp[i] = 0;
191  ktrans[i] = (255U << 24);
192  if (CONST_ATT == isosurf->att[ATT_TRANSP].att_src &&
193  isosurf->att[ATT_TRANSP].constant != 0.0) {
194  ktrans[i] = (255 - (int)isosurf->att[ATT_TRANSP].constant) << 24;
195  }
196  else if (MAP_ATT == isosurf->att[ATT_TRANSP].att_src) {
197  check_transp[i] = 1;
198  e_dl[i]++;
199  }
200 
201  /* emis */
202  check_emis[i] = 0;
203  kem[i] = 0.0;
204  if (CONST_ATT == isosurf->att[ATT_EMIT].att_src) {
205  kem[i] = isosurf->att[ATT_EMIT].constant / 255.;
206  }
207  else if (MAP_ATT == isosurf->att[ATT_EMIT].att_src) {
208  check_emis[i] = 1;
209  e_dl[i]++;
210  }
211 
212  /* shin */
213  check_shin[i] = 0;
214  ksh[i] = 0.0;
215  if (CONST_ATT == isosurf->att[ATT_SHINE].att_src) {
216  ksh[i] = isosurf->att[ATT_SHINE].constant / 255.;
217  }
218  else if (MAP_ATT == isosurf->att[ATT_SHINE].att_src) {
219  check_shin[i] = 1;
220  e_dl[i]++;
221  }
222 
223  /* color */
224  check_color[i] = 0;
225  curcolor[i] = 0.0;
226  if (CONST_ATT == isosurf->att[ATT_COLOR].att_src) {
227  curcolor[i] = (int)isosurf->att[ATT_COLOR].constant;
228  }
229  else if (MAP_ATT == isosurf->att[ATT_COLOR].att_src) {
230  check_color[i] = 1;
231  e_dl[i] += 3;
232  }
233 
234  /* check material */
235  check_material[i] =
236  (check_shin[i] || check_emis[i] || (kem[i] && check_color[i]));
237 
238  /* set position in data */
239  pos[i] = 0;
240  nz[i] = 0;
241  }
242 
243  G_debug(5, " initialize OK");
244 
245  for (z = 0; z < depths - 1; z++) {
246  zc = z * zres;
247 
248  if (GS_check_cancel()) {
249  for (i = 0; i < gvl->n_isosurfs; i++) {
250  G_debug(5, " break : isosurf : %d datalength : %d B\n", i,
251  pos[i]);
252  }
253 
254  gsd_set_material(1, 1, 0., 0., 0x0);
255  gsd_popmatrix();
256  gsd_blend(0);
257  gsd_zwritemask(0xffffffff);
258 
259  return (-1);
260  }
261 
262  for (y = 0; y < rows - 1; y++) {
263  yc = ((rows - 1) * yres) - (y * yres);
264 
265  for (x = 0; x < cols - 1; x++) {
266  xc = x * xres;
267 
268  for (i = 0; i < gvl->n_isosurfs; i++) {
269 
270  /* read cube index */
271  if (nz[i] != 0) {
272  nz[i]--;
273  continue;
274  }
275  else {
276  c_ndx = READ();
277  if (c_ndx == 0) {
278  nz[i] = READ() - 1;
279  continue;
280  }
281  else {
282  c_ndx = (c_ndx - 1) * 256 + READ();
283  }
284  }
285 
286  /* save position */
287  tmp_pos = pos[i];
288 
289  /* set position for each cube edge data */
290  iv = 0;
291  for (j = 0; j < cell_table[c_ndx].nedges; j++) {
292  if (cell_table[c_ndx].edges[j] == 12)
293  iv = 1;
294 
295  edge_pos[cell_table[c_ndx].edges[j]] =
296  pos[i] + j * e_dl[i];
297  }
298 
299  /* enable/disable blending and depth buffer writing */
300  if (check_transp[i] || (ktrans[i] >> 24) < 255) {
301  if (!pktransp) {
302  gsd_blend(1);
303  gsd_zwritemask(0);
304  }
305  }
306  else if (pktransp) {
307  gsd_blend(0);
308  gsd_zwritemask(0xffffffff);
309  pktransp = 0;
310  }
311 
312  /* draw cube polygons */
313  for (p = 0, num = 0; num < cell_table[c_ndx].npolys;
314  num++) {
315  gsd_bgnpolygon();
316 
317  for (j = 0; j < 3; j++) {
318  crnt_ev = cell_table[c_ndx].polys[p];
319  /* set position in data to current edge data */
320  pos[i] = edge_pos[crnt_ev];
321 
322  /* triagle vertex */
323  if (crnt_ev == 12) {
324  pt[X] = xc + (READ() / 255. * xres);
325  pt[Y] = yc + (-(READ() / 255. * yres));
326  pt[Z] = zc + (READ() / 255. * zres);
327  }
328  else {
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];
334 
335  pt[X] = xc + (pt[X] * xres);
336  pt[Y] = yc + (-(pt[Y] * yres));
337  pt[Z] = zc + (pt[Z] * zres);
338  }
339 
340  n[X] = (READ() / 127. - 1.) / xres;
341  n[Y] = (-(READ() / 127. - 1.)) / yres;
342  n[Z] = (READ() / 127. - 1.) / zres;
343 
344  if (gvl->isosurf[i]->inout_mode) {
345  n[X] *= -1;
346  n[Y] *= -1;
347  n[Z] *= -1;
348  }
349 
350  if (check_color[i]) {
351  r = READ();
352  g = READ();
353  b = READ();
354  curcolor[i] = (r & 0xff) | ((g & 0xff) << 8) |
355  ((b & 0xff) << 16);
356  }
357 
358  if (check_transp[i])
359  ktrans[i] = READ() << 24;
360  ;
361 
362  if (check_shin[i])
363  ksh[i] = ((float)READ()) / 255.;
364 
365  if (check_emis[i])
366  kem[i] = ((float)READ()) / 255.;
367 
368  if (pksh != ksh[i] || pkem != kem[i] ||
369  (kem[i] && check_color[i])) {
370  pksh = ksh[i];
371  pkem = kem[i];
372  gsd_set_material(1, 1, ksh[i], kem[i],
373  curcolor[i]);
374  }
375 
376  gsd_litvert_func(n, ktrans[i] | curcolor[i], pt);
377  p++;
378  }
379 
380  gsd_endpolygon();
381  }
382 
383  /* set position to next cube */
384  pos[i] = tmp_pos + cell_table[c_ndx].nedges * e_dl[i] +
385  (iv ? 2 : 0);
386  }
387  }
388  }
389  }
390 
391  for (i = 0; i < gvl->n_isosurfs; i++) {
392  G_debug(5, " end : isosurf : %d datalength : %d B\n", i, pos[i]);
393  }
394 
395  gsd_set_material(1, 1, 0., 0., 0x0);
396  gsd_popmatrix();
397  gsd_blend(0);
398  gsd_zwritemask(0xffffffff);
399 
400  return (0);
401 }
402 
403 /*!
404  \brief Draw volume isosurface in draw mode
405 
406  \param gvl pointer to geovol struct [unused]
407 
408  \return 0
409  */
411 {
412  return (0);
413 }
414 
415 /************************************************************************/
416 /* SLICES */
417 
418 /************************************************************************/
419 
420 #define DISTANCE_2(x1, y1, x2, y2) \
421  sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
422 
423 /*!
424  \brief Draw slices
425 
426  \param gvl pointer to geovol struct
427 
428  \return 0
429  */
431 {
432  float tx, ty, tz;
433  int i;
434 
435  GLdouble modelMatrix[16], projMatrix[16];
436  GLint viewport[4];
437  GLint window[4];
438 
439  G_debug(5, "gvld_slices");
440 
441  /* shade */
443 
444  /* scaling */
445  GS_get_scale(&tx, &ty, &tz, 1);
446 
447  /* get viewport */
448  gsd_getwindow(window, viewport, modelMatrix, projMatrix);
449 
451  gsd_pushmatrix();
452  gsd_do_scale(1);
453  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
454 
455  for (i = 0; i < gvl->n_slices; i++) {
456  gsd_blend(0);
457  gsd_zwritemask(0xffffffff);
458 
459  if (gvl->slice[i]->transp == 0)
460  gvld_slice(gvl, i);
461  }
462 
463  for (i = 0; i < gvl->n_slices; i++) {
464  gsd_blend(1);
465  gsd_zwritemask(0x0);
466 
467  if (gvl->slice[i]->transp > 0)
468  gvld_slice(gvl, i);
469  }
470 
471  gsd_set_material(1, 1, 0., 0., 0x0);
472  gsd_popmatrix();
473  gsd_blend(0);
474  gsd_zwritemask(0xffffffff);
475 
476  return (0);
477 }
478 
479 /*!
480  \brief Draw slice
481 
482  \param gvl pointer to geovol struct
483  \param ndx
484 
485  \return 1
486  */
487 int gvld_slice(geovol *gvl, int ndx)
488 {
489  geovol_slice *slice;
490 
491  int color, offset, transp;
492  float n[3], pt[4];
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;
496  int ptX, ptY, ptZ;
497  double resx, resy, resz;
498 
499  /* current slice */
500  slice = gvl->slice[ndx];
501 
502  /* distance between slice def. pts */
503  distxy = DISTANCE_2(slice->x2, slice->y2, slice->x1, slice->y1);
504  distz = fabsf(slice->z2 - slice->z1);
505 
506  /* distance between slice def pts is zero - zero slice */
507  if (distxy == 0. || distz == 0.) {
508  return (1);
509  }
510 
511  /* set slice mod, resolution and set correct coords */
512  if (slice->dir == X) {
513  modx = gvl->slice_y_mod;
514  mody = gvl->slice_z_mod;
515  modz = gvl->slice_x_mod;
516  resx = gvl->yres;
517  resy = gvl->zres;
518  resz = gvl->xres;
519  ptX = Y;
520  ptY = Z;
521  ptZ = X;
522  }
523  else if (slice->dir == Y) {
524  modx = gvl->slice_x_mod;
525  mody = gvl->slice_z_mod;
526  modz = gvl->slice_y_mod;
527  resx = gvl->xres;
528  resy = gvl->zres;
529  resz = gvl->yres;
530  ptX = X;
531  ptY = Z;
532  ptZ = Y;
533  }
534  else {
535  modx = gvl->slice_x_mod;
536  mody = gvl->slice_y_mod;
537  modz = gvl->slice_z_mod;
538  resx = gvl->xres;
539  resy = gvl->yres;
540  resz = gvl->zres;
541  ptX = X;
542  ptY = Y;
543  ptZ = Z;
544  }
545 
546  /* x,y mod */
547  modxy = DISTANCE_2((slice->x2 - slice->x1) / distxy * modx,
548  (slice->y2 - slice->y1) / distxy * mody, 0., 0.);
549 
550  /* cols/rows of slice */
551  f_cols = distxy / modxy;
552  cols = f_cols > (int)f_cols ? (int)f_cols + 1 : (int)f_cols;
553 
554  f_rows = distz / modz;
555  rows = f_rows > (int)f_rows ? (int)f_rows + 1 : (int)f_rows;
556 
557  /* step in x,y for each row of slice */
558  stepx = (slice->x2 - slice->x1) / f_cols;
559  stepy = (slice->y2 - slice->y1) / f_cols;
560  stepz = (slice->z2 - slice->z1) / f_rows;
561 
562  /* set x,y initially to first slice pt */
563  x = (slice->x1);
564  y = (slice->y1);
565 
566  /* set next draw pt */
567  if (f_cols < 1.) {
568  nextx = x + stepx * f_cols;
569  nexty = y + stepy * f_cols;
570  }
571  else {
572  nextx = x + stepx;
573  nexty = y + stepy;
574  }
575 
576  /* set transparency */
577  if (slice->transp > 0) {
578  transp = (255 - slice->transp) << 24;
579  }
580  else {
581  transp = 0x0;
582  }
583 
584  /* loop in slice cols */
585  for (c = 0; c < cols; c++) {
586 
587  /* set z to slice z1 pt */
588  z = slice->z1;
589 
590  /* begin draw one row - triangle strip */
591  gsd_bgntmesh();
592 
593  /* loop in slice rows */
594  for (r = 0; r < rows + 1; r++) {
595  /* offset to data - 1. column */
596  offset = (c + 1) * (rows + 1) * 3 + r * 3;
597 
598  /* get color from slice data */
599  color = (slice->data[offset] & 0xff) |
600  ((slice->data[offset + 1] & 0xff) << 8) |
601  ((slice->data[offset + 2] & 0xff) << 16);
602 
603  /* triagle vertices */
604  pt[ptX] = nextx * resx;
605  pt[ptY] = nexty * resy;
606  pt[ptZ] = z * resz;
607 
608  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
609  gsd_litvert_func(n, (unsigned int)transp | color, pt);
610 
611  /* offset to data - 2. column */
612  offset = c * (rows + 1) * 3 + r * 3;
613 
614  /* get color from slice data */
615  color = (slice->data[offset] & 0xff) |
616  ((slice->data[offset + 1] & 0xff) << 8) |
617  ((slice->data[offset + 2] & 0xff) << 16);
618 
619  /* set triangle vertices */
620  pt[ptX] = x * resx;
621  pt[ptY] = y * resy;
622  pt[ptZ] = z * resz;
623 
624  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
625  gsd_litvert_func(n, (unsigned int)transp | color, pt);
626 
627  if (r + 1 > f_rows) {
628  z += stepz * (f_rows - (float)r);
629  }
630  else {
631  z += stepz;
632  }
633  }
634 
635  gsd_endtmesh();
636 
637  /* step */
638  if (c + 2 > f_cols) {
639  x += stepx;
640  nextx += stepx * (f_cols - (float)(c + 1));
641  y += stepy;
642  nexty += stepy * (f_cols - (float)(c + 1));
643  }
644  else {
645  x += stepx;
646  nextx += stepx;
647  y += stepy;
648  nexty += stepy;
649  }
650  }
651 
652  gsd_blend(0);
653  gsd_zwritemask(0xffffffff);
654 
655  return (1);
656 }
657 
658 /*!
659  \brief Draw wire slices
660 
661  \param gvl pointer to geovol struct
662 
663  \return 0
664  */
666 {
667  float pt[3];
668  int i;
669  int ptX, ptY, ptZ;
670  double resx, resy, resz;
671 
672  geovol_slice *slice;
673 
674  G_debug(5, "gvld_wire_slices");
675 
676  gsd_pushmatrix();
677 
678  /* shading */
680  /* set color mode */
682  /* do scale and set volume position */
683  gsd_do_scale(1);
684  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
685 
686  /* set color and line width */
687  gsd_color_func(0x0);
688  gsd_linewidth(1);
689 
690  /* loop in slices */
691  for (i = 0; i < gvl->n_slices; i++) {
692  slice = gvl->slice[i];
693 
694  /* initialize correct coords */
695  if (slice->dir == X) {
696  resx = gvl->yres;
697  resy = gvl->zres;
698  resz = gvl->xres;
699  ptX = Y;
700  ptY = Z;
701  ptZ = X;
702  }
703  else if (slice->dir == Y) {
704  resx = gvl->xres;
705  resy = gvl->zres;
706  resz = gvl->yres;
707  ptX = X;
708  ptY = Z;
709  ptZ = Y;
710  }
711  else {
712  resx = gvl->xres;
713  resy = gvl->yres;
714  resz = gvl->zres;
715  ptX = X;
716  ptY = Y;
717  ptZ = Z;
718  }
719 
720  gsd_bgnline();
721 
722  /* first slice edge */
723  pt[ptX] = slice->x1 * resx;
724  pt[ptY] = slice->y1 * resy;
725  pt[ptZ] = slice->z1 * resz;
726  ;
727  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
728  gsd_vert_func(pt);
729 
730  pt[ptX] = slice->x1 * resx;
731  pt[ptY] = slice->y1 * resy;
732  pt[ptZ] = slice->z2 * resz;
733  ;
734  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
735  gsd_vert_func(pt);
736 
737  pt[ptX] = slice->x2 * resx;
738  pt[ptY] = slice->y2 * resy;
739  pt[ptZ] = slice->z2 * resz;
740  ;
741  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
742  gsd_vert_func(pt);
743 
744  pt[ptX] = slice->x2 * resx;
745  pt[ptY] = slice->y2 * resy;
746  pt[ptZ] = slice->z1 * resz;
747  ;
748  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
749  gsd_vert_func(pt);
750 
751  pt[ptX] = slice->x1 * resx;
752  pt[ptY] = slice->y1 * resy;
753  pt[ptZ] = slice->z1 * resz;
754  ;
755  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
756  gsd_vert_func(pt);
757 
758  gsd_endline();
759  }
760 
761  gsd_set_material(1, 1, 0., 0., 0x0);
762  gsd_popmatrix();
763 
764  return (0);
765 }
766 
767 /*!
768  \brief Draw volume bounding box
769 
770  \param gvl pointer to geovol struct
771 
772  \return 0
773  */
775 {
776  float pt[3];
777 
778  G_debug(5, "gvld_wind3_box(): id=%d", gvl->gvol_id);
779 
780  gsd_pushmatrix();
781 
782  /* shading */
784  /* set color mode */
786  /* do scale and set volume position */
787  gsd_do_scale(1);
788  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
789 
790  /* set color and line width */
791  gsd_color_func(0x0);
792  gsd_linewidth(1);
793 
794  /* draw box */
795 
796  /* front edges */
797  gsd_bgnline();
798  pt[X] = 0;
799  pt[Y] = 0;
800  pt[Z] = 0;
801  gsd_vert_func(pt);
802  pt[X] = (gvl->cols - 1) * gvl->xres;
803  pt[Y] = 0;
804  pt[Z] = 0;
805  gsd_vert_func(pt);
806  pt[X] = (gvl->cols - 1) * gvl->xres;
807  pt[Y] = (gvl->rows - 1) * gvl->yres;
808  pt[Z] = 0;
809  gsd_vert_func(pt);
810  pt[X] = 0;
811  pt[Y] = (gvl->rows - 1) * gvl->yres;
812  pt[Z] = 0;
813  gsd_vert_func(pt);
814  pt[X] = 0;
815  pt[Y] = 0;
816  pt[Z] = 0;
817  gsd_vert_func(pt);
818  gsd_endline();
819 
820  /* back edges */
821  gsd_bgnline();
822  pt[X] = 0;
823  pt[Y] = 0;
824  pt[Z] = (gvl->depths - 1) * gvl->zres;
825  gsd_vert_func(pt);
826  pt[X] = (gvl->cols - 1) * gvl->xres;
827  pt[Y] = 0;
828  pt[Z] = (gvl->depths - 1) * gvl->zres;
829  gsd_vert_func(pt);
830  pt[X] = (gvl->cols - 1) * gvl->xres;
831  pt[Y] = (gvl->rows - 1) * gvl->yres;
832  pt[Z] = (gvl->depths - 1) * gvl->zres;
833  gsd_vert_func(pt);
834  pt[X] = 0;
835  pt[Y] = (gvl->rows - 1) * gvl->yres;
836  pt[Z] = (gvl->depths - 1) * gvl->zres;
837  gsd_vert_func(pt);
838  pt[X] = 0;
839  pt[Y] = 0;
840  pt[Z] = (gvl->depths - 1) * gvl->zres;
841  gsd_vert_func(pt);
842  gsd_endline();
843 
844  /* others edges */
845  gsd_bgnline();
846  pt[X] = 0;
847  pt[Y] = 0;
848  pt[Z] = 0;
849  gsd_vert_func(pt);
850  pt[X] = 0;
851  pt[Y] = 0;
852  pt[Z] = (gvl->depths - 1) * gvl->zres;
853  gsd_vert_func(pt);
854  gsd_endline();
855 
856  gsd_bgnline();
857  pt[X] = (gvl->cols - 1) * gvl->xres;
858  pt[Y] = 0;
859  pt[Z] = 0;
860  gsd_vert_func(pt);
861  pt[X] = (gvl->cols - 1) * gvl->xres;
862  pt[Y] = 0;
863  pt[Z] = (gvl->depths - 1) * gvl->zres;
864  gsd_vert_func(pt);
865  gsd_endline();
866 
867  gsd_bgnline();
868  pt[X] = 0;
869  pt[Y] = (gvl->rows - 1) * gvl->yres;
870  pt[Z] = 0;
871  gsd_vert_func(pt);
872  pt[X] = 0;
873  pt[Y] = (gvl->rows - 1) * gvl->yres;
874  pt[Z] = (gvl->depths - 1) * gvl->zres;
875  gsd_vert_func(pt);
876  gsd_endline();
877 
878  gsd_bgnline();
879  pt[X] = (gvl->cols - 1) * gvl->xres;
880  pt[Y] = (gvl->rows - 1) * gvl->yres;
881  pt[Z] = 0;
882  gsd_vert_func(pt);
883  pt[X] = (gvl->cols - 1) * gvl->xres;
884  pt[Y] = (gvl->rows - 1) * gvl->yres;
885  pt[Z] = (gvl->depths - 1) * gvl->zres;
886  gsd_vert_func(pt);
887  gsd_endline();
888 
889  gsd_popmatrix();
890 
891  return (0);
892 }
CELL_ENTRY cell_table[256]
Definition: cell_table.c:3
#define G_malloc(n)
Definition: defs/gis.h:94
int G_debug(int, const char *,...) __attribute__((format(printf
void gsd_endtmesh(void)
ADD.
Definition: gsd_prim.c:307
void gsd_pushmatrix(void)
Push the current matrix stack.
Definition: gsd_prim.c:511
char * gvl_file_get_name(int)
Get file name for given handle.
Definition: gvl_file.c:165
void gsd_getwindow(int *, int *, double *, double *)
Get viewport.
Definition: gsd_prim.c:554
void gsd_do_scale(int)
Set current scale.
Definition: gsd_views.c:355
int gvl_slices_calc(geovol *)
Calculate slices for given volume set.
Definition: gvl_calc.c:1034
void gsd_shademodel(int)
Set shaded model.
Definition: gsd_prim.c:419
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition: gsd_prim.c:372
int gvl_isosurf_calc(geovol *)
Fill data structure with computed isosurfaces polygons.
Definition: gvl_calc.c:585
void gsd_color_func(unsigned int)
Set current color.
Definition: gsd_prim.c:698
void gsd_translate(float, float, float)
Multiply the current matrix by a translation matrix.
Definition: gsd_prim.c:539
void gsd_popmatrix(void)
Pop the current matrix stack.
Definition: gsd_prim.c:501
void gsd_zwritemask(unsigned long)
Write out z-mask.
Definition: gsd_prim.c:241
void gsd_linewidth(short)
Set width of rasterized lines.
Definition: gsd_prim.c:267
void gsd_endline(void)
End line.
Definition: gsd_prim.c:407
void gsd_colormode(int)
Set color mode.
Definition: gsd_prim.c:98
void GS_get_scale(float *, float *, float *, int)
Get axis scale.
Definition: gs2.c:3236
void gsd_set_material(int, int, float, float, int)
Set material.
Definition: gsd_prim.c:803
void gsd_bgnline(void)
Begin line.
Definition: gsd_prim.c:397
void gsd_blend(int)
Specify pixel arithmetic.
Definition: gsd_prim.c:994
void gsd_vert_func(float *)
ADD.
Definition: gsd_prim.c:686
void gsd_bgntmesh(void)
ADD.
Definition: gsd_prim.c:297
int GS_check_cancel(void)
Check for cancel.
Definition: gsx.c:30
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition: gsd_prim.c:387
void gsd_litvert_func(float *, unsigned long, float *)
Set the current normal vector & specify vertex.
Definition: gsd_prim.c:657
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition: gis.h:47
#define DISTANCE_2(x1, y1, x2, y2)
Definition: gvld.c:420
int gvld_isosurf(geovol *gvl)
Draw volume isosurfaces.
Definition: gvld.c:92
int gvld_slice(geovol *gvl, int ndx)
Draw slice.
Definition: gvld.c:487
int gvld_wire_isosurf(geovol *gvl UNUSED)
Draw volume isosurface in draw mode.
Definition: gvld.c:410
int gvld_wire_slices(geovol *gvl)
Draw wire slices.
Definition: gvld.c:665
int gvld_wind3_box(geovol *gvl)
Draw volume bounding box.
Definition: gvld.c:774
int gvld_slices(geovol *gvl)
Draw slices.
Definition: gvld.c:430
int gvld_wire_vol(geovol *gvl)
Draw volume in wire mode (bounding box)
Definition: gvld.c:69
#define READ()
Definition: gvld.c:28
int gvld_vol(geovol *gvl)
Draw volume set (slices and isosurfaces)
Definition: gvld.c:38
OGSF library -.
float g
Definition: named_colr.c:7
#define CM_DIFFUSE
Definition: ogsf.h:151
#define X
Definition: ogsf.h:140
#define ATT_COLOR
Definition: ogsf.h:76
#define ATT_EMIT
Definition: ogsf.h:80
#define Z
Definition: ogsf.h:142
#define ATT_SHINE
Definition: ogsf.h:79
#define Y
Definition: ogsf.h:141
#define MAP_ATT
Definition: ogsf.h:85
#define CM_COLOR
Definition: ogsf.h:148
#define DM_GOURAUD
Definition: ogsf.h:56
#define DM_FLAT
Definition: ogsf.h:57
#define CONST_ATT
Definition: ogsf.h:86
#define ATT_TRANSP
Definition: ogsf.h:78
double b
Definition: r_raster.c:39
double r
Definition: r_raster.c:39
int npolys
Definition: viz.h:70
int polys[30]
Definition: viz.h:71
int nedges
Definition: viz.h:68
int edges[12]
Definition: viz.h:69
Definition: ogsf.h:426
IFLAG slice_draw_mode
Definition: ogsf.h:447
int n_slices
Definition: ogsf.h:444
int hfile
Definition: ogsf.h:430
int depths
Definition: ogsf.h:431
geovol_slice * slice[MAX_SLICES]
Definition: ogsf.h:445
int slice_z_mod
Definition: ogsf.h:446
float x_trans
Definition: ogsf.h:436
int isosurf_z_mod
Definition: ogsf.h:441
int slice_y_mod
Definition: ogsf.h:446
int isosurf_y_mod
Definition: ogsf.h:441
double zres
Definition: ogsf.h:433
int cols
Definition: ogsf.h:431
int isosurf_x_mod
Definition: ogsf.h:441
IFLAG isosurf_draw_mode
Definition: ogsf.h:442
double yres
Definition: ogsf.h:433
float z_trans
Definition: ogsf.h:436
int gvol_id
Definition: ogsf.h:427
int slice_x_mod
Definition: ogsf.h:446
float y_trans
Definition: ogsf.h:436
geovol_isosurf * isosurf[MAX_ISOSURFS]
Definition: ogsf.h:440
int n_isosurfs
Definition: ogsf.h:439
double xres
Definition: ogsf.h:433
int rows
Definition: ogsf.h:431
float constant
Definition: ogsf.h:403
IFLAG att_src
Definition: ogsf.h:399
geovol_isosurf_att att[MAX_ATTS]
Definition: ogsf.h:411
int inout_mode
Definition: ogsf.h:410
unsigned char * data
Definition: ogsf.h:420
float z1
Definition: ogsf.h:419
float x1
Definition: ogsf.h:419
float z2
Definition: ogsf.h:419
float y1
Definition: ogsf.h:419
int dir
Definition: ogsf.h:418
float x2
Definition: ogsf.h:419
float y2
Definition: ogsf.h:419
int transp
Definition: ogsf.h:423
#define x