2021-09-09 17:10:24 +10:00
|
|
|
#ifndef DCEL_HEADER
|
|
|
|
#include "dcel.h"
|
|
|
|
#endif
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
#ifndef VORONOI_HEADER
|
|
|
|
#define VORONOI_HEADER
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 21:23:53 +10:00
|
|
|
typedef struct tower {
|
|
|
|
char *id;
|
|
|
|
char *postcode;
|
|
|
|
char *manager;
|
|
|
|
int population;
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
} tower_t;
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
/* Reads the CSV file and stores the information in the towers array */
|
|
|
|
tower_t **readTowers(tower_t **towers, FILE *datasetFile, int *numTowers);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 21:23:53 +10:00
|
|
|
/* Reads the current row from the CSV and converts it into a new tower */
|
2021-09-09 17:10:24 +10:00
|
|
|
void readCurrentTower(char *lineBuffer, tower_t *tower);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 21:23:53 +10:00
|
|
|
/* Frees all towers in a towers array */
|
2021-09-09 17:10:24 +10:00
|
|
|
void freeTowers(tower_t **towers, int numTowers);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
/* Reads a points file and stores the information in the points array */
|
|
|
|
vertex_t **readPoints(vertex_t **points, FILE *pointsFile, int *numPoints);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 21:23:53 +10:00
|
|
|
/* Frees all points from a points array */
|
|
|
|
void freePoints(vertex_t **points, int numPoints);
|
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
/* Outputs the bisector equations from pointsFile into outputFile */
|
|
|
|
void stage1(char *pointsFileName, char *outputFileName);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
/* Outputs the intersections the bisectors make with the polygon */
|
|
|
|
void stage2(char *pointsFileName, char *polygonFileName, char *outputFileName);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
2021-09-09 17:10:24 +10:00
|
|
|
/* Constructs a Voronoi diagram and prints the resulting diameters */
|
|
|
|
void stage3(char *dataFileName, char *polygonFileName, char *outputFileName);
|
|
|
|
|
|
|
|
/* Same as stage3, but prints diameters in ascending order */
|
|
|
|
void stage4(char *dataFileName, char *polygonFileName, char *outputFileName);
|
2021-09-08 21:48:00 +10:00
|
|
|
|
|
|
|
#endif
|