]> granicus.if.org Git - poly2tri-c/commitdiff
Various small changes to make the test program compile
authorBarak Itkin <lightningismyname@gmail.com>
Sat, 5 May 2012 13:10:35 +0000 (16:10 +0300)
committerBarak Itkin <lightningismyname@gmail.com>
Sat, 5 May 2012 13:10:35 +0000 (16:10 +0300)
bin/main.c
refine/delaunay-terminator.c
refine/delaunay-terminator.h
render/mesh-render.h

index 7ec0d66539d86b8b7b7f553ad9bc5d322a422424..5bceab111443ff1372fabd67b86f7f80bae8d107 100755 (executable)
 
 #include <p2t/poly2tri.h>
 
-#include <refine/triangulation.h>
-#include <render/svg-plot.h>
 #include <refine/refine.h>
-
+#include <render/svg-plot.h>
 #include <render/mesh-render.h>
 
 #include <string.h>
@@ -74,9 +72,9 @@ typedef gfloat Point2f[2];
  *
  */
 void
-read_points_file (const gchar  *path,
-                  GPtrArray   **points,
-                  GArray      **colors)
+read_points_file (const gchar       *path,
+                  P2tPointPtrArray  *points,
+                  GArray           **colors)
 {
   FILE *f = fopen (path, "r");
   gint countPts = 0, countCls = 0;
@@ -117,7 +115,7 @@ read_points_file (const gchar  *path,
 
           if (points != NULL)
             {
-              g_ptr_array_add (*points, p2tr_point_new (ptc[0], ptc[1]));
+              g_ptr_array_add (*points, p2t_point_new (ptc[0], ptc[1]));
               countPts++;
             }
         }
@@ -174,9 +172,10 @@ gint main (int argc, char *argv[])
   GPtrArray *pts;
   GArray    *colors;
 
-  P2tRTriangulation *T;
+  P2tCDT *cdt;
+  P2trCDT *rcdt;
+  P2trDelaunayTerminator *dt;
 
-  gint i;
   gchar buf[P2TC_MAX_PATH+1];
   gfloat *im;
 
@@ -217,9 +216,14 @@ gint main (int argc, char *argv[])
 
   read_points_file (input_file, &pts, &colors);
 
-  T = p2tr_triangulate_and_refine (pts, refine_max_steps);
+  cdt = p2t_cdt_new (pts);
+  rcdt = p2tr_cdt_new (cdt);
+  p2t_cdt_free (cdt);
+  
+  dt = p2tr_dt_new (G_PI / 6, p2tr_dt_false_too_big, rcdt);
+  p2tr_dt_refine (dt, refine_max_steps);
 
-  p2tr_plot_svg (T,out);
+  p2tr_plot_svg (dt->mesh->mesh,out);
 
   fclose (out);
 
@@ -231,7 +235,7 @@ gint main (int argc, char *argv[])
       exit (1);
     }
 
-  P2tRImageConfig imc;
+  P2trImageConfig imc;
   
   imc.cpp = 4;
   imc.min_x = imc.min_y = 0;
@@ -240,21 +244,22 @@ gint main (int argc, char *argv[])
 
   im = g_new (gfloat, imc.cpp * imc.x_samples * imc.y_samples);
 
-  p2tr_mesh_render_scanline (T, im, &imc, p2tr_test_point_to_color, NULL);
+  p2tr_mesh_render_scanline (dt->mesh->mesh, im, &imc, p2tr_test_point_to_color, NULL);
 
   p2tr_write_ppm (out, im, &imc);
   fclose (out);
 
   g_free (im);
 
-  p2tr_triangulation_free (T);
+  // p2tr_triangulation_free (T);
 
-  for (i = 0; i < pts->len; i++)
-    {
-      p2tr_point_unref ((P2tRPoint*) g_ptr_array_index (pts, i));
-    }
+//  for (i = 0; i < pts->len; i++)
+//    {
+//      p2tr_point_unref ((P2trPoint*) g_ptr_array_index (pts, i));
+//    }
 
   g_ptr_array_free (pts, TRUE);
   g_array_free (colors, TRUE);
   
+  return 0;
 }
index cfc59e443574df54a67eb72571315f871d02091a..a455ea4f89305016bd4dd9b7e623b36ce0911863 100644 (file)
@@ -189,14 +189,15 @@ p2tr_dt_segment_queue_is_empty (P2trDelaunayTerminator *self)
   return g_queue_is_empty (&self->Qs);
 }
 
-static gboolean
-false_too_big (P2trTriangle *tri)
+gboolean
+p2tr_dt_false_too_big (P2trTriangle *tri)
 {
   return FALSE;
 }
 
-void p2tr_dt_refine (P2trDelaunayTerminator *self,
-                     gint                    max_steps)
+void
+p2tr_dt_refine (P2trDelaunayTerminator *self,
+                gint                    max_steps)
 {
   P2trHashSetIter hs_iter;
   P2trEdge *s;
@@ -208,7 +209,7 @@ void p2tr_dt_refine (P2trDelaunayTerminator *self,
     if (s->constrained && p2tr_cdt_is_encroached (s))
       p2tr_dt_enqueue_segment (self, s);
 
-  SplitEncroachedSubsegments (self, 0, false_too_big);
+  SplitEncroachedSubsegments (self, 0, p2tr_dt_false_too_big);
 
   p2tr_hash_set_iter_init (&hs_iter, self->mesh->mesh->triangles);
   while (p2tr_hash_set_iter_next (&hs_iter, (gpointer*)&t))
index e536bd63706af2dbf0670ffba8140639f6c816e1..0820b4741352b844d5ed199eedf1c1a04516e64d 100644 (file)
@@ -27,7 +27,12 @@ P2trHashSet*  p2tr_cdt_get_segments_encroached_by (P2trCDT     *self,
 
 gboolean      p2tr_cdt_is_encroached (P2trEdge *E);
 
+gboolean     p2tr_dt_false_too_big (P2trTriangle *tri);
+
 P2trDelaunayTerminator*
 p2tr_dt_new (gdouble theta, P2trTriangleTooBig delta, P2trCDT *cdt);
 
+void p2tr_dt_refine (P2trDelaunayTerminator *self,
+                     gint                    max_steps);
+
 #endif
\ No newline at end of file
index a93cd57dae168ceeaa2b3c6a7628d5dbacdd9cf0..824838cfec74035907135133b9942dfc4e18ebc3 100755 (executable)
@@ -52,4 +52,9 @@ p2tr_mesh_render_scanline2 (P2truvt              *uvt_cache,
                             P2trPointToColorFunc  pt2col,
                             gpointer              pt2col_user_data);
 
+void
+p2tr_write_ppm (FILE            *f,
+                gfloat          *dest,
+                P2trImageConfig *config);
+
 #endif