#  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: steiner.rules,v 1.14 2004/11/12 13:38:35 gawrilow Exp $

object Polytope;

# category: Basic properties
# A weighted inner point depending on the outer angle called Steiner point for all faces of dimensions `2` to `d`.

property STEINER_POINTS
$type="matrix";


STEINER_POINTS : HASSE_DIAGRAM, GRAPH, VERTICES, DIM, BOUNDED
WEIGHT 6.10
   client("steiner_point_all", $this);


# category: Visualization
# Create a SchlegelDiagram object.
#
# The projection ray will connect the Steiner points of the polytope
# and the projection facet.
#
# Default zoom factor is 1/2.
# return: SchlegelDiagram

user_method makeSchlegelSteinerPoints(%make_schlegel_params) {
   my ($this, $params)=@_;
   my $P=$this->STEINER_POINTS;
   $params->{FACET} ||= 0;
   $params->{ZOOM} ||= "1/2";
   new Apps::polytope::SchlegelDiagram (
      Polytope => $this,
      %$params,
      FACET_POINT => $P->[$params->{FACET}+1],
      INNER_POINT => $P->[0],
  );
}

package Visual::Color;

# Steiner points are drawn in blue
custom $steiner_point="0 0 255";

package default;

# Steiner points are drawn thicker than the vertices
custom $steiner_point_thickness=7;

###################################################################################
#
#  decoration methods adding Steiner points to various drawings
#
package Visual::Polytope;

# Add the @see STEINER_POINTS to the 3-d visualization
# The facets are made transparent.
user_method STEINER {
   my ($this)=@_;
   $this->FacetStyle="hidden";
   my $P=$this->Polytope;
   my $SP=new Visual::PointSet(
      Name => "Steiner points of " . $this->Name,
      Points => [ $P->dehomogenize($P->STEINER_POINTS) ],
      PointColor => $Visual::Color::steiner_point,
      PointLabels => "hidden",
      PointStyle => "thickness $Apps::polytope::steiner_point_thickness",
   );
   visualize($this, $SP);
}

*Visual::PolytopeGraph::STEINER=\&STEINER;

package Visual::Schlegel;

# Add the @see STEINER_POINTS to the 4-d visualization
user_method STEINER {
   my ($this)=@_;
   my $SD=$this->Schlegel;
   my $P=$SD->Polytope;
   my @steiner_points=@{$P->STEINER_POINTS};
   # omit the Steiner point of the whole polytope and the one on the projection facet
   splice @steiner_points, 0, 1;
   splice @steiner_points, $SD->FACET, 1;
   my $SP=new Visual::PointSet(
      Name => "Steiner points of " . $this->Name,
      Points => $this->append_points(\@steiner_points),
      PointColor => $Visual::Color::steiner_point,
      PointLabels => "hidden",
      PointStyle => "thickness $Apps::polytope::steiner_point_thickness",
   );
   visualize($this, $SP);
}


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