package biduledres;


public class Main {
    public static void printUsage() {
        System.out.println("usage: java biduledres.Main n (n nombre de rabotages à effectuer sur le tétraèdre de départ.");
    }
    
    public static void main(String[] args) {
        int nRabotages = 0;
        try {
            nRabotages = Integer.parseInt(args[0]);
        } catch (NumberFormatException e) {
            printUsage();
        } catch (ArrayIndexOutOfBoundsException e) {
            printUsage();
        }
        
        SommetPrimitif a = new SommetPrimitif("A");
        SommetPrimitif b = new SommetPrimitif("B");
        SommetPrimitif c = new SommetPrimitif("C");
        SommetPrimitif d = new SommetPrimitif("D");

        // on pourrait aussi instancier un Biduledre...
        Tetraedre t = new Tetraedre(a, b, c, d);
        
        Espace espace = new Espace(3);
        try {
            espace.setPosition(a, new SommetSpatial(new double[] {0, 0, 1}));
            espace.setPosition(b, new SommetSpatial(new double[] {1, 0 , 0}));
            espace.setPosition(c, new SommetSpatial(new double[] {-0.5, Math.sin(2 * Math.PI / 3), 0}));
            espace.setPosition(d, new SommetSpatial(new double[] {-0.5, -Math.sin(2 * Math.PI / 3), 0}));
        } catch (ExceptionPositionInvalide ex) {
            System.out.println("Pas le même nombre de dimensions: " + ex.getNombreDimensionsSommetSpatial() + " != " + ex.getNombreDimensionsEspace());
        }
        Polyedre p = UsinePolyedre.getNieme(t, nRabotages);
        PolyedreSpatial ps = new PolyedreSpatial(p, espace);
        System.out.println(ps.toXML());
        FramePolyedre frame = new FramePolyedre(ps); 
        frame.show();
    }
}
