From 651274dc0845b6f1a5922268b479ab1c9b41c0e6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Jan 2008 02:07:02 +0000 Subject: [PATCH] rename things more sensibly; now it can optimise but the edgewise vertex formula is bad --- .bzrignore | 6 ++---- Makefile | 16 ++++++++-------- energy.c | 19 ++++++++++++------- mgraph.h | 4 ++-- approxmodel => oldmoebius-converter | 0 generator => sgtatham-regenerator | 0 6 files changed, 24 insertions(+), 21 deletions(-) rename approxmodel => oldmoebius-converter (100%) rename generator => sgtatham-regenerator (100%) diff --git a/.bzrignore b/.bzrignore index 098b20b..6c387ea 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,12 +1,10 @@ minimise primer -initial view -best *.d *.tmp *.new core vgcore.* -lumpy -prime +prime.data +*.cfm diff --git a/Makefile b/Makefile index a4b09dc..4726f04 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -TARGETS= minimise primer initial view +TARGETS= minimise primer view lumpy.cfm sgtatham.cfm CWARNS= -Wall -Wwrite-strings -Wpointer-arith -Werror -Wshadow CXXWARNS= $(CWARNS) -Wno-shadow -Wno-error @@ -17,24 +17,24 @@ all: $(TARGETS) minimise: energy.o bgl.o common.o mgraph.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBGSL) -prime: primer - ./$^ $o - primer: primer.o common.o $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) +prime.data: primer + ./$^ $o + view: view.o common.o mgraph.o $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11 -sgtatham: generator prime sgtatham/z.typescript +sgtatham.cfm: sgtatham-regenerator prime.data sgtatham/z.typescript ./$^ -T -o$@ -lumpy: approxmodel prime ../moebius/ins-new ../moebius/a.out +lumpy.cfm: oldmoebius-converter prime.data ../moebius/ins-new ../moebius/a.out ./$^ -o$@ clean: - rm -f *.o $(TARGETS) *.new *.tmp *.rej *.orig core vgcore.* - rm -f initial + rm -f prime.data $(TARGETS) + rm -f *.o *.new *.tmp *.rej *.orig core vgcore.* *~ rm -f *.d realclean: clean diff --git a/energy.c b/energy.c index d673c14..54c73fa 100644 --- a/energy.c +++ b/energy.c @@ -9,8 +9,8 @@ #include #include -#define BEST_F "best" -#define INITIAL_F "initial" +static const char *input_file, *output_file; +static char *output_file_tmp; static double edgewise_vertex_displacement_cost(const Vertices vertices); static double noncircular_rim_cost(const Vertices vertices); @@ -41,10 +41,10 @@ static double compute_energy(const Vertices vertices) { printf(" BEST"); - best_f= fopen(BEST_F ".new","wb"); if (!best_f) diee("fopen new best"); + best_f= fopen(output_file_tmp,"wb"); if (!best_f) diee("fopen new out"); r= fwrite(vertices,sizeof(Vertices),1,best_f); if (r!=1) diee("fwrite"); if (fclose(best_f)) diee("fclose new best"); - if (rename(BEST_F ".new", BEST_F)) diee("rename install new best"); + if (rename(output_file_tmp,output_file)) diee("rename install new best"); best_energy= energy; } @@ -129,7 +129,12 @@ int main(int argc, const char *const *argv) { gsl_vector initial_gsl, step_size_gsl; int r, v, k; - if (argc>1) { fputs("takes no arguments\n",stderr); exit(8); } + if (argc!=3 || argv[1][0]=='-' || strncmp(argv[2],"-o",2)) + { fputs("usage: minimise -o