/* Copyright (c) 1997-2010
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
   http://www.polymake.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: k_skeleton.cc 9991 2010-12-12 23:36:28Z gawrilow $
*/

#include "polymake/client.h"
#include "polymake/topaz/complex_tools.h"
#include "polymake/Rational.h"
#include "polymake/Matrix.h"

namespace polymake { namespace topaz {
  
perl::Object k_skeleton_client(perl::Object p_in, const int k, perl::OptionSet options)
{
   const Array< Set<int> > C = p_in.give("FACETS");
   const PowerSet<int> Skeleton = k_skeleton(C,k);
   
   // no adjusting of vertices required
   perl::Object p_out("SimplicialComplex");
   p_out.set_description() << k << "-skeleton of " << p_in.name() << endl;
   p_out.take("FACETS") << Skeleton;

   Matrix<Rational> GR;
   if (p_in.lookup("GEOMETRIC_REALIZATION") >> GR)
      p_out.take("GEOMETRIC_REALIZATION") << GR;

   if (!options["nol"]) {
      const Array<std::string> L = p_in.give("VERTEX_LABELS");
      p_out.take("VERTEX_LABELS") << L;
   }

   return p_out;
}

UserFunction4perl("# @category Producing a new simplicial complex from others\n"
                  "# Produce the //k//-skeleton.\n"
                  "# @param SimplicialComplex complex"
                  "# @param int k"
                  "# @option Bool nol suppresses creation of [[VERTEX_LABELS]]"
                  "# @return SimplicialComplex",
                  &k_skeleton_client, "k_skeleton(SimplicialComplex $ { nol=>0 })");
} }

// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
