Compare commits
3 Commits
4bca017774
...
02bbdc7249
Author | SHA1 | Date | |
---|---|---|---|
|
02bbdc7249 | ||
|
300bcfa7a0 | ||
|
3dbcb198bf |
8
.gitignore
vendored
8
.gitignore
vendored
@ -7,11 +7,3 @@ gmon.out
|
||||
dummy-file
|
||||
toto
|
||||
|
||||
tools/*.obj
|
||||
! tools/minimal.obj
|
||||
! tools/cube.obj
|
||||
tools/read_obj
|
||||
tools/*.xyz
|
||||
tools/*.asc
|
||||
tools/toto
|
||||
tools/core
|
||||
|
12
tools/.gitignore
vendored
12
tools/.gitignore
vendored
@ -1,8 +1,18 @@
|
||||
|
||||
essai_faces
|
||||
read_obj
|
||||
export_evblob
|
||||
|
||||
*.obj
|
||||
! tools/minimal.obj
|
||||
! tools/cube.obj
|
||||
read_obj
|
||||
*.xyz
|
||||
*.asc
|
||||
toto
|
||||
core
|
||||
|
||||
*.vertices
|
||||
*.edges
|
||||
*.blob
|
||||
*.evblob
|
||||
|
||||
|
@ -3,10 +3,18 @@ BBFUNCS = ../libbubulles.a
|
||||
|
||||
OPT = -Wall -Wextra -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
||||
|
||||
read_obj: read_obj.c Makefile importobj.o rdwredges.o \
|
||||
# ---------
|
||||
|
||||
read_obj: read_obj.c Makefile importobj.o rdwredges.o \
|
||||
$(BBFUNCS)
|
||||
gcc $(OPT) $< importobj.o rdwredges.o $(BBFUNCS) -o $@
|
||||
|
||||
export_evblob: export_evblob.c Makefile importobj.o rdwredges.o \
|
||||
$(BBFUNCS)
|
||||
gcc $(OPT) $< importobj.o rdwredges.o $(BBFUNCS) -o $@
|
||||
|
||||
# ---------
|
||||
|
||||
importobj.o: importobj.c ../bubulles.h ../edges.h Makefile
|
||||
$(CC) $(OPT) -c $<
|
||||
|
||||
|
70
tools/export_evblob.c
Normal file
70
tools/export_evblob.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* EdgesAndVertices
|
||||
|
||||
https://git.tetalab.org/tTh/libbubulle/src/branch/master/tools/
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../bubulles.h"
|
||||
#include "../edges.h"
|
||||
|
||||
#include "objtrucs.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
EdgesAndVertices eav;
|
||||
int foo, idx, a, b;
|
||||
|
||||
fprintf(stderr, "### EdgesAndVertices - %s %s\n", __DATE__, __TIME__);
|
||||
|
||||
verbosity = 0;
|
||||
|
||||
memset(&eav, 0, sizeof(EdgesAndVertices));
|
||||
foo = x_load_vertedges("foo.evblob", &eav);
|
||||
fprintf(stderr, " load vertice & edges blob -> %d\n", foo);
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "vertices at %p\n", eav.Blist);
|
||||
fprintf(stderr, "edges at %p\n", eav.Elist);
|
||||
fprintf(stderr, "status is %d\n", eav.status);
|
||||
}
|
||||
|
||||
/*
|
||||
* OK we have (maybe) all the data in da place
|
||||
* and we can spit all the edges to stdout
|
||||
*/
|
||||
fprintf(stderr, "got %d vertices and %d edges\n",
|
||||
eav.Blist->fidx,
|
||||
eav.Elist->fidx);
|
||||
|
||||
for (idx=0; idx<eav.Elist->fidx; idx++) {
|
||||
|
||||
a = eav.Elist->edges[idx].A;
|
||||
b = eav.Elist->edges[idx].B;
|
||||
// fprintf(stderr, "%7d %7d\n", a, b);
|
||||
|
||||
printf("%.9f %f %f %f %f %f\n",
|
||||
eav.Blist->bbs[a].p.x,
|
||||
eav.Blist->bbs[a].p.y,
|
||||
eav.Blist->bbs[a].p.z,
|
||||
eav.Blist->bbs[b].p.x,
|
||||
eav.Blist->bbs[b].p.y,
|
||||
eav.Blist->bbs[b].p.z );
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
@ -158,7 +158,7 @@ for (ix=0; ix<3; ix++) {
|
||||
|
||||
if (dropped) {
|
||||
fprintf(stderr, "%s: %d dropped...\n", __func__, dropped);
|
||||
exit(1);
|
||||
// exit(1);
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
@ -309,7 +309,7 @@ bubulles_to_data(file_vert, NULL, bublist, 0);
|
||||
|
||||
edges_to_data(file_edges, edges, 0);
|
||||
|
||||
foo = x_write_vertedges("foo.blob", bublist, edges);
|
||||
foo = x_write_vertedges("foo.evblob", bublist, edges);
|
||||
|
||||
// Cleanup
|
||||
free_bubulles(bublist, 0);
|
||||
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
* EXPERIMENTAL CODE !
|
||||
*
|
||||
* see also 'rdwredges.c
|
||||
*/
|
||||
|
||||
|
||||
@ -8,7 +10,8 @@ typedef struct {
|
||||
BBList *Blist;
|
||||
EdgeList *Elist;
|
||||
int status;
|
||||
} EdgeAndVertices;
|
||||
} EdgesAndVertices;
|
||||
|
||||
int x_write_vertedges(char *filename, BBList *bblist, EdgeList *edges);
|
||||
|
||||
int x_load_vertedges(char *filename, EdgesAndVertices *eav);
|
||||
|
@ -19,6 +19,17 @@
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
static void dumper(void *ptr, int count)
|
||||
{
|
||||
int idx;
|
||||
unsigned char *cptr = (unsigned char *)ptr;
|
||||
|
||||
for (idx=0; idx<count; idx++) {
|
||||
fprintf(stderr, "%02x", cptr[idx]);
|
||||
}
|
||||
fprintf(stderr, " ?\n");
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
int x_write_vertedges(char *filename, BBList *bblist, EdgeList *edges)
|
||||
@ -26,9 +37,12 @@ int x_write_vertedges(char *filename, BBList *bblist, EdgeList *edges)
|
||||
FILE *fp;
|
||||
int idx, edg[2];
|
||||
double coo[3];
|
||||
int nbre;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__, filename,
|
||||
bblist, edges);
|
||||
#endif
|
||||
|
||||
if (NULL==(fp=fopen(filename, "w"))) {
|
||||
perror(filename);
|
||||
@ -37,8 +51,10 @@ if (NULL==(fp=fopen(filename, "w"))) {
|
||||
|
||||
print_bublist_desc(bblist, 0);
|
||||
fwrite("VERTICES", 8, 1, fp);
|
||||
nbre = bblist->fidx;
|
||||
fwrite(&nbre, sizeof(int), 1, fp);
|
||||
for (idx=0; idx<bblist->fidx; idx++) {
|
||||
fprintf(stderr, "vertice %d\n", idx);
|
||||
// fprintf(stderr, "vertice %d\n", idx);
|
||||
coo[0] = bblist->bbs[idx].p.x;
|
||||
coo[1] = bblist->bbs[idx].p.y;
|
||||
coo[2] = bblist->bbs[idx].p.z;
|
||||
@ -47,6 +63,8 @@ for (idx=0; idx<bblist->fidx; idx++) {
|
||||
|
||||
print_edgelist_desc(edges, 0);
|
||||
fwrite("EDGES ", 8, 1, fp);
|
||||
nbre = edges->fidx;
|
||||
fwrite(&nbre, sizeof(int), 1, fp);
|
||||
for (idx=0; idx<edges->fidx; idx++) {
|
||||
edg[0] = edges->edges[idx].A;
|
||||
edg[1] = edges->edges[idx].B;
|
||||
@ -57,3 +75,108 @@ fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
int x_load_vertedges(char *filename, EdgesAndVertices *eav)
|
||||
{
|
||||
BBList *blst;
|
||||
EdgeList *elst;
|
||||
FILE *fp;
|
||||
char marker[8];
|
||||
int nbre, foo, idx, edg[2];
|
||||
double coo[3];
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, eav);
|
||||
#endif
|
||||
|
||||
if (NULL==(fp=fopen(filename, "r"))) {
|
||||
perror(filename);
|
||||
return -4;
|
||||
}
|
||||
|
||||
/* + + + + + + + + + + + */
|
||||
foo = fread(marker, 8, 1, fp);
|
||||
if (1 != foo) {
|
||||
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
|
||||
return -1;
|
||||
}
|
||||
if (memcmp("VERTICES", marker, 8)) {
|
||||
fprintf(stderr, " %s is not an evblob file.\n", filename);
|
||||
dumper(marker, 8);
|
||||
return -4;
|
||||
}
|
||||
|
||||
/* now, get the numbers of vertices */
|
||||
foo = fread(&nbre, sizeof(int), 1, fp);
|
||||
if (1 != foo) {
|
||||
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
|
||||
return -1;
|
||||
}
|
||||
fprintf(stderr, " %d vertices to be loaded\n", nbre);
|
||||
|
||||
/* allocate memory */
|
||||
blst = alloc_bubulles(filename, nbre, 0);
|
||||
if (NULL==blst) {
|
||||
fprintf(stderr, "in %s, no mem, aborting...\n", __func__);
|
||||
abort();
|
||||
}
|
||||
if (verbosity > 1) print_bublist_desc(blst, 0);
|
||||
/* load all that XYZ points */
|
||||
for (idx=0; idx<nbre; idx++) {
|
||||
if (3 != fread(coo, sizeof(double), 3, fp)) {
|
||||
fprintf(stderr, "%s err reading vertice #%d\n", __func__, idx);
|
||||
exit(1);
|
||||
}
|
||||
blst->bbs[idx].p.x = coo[0];
|
||||
blst->bbs[idx].p.y = coo[1];
|
||||
blst->bbs[idx].p.z = coo[2];
|
||||
blst->fidx++;
|
||||
}
|
||||
|
||||
/* + + + + + + + + + + + */
|
||||
foo = fread(marker, 8, 1, fp);
|
||||
if (1 != foo) {
|
||||
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
|
||||
return -1;
|
||||
}
|
||||
if (memcmp("EDGES ", marker, 8)) {
|
||||
fprintf(stderr, " %s is not an evblob file.\n", filename);
|
||||
dumper(marker, 8);
|
||||
return -4;
|
||||
}
|
||||
/* now, get the numbers of eges */
|
||||
foo = fread(&nbre, sizeof(int), 1, fp);
|
||||
if (1 != foo) {
|
||||
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
|
||||
return -1;
|
||||
}
|
||||
fprintf(stderr, " %d edges to be loaded\n", nbre);
|
||||
/* allocate memory for edges list */
|
||||
elst = alloc_edgelist("krkrkr", nbre, 0);
|
||||
if (NULL==elst) {
|
||||
fprintf(stderr, "no mem for edges in %s, aborting...\n", __func__);
|
||||
abort(); /* be violent before OOMK */
|
||||
}
|
||||
|
||||
/* read (and check ?) the edges */
|
||||
for (idx=0; idx<nbre; idx++) {
|
||||
if (2 != fread(edg, sizeof(int), 2, fp)) {
|
||||
fprintf(stderr, "%s: err reading edge #%d\n", __func__, idx);
|
||||
return -6;
|
||||
}
|
||||
elst->edges[idx].A = edg[0];
|
||||
elst->edges[idx].B = edg[1];
|
||||
elst->fidx++;
|
||||
}
|
||||
|
||||
/* so, now I think we have got all the data */
|
||||
eav->Blist = blst;
|
||||
eav->Elist = elst;
|
||||
eav->status = 0x51;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user