diff --git a/src/dwyer.c b/src/dwyer.c index 9cdc0e4d15f716c605ffd94929832eb591bd9d70..17d244df77467e1770d1ba8fa66ea63b87b63dd0 100644 --- a/src/dwyer.c +++ b/src/dwyer.c @@ -55,9 +55,9 @@ typedef int EDGE_PTR; typedef unsigned short VERTEX_PTR; -struct VEC2 { +/*struct VEC2 { double x,y; -}; +};*/ struct VERTEX { struct VEC2 v; @@ -533,8 +533,11 @@ else { /* Quicksort */ /* plots a site on your favorite device. */ plot_site(v) VERTEX_PTR v; { +#ifdef POSTSCRIPT + printf("p%d drawsite\n", v); +#endif #ifdef OUTPUTFILE - fprintf(out, "p%d drawsite\n", v); + svgDrawSite(va[v].v); #endif } @@ -545,6 +548,9 @@ plot_dt_edge(e) #ifdef POSTSCRIPT printf("p%d p%d drawseg\n", orig(e), dest(e)); #endif +#ifdef OUTPUTFILE + svgDrawLine(va[orig(e)].v, va[dest(e)].v); +#endif } BOOLEAN forward(e, base) @@ -727,6 +733,9 @@ struct VEC2 v1, v2; #ifdef POSTSCRIPT printf("%f %f %f %f drawline\n", v1.x, v1.y, v2.x, v2.y); #endif +#ifdef OUTPUTFILE + svgDrawLine(v1, v2); +#endif } plot_infinite_vd_edge(e) @@ -1114,6 +1123,9 @@ EDGE_PTR e; #ifdef POSTSCRIPT printf("p%d p%d drawseg\n", orig(e), dest(e)); #endif +#ifdef OUTPUTFILE + svgDrawLine(va[orig(e)].v, va[dest(e)].v); +#endif } dumpedge(e) EDGE_PTR e; diff --git a/src/helper.c b/src/helper.c index cfbf2ad3c06fd00f575cb611559a8a72bf5b7726..86e2cc15795784048465deb15662f2ce8237ee26 100644 --- a/src/helper.c +++ b/src/helper.c @@ -7,9 +7,11 @@ #include "helper.h" -void svgDrawLine(edge l, char *color) { + + +void svgDrawLine(vertex a, vertex b) { #ifdef OUTPUTFILE - fprintf(out, "<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:rgb(%s);stroke-width:1\" />\n", l.a.x*W, l.a.y*H, l.b.x*W, l.b.y*H, color); + fprintf(out, "<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:purple;stroke-width:1\" />\n", a.x*W, a.y*H, b.x*W, b.y*H); #endif } @@ -27,7 +29,7 @@ void svgDrawTriangle(vertex a, vertex b, vertex c) { void svgDrawSite(vertex v) { #ifdef OUTPUTFILE - fprintf(out, "<circle cx=\"%f\" cy=\"%f\" r=\"%f\" stroke=\"black\" stroke-width=\"1\" fill=\"black\" />", v.x*W, v.y*H, 2); + fprintf(out, "<circle cx=\"%f\" cy=\"%f\" r=\"%f\" stroke=\"black\" stroke-width=\"1\" fill=\"black\" />", v.x*W, v.y*H, 2.0); #endif } diff --git a/src/helper.h b/src/helper.h index 581f2f955e593a70bfc702da460722bdd47d70fd..18a90467edbf66195262082a2171fd3db3a0490b 100644 --- a/src/helper.h +++ b/src/helper.h @@ -8,13 +8,19 @@ #ifndef HELPER_H_ #define HELPER_H_ +#define OUTPUTFILE "output.html" + #include <stdio.h> -#define W 1000 -#define H 1000 -#define M 255 +#define W 2000 +#define H 2000 -typedef struct { +#ifdef OUTPUTFILE +FILE *out; +#endif + + +typedef struct VEC2{ double x, y; } vertex; @@ -22,7 +28,7 @@ typedef struct { vertex a; vertex b; vertex c; -}; +} blub; typedef struct { vertex center; @@ -36,8 +42,9 @@ typedef struct { void writeSvgStart (); void writeSvgEnd (); -void svgDrawLine(edge, char *); +void svgDrawLine(vertex, vertex); void svgDrawCircle(circle); void svgDrawTriangle(vertex, vertex, vertex); +void svgDrawSite(vertex); #endif /* HELPER_H_ */ diff --git a/src/main.c b/src/main.c index 28982b32de4c61af67acc19c9f8bc931db99fabc..324d2894d5944aac7fdf43d7db1db8610d9b309c 100644 --- a/src/main.c +++ b/src/main.c @@ -5,21 +5,16 @@ * Author: Mika */ -#define OUTPUTFILE "output.html" +#include "main.h" -#include "delaunay.h" -#include "voronoi.h" -#ifdef OUTPUTFILE -FILE *out; -#endif int main(int argc, char *argv[]) { //input: 1. function 0=cws_delaunay 2. # of points, 3. # of executions //create_image(); //write_ppm ( "sine.ppm" ); - int numberOfPoints = 10000; - int function = 0; + int numberOfPoints = 20; + int function = 2; int executions = 1; if(argc > 0) { //printf("%s\n", argv[0]); @@ -33,7 +28,7 @@ int main(int argc, char *argv[]) { vertex points[numberOfPoints]; generatePoints(points, numberOfPoints); - printf("%u\n", sizeof(points)); + printf("%lu\n", sizeof(points)); fflush(stdout); //drawPoints(points, numberOfPoints); diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000000000000000000000000000000000000..f05d20a372754b890dd909f20b753e752eb1e236 --- /dev/null +++ b/src/main.h @@ -0,0 +1,16 @@ +/* + * main.h + * + * Created on: Dec 5, 2018 + * Author: mika + */ + +#ifndef MAIN_H_ +#define MAIN_H_ + +#include "delaunay.h" +#include "voronoi.h" +#include "helper.h" + + +#endif /* MAIN_H_ */ diff --git a/src/voronoi.c b/src/voronoi.c index 8d867b54a2d4317f4c427821a098eb91db5c48f9..338bf89715362a7a82c003b5b23f6161b5f39738 100644 --- a/src/voronoi.c +++ b/src/voronoi.c @@ -13,11 +13,10 @@ circle center(vertexCircle vc) { circle c = circleFrom3Points(vc.a, vc.b, vc.c); return c; } -int reportEdge(edge l) { +int reportEdge(vertex a, vertex b) { //svgDrawCircle(a,out); //svgDrawCircle(b,out); - char *color = "0,0,255"; - svgDrawLine(l, color); + svgDrawLine(a, b); return 0; } @@ -91,12 +90,12 @@ void voronoiCws(vertex* S, int size) { } else { if(!outOfBorder(currentV)) { #ifdef OUTPUTFILE - reportEdge((edge){currentV, lastV}, out); + reportEdge(currentV, lastV); #endif } if(k == j0) { #ifdef OUTPUTFILE - reportEdge((edge){currentV, firstV}); + reportEdge(currentV, firstV); #endif } } @@ -110,14 +109,14 @@ void voronoiCws(vertex* S, int size) { } else { if(!outOfBorder(lastV)) { #ifdef OUTPUTFILE - reportEdge((edge){currentV, lastV}, out); + reportEdge(currentV, lastV); #endif } } currentV = findBorderVertex(S[i], S[k]); if(k == j0) { if(!outOfBorder(firstV)) { - reportEdge((edge){currentV, firstV}); + reportEdge(currentV, firstV); } } } diff --git a/src/voronoi.h b/src/voronoi.h index 4723923699629aa272d0d0b90b7a435b219bb0e4..5f8a6a1b043b1da364a48dbc17dc7c0c6e6fde68 100644 --- a/src/voronoi.h +++ b/src/voronoi.h @@ -9,6 +9,7 @@ #define SRC_VORONOI_H_ #include "delaunay.h" +#include "helper.h" /** @@ -50,7 +51,7 @@ edgeCircle clockwiseNextVoronoiEdge(edgeCircle e); */ edgeCircle nextVoronoiEdgeOnBoudary(edgeCircle e); -int reportEdge(edge l); +int reportEdge(vertex, vertex); void voronoiCws(vertex* S, int size);