20#include <grass/ogsf.h>
42 float top, bottom, left, right;
58 return (bgn[
X] >= left && bgn[
X] <= right && end[
X] >= left &&
59 end[
X] <= right && bgn[
Y] >= bottom && bgn[
Y] <= top &&
60 end[
Y] >= bottom && end[
Y] <= top);
79int 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++) {
166 if (gln->dims == 3) {
167 bgn[
X] = gln->p3[k][
X] + gv->x_trans - gs->ox;
168 bgn[
Y] = gln->p3[k][
Y] + gv->y_trans - gs->oy;
169 end[
X] = gln->p3[k + 1][
X] + gv->x_trans - gs->ox;
170 end[
Y] = gln->p3[k + 1][
Y] + gv->y_trans - gs->oy;
173 bgn[
X] = gln->p2[k][
X] + gv->x_trans - gs->ox;
174 bgn[
Y] = gln->p2[k][
Y] + gv->y_trans - gs->oy;
175 end[
X] = gln->p2[k + 1][
X] + gv->x_trans - gs->ox;
176 end[
Y] = gln->p2[k + 1][
Y] + gv->y_trans - gs->oy;
179 if (src == MAP_ATT) {
183 for (i = 0, j = 0; i < npts; i++) {
192 points[i][Z] += gv->z_trans;
205 else if (src == CONST_ATT) {
222 G_debug(5,
"gvd_vect(): 3D vector line");
223 points = (Point3 *)malloc(
sizeof(Point3));
226 for (k = 0; k < gln->npts; k++) {
228 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
230 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
231 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
240 else if (gln->type == OGSF_POLYGON) {
242 if (gln->dims == 3) {
243 G_debug(5,
"gvd_vect(): draw 3D polygon");
246 if (gln->npts >= 3) {
247 points = (Point3 *)malloc(2 *
sizeof(Point3));
248 glEnable(GL_NORMALIZE);
250 glEnable(GL_COLOR_MATERIAL);
251 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
253 glEnable(GL_LIGHTING);
254 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
256 glShadeModel(GL_FLAT);
258 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
261 glColor3f(1.0, 0, 0);
263 glNormal3fv(gln->norm);
265 for (k = 0; k < gln->npts; k++) {
267 (float)(gln->p3[k][
X] + gv->x_trans - gs->ox);
269 (float)(gln->p3[k][
Y] + gv->y_trans - gs->oy);
270 points[0][Z] = (float)(gln->p3[k][Z] + gv->z_trans);
271 glVertex3fv(points[0]);
274 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
308 for (i = 0, j = 0; i < npts; i++) {
void G_free(void *buf)
Free allocated memory.
int G_debug(int level, const char *msg,...)
Print debugging message.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
int gs_get_zrange(float *min, float *max)
Get z-range.
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
int gs_update_curmask(geosurf *surf)
Update current maps.
void gsd_pushmatrix(void)
Push the current matrix stack.
void gsd_vert_func(float *pt)
ADD.
void gsd_colormode(int cm)
Set color mode.
void gsd_popmatrix(void)
Pop the current matrix stack.
void gsd_endline(void)
End line.
void gsd_bgnline(void)
Begin line.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_color_func(unsigned int col)
Set current color.
void gsd_linewidth(short n)
Set width of rasterized lines.
void gsd_do_scale(int doexag)
Set current scale.
Point3 * gsdrape_get_segments(geosurf *gs, float *bgn, float *end, int *num)
ADD.
int GS_check_cancel(void)
Check for cancel.
int gv_decimate_lines(geovect *gv)
Decimate line.
void gvd_draw_lineonsurf(geosurf *gs, float *bgn, float *end, int color)
Draw line on surface.
int gvd_vect(geovect *gv, geosurf *gs, int do_fast)
Draw vector set.
int gs_clip_segment(geosurf *gs, float *bgn, float *end, float *region)
Clip segment.