Compare commits
No commits in common. "f5de09b23af6d1ec981a190e882d8d64cedb0ac6" and "895e61cbb67b10aa26d1bc83e5a5f5882dc474e0" have entirely different histories.
f5de09b23a
...
895e61cbb6
@ -1,24 +0,0 @@
|
||||
#!/bin/awk -f
|
||||
|
||||
#
|
||||
# this software is NOT ready for prime time !
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
count = 0
|
||||
print "/* DO NOT EDIT BY HAND, BASTARD !*/"
|
||||
print "/* generated ", strftime(), " */"
|
||||
print
|
||||
print "#declare OBJ_vertices = object\n{"
|
||||
print "union {"
|
||||
}
|
||||
|
||||
{
|
||||
printf "sphere { <%.9f, %.9f, %.9f>, RR }\n", $1, $2, $3
|
||||
count++;
|
||||
}
|
||||
|
||||
END {
|
||||
print " }\n}\n"
|
||||
print "// ", count, "vertices.\n"
|
||||
}
|
@ -17,43 +17,6 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
int printf_the_boudingbox(EdgesAndVertices *eav)
|
||||
{
|
||||
int idx;
|
||||
double x, y, z;
|
||||
double minX, minY, minZ;
|
||||
double maxX, maxY, maxZ;
|
||||
|
||||
minX = minY = minZ = 1e35;
|
||||
maxX = maxY = maxZ = -1e35;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "====== %s is not fully implemented ======\n", __func__);
|
||||
|
||||
for (idx=0; idx<eav->Blist->fidx; idx++) {
|
||||
x = eav->Blist->bbs[idx].p.x;
|
||||
y = eav->Blist->bbs[idx].p.y;
|
||||
z = eav->Blist->bbs[idx].p.z;
|
||||
|
||||
if (x < minX) minX = x;
|
||||
else if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y;
|
||||
else if (y > maxY) maxY = y;
|
||||
if (z < minZ) minZ = z;
|
||||
else if (z > maxZ) maxZ = z;
|
||||
|
||||
}
|
||||
|
||||
printf( "%.9f %.9f %.9f %.9f %.9f %.9f\n",
|
||||
minX, minY, minZ, maxX, maxY, maxZ);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
int printf_the_vertices(EdgesAndVertices *eav)
|
||||
@ -138,16 +101,12 @@ if (verbosity > 1) {
|
||||
mode = 666;
|
||||
if (! strcasecmp("edges", outmode)) { mode = 0; }
|
||||
else if (! strcasecmp("vertices", outmode)) { mode = 1; }
|
||||
else if (! strcasecmp("bbox", outmode)) { mode = 2; }
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
printf_the_edges(&eav); break;
|
||||
case 1:
|
||||
printf_the_vertices(&eav); break;
|
||||
case 2:
|
||||
printf_the_boudingbox(&eav); break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "no way to do '%s'\n", outmode);
|
||||
exit(1);
|
||||
@ -182,11 +141,10 @@ while ((opt = getopt(argc, argv, "ht:v")) != -1) {
|
||||
case 'v':
|
||||
verbosity++; break;
|
||||
case 't':
|
||||
// fprintf(stderr, "type -> '%s'\n", optarg);
|
||||
fprintf(stderr, "type -> '%s'\n", optarg);
|
||||
outmode = optarg;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "'%c' EBADOPT\n", opt);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define PSYCHOTIK 1
|
||||
#define LINE_SZ 666
|
||||
|
||||
static BBList *bublist;
|
||||
@ -150,11 +149,8 @@ if ( pts[0]==pts[1] || pts[0]==pts[2] || pts[2]==pts[1] ) {
|
||||
for (ix=0; ix<3; ix++) {
|
||||
a = ix % 3;
|
||||
b = (ix+1) % 3;
|
||||
#if PSYCHOTIK
|
||||
foo = push_a_missing_edge(edges, pts[a], pts[b]);
|
||||
#else
|
||||
// foo = push_a_missing_edge(edges, pts[a], pts[b]);
|
||||
foo = push_an_edge(edges, pts[a], pts[b]);
|
||||
#endif
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: disaster #%d line %d\n",
|
||||
__func__, foo, linenumber);
|
||||
@ -175,9 +171,9 @@ return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* The main procedure, who contains a lot of things.
|
||||
*
|
||||
*/
|
||||
int try_to_read_an_OBJ_file(char *infname, char *ofname, int outstyle)
|
||||
int try_to_read_an_OBJ_file(char *infname, int outstyle)
|
||||
{
|
||||
FILE *fpin;
|
||||
char line[LINE_SZ+1], *cptr, *token;
|
||||
@ -188,8 +184,7 @@ Bubulle bubulle;
|
||||
char *outfname, *baseptr;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n\n", __func__,
|
||||
infname, ofname, outstyle);
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n\n", __func__, infname, outstyle);
|
||||
#endif
|
||||
|
||||
/* get memory for generated output filename(s) */
|
||||
@ -315,8 +310,8 @@ fclose(fpin);
|
||||
fprintf(stderr, " ***************************************\n");
|
||||
|
||||
if(verbosity) {
|
||||
fprintf(stderr, "%s(): %9d vertices loaded\n", __func__, bublist->fidx);
|
||||
fprintf(stderr, "%s(): %9d edges loaded\n", __func__, edges->fidx);
|
||||
fprintf(stderr, "%s(): %d vertices loaded\n", __func__, bublist->fidx);
|
||||
fprintf(stderr, "%s(): %d edges loaded\n", __func__, edges->fidx);
|
||||
}
|
||||
|
||||
if (verbosity > 1) {
|
||||
@ -324,7 +319,7 @@ if (verbosity > 1) {
|
||||
print_edgelist_desc(edges, 0);
|
||||
}
|
||||
|
||||
if (outstyle) { /* two ascii files */
|
||||
if (outstyle) { /* two ascii files */
|
||||
strcpy(outfname, infname);
|
||||
cptr = rindex(outfname, '.');
|
||||
fprintf(stderr, "rindex -> [%s]\n", cptr);
|
||||
@ -332,23 +327,15 @@ if (outstyle) { /* two ascii files */
|
||||
bubulles_to_data(outfname, NULL, bublist, 0);
|
||||
// edges_to_data(file_edges, edges, 0);
|
||||
}
|
||||
else { /* one 'evblob' file */
|
||||
if (NULL == ofname) {
|
||||
strcpy(outfname, infname);
|
||||
/* see manpage basename(3) */
|
||||
baseptr = basename(outfname);
|
||||
// fprintf(stderr, "baseptr -> [%s]\n", baseptr);
|
||||
cptr = rindex(baseptr, '.');
|
||||
strcpy(cptr, ".evblob");
|
||||
fprintf(stderr, "baseptr-> [%s]\n", baseptr);
|
||||
cptr = baseptr;
|
||||
}
|
||||
else {
|
||||
cptr = ofname;
|
||||
fprintf(stderr, "writing to %s\n", cptr);
|
||||
}
|
||||
foo = x_write_vertedges(cptr, bublist, edges);
|
||||
|
||||
else { /* one 'evblob' file */
|
||||
strcpy(outfname, infname);
|
||||
/* see manpage basename(3) */
|
||||
baseptr = basename(outfname);
|
||||
// fprintf(stderr, "baseptr -> [%s]\n", baseptr);
|
||||
cptr = rindex(baseptr, '.');
|
||||
strcpy(cptr, ".evblob");
|
||||
// fprintf(stderr, "baseptr-> [%s]\n", baseptr);
|
||||
foo = x_write_vertedges(baseptr, bublist, edges);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Err #%d when writing edges&vertices file\n", foo);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ typedef struct {
|
||||
} EdgesAndVertices;
|
||||
|
||||
/* in importobj.c */
|
||||
int try_to_read_an_OBJ_file(char *fname, char *oname, int outstyle);
|
||||
int try_to_read_an_OBJ_file(char *fname, int outstyle);
|
||||
|
||||
/* in rdwredges.c */
|
||||
int x_write_vertedges (char *filename, BBList *bblist, EdgeList *edges);
|
||||
|
@ -25,7 +25,7 @@ exit(0);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
char *ofname = NULL;
|
||||
// char *fname; /* see manpage basename(3) */
|
||||
|
||||
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
|
||||
|
||||
@ -34,13 +34,10 @@ if (1 == argc) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
help(); break;
|
||||
case 'o':
|
||||
ofname = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
verbosity++; break;
|
||||
default:
|
||||
@ -51,8 +48,8 @@ while ((opt = getopt(argc, argv, "ho:v")) != -1) {
|
||||
|
||||
|
||||
if (optind < argc) {
|
||||
fprintf(stderr, "arg = %s\n", argv[optind]);
|
||||
foo = try_to_read_an_OBJ_file(argv[optind], ofname, 0);
|
||||
// fprintf(stderr, "ARG = %s\n", argv[optind]);
|
||||
foo = try_to_read_an_OBJ_file(argv[optind], 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user