19 #include <grass/gis.h>
20 #include <grass/gstypes.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;
488 coloratt = &(surf->att[ATT_COLOR]);
489 col_src = surf->att[ATT_COLOR].att_src;
491 if (col_src != MAP_ATT) {
492 if (col_src == CONST_ATT) {
493 curcolor = (
int)surf->att[ATT_COLOR].constant;
496 curcolor = surf->wire_color;
507 xres = xmod * surf->xres;
508 yres = ymod * surf->yres;
509 ymax = (surf->rows - 1) * surf->yres;
510 xcnt = 1 + (surf->cols - 1) / xmod;
511 ycnt = 1 + (surf->rows - 1) / ymod;
517 zexag = surf->z_exag;
522 for (row = 0; row < ycnt; row++) {
523 pt[
Y] = ymax - row * yres;
524 y1off = row * ymod * surf->cols;
526 for (col = 0; col < xcnt; col++) {
528 offset = col * xmod + y1off;
531 if (
BM_get(surf->curmask, col * xmod, row * ymod)) {
536 FNORM(surf->norms[offset], n);
544 gsd_arrow(pt, curcolor, xres * 2, n, sz, surf);
573 int check_mask, check_color, check_transp;
574 int check_material, check_emis, check_shin;
575 typbuff *
buff, *cobuff, *trbuff, *embuff, *shbuff;
577 int row, col, xcnt, ycnt;
578 long y1off, y2off, y3off;
582 float x1, x2, x3, y1, y2, y3, tx, ty, tz, ttr;
583 float n[3], pt[4], xres, yres,
ymax, zexag;
584 int em_src, sh_src, trans_src, col_src, curcolor;
585 gsurf_att *ematt, *shatt, *tratt, *coloratt;
588 int datarow1, datacol1, datarow2, datacol2, datarow3, datacol3;
590 float kem, ksh, pkem, pksh;
593 int step_val = 2 * surf->x_modw;
594 int start_val = surf->x_modw;
615 check_mask = surf->curmask ? 1 : 0;
623 xres = xmod * surf->xres;
624 yres = ymod * surf->yres;
625 ymax = (surf->rows - 1) * surf->yres;
633 zexag = surf->z_exag;
645 tratt = &(surf->att[ATT_TRANSP]);
646 ktrans = (255 << 24);
647 trans_src = surf->att[ATT_TRANSP].att_src;
649 if (CONST_ATT == trans_src && surf->att[ATT_TRANSP].constant != 0.0) {
650 ktrans = (255 - (
int)surf->att[ATT_TRANSP].constant) << 24;
654 else if (MAP_ATT == trans_src) {
656 check_transp = trbuff ? 1 : 0;
662 ematt = &(surf->att[ATT_EMIT]);
665 em_src = surf->att[ATT_EMIT].att_src;
667 if (CONST_ATT == em_src) {
668 kem = surf->att[ATT_EMIT].constant / 255.;
670 else if (MAP_ATT == em_src) {
672 check_emis = embuff ? 1 : 0;
676 shatt = &(surf->att[ATT_SHINE]);
679 sh_src = surf->att[ATT_SHINE].att_src;
681 if (CONST_ATT == sh_src) {
682 ksh = surf->att[ATT_SHINE].constant / 255.;
685 else if (MAP_ATT == sh_src) {
687 check_shin = shbuff ? 1 : 0;
693 coloratt = &(surf->att[ATT_COLOR]);
694 col_src = surf->att[ATT_COLOR].att_src;
696 if (col_src != MAP_ATT) {
697 if (col_src == CONST_ATT) {
698 curcolor = (
int)surf->att[ATT_COLOR].constant;
701 curcolor = surf->wire_color;
707 check_material = (check_shin || check_emis || (kem && check_color));
711 for (row = start_val; row <= ycnt - start_val; row += step_val) {
713 datarow1 = row * ymod;
714 datarow2 = (row - (step_val / 2)) * ymod;
715 datarow3 = (row + (step_val / 2)) * ymod;
718 y1 = ymax - row * yres;
719 y2 = ymax - (row - (step_val / 2)) * yres;
720 y3 = ymax - (row + (step_val / 2)) * yres;
722 y1off = row * ymod * surf->cols;
723 y2off = (row - (step_val / 2)) * ymod * surf->cols;
724 y3off = (row + (step_val / 2)) * ymod * surf->cols;
726 for (col = start_val; col <= xcnt - start_val; col += step_val) {
728 datacol1 = col * xmod;
729 datacol2 = (col - (step_val / 2)) * xmod;
730 datacol3 = (col + (step_val / 2)) * xmod;
733 x2 = (col - (step_val / 2)) * xres;
734 x3 = (col + (step_val / 2)) * xres;
740 offset2[0] = y1off + datacol1;
749 offset2[1] = y2off + datacol2;
750 offset2[2] = y2off + datacol1;
751 offset2[3] = y2off + datacol3;
752 offset2[4] = y1off + datacol3;
753 offset2[5] = y3off + datacol3;
754 offset2[6] = y3off + datacol1;
755 offset2[7] = y3off + datacol2;
756 offset2[8] = y1off + datacol2;
757 offset2[9] = y2off + datacol2;
780 for (ii = 0; ii < 10; ii++) {
791 FNORM(surf->norms[offset2[ii]], n);
794 curcolor =
gs_mapcolor(cobuff, coloratt, offset2[ii]);
798 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
799 ktrans = (char)(255 - ktrans) << 24;
803 if (check_material) {
814 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 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 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.
int G_debug(int level, const char *msg,...)
Print debugging message.
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.
float GS_global_exag(void)
Get global z-exag value.
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.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
int gsd_wire_surf_map(geosurf *surf)
ADD.
#define GET_MAPATT(buff, offset, att)