Skip to content
Snippets Groups Projects
Commit 04045bae authored by mika's avatar mika
Browse files

seg fault fix

parent 8f4e6dc1
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <time.h>
/* Image parameters */
#define W 1000
......@@ -59,21 +60,29 @@ int main(int argc, char *argv[]) {
//create_image();
//write_ppm ( "sine.ppm" );
int numberOfPoints = 10;
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
printf("%d\n", RAND_MAX);
if(argc > 0) {
//printf("%s\n", argv[0]);
}
//printf("%d\n", argc);
if(argc == 2) {
//printf("%s\n", argv[1]);
numberOfPoints = atoi(argv[1]);
}
//puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
//printf("%d\n", RAND_MAX);
vertex points[numberOfPoints];
generatePoints(points, numberOfPoints);
drawPoints(points, numberOfPoints);
for(int i = 0; i < numberOfPoints; i++) {
printf("%f, %f\n", points[i].x, points[i].y);
//printf("%f, %f\n", points[i].x, points[i].y);
}
FILE *out = fopen ( "delaunay.html", "w" );
writeSvgStart ( out );
delaunayCws(points, numberOfPoints, out);
writeSvgEnd ( out );
fclose(out);
readFile("test.txt", "r");
//readFile("test.txt", "r");
return EXIT_SUCCESS;
}
......@@ -262,7 +271,7 @@ circle circle_vvv(vertex v1, vertex v2, vertex v3)
printf("%f, %f - %f, %f - %f, %f\n", triangle.a.x, triangle.a.y, triangle.b.x, triangle.b.y, triangle.c.x, triangle.c.y);
}*/
void printPoint(vertex point) {
printf("%f, %f\n", point.x, point.y);
//printf("%f, %f\n", point.x, point.y);
}
void generatePoints(vertex points[], int sizeOfPoints) {
......@@ -289,7 +298,7 @@ void readFile(char* location, char* rw){
f=fopen("test.txt","rt");
while((c=fgetc(f))!=EOF){
printf("%c",c);
//printf("%c",c);
}
fclose(f);
......@@ -458,19 +467,19 @@ void delaunayCws(vertex* S, int size, FILE *out) {
/*if(k == j1) {
break;
}*/
printf("%d, %d, %d, %d\n", i, j, k, isTriangle);
//printf("%d, %d, %d, %d\n", i, j, k, isTriangle);
if(i < j && i < k) {
if(isTriangle == 2){
vertex tri[3] = {S[i], S[j], S[k]};
reportTriangle(tri, 3, out);
}
}
printf("j = %d, k = %d\n", j, k);
//printf("j = %d, k = %d\n", j, k);
//printf("jAlreadyUsed = ");
/*for(int a = 0; a < numberOfJ; a++) {
printf("%d, ", jAlreadyUsed[a]);
}*/
printf("\n");
//printf("\n");
//j1 = j;
j = k;
} while(/*!arrayContains(jAlreadyUsed, numberOfJ, j)*/ j != j0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment