Index: trunk/magic/remove/src/Line.c
===================================================================
--- trunk/magic/remove/src/Line.c	(revision 25001)
+++ trunk/magic/remove/src/Line.c	(revision 25082)
@@ -36,5 +36,5 @@
     // If the current line is not vertical, check to see if the point
     // is inside the two endpoints independent of direction
-    
+
     if (line->begin.x != line->end.x)
     {
@@ -59,11 +59,11 @@
     ux = line->end.x - line->begin.x;
     uy = line->end.y - line->begin.y;
-    
+
     vx = x - line->begin.x;
     vy = y - line->begin.y;
-    
+
     double u_u = ux * ux + uy * uy;                         // (u . u)
     double u_v = ux * vx + uy * vy;                         // (u . v)
-    
+
     if (u_v <= 0) return vx * vx + vy * vy;                 // (v . v)
     if (u_u <= u_v)
@@ -73,8 +73,8 @@
         return wx * wx + wy * wy;                           // (w . w)
     }
-    
+
     // Compute P(b) is the base of the perpendicular dropped from tuple to
     // the line
-    
+
     b = u_v / u_u;
     px = vx - b * ux;
@@ -109,25 +109,25 @@
     double wx  = first->begin.x - second->begin.x;
     double wy  = first->begin.y - second->begin.y;
-    
+
     // Calculate the perpendicular product, dt
-    
+
     double dt = dx1 * dy2 - dy1 * dx2;
-    
+
     // Are the lines parallel?
-    
+
     if (fabs (dt) <= 1e-8)
     {
         // Check to see if they are overlap
-        
+
         if (dx1 * wy - dy1 * wx != 0 || dx2 * wy - dy2 * wx != 0) return 0;
-        
+
         // The line are coplanar, so check to see if they are degenerate
-        
+
         len1 = dx1 * dx1 + dy1 * dy1;
         len2 = dx2 * dx2 + dy2 * dy2;
-        
+
         // First, check to see if both lines are points and if they are
         // distinct tuples
-        
+
         if (len1 == 0 && len2 == 0)
         {
@@ -137,8 +137,8 @@
             return 1;
         }
-        
+
         // Check to see if the first line is a point and is inside the
         // second line
-        
+
         if (len1 == 0)
         {
@@ -148,8 +148,8 @@
                 return 0;
         }
-        
+
         // Check to see if the second line is a point and is inside the
         // first line
-        
+
         if (len2 == 0)
         {
@@ -159,14 +159,14 @@
                 return 0;
         }
-        
+
         // Since both lines are coplanar and have length, search for
         // overlap tuples
-        
+
         w2x = first->end.x - second->begin.x;
         w2y = first->end.y - second->begin.y;
-        
+
         t0 = (dx2 != 0) ? wx  / dx2 : wy  / dy2;
         t1 = (dx2 != 0) ? w2x / dx2 : w2y / dy2;
-        
+
         if (t0 > t1) SwapDouble (&t0, &t1);
         if ((inFirstSegment || inSecondSegment) && (t0 > 1 || t1 < 0))
@@ -176,27 +176,27 @@
         t0 = (t0 < 0) ? 0 : t0;             // Clip to min 0
         t1 = (t1 > 1) ? 1 : t1;             // Clip to max 1
-        
+
         // Set the first tuple of intersection
-        
+
         tuple1->x = second->begin.x + t0 * dx2;
         tuple1->y = second->begin.y + t0 * dy2;
-        
+
         // Check to see if the intersection is a single tuple
-        
+
         if (t0 == t1) return 1;
-        
+
         // Otherwise, set the second tuple of intersection as well
-        
+
         tuple2->x = second->begin.x + t1 * dx2;
         tuple2->y = second->begin.y + t1 * dy2;
         return 2;
     }
-    
+
     // The segments are skew and may intersect in a tuple.
     // Get the intersect parameter for the first line
-    
+
     double i1 = (dx2 * wy - dy2 * wx) / dt;
     if (inFirstSegment && (i1 < 0 || i1 > 1)) return 0;
-    
+
     // Get the intersect parameter for the second line
 
@@ -226,4 +226,9 @@
     vertices[3].x = 0;       vertices[3].y = numRows;
 
+    clipLine.begin.x = 0;
+    clipLine.begin.y = 0;
+    clipLine.end.x = 0;
+    clipLine.end.y = 0;
+
     for (i = 0; i < 4 && found < 2; ++i)
     {
@@ -237,5 +242,5 @@
                 ++found;
             }
-            else if (tuple1.x != clipLine.begin.x || 
+            else if (tuple1.x != clipLine.begin.x ||
                      tuple1.y != clipLine.begin.y)
             {
@@ -245,7 +250,7 @@
         }
     }
-    
+
     // If two endpoints are found, clip the line
-    
+
     if (found > 1)
     {
@@ -283,4 +288,9 @@
     vertices[3].x = minX; vertices[3].y = maxY;
 
+    clipLine.begin.x = 0;
+    clipLine.begin.y = 0;
+    clipLine.end.x = 0;
+    clipLine.end.y = 0;
+
     for (i = 0; i < 4 && found < 2; ++i)
     {
@@ -294,5 +304,5 @@
                 ++found;
             }
-            else if (tuple1.x != clipLine.begin.x || 
+            else if (tuple1.x != clipLine.begin.x ||
                      tuple1.y != clipLine.begin.y)
             {
@@ -302,7 +312,7 @@
         }
     }
-    
+
     // If two endpoints are found, clip the line
-    
+
     if (found > 1)
     {
@@ -360,5 +370,5 @@
     @param[out] pixels list of PixelPos pointers corresponding
                        based on the line settings
-    @param[in] line Line to map to pixels   
+    @param[in] line Line to map to pixels
     @param[in] numCols maximum X (columns) for the line
     @param[in] numRows maximum Y (rows) for the line            */
@@ -367,17 +377,16 @@
 {
     Line offsetLine;
-    PixelPos *pixel;
     double slope, xOffset, yOffset, xMid, yMid;
     int x, y, xBegin = numCols, yBegin = numRows, xEnd = 0, yEnd = 0;
 
     // Extract the endpoints
-    
+
     double x1 = line->begin.x;
     double y1 = line->begin.y;
     double x2 = line->end.x;
     double y2 = line->end.y;
-    
+
     // Determine the width and height of the line
-    
+
     double dx = x2 - x1;
     double dy = y2 - y1;
@@ -403,5 +412,5 @@
 
     // Step point by point based on the dominate axis
-    
+
     if (fabs (dx) > fabs (dy))
     {
@@ -411,5 +420,5 @@
         // If line is back to front, reorder endpoints and recompute
         // the line width and height
-        
+
         if (x1 > x2)
         {
@@ -421,10 +430,10 @@
 
         // Compute the slope of the line
-        
+
         slope = dy / dx;
-        
+
         // Compute the x and y offsets for the line width extent
 
-        if (xBegin > xEnd) 
+        if (xBegin > xEnd)
             SwapInt (&xBegin, &xEnd);
         else
@@ -451,5 +460,5 @@
     }
     else
-    {       
+    {
         // -------------------
         // vertical(ish) lines
@@ -457,5 +466,5 @@
         // If line is back to front, reorder endpoints and recompute
         // the line width and height
-        
+
         if (y1 > y2)
         {
@@ -465,9 +474,9 @@
             dy = y2 - y1;
         }
-        
+
         // Compute the slope of the line
-        
+
         slope = dx / dy;
-        
+
         // Compute the x and y offsets for the line width extent
 
@@ -481,5 +490,5 @@
         xMid = x1 + slope * (yBegin - y1);
         xOffset = fabs (halfWidth * dr / dy);
-        
+
         for (y = yBegin; y != yEnd; ++y)
         {
