#  Copyright (c) 1997-2021
#  Ewgenij Gawrilow, Michael Joswig, and the polymake team
#  Technische Universität Berlin, Germany
#  https://polymake.org
#
#  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.
#-------------------------------------------------------------------------------


object PolyhedralFan {

   property GROUP {

      # @category Symmetry
      # f<sub>k</sub> is the number of k-dimensional cones up to symmetry.
      property ORBITS_F_VECTOR : Vector<Integer>;

      # @category Symmetry
      # Number of [[CONES]] in each orbit represented by the elements of
      # [[REPRESENTATIVE_CONES]].
      property CONES_ORBIT_SIZES : Array<Array<Int>>;

   }


rule GROUP.REPRESENTATIVE_MAXIMAL_CONES : MAXIMAL_CONES, GROUP.MAXIMAL_CONES_ACTION.ORBIT_REPRESENTATIVES {
    my @mcr;
    foreach my $r (@{$this->GROUP->MAXIMAL_CONES_ACTION->ORBIT_REPRESENTATIVES}) {
        push @mcr, new Set<Int>($this->MAXIMAL_CONES->[$r]);
    }
    $this->GROUP->REPRESENTATIVE_MAXIMAL_CONES = new Array<Set<Int>>(\@mcr);
}



rule GROUP.MAXIMAL_CONES_ACTION.REPRESENTATIVE_COMBINATORIAL_DIMS : RAYS, GROUP.REPRESENTATIVE_MAXIMAL_CONES, LINEALITY_SPACE {
   my @dims;
   foreach (@{$this->GROUP->REPRESENTATIVE_MAXIMAL_CONES}) {
      push @dims, (new polytope::Cone(RAYS=>$this->RAYS->minor($_,All),LINEALITY_SPACE=>$this->LINEALITY_SPACE))->COMBINATORIAL_DIM;
   }
   $this->GROUP->MAXIMAL_CONES_ACTION->REPRESENTATIVE_COMBINATORIAL_DIMS=\@dims;
}
weight 1.50;

rule GROUP.MAXIMAL_CONES_ACTION.N_ORBITS : GROUP.REPRESENTATIVE_MAXIMAL_CONES {
   $this->GROUP->MAXIMAL_CONES_ACTION->N_ORBITS=scalar(@{$this->GROUP->REPRESENTATIVE_MAXIMAL_CONES});
}
weight 0.1;

rule F_VECTOR, GROUP.ORBITS_F_VECTOR, GROUP.REPRESENTATIVE_CONES, GROUP.CONES_ORBIT_SIZES : RAYS, GROUP.REPRESENTATIVE_MAXIMAL_CONES, GROUP.RAYS_ACTION.ALL_GROUP_ELEMENTS, COMBINATORIAL_DIM, LINEALITY_SPACE {
    all_cones_symmetry($this,$this->COMBINATORIAL_DIM);
}
weight 3.10;

rule F_VECTOR, GROUP.ORBITS_F_VECTOR, GROUP.REPRESENTATIVE_CONES, GROUP.CONES_ORBIT_SIZES, COMBINATORIAL_DIM, GROUP.MAXIMAL_CONES_ACTION.REPRESENTATIVE_COMBINATORIAL_DIMS : RAYS, GROUP.REPRESENTATIVE_MAXIMAL_CONES, GROUP.RAYS_ACTION.ALL_GROUP_ELEMENTS, LINEALITY_SPACE {
    all_cones_symmetry($this);
}
weight 3.60;

rule PURE : GROUP.MAXIMAL_CONES_ACTION.REPRESENTATIVE_COMBINATORIAL_DIMS {
    my $dim=$this->GROUP->MAXIMAL_CONES_ACTION->REPRESENTATIVE_COMBINATORIAL_DIMS->[0];
    foreach (@{$this->GROUP->MAXIMAL_CONES_ACTION->REPRESENTATIVE_COMBINATORIAL_DIMS})  {
      if ($_!=$dim) {
          $this->PURE=0;
	  return;
     }
   }
   $this->PURE=1;
}
weight 1.10;

}

object PolyhedralComplex {

    # @category Symmetry
    property GROUP {

        # @category Symmetry
        property INPUT_POLYTOPES_ACTION = override INPUT_CONES_ACTION;

        # @category Symmetry
        property POLYTOPES_ORBIT_SIZES = override CONES_ORBIT_SIZES;
    }

}

# Local Variables:
# mode: perl
# cperl-indent-level: 3
# indent-tabs-mode:nil
# End:
