X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/663316ddc03c19cf06e95bad67fd5ac2bb5e1dfc..2c669de47805cf0b8bd1c8bcf3958f52b1902926:/pypol/polyhedra.py?ds=inline diff --git a/pypol/polyhedra.py b/pypol/polyhedra.py index a08213d..37f16e0 100644 --- a/pypol/polyhedra.py +++ b/pypol/polyhedra.py @@ -1,4 +1,3 @@ - import functools import math import numbers @@ -6,7 +5,7 @@ import numbers from . import islhelper from .islhelper import mainctx, libisl -from .coordinates import Point +from .geometry import GeometricObject, Point from .linexprs import Expression, Symbol, Rational from .domains import Domain @@ -33,11 +32,7 @@ class Polyhedron(Domain): if inequalities is not None: raise TypeError('too many arguments') return cls.fromstring(equalities) - elif isinstance(equalities, Polyhedron): - if inequalities is not None: - raise TypeError('too many arguments') - return equalities - elif isinstance(equalities, Domain): + elif isinstance(equalities, GeometricObject): if inequalities is not None: raise TypeError('too many arguments') return equalities.aspolyhedron() @@ -247,6 +242,17 @@ class Polyhedron(Domain): angles[m] = angle return sorted(points, key=angles.get) + def faces(self): + vertices = self.vertices() + faces = [] + for constraint in self.constraints: + face = [] + for vertex in vertices: + if constraint.subs(vertex.coordinates()) == 0: + face.append(vertex) + faces.append(face) + return faces + def plot(self): import matplotlib.pyplot as plt from matplotlib.path import Path