Compare commits
5 Commits
b861e8c86b
...
52e5ace4e1
Author | SHA1 | Date | |
---|---|---|---|
|
52e5ace4e1 | ||
|
c4547fa832 | ||
|
6a5d00fa10 | ||
|
398a5d3957 | ||
|
939b516625 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ toto
|
|||||||
|
|
||||||
tools/*.obj
|
tools/*.obj
|
||||||
! tools/minimal.obj
|
! tools/minimal.obj
|
||||||
|
! tools/cube.obj
|
||||||
tools/read_obj
|
tools/read_obj
|
||||||
tools/*.xyz
|
tools/*.xyz
|
||||||
tools/*.asc
|
tools/*.asc
|
||||||
|
2
Makefile
2
Makefile
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
OPT = -Wall -g -pg -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
||||||
|
|
||||||
libbubulles.a: bubulles.o edges.o
|
libbubulles.a: bubulles.o edges.o
|
||||||
ar r $@ $?
|
ar r $@ $?
|
||||||
|
14
bubulles.c
14
bubulles.c
@ -121,18 +121,18 @@ return ( &where->bbs[idx] );
|
|||||||
int print_bublist_desc(BBList *bbl, int opts)
|
int print_bublist_desc(BBList *bbl, int opts)
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("------- bblist at %p\n", bbl);
|
fprintf(stderr, "------- bblist at %p\n", bbl);
|
||||||
printf("\tname \t'%s'\n", bbl->name);
|
fprintf(stderr, "\tname \t'%s'\n", bbl->name);
|
||||||
|
|
||||||
printf("\tsize\t%6d\n\tfidx\t%6d\n", bbl->size, bbl->fidx);
|
fprintf(stderr, "\tsize\t%6d\n\tfidx\t%6d\n", bbl->size, bbl->fidx);
|
||||||
if (opts & 0x01) {
|
if (opts & 0x01) {
|
||||||
printf("\txyz\t%f %f %f\n",
|
fprintf(stderr, "\txyz\t%f %f %f\n",
|
||||||
bbl->position.x, bbl->position.y, bbl->position.z);
|
bbl->position.x, bbl->position.y, bbl->position.z);
|
||||||
}
|
}
|
||||||
printf("\tflags\t0x%08lX\n", bbl->flags);
|
fprintf(stderr, "\tflags\t0x%08lX\n", bbl->flags);
|
||||||
printf("\tarray\t%p\n", bbl->bbs);
|
fprintf(stderr, "\tarray\t%p\n", bbl->bbs);
|
||||||
|
|
||||||
puts(""); fflush(stdout);
|
fflush(stderr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
78
edges.c
78
edges.c
@ -65,6 +65,26 @@ return 0;
|
|||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
|
* with this func, you can search for duplicates, but
|
||||||
|
* it is going to be SLOW with huges object.
|
||||||
|
*/
|
||||||
|
static int is_edge_in_list(EdgeList *list, int p0, int p1)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
for (idx=0; idx < list->fidx; idx++) {
|
||||||
|
if ( (list->edges[idx].A == p0) &&
|
||||||
|
(list->edges[idx].B == p1) ) return 1;
|
||||||
|
|
||||||
|
if ( (list->edges[idx].A == p1) &&
|
||||||
|
(list->edges[idx].B == p0) ) return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* NOT FOUND */
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
*
|
||||||
* we have two functions for adding an edge to a list
|
* we have two functions for adding an edge to a list
|
||||||
* the first one add unconditionnaly the edge to the
|
* the first one add unconditionnaly the edge to the
|
||||||
* (non full) list...
|
* (non full) list...
|
||||||
@ -88,6 +108,7 @@ list->edges[list->fidx].B = p1;
|
|||||||
list->fidx ++;
|
list->fidx ++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* and the second only insert an edge if it was missing
|
* and the second only insert an edge if it was missing
|
||||||
* from the currently know list.
|
* from the currently know list.
|
||||||
@ -114,24 +135,6 @@ if ( ! is_edge_in_list(list, p0, p1) ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
|
||||||
* with this func, you can search for duplicates
|
|
||||||
*/
|
|
||||||
int is_edge_in_list(EdgeList *list, int p0, int p1)
|
|
||||||
{
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
for (idx=0; idx < list->fidx; idx++) {
|
|
||||||
if ( (list->edges[idx].A == p0) &&
|
|
||||||
(list->edges[idx].B == p1) ) return 1;
|
|
||||||
|
|
||||||
if ( (list->edges[idx].A == p1) &&
|
|
||||||
(list->edges[idx].B == p0) ) return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; /* NOT FOUND */
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
int print_edgelist_desc(EdgeList *list, int k)
|
int print_edgelist_desc(EdgeList *list, int k)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -147,12 +150,43 @@ fprintf(stderr, "\tsize %8d\n", list->size);
|
|||||||
fprintf(stderr, "\tnext free %8d\n", list->fidx);
|
fprintf(stderr, "\tnext free %8d\n", list->fidx);
|
||||||
fprintf(stderr, "\tmagic 0x%08lX\n", list->magic);
|
fprintf(stderr, "\tmagic 0x%08lX\n", list->magic);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* /!\ the output format is subject to changes in
|
||||||
|
* a near futur.
|
||||||
|
*/
|
||||||
|
int edges_to_data(char *fname, EdgeList *list, int k)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
int idx, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, fname, list, k);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (NULL==(fp=fopen(fname, "w"))) {
|
||||||
|
perror(fname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (idx=0; idx<list->fidx; idx++) {
|
||||||
|
foo = fprintf(fp, "%d %d\n", list->edges[idx].A, list->edges[idx].B);
|
||||||
|
/*
|
||||||
|
* error check
|
||||||
|
*/
|
||||||
|
if (foo < 0) {
|
||||||
|
perror(fname);
|
||||||
|
exit(1); /* be violent ! */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int print_the_edges(FILE *fp, EdgeList *list, int k)
|
int print_the_edges(FILE *fp, EdgeList *list, int k)
|
||||||
{
|
{
|
||||||
int foo;
|
int idx;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, list, k);
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, list, k);
|
||||||
@ -165,9 +199,9 @@ if (k) {
|
|||||||
|
|
||||||
fprintf(stderr, " list.fidx = %d\n", list->fidx);
|
fprintf(stderr, " list.fidx = %d\n", list->fidx);
|
||||||
|
|
||||||
for (foo=0; foo<list->fidx; foo++) {
|
for (idx=0; idx<list->fidx; idx++) {
|
||||||
fprintf(fp, "%6d\t\t%5d %5d\n", foo,
|
fprintf(fp, "%6d\t\t%5d %5d\n", idx,
|
||||||
list->edges[foo].A, list->edges[foo].B);
|
list->edges[idx].A, list->edges[idx].B);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
7
edges.h
7
edges.h
@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* edges.h
|
* edges.h
|
||||||
* a part of libbubulle from tTh
|
* a part of libbubulle from tTh
|
||||||
|
*
|
||||||
|
* https://git.tetalab.org/tTh/libbubulle
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int A, B;
|
int A, B;
|
||||||
short burz;
|
short burz; /* for what usage ??? */
|
||||||
} AnEdge;
|
} AnEdge;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -26,9 +28,10 @@ int free_edgelist(EdgeList *list, int k);
|
|||||||
int push_an_edge(EdgeList *list, int p0, int p1);
|
int push_an_edge(EdgeList *list, int p0, int p1);
|
||||||
int push_a_missing_edge(EdgeList *list, int p0, int p1);
|
int push_a_missing_edge(EdgeList *list, int p0, int p1);
|
||||||
|
|
||||||
int is_edge_in_list(EdgeList *list, int p0, int p1);
|
// int is_edge_in_list(EdgeList *list, int p0, int p1);
|
||||||
|
|
||||||
int print_edgelist_desc(EdgeList *list, int k);
|
int print_edgelist_desc(EdgeList *list, int k);
|
||||||
|
int edges_to_data(char *fname, EdgeList *list, int k);
|
||||||
int print_the_edges(FILE *file, EdgeList *list, int k);
|
int print_the_edges(FILE *file, EdgeList *list, int k);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
3
tools/.gitignore
vendored
3
tools/.gitignore
vendored
@ -1,4 +1,7 @@
|
|||||||
|
|
||||||
|
essai_faces
|
||||||
|
read_obj
|
||||||
|
|
||||||
*.vertices
|
*.vertices
|
||||||
*.edges
|
*.edges
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
|
||||||
BBFUNCS = ../libbubulles.a
|
BBFUNCS = ../libbubulles.a
|
||||||
|
|
||||||
OPT = -Wall -g -pg -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
||||||
|
|
||||||
read_obj: read_obj.c Makefile importobj.o $(BBFUNCS)
|
read_obj: read_obj.c Makefile importobj.o $(BBFUNCS)
|
||||||
gcc $(OPT) $< importobj.o $(BBFUNCS) -o $@
|
gcc $(OPT) $< importobj.o $(BBFUNCS) -o $@
|
||||||
|
|
||||||
importobj.o: importobj.c ../bubulles.h Makefile
|
importobj.o: importobj.c ../bubulles.h Makefile
|
||||||
$(CC) $(OPT) -c $<
|
$(CC) $(OPT) -c $<
|
||||||
|
|
||||||
|
essai_faces: essai_faces.c Makefile
|
||||||
|
$(CC) $(OPT) $< -o $@
|
||||||
|
49
tools/cube.obj
Normal file
49
tools/cube.obj
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# cube.obj
|
||||||
|
#
|
||||||
|
|
||||||
|
o cube
|
||||||
|
|
||||||
|
v 0.0 0.0 0.0
|
||||||
|
v 0.0 0.0 1.0
|
||||||
|
v 0.0 1.0 0.0
|
||||||
|
v 0.0 1.0 1.0
|
||||||
|
v 1.0 0.0 0.0
|
||||||
|
v 1.0 0.0 1.0
|
||||||
|
v 1.0 1.0 0.0
|
||||||
|
v 1.0 1.0 1.0
|
||||||
|
|
||||||
|
vt 0.25 0.0
|
||||||
|
vt 0.5 0.0
|
||||||
|
vt 0 0.25
|
||||||
|
vt 0.25 0.25
|
||||||
|
vt 0.5 0.25
|
||||||
|
vt 0.75 0.25
|
||||||
|
vt 0.0 0.5
|
||||||
|
vt 0.25 0.5
|
||||||
|
vt 0.5 0.5
|
||||||
|
vt 0.75 0.5
|
||||||
|
vt 0.25 0.75
|
||||||
|
vt 0.5 0.75
|
||||||
|
vt 0.25 1.0
|
||||||
|
vt 0.5 1.0
|
||||||
|
|
||||||
|
vn 0.0 0.0 1.0
|
||||||
|
vn 0.0 0.0 -1.0
|
||||||
|
vn 0.0 1.0 0.0
|
||||||
|
vn 0.0 -1.0 0.0
|
||||||
|
vn 1.0 0.0 0.0
|
||||||
|
vn -1.0 0.0 0.0
|
||||||
|
|
||||||
|
f 1/11/2 7/14/2 5/12/2
|
||||||
|
f 1/11/2 3/13/2 7/14/2
|
||||||
|
f 1/7/6 4/4/6 3/3/6
|
||||||
|
f 1/7/6 2/8/6 4/4/6
|
||||||
|
f 3/1/3 8/5/3 7/2/3
|
||||||
|
f 3/1/3 4/4/3 8/5/3
|
||||||
|
f 5/10/5 7/6/5 8/5/5
|
||||||
|
f 5/10/5 8/5/5 6/9/5
|
||||||
|
f 1/11/4 5/12/4 6/9/4
|
||||||
|
f 1/11/4 6/9/4 2/8/4
|
||||||
|
f 2/8/1 6/9/1 8/5/1
|
||||||
|
f 2/8/1 8/5/1 4/4/1
|
||||||
|
|
44
tools/essai_faces.c
Normal file
44
tools/essai_faces.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int essai_lecture_face(char *str)
|
||||||
|
{
|
||||||
|
char *buffer, *ptr;
|
||||||
|
int bar;
|
||||||
|
int A, B, C;
|
||||||
|
|
||||||
|
printf("-------- '%s'\n", str);
|
||||||
|
buffer = ptr = strdup(str);
|
||||||
|
for (bar = 0;;) {
|
||||||
|
ptr = strtok(ptr, " \t");
|
||||||
|
if (NULL != ptr) {
|
||||||
|
printf("\t%2d '%s'\n", bar, ptr);
|
||||||
|
ptr = NULL;
|
||||||
|
bar++;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* so, here, we know the number of thing to decipher
|
||||||
|
*/
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
printf(" -> %d\n", bar);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, bar;
|
||||||
|
|
||||||
|
foo = essai_lecture_face("3 14 159");
|
||||||
|
foo = essai_lecture_face("2 4 6 8");
|
||||||
|
foo = essai_lecture_face("0/10 1/11 2/12");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../bubulles.h"
|
#include "../bubulles.h"
|
||||||
#include "../edges.h"
|
#include "../edges.h"
|
||||||
@ -27,7 +28,8 @@ typedef struct {
|
|||||||
int id;
|
int id;
|
||||||
} Tokens;
|
} Tokens;
|
||||||
|
|
||||||
enum token_id { T_comment=1, T_vertice, T_group, T_face, T_vt };
|
enum token_id { T_comment=1, T_vertice, T_group, T_face, T_vt, T_vn,
|
||||||
|
T_line, T_object, T_smoothing, T_usemtl, T_mtllib };
|
||||||
|
|
||||||
Tokens TokenList[] = {
|
Tokens TokenList[] = {
|
||||||
{ "#", T_comment },
|
{ "#", T_comment },
|
||||||
@ -35,6 +37,12 @@ Tokens TokenList[] = {
|
|||||||
{ "g", T_group }, // to be verified !
|
{ "g", T_group }, // to be verified !
|
||||||
{ "f", T_face },
|
{ "f", T_face },
|
||||||
{ "vt", T_vt }, // c'est quoi ce truc ?
|
{ "vt", T_vt }, // c'est quoi ce truc ?
|
||||||
|
{ "vn", T_vt }, // c'est quoi ce truc ?
|
||||||
|
{ "l", T_line },
|
||||||
|
{ "o", T_object },
|
||||||
|
{ "s", T_smoothing },
|
||||||
|
{ "usemtl", T_usemtl },
|
||||||
|
{ "mtllib", T_mtllib },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,45 +84,62 @@ if (3 == foo) {
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* new Mon 27 Mar 2023 12:08:18 AM CEST */
|
/* new Mon 27 Mar 2023 12:08:18 AM CEST
|
||||||
|
*
|
||||||
|
* mmmm... complex thing to do...
|
||||||
|
*
|
||||||
|
*/
|
||||||
int parse_face(char *cptr, int phy)
|
int parse_face(char *cptr, int phy)
|
||||||
{
|
{
|
||||||
int ix, foo;
|
int ix, foo;
|
||||||
int fa, fb;
|
int pts[3];
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, cptr, phy);
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, cptr, phy);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (0)
|
||||||
|
fprintf(stderr, "parse_face");
|
||||||
|
for (foo=0; foo<16; foo++) {
|
||||||
|
fprintf(stderr, " %02X", ((unsigned char *)cptr)[foo]);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (ix=0; ix<3; ix++) {
|
for (ix=0; ix<3; ix++) {
|
||||||
cptr = strtok(NULL, " ");
|
cptr = strtok(NULL, " ");
|
||||||
if (NULL == cptr) {
|
if (NULL == cptr) {
|
||||||
fprintf(stderr, "incomplete face in %s\n", __func__);
|
fprintf(stderr, "incomplete face in %s\n", __func__);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
if (2 != sscanf(cptr, "%d/%d", &fa, &fb)) {
|
if (1 != sscanf(cptr, "%d", &pts[ix])) {
|
||||||
fprintf(stderr, "%s: err sscanf\n", __func__);
|
fprintf(stderr, "%s: err sscanf\n", __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
// XXX fprintf(stderr, " %d got %d %d\n", ix, fa, fb);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* yes, i've found 0-lenght edges, wtf ?
|
|
||||||
*/
|
|
||||||
if (fa == fb) {
|
|
||||||
// fprintf(stderr, "'%s' dublicate\n", cptr);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = push_a_missing_edge(edges, fa, fb);
|
/** check the freshly read datas **/
|
||||||
|
if ( pts[0]==pts[1] || pts[0]==pts[2] || pts[2]==pts[1] ) {
|
||||||
|
fprintf(stderr, "%s: degerated face ( %d %d %d )\n", __func__,
|
||||||
|
pts[0], pts[1], pts[2]);
|
||||||
|
sleep(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = push_a_missing_edge(edges, pts[0], pts[1]);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: disaster #%d\n", __func__, foo);
|
fprintf(stderr, "%s: disaster #%d\n", __func__, foo);
|
||||||
#if MUST_ABORT
|
|
||||||
fflush(stderr), abort();
|
|
||||||
#endif
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
foo = push_a_missing_edge(edges, pts[1], pts[2]);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: disaster #%d\n", __func__, foo);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
foo = push_a_missing_edge(edges, pts[2], pts[0]);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: disaster #%d\n", __func__, foo);
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
@ -128,7 +153,7 @@ int try_to_read_an_OBJ_file(char *infname, char *file_vert, char *file_edges,
|
|||||||
int notused)
|
int notused)
|
||||||
{
|
{
|
||||||
FILE *fpin;
|
FILE *fpin;
|
||||||
char line[LINE_SZ+1], *cptr;
|
char line[LINE_SZ+1], *cptr, *token;
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
int foo, nbre, tokenid;
|
int foo, nbre, tokenid;
|
||||||
Bubulle bubulle;
|
Bubulle bubulle;
|
||||||
@ -143,14 +168,14 @@ if (NULL==(fpin=fopen(infname, "r"))) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bublist = alloc_bubulles(infname, 500000, 0);
|
bublist = alloc_bubulles(infname, 200000, 0);
|
||||||
if (NULL==bublist) {
|
if (NULL==bublist) {
|
||||||
fprintf(stderr, "in %s, no mem for bubls, aborting...\n", __func__);
|
fprintf(stderr, "in %s, no mem for bubls, aborting...\n", __func__);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
print_bublist_desc(bublist, 0);
|
print_bublist_desc(bublist, 0);
|
||||||
|
|
||||||
edges = alloc_edgelist("krkrkr", 200000, 0);
|
edges = alloc_edgelist("krkrkr", 400000, 0);
|
||||||
if (NULL==edges) {
|
if (NULL==edges) {
|
||||||
fprintf(stderr, "no mem for edges in %s, aborting...\n", __func__);
|
fprintf(stderr, "no mem for edges in %s, aborting...\n", __func__);
|
||||||
abort();
|
abort();
|
||||||
@ -173,9 +198,11 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
|||||||
|
|
||||||
cptr = strtok(line, " ");
|
cptr = strtok(line, " ");
|
||||||
if (NULL == cptr) {
|
if (NULL == cptr) {
|
||||||
fprintf(stderr, "no token ?\n");
|
/* this is an empty line */
|
||||||
|
// fprintf(stderr, "no token ?\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
token = cptr;
|
||||||
tokenid = type_of_the_line(cptr);
|
tokenid = type_of_the_line(cptr);
|
||||||
if (verbosity > 1)
|
if (verbosity > 1)
|
||||||
fprintf(stderr, "token '%s' --> %d\n", cptr, tokenid);
|
fprintf(stderr, "token '%s' --> %d\n", cptr, tokenid);
|
||||||
@ -202,21 +229,43 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case T_face:
|
||||||
|
/* experimental code here */
|
||||||
|
foo = parse_face(cptr, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, " '%s' parse face -> %d\n",
|
||||||
|
cptr, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_object:
|
||||||
|
cptr = strtok(NULL, " ");
|
||||||
|
fprintf(stderr, "\tObject: %s\n", cptr);
|
||||||
|
break;
|
||||||
case T_group:
|
case T_group:
|
||||||
cptr = strtok(NULL, " ");
|
cptr = strtok(NULL, " ");
|
||||||
fprintf(stderr, "\tGroup: %s\n", cptr);
|
fprintf(stderr, "\tGroup: %s\n", cptr);
|
||||||
break;
|
break;
|
||||||
|
case T_usemtl:
|
||||||
|
cptr = strtok(NULL, " ");
|
||||||
|
fprintf(stderr, "\tUsemtl: %s\n", cptr);
|
||||||
|
break;
|
||||||
|
case T_mtllib:
|
||||||
|
cptr = strtok(NULL, " ");
|
||||||
|
fprintf(stderr, "\tMtllib: %s\n", cptr);
|
||||||
|
break;
|
||||||
|
|
||||||
case T_face:
|
case T_line:
|
||||||
foo = parse_face(cptr, 0);
|
break;
|
||||||
if (foo) fprintf(stderr, " '%s' parse face -> %d\n",
|
case T_smoothing:
|
||||||
cptr, foo);
|
break;
|
||||||
|
case T_vt:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// fprintf(stderr, "\ttoken %d ?\n", tokenid);
|
fprintf(stderr, "token %s -> %d ?\n", token, tokenid);
|
||||||
continue; /* wtf ? */
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbre++;
|
nbre++;
|
||||||
@ -234,7 +283,7 @@ bubulles_to_data(file_vert, NULL, bublist, 0);
|
|||||||
free_bubulles(bublist, 0);
|
free_bubulles(bublist, 0);
|
||||||
|
|
||||||
print_edgelist_desc(edges, 0);
|
print_edgelist_desc(edges, 0);
|
||||||
print_the_edges(stdout, edges, 0);
|
edges_to_data(file_edges, edges, 0);
|
||||||
free_edgelist(edges, 0);
|
free_edgelist(edges, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
g minimal
|
o minimal
|
||||||
v 0 0 0
|
v 0 0 0
|
||||||
v 1 0 0
|
v 1 0 0
|
||||||
v 0 1 0
|
v 0 1 0
|
||||||
v 0 0 1
|
v 0 0 1
|
||||||
f 1/2, 2/3, 3/1
|
f 1/2 2/3 3/1
|
||||||
f 0/1, 0/1, 0/2
|
f 0/1 0/1 0/2
|
||||||
|
@ -20,15 +20,17 @@ int main(int argc, char *argv[])
|
|||||||
int foo;
|
int foo;
|
||||||
char *fname; /* see manpage basename(3) */
|
char *fname; /* see manpage basename(3) */
|
||||||
|
|
||||||
|
fprintf(stderr, "\n### READ_OBJ %s %s\n\n", __DATE__, __TIME__);
|
||||||
|
|
||||||
if (2 != argc) {
|
if (2 != argc) {
|
||||||
bubulles_version(1);
|
bubulles_version(1);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosity = 0;
|
verbosity = 1;
|
||||||
|
|
||||||
fname = basename(argv[1]);
|
fname = basename(argv[1]);
|
||||||
fprintf (stderr, "input fname is '%s'\n", fname);
|
fprintf (stderr, "input file name is '%s'\n", fname);
|
||||||
|
|
||||||
foo = try_to_read_an_OBJ_file(argv[1], "bulles.vertices", "bulles.edges", 0);
|
foo = try_to_read_an_OBJ_file(argv[1], "bulles.vertices", "bulles.edges", 0);
|
||||||
fprintf(stderr, "try to read '%s' -> %d\n", argv [1], foo);
|
fprintf(stderr, "try to read '%s' -> %d\n", argv [1], foo);
|
||||||
|
Loading…
Reference in New Issue
Block a user