[GRASS-CVS] glynn: grass6/lib/display draw2.c,1.12,1.13
grass at intevation.de
grass at intevation.de
Mon Dec 3 04:16:32 EST 2007
- Previous message: [GRASS-CVS] glynn: grass6/include display.h,2.22,2.23
- Next message: [GRASS-CVS] markus: grass6/gui/tcltk/gis.m description.html,
1.14.2.4, 1.14.2.5 georect.tcl, 1.37.2.2,
1.37.2.3 gm_profile.html, 1.3.2.3, 1.3.2.4 gmmenu.tcl,
1.53.2.2, 1.53.2.3 mapcanvas.tcl, 1.77, 1.77.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: glynn
Update of /grassrepository/grass6/lib/display
In directory doto:/tmp/cvs-serv11912/lib/display
Modified Files:
draw2.c
Log Message:
Remove clip margin
Filter zero-length segments
Round point/line vertices downward instead of to nearest
Index: draw2.c
===================================================================
RCS file: /grassrepository/grass6/lib/display/draw2.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- draw2.c 14 Jun 2007 10:36:12 -0000 1.12
+++ draw2.c 3 Dec 2007 09:16:30 -0000 1.13
@@ -56,7 +56,6 @@
static struct vector cur;
static struct rectangle clip;
-static double clip_margin;
static struct plane pl_left = {-1, 0, 0};
static struct plane pl_rite = { 1, 0, 0};
@@ -115,7 +114,25 @@
yf = NULL;
}
-static void do_convert(const double *x, const double *y, int n)
+static int do_filter(int *x, int *y, int n)
+{
+ int i, j;
+
+ for (i = 0, j = 1; j < n; j++)
+ {
+ if (x[j] == x[i] && y[j] == y[i])
+ continue;
+ i++;
+ if (i == j)
+ continue;
+ x[i] = x[j];
+ y[i] = y[j];
+ }
+
+ return i + 1;
+}
+
+static void do_round(const double *x, const double *y, int n)
{
int i;
@@ -128,6 +145,19 @@
}
}
+static void do_floor(const double *x, const double *y, int n)
+{
+ int i;
+
+ alloc_int(n);
+
+ for (i = 0; i < n; i++)
+ {
+ xi[i] = floor(D_u_to_d_col(x[i]));
+ yi[i] = floor(D_u_to_d_row(y[i]));
+ }
+}
+
static double dist_plane(double x, double y, const struct plane *p)
{
return x * p->x + y * p->y + p->k;
@@ -296,27 +326,6 @@
}
/*!
- * \brief set clip margin
- *
- * Sets the clip margin, i.e. the distance by which a line must extend
- * beyond the frame before it will be clipped.
- *
- * D_clip_to_map() enlarges the clip window beyond the frame by this
- * value.
- *
- * This function unsets the clip window, so it will be recalculated by
- * the next drawing operation.
- *
- * \param d
- */
-
-void D_set_clip_margin(double d)
-{
- clip_margin = d;
- window_set = 0;
-}
-
-/*!
* \brief set clipping window to map window
*
* Sets the clipping window to the pixel window that corresponds to the
@@ -327,13 +336,11 @@
void D_clip_to_map(void)
{
- double d = clip_margin;
-
D_set_clip(
- D_get_u_north() - d,
- D_get_u_south() + d,
- D_get_u_west() - d,
- D_get_u_east() + d);
+ D_get_u_north(),
+ D_get_u_south(),
+ D_get_u_west(),
+ D_get_u_east());
}
/*!
@@ -464,7 +471,8 @@
j++;
}
- do_convert(xf, yf, n);
+ do_floor(xf, yf, n);
+ n = do_filter(xi, yi, n);
R_polydots_abs(xi, yi, j);
}
@@ -540,7 +548,8 @@
dealloc_float(&x, &y, 1);
- do_convert(x, y, n);
+ do_floor(x, y, n);
+ n = do_filter(xi, yi, n);
R_polyline_abs(xi, yi, n);
}
@@ -652,7 +661,8 @@
dealloc_float(&x, &y, 1);
- do_convert(x, y, n);
+ do_round(x, y, n);
+ n = do_filter(xi, yi, n);
R_polygon_abs(xi, yi, n);
}
@@ -734,7 +744,8 @@
dealloc_float(&x, &y, 1);
- do_convert(x, y, n);
+ do_round(x, y, n);
+ n = do_filter(xi, yi, n);
R_polygon_abs(xi, yi, n);
}
@@ -812,19 +823,22 @@
void D_polydots(const double *x, const double *y, int n)
{
- do_convert(x, y, n);
+ do_floor(x, y, n);
+ n = do_filter(xi, yi, n);
R_polydots_abs(xi, yi, n);
}
void D_polyline(const double *x, const double *y, int n)
{
- do_convert(x, y, n);
+ do_floor(x, y, n);
+ n = do_filter(xi, yi, n);
R_polyline_abs(xi, yi, n);
}
void D_polygon(const double *x, const double *y, int n)
{
- do_convert(x, y, n);
+ do_round(x, y, n);
+ n = do_filter(xi, yi, n);
R_polygon_abs(xi, yi, n);
}
@@ -845,20 +859,10 @@
void D_line_width(double d)
{
int w = round(d);
- double m;
if (w < 0)
w = 0;
R_line_width(w);
-
- /* clip/cull margin should be >0 */
- if (w < 1)
- w = 1;
-
- m = ceil(w / 2.0);
- m /= D_get_u_to_d_xconv();
-
- D_set_clip_margin(m);
}
- Previous message: [GRASS-CVS] glynn: grass6/include display.h,2.22,2.23
- Next message: [GRASS-CVS] markus: grass6/gui/tcltk/gis.m description.html,
1.14.2.4, 1.14.2.5 georect.tcl, 1.37.2.2,
1.37.2.3 gm_profile.html, 1.3.2.3, 1.3.2.4 gmmenu.tcl,
1.53.2.2, 1.53.2.3 mapcanvas.tcl, 1.77, 1.77.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the grass-commit
mailing list