22 #include <grass/gis.h>
23 #include <grass/gstypes.h>
45 float top, bottom, left, right;
61 return (bgn[
X] >= left && bgn[
X] <= right &&
62 end[
X] >= left && end[
X] <= right &&
63 bgn[
Y] >= bottom && bgn[
Y] <= top &&
64 end[
Y] >= bottom && end[
Y] <= top);
83 int gvd_vect(geovect * gv, geosurf * gs,
int do_fast)
86 float bgn[3], end[3], tx, ty, tz, konst;
87 float zmin, zmax, fudge;
92 G_debug(5,
"gvd_vect(): id=%d", gv->gvect_id);
103 fudge = (zmax - zmin) / 500.;
105 if (src == CONST_ATT) {
106 konst = gs->att[ATT_TOPO].constant;
107 bgn[Z] = end[Z] = konst;
116 bgn[Z] = end[Z] = konst;
123 gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans + fudge);
131 if (!gv->fastlines) {
141 for (; gln; gln = gln->next) {
142 G_debug(5,
"gvd_vect(): type = %d dims = %d", gln->type, gln->dims);
153 if (gln->type == OGSF_LINE) {
154 if (gln->dims == 2) {
155 G_debug(5,
"gvd_vect(): 2D vector line");
156 for (k = 0; k < gln->npts - 1; k++) {
157 bgn[
X] = gln->p2[k][
X] + gv->x_trans - gs->ox;
158 bgn[
Y] = gln->p2[k][
Y] + gv->y_trans - gs->oy;
159 end[
X] = gln->p2[k + 1][
X] + gv->x_trans - gs->ox;
160 end[
Y] = gln->p2[k + 1][
Y] + gv->y_trans - gs->oy;
162 if (src == MAP_ATT) {
166 for (i = 0, j = 0; i < npts; i++) {
175 points[i][Z] += gv->z_trans;
188 else if (src == CONST_ATT) {
205 G_debug(5,
"gvd_vect(): 3D vector line");
206 points = (Point3 *) malloc(
sizeof(Point3));
210 for (k = 0; k < gln->npts; k++) {
212 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
214 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
215 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
223 else if (gln->type == OGSF_POLYGON) {
224 if (gln->dims == 3) {
225 G_debug(5,
"gvd_vect(): draw 3D polygon");
228 if (gln->npts >= 3) {
229 points = (Point3 *) malloc(2 *
sizeof(Point3));
230 glEnable(GL_NORMALIZE);
232 glEnable(GL_COLOR_MATERIAL);
233 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
235 glEnable(GL_LIGHTING);
236 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
238 glShadeModel(GL_FLAT);
240 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
243 glColor3f(1.0, 0, 0);
245 glNormal3fv(gln->norm);
247 for (k = 0; k < gln->npts; k++) {
249 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
251 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
252 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
253 glVertex3fv(points[0]);
256 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
289 for (i = 0, j = 0; i < npts; i++) {