Ticket #43154: terra.patches

File terra.patches, 13.2 KB (added by lockhart (Thomas Lockhart), 10 years ago)

Patches to compile with newer compilers and fix mesh window display and resizing issue.

Line 
1diff -u ../terra.orig/Array.h ./Array.h
2--- ../terra.orig/Array.h       1995-12-19 11:24:31.000000000 -0800
3+++ ./Array.h   2014-03-18 15:04:25.000000000 -0700
4@@ -1,6 +1,9 @@
5 #ifndef ARRAY_INCLUDED // -*- C++ -*-
6 #define ARRAY_INCLUDED
7 
8+#include <memory.h>
9+
10+
11 //
12 // Array classes
13 //
14diff -u ../terra.orig/GreedyInsert.cc ./GreedyInsert.cc
15--- ../terra.orig/GreedyInsert.cc       1996-01-19 09:07:18.000000000 -0800
16+++ ./GreedyInsert.cc   2014-03-18 15:17:36.000000000 -0700
17@@ -1,9 +1,11 @@
18-#include <iostream.h>
19+#include <iostream>
20 #include "GreedyInsert.h"
21-
22+#include <assert.h>
23 #include "Mask.h"
24 extern ImportMask *MASK;
25 
26+using namespace std;
27+
28 void TrackedTriangle::update(Subdivision& s)
29 {
30     GreedySubdivision& gs = (GreedySubdivision&)s;
31@@ -209,7 +211,11 @@
32 
33     is_used(sx,sy) = DATA_POINT_USED;
34     count++;
35+#if 0
36     return insert(Vec2(sx,sy), t);
37+#endif
38+    Vec2 vec(sx,sy);
39+    return insert(vec, t);
40 }
41 
42 
43Only in .: GreedyInsert.o
44diff -u ../terra.orig/Heap.cc ./Heap.cc
45--- ../terra.orig/Heap.cc       1996-01-09 13:19:08.000000000 -0800
46+++ ./Heap.cc   2014-03-18 15:04:25.000000000 -0700
47@@ -1,7 +1,9 @@
48 #include <assert.h>
49-#include <iostream.h>
50+#include <iostream>
51 #include "Heap.h"
52 
53+using namespace std;
54+
55 
56 void Heap::swap(int i,int j)
57 {
58Only in .: Heap.o
59diff -u ../terra.orig/Makefile ./Makefile
60--- ../terra.orig/Makefile      1996-01-30 08:35:20.000000000 -0800
61+++ ./Makefile  2014-03-18 16:52:05.000000000 -0700
62@@ -4,23 +4,24 @@
63 # You should change these to fit your system.
64 #
65 
66-CC = cc
67-C++ = CC
68+CC = gcc
69+C++ = g++
70 
71 # For compiling on SGI's with the pre-5.3 (ie. cfront-based) compiler:
72 # add '-ptr/tmp/terra_ptrepository' to OPTFLAGS
73 # add '-pte.cc' to LFLAGS
74 
75-OPTFLAGS = -g -mips2
76+# OPTFLAGS = -g -mips2
77 # OPTFLAGS = -O2 -mips2
78+OPTFLAGS = -g -Wall
79 
80 GUI_LIBS = -lglut -lGLU -lGL -lXmu -lX11
81-LIBS = -lmalloc -lmx
82+LIBS = # -lmalloc -lmx
83 
84 #
85 # This defines the location of the GLUT libraries
86 #
87-ANIM = /afs/cs/project/anim/garland
88+ANIM = /opt/local
89 GLUT_FLAGS = 
90 GLUT_INCDIR = $(ANIM)/include
91 GLUT_LIBDIR = $(ANIM)/lib
92@@ -34,7 +35,7 @@
93 #
94 # These are the flags for compilation (CFLAGS) and linking (LFLAGS)
95 #
96-CFLAGS = $(INCDIR) $(OPTFLAGS) -DSAFETY
97+CFLAGS = $(INCDIR) $(OPTFLAGS) -DIOSTREAMH # -DSAFETY
98 LFLAGS = $(LIBDIR) $(OPTFLAGS)
99 
100 
101@@ -81,7 +82,7 @@
102 
103 depend :
104        touch Makefile.depend
105-       makedepend -fMakefile.depend $(INCDIR) -I/usr/include/CC $(BASE_SRCS) $(GUI_SRCS)
106+       makedepend -fMakefile.depend $(INCDIR) $(BASE_SRCS) $(GUI_SRCS)
107        /bin/rm -f Makefile.depend.bak
108 
109 sinclude Makefile.depend
110diff -u ../terra.orig/Map.h ./Map.h
111--- ../terra.orig/Map.h 1996-01-30 08:35:21.000000000 -0800
112+++ ./Map.h     2014-03-18 15:09:08.000000000 -0700
113@@ -2,10 +2,13 @@
114 #define MAP_INCLUDED
115 
116 #include <stdlib.h>
117-#include <iostream.h>
118+#include <iostream>
119 
120 #include "Geom.h"
121 
122+using namespace std;
123+
124+
125 class Map
126 {
127 public:
128Only in .: Map.o
129diff -u ../terra.orig/Mask.cc ./Mask.cc
130--- ../terra.orig/Mask.cc       1996-01-17 08:03:13.000000000 -0800
131+++ ./Mask.cc   2014-03-18 15:04:25.000000000 -0700
132@@ -1,10 +1,12 @@
133 #include <math.h>
134 #include <stdlib.h>
135-#include <iostream.h>
136+#include <iostream>
137 
138 #include "Geom.h"
139 #include "Mask.h"
140 
141+using namespace std;
142+
143 
144 RealMask *readMask(istream& in)
145 {
146diff -u ../terra.orig/Mask.h ./Mask.h
147--- ../terra.orig/Mask.h        1996-01-17 08:03:14.000000000 -0800
148+++ ./Mask.h    2014-03-18 15:16:16.000000000 -0700
149@@ -1,6 +1,11 @@
150 #ifndef MASK_INCLUDED // -*- C++ -*-
151 #define MASK_INCLUDED
152 
153+#include <istream>
154+
155+using namespace std;
156+
157+
158 class ImportMask
159 {
160 
161Only in .: Mask.o
162diff -u ../terra.orig/Quadedge.cc ./Quadedge.cc
163--- ../terra.orig/Quadedge.cc   1995-12-19 14:05:48.000000000 -0800
164+++ ./Quadedge.cc       2014-03-18 15:04:25.000000000 -0700
165@@ -1,8 +1,10 @@
166 #include <stdlib.h>
167-#include <iostream.h>
168+#include <iostream>
169 
170 #include "Quadedge.h"
171 
172+using namespace std;
173+
174 Edge::Edge(const Edge&)
175 {
176     cerr << "Edge: Edge assignments are forbidden." << endl;
177Only in .: Quadedge.o
178diff -u ../terra.orig/Subdivision.cc ./Subdivision.cc
179--- ../terra.orig/Subdivision.cc        1996-01-30 08:35:22.000000000 -0800
180+++ ./Subdivision.cc    2014-04-01 17:12:59.000000000 -0700
181@@ -1,9 +1,10 @@
182 #include <stdlib.h>
183-#include <iostream.h>
184+#include <iostream>
185 #include <assert.h>
186 
187 #include "Subdivision.h"
188 
189+using namespace std;
190 
191 
192 Edge *Subdivision::makeEdge(Vec2& org, Vec2& dest)
193@@ -105,7 +106,7 @@
194 
195 static void overEdge(Edge *e, edge_callback fn, void *closure)
196 {
197-    if( e->token != timestamp )
198+    if( static_cast<typeof(timestamp)>(e->token) != timestamp )
199     {
200        e->token = timestamp;
201        e->Sym()->token = timestamp;
202@@ -214,7 +215,7 @@
203         real td = triArea(x, ed->Dest(), ed->Org());
204 
205         if (td>0)                       // x is below ed
206-            if (to>0 || to==0 && t==0) {// x is interior, or origin endpoint
207+            if (to>0 || (to==0 && t==0)) {// x is interior, or origin endpoint
208                 startingEdge = e;
209                 return e;
210             }
211@@ -259,10 +260,12 @@
212 
213     if ( (x == e->Org()) || (x == e->Dest()) ) {
214         // point is already in the mesh
215+#if 0
216        //
217         cerr << "WARNING: Tried to reinsert point: " << x << endl;
218        cerr << "         org: " << e->Org() << endl;
219        cerr << "        dest: " << e->Dest() << endl;
220+#endif
221         return NULL;
222     }
223 
224@@ -338,7 +341,9 @@
225     do {
226 
227        Edge *e = spoke->Lnext();
228+#if 0
229        Edge *t = e->Oprev();
230+#endif
231 
232        if( isInterior(e) && shouldSwap(x, e) )
233            swap(e);
234Only in .: Subdivision.o
235diff -u ../terra.orig/Vec2.h ./Vec2.h
236--- ../terra.orig/Vec2.h        1996-01-30 08:35:24.000000000 -0800
237+++ ./Vec2.h    2014-03-18 16:55:04.000000000 -0700
238@@ -1,6 +1,11 @@
239 #ifndef VEC2_INCLUDED // -*- C++ -*-
240 #define VEC2_INCLUDED
241 
242+#include <iostream>
243+
244+using namespace std;
245+
246+
247 class Vec2 {
248 protected:
249     real elt[2];
250@@ -163,7 +168,13 @@
251 
252 inline istream& operator>>(istream& in, Vec2& v)
253 {
254+#if 0
255     return in >> "[" >> v[0] >> v[1] >> "]";
256+#endif
257+    in.ignore(1, '[');
258+    in >> v[0] >> v[1];
259+    in.ignore(1, ']');
260+    return in;
261 }
262 #endif
263 
264diff -u ../terra.orig/Vec3.h ./Vec3.h
265--- ../terra.orig/Vec3.h        1995-12-19 11:24:37.000000000 -0800
266+++ ./Vec3.h    2014-03-18 16:54:02.000000000 -0700
267@@ -1,6 +1,11 @@
268 #ifndef VEC3_INCLUDED // -*- C++ -*-
269 #define VEC3_INCLUDED
270 
271+#include <iostream>
272+
273+using namespace std;
274+
275+
276 class Vec3 {
277 protected:
278     real elt[3];
279@@ -173,7 +178,13 @@
280 
281 inline istream& operator>>(istream& in, Vec3& v)
282 {
283+#if 0
284     return in >> "[" >> v[0] >> v[1] >> v[2] >> "]";
285+#endif
286+    in.ignore(1, '[');
287+    in >> v[0] >> v[1];
288+    in.ignore(1, ']');
289+    return in;
290 }
291 #endif
292 
293Only in .: altadena-lake.osm
294Only in .: altadena.osm
295diff -u ../terra.orig/cmdline.cc ./cmdline.cc
296--- ../terra.orig/cmdline.cc    1996-01-19 10:34:14.000000000 -0800
297+++ ./cmdline.cc        2014-04-01 17:11:47.000000000 -0700
298@@ -1,7 +1,9 @@
299 #include <stdlib.h>
300-#include <fstream.h>
301+#include <fstream>
302 #include <string.h>
303 #include "terra.h"
304+#include <getopt.h>
305+
306 
307 GreedySubdivision *mesh;
308 Map *DEM;
309@@ -18,9 +20,9 @@
310 char *mask_filename   = NULL;
311 char *script_filename = NULL;
312 
313-static char *options = "e:p:h:o:m:s:";
314+static const char *options = "e:p:h:o:m:s:";
315 
316-static char *usage_string =
317+static const char *usage_string =
318 "-e <thresh>      Sets the tolerable error threshold\n"
319 "-p <count>       Sets the maximum number of allowable points\n"
320 "-h <factor>      Sets the height scaling factor.  For example,\n"
321@@ -31,7 +33,7 @@
322 "-s <file>        Execute preinsertion script from <file>\n"
323 "\n";
324 
325-static void usage_error(char *msg = NULL)
326+static void usage_error(const char *msg = NULL)
327 {
328     if( msg )
329        cerr << msg << endl;
330Only in .: cmdline.o
331diff -u ../terra.orig/glHacks.h ./glHacks.h
332--- ../terra.orig/glHacks.h     1996-01-30 08:35:27.000000000 -0800
333+++ ./glHacks.h 2014-03-18 16:55:18.000000000 -0700
334@@ -4,6 +4,9 @@
335 #include <GL/glx.h>
336 #include <GL/gl.h>
337 #include <GL/glu.h>
338+#include <iostream>
339+
340+using namespace std;
341 
342 
343 /*************************************************************************
344Only in .: glHacks.o
345diff -u ../terra.orig/greedy.cc ./greedy.cc
346--- ../terra.orig/greedy.cc     1996-01-19 10:34:15.000000000 -0800
347+++ ./greedy.cc 2014-04-01 17:14:20.000000000 -0700
348@@ -1,4 +1,6 @@
349 #include "terra.h"
350+#include <fstream>
351+
352 
353 void scripted_preinsertion(istream& script)
354 {
355@@ -64,7 +66,7 @@
356 inline int goal_not_met()
357 {
358     return mesh->maxError() > error_threshold &&
359-          mesh->pointCount() < point_limit;
360+      static_cast<typeof(point_limit)>(mesh->pointCount()) < point_limit;
361 }
362 
363 static void announce_goal()
364Only in .: greedy.o
365diff -u ../terra.orig/gui.cc ./gui.cc
366--- ../terra.orig/gui.cc        1996-01-30 08:35:28.000000000 -0800
367+++ ./gui.cc    2014-04-01 17:10:12.000000000 -0700
368@@ -1,5 +1,5 @@
369-#include <iostream.h>
370-#include <fstream.h>
371+#include <iostream>
372+#include <fstream>
373 
374 #include <GL/glut.h>
375 #include "glHacks.h"
376@@ -14,6 +14,7 @@
377 int will_draw_dem = False;
378 
379 
380+void xglutResize(int width, int height);
381 // Prototype for our hack below.
382 //
383 void xglutKeepAspect(float width, float height);
384@@ -69,10 +70,10 @@
385 {
386     int toggle = glutCreateMenu(mesh_toggle_menu);
387 
388-    glutAddMenuEntry("Draw DEM data", (int)&will_draw_dem);
389+    glutAddMenuEntry("Draw DEM data", will_draw_dem);
390 
391 
392-    int main = glutCreateMenu(mesh_main_menu);
393+    glutCreateMenu(mesh_main_menu);
394     glutAddSubMenu("Toggle", toggle);
395 
396     glutAddMenuEntry("Output Mesh EPS", MESH_MENU_EPS);
397@@ -141,6 +142,7 @@
398       glC(1.0, 0.15, 0.15);
399       mesh->overEdges(draw_edge);
400     glEnd();
401+    glutSwapBuffers();
402 }
403 
404 static inline void redisplay_all(int other)
405@@ -400,7 +402,8 @@
406 
407     // ---------------------------------------------------------------------
408 
409-    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
410+    // glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
411+    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
412     mesh_view = glutCreateWindow("TERRA: Mesh");
413 
414     xglutKeepAspect(DEM->width, DEM->height);
415@@ -408,6 +411,7 @@
416     create_mesh_menus();
417 
418     glutDisplayFunc(mesh_display);
419+    glutReshapeFunc(xglutResize);
420     glutMouseFunc(mesh_mouse);
421 
422     glMatrixMode(GL_PROJECTION);
423@@ -433,24 +437,38 @@
424 //
425 ////////////////////////////////////////////////////////////////////////
426 
427-extern "C" {
428-#include <GL/glutint.h>
429-}
430-
431-void xglutKeepAspect(float width, float height)
432+void xglutResize(int width, int height)
433 {
434-    Window win;
435-    XSizeHints hints;
436+    Map& map = mesh->getData();
437+    real w = (real)map.width;
438+    real h = (real)map.height;
439+
440+    // const float ar_origin = (float) WIDTH / (float) HEIGHT;
441+    const float ar_origin = (float) w / (float) h;
442+    const float ar_new = (float) width / (float) height;
443+
444+    float scale_w = (float) width / (float) w;
445+    float scale_h = (float) height / (float) h;
446+    if (ar_new > ar_origin) {
447+        scale_w = scale_h;
448+    } else {
449+        scale_h = scale_w;
450+    }
451 
452-    if( __glutCurrentWindow )
453-    {
454-        win = __glutCurrentWindow->win;
455+    float margin_x = (width - w * scale_w) / 2;
456+    float margin_y = (height - h * scale_h) / 2;
457 
458+    glViewport(margin_x, margin_y, w * scale_w, h * scale_h);
459+    glMatrixMode(GL_PROJECTION);
460+    glLoadIdentity();
461+    glOrtho(0, w / ar_origin, 0, h / ar_origin, 0, 1.0);
462 
463-        hints.flags = PAspect;
464-        hints.min_aspect.x = hints.max_aspect.x = (int)(1000*width);
465-        hints.min_aspect.y = hints.max_aspect.y = (int)(1000*height);
466+    glMatrixMode(GL_MODELVIEW);
467+    glLoadIdentity() ;
468+}
469 
470-        XSetWMNormalHints(__glutDisplay, win, &hints);
471-    }
472+void xglutKeepAspect(float width, float height)
473+{
474+    int w = glutGet(GLUT_WINDOW_WIDTH);
475+    glutReshapeWindow(w, static_cast<int>(floor(width*(height/w)+0.5)));
476 }
477Only in .: gui.o
478Only in .: jpl.osm
479diff -u ../terra.orig/output.cc ./output.cc
480--- ../terra.orig/output.cc     1996-01-30 08:35:30.000000000 -0800
481+++ ./output.cc 2014-04-01 17:08:47.000000000 -0700
482@@ -1,8 +1,8 @@
483 #include "terra.h"
484-#include <fstream.h>
485+#include <fstream>
486 
487 
488-void generate_output(char *filename, FileFormat format)
489+void generate_output(const char *filename, FileFormat format)
490 {
491     if( !filename )
492        filename = output_filename;
493Only in .: output.o
494Only in .: terra
495diff -u ../terra.orig/terra.cc ./terra.cc
496--- ../terra.orig/terra.cc      1996-01-10 13:22:59.000000000 -0800
497+++ ./terra.cc  2014-03-18 15:09:42.000000000 -0700
498@@ -1,10 +1,12 @@
499 #include "terra.h"
500 
501-main(int argc, char **argv)
502+int main(int argc, char **argv)
503 {
504     process_cmdline(argc, argv);
505 
506     greedy_insertion();
507 
508     generate_output();
509+
510+    return 0;
511 }
512diff -u ../terra.orig/terra.h ./terra.h
513--- ../terra.orig/terra.h       1996-01-19 10:34:17.000000000 -0800
514+++ ./terra.h   2014-04-01 17:08:42.000000000 -0700
515@@ -24,7 +24,7 @@
516 extern void scripted_preinsertion(istream&);
517 extern void subsample_insertion(int target_width);
518 
519-extern void generate_output(char *filename=NULL,
520+extern void generate_output(const char *filename=NULL,
521                            FileFormat format=NULLfile);
522 extern void output_tin(ostream&);
523 extern void output_eps(ostream&);
524Only in .: terra.o
525Only in .: xterra
526diff -u ../terra.orig/xterra.cc ./xterra.cc
527--- ../terra.orig/xterra.cc     1995-12-15 11:26:34.000000000 -0800
528+++ ./xterra.cc 2014-04-01 17:09:39.000000000 -0700
529@@ -5,7 +5,7 @@
530 
531 
532 
533-main(int argc, char **argv)
534+int main(int argc, char **argv)
535 {
536     glutInit(&argc, argv);
537     process_cmdline(argc, argv);
538@@ -15,4 +15,6 @@
539 
540 
541     gui_interact();
542+
543+    return 0;
544 }
545Only in .: xterra.o