GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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 functions)
5 
6  GRASS OpenGL gsurf OGSF Library
7 
8  (C) 1999-2008 by the GRASS Development Team
9 
10  This program is free software under the
11  GNU General Public License (>=v2).
12  Read the file COPYING that comes with GRASS
13  for details.
14 
15  \author Tomas Paudits (February 2004)
16  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
17  */
18 
19 #include <math.h>
20 
21 #include <grass/gis.h>
22 #include <grass/ogsf.h>
23 
24 #include "mc33_table.h"
25 
26 /* useful macros */
27 #define READ() gvl_read_char(pos[i]++, gvl->isosurf[i]->data)
28 
29 /*!
30  \brief Draw volume set (slices and isosurfaces)
31 
32  \param gvl pointer to geovol struct
33 
34  \return -1 on failure
35  \return 1 on success
36  */
37 int gvld_vol(geovol *gvl)
38 {
39  G_debug(5, "gvld_vol(): id=%d", gvl->gvol_id);
40 
41  /* SLICES */
42  /* calculate slices data, if slices changed */
43  if (0 > gvl_slices_calc(gvl))
44  return (-1);
45  /* draw slices */
46  if (0 > gvld_slices(gvl))
47  return (-1);
48 
49  /* ISOSURFACES */
50  /* calculate isosurfaces data, if isosurfaces changed */
51  if (0 > gvl_isosurf_calc(gvl))
52  return (-1);
53  /* draw isosurfaces */
54  if (0 > gvld_isosurf(gvl))
55  return (-1);
56 
57  return (1);
58 }
59 
60 /*!
61  \brief Draw volume in wire mode (bounding box)
62 
63  \param gvl pointer to geovol struct
64 
65  \return -1 on failure
66  \return 1 on success
67  */
69 {
70  G_debug(5, "gvld_wire_vol(): id=%d", gvl->gvol_id);
71 
72  gvld_wind3_box(gvl);
73 
74  if (0 > gvld_wire_slices(gvl))
75  return (-1);
76 
77  if (0 > gvld_wire_isosurf(gvl))
78  return (-1);
79 
80  return (1);
81 }
82 
83 /*!
84  \brief Draw volume isosurfaces
85 
86  \param gvl pointer to geovol struct
87 
88  \return -1 on failure
89  \return 1 on success
90  */
91 int gvld_isosurf(geovol * gvl)
92 {
93  float tx, ty, tz;
94  int cols, rows, depths;
95  int x, y, z, i, iv;
96  float xc, yc, zc;
97  float xres, yres, zres;
98  unsigned r, g, b;
99 
100  int j, p, num, c_ndx, crnt_ev;
101  float n[3], pt[4];
102 
103  int n_i = gvl->n_isosurfs;
104 
105  int *check_color, *check_transp, *check_material, *check_emis,
106  *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] = (255 << 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] = (check_shin[i] || check_emis[i] ||
236  (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",
251  i, 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] =
355  (r & 0xff) | ((g & 0xff) << 8) |
356  ((b & 0xff) << 16);
357  }
358 
359  if (check_transp[i])
360  ktrans[i] = READ() << 24;;
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] =
385  tmp_pos + cell_table[c_ndx].nedges * e_dl[i] +
386  (iv ? 2 : 0);
387  }
388 
389  }
390 
391  }
392 
393  }
394 
395  for (i = 0; i < gvl->n_isosurfs; i++) {
396  G_debug(5, " end : isosurf : %d datalength : %d B\n", i, pos[i]);
397  }
398 
399  gsd_set_material(1, 1, 0., 0., 0x0);
400  gsd_popmatrix();
401  gsd_blend(0);
402  gsd_zwritemask(0xffffffff);
403 
404  return (0);
405 }
406 
407 /*!
408  \brief Draw volume isosurface in draw mode
409 
410  \param gvl pointer to geovol struct
411 
412  \return 0
413  */
415 {
416  return (0);
417 }
418 
419 /************************************************************************/
420 /* SLICES */
421 
422 /************************************************************************/
423 
424 #define DISTANCE_2(x1, y1, x2, y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
425 
426 /*!
427  \brief Draw slices
428 
429  \param gvl pointer to geovol struct
430 
431  \return 0
432  */
433 int gvld_slices(geovol * gvl)
434 {
435  float tx, ty, tz;
436  int i;
437 
438  GLdouble modelMatrix[16], projMatrix[16];
439  GLint viewport[4];
440  GLint window[4];
441 
442  G_debug(5, "gvld_slices");
443 
444  /* shade */
446 
447  /* scaling */
448  GS_get_scale(&tx, &ty, &tz, 1);
449 
450  /* get viewport */
451  gsd_getwindow(window, viewport, modelMatrix, projMatrix);
452 
454  gsd_pushmatrix();
455  gsd_do_scale(1);
456  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
457 
458  for (i = 0; i < gvl->n_slices; i++) {
459  gsd_blend(0);
460  gsd_zwritemask(0xffffffff);
461 
462  if (gvl->slice[i]->transp == 0)
463  gvld_slice(gvl, i);
464  }
465 
466  for (i = 0; i < gvl->n_slices; i++) {
467  gsd_blend(1);
468  gsd_zwritemask(0x0);
469 
470  if (gvl->slice[i]->transp > 0)
471  gvld_slice(gvl, i);
472  }
473 
474  gsd_set_material(1, 1, 0., 0., 0x0);
475  gsd_popmatrix();
476  gsd_blend(0);
477  gsd_zwritemask(0xffffffff);
478 
479  return (0);
480 }
481 
482 /*!
483  \brief Draw slice
484 
485  \param gvl pointer to geovol struct
486  \param ndx
487 
488  \return 1
489  */
490 int gvld_slice(geovol * gvl, int ndx)
491 {
492  geovol_slice *slice;
493 
494  int color, offset, transp;
495  float n[3], pt[4];
496  float x, nextx, y, nexty, z, stepx, stepy, stepz;
497  int cols, rows, c, r;
498  float f_cols, f_rows, distxy, distz, modx, mody, modz, modxy;
499  int ptX, ptY, ptZ;
500  double resx, resy, resz;
501 
502  /* current slice */
503  slice = gvl->slice[ndx];
504 
505  /* distance between slice def. pts */
506  distxy = DISTANCE_2(slice->x2, slice->y2, slice->x1, slice->y1);
507  distz = fabsf(slice->z2 - slice->z1);
508 
509  /* distance between slice def pts is zero - zero slice */
510  if (distxy == 0. || distz == 0.) {
511  return (1);
512  }
513 
514  /* set slice mod, resolution and set correct coords */
515  if (slice->dir == X) {
516  modx = gvl->slice_y_mod;
517  mody = gvl->slice_z_mod;
518  modz = gvl->slice_x_mod;
519  resx = gvl->yres;
520  resy = gvl->zres;
521  resz = gvl->xres;
522  ptX = Y;
523  ptY = Z;
524  ptZ = X;
525  }
526  else if (slice->dir == Y) {
527  modx = gvl->slice_x_mod;
528  mody = gvl->slice_z_mod;
529  modz = gvl->slice_y_mod;
530  resx = gvl->xres;
531  resy = gvl->zres;
532  resz = gvl->yres;
533  ptX = X;
534  ptY = Z;
535  ptZ = Y;
536  }
537  else {
538  modx = gvl->slice_x_mod;
539  mody = gvl->slice_y_mod;
540  modz = gvl->slice_z_mod;
541  resx = gvl->xres;
542  resy = gvl->yres;
543  resz = gvl->zres;
544  ptX = X;
545  ptY = Y;
546  ptZ = Z;
547  }
548 
549  /* x,y mod */
550  modxy =
551  DISTANCE_2((slice->x2 - slice->x1) / distxy * modx,
552  (slice->y2 - slice->y1) / distxy * mody, 0., 0.);
553 
554  /* cols/rows of slice */
555  f_cols = distxy / modxy;
556  cols = f_cols > (int)f_cols ? (int)f_cols + 1 : (int)f_cols;
557 
558  f_rows = distz / modz;
559  rows = f_rows > (int)f_rows ? (int)f_rows + 1 : (int)f_rows;
560 
561  /* step in x,y for each row of slice */
562  stepx = (slice->x2 - slice->x1) / f_cols;
563  stepy = (slice->y2 - slice->y1) / f_cols;
564  stepz = (slice->z2 - slice->z1) / f_rows;
565 
566  /* set x,y initially to first slice pt */
567  x = (slice->x1);
568  y = (slice->y1);
569 
570  /* set next draw pt */
571  if (f_cols < 1.) {
572  nextx = x + stepx * f_cols;
573  nexty = y + stepy * f_cols;
574  }
575  else {
576  nextx = x + stepx;
577  nexty = y + stepy;
578  }
579 
580  /* set transparency */
581  if (slice->transp > 0) {
582  transp = (255 - slice->transp) << 24;
583  }
584  else {
585  transp = 0x0;
586  }
587 
588  /* loop in slice cols */
589  for (c = 0; c < cols; c++) {
590 
591  /* set z to slice z1 pt */
592  z = slice->z1;
593 
594  /* begin draw one row - triangle strip */
595  gsd_bgntmesh();
596 
597  /* loop in slice rows */
598  for (r = 0; r < rows + 1; r++) {
599  /* offset to data - 1. column */
600  offset = (c + 1) * (rows + 1) * 3 + r * 3;
601 
602  /* get color from slice data */
603  color = (slice->data[offset] & 0xff) |
604  ((slice->data[offset + 1] & 0xff) << 8) |
605  ((slice->data[offset + 2] & 0xff) << 16);
606 
607  /* triagle vertices */
608  pt[ptX] = nextx * resx;
609  pt[ptY] = nexty * resy;
610  pt[ptZ] = z * resz;
611 
612  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
613  gsd_litvert_func(n, (unsigned int)transp | color, pt);
614 
615  /* offset to data - 2. column */
616  offset = c * (rows + 1) * 3 + r * 3;
617 
618  /* get color from slice data */
619  color = (slice->data[offset] & 0xff) |
620  ((slice->data[offset + 1] & 0xff) << 8) |
621  ((slice->data[offset + 2] & 0xff) << 16);
622 
623  /* set triangle vertices */
624  pt[ptX] = x * resx;
625  pt[ptY] = y * resy;
626  pt[ptZ] = z * resz;
627 
628  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
629  gsd_litvert_func(n, (unsigned int)transp | color, pt);
630 
631  if (r + 1 > f_rows) {
632  z += stepz * (f_rows - (float)r);
633  }
634  else {
635  z += stepz;
636  }
637  }
638 
639  gsd_endtmesh();
640 
641  /* step */
642  if (c + 2 > f_cols) {
643  x += stepx;
644  nextx += stepx * (f_cols - (float)(c + 1));
645  y += stepy;
646  nexty += stepy * (f_cols - (float)(c + 1));
647  }
648  else {
649  x += stepx;
650  nextx += stepx;
651  y += stepy;
652  nexty += stepy;
653  }
654  }
655 
656  gsd_blend(0);
657  gsd_zwritemask(0xffffffff);
658 
659  return (1);
660 }
661 
662 /*!
663  \brief Draw wire slices
664 
665  \param gvl pointer to geovol struct
666 
667  \return 0
668  */
670 {
671  float pt[3];
672  int i;
673  int ptX, ptY, ptZ;
674  double resx, resy, resz;
675 
676  geovol_slice *slice;
677 
678  G_debug(5, "gvld_wire_slices");
679 
680  gsd_pushmatrix();
681 
682  /* shading */
684  /* set color mode */
686  /* do scale and set volume position */
687  gsd_do_scale(1);
688  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
689 
690  /* set color and line width */
691  gsd_color_func(0x0);
692  gsd_linewidth(1);
693 
694  /* loop in slices */
695  for (i = 0; i < gvl->n_slices; i++) {
696  slice = gvl->slice[i];
697 
698  /* initialize correct coords */
699  if (slice->dir == X) {
700  resx = gvl->yres;
701  resy = gvl->zres;
702  resz = gvl->xres;
703  ptX = Y;
704  ptY = Z;
705  ptZ = X;
706  }
707  else if (slice->dir == Y) {
708  resx = gvl->xres;
709  resy = gvl->zres;
710  resz = gvl->yres;
711  ptX = X;
712  ptY = Z;
713  ptZ = Y;
714  }
715  else {
716  resx = gvl->xres;
717  resy = gvl->yres;
718  resz = gvl->zres;
719  ptX = X;
720  ptY = Y;
721  ptZ = Z;
722  }
723 
724  gsd_bgnline();
725 
726  /* first slice edge */
727  pt[ptX] = slice->x1 * resx;
728  pt[ptY] = slice->y1 * resy;
729  pt[ptZ] = slice->z1 * resz;;
730  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
731  gsd_vert_func(pt);
732 
733  pt[ptX] = slice->x1 * resx;
734  pt[ptY] = slice->y1 * resy;
735  pt[ptZ] = slice->z2 * resz;;
736  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
737  gsd_vert_func(pt);
738 
739  pt[ptX] = slice->x2 * resx;
740  pt[ptY] = slice->y2 * resy;
741  pt[ptZ] = slice->z2 * resz;;
742  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
743  gsd_vert_func(pt);
744 
745  pt[ptX] = slice->x2 * resx;
746  pt[ptY] = slice->y2 * resy;
747  pt[ptZ] = slice->z1 * resz;;
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  pt[Y] = (gvl->rows - 1) * gvl->yres - pt[Y];
755  gsd_vert_func(pt);
756 
757  gsd_endline();
758  }
759 
760  gsd_set_material(1, 1, 0., 0., 0x0);
761  gsd_popmatrix();
762 
763  return (0);
764 }
765 
766 /*!
767  \brief Draw volume bounding box
768 
769  \param gvl pointer to geovol struct
770 
771  \return 0
772  */
774 {
775  float pt[3];
776 
777  G_debug(5, "gvld_wind3_box(): id=%d", gvl->gvol_id);
778 
779  gsd_pushmatrix();
780 
781  /* shading */
783  /* set color mode */
785  /* do scale and set volume position */
786  gsd_do_scale(1);
787  gsd_translate(gvl->x_trans, gvl->y_trans, gvl->z_trans);
788 
789  /* set color and line width */
790  gsd_color_func(0x0);
791  gsd_linewidth(1);
792 
793  /* draw box */
794 
795  /* front edges */
796  gsd_bgnline();
797  pt[X] = 0;
798  pt[Y] = 0;
799  pt[Z] = 0;
800  gsd_vert_func(pt);
801  pt[X] = (gvl->cols - 1) * gvl->xres;
802  pt[Y] = 0;
803  pt[Z] = 0;
804  gsd_vert_func(pt);
805  pt[X] = (gvl->cols - 1) * gvl->xres;
806  pt[Y] = (gvl->rows - 1) * gvl->yres;
807  pt[Z] = 0;
808  gsd_vert_func(pt);
809  pt[X] = 0;
810  pt[Y] = (gvl->rows - 1) * gvl->yres;
811  pt[Z] = 0;
812  gsd_vert_func(pt);
813  pt[X] = 0;
814  pt[Y] = 0;
815  pt[Z] = 0;
816  gsd_vert_func(pt);
817  gsd_endline();
818 
819  /* back edges */
820  gsd_bgnline();
821  pt[X] = 0;
822  pt[Y] = 0;
823  pt[Z] = (gvl->depths - 1) * gvl->zres;
824  gsd_vert_func(pt);
825  pt[X] = (gvl->cols - 1) * gvl->xres;
826  pt[Y] = 0;
827  pt[Z] = (gvl->depths - 1) * gvl->zres;
828  gsd_vert_func(pt);
829  pt[X] = (gvl->cols - 1) * gvl->xres;
830  pt[Y] = (gvl->rows - 1) * gvl->yres;
831  pt[Z] = (gvl->depths - 1) * gvl->zres;
832  gsd_vert_func(pt);
833  pt[X] = 0;
834  pt[Y] = (gvl->rows - 1) * gvl->yres;
835  pt[Z] = (gvl->depths - 1) * gvl->zres;
836  gsd_vert_func(pt);
837  pt[X] = 0;
838  pt[Y] = 0;
839  pt[Z] = (gvl->depths - 1) * gvl->zres;
840  gsd_vert_func(pt);
841  gsd_endline();
842 
843  /* others edges */
844  gsd_bgnline();
845  pt[X] = 0;
846  pt[Y] = 0;
847  pt[Z] = 0;
848  gsd_vert_func(pt);
849  pt[X] = 0;
850  pt[Y] = 0;
851  pt[Z] = (gvl->depths - 1) * gvl->zres;
852  gsd_vert_func(pt);
853  gsd_endline();
854 
855  gsd_bgnline();
856  pt[X] = (gvl->cols - 1) * gvl->xres;
857  pt[Y] = 0;
858  pt[Z] = 0;
859  gsd_vert_func(pt);
860  pt[X] = (gvl->cols - 1) * gvl->xres;
861  pt[Y] = 0;
862  pt[Z] = (gvl->depths - 1) * gvl->zres;
863  gsd_vert_func(pt);
864  gsd_endline();
865 
866  gsd_bgnline();
867  pt[X] = 0;
868  pt[Y] = (gvl->rows - 1) * gvl->yres;
869  pt[Z] = 0;
870  gsd_vert_func(pt);
871  pt[X] = 0;
872  pt[Y] = (gvl->rows - 1) * gvl->yres;
873  pt[Z] = (gvl->depths - 1) * gvl->zres;
874  gsd_vert_func(pt);
875  gsd_endline();
876 
877  gsd_bgnline();
878  pt[X] = (gvl->cols - 1) * gvl->xres;
879  pt[Y] = (gvl->rows - 1) * gvl->yres;
880  pt[Z] = 0;
881  gsd_vert_func(pt);
882  pt[X] = (gvl->cols - 1) * gvl->xres;
883  pt[Y] = (gvl->rows - 1) * gvl->yres;
884  pt[Z] = (gvl->depths - 1) * gvl->zres;
885  gsd_vert_func(pt);
886  gsd_endline();
887 
888  gsd_popmatrix();
889 
890  return (0);
891 }
int slice_x_mod
Definition: ogsf.h:455
#define G_malloc(n)
Definition: defs/gis.h:112
#define DISTANCE_2(x1, y1, x2, y2)
Definition: gvld.c:424
OGSF library -.
#define CM_DIFFUSE
Definition: ogsf.h:148
int rows
Definition: ogsf.h:440
void gsd_blend(int)
Specify pixel arithmetic.
Definition: gsd_prim.c:996
#define ATT_SHINE
Definition: ogsf.h:77
int slice_z_mod
Definition: ogsf.h:455
float constant
Definition: ogsf.h:409
IFLAG att_src
Definition: ogsf.h:405
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition: gsd_prim.c:371
int depths
Definition: ogsf.h:440
void gsd_popmatrix(void)
Pop the current matrix stack.
Definition: gsd_prim.c:500
#define DM_FLAT
Definition: ogsf.h:55
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition: gsd_prim.c:386
int polys[30]
Definition: viz.h:78
geovol_isosurf * isosurf[MAX_ISOSURFS]
Definition: ogsf.h:449
int npolys
Definition: viz.h:77
void gsd_shademodel(int)
Set shaded model.
Definition: gsd_prim.c:418
#define x
int gvld_isosurf(geovol *gvl)
Draw volume isosurfaces.
Definition: gvld.c:91
int gvld_slice(geovol *gvl, int ndx)
Draw slice.
Definition: gvld.c:490
float z2
Definition: ogsf.h:427
int inout_mode
Definition: ogsf.h:417
int isosurf_y_mod
Definition: ogsf.h:450
float x_trans
Definition: ogsf.h:445
int n_isosurfs
Definition: ogsf.h:448
int edges[12]
Definition: viz.h:76
float y2
Definition: ogsf.h:427
int cols
Definition: ogsf.h:440
void gsd_colormode(int)
Set color mode.
Definition: gsd_prim.c:97
int n_slices
Definition: ogsf.h:453
double b
Definition: r_raster.c:39
int gvol_id
Definition: ogsf.h:436
int gvld_wire_slices(geovol *gvl)
Draw wire slices.
Definition: gvld.c:669
#define CM_COLOR
Definition: ogsf.h:145
void gsd_color_func(unsigned int)
Set current color.
Definition: gsd_prim.c:701
int isosurf_x_mod
Definition: ogsf.h:450
geovol_isosurf_att att[MAX_ATTS]
Definition: ogsf.h:418
int nedges
Definition: viz.h:75
void gsd_endline(void)
End line.
Definition: gsd_prim.c:406
#define MAP_ATT
Definition: ogsf.h:83
void gsd_translate(float, float, float)
Multiply the current matrix by a translation matrix.
Definition: gsd_prim.c:538
char * gvl_file_get_name(int)
Get file name for given handle.
Definition: gvl_file.c:165
#define DM_GOURAUD
Definition: ogsf.h:54
geovol_slice * slice[MAX_SLICES]
Definition: ogsf.h:454
#define ATT_COLOR
Definition: ogsf.h:74
float g
Definition: named_colr.c:8
int dir
Definition: ogsf.h:426
int gvld_wire_vol(geovol *gvl)
Draw volume in wire mode (bounding box)
Definition: gvld.c:68
float y_trans
Definition: ogsf.h:445
#define Z
Definition: ogsf.h:139
double xres
Definition: ogsf.h:442
Definition: ogsf.h:434
IFLAG slice_draw_mode
Definition: ogsf.h:456
void gsd_zwritemask(unsigned long)
Write out z-mask.
Definition: gsd_prim.c:240
#define Y
Definition: ogsf.h:138
int transp
Definition: ogsf.h:431
int slice_y_mod
Definition: ogsf.h:455
int hfile
Definition: ogsf.h:439
void gsd_linewidth(short)
Set width of rasterized lines.
Definition: gsd_prim.c:266
int gvl_isosurf_calc(geovol *)
Fill data structure with computed isosurfaces polygons.
Definition: gvl_calc.c:585
void gsd_getwindow(int *, int *, double *, double *)
Get viewport.
Definition: gsd_prim.c:553
int gvld_slices(geovol *gvl)
Draw slices.
Definition: gvld.c:433
#define ATT_TRANSP
Definition: ogsf.h:76
unsigned char * data
Definition: ogsf.h:428
float z_trans
Definition: ogsf.h:445
void gsd_litvert_func(float *, unsigned long, float *)
Set the current normal vector & specify vertex.
Definition: gsd_prim.c:660
int gvld_wind3_box(geovol *gvl)
Draw volume bounding box.
Definition: gvld.c:773
int GS_check_cancel(void)
Check for cancel.
Definition: gsx.c:30
int isosurf_z_mod
Definition: ogsf.h:450
int gvld_vol(geovol *gvl)
Draw volume set (slices and isosurfaces)
Definition: gvld.c:37
void gsd_pushmatrix(void)
Push the current matrix stack.
Definition: gsd_prim.c:510
#define X
Definition: ogsf.h:137
void GS_get_scale(float *, float *, float *, int)
Get axis scale.
Definition: gs2.c:3240
int gvl_slices_calc(geovol *)
Calculate slices for given volume set.
Definition: gvl_calc.c:1037
#define READ()
Definition: gvld.c:27
float z1
Definition: ogsf.h:427
void gsd_bgntmesh(void)
ADD.
Definition: gsd_prim.c:296
double zres
Definition: ogsf.h:442
float x2
Definition: ogsf.h:427
void gsd_endtmesh(void)
ADD.
Definition: gsd_prim.c:306
float x1
Definition: ogsf.h:427
#define ATT_EMIT
Definition: ogsf.h:78
void gsd_set_material(int, int, float, float, int)
Set material.
Definition: gsd_prim.c:806
IFLAG isosurf_draw_mode
Definition: ogsf.h:451
#define CONST_ATT
Definition: ogsf.h:84
void gsd_do_scale(int)
Set current scale.
Definition: gsd_views.c:355
CELL_ENTRY cell_table[256]
Definition: cell_table.c:3
int G_debug(int, const char *,...) __attribute__((format(printf
double yres
Definition: ogsf.h:442
double r
Definition: r_raster.c:39
float y1
Definition: ogsf.h:427
void gsd_bgnline(void)
Begin line.
Definition: gsd_prim.c:396
int gvld_wire_isosurf(geovol *gvl)
Draw volume isosurface in draw mode.
Definition: gvld.c:414
void gsd_vert_func(float *)
ADD.
Definition: gsd_prim.c:689