From 0c8b3535fe28f5ca90e0408ada81daf01cbb47e5 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 8 Sep 2008 16:57:41 +0200 Subject: [PATCH] add isl_set_read_from_file for reading unions of polyhedra (in polylib format) --- include/isl_set.h | 2 ++ isl_input.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/isl_set.h b/include/isl_set.h index 817d308..ac61c07 100644 --- a/include/isl_set.h +++ b/include/isl_set.h @@ -93,6 +93,8 @@ struct isl_basic_set *isl_basic_set_simplify( #define ISL_FORMAT_OMEGA 2 struct isl_basic_set *isl_basic_set_read_from_file(struct isl_ctx *ctx, FILE *input, unsigned input_format); +struct isl_set *isl_set_read_from_file(struct isl_ctx *ctx, + FILE *input, unsigned input_format); int isl_basic_set_is_equal(struct isl_ctx *ctx, struct isl_basic_set *bset1, struct isl_basic_set *bset2); diff --git a/isl_input.c b/isl_input.c index 6e5d907..23b3c07 100644 --- a/isl_input.c +++ b/isl_input.c @@ -75,6 +75,37 @@ error: return NULL; } +static struct isl_set *isl_set_read_from_file_polylib( + struct isl_ctx *ctx, FILE *input) +{ + struct isl_set *set = NULL; + char line[1024]; + int i; + unsigned n; + + isl_assert(ctx, next_line(input, line, sizeof(line)), return NULL); + isl_assert(ctx, sscanf(line, "%u", &n) == 1, return NULL); + + set = isl_set_alloc(ctx, 0, 0, n, 0); + if (!set) + return NULL; + if (n == 0) + return set; + for (i = 0; i < n; ++i) { + set->p[i] = isl_basic_set_read_from_file_polylib(ctx, input); + if (!set->p[i]) + goto error; + } + set->n = n; + set->dim = set->p[0]->dim; + for (i = 1; i < n; ++i) + isl_assert(ctx, set->dim == set->p[i]->dim, goto error); + return set; +error: + isl_set_free(ctx, set); + return NULL; +} + struct isl_basic_set *isl_basic_set_read_from_file(struct isl_ctx *ctx, FILE *input, unsigned input_format) { @@ -94,3 +125,12 @@ struct isl_basic_map *isl_basic_map_read_from_file(struct isl_ctx *ctx, else isl_assert(ctx, 0, return NULL); } + +struct isl_set *isl_set_read_from_file(struct isl_ctx *ctx, + FILE *input, unsigned input_format) +{ + if (input_format == ISL_FORMAT_POLYLIB) + return isl_set_read_from_file_polylib(ctx, input); + else + isl_assert(ctx, 0, return NULL); +} -- 2.7.4