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

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



The branch, master has been updated
       via  b7c1421f3675559c3c70d9a754b534a127b9d17f (commit)
      from  474ae8d2851fb56fd1ee555f6f96dc38a0912c4c (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/Makefile.am           |   10 --
 src/gts/gts.h             |    6 +
 src/gts/predicates.c      |   48 +++++++-
 src/gts/predicates_init.c |  108 ----------------
 src/toporouter.c          |  312 ++++++++++++++++++++++++---------------------
 src/toporouter.h          |    2 +
 6 files changed, 223 insertions(+), 263 deletions(-)
 delete mode 100644 src/gts/predicates_init.c


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

commit b7c1421f3675559c3c70d9a754b534a127b9d17f
Author: anthonix <anthonix@anthonix-desktop.(none)>
Commit: anthonix <anthonix@anthonix-desktop.(none)>

    Toporouter: Dynamic computation of GTS predicates

:100644 100644 1d5e818... 1c97b60... M	src/Makefile.am
:100644 100644 ad4f0d5... 99a92b7... M	src/gts/gts.h
:100644 100644 3c850a8... 7b7fcf2... M	src/gts/predicates.c
:100644 000000 5d8cfb7... 0000000... D	src/gts/predicates_init.c
:100644 100644 a2b385e... 2511e91... M	src/toporouter.c
:100644 100644 2979d84... 21f403a... M	src/toporouter.h

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

commit b7c1421f3675559c3c70d9a754b534a127b9d17f
Author: anthonix <anthonix@anthonix-desktop.(none)>
Commit: anthonix <anthonix@anthonix-desktop.(none)>

    Toporouter: Dynamic computation of GTS predicates

diff --git a/src/Makefile.am b/src/Makefile.am
index 1d5e818..1c97b60 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -175,11 +175,9 @@ pcb_DEPENDENCIES = @HIDLIBS@
 
 if WITH_TOPOROUTER
 PCB_SRCS += toporouter.c toporouter.h
-noinst_PROGRAMS = predicates_init
 noinst_LIBRARIES += libgts.a
 pcb_LDADD += libgts.a
 pcb_DEPENDENCIES += libgts.a
-BUILT_SOURCES += gts/predicates_init.h
 endif
 
 pcb_SOURCES = ${PCB_SRCS} core_lists.h
@@ -319,11 +317,6 @@ hid/lesstif/lesstif_lists.h : ${LIBLESSTIF_SRCS} Makefile
 	(for f in ${LIBLESSTIF_SRCS} ; do cat $(srcdir)/$$f ; done) | grep "^REGISTER" > $@.tmp
 	mv $@.tmp $@
 
-predicates_init_SOURCES = gts/predicates_init.c gts/rounding.h
-
-gts/predicates_init.h: predicates_init
-	./predicates_init >  gts/predicates_init.h
-
 libgts_a_CPPFLAGS = -I./gts
 LIBGTS_SRCS = \
 	gts/object.c \
@@ -365,8 +358,6 @@ LIBGTS_SRCS = \
 	gts/curvature.c \
 	gts/tribox3.c
 libgts_a_SOURCES = ${LIBGTS_SRCS} gts/gts_lists.h
-libgts_a_DEPENDENCIES = gts/predicates_init.h
-
  
 gts/gts_lists.h : ${LIBGTS_SRCS} Makefile
 	true > $@
@@ -446,7 +437,6 @@ DISTCLEANFILES= pcbtest.sh gpcb-menu.h pcb-menu.h \
 	hid/png/png_lists.h \
 	hid/nelma/nelma_lists.h \
 	hid/ps/ps_lists.h \
-	gts/predicates_init.h \
 	gts/gts_lists.h \
 	core_lists.h \
 	dbus-introspect.h
diff --git a/src/gts/gts.h b/src/gts/gts.h
index ad4f0d5..99a92b7 100644
--- a/src/gts/gts.h
+++ b/src/gts/gts.h
@@ -61,6 +61,12 @@ GTS_C_VAR const guint gts_binary_age;
 #define GTS_COMMENTS  "#!"
 #define GTS_MAINTAINER "popinet@xxxxxxxxxxxxxxxxxxxxx"
 
+
+
+
+void gts_predicates_init();
+
+
 /* Class declarations for base types */
 
 typedef struct _GtsObjectClassInfo     GtsObjectClassInfo;
diff --git a/src/gts/predicates.c b/src/gts/predicates.c
index 3c850a8..7b7fcf2 100644
--- a/src/gts/predicates.c
+++ b/src/gts/predicates.c
@@ -119,7 +119,7 @@
 #include "predicates.h"
 
 /* Use header file generated automatically by predicates_init. */
-#define USE_PREDICATES_INIT
+//#define USE_PREDICATES_INIT
 
 #ifdef USE_PREDICATES_INIT
 #include "predicates_init.h"
@@ -378,6 +378,52 @@ static REAL o3derrboundA, o3derrboundB, o3derrboundC;
 static REAL iccerrboundA, iccerrboundB, iccerrboundC;
 static REAL isperrboundA, isperrboundB, isperrboundC;
 
+void 
+gts_predicates_init()
+{
+  double half = 0.5;
+  double check = 1.0, lastcheck;
+  int every_other = 1;
+  /* epsilon = 2^(-p).  Used to estimate roundoff errors. */
+  double epsilon = 1.0;   
+
+  FPU_ROUND_DOUBLE;
+
+  splitter = 1.;
+
+  /* Repeatedly divide `epsilon' by two until it is too small to add to   */
+  /* one without causing roundoff.  (Also check if the sum is equal to    */
+  /* the previous sum, for machines that round up instead of using exact  */
+  /* rounding.  Not that this library will work on such machines anyway). */
+  do {
+    lastcheck = check;
+    epsilon *= half;
+    if (every_other) {
+      splitter *= 2.0;
+    }
+    every_other = !every_other;
+    check = 1.0 + epsilon;
+  } while ((check != 1.0) && (check != lastcheck));
+  splitter += 1.0;
+  /* Error bounds for orientation and incircle tests. */
+  resulterrbound = (3.0 + 8.0 * epsilon) * epsilon;
+  ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon;
+  ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon;
+  ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon;
+  o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon;
+  o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon;
+  o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon;
+  iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon;
+  iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon;
+  iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon;
+  isperrboundA = (16.0 + 224.0 * epsilon) * epsilon;
+  isperrboundB = (5.0 + 72.0 * epsilon) * epsilon;
+  isperrboundC = (71.0 + 1408.0 * epsilon) * epsilon * epsilon;
+
+
+  FPU_RESTORE;
+}
+
 #endif /* USE_PREDICATES_INIT */
 
 /*****************************************************************************/
diff --git a/src/gts/predicates_init.c b/src/gts/predicates_init.c
deleted file mode 100644
index 5d8cfb7..0000000
--- a/src/gts/predicates_init.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/* GTS - Library for the manipulation of triangulated surfaces
- * Copyright (C) 1999 Stéphane Popinet
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* This program creates a header file defining the various constants needed by
- * predicates.c. These constant are machine dependent.
- * adapted from predicates.c by Jonathan Richard Shewchuk
- */
-
-#include <stdio.h>
-
-/* FPU control. We MUST have only double precision (not extended precision) */
-#include "rounding.h"
-
-int main (int argc, char * argv[])
-{
-  double half = 0.5;
-  double check = 1.0, lastcheck;
-  int every_other = 1;
-  /* epsilon = 2^(-p).  Used to estimate roundoff errors. */
-  double epsilon = 1.0;   
-  /* splitter = 2^ceiling(p / 2) + 1.  Used to split floats in half. */
-  double splitter = 1.0;
-  /* A set of coefficients used to calculate maximum roundoff errors. */
-  double resulterrbound;
-  double ccwerrboundA, ccwerrboundB, ccwerrboundC;
-  double o3derrboundA, o3derrboundB, o3derrboundC;
-  double iccerrboundA, iccerrboundB, iccerrboundC;
-  double isperrboundA, isperrboundB, isperrboundC;
-
-  FPU_ROUND_DOUBLE;
-
-  epsilon = 1.0;
-  splitter = 1.0;
-  /* Repeatedly divide `epsilon' by two until it is too small to add to   */
-  /* one without causing roundoff.  (Also check if the sum is equal to    */
-  /* the previous sum, for machines that round up instead of using exact  */
-  /* rounding.  Not that this library will work on such machines anyway). */
-  do {
-    lastcheck = check;
-    epsilon *= half;
-    if (every_other) {
-      splitter *= 2.0;
-    }
-    every_other = !every_other;
-    check = 1.0 + epsilon;
-  } while ((check != 1.0) && (check != lastcheck));
-  splitter += 1.0;
-  /* Error bounds for orientation and incircle tests. */
-  resulterrbound = (3.0 + 8.0 * epsilon) * epsilon;
-  ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon;
-  ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon;
-  ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon;
-  o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon;
-  o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon;
-  o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon;
-  iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon;
-  iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon;
-  iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon;
-  isperrboundA = (16.0 + 224.0 * epsilon) * epsilon;
-  isperrboundB = (5.0 + 72.0 * epsilon) * epsilon;
-  isperrboundC = (71.0 + 1408.0 * epsilon) * epsilon * epsilon;
-
-  puts ("/* This file was generated automatically by predicates_init\n"
-	" *\n"
-	" * This file is free software; you can redistribute it and/or\n"
-	" * modify it under the terms of the GNU Library General Public\n"
-	" * License as published by the Free Software Foundation; either\n"
-	" * version 2 of the License, or (at your option) any later version.\n"
-	" *\n"
-	" * This file is distributed in the hope that it will be useful,\n"
-	" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-	" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
-	" */\n");
-  printf ("static double splitter = %f;\n", splitter);
-  printf ("static double resulterrbound = %.16g;\n", resulterrbound);
-  printf ("static double ccwerrboundA = %.16g;\n", ccwerrboundA);
-  printf ("static double ccwerrboundB = %.16g;\n", ccwerrboundB);
-  printf ("static double ccwerrboundC = %.16g;\n", ccwerrboundC);
-  printf ("static double o3derrboundA = %.16g;\n", o3derrboundA);
-  printf ("static double o3derrboundB = %.16g;\n", o3derrboundB);
-  printf ("static double o3derrboundC = %.16g;\n", o3derrboundC);
-  printf ("static double iccerrboundA = %.16g;\n", iccerrboundA);
-  printf ("static double iccerrboundB = %.16g;\n", iccerrboundB);
-  printf ("static double iccerrboundC = %.16g;\n", iccerrboundC);
-  printf ("static double isperrboundA = %.16g;\n", isperrboundA);
-  printf ("static double isperrboundB = %.16g;\n", isperrboundB);
-  printf ("static double isperrboundC = %.16g;\n", isperrboundC);
-  
-  FPU_RESTORE;
-
-  return 0;
-}
diff --git a/src/toporouter.c b/src/toporouter.c
index a2b385e..2511e91 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -7247,7 +7247,8 @@ calculate_arc_to_arc(toporouter_t *ar, toporouter_arc_t *parc, toporouter_arc_t
     coords_on_line(bx, by, m, a, &a0x, &a0y, &a1x, &a1y);
 
     winddir = coord_wind(vx(smallr->centre), vy(smallr->centre), a0x, a0y, vx(bigr->centre), vy(bigr->centre));
-#ifdef DEBUG_EXPORT   
+//#ifdef DEBUG_EXPORT   
+  if(!winddir) {
     printf("TWIST:\n");
       printf("theta = %f a = %f b = %f r = %f d = %f po = %f\n", theta, a, b, bigr->r + smallr->r,
           gts_point_distance(GTS_POINT(bigr->centre), GTS_POINT(smallr->centre)),
@@ -7255,7 +7256,8 @@ calculate_arc_to_arc(toporouter_t *ar, toporouter_arc_t *parc, toporouter_arc_t
 
       printf("bigr centre = %f,%f smallr centre = %f,%f\n\n", vx(bigr->centre), vy(bigr->centre), 
           vx(smallr->centre), vy(smallr->centre));
-#endif      
+  }
+//#endif      
 /*    if(!winddir) {
       smallr->centre->flags |= VERTEX_FLAG_RED;
       bigr->centre->flags |= VERTEX_FLAG_GREEN;
@@ -7463,6 +7465,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
     toporouter_arc_t *arc = (toporouter_arc_t *)i->data;
 
     if(oproute->serp && g_list_find(oproute->serp->arcs, arc)) {
+      parc = arc;
       i = i->next;
       continue;
     }
@@ -7529,6 +7532,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: BS TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (STRAIGHT BS del:bigr winddir:bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, bigr);    
             }
           }
@@ -7545,6 +7549,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: BS TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (STRAIGHT BS del:bigr winddir:!bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, bigr);    
             }
           }
@@ -7569,6 +7574,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: SB TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif 
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (STRAIGHT SB del:smallr winddir:bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, smallr);    
             }
           }else{
@@ -7585,6 +7591,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: SB TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (STRAIGHT SB del:smallr winddir:!bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, smallr);    
             }
           }else{
@@ -7630,6 +7637,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: BS TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (TWIST BS del:bigr winddir:bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, bigr);    
             }
           }
@@ -7646,6 +7654,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
               printf("WARNING: BS TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (TWIST BS del:bigr winddir:!bigr->dir)\n");  
               remlist = g_slist_prepend(remlist, bigr);    
             }
           }
@@ -7672,10 +7681,11 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
             wind2 = coord_wind(vx(smallr->centre), vy(smallr->centre), a0x, a0y, vx(bigr->centre), vy(bigr->centre));
 
             if(wind1 != wind2) {
-#ifdef DEBUG_EXPORT          
-              printf("WARNING: SB TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
-#endif 
+//#ifdef DEBUG_EXPORT          
+              printf("WARNING: SB OVERSHOOT DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
+//#endif 
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
+              printf("overshoot check deleting arc (TWIST SB del:smallr winddir:smallr->dir)\n");  
               remlist = g_slist_prepend(remlist, smallr);   
             }
           }else{
@@ -7691,6 +7701,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
 #ifdef DEBUG_EXPORT          
               printf("WARNING: SB TWIST DETECTED %f,%f %f,%f\n", vx(bigr->centre), vy(bigr->centre), vx(smallr->centre), vy(smallr->centre));
 #endif
+              printf("overshoot check deleting arc (TWIST SB del:smallr winddir:!smallr->dir)\n");  
 //              if(smallr->centre->flags & VERTEX_FLAG_FAKE) fliplist = g_slist_prepend(fliplist, smallr);
               remlist = g_slist_prepend(remlist, smallr);    
             }
@@ -7713,7 +7724,7 @@ fix_overshoot_oproute_arcs(toporouter_oproute_t *oproute)
   while(j) {
     toporouter_arc_t *arc = TOPOROUTER_ARC(j->data);
 
-    printf("overshoot check deleting arc %f,%f\n", vx(arc->centre), vy(arc->centre));  
+//    printf("overshoot check deleting arc %f,%f\n", vx(arc->centre), vy(arc->centre));  
     toporouter_arc_remove(oproute, arc);
 
     j = j->next;
@@ -8904,6 +8915,98 @@ arc_import_clearance(toporouter_arc_t *arc, GList **clearancelist, gdouble x0, g
 */
 }
 
+gint
+oproute_arc_to_oproute_wind(toporouter_arc_t *arc, toporouter_oproute_t *adj)
+{
+  toporouter_oproute_t *oproute = arc->oproute;
+  toporouter_vertex_t *closestadjv = NULL, *closestpathv = NULL;
+  gint wind;
+  GSList *i = oproute->path;
+  gdouble closestd = 0.;
+
+  while(i) {
+    toporouter_vertex_t *pathv = TOPOROUTER_VERTEX(i->data);
+    GList *edgerouting = pathv->routingedge ? g_list_find(edge_routing(pathv->routingedge), pathv) : NULL;
+    gdouble tempd = gts_point_distance2(GTS_POINT(arc->centre), GTS_POINT(pathv));
+    
+    if(edgerouting && edgerouting->next && TOPOROUTER_VERTEX(edgerouting->next->data)->oproute == adj) {
+      if(!closestadjv || tempd < closestd) {
+        closestd = tempd;
+        closestadjv = TOPOROUTER_VERTEX(edgerouting->next->data);
+        closestpathv = pathv;
+      }
+    }else if(edgerouting && edgerouting->prev && TOPOROUTER_VERTEX(edgerouting->prev->data)->oproute == adj) {
+      if(!closestadjv || tempd < closestd) {
+        closestd = tempd;
+        closestadjv = TOPOROUTER_VERTEX(edgerouting->prev->data);
+        closestpathv = pathv;
+      }
+    }
+
+    i = i->next;
+  }
+
+  g_assert(closestadjv);
+
+  if(closestpathv->child) {
+    wind = vertex_wind(GTS_VERTEX(closestpathv), GTS_VERTEX(closestpathv->child), GTS_VERTEX(closestadjv));
+  }else{
+    g_assert(closestpathv->parent);
+    wind = vertex_wind(GTS_VERTEX(closestpathv->parent), GTS_VERTEX(closestpathv), GTS_VERTEX(closestadjv));
+  }
+/* 
+  printf("\t\tORIENTATION of %s relative to arc %f,%f of %s = %d (arcwind = %d)\n", adj->netlist, vx(arc->centre), vy(arc->centre),
+      oproute->netlist, wind, arc->dir);
+
+  printf("\t\tclosestpathv = %f,%f closestadjv = %f,%f\n", 
+      vx(closestpathv), vy(closestpathv), vx(closestadjv), vy(closestadjv));
+*/
+  return wind;
+}
+
+gint
+oproute_to_oproute_arc_wind(toporouter_oproute_t *oproute, toporouter_arc_t *arc)
+{
+  toporouter_oproute_t *adj = arc->oproute;
+  toporouter_vertex_t *closestadjv = NULL, *closestpathv = NULL;
+  gint wind;
+  GSList *i = oproute->path;
+  gdouble closestd = 0.;
+
+  while(i) {
+    toporouter_vertex_t *pathv = TOPOROUTER_VERTEX(i->data);
+    GList *edgerouting = pathv->routingedge ? g_list_find(edge_routing(pathv->routingedge), pathv) : NULL;
+    gdouble tempd = gts_point_distance2(GTS_POINT(arc->centre), GTS_POINT(pathv));
+    
+    if(edgerouting && edgerouting->next && TOPOROUTER_VERTEX(edgerouting->next->data)->oproute == adj) {
+      if(!closestadjv || tempd < closestd) {
+        closestd = tempd;
+        closestadjv = TOPOROUTER_VERTEX(edgerouting->next->data);
+        closestpathv = pathv;
+      }
+    }else if(edgerouting && edgerouting->prev && TOPOROUTER_VERTEX(edgerouting->prev->data)->oproute == adj) {
+      if(!closestadjv || tempd < closestd) {
+        closestd = tempd;
+        closestadjv = TOPOROUTER_VERTEX(edgerouting->prev->data);
+        closestpathv = pathv;
+      }
+    }
+
+    i = i->next;
+  }
+
+  g_assert(closestadjv);
+
+  if(closestpathv->child) {
+    wind = vertex_wind(GTS_VERTEX(closestpathv), GTS_VERTEX(closestpathv->child), GTS_VERTEX(closestadjv));
+  }else{
+    g_assert(closestpathv->parent);
+    wind = vertex_wind(GTS_VERTEX(closestpathv->parent), GTS_VERTEX(closestpathv), GTS_VERTEX(closestadjv));
+  }
+  
+  return wind;
+}
+
 toporouter_arc_t *
 oproute_insert_arc(toporouter_oproute_t *oproute, guint arcn, toporouter_arc_t *arc, gdouble x0, gdouble y0, gdouble x1, gdouble y1,
     gdouble line_int_x, gdouble line_int_y, gdouble ms)
@@ -8925,41 +9028,61 @@ oproute_insert_arc(toporouter_oproute_t *oproute, guint arcn, toporouter_arc_t *
 
   g_assert(vx(arc->centre) != line_int_x && vy(arc->centre) != line_int_y);
   coord_move_towards_coord_values(vx(arc->centre), vy(arc->centre), line_int_x, line_int_y, ms, &properx, &propery);
-  dir = coord_wind(x0, y0, properx, propery, x1, y1);
+//  dir = coord_wind(x0, y0, properx, propery, x1, y1);
+  dir = oproute_to_oproute_arc_wind(oproute, arc);
 
   newarc = toporouter_arc_new(oproute, NULL, arc->centre, ms, dir);
   
   oproute->arcs = g_list_insert(oproute->arcs, newarc, arcn);
-  printf("\tinserting arc centre %f,%f radius %f\n", vx(arc->centre), vy(arc->centre), ms);
+  printf("\tinserting arc centre %f,%f radius %f at arcn %d\n", vx(arc->centre), vy(arc->centre), ms, arcn);
   return newarc;
 }
 
+
 void
 adjseg_check_clearance(toporouter_t *r, GSList **ignore, GList **clearancelist, guint *arcn, gdouble x0, gdouble y0, gdouble x1, gdouble y1, toporouter_oproute_t *oproute,
     toporouter_oproute_t *adj)
 {
   GList *arcs = oproute->arcs;
+  GList *insertlist = NULL;
   guint recalculate = 0;
+  gdouble linedata[4] = {x0, y0, x1, y1};
 
   printf("checking lines of %s against arcs of %s\n", adj->netlist, oproute->netlist);
-
+  
+  arcs = oproute->arcs;
   while(arcs) {
     toporouter_arc_t *arc = TOPOROUTER_ARC(arcs->data);
     gdouble line_int_x, line_int_y;
-    
+   
+    if(oproute_arc_to_oproute_wind(arc, adj) == arc->dir) {
+      arcs = arcs->next;
+      continue;
+    }
+
     if(!path_adjacent_to_vertex(adj->path, arc->centre))
       if(vertex_line_normal_intersection(x0, y0, x1, y1, vx(arc->centre), vy(arc->centre), &line_int_x, &line_int_y)) {
         gdouble ms = oproute_min_spacing(adj, oproute) + arc->r;
         gdouble d = sqrt(pow(line_int_x-vx(arc->centre),2)+pow(line_int_y-vy(arc->centre),2));
-
+        
+        
         if(d < ms) {
-          toporouter_arc_t *newarc;
-          printf("\tfailure with arc->centre %f,%f and line %f,%f %f,%f\n", vx(arc->centre), vy(arc->centre), x0, y0, x1, y1);
-
-          newarc = oproute_insert_arc(adj, (*arcn)++, arc, x0, y0, x1, y1, line_int_x, line_int_y, ms);
-          if(newarc) arc_import_clearance(newarc, clearancelist, vx(newarc->centre), vy(newarc->centre), x1, y1);
+          toporouter_clearance_t *c = toporouter_clearance_new(arc, x0, y0, x1, y1, NULL);
+          c->line_int_x = line_int_x;
+          c->line_int_y = line_int_y;
+          c->ms = ms;
 
+          printf("\tfailure with arc->centre %f,%f and line %f,%f %f,%f\n", vx(arc->centre), vy(arc->centre), x0, y0, x1, y1);
+          
+          insertlist = g_list_insert_sorted_with_data(insertlist, c, clearance_list_compare, &linedata);
+/*
+          newarc = oproute_insert_arc(adj, *arcn, arc, x0, y0, x1, y1, line_int_x, line_int_y, ms);
+          if(newarc) {
+            arc_import_clearance(newarc, clearancelist, vx(newarc->centre), vy(newarc->centre), x1, y1);
+            (*arcn)++;
+          }
           recalculate = 1;
+*/          
         }
 
       }
@@ -8967,19 +9090,39 @@ adjseg_check_clearance(toporouter_t *r, GSList **ignore, GList **clearancelist,
     arcs = arcs->next;
   }
 
+  arcs = insertlist;
+  while(arcs) {
+    toporouter_clearance_t *c = TOPOROUTER_CLEARANCE(arcs->data);
+    toporouter_arc_t *arc = TOPOROUTER_ARC(c->data), *newarc;
+
+    newarc = oproute_insert_arc(adj, *arcn, arc, x0, y0, x1, y1, c->line_int_x, c->line_int_y, c->ms);
+
+    if(newarc) {
+      arc_import_clearance(newarc, clearancelist, vx(newarc->centre), vy(newarc->centre), x1, y1);
+      (*arcn)++;
+    }
+    recalculate = 1;
+
+    free(c);
+
+    arcs = arcs->next;
+  }
+
   if(recalculate) {
     GSList *tempignore = ignore ? g_slist_copy(*ignore) : NULL;
-
+///*
     fix_colinear_oproute_arcs(adj);
     calculate_oproute(r, adj);
     fix_overshoot_oproute_arcs(adj);
     calculate_oproute(r, adj);
-
+//*/
     tempignore = g_slist_prepend(tempignore, oproute);
     oproute_foreach_adjseg(r, adj, adjseg_check_clearance, &tempignore);
     g_slist_free(tempignore);
   }
 
+  g_list_free(insertlist);
+
 }
 
 
@@ -9276,129 +9419,6 @@ oproute_check_adj_serpintine_arcs(toporouter_oproute_t *oproute, toporouter_opro
 }
 
 void
-oproute_check_adjs(toporouter_t *r, toporouter_oproute_t *oproute, toporouter_oproute_t *dontcheck)
-{
-  GSList *i = oproute->adj;
-
-  printf("checking oproute %s..\n", oproute->netlist);
-  while(i) {
-    toporouter_oproute_t *adj = TOPOROUTER_OPROUTE(i->data);
-    gdouble px = vx(adj->term1), py = vy(adj->term1);
-    GList *adjarcs = adj->arcs, *arcs;
-    toporouter_vertex_t *pv;
-    guint arcn = 0;
-    guint recalculate = 0;
-    
-    if(adj == dontcheck) {
-      i = i->next;
-      continue;
-    }
-
-    //oproute_check_adj_serpintine_arcs(oproute, adj);
-//    oproute_foreach_adjseg(oproute, adjseg_check_serp_clearances);
-    
-//    printf("\tchecking adj oproute %s..\n", adj->netlist);
-//    print_oproute(adj);
-
-    while(adjarcs) {
-      toporouter_arc_t *adjarc = TOPOROUTER_ARC(adjarcs->data);
-      
-      pv = oproute->term1;
-      arcs = oproute->arcs;
-      while(arcs) {
-        toporouter_arc_t *arc = TOPOROUTER_ARC(arcs->data);
-        gdouble line_int_x, line_int_y;
-//        toporouter_vertex_t *nv = arcs->next ? TOPOROUTER_ARC(arcs->next->data)->centre : oproute->term2;
-/*
-        if((vx(arc->centre) == px && vy(arc->centre) == py) || (vx(arc->centre) == adjarc->x0 && vy(arc->centre) == adjarc->y0)) {
-          pv = arc->centre;
-          arcs = arcs->next;
-          continue;
-        }
-        
-        if(arc->centre == adjarc->centre) {
-          pv = arc->centre;
-          arcs = arcs->next;
-          continue;
-        }
-*/
-        if(!path_adjacent_to_vertex(adj->path, arc->centre))
-        if(vertex_line_normal_intersection(px, py, adjarc->x0, adjarc->y0, vx(arc->centre), vy(arc->centre), &line_int_x, &line_int_y)) {
-//          if(vertex_wind(GTS_VERTEX(pv), GTS_VERTEX(nv), GTS_VERTEX(arc->centre)) == coord_wind(vx(pv), vy(pv), vx(nv), vy(nv), line_int_x, line_int_y)) {
-            gdouble ms = oproute_min_spacing(adj, oproute) + arc->r;
-            gdouble d = sqrt(pow(line_int_x-vx(arc->centre),2)+pow(line_int_y-vy(arc->centre),2));
-
-            if(d < ms) {
-              printf("\tfailure with arc->centre %f,%f and line %f,%f %f,%f\n",
-                  vx(arc->centre), vy(arc->centre), px, py, adjarc->x0, adjarc->y0);
-
-              oproute_insert_arc(adj, arcn++, arc, px, py, adjarc->x0, adjarc->y0, line_int_x, line_int_y, ms);
-              recalculate = 1;
-//            }
-          }
-              
-        }
-
-        pv = arc->centre;
-        arcs = arcs->next;
-      }
-
-      arcn++;
-
-      px = adjarc->x1;
-      py = adjarc->y1;
-
-      adjarcs = adjarcs->next;
-    }
-   
-    pv = oproute->term1;
-    arcs = oproute->arcs;
-    while(arcs) {
-      toporouter_arc_t *arc = TOPOROUTER_ARC(arcs->data);
-      gdouble line_int_x, line_int_y;
-//      toporouter_vertex_t *nv = arcs->next ? TOPOROUTER_ARC(arcs->next->data)->centre : oproute->term2;
-/*      
-      if((vx(arc->centre) == px && vy(arc->centre) == py) || (vx(arc->centre) == vx(adj->term2) && vy(arc->centre) == vy(adj->term2))) {
-        pv = arc->centre;
-        arcs = arcs->next;
-        continue;
-      }
-*/
-      if(!path_adjacent_to_vertex(adj->path, arc->centre))
-      if(vertex_line_normal_intersection(px, py, vx(adj->term2), vy(adj->term2), vx(arc->centre), vy(arc->centre), &line_int_x, &line_int_y)) {
-//        if(vertex_wind(GTS_VERTEX(pv), GTS_VERTEX(nv), GTS_VERTEX(arc->centre)) == coord_wind(vx(pv), vy(pv), vx(nv), vy(nv), line_int_x, line_int_y)) {
-          gdouble ms = oproute_min_spacing(adj, oproute) + arc->r;
-          gdouble d = sqrt(pow(line_int_x-vx(arc->centre),2)+pow(line_int_y-vy(arc->centre),2));
-          if(d < ms) {
-            printf("\t\tfailure with arc->centre %f,%f and line %f,%f %f,%f\n",
-                vx(arc->centre), vy(arc->centre), px, py, vx(adj->term2), vy(adj->term2));
-            oproute_insert_arc(adj, arcn++, arc, px, py, vx(adj->term2), vy(adj->term2), line_int_x, line_int_y, ms);
-            recalculate = 1;
-//          }
-        }
-
-      }
-
-      pv = arc->centre;
-
-      arcs = arcs->next;
-    }
- 
-    if(recalculate) {
-      fix_colinear_oproute_arcs(adj);
-      calculate_oproute(r, adj);
-      fix_overshoot_oproute_arcs(adj);
-      calculate_oproute(r, adj);
-      //oproute_check_adjs(r, adj, oproute);
-    }
-
-    i = i->next;
-  }
-
-
-}
-
-void
 oproutes_tof_match(toporouter_t *r, GSList *oproutes)
 {
   guint n = g_slist_length(oproutes);
@@ -9538,7 +9558,7 @@ export_oproute_check:
   }
 //*/  
 
-//  oproutes_tof_match(r, oproutes);
+  if(r->flags & TOPOROUTER_FLAG_MATCH) oproutes_tof_match(r, oproutes);
   
 //export_oproute_finish:
   i = oproutes;
@@ -10303,6 +10323,8 @@ parse_arguments(toporouter_t *r, int argc, char **argv)
       r->flags |= TOPOROUTER_FLAG_HARDSRC;
     }else if(!strcmp(argv[i], "harddest")) {
       r->flags |= TOPOROUTER_FLAG_HARDDEST;
+    }else if(!strcmp(argv[i], "match")) {
+      r->flags |= TOPOROUTER_FLAG_MATCH;
     }else if(sscanf(argv[i], "h%d", &tempint)) {
       r->router = hard_router;
       r->effort = tempint;
@@ -10364,6 +10386,8 @@ toporouter_new()
 
   ltime=time(NULL); 
 
+  gts_predicates_init();
+
   printf("Topological Autorouter - Copyright 2009 Anthony Blake (amb33@xxxxxxxxxxxxxxxx)\n");
   printf("Started %s\n",asctime( localtime(&ltime) ) );  
   
@@ -10441,7 +10465,7 @@ toporouter (int argc, char **argv, int x, int y)
 */
   spring_embedder(r);
   create_pad_points(r);
-/*
+///*
   {
     int i;
     for(i=0;i<groupcount();i++) {
@@ -10450,7 +10474,7 @@ toporouter (int argc, char **argv, int x, int y)
       toporouter_draw_surface(r, r->layers[i].surface, buffer, 2048, 2048, 2, NULL, i, NULL);
     }
   }
-*/ 
+//*/ 
   toporouter_export(r);
 
 /*
diff --git a/src/toporouter.h b/src/toporouter.h
index 2979d84..21f403a 100644
--- a/src/toporouter.h
+++ b/src/toporouter.h
@@ -57,6 +57,7 @@
 #define TOPOROUTER_FLAG_VERBOSE     (1<<0)
 #define TOPOROUTER_FLAG_HARDDEST    (1<<1)
 #define TOPOROUTER_FLAG_HARDSRC     (1<<2)
+#define TOPOROUTER_FLAG_MATCH       (1<<3)
 
 #if TOPO_OUTPUT_ENABLED
   #include <cairo.h>
@@ -297,6 +298,7 @@ typedef struct {
 struct _toporouter_clearance_t {
   gpointer data;
   gint wind;
+  gdouble line_int_x, line_int_y, ms;
 };
 
 typedef struct _toporouter_clearance_t toporouter_clearance_t;



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