]> granicus.if.org Git - poly2tri-c/commitdiff
Configure usage of debugging functions and symbols in the configure script
authorBarak Itkin <lightningismyname@gmail.com>
Sat, 7 Jul 2012 08:37:22 +0000 (11:37 +0300)
committerBarak Itkin <lightningismyname@gmail.com>
Sat, 7 Jul 2012 08:37:22 +0000 (11:37 +0300)
This commit drops by default the option to validate properties of the CDT
during the refinement process, and *increases the speed in orders of
magnitude* for complex inputs

configure.ac
poly2tri-c/refine/cdt.c
poly2tri-c/refine/cdt.h
poly2tri-c/refine/delaunay-terminator.c

index e975dace576cc766758700cf6d931aa41f4c13e2..9232aa75fee260c8c4c6cfebcf70633c6bed9544 100644 (file)
@@ -31,7 +31,7 @@ m4_define([lt_revision], [0])
 m4_define([lt_age], [0])
 
 # Declare the package details
-AC_INIT([poly2tri-c], p2tc_real_version, [lightningismyname@gmail.com])
+AC_INIT([poly2tri-c],[p2tc_real_version],[lightningismyname@gmail.com])
 
 P2TC_MAJOR_VERSION=p2tc_major_version
 P2TC_MINOR_VERSION=p2tc_minor_version
@@ -103,6 +103,39 @@ CFLAGS="$CFLAGS $GLIB_CFLAGS"
 LDFLAGS="$LDFLAGS $GLIB_LIBS"
 LIBS="$LIBS $GLIB_LIBS"
 
+# Allow building with debugging symbols
+AC_MSG_CHECKING([whether to turn on debugging])
+AC_ARG_ENABLE(debug,
+              AS_HELP_STRING([--enable-debug],[turn on debugging (default=no)]),
+              if eval "test x$enable_debug = xyes"; then
+                DEBUGFLAG="-g"
+              fi)
+
+if test -n "$DEBUGFLAG"; then
+  AC_MSG_RESULT([yes])
+  CFLAGS="$DEBUGFLAG $CFLAGS"
+else
+  AC_MSG_RESULT([no])
+fi
+
+# Allow forcing a validation of the CDT after each refinement step
+AC_MSG_CHECKING([whether to enable CDT validation during refinement])
+AC_ARG_ENABLE(cdt-validation,
+              AS_HELP_STRING([--enable-cdt-validation],[turn on CDT validation during refinement (WARNING: SLOW!, default=no)]),
+              if eval "test x$enable_cdt_validation = xyes"; then
+                P2TR_ENABLE_CDT_VALIDATION="TRUE"
+              fi)
+
+if test -n "$P2TR_ENABLE_CDT_VALIDATION"; then
+  CDTVFLAG="-DP2TR_CDT_VALIDATE=TRUE"
+  AC_MSG_RESULT([yes])
+else
+  CDTVFLAG="-DP2TR_CDT_VALIDATE=FALSE"
+  AC_MSG_RESULT([no])
+fi
+
+CFLAGS="$CDTVFLAG $CFLAGS"
+
 # Output this configuration header file
 AC_CONFIG_HEADERS([config.h])
 
index 87fda44b2e1a234886de5ce0d64e605684d62339..34e3a384025c35250e6e904a82b2949fbcfca73e 100644 (file)
@@ -295,7 +295,7 @@ p2tr_cdt_insert_point (P2trCDT           *self,
   gboolean      inserted = FALSE;
   gint          i;
 
-  p2tr_cdt_validate_unused (self);
+  P2TR_CDT_VALIDATE_UNUSED (self);
 
   if (point_location_guess == NULL)
     tri = p2tr_mesh_find_point (self->mesh, pc);
@@ -329,7 +329,7 @@ p2tr_cdt_insert_point (P2trCDT           *self,
   /* We no longer need the triangle */
   p2tr_triangle_unref (tri);
 
-  p2tr_cdt_validate_unused (self);
+  P2TR_CDT_VALIDATE_UNUSED (self);
   return pt;
 }
 
@@ -446,7 +446,7 @@ p2tr_cdt_split_edge (P2trCDT   *self,
   GList     *fan = NULL, *new_edges = NULL;
   P2trHashSet *fan_edges;
 
-  p2tr_cdt_validate_unused (self);
+  P2TR_CDT_VALIDATE_UNUSED (self);
 
   p2tr_edge_remove (e);
 
@@ -482,7 +482,7 @@ p2tr_cdt_split_edge (P2trCDT   *self,
       p2tr_edge_unref (CY);
     }
 
-  p2tr_cdt_validate_unused (self);
+  P2TR_CDT_VALIDATE_UNUSED (self);
 
   return new_edges;
 }
index 1c8b247796d91362d9fe73245785c1eff2248e0a..23455a66c59e68251e455a56fa879d8e35cc07d7 100644 (file)
@@ -43,8 +43,6 @@ typedef struct
   P2trPSLG *outline;
 } P2trCDT;
 
-void        p2tr_cdt_validate_unused (P2trCDT* self);
-
 /**
  * Create a new P2trCDT from an existing P2tCDT. The resulting P2trCDT
  * does not depend on the original P2tCDT which can be freed
@@ -72,6 +70,8 @@ gboolean    p2tr_cdt_visible_from_edge (P2trCDT     *self,
  */
 void        p2tr_cdt_validate_edges    (P2trCDT *self);
 
+void        p2tr_cdt_validate_unused   (P2trCDT* self);
+
 /**
  * Make sure the constrained empty circum-circle property holds,
  * meaning that each triangles circum-scribing circle is either empty
@@ -80,6 +80,16 @@ void        p2tr_cdt_validate_edges    (P2trCDT *self);
  */
 void        p2tr_cdt_validate_cdt      (P2trCDT *self);
 
+#if P2TR_CDT_VALIDATE
+#define P2TR_CDT_VALIDATE_EDGES(CDT)  p2tr_cdt_validate_edges(CDT)
+#define P2TR_CDT_VALIDATE_UNUSED(CDT) p2tr_cdt_validate_unused(CDT)
+#define P2TR_CDT_VALIDATE_CDT(CDT)    p2tr_cdt_validate_cdt(CDT)
+#else
+#define P2TR_CDT_VALIDATE_EDGES(CDT)  G_STMT_START { } G_STMT_END
+#define P2TR_CDT_VALIDATE_UNUSED(CDT) G_STMT_START { } G_STMT_END
+#define P2TR_CDT_VALIDATE_CDT(CDT)    G_STMT_START { } G_STMT_END
+#endif
+
 /**
  * Insert a point into the triangulation while preserving the
  * constrained delaunay property
index a60c6251f98ef4b261ebf015ca3e5e7d4347085b..5ed5fb21688eef87943b4688e51256a554089a7b 100644 (file)
@@ -260,7 +260,7 @@ p2tr_dt_refine (P2trDelaunayTerminator   *self,
   P2trVTriangle *vt;
   gint steps = 0;
 
-  p2tr_cdt_validate_cdt(self->mesh);
+  P2TR_CDT_VALIDATE_CDT (self->mesh);
 
   if (steps++ >= max_steps)
     return;
@@ -271,7 +271,7 @@ p2tr_dt_refine (P2trDelaunayTerminator   *self,
       p2tr_dt_enqueue_segment (self, s);
 
   SplitEncroachedSubsegments (self, 0, p2tr_refiner_false_too_big);
-  p2tr_cdt_validate_cdt(self->mesh);
+  P2TR_CDT_VALIDATE_CDT (self->mesh);
 
   p2tr_hash_set_iter_init (&hs_iter, self->mesh->mesh->triangles);
   while (p2tr_hash_set_iter_next (&hs_iter, (gpointer*)&t))
@@ -293,7 +293,7 @@ p2tr_dt_refine (P2trDelaunayTerminator   *self,
           P2trVEdgeSet *E;
           P2trPoint *cPoint;
 
-          p2tr_cdt_validate_cdt (self->mesh);
+          P2TR_CDT_VALIDATE_CDT (self->mesh);
           p2tr_triangle_get_circum_circle (t, &tCircum);
           c = &tCircum.center;