[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (c200dd11f9c608a40db6e9894eafc34510aff220)



The branch, master has been updated
       via  c200dd11f9c608a40db6e9894eafc34510aff220 (commit)
      from  750f05c6fe9a9ce7e40f254923ab61a10c5ffa2b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/create.c                  |    2 ++
 src/global.h                  |    2 ++
 src/hid/common/draw_helpers.c |   14 ++++++++++++--
 src/mymem.c                   |    1 +
 src/polygon.c                 |   37 +++++++++++++++++++++++++++++++++++++
 src/polygon.h                 |    1 +
 6 files changed, 55 insertions(+), 2 deletions(-)


=================
 Commit Messages
=================

commit c200dd11f9c608a40db6e9894eafc34510aff220
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Add cache for "noholes", diced versions of polygons

:100644 100644 6d34465... 500d0a0... M	src/create.c
:100644 100644 e8fc8f1... f494dbc... M	src/global.h
:100644 100644 a7c4620... ded1bc8... M	src/hid/common/draw_helpers.c
:100644 100644 36b13d5... c3663d6... M	src/mymem.c
:100644 100644 46cba47... 106caff... M	src/polygon.c
:100644 100644 1ec0a04... 2faaa20... M	src/polygon.h

=========
 Changes
=========

commit c200dd11f9c608a40db6e9894eafc34510aff220
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Add cache for "noholes", diced versions of polygons

diff --git a/src/create.c b/src/create.c
index 6d34465..500d0a0 100644
--- a/src/create.c
+++ b/src/create.c
@@ -610,6 +610,8 @@ CreateNewPolygon (LayerTypePtr Layer, FlagType Flags)
   polygon->Flags = Flags;
   polygon->ID = ID++;
   polygon->Clipped = NULL;
+  polygon->NoHoles = NULL;
+  polygon->NoHolesValid = 0;
   return (polygon);
 }
 
diff --git a/src/global.h b/src/global.h
index e8fc8f1..f494dbc 100644
--- a/src/global.h
+++ b/src/global.h
@@ -241,6 +241,8 @@ struct polygon_st			/* holds information about a polygon */
   Cardinal PointN,		/* number of points in polygon */
     PointMax;			/* max number from malloc() */
   POLYAREA *Clipped;		/* the clipped region of this polygon */
+  PLINE *NoHoles;		/* the polygon broken into hole-less regions */
+  int NoHolesValid;		/* Is the NoHoles polygon up to date? */
   PointTypePtr Points;		/* data */
 };
 
diff --git a/src/hid/common/draw_helpers.c b/src/hid/common/draw_helpers.c
index a7c4620..ded1bc8 100644
--- a/src/hid/common/draw_helpers.c
+++ b/src/hid/common/draw_helpers.c
@@ -70,9 +70,20 @@ void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
             we are dicing for every case. Some GUIs
             rely on this, and need their flags fixing. */
 
-  NoHolesPolygonDicer (poly, clip_box, fill_contour_cb, gc);
+  if (!poly->NoHolesValid)
+    {
+      ComputeNoHoles (poly);
+    }
+  if (poly->NoHoles)
+    {
+      PLINE *pl;
+
+      for (pl = poly->NoHoles; pl != NULL; pl = pl->next)
+        fill_contour (gc, pl);
+    }
 
   /* Draw other parts of the polygon if fullpoly flag is set */
+  /* NB: No "NoHoles" cache for these */
   if (TEST_FLAG (FULLPOLYFLAG, poly))
     {
       PolygonType p = *poly;
@@ -82,7 +93,6 @@ void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
            p.Clipped = p.Clipped->f)
         NoHolesPolygonDicer (&p, clip_box, fill_contour_cb, gc);
     }
-
 }
 
 static int thindraw_hole_cb (PLINE *pl, void *user_data)
diff --git a/src/mymem.c b/src/mymem.c
index 36b13d5..c3663d6 100644
--- a/src/mymem.c
+++ b/src/mymem.c
@@ -736,6 +736,7 @@ FreePolygonMemory (PolygonTypePtr Polygon)
       MYFREE (Polygon->Points);
       if (Polygon->Clipped)
 	poly_Free (&Polygon->Clipped);
+      poly_FreeContours (&Polygon->NoHoles);
       memset (Polygon, 0, sizeof (PolygonType));
     }
 }
diff --git a/src/polygon.c b/src/polygon.c
index 46cba47..106caff 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -120,6 +120,26 @@ static double circleVerticies[] = {
   0.98480775301221, 0.17364817766693,
 };
 
+static void
+add_noholes_polyarea (PLINE *pline, void *user_data)
+{
+  PolygonType *poly = user_data;
+
+  /* Prepend the pline into the NoHoles linked list */
+  pline->next = poly->NoHoles;
+  poly->NoHoles = pline;
+}
+
+void
+ComputeNoHoles (PolygonType *poly)
+{
+  poly_FreeContours (&poly->NoHoles);
+  if (poly->Clipped)
+    NoHolesPolygonDicer (poly, NULL, add_noholes_polyarea, poly);
+  else
+    printf ("Compute_noholes caught poly->Clipped = NULL\n");
+  poly->NoHolesValid = 1;
+}
 
 static POLYAREA *
 biggest (POLYAREA * p)
@@ -228,6 +248,8 @@ ClipOriginal (PolygonType * poly)
       fprintf (stderr, "Error while clipping PBO_ISECT: %d\n", r);
       poly_Free (&result);
       poly->Clipped = NULL;
+      if (poly->NoHoles) printf ("Just leaked in ClipOriginal\n");
+      poly->NoHoles = NULL;
       return 0;
     }
   poly->Clipped = biggest (result);
@@ -632,6 +654,8 @@ Subtract (POLYAREA * np1, PolygonType * p, Boolean fnp)
       fprintf (stderr, "Error while clipping PBO_SUB: %d\n", x);
       poly_Free (&merged);
       p->Clipped = NULL;
+      if (p->NoHoles) printf ("Just leaked in Subtract\n");
+      p->NoHoles = NULL;
       return -1;
     }
   p->Clipped = biggest (merged);
@@ -909,6 +933,7 @@ clearPoly (DataTypePtr Data, LayerTypePtr Layer, PolygonType * polygon,
       if (info.solder || group == Group (Data, max_layer + COMPONENT_LAYER))
 	r += r_search (Data->pad_tree, &region, NULL, pad_sub_callback, &info);
     }
+  polygon->NoHolesValid = 0;
   return r;
 }
 
@@ -925,6 +950,8 @@ Unsubtract (POLYAREA * np1, PolygonType * p)
       fprintf (stderr, "Error while clipping PBO_UNITE: %d\n", x);
       poly_Free (&merged);
       p->Clipped = NULL;
+      if (p->NoHoles) printf ("Just leaked in Unsubtract\n");
+      p->NoHoles = NULL;
       return 0;
     }
   p->Clipped = biggest (merged);
@@ -1031,11 +1058,14 @@ InitClip (DataTypePtr Data, LayerTypePtr layer, PolygonType * p)
   if (p->Clipped)
     poly_Free (&p->Clipped);
   p->Clipped = original_poly (p);
+  poly_FreeContours (&p->NoHoles);
   if (!p->Clipped)
     return 0;
   assert (poly_Valid (p->Clipped));
   if (TEST_FLAG (CLEARPOLYFLAG, p))
     clearPoly (Data, layer, p, NULL, 0);
+  else
+    p->NoHolesValid = 0;
   return 1;
 }
 
@@ -1289,18 +1319,23 @@ subtract_plow (DataTypePtr Data, LayerTypePtr Layer, PolygonTypePtr Polygon,
     case PIN_TYPE:
     case VIA_TYPE:
       SubtractPin (Data, (PinTypePtr) ptr2, Layer, Polygon);
+      Polygon->NoHolesValid = 0;
       return 1;
     case LINE_TYPE:
       SubtractLine ((LineTypePtr) ptr2, Polygon);
+      Polygon->NoHolesValid = 0;
       return 1;
     case ARC_TYPE:
       SubtractArc ((ArcTypePtr) ptr2, Polygon);
+      Polygon->NoHolesValid = 0;
       return 1;
     case PAD_TYPE:
       SubtractPad ((PadTypePtr) ptr2, Polygon);
+      Polygon->NoHolesValid = 0;
       return 1;
     case TEXT_TYPE:
       SubtractText ((TextTypePtr) ptr2, Polygon);
+      Polygon->NoHolesValid = 0;
       return 1;
     }
   return 0;
@@ -1621,6 +1656,8 @@ MorphPolygon (LayerTypePtr layer, PolygonTypePtr poly)
    * we do this dirty work.
    */
   poly->Clipped = NULL;
+  if (poly->NoHoles) printf ("Just leaked in MorpyPolygon\n");
+  poly->NoHoles = NULL;
   flags = poly->Flags;
   RemovePolygon (layer, poly);
   inhibit = True;
diff --git a/src/polygon.h b/src/polygon.h
index 1ec0a04..2faaa20 100644
--- a/src/polygon.h
+++ b/src/polygon.h
@@ -44,6 +44,7 @@ int PolygonHoles (PolygonType *ptr, const BoxType *range,
                   void *user_data);
 int PlowsPolygon (DataType *, int, void *, void *,
 		  int (*callback) (DataTypePtr, LayerTypePtr, PolygonTypePtr, int, void *, void *));
+void ComputeNoHoles (PolygonType *poly);
 POLYAREA * ContourToPoly (PLINE *);
 POLYAREA * RectPoly (LocationType x1, LocationType x2, LocationType y1, LocationType y2);
 POLYAREA * CirclePoly(LocationType x, LocationType y, BDimension radius);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs