mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-22 09:10:37 +02:00
6ac06aab7c
- solidify/face.h (struct face), solidify/face.c (read_face), solidify/level.c (draw_map, draw_image): introduce inclination of the z0 plane - solidify/level.c (draw_map): make blue z == z0 display more continuous - solidify/level.c (scroll_event): moved z0 shift to scroll_z - solidify/level.c (scroll_event, scroll_xy): added manipulation of the z0 plane's inclination
71 lines
1.2 KiB
C
71 lines
1.2 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include "util.h"
|
|
#include "array.h"
|
|
#include "histo.h"
|
|
#include "face.h"
|
|
|
|
|
|
struct face *read_face(const char *name)
|
|
{
|
|
FILE *file;
|
|
struct face *f;
|
|
struct histo *h;
|
|
float x, y, z;
|
|
int xi, yi, zi;
|
|
|
|
if (!strcmp(name, "-")) {
|
|
file = stdin;
|
|
} else {
|
|
int len;
|
|
|
|
len = strlen(name);
|
|
if (len > 4 && !strcmp(name+len-4, ".bz2")) {
|
|
char tmp[1000]; /* @@@ enough */
|
|
|
|
sprintf(tmp, "bzcat \"%s\"", name);
|
|
file = popen(tmp, "r");
|
|
if (!file) {
|
|
perror(tmp);
|
|
exit(1);
|
|
}
|
|
} else {
|
|
file = fopen(name, "r");
|
|
if (!file) {
|
|
perror(name);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
f = alloc_type(struct face);
|
|
f->a = new_array();
|
|
|
|
while (fscanf(file, "%f,%f,%f\r\n", &x, &y, &z) == 3) {
|
|
/* @@@ hack - should auto-scale */
|
|
xi = round(x*10.0);
|
|
yi = round(y*10.0);
|
|
zi = round(z*40.0);
|
|
set(f->a, xi, yi, zi);
|
|
}
|
|
if (file != stdin)
|
|
(void) fclose(file);
|
|
|
|
f->sx = f->a->max_x-f->a->min_x+1;
|
|
f->sy = f->a->max_y-f->a->min_y+1;
|
|
h = make_histo(f->a);
|
|
f->z_ref = f->a->min_z+median(h);
|
|
free_histo(h);
|
|
f->fx = f->fy = 0;
|
|
|
|
fprintf(stderr, "%d-%d / %d-%d / %d-%d\n",
|
|
f->a->min_x, f->a->max_x, f->a->min_y, f->a->max_y,
|
|
f->a->min_z, f->a->max_z);
|
|
|
|
return f;
|
|
}
|
|
|
|
|