You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dg...@hyperreal.org on 1998/03/01 01:31:51 UTC
cvs commit: apache-1.3/src/modules/standard mod_imap.c
dgaudet 98/02/28 16:31:51
Modified: src CHANGES
src/modules/standard mod_imap.c
Log:
fix border processing for polys
PR: 1771
Submitted by: Konstantin Morshnev <mo...@design.ru>
Revision Changes Path
1.675 +4 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.674
retrieving revision 1.675
diff -u -r1.674 -r1.675
--- CHANGES 1998/03/01 00:19:33 1.674
+++ CHANGES 1998/03/01 00:31:47 1.675
@@ -1,5 +1,9 @@
Changes with Apache 1.3b6
+ *) The "poly" directive in image maps did not include the borders of the
+ polygon, whereas the "rect" directive does. Fix this inconsistency.
+ [Konstantin Morshnev <mo...@design.ru>] PR#1771
+
*) Make \\ behave as expected. [Ronald.Tschalaer@psi.ch]
*) Add `Rule HIDE' to Configuration to hide the Apache symbol
1.42 +23 -74 apache-1.3/src/modules/standard/mod_imap.c
Index: mod_imap.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_imap.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- mod_imap.c 1998/02/01 22:05:40 1.41
+++ mod_imap.c 1998/03/01 00:31:50 1.42
@@ -196,86 +196,35 @@
return (radius2 <= radius1);
}
+#define fmin(a,b) (((a)>(b))?(b):(a))
+#define fmax(a,b) (((a)>(b))?(a):(b))
+
static int pointinpoly(const double point[2], double pgon[MAXVERTS][2])
{
- int i, numverts, inside_flag, xflag0;
- int crossings;
- double *p;
- const double *stop;
- double tx, ty, y;
-
- for (i = 0; pgon[i][X] != -1 && i < MAXVERTS; i++);
-
- numverts = i;
- crossings = 0;
-
- tx = point[X];
- ty = point[Y];
- y = pgon[numverts - 1][Y];
+ int i, numverts, crossings = 0;
+ double x = point[X], y = point[Y];
- p = (double *) pgon + 1;
- if ((y >= ty) != (*p >= ty)) {
-
- xflag0 = (pgon[numverts - 1][X] >= tx);
- if (xflag0 == (*(double *) pgon >= tx)) {
- if (xflag0) {
- crossings++;
- }
- }
- else {
- crossings += (pgon[numverts - 1][X] - (y - ty) *
- (*(double *) pgon - pgon[numverts - 1][X]) /
- (*p - y)) >= tx;
- }
+ for (numverts = 0; pgon[numverts][X] != -1 && numverts < MAXVERTS;
+ numverts++) {
+ /* just counting the vertexes */
}
- stop = pgon[numverts];
-
- for (y = *p, p += 2; p < stop; y = *p, p += 2) {
-
- if (y >= ty) {
-
- while ((p < stop) && (*p >= ty)) {
- p += 2;
- }
-
- if (p >= stop) {
- break;
- }
- if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
-
- if (xflag0) {
- crossings++;
- }
- }
- else {
- crossings += (*(p - 3) - (*(p - 2) - ty) *
- (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
- }
- }
- else {
- while ((p < stop) && (*p < ty)) {
- p += 2;
- }
-
- if (p >= stop) {
- break;
- }
-
- if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
- if (xflag0) {
- crossings++;
- }
- }
- else {
- crossings += (*(p - 3) - (*(p - 2) - ty) *
- (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
- }
- }
+ for (i = 0; i < numverts; i++) {
+ double x1=pgon[i][X];
+ double y1=pgon[i][Y];
+ double x2=pgon[(i + 1) % numverts][X];
+ double y2=pgon[(i + 1) % numverts][Y];
+ double d=(y - y1) * (x2 - x1) - (x - x1) * (y2 - y1);
+
+ if ((y1 >= y) != (y2 >= y)) {
+ crossings +=y2 - y1 >= 0 ? d >= 0 : d <= 0;
+ }
+ if (!d && fmin(x1,x2) <= x && x <= fmax(x1,x2)
+ && fmin(y1,y2) <= y && y <= fmax(y1,y2)) {
+ return 1;
+ }
}
-
- inside_flag = crossings & 0x01;
- return (inside_flag);
+ return crossings & 0x01;
}