X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/9431c353bd39a1fbb855580ee34931a07321a0f1..6ec23dc57252ffe01aa60595fc499f580381e4a9:/pypol/domains.py diff --git a/pypol/domains.py b/pypol/domains.py index 255c995..cd118e8 100644 --- a/pypol/domains.py +++ b/pypol/domains.py @@ -6,6 +6,7 @@ from fractions import Fraction from . import islhelper from .islhelper import mainctx, libisl, isl_set_basic_sets +from .geometry import GeometricObject from .coordinates import Point from .linexprs import Expression, Symbol @@ -17,7 +18,7 @@ __all__ = [ @functools.total_ordering -class Domain: +class Domain(GeometricObject): __slots__ = ( '_polyhedra', @@ -28,14 +29,14 @@ class Domain: def __new__(cls, *polyhedra): from .polyhedra import Polyhedron if len(polyhedra) == 1: - polyhedron = polyhedra[0] - if isinstance(polyhedron, str): - return cls.fromstring(polyhedron) - elif isinstance(polyhedron, Polyhedron): - return polyhedron + argument = polyhedra[0] + if isinstance(argument, str): + return cls.fromstring(argument) + elif isinstance(argument, GeometricObject): + return argument.aspolyhedron() else: raise TypeError('argument must be a string ' - 'or a Polyhedron instance') + 'or a GeometricObject instance') else: for polyhedron in polyhedra: if not isinstance(polyhedron, Polyhedron): @@ -154,6 +155,9 @@ class Domain: islbset = libisl.isl_set_polyhedral_hull(islset) return Polyhedron._fromislbasicset(islbset, self.symbols) + def asdomain(self): + return self + def project(self, dims): # use to remove certain variables islset = self._toislset(self.polyhedra, self.symbols)