#  Copyright (c) 1997-2004
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de
#
#  This program 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 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program 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.
#----------------------------------------------------------------------------
#  $Project: polymake $$Id: bastat.rules,v 1.24 2004/12/10 15:47:24 gawrilow Exp $


# path to the 'intpoints' executable from the bastat package
custom $bastat_intpoints;

CONFIGURE {
   $bastat_intpoints=find_via_path("intpoints")
   or die "bastat program 'intpoints' not found\n";
}

object RationalPolytope;

# category: Integral lattice points
# Number of non-negative interior lattice points
property N_NON_NEG_INT
$type="cardinal";


N_NON_NEG_INT : AMBIENT_DIM, FACETS | INEQUALITIES
   my @ineq=convert_to_integer($this->FACETS | INEQUALITIES);
   my $rows=@ineq;
   my $intpoints=new Poly::ProgramPipe($bastat_intpoints);
   print $intpoints "0\n", $this->AMBIENT_DIM, "\n$rows\n";	# ordering and dimensions
   foreach (@ineq) {
      /(\w)(.*)/;
      print $intpoints (negative($2), " ", $1, "\n");
   }
   my $n=-1; # output of -1 signals an unknown error
   while (<$intpoints>) {
      if (/^Pas de point entier/) {
         $n=0;
      } elsif (/^(\d+)\s+points? entiers?/) {
         $n=$1;
         last;
      }
   }
   $this->N_NON_NEG_INT=$n;


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
