/* main.c * * Created by Rory Healy (healyr@student.unimelb.edu.au) * Created on 25th August 2021 * Last modified 9th September 2021 * * Lists the watchtowers that are in each face of the polygon. * The polygon can be split using a pair of integers, which represent * the edge numbers that should be connected. This comes from stdin. * * To see valid input arguments, run ./voronoi2 * */ #ifndef VORONOI_HEADER #include "voronoi.h" #endif #ifndef INPUT_HEADER #include "input.h" #endif int main(int argc, char **argv) { /* Ensure input arguments are correct */ if (argc == 1) { printArgError(STAGE_ERROR, "Incorrect usage."); } enum stages stage = getStage(argv[1]); int expectedArgs = getExpectedArgs(stage); if (expectedArgs != argc) { printArgError(stage, "Incorrect number of inputs."); } /* Then run the program according to the stage given */ switch(stage) { /* Expected usage: ./voronoi2 1 pointsFile outputFile */ case STAGE_1: stage1(argv[2], argv[3]); break; /* Expected usage: ./voronoi2 2 pointsFile polygonFile outputFile */ case STAGE_2: stage2(argv[2], argv[3], argv[4]); break; /* Expected usage: ./voronoi2 3 dataFile polygonFile outputFile */ case STAGE_3: stage3(argv[2], argv[3], argv[4]); break; /* Expected usage: /voronoi2 4 dataFile polygonFile outputFile */ case STAGE_4: stage4(argv[2], argv[3], argv[4]); break; /* Return error if stage number isn't defined. */ case STAGE_ERROR: default: printArgError(stage, "Invalid stage entered."); exit(EXIT_FAILURE); } return 0; }