r5707 - developers/werner/cncmap/zmap

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Oct 23 23:47:40 CEST 2009


Author: werner
Date: 2009-10-23 23:47:40 +0200 (Fri, 23 Oct 2009)
New Revision: 5707

Added:
   developers/werner/cncmap/zmap/main.c
Removed:
   developers/werner/cncmap/zmap/try.c
Modified:
   developers/werner/cncmap/zmap/Makefile
Log:
- renamed command-line utility from "zline" to "zmap"
- zmap/try.c: renamed to zmap/main.c



Modified: developers/werner/cncmap/zmap/Makefile
===================================================================
--- developers/werner/cncmap/zmap/Makefile	2009-10-23 21:44:49 UTC (rev 5706)
+++ developers/werner/cncmap/zmap/Makefile	2009-10-23 21:47:40 UTC (rev 5707)
@@ -11,9 +11,9 @@
 #
 
 
-MAIN=zline
+MAIN=zmap
 
-OBJS=try.o zline.o zmap.o
+OBJS=main.o zline.o zmap.o
 
 CFLAGS = -g -Wall -Wshadow
 LDFLAGS = -lm

Copied: developers/werner/cncmap/zmap/main.c (from rev 5706, developers/werner/cncmap/zmap/try.c)
===================================================================
--- developers/werner/cncmap/zmap/main.c	                        (rev 0)
+++ developers/werner/cncmap/zmap/main.c	2009-10-23 21:47:40 UTC (rev 5707)
@@ -0,0 +1,127 @@
+/*
+ * main.c - Command-line interface to zmap and zline
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "zmap.h"
+#include "zline.h"
+
+
+#define EPSILON	0.001	/* 1 um */
+
+
+struct line {
+	struct xyz a, b;
+};
+
+
+static void point(void *user, double x, double y, double z)
+{
+	printf("%f %f %f\n", x, y, z);
+}
+
+
+static void point_3d(void *user, double x, double y, double z)
+{
+	const struct line *line = user;
+	double len, pos;
+	double f;
+
+	len = hypot(line->b.x-line->a.x, line->b.y-line->a.y);
+	pos = hypot(x-line->a.x, y-line->a.y);
+	f = len < EPSILON ? 0.5 : pos/len;
+		f = 0.5;
+	z += f*line->b.z+(1-f)*line->a.z;
+	point(NULL, x, y, z);
+}
+
+
+static void process_file(FILE *file)
+{
+	int lineno = 0;
+	char buf[1024];
+	struct line line;
+	int first = 1;
+	int n;
+
+	while (fgets(buf, sizeof(buf), file)) {
+		lineno++;
+		n = sscanf(buf, "%lf %lf %lf\n",
+		    &line.b.x, &line.b.y, &line.b.z);
+		switch (n) {
+		case -1:
+			printf("\n");
+			first = 1;
+			continue;
+		case 2:
+			line.b.z = 0;
+			/* fall through */
+		case 3:
+			break;
+		default:
+			fprintf(stderr, "invalid data at line %d\n", lineno);
+			exit(1);
+		}
+		if (!first)
+			zline(line.a.x, line.a.y, line.b.x, line.b.y,
+			    point_3d, &line);
+		line.a = line.b;
+		first = 0;
+	}
+}
+
+
+static void usage(const char *name)
+{
+	fprintf(stderr, "usage: %s zmap_file [xa ya [xb yb]]\n", name);
+	exit(1);
+}
+
+
+int main(int argc, char **argv)
+{
+	char *end;
+	double p[4];
+	int i;
+
+	switch (argc) {
+	case 2:
+		break;
+	case 4:
+	case 6:
+		for (i = 2; i != argc; i++) {
+			p[i-2] = strtod(argv[i], &end);
+			if (*end)
+				usage(*argv);
+		}
+		break;
+	default:
+		usage(*argv);
+	}
+	zline_init(argv[1]);
+	switch (argc) {
+	case 2:
+		process_file(stdin);
+		break;
+	case 4:
+		zpoint(p[0], p[1], point, NULL);
+		break;
+	case 6:
+		zline(p[0], p[1], p[2], p[3], point, NULL);
+		break;
+	}
+	zline_end();
+	return 0;
+}

Deleted: developers/werner/cncmap/zmap/try.c
===================================================================
--- developers/werner/cncmap/zmap/try.c	2009-10-23 21:44:49 UTC (rev 5706)
+++ developers/werner/cncmap/zmap/try.c	2009-10-23 21:47:40 UTC (rev 5707)
@@ -1,127 +0,0 @@
-/*
- * main.c - Command-line interface to zmap and zline
- *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 Werner Almesberger
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-
-#include "zmap.h"
-#include "zline.h"
-
-
-#define EPSILON	0.001	/* 1 um */
-
-
-struct line {
-	struct xyz a, b;
-};
-
-
-static void point(void *user, double x, double y, double z)
-{
-	printf("%f %f %f\n", x, y, z);
-}
-
-
-static void point_3d(void *user, double x, double y, double z)
-{
-	const struct line *line = user;
-	double len, pos;
-	double f;
-
-	len = hypot(line->b.x-line->a.x, line->b.y-line->a.y);
-	pos = hypot(x-line->a.x, y-line->a.y);
-	f = len < EPSILON ? 0.5 : pos/len;
-		f = 0.5;
-	z += f*line->b.z+(1-f)*line->a.z;
-	point(NULL, x, y, z);
-}
-
-
-static void process_file(FILE *file)
-{
-	int lineno = 0;
-	char buf[1024];
-	struct line line;
-	int first = 1;
-	int n;
-
-	while (fgets(buf, sizeof(buf), file)) {
-		lineno++;
-		n = sscanf(buf, "%lf %lf %lf\n",
-		    &line.b.x, &line.b.y, &line.b.z);
-		switch (n) {
-		case -1:
-			printf("\n");
-			first = 1;
-			continue;
-		case 2:
-			line.b.z = 0;
-			/* fall through */
-		case 3:
-			break;
-		default:
-			fprintf(stderr, "invalid data at line %d\n", lineno);
-			exit(1);
-		}
-		if (!first)
-			zline(line.a.x, line.a.y, line.b.x, line.b.y,
-			    point_3d, &line);
-		line.a = line.b;
-		first = 0;
-	}
-}
-
-
-static void usage(const char *name)
-{
-	fprintf(stderr, "usage: %s zmap_file [xa ya [xb yb]]\n", name);
-	exit(1);
-}
-
-
-int main(int argc, char **argv)
-{
-	char *end;
-	double p[4];
-	int i;
-
-	switch (argc) {
-	case 2:
-		break;
-	case 4:
-	case 6:
-		for (i = 2; i != argc; i++) {
-			p[i-2] = strtod(argv[i], &end);
-			if (*end)
-				usage(*argv);
-		}
-		break;
-	default:
-		usage(*argv);
-	}
-	zline_init(argv[1]);
-	switch (argc) {
-	case 2:
-		process_file(stdin);
-		break;
-	case 4:
-		zpoint(p[0], p[1], point, NULL);
-		break;
-	case 6:
-		zline(p[0], p[1], p[2], p[3], point, NULL);
-		break;
-	}
-	zline_end();
-	return 0;
-}




More information about the commitlog mailing list