#  Copyright (c) 1997-2006
#  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: common.rules 7088 2006-02-23 11:36:03Z thilosch $

INCLUDE
   surface_properties.rules

object Surface;

HASSE_DIAGRAM : FACETS
  client("hasse_diagram",$this,"FACETS");

ROTATION_SCHEME : HASSE_DIAGRAM
  client("rotation_scheme",$this,"-primal");

GRAPH : FACETS
  client("graph_from_incidence", $this, "FACETS", "-primal");

VERTEX_DEGREES : GRAPH
WEIGHT 1.10
   $this->VERTEX_DEGREES=join(" ", row_sizes($this->GRAPH));

DUAL_GRAPH : FACETS
  client("graph_from_incidence", $this, "FACETS", "-dual");

N_VERTICES : GEOMETRIC_REALIZATION
  $this->N_VERTICES = @{$this->GEOMETRIC_REALIZATION};

N_FACETS : FACETS
  $this->N_FACETS = @{$this->FACETS};

VERTEX_LABELS : N_VERTICES
WEIGHT 0.10
   my @labels = (0..$this->N_VERTICES-1);
   $this->VERTEX_LABELS="@labels";

FACETS : FACETS_CYCLIC
  my @facets = @{$this->FACETS_CYCLIC};
  map { 
    $_ = "{". join(" ",sort { $a <=> $b } m/\d+/g)."}\n" 
  } @facets;
  $this->FACETS = \@facets;

FACETS_CYCLIC, NEIGHBOR_FACETS_CYCLIC : FACETS, DUAL_GRAPH
  client("neighbors_cyclic",$this, "-primal");

FTV_CYCLIC, ROTATION_SCHEME : FACETS, GRAPH
  client("neighbors_cyclic",$this, "-dual");

F_VECTOR, F2_VECTOR : HASSE_DIAGRAM
WEIGHT 3.10
   client("f2_vector", $this)

EULER_CHARACTERISTIC : F_VECTOR
   my @F_VECTOR = ($this->F_VECTOR =~ /\d+/g);
   my $EC = 0;
   my $sign = 1;
   map { $EC += $sign*$_; $sign *= -1} @F_VECTOR;
   $this->EULER_CHARACTERISTIC = $EC;

GENUS : EULER_CHARACTERISTIC
  $this->GENUS = 1-$this->EULER_CHARACTERISTIC/2

POLYGON_SIZES : FACETS
  my %polygon_sizes;
  map { ++$polygon_sizes{$_} } row_sizes($this->FACETS);
  my $sizes;
  map { $sizes .= "($_ $polygon_sizes{$_}) "} sort { $a <=> $b } keys %polygon_sizes;
  $this->POLYGON_SIZES = "{ $sizes}";

VERTEX_SIZES : VERTEX_DEGREES
  my %vertex_sizes;
  map { ++$vertex_sizes{$_} } split(/\s+/,$this->VERTEX_DEGREES);
  my $sizes;
  map { $sizes .= "($_ $vertex_sizes{$_}) "} sort { $a <=> $b } keys %vertex_sizes;
  $this->VERTEX_SIZES = "{ $sizes}";


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