#  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 PointConfiguration {


file_suffix pc

# @category Input property
# The points of the configuration.  Multiples allowed.
property POINTS = override VECTORS;

# @category Visualization
# Unique names assigned to the [[POINTS]].
property POINT_LABELS = override LABELS;

# @category Geometry
# Tells if multiple points exist.
property MULTIPLE_POINTS = override MULTIPLE_VECTORS;

# @category Geometry
# The polytope being the convex hull of the point configuration.
property CONVEX_HULL : Polytope<Scalar> {

   # Indices of [[Polytope::VERTICES]] of the [[CONVEX_HULL]] as [[POINTS]].
   property VERTEX_POINT_MAP : Array<Int>;

   rule VERTEX_POINT_MAP : VertexPerm.VERTEX_POINT_MAP, VertexPerm.PERMUTATION {
     $this->VERTEX_POINT_MAP=permuted($this->VertexPerm->VERTEX_POINT_MAP, $this->VertexPerm->PERMUTATION);
   }
   weight 1.10;

}

# @category Geometry
# Affine dimension of the point configuration.
# Similar to [[Polytope::DIM]].
# @return Int
user_method DIM() : VECTOR_DIM {
   return $_[0]->VECTOR_DIM-1;
}

# @category Geometry
# Ambient dimension of the point configuration (without the homogenization coordinate).
# Similar to [[Polytope::AMBIENT_DIM]].
# @return Int
user_method AMBIENT_DIM() : VECTOR_AMBIENT_DIM {
   return $_[0]->VECTOR_AMBIENT_DIM-1;
}

# @category Geometry
# True if the point configuration is bounded.
property BOUNDED : Bool;


# @category Geometry
# Number of [[POINTS]].
property N_POINTS = override N_VECTORS;


# @category Geometry
# True if the [[POINTS]] are in convex position.
property CONVEX : Bool;

# @category Geometry
# [[POINTS]] that are not [[Polytope::VERTICES]] of the [[CONVEX_HULL]]
property NON_VERTICES : Set;

# @category Geometry
# Indices of [[Polytope::VERTICES]] of the [[CONVEX_HULL]] as [[POINTS]]
property VERTEX_POINT_MAP : Array<Int>;


# @category Geometry
# Dual basis of the affine hull of the point configuration
property AFFINE_HULL : Matrix<Scalar>;

# @category Combinatorics
# Graph of the point configuration.
# Two points are adjacent if they are neigbours in a edge of the [[CONVEX_HULL]].
property GRAPH : Graph;


# @category Geometry
# Indices of [[POINTS]] that are rays.
property FAR_POINTS : Set;

# @category Geometry
# The center of gravity of the point configuration.
property BARYCENTER : Vector<Scalar>;

# @category Geometry
# True if (1, 0, 0, ...) is in the relative interior.
property CENTERED : Bool;


# @category Triangulation and volume
# Some triangulation of the point configuration.
property TRIANGULATION : topaz::GeometricSimplicialComplex<Scalar> : multiple {

   # @category Triangulation and volume
   # The splits that are coarsenings of the current [[TRIANGULATION]].
   # If the triangulation is regular these form the unique split decomposition of
   # the corresponding weight function.
   property REFINED_SPLITS : Set<Int>;
   
   # @category Triangulation and volume
   # GKZ-vector
   # 	See Chapter 7 in Gelfand, Kapranov, and Zelevinsky:
   # 	Discriminants, Resultants and Multidimensional Determinants, Birkhäuser 1994
   property GKZ_VECTOR : Vector<Scalar>;

   # @category Triangulation and volume
   # Weight vector to construct a regular [[TRIANGULATION]].
   # Must be generic.
   property WEIGHTS : Vector<Scalar>;
   
   # @category Triangulation and volume
   # Calculate the massive GKZ vectors of the triangulations of a integral PointConfiguration //A//.
   # For a definition see Chapter 11 of Gelfand, Kapranov, and Zelevinsky: Discriminants, Resultants and Multidimensional Determinants, Birkhäuser 1994.
   # @param PointConfiguration<Rational> A the integral point configuration
   # @return Vector<Integer>
   # @example To calculate the massive GKZ vector of a triangulation of a point configuration.
   # This example is from the book mentioned above (p. 369, top right example).
   # > $A=new PointConfiguration(POINTS=>[[1,0,0],[1,1,0],[1,2,0],[1,3,0],[1,0,1],[1,1,1],[1,0,2]]);
   # > $A->add("TRIANGULATION", WEIGHTS=>[0,1,0,1,1,1,0]);
   # > print $A->TRIANGULATION->MASSIVE_GKZ_VECTOR;
   # | 1 0 3 1 0 0 4
   property MASSIVE_GKZ_VECTOR : Vector<Scalar>;

}

# @category Triangulation and volume
# boundary complex of the triangulation
property TRIANGULATION.BOUNDARY {

   # @category Triangulation and volume
   # DOC_FIXME: Incomprehensible description!
   # For each facet the set of simplex indices of BOUNDARY that triangulate it.
   property FACET_TRIANGULATIONS : Array<Set>;
}


# @category Combinatorics
# The splits of the point configuration, i.e., hyperplanes cutting the configuration in
# two parts such that we have a regular subdivision.
property SPLITS : Matrix<Scalar>;

# @category Combinatorics
# Two [[SPLITS]] are compatible if the defining hyperplanes do not intersect in the
# interior of the point configuration.  This defines a graph.
property SPLIT_COMPATIBILITY_GRAPH : Graph;


# @category Visualization
# [[Polytope::VIF_CYCLIC_NORMAL]] of the [[CONVEX_HULL]], but with
# the indices form [[POINTS]] instead of [[Polytope::VERTICES]]
property PIF_CYCLIC_NORMAL : Array<Array<Int>>;

}

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