diff --git a/src/PolyUtil.c b/src/PolyUtil.c index 0575a4a..3fde396 100644 --- a/src/PolyUtil.c +++ b/src/PolyUtil.c @@ -173,28 +173,28 @@ int poly_c_point_inside(gpc_vertex_list *vl, double x, double y){ int poly_p_point_inside(gpc_polygon *p, double x, double y){ - int i; + int i; int inSolid; - t_area_index *array_areas; - array_areas = (t_area_index *) malloc(sizeof(t_area_index) * p->num_contours); - for(i=0; i< p->num_contours; i++) { - array_areas[i].area = poly_c_area(p->contour + i); - array_areas[i].idx = i; - } - qsort(array_areas, p->num_contours, sizeof(array_areas[0]), compare_structs); - for(i=0; i < p->num_contours; i++) { - /* loop area sorted contours */ - inSolid = poly_c_point_inside(p->contour + array_areas[i].idx, x, y); - if (inSolid == -1) - break; /* error */ - if (inSolid > 0){ - if (p->hole[array_areas[i].idx] == 1) - inSolid = 0; - break; - } - } - free(array_areas); - return inSolid; + t_area_index *array_areas; + array_areas = (t_area_index *) malloc(sizeof(t_area_index) * p->num_contours); + for(i=0; i< p->num_contours; i++) { + array_areas[i].area = poly_c_area(p->contour + i); + array_areas[i].idx = i; + } + qsort(array_areas, p->num_contours, sizeof(array_areas[0]), compare_structs); + for(i=0; i < p->num_contours; i++) { + /* loop area sorted contours */ + inSolid = poly_c_point_inside(p->contour + array_areas[i].idx, x, y); + if (inSolid == -1) + break; /* error */ + if (inSolid > 0){ + if (p->hole[array_areas[i].idx] == 1) + inSolid = 0; + break; + } + } + free(array_areas); + return inSolid; }