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 + gv->z_trans;
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++) {
void G_free(void *buf)
Free allocated memory.
void gvd_draw_lineonsurf(geosurf *gs, float *bgn, float *end, int color)
Draw line on surface.
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
void gsd_do_scale(int doexag)
Set current scale.
void gsd_colormode(int cm)
Set color mode.
int GS_check_cancel(void)
Check for cancel.
void gsd_color_func(unsigned int col)
Set current color.
int gs_clip_segment(geosurf *gs, float *bgn, float *end, float *region)
Clip segment.
int gvd_vect(geovect *gv, geosurf *gs, int do_fast)
Draw vector set.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_pushmatrix(void)
Push the current matrix stack.
void gsd_endline(void)
End line.
int gv_decimate_lines(geovect *gv)
Decimate line.
void gsd_vert_func(float *pt)
ADD.
Point3 * gsdrape_get_segments(geosurf *gs, float *bgn, float *end, int *num)
ADD.
int G_debug(int level, const char *msg,...)
Print debugging message.
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
void gsd_linewidth(short n)
Set width of rasterized lines.
void gsd_popmatrix(void)
Pop the current matrix stack.
int gs_get_zrange(float *min, float *max)
Get z-range.
void gsd_bgnline(void)
Begin line.
int gs_update_curmask(geosurf *surf)
Update current maps.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.