]> granicus.if.org Git - poly2tri-c/commitdiff
Multiple fixes to allow usage with other compilers master
authorBarak Itkin <lightningismyname@gmail.com>
Sat, 15 Nov 2014 15:03:10 +0000 (17:03 +0200)
committerBarak Itkin <lightningismyname@gmail.com>
Sat, 15 Nov 2014 15:03:10 +0000 (17:03 +0200)
1. Fix many signed/unsigned comparisons
2. Avoid having multiple C files with the same name
3. Add return statements after failing asserts, just to calm the compiler

21 files changed:
poly2tri-c/p2t/common/shapes.c
poly2tri-c/p2t/sweep/sweep.c
poly2tri-c/p2t/sweep/sweep_context.c
poly2tri-c/refine/cdt-flipfix.h
poly2tri-c/refine/cluster.c
poly2tri-c/refine/delaunay-terminator.c
poly2tri-c/refine/delaunay-terminator.h
poly2tri-c/refine/mesh.c
poly2tri-c/refine/mesh.h
poly2tri-c/refine/pslg.h
poly2tri-c/refine/rcdt.c [moved from poly2tri-c/refine/cdt.c with 99% similarity]
poly2tri-c/refine/rcdt.h [moved from poly2tri-c/refine/cdt.h with 98% similarity]
poly2tri-c/refine/refine.h
poly2tri-c/refine/refiner.c
poly2tri-c/refine/refiner.h
poly2tri-c/refine/rutils.c [moved from poly2tri-c/refine/utils.c with 98% similarity]
poly2tri-c/refine/rutils.h [moved from poly2tri-c/refine/utils.h with 98% similarity]
poly2tri-c/refine/triangle.c
poly2tri-c/refine/vedge.h
poly2tri-c/refine/visibility.c
poly2tri-c/render/mesh-render.c

index 62fec896ea002a969241ff5f65adc7ec6040091f..41e50486d146bf2f4f9d8f927f729f72f0f27253 100644 (file)
@@ -290,7 +290,7 @@ p2t_triangle_legalize_pt_pt (P2tTriangle* THIS, P2tPoint *opoint, P2tPoint *npoi
     }
   else
     {
-      assert (0);
+      g_assert_not_reached ();
     }
 }
 
@@ -309,7 +309,9 @@ p2t_triangle_index (P2tTriangle* THIS, const P2tPoint* p)
     {
       return 2;
     }
-  assert (0);
+  g_assert_not_reached ();
+  /* Return a value to silence some compilers */
+  return -1;
 }
 
 int
@@ -399,7 +401,10 @@ p2t_triangle_point_cw (P2tTriangle* THIS, P2tPoint* point)
     {
       return THIS->points_[1];
     }
-  assert (0);
+
+  g_assert_not_reached ();
+  /* Return a value to silence some compilers */
+  return NULL;
 }
 
 /* The point counter-clockwise to given point */
@@ -419,7 +424,9 @@ p2t_triangle_point_ccw (P2tTriangle* THIS, P2tPoint* point)
     {
       return THIS->points_[0];
     }
-  assert (0);
+  g_assert_not_reached ();
+  /* Return a value to silence some compilers */
+  return NULL;
 }
 
 /* The neighbor clockwise to given point */
index 76800756babe916f441e270f7304061133924c9b..6d415cf639a9a0c24d585a7af093897478157cf2 100644 (file)
@@ -61,7 +61,7 @@ p2t_sweep_new ()
 void
 p2t_sweep_destroy (P2tSweep* THIS)
 {
-  int i;
+  guint i;
   /* Clean up memory */
   for (i = 0; i < THIS->nodes_->len; i++)
     {
@@ -94,7 +94,8 @@ p2t_sweep_triangulate (P2tSweep *THIS, P2tSweepContext *tcx)
 void
 p2t_sweep_sweep_points (P2tSweep *THIS, P2tSweepContext *tcx)
 {
-  int i, j;
+  int i;
+  guint j;
   for (i = 1; i < p2t_sweepcontext_point_count (tcx); i++)
     {
       P2tPoint* point = p2t_sweepcontext_get_point (tcx, i);
@@ -983,8 +984,9 @@ p2t_sweep_next_flip_point (P2tSweep *THIS, P2tPoint* ep, P2tPoint* eq, P2tTriang
     }
   else
     {
-      /*throw new RuntimeException("[Unsupported] Opposing point on constrained edge");*/
-      assert (0);
+      g_error ("[Unsupported] Opposing point on constrained edge");
+      /* Return a value to silence some compilers */
+      return NULL;
     }
 }
 
index 18c278aa7a3b59f7cc67547071d2f15e3fa29324..a672e1332dbb854e2766f70bde6af314d1ab4448 100644 (file)
@@ -62,7 +62,7 @@ p2t_sweepcontext_edgeevent_init (P2tSweepContextEdgeEvent* THIS)
 void
 p2t_sweepcontext_init (P2tSweepContext* THIS, P2tPointPtrArray polyline)
 {
-  int i;
+  guint i;
 
   THIS->front_ = NULL;
   THIS->head_ = NULL;
@@ -98,7 +98,7 @@ void
 p2t_sweepcontext_destroy (P2tSweepContext* THIS)
 {
   GList* iter;
-  int i;
+  guint i;
   /* Clean up memory */
 
   p2t_point_free (THIS->head_);
@@ -138,7 +138,7 @@ p2t_sweepcontext_delete (P2tSweepContext* THIS)
 void
 p2t_sweepcontext_add_hole (P2tSweepContext *THIS, P2tPointPtrArray polyline)
 {
-  int i;
+  guint i;
   p2t_sweepcontext_init_edges (THIS, polyline);
   for (i = 0; i < polyline->len; i++)
     {
@@ -167,7 +167,7 @@ p2t_sweepcontext_get_map (P2tSweepContext *THIS)
 void
 p2t_sweepcontext_init_triangulation (P2tSweepContext *THIS)
 {
-  int i;
+  guint i;
   double xmax = point_index (THIS->points_, 0)->x, xmin = point_index (THIS->points_, 0)->x;
   double ymax = point_index (THIS->points_, 0)->y, ymin = point_index (THIS->points_, 0)->y;
   double dx, dy;
index dad11b2e4afa321b582f62eb15fa535089ecab5d..2b5a83dcc878578e232f6f0f9b7036556eaa36d2 100644 (file)
@@ -37,8 +37,8 @@
 
 #include "edge.h"
 #include "vedge.h"
-#include "cdt.h"
-#include "utils.h"
+#include "rcdt.h"
+#include "rutils.h"
 
 /**
  * Flip-Fix all the virtual edges inside the given set
index ccf92170507e85041fc2ee4c5d0a11c4c8d52756..ae678b600c628cd99be9795e033014b72f3507b9 100644 (file)
@@ -33,7 +33,7 @@
 #include <math.h>
 
 #include <glib.h>
-#include "utils.h"
+#include "rutils.h"
 #include "point.h"
 #include "edge.h"
 
index 1de1fea5da224126834d9624de923c41ff4180e5..a434d32aa502b5a3cfadcfd4176266d55dfcb4fc 100644 (file)
@@ -34,7 +34,7 @@
 #include <math.h>
 #include <glib.h>
 
-#include "utils.h"
+#include "rutils.h"
 #include "rmath.h"
 
 #include "point.h"
@@ -42,7 +42,7 @@
 #include "triangle.h"
 
 #include "mesh.h"
-#include "cdt.h"
+#include "rcdt.h"
 #include "cluster.h"
 
 #include "vedge.h"
@@ -368,7 +368,7 @@ SplitPermitted (P2trDelaunayTerminator *self, P2trEdge *s, gdouble d)
 {
   P2trCluster *startCluster = p2tr_cluster_get_for (P2TR_EDGE_START(s), s);
   P2trCluster *endCluster =   p2tr_cluster_get_for (s->end, s);
-  P2trCluster *S_NOREF;
+  P2trCluster *S_NOREF =      NULL;
   GList *iter;
   
   gboolean permitted = FALSE;
index fe0ef5d505c712dc922e1933a89ff9db09b9bd51..33f4a77db2d033f6232cf0ac806c02712ae4e1b3 100644 (file)
@@ -34,7 +34,7 @@
 #define __P2TC_REFINE_DELAUNAY_TERMINATOR_H__
 
 #include <glib.h>
-#include "cdt.h"
+#include "rcdt.h"
 #include "refiner.h"
 #include "vedge.h"
 
index 7fc192f9c7187cdd4d67e3163f7d96026ffc5f5f..493b23242f42422cfb9e2c1c37d3770831e7fb77 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 #include <glib.h>
-#include "utils.h"
+#include "rutils.h"
 
 #include "mesh.h"
 #include "point.h"
index f62c35185e1bde3100a83c7525d0117e7cb5b178..846c29d7b100db6a7809c032eef8179616a81219 100644 (file)
@@ -36,7 +36,7 @@
 #include <stdio.h>
 #include <glib.h>
 #include "vector2.h"
-#include "utils.h"
+#include "rutils.h"
 #include "triangulation.h"
 
 /**
index ef06bf34ca1b0184b590457296492da581aef7f2..2b2ed8521c795d41ab4e4e5d668e87c539aa5d43 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef __P2TC_REFINE_PSLG_H__
 #define __P2TC_REFINE_PSLG_H__
 
-#include "utils.h"
+#include "rutils.h"
 #include "vector2.h"
 #include "line.h"
 #include "bounded-line.h"
similarity index 99%
rename from poly2tri-c/refine/cdt.c
rename to poly2tri-c/refine/rcdt.c
index 4929d344c39f09a496d9ba1a407ba957655e4526..d61b488dd73349a909063a36783f1d10f75f06f3 100644 (file)
@@ -37,7 +37,7 @@
 #include "edge.h"
 #include "triangle.h"
 
-#include "cdt.h"
+#include "rcdt.h"
 #include "visibility.h"
 #include "cdt-flipfix.h"
 
@@ -82,7 +82,7 @@ p2tr_cdt_new (P2tCDT *cdt)
 
   P2trVEdgeSet *new_edges = p2tr_vedge_set_new ();
 
-  gint i, j;
+  guint i, j;
 
   rmesh->mesh = p2tr_mesh_new ();
   rmesh->outline = p2tr_pslg_new ();
similarity index 98%
rename from poly2tri-c/refine/cdt.h
rename to poly2tri-c/refine/rcdt.h
index 23455a66c59e68251e455a56fa879d8e35cc07d7..55bd3b3c1c74f79503036e343128e520adeea787 100644 (file)
@@ -30,8 +30,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __P2TC_REFINE_CDT_H__
-#define __P2TC_REFINE_CDT_H__
+#ifndef __P2TC_REFINE_RCDT_H__
+#define __P2TC_REFINE_RCDT_H__
 
 #include <poly2tri-c/p2t/poly2tri.h>
 #include "mesh.h"
index 78288872c573864ed7e1071c37a7badbb21583c5..5bfb3ee4841fdc2763e9f0bdc5f71d67f3e2d225 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef __P2TC_REFINE_H__
 #define __P2TC_REFINE_H__
 
-#include "utils.h"
+#include "rutils.h"
 #include "rmath.h"
 
 #include "vector2.h"
@@ -53,7 +53,7 @@
 #include "vtriangle.h"
 
 #include "cluster.h"
-#include "cdt.h"
+#include "rcdt.h"
 #include "refiner.h"
 
 #endif
index 92e2c3285b34e833278d2bf169e74f8ad03674d6..a56d16288a4f752057fe195f66912f578c5939b1 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 #include <glib.h>
-#include "cdt.h"
+#include "rcdt.h"
 #include "delaunay-terminator.h"
 #include "refiner.h"
 
index ffeba910bea6e6ef5bf1075b547ab474ee78471f..739bb97b914ba16c7935739b35ce6f42214e402d 100644 (file)
@@ -34,7 +34,7 @@
 #define __P2TC_REFINE_REFINER_H__
 
 #include <glib.h>
-#include "cdt.h"
+#include "rcdt.h"
 
 typedef struct P2trRefiner_ P2trRefiner;
 
similarity index 98%
rename from poly2tri-c/refine/utils.c
rename to poly2tri-c/refine/rutils.c
index d9d7db4213381608dcfc4464fe1aa00fabccdeae..589e42c3fafd1266363b86af18f7e1fb83898463 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdarg.h>
 #include <glib.h>
 
-#include "utils.h"
+#include "rutils.h"
 
 GList*
 p2tr_utils_new_reversed_pointer_list (int count, ...)
similarity index 98%
rename from poly2tri-c/refine/utils.h
rename to poly2tri-c/refine/rutils.h
index 576476fa5f3aabc3ad5f152f95398b79b0016280..0163f792cec7e4330de74685dc690581ecd89166 100644 (file)
@@ -30,8 +30,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __P2TC_REFINE_UTILS_H__
-#define __P2TC_REFINE_UTILS_H__
+#ifndef __P2TC_REFINE_RUTILS_H__
+#define __P2TC_REFINE_RUTILS_H__
 
 #ifdef __cplusplus
 extern "C"
index ce28dcc9356cd5d9520624896917ac7830e7f43f..71c6d17474371e5880a1e83965614a3ab37edb69 100644 (file)
@@ -33,7 +33,7 @@
 #include <math.h>
 #include <glib.h>
 
-#include "utils.h"
+#include "rutils.h"
 #include "rmath.h"
 
 #include "point.h"
index 30f0e8f3f98ed553e609ddacaaec1bb2cef3346a..4fb7541979c66f8658412b5eb0d3515f2366871e 100644 (file)
@@ -34,7 +34,7 @@
 #define __P2TC_REFINE_VEDGE_H__
 
 #include <glib.h>
-#include "utils.h"
+#include "rutils.h"
 #include "triangulation.h"
 
 /**
index eab71edaa09256aad69017b908ac7cb9fa356245..3862e7f1a898a3fd279b52749c77c1904fadc55a 100644 (file)
@@ -425,7 +425,7 @@ p2tr_visibility_is_visible_from_edges (P2trPSLG              *pslg,
                                        guint                  line_count)
 {
   P2trPSLG *edges = p2tr_pslg_new ();
-  gint i;
+  guint i;
   gboolean result;
   
   for (i = 0; i < line_count; i++)
index 6794b7145ba9e87063f3927b790f8fc15cd3198e..e4d3025fd1501df49a4dcafed2a8664286e69014 100644 (file)
@@ -76,7 +76,7 @@ p2tr_mesh_render_cache_uvt_exact (P2trMesh        *T,
                                   gint             dest_len,
                                   P2trImageConfig *config)
 {
-  gint x, y, n = dest_len;
+  guint x, y, n = dest_len;
   P2trUVT *uvt = dest;
   P2trTriangle *tr_prev = NULL;
   P2trVector2 pt;