[Commit] tess ChangeLog,1.20,1.21 bentley.5c,1.16,1.17

Carl Worth commit at keithp.com
Wed Jul 28 20:26:40 PDT 2004


Committed by: cworth

Update of /local/src/CVS/tess
In directory home.keithp.com:/tmp/cvs-serv8851

Modified Files:
	ChangeLog bentley.5c 
Log Message:

        * bentley.5c: Remove code that is not needed since we won't have
        horizontal edges in our list of edges to intersect.


Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/tess/ChangeLog,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ChangeLog	29 Jul 2004 03:25:15 -0000	1.20
+++ ChangeLog	29 Jul 2004 03:26:37 -0000	1.21
@@ -1,5 +1,10 @@
 2004-07-28  Carl Worth  <cworth at isi.edu>
 
+	* bentley.5c: Remove code that is not needed since we won't have
+	horizontal edges in our list of edges to intersect.
+
+2004-07-28  Carl Worth  <cworth at isi.edu>
+
 	* bentley.5c: Merge kbentley.5c into bentley.5c so that it uses
 	skip lists now. Remove kbentley.5c.
 

Index: bentley.5c
===================================================================
RCS file: /local/src/CVS/tess/bentley.5c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- bentley.5c	29 Jul 2004 03:25:15 -0000	1.16
+++ bentley.5c	29 Jul 2004 03:26:37 -0000	1.17
@@ -3,6 +3,7 @@
 autoload Skiplist;
 
 const bool VALIDATE_SORT = true;
+const bool PRINT_SVG_FILES = false;
 
 autoload Sort;
 
@@ -88,30 +89,17 @@
     if (a.rational_point.y != b.rational_point.y)
         return a.rational_point.y > b.rational_point.y;
 
-    /* XXX: We will be able to drop these when we disallow horizontal
-     * edges. */
-    bool a_horiz = ElementEdge(a.e1)->top.y == ElementEdge(a.e1)->bottom.y;
-    bool b_horiz = ElementEdge(b.e1)->top.y == ElementEdge(b.e1)->bottom.y;
-
     /* Even with the same Y-value, further vertical discrimination is
-     * determined by the event type for non-horizontal edges. Due to
-     * the infinitesimal shortening rule, non-horizontal stop events
-     * occur before the current Y value while non-horizontal start
-     * events occur after the current value.
-     *
-     * So, a non-horizontal stop event is less than another event if
-     * that other event belongs to a horizontal edge or it is not a
-     * stop event. Similar logic holds for non-horizontal start
-     * events.
+     * determined by the event type. Due to the infinitesimal
+     * shortening rule, stop events occur before the current Y value
+     * while start events occur after the current value.
      */
-    if (!a_horiz && (b_horiz || b.type != a.type)) {
+    if (a.type != b.type) {
 	if (a.type == EventType.Stop)
 	    return false;
 	if (a.type == EventType.Start)
 	    return true;
-    }
 
-    if (!b_horiz && (a_horiz || a.type != b.type)) {
 	if (b.type == EventType.Stop)
 	    return true;
 	if (b.type == EventType.Start)
@@ -125,32 +113,9 @@
     if (a.rational_point.x != b.rational_point.x)
         return a.rational_point.x > b.rational_point.x;
 
-    /* At this point, degenerate edges cause problems, (stop events
-     * get scheduled before start events). I had tried adding code
-     * here to fix it, but decided instead to just remove those edges
-     * before the algorithm begine.
-     */
-
-    /* Even with the same X-value, further horizontal discrimination
-     * is determined by the event type for horizontal edges.  As
-     * before, due to the shortening rule, stop events occur before
-     * the current X value while start events occur after the current
-     * value.
-     */
-    if (a.type != b.type) {
-	if (a.type == EventType.Stop)
-	    return false;
-	if (a.type == EventType.Start)
-	    return true;
-	if (b.type == EventType.Stop)
-	    return true;
-	if (b.type == EventType.Start)
-	    return false;
-    }
-
     /* At this stage we are looking at two events of the same type at
      * the same point. The final sort key is a slope comparison. We
-     * need a difference sense for start and stop events based on the
+     * need a different sense for start and stop events based on the
      * shortening rule.
      *
      * NOTE: Fortunately, we get to ignore errors in the relative
@@ -160,9 +125,9 @@
      */
     if (! slope_equal (ElementEdge(a.e1), ElementEdge(b.e1)))
 	if (a.type == EventType.Start)
-            return slope_greater (ElementEdge (a.e1), ElementEdge (b.e1));
+	    return slope_greater (ElementEdge (a.e1), ElementEdge (b.e1));
 	else
-            return ! slope_greater (ElementEdge (a.e1), ElementEdge (b.e1));
+	    return ! slope_greater (ElementEdge (a.e1), ElementEdge (b.e1));
 
     /* As a final discrimination, look at the opposite point. This
      * leaves ambiguities only for identical edges.
@@ -219,27 +184,15 @@
     };
 }
 
-/* XXX: As should be obvious, this function is a bit simpler in the
- * absence of horizontal edges */
 RationalPoint intersect_segments (&Edge a, &Edge b)
 {
     RationalPoint intersection = intersect_lines (&a, &b);
 
-    if (a.top.y == a.bottom.y) {
-	if (intersection.x <= a.top.x || intersection.x >= a.bottom.x)
-	    raise no_intersection ();
-    } else {
-	if (intersection.y <= a.top.y || intersection.y >= a.bottom.y)
-	    raise no_intersection ();
-    }
+    if (intersection.y <= a.top.y || intersection.y >= a.bottom.y)
+	raise no_intersection ();
 
-    if (b.top.y == b.bottom.y) {
-	if (intersection.x <= b.top.x || intersection.x >= b.bottom.x)
-	    raise no_intersection ();
-    } else {
-	if (intersection.y <= b.top.y || intersection.y >= b.bottom.y)
-	    raise no_intersection ();
-    }
+    if (intersection.y <= b.top.y || intersection.y >= b.bottom.y)
+	raise no_intersection ();
 
     return intersection;
 }
@@ -407,16 +360,6 @@
     EventQueue event_queue = Sortlist::new (event_greater);
     Edge[...] result = {};
 
-    Edge[*] remove_degenerate (Edge[*] edges) {
-	Edge[...] non_degenerate = {};
-	for (int i=0; i < dim(edges); i++)
-	    if (edges[i].top.x != edges[i].bottom.x ||
-		edges[i].top.y != edges[i].bottom.y)
-		non_degenerate[dim(non_degenerate)] = edges[i];
-
-	return non_degenerate;
-    }
-
     Edge[*] remove_horizontal (Edge[*] edges) {
 	Edge[...] non_horizontal = {};
 	for (int i=0; i < dim(edges); i++)
@@ -427,9 +370,6 @@
     }
 
     void initialize_event_queue (Edge[*] segments) {
-/*
-	segments = remove_degenerate (segments);
-*/
 	segments = remove_horizontal (segments);
 
 	for (int i=0; i < dim(segments); i++) {
@@ -561,7 +501,7 @@
 
 	current_y = event->point.y;
 
-	if (true)
+	if (PRINT_SVG_FILES)
 	{
 	    string filename;
 	    filename = sprintf ("%s_%04d.svg", TEST_NAME, FRAME_COUNT++);




More information about the Commit mailing list