19 #include <grass/gis.h>
20 #include <grass/ogsf.h>
51 G_debug(3,
"gsd_wire_surf(): id=%d", surf->gsurf_id);
62 if (surf->draw_mode & DM_GRID_WIRE)
102 int check_mask, check_color;
103 typbuff *buff, *cobuff;
104 int xmod, ymod, row, col, cnt, xcnt, ycnt, x1off;
106 float pt[4], xres, yres, ymax, zexag;
107 int col_src, curcolor;
110 G_debug(3,
"gsd_wire_surf_map");
116 check_mask = surf->curmask ? 1 : 0;
126 xres = xmod * surf->xres;
127 yres = ymod * surf->yres;
128 ymax = (surf->rows - 1) * surf->yres;
129 xcnt = 1 + (surf->cols - 1) / xmod;
130 ycnt = 1 + (surf->rows - 1) / ymod;
136 zexag = surf->z_exag;
143 check_color = (surf->wire_color == WC_COLOR_ATT);
146 coloratt = &(surf->att[ATT_COLOR]);
147 col_src = surf->att[ATT_COLOR].att_src;
149 if (col_src != MAP_ATT) {
150 if (col_src == CONST_ATT) {
165 for (row = 0; row < ycnt; row++) {
166 pt[
Y] = ymax - row * yres;
167 y1off = row * ymod * surf->cols;
172 for (col = 0; col < xcnt; col++) {
175 offset = x1off + y1off;
178 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
197 pt[Z] = pt[Z] * zexag;
214 for (col = 0; col < xcnt; col++) {
221 for (row = 0; row < ycnt; row++) {
222 pt[
Y] = ymax - row * yres;
223 y1off = row * ymod * surf->cols;
224 offset = x1off + y1off;
227 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
245 pt[Z] = pt[Z] * zexag;
278 int do_diff, check_mask, check_color;
279 int xmod, ymod, row, col, cnt, xcnt, ycnt, x1off;
281 float pt[4], xres, yres, ymax, zexag;
286 G_debug(3,
"gsd_wire_surf_const");
291 check_mask = surf->curmask ? 1 : 0;
297 xres = xmod * surf->xres;
298 yres = ymod * surf->yres;
300 xcnt = 1 + (surf->cols - 1) / xmod;
301 ycnt = 1 + (surf->rows - 1) / ymod;
302 ymax = (surf->rows - 1) * surf->yres;
308 zexag = surf->z_exag;
315 check_color = (surf->wire_color == WC_COLOR_ATT);
318 coloratt = &(surf->att[ATT_COLOR]);
319 col_src = surf->att[ATT_COLOR].att_src;
321 if (col_src != MAP_ATT) {
322 if (col_src == CONST_ATT) {
338 for (row = 0; row < ycnt; row++) {
339 pt[
Y] = ymax - row * yres;
340 y1off = row * ymod * surf->cols;
345 for (col = 0; col < xcnt; col++) {
348 offset = x1off + y1off;
351 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
382 for (col = 0; col < xcnt; col++) {
389 for (row = 0; row < ycnt; row++) {
390 pt[
Y] = ymax - row * yres;
391 y1off = row * ymod * surf->cols;
392 offset = x1off + y1off;
395 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
459 typbuff *buff, *cobuff;
460 int check_mask, check_color;
461 int xmod, ymod, row, col, xcnt, ycnt;
463 float tx, ty, tz, sz;
464 float n[3], pt[4], xres, yres, ymax, zexag;
465 int col_src, curcolor;
480 check_mask = surf->curmask ? 1 : 0;
489 coloratt = &(surf->att[ATT_COLOR]);
490 col_src = surf->att[ATT_COLOR].att_src;
492 if (col_src != MAP_ATT) {
493 if (col_src == CONST_ATT) {
494 curcolor = (int)surf->att[ATT_COLOR].constant;
497 curcolor = surf->wire_color;
508 xres = xmod * surf->xres;
509 yres = ymod * surf->yres;
510 ymax = (surf->rows - 1) * surf->yres;
511 xcnt = 1 + (surf->cols - 1) / xmod;
512 ycnt = 1 + (surf->rows - 1) / ymod;
518 zexag = surf->z_exag;
523 for (row = 0; row < ycnt; row++) {
524 pt[
Y] = ymax - row * yres;
525 y1off = row * ymod * surf->cols;
527 for (col = 0; col < xcnt; col++) {
529 offset = col * xmod + y1off;
532 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
537 FNORM(surf->norms[offset], n);
545 gsd_arrow(pt, curcolor, xres * 2, n, sz, surf);
574 int check_mask, check_color, check_transp;
575 int check_material, check_emis, check_shin;
576 typbuff *buff, *cobuff, *trbuff, *embuff, *shbuff;
578 int row, col, xcnt, ycnt;
579 long y1off, y2off, y3off;
583 float x1, x2, x3, y1, y2, y3, tx, ty, tz, ttr;
584 float n[3], pt[4], xres, yres, ymax, zexag;
585 int em_src, sh_src, trans_src, col_src, curcolor;
586 gsurf_att *ematt, *shatt, *tratt, *coloratt;
589 int datarow1, datacol1, datarow2, datacol2, datarow3, datacol3;
591 float kem, ksh, pkem, pksh;
594 int step_val = 2 * surf->x_modw;
595 int start_val = surf->x_modw;
616 check_mask = surf->curmask ? 1 : 0;
624 xres = xmod * surf->xres;
625 yres = ymod * surf->yres;
626 ymax = (surf->rows - 1) * surf->yres;
634 zexag = surf->z_exag;
646 tratt = &(surf->att[ATT_TRANSP]);
647 ktrans = (255 << 24);
648 trans_src = surf->att[ATT_TRANSP].att_src;
650 if (CONST_ATT == trans_src && surf->att[ATT_TRANSP].constant != 0.0) {
651 ktrans = (255 - (int)surf->att[ATT_TRANSP].constant) << 24;
655 else if (MAP_ATT == trans_src) {
657 check_transp = trbuff ? 1 : 0;
663 ematt = &(surf->att[ATT_EMIT]);
666 em_src = surf->att[ATT_EMIT].att_src;
668 if (CONST_ATT == em_src) {
669 kem = surf->att[ATT_EMIT].constant / 255.;
671 else if (MAP_ATT == em_src) {
673 check_emis = embuff ? 1 : 0;
677 shatt = &(surf->att[ATT_SHINE]);
680 sh_src = surf->att[ATT_SHINE].att_src;
682 if (CONST_ATT == sh_src) {
683 ksh = surf->att[ATT_SHINE].constant / 255.;
686 else if (MAP_ATT == sh_src) {
688 check_shin = shbuff ? 1 : 0;
695 coloratt = &(surf->att[ATT_COLOR]);
696 col_src = surf->att[ATT_COLOR].att_src;
698 if (col_src != MAP_ATT) {
699 if (col_src == CONST_ATT) {
700 curcolor = (int)surf->att[ATT_COLOR].constant;
703 curcolor = surf->wire_color;
709 check_material = (check_shin || check_emis || (kem && check_color));
713 for (row = start_val; row <= ycnt - start_val; row += step_val) {
715 datarow1 = row * ymod;
716 datarow2 = (row - (step_val / 2)) * ymod;
717 datarow3 = (row + (step_val / 2)) * ymod;
720 y1 = ymax - row * yres;
721 y2 = ymax - (row - (step_val / 2)) * yres;
722 y3 = ymax - (row + (step_val / 2)) * yres;
724 y1off = row * ymod * surf->cols;
725 y2off = (row - (step_val / 2)) * ymod * surf->cols;
726 y3off = (row + (step_val / 2)) * ymod * surf->cols;
728 for (col = start_val; col <= xcnt - start_val; col += step_val) {
730 datacol1 = col * xmod;
731 datacol2 = (col - (step_val / 2)) * xmod;
732 datacol3 = (col + (step_val / 2)) * xmod;
735 x2 = (col - (step_val / 2)) * xres;
736 x3 = (col + (step_val / 2)) * xres;
742 offset2[0] = y1off + datacol1;
751 offset2[1] = y2off + datacol2;
752 offset2[2] = y2off + datacol1;
753 offset2[3] = y2off + datacol3;
754 offset2[4] = y1off + datacol3;
755 offset2[5] = y3off + datacol3;
756 offset2[6] = y3off + datacol1;
757 offset2[7] = y3off + datacol2;
758 offset2[8] = y1off + datacol2;
759 offset2[9] = y2off + datacol2;
782 for (ii = 0; ii < 10; ii++) {
793 FNORM(surf->norms[offset2[ii]], n);
796 curcolor =
gs_mapcolor(cobuff, coloratt, offset2[ii]);
800 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
801 ktrans = (char)(255 - ktrans) << 24;
805 if (check_material) {
816 if (pksh != ksh || pkem != kem || (kem && check_color)) {
void gsd_zwritemask(unsigned long n)
Write out z-mask.
int BM_get(struct BM *map, int x, int y)
Gets 'val' from the bitmap.
int gsd_wire_surf(geosurf *surf)
Draw surface wire.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
void gsd_do_scale(int doexag)
Set current scale.
void gsd_set_material(int set_shin, int set_emis, float sh, float em, int emcolor)
Set material.
int gsd_surf_const(geosurf *surf, float k)
Using tmesh - not confident with qstrips portability.
int gs_calc_normals(geosurf *gs)
Calculate normals.
void gsd_colormode(int cm)
Set color mode.
void gsd_color_func(unsigned int col)
Set current color.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_litvert_func(float *norm, unsigned long col, float *pt)
Set the current normal vector & specify vertex.
geosurf * gsdiff_get_SDref(void)
ADD.
void gsd_bgntfan(void)
ADD.
void gsd_pushmatrix(void)
Push the current matrix stack.
int gsd_wire_surf_const(geosurf *surf, float k)
ADD.
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
void gsd_endline(void)
End line.
int gsd_wire_arrows(geosurf *surf)
ADD.
void gsd_endtfan(void)
ADD.
int G_debug(int level, const char *msg,...)
Print debugging message.
int gsd_wire_surf_func(geosurf *gs, int(*user_func)())
ADD.
int gsd_coarse_surf_map(geosurf *surf)
Draw coarse surface.
void gsd_blend(int yesno)
Specify pixel arithmetic.
void gsd_vert_func(float *pt)
ADD.
float GS_global_exag(void)
Get global z-exag value.
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
float gsdiff_do_SD(float val, int offset)
ADD.
void gsd_popmatrix(void)
Pop the current matrix stack.
#define SCALE_ATT(att, val, low, high)
int gs_mapcolor(typbuff *cobuff, gsurf_att *coloratt, int offset)
Call this one when you already know att_src is MAP_ATT.
void gsd_bgnline(void)
Begin line.
int gs_update_curmask(geosurf *surf)
Update current maps.
int gsd_arrow(float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf)
ADD.
int gsd_wire_surf_map(geosurf *surf)
ADD.
#define GET_MAPATT(buff, offset, att)