mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-21 22:13:09 +02:00
Infrastructure for generating POV-Ray output (not useful yet)
- solidify/Makefile: added solid.o - solidify/solid.h, solidify.c (height_field, povray): output the part as the intersection of two height fields - solidify/solidify.c (main): generate POV-Ray output if stdout is redirected - solidify/Makefile (run, pov, disp): targets to run a test setup, render it, and display the result - solidify/main.pov: simple scene showing the test part
This commit is contained in:
parent
f3e7c1ec73
commit
37e840fa77
@ -12,7 +12,8 @@
|
||||
|
||||
SHELL = /bin/bash
|
||||
|
||||
OBJS = array.o face.o histo.o level.o overlap.o solidify.o style.o util.o
|
||||
OBJS = array.o face.o histo.o level.o overlap.o solid.o solidify.o style.o \
|
||||
util.o
|
||||
|
||||
CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
|
||||
-Wmissing-declarations -Wno-format-zero-length
|
||||
@ -50,6 +51,25 @@ clean:
|
||||
spotless: clean
|
||||
rm -f solidify
|
||||
|
||||
# ----- Experimental execution ------------------------------------------------
|
||||
|
||||
PRJ=http://projects.qi-hardware.com/index.php/p/ben-scans/source/tree/master
|
||||
DIR=$(PRJ)/data/csv
|
||||
FACE_A=$(DIR)/ben-batcvr-outside-100um.txt.bz2
|
||||
FACE_B=$(DIR)/ben-batcvr-inside-100um.txt.bz2
|
||||
D=1.16
|
||||
|
||||
.PHONY: run pov disp
|
||||
|
||||
run: solidify
|
||||
./solidify $(FACE_A) $(FACE_B) $(D) >batcvr.inc
|
||||
|
||||
pov:
|
||||
povray +A -W1280 -H1024 main.pov
|
||||
|
||||
disp:
|
||||
display main.png
|
||||
|
||||
# ----- Dependencies ----------------------------------------------------------
|
||||
|
||||
# compile and generate dependencies, from fped, based on
|
||||
|
27
solidify/main.pov
Normal file
27
solidify/main.pov
Normal file
@ -0,0 +1,27 @@
|
||||
#include "colors.inc"
|
||||
#include "batcvr.inc"
|
||||
|
||||
camera {
|
||||
location < 2, 2, 3>
|
||||
look_at < 0, 0, 0>
|
||||
right -4/3*x
|
||||
sky x
|
||||
}
|
||||
|
||||
background { color White }
|
||||
|
||||
light_source {
|
||||
< 4, 7, 4>
|
||||
color White
|
||||
}
|
||||
|
||||
union {
|
||||
Part
|
||||
pigment { rgb <0.9, 0.9, 0.9> }
|
||||
finish {
|
||||
brilliance 2
|
||||
phong 0.8
|
||||
phong_size 100
|
||||
metallic
|
||||
}
|
||||
}
|
71
solidify/solid.c
Normal file
71
solidify/solid.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* solid.c - Data structure and handling of a solid made of two opposing faces
|
||||
*
|
||||
* Written 2010 by Werner Almesberger
|
||||
* Copyright 2010 by 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "face.h"
|
||||
#include "solid.h"
|
||||
|
||||
|
||||
static void height_field(const char *name, const struct face *f,
|
||||
const struct matrix *m)
|
||||
{
|
||||
FILE *file;
|
||||
int x, y;
|
||||
int z;
|
||||
uint16_t g;
|
||||
uint8_t v[2];
|
||||
|
||||
file = fopen(name, "w");
|
||||
if (!file) {
|
||||
perror(name);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(file, "P5\n%d %d\n65535\n", f->sx, f->sy);
|
||||
for (y = 0; y != f->sy; y++)
|
||||
for (x = 0; x != f->sx; x++) {
|
||||
z = get(f->a, x+f->a->min_x, y+f->a->min_y);
|
||||
g = z == UNDEF ? 0 :
|
||||
65535*(z-f->a->min_z)/(f->a->max_z-f->a->min_z);
|
||||
v[0] = g >> 8;
|
||||
v[1] = g;
|
||||
fwrite(v, 2, 1, file);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
||||
void povray(const struct solid *s)
|
||||
{
|
||||
struct matrix m;
|
||||
|
||||
m.a[0][0] = m.a[1][1] = 1;
|
||||
m.a[0][1] = m.a[1][0] = 0;
|
||||
m.b[0] = m.b[1] = 0;
|
||||
|
||||
height_field("top.pgm", s->a, &m);
|
||||
height_field("bot.pgm", s->b, &m);
|
||||
|
||||
/*
|
||||
* 1/65535 = 0.000015..., so we set the water level a bit lower, e.g.,
|
||||
* to 0.0001
|
||||
*/
|
||||
printf(
|
||||
"#declare Part =\n"
|
||||
" intersection {\n"
|
||||
" height_field { pgm \"top.pgm\" water_level 0.00001 smooth }\n"
|
||||
" height_field { pgm \"bot.pgm\" water_level 0.00001 smooth }\n"
|
||||
" }\n");
|
||||
}
|
@ -18,4 +18,7 @@ struct solid {
|
||||
double dist;
|
||||
};
|
||||
|
||||
|
||||
void povray(const struct solid *s);
|
||||
|
||||
#endif /* SOLID_H */
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -137,6 +138,8 @@ int main(int argc, char **argv)
|
||||
solid.b = read_face(argv[2]);
|
||||
solid.dist = atof(argv[3])/0.025; /* @@@ hack */
|
||||
gui();
|
||||
if (!isatty(1))
|
||||
povray(&solid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user