18 #include <grass/gis.h>
19 #include <grass/ogsf.h>
41 float top, bottom, left, right;
57 return (bgn[
X] >= left && bgn[
X] <= right &&
58 end[
X] >= left && end[
X] <= right &&
59 bgn[
Y] >= bottom && bgn[
Y] <= top &&
60 end[
Y] >= bottom && end[
Y] <= top);
79 int gvd_vect(geovect * gv, geosurf * gs,
int do_fast)
82 float bgn[3], end[3], tx, ty, tz, konst;
83 float zmin, zmax, fudge;
88 G_debug(5,
"gvd_vect(): id=%d", gv->gvect_id);
99 fudge = (zmax - zmin) / 500.;
101 if (src == CONST_ATT) {
102 konst = gs->att[ATT_TOPO].constant;
103 bgn[Z] = end[Z] = konst + gv->z_trans;
112 bgn[Z] = end[Z] = konst;
119 gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans + fudge);
125 if (!gv->fastlines) {
135 for (; gln; gln = gln->next) {
136 G_debug(5,
"gvd_vect(): type = %d dims = %d", gln->type, gln->dims);
147 if (gln->highlighted > 0) {
151 else if (gv->tstyle && gv->tstyle->active) {
161 if (gln->type == OGSF_LINE) {
163 if (gln->dims == 2 || !gv->use_z) {
164 G_debug(5,
"gvd_vect(): 2D vector line");
165 for (k = 0; k < gln->npts - 1; k++) {
168 bgn[
X] = gln->p3[k][
X] + gv->x_trans - gs->ox;
169 bgn[
Y] = gln->p3[k][
Y] + gv->y_trans - gs->oy;
170 end[
X] = gln->p3[k + 1][
X] + gv->x_trans - gs->ox;
171 end[
Y] = gln->p3[k + 1][
Y] + gv->y_trans - gs->oy;
174 bgn[
X] = gln->p2[k][
X] + gv->x_trans - gs->ox;
175 bgn[
Y] = gln->p2[k][
Y] + gv->y_trans - gs->oy;
176 end[
X] = gln->p2[k + 1][
X] + gv->x_trans - gs->ox;
177 end[
Y] = gln->p2[k + 1][
Y] + gv->y_trans - gs->oy;
180 if (src == MAP_ATT) {
184 for (i = 0, j = 0; i < npts; i++) {
193 points[i][Z] += gv->z_trans;
206 else if (src == CONST_ATT) {
223 G_debug(5,
"gvd_vect(): 3D vector line");
224 points = (Point3 *) malloc(
sizeof(Point3));
227 for (k = 0; k < gln->npts; k++) {
229 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
231 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
232 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
241 else if (gln->type == OGSF_POLYGON) {
243 if (gln->dims == 3) {
244 G_debug(5,
"gvd_vect(): draw 3D polygon");
247 if (gln->npts >= 3) {
248 points = (Point3 *) malloc(2 *
sizeof(Point3));
249 glEnable(GL_NORMALIZE);
251 glEnable(GL_COLOR_MATERIAL);
252 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
254 glEnable(GL_LIGHTING);
255 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
257 glShadeModel(GL_FLAT);
259 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
262 glColor3f(1.0, 0, 0);
264 glNormal3fv(gln->norm);
266 for (k = 0; k < gln->npts; k++) {
268 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
270 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
271 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
272 glVertex3fv(points[0]);
275 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
309 for (i = 0, j = 0; i < npts; i++) {