#!/usr/bin/polymake --script

# Simplify simplicial complex using edge contractions and bistellar flips

use application "topaz";
use strict;
use warnings;

#require "./lib.pl"; # load common functions


my $outpath="K3";

if (! -d $outpath ) { 
        mkdir $outpath;
}

my $regdesc=shift;



my $q=load_data("akbulut-kirby/AK_poly/K3_17.poly");


#$q=edge_contraction($q);

$q=bistellar_simplification(barycentric_subdivision($q));

my $vert = @{$q->F_VECTOR}[0];

if (! -d "$outpath/$vert") {
        mkdir "$outpath/$vert";
}

save($q, "$outpath/$vert/$regdesc.poly");
