From 37d4e6f7388e8f22ba9ede499d7615d1fd2954de Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 16 Aug 2003 01:38:22 +0000 Subject: [PATCH] - Various tweaks to make the code build with gcc-2.95 under linux. - added a -n option to specify a minimum number of nodes to emit irregardless of the error threshold. --- src/Prep/Terra/GreedyInsert.cc | 3 +- src/Prep/Terra/Makefile-gcc-2.95 | 89 ++++++++++++++++++++++++++++++++ src/Prep/Terra/Vec2.h | 2 + src/Prep/Terra/cmdline.cc | 13 ++++- src/Prep/Terra/glHacks.h | 2 + src/Prep/Terra/greedy.cc | 7 ++- src/Prep/Terra/gui.cc | 4 ++ src/Prep/Terra/terra.h | 1 + 8 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/Prep/Terra/Makefile-gcc-2.95 diff --git a/src/Prep/Terra/GreedyInsert.cc b/src/Prep/Terra/GreedyInsert.cc index 1626f4df..893baeab 100644 --- a/src/Prep/Terra/GreedyInsert.cc +++ b/src/Prep/Terra/GreedyInsert.cc @@ -209,7 +209,8 @@ Edge *GreedySubdivision::select(int sx, int sy, Triangle *t) is_used(sx,sy) = DATA_POINT_USED; count++; - return insert(Vec2(sx,sy), t); + Vec2 tmp(sx,sy); + return insert(tmp, t); } diff --git a/src/Prep/Terra/Makefile-gcc-2.95 b/src/Prep/Terra/Makefile-gcc-2.95 new file mode 100644 index 00000000..07b70a3b --- /dev/null +++ b/src/Prep/Terra/Makefile-gcc-2.95 @@ -0,0 +1,89 @@ +################################################################# +# +# Configuration variables. +# You should change these to fit your system. +# + +CC = cc +C++ = g++-2.95 + +# For compiling on SGI's with the pre-5.3 (ie. cfront-based) compiler: +# add '-ptr/tmp/terra_ptrepository' to OPTFLAGS +# add '-pte.cc' to LFLAGS + +OPTFLAGS = -O2 -g +#OPTFLAGS = -g -mips2 +# OPTFLAGS = -O2 -mips2 + +GUI_LIBS = -lglut -lGLU -lGL -L/usr/X11R6/lib -lXmu -lX11 +LIBS = + +# +# This defines the location of the GLUT libraries +# +ANIM = /afs/cs/project/anim/garland +GLUT_FLAGS = +GLUT_INCDIR = $(ANIM)/include +GLUT_LIBDIR = $(ANIM)/lib + +# +# Include any other search directories you need here +# +INCDIR = -I$(GLUT_INCDIR) +LIBDIR = -L$(GLUT_LIBDIR) + +# +# These are the flags for compilation (CFLAGS) and linking (LFLAGS) +# +# CFLAGS = $(INCDIR) $(OPTFLAGS) -DSAFETY +CFLAGS = $(INCDIR) $(OPTFLAGS) -DSAFETY -DIOSTREAMH +LFLAGS = $(LIBDIR) $(OPTFLAGS) + + +################################################################# +# +# Rules for building the Terra programs. +# You should not need to change anything here. +# + +.SUFFIXES: .cc +.cc.o: + $(C++) $(CFLAGS) -c $< + +.C.o: + $(C++) $(CFLAGS) -c $< + + +BASE_SRCS = Quadedge.cc Subdivision.cc Map.cc Mask.cc cmdline.cc \ + GreedyInsert.cc Heap.cc greedy.cc output.cc +GUI_SRCS = glHacks.cc gui.cc xterra.cc + +TERRA_SRCS = terra.cc $(BASE_SRCS) +XTERRA_SRCS = $(GUI_SRCS) $(BASE_SRCS) + +TERRA_OBJS = $(TERRA_SRCS:.cc=.o) +XTERRA_OBJS = $(XTERRA_SRCS:.cc=.o) + + +TARGETS = terra xterra + +all: $(TARGETS) + +terra: $(TERRA_OBJS) + $(C++) $(LFLAGS) -o terra $(TERRA_OBJS) $(LIBS) + +xterra: $(XTERRA_OBJS) + $(C++) $(LFLAGS) -o xterra $(XTERRA_OBJS) $(GUI_LIBS) $(LIBS) + +clean : + /bin/rm -f $(XTERRA_OBJS) $(TERRA_OBJS) $(TARGETS) + /bin/rm -f -r ii_files ptrepository + find . -name '*~' -print -exec rm -f {} \; + find . -name 'core' -print -exec rm -f {} \; + +depend : + touch Makefile.depend + makedepend -fMakefile.depend $(INCDIR) -I/usr/include/CC $(BASE_SRCS) $(GUI_SRCS) + /bin/rm -f Makefile.depend.bak + +sinclude Makefile.depend diff --git a/src/Prep/Terra/Vec2.h b/src/Prep/Terra/Vec2.h index 4bbc31a2..85230dfc 100644 --- a/src/Prep/Terra/Vec2.h +++ b/src/Prep/Terra/Vec2.h @@ -1,6 +1,8 @@ #ifndef VEC2_INCLUDED // -*- C++ -*- #define VEC2_INCLUDED +#include + class Vec2 { protected: real elt[2]; diff --git a/src/Prep/Terra/cmdline.cc b/src/Prep/Terra/cmdline.cc index fa319b53..dba88b7c 100644 --- a/src/Prep/Terra/cmdline.cc +++ b/src/Prep/Terra/cmdline.cc @@ -1,3 +1,4 @@ +#include #include #include #include @@ -11,6 +12,7 @@ ImportMask *MASK; real error_threshold = 0.0; +int min_points = -1; int point_limit = -1; real height_scale = 1.0; FileFormat output_format; @@ -18,10 +20,11 @@ char *output_filename = NULL; char *mask_filename = NULL; char *script_filename = NULL; -static char *options = "e:p:h:o:m:s:"; +static char *options = "e:n:p:h:o:m:s:"; static char *usage_string = "-e Sets the tolerable error threshold\n" +"-n Sets the *minimum* number of points regardless of \n" "-p Sets the maximum number of allowable points\n" "-h Sets the height scaling factor. For example,\n" " if grid points are 25m apart, use a factor of 0.04\n" @@ -59,6 +62,11 @@ void process_cmdline(int argc, char **argv) cerr << " Setting error threshold to " <width * DEM->height; diff --git a/src/Prep/Terra/glHacks.h b/src/Prep/Terra/glHacks.h index 8074ccb2..7750b205 100644 --- a/src/Prep/Terra/glHacks.h +++ b/src/Prep/Terra/glHacks.h @@ -1,6 +1,8 @@ #ifndef GLHACKS_INCLUDED // -*- C++ -*- #define GLHACKS_INCLUDED +#include + #include #include #include diff --git a/src/Prep/Terra/greedy.cc b/src/Prep/Terra/greedy.cc index 8a896643..a37e8407 100644 --- a/src/Prep/Terra/greedy.cc +++ b/src/Prep/Terra/greedy.cc @@ -63,8 +63,11 @@ void subsample_insertion(int target_width) inline int goal_not_met() { - return mesh->maxError() > error_threshold && - mesh->pointCount() < point_limit; + return + ( mesh->maxError() > error_threshold && + mesh->pointCount() < point_limit ) || + mesh->pointCount() < min_points; + } static void announce_goal() diff --git a/src/Prep/Terra/gui.cc b/src/Prep/Terra/gui.cc index 7eaff3d4..291e2b6b 100644 --- a/src/Prep/Terra/gui.cc +++ b/src/Prep/Terra/gui.cc @@ -433,12 +433,15 @@ void gui_interact() // //////////////////////////////////////////////////////////////////////// +#if 0 extern "C" { #include } +#endif void xglutKeepAspect(float width, float height) { +#if 0 Window win; XSizeHints hints; @@ -453,4 +456,5 @@ void xglutKeepAspect(float width, float height) XSetWMNormalHints(__glutDisplay, win, &hints); } +#endif } diff --git a/src/Prep/Terra/terra.h b/src/Prep/Terra/terra.h index 62a15041..1b9296c3 100644 --- a/src/Prep/Terra/terra.h +++ b/src/Prep/Terra/terra.h @@ -11,6 +11,7 @@ extern Map *DEM; extern ImportMask *MASK; extern real error_threshold; +extern int min_points; extern int point_limit; extern real height_scale; enum FileFormat {NULLfile, TINfile, EPSfile, DEMfile, OBJfile, RMSfile};