X-Git-Url: https://scm.cri.mines-paristech.fr/git/linpy.git/blobdiff_plain/f6de7444731fbcadb872d64b97fe5b2877c24229..9b755b94aa2c8847ffca607de239f5c3bca9984b:/pypol/_islhelper.c
diff --git a/pypol/_islhelper.c b/pypol/_islhelper.c
index a7b4f33..6757ae1 100644
--- a/pypol/_islhelper.c
+++ b/pypol/_islhelper.c
@@ -1,7 +1,25 @@
+// Copyright 2014 MINES ParisTech
+//
+// This file is part of Linpy.
+//
+// Linpy is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Linpy is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Linpy. If not, see .
+
#include
#include
#include
+#include
static inline int _append_pointer_to_list(void *pointer, void *user) {
@@ -89,11 +107,37 @@ static PyObject * isl_set_points(PyObject *self, PyObject *args) {
return list;
}
+static int _append_vertex_to_list(isl_vertex *vertex, void* user) {
+ return _append_pointer_to_list((void *) vertex, user);
+}
+
+static PyObject * isl_vertices_vertices(PyObject *self, PyObject *args) {
+ long pointer;
+ isl_vertices *vertices;
+ PyObject *list;
+ if (!PyArg_ParseTuple(args, "l", &pointer)) {
+ return NULL;
+ }
+ vertices = (isl_vertices *) pointer;
+ list = PyList_New(0);
+ if (list == NULL) {
+ return NULL;
+ }
+ if (isl_vertices_foreach_vertex(vertices, _append_vertex_to_list, list) == -1) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "an error occurred in isl_vertices_foreach_vertex");
+ Py_DECREF(list);
+ return NULL;
+ }
+ return list;
+}
+
static PyMethodDef _islhelper_methods[] = {
{"isl_basic_set_constraints", isl_basic_set_constraints, METH_VARARGS, NULL},
{"isl_set_basic_sets", isl_set_basic_sets, METH_VARARGS, NULL},
{"isl_set_points", isl_set_points, METH_VARARGS, NULL},
+ {"isl_vertices_vertices", isl_vertices_vertices, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
@@ -111,10 +155,8 @@ PyMODINIT_FUNC PyInit__islhelper(void) {
if (m == NULL) {
return NULL;
}
-
if (PyModule_AddObject(m, "dim_set", PyLong_FromLong(isl_dim_set)) == -1) {
return NULL;
}
-
return m;
}