From: Barak Itkin Date: Sat, 12 May 2012 20:44:23 +0000 (+0300) Subject: 1. Fix a missing call to triangulate in the main test program X-Git-Tag: p2tc-0.1.0~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc960aceb31af4110b5547c93511828779fc9ce4;p=poly2tri-c 1. Fix a missing call to triangulate in the main test program 2. Fix the free function of the edge class --- diff --git a/bin/main.c b/bin/main.c index 33266fb..8d617f3 100755 --- a/bin/main.c +++ b/bin/main.c @@ -221,6 +221,8 @@ gint main (int argc, char *argv[]) read_points_file (input_file, &pts, &colors); cdt = p2t_cdt_new (pts); + p2t_cdt_triangulate (cdt); + rcdt = p2tr_cdt_new (cdt); p2t_cdt_free (cdt); diff --git a/refine/edge.c b/refine/edge.c index 9a91c79..4744230 100644 --- a/refine/edge.c +++ b/refine/edge.c @@ -63,31 +63,33 @@ p2tr_edge_is_removed (P2trEdge *self) return self->end == NULL; } -static void -p2tr_edge_remove_one_side (P2trEdge *self) -{ - if (self->tri != NULL) - { - p2tr_triangle_remove (self->tri); - p2tr_triangle_unref (self->tri); - self->tri = NULL; - } - _p2tr_point_remove_edge(P2TR_EDGE_START(self), self); - p2tr_point_unref (self->end); - self->end = NULL; -} - void p2tr_edge_remove (P2trEdge *self) { P2trMesh *mesh; + P2trPoint *start, *end; if (self->end == NULL) /* This is only true if the edge was removed */ return; mesh = p2tr_edge_get_mesh (self); - p2tr_edge_remove_one_side (self); - p2tr_edge_remove_one_side (self->mirror); + + start = P2TR_EDGE_START(self); + end = self->end; + + if (self->tri != NULL) + p2tr_triangle_remove (self->tri); + if (self->mirror->tri != NULL) + p2tr_triangle_remove (self->mirror->tri); + + _p2tr_point_remove_edge(start, self); + _p2tr_point_remove_edge(end, self->mirror); + + self->end = NULL; + self->mirror->end = NULL; + + p2tr_point_unref (start); + p2tr_point_unref (end); if (mesh != NULL) { @@ -181,4 +183,4 @@ p2tr_edge_angle_between(P2trEdge *e1, P2trEdge *e2) result -= 2 * G_PI; return result; -} \ No newline at end of file +}