From: Barak Itkin Date: Sat, 5 May 2012 13:10:35 +0000 (+0300) Subject: Various small changes to make the test program compile X-Git-Tag: p2tc-0.1.0~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59b5230e1c3dad60932dd57c29900437a0f38a96;p=poly2tri-c Various small changes to make the test program compile --- diff --git a/bin/main.c b/bin/main.c index 7ec0d66..5bceab1 100755 --- a/bin/main.c +++ b/bin/main.c @@ -35,10 +35,8 @@ #include -#include -#include #include - +#include #include #include @@ -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; } diff --git a/refine/delaunay-terminator.c b/refine/delaunay-terminator.c index cfc59e4..a455ea4 100644 --- a/refine/delaunay-terminator.c +++ b/refine/delaunay-terminator.c @@ -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)) diff --git a/refine/delaunay-terminator.h b/refine/delaunay-terminator.h index e536bd6..0820b47 100644 --- a/refine/delaunay-terminator.h +++ b/refine/delaunay-terminator.h @@ -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 diff --git a/render/mesh-render.h b/render/mesh-render.h index a93cd57..824838c 100755 --- a/render/mesh-render.h +++ b/render/mesh-render.h @@ -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