Revision: 41094
http://brlcad.svn.sourceforge.net/brlcad/?rev=41094&view=rev
Author: brlcad
Date: 2010-10-19 05:48:31 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
reorder to avoid forward decls, fix nmg_eue_dist() linkage on Windows, pull
from header
Modified Paths:
--------------
brlcad/trunk/src/conv/jack/g-jack.c
Modified: brlcad/trunk/src/conv/jack/g-jack.c
===================================================================
--- brlcad/trunk/src/conv/jack/g-jack.c 2010-10-19 05:41:34 UTC (rev 41093)
+++ brlcad/trunk/src/conv/jack/g-jack.c 2010-10-19 05:48:31 UTC (rev 41094)
@@ -27,7 +27,6 @@
#include "common.h"
#include <stdlib.h>
-#include <stdio.h>
#include <math.h>
#include <string.h>
#include "bio.h"
@@ -39,12 +38,6 @@
#include "plot3.h"
-BU_EXTERN(union tree *do_region_end, (struct db_tree_state *tsp, const struct
db_full_path *pathp, union tree *curtree, genptr_t client_data));
-void nmg_to_psurf(struct nmgregion *r, FILE *fp_psurf);
-void jack_faces(struct nmgregion *r, FILE *fp_psurf, int *map);
-
-extern double nmg_eue_dist; /* from nmg_plot.c */
-
static const char usage[] = "\
Usage: %s [-v] [-d] [-f] [-xX lvl] [-u eu_dist]\n\
[-a abs_tess_tol] [-r rel_tess_tol] [-n norm_tess_tol]\n\
@@ -69,181 +62,157 @@
static int regions_tried = 0;
static int regions_done = 0;
+
/*
- * M A I N
+ * J A C K _ F A C E S
+ *
+ * Continues the conversion of an nmg into Jack format. Before
+ * this routine is called, a list of unique vertices has been
+ * stored in a heap. Using this heap and the nmg structure, a
+ * list of face vertices is written to the Jack data base file.
*/
-int
-main(int argc, char **argv)
+void
+jack_faces(struct nmgregion *r, FILE *fp_psurf, int *map)
+ /* NMG region to be converted. */
+ /* Jack format file to write face vertices to. */
+
{
- char *dot;
- int c;
- double percent;
- struct bu_vls fig_file;
+ struct edgeuse *eu;
+ struct faceuse *fu;
+ struct loopuse *lu;
+ struct shell *s;
+ struct vertex *v;
- bu_setlinebuf( stderr );
+ for (BU_LIST_FOR(s, shell, &r->s_hd)) {
+ /* Shell is made of faces. */
+ for (BU_LIST_FOR(fu, faceuse, &s->fu_hd)) {
+ NMG_CK_FACEUSE(fu);
+ if (fu->orientation != OT_SAME)
+ continue;
+ for (BU_LIST_FOR(lu, loopuse, &fu->lu_hd)) {
+ NMG_CK_LOOPUSE(lu);
+ if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_EDGEUSE_MAGIC) {
+ for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
+ NMG_CK_EDGEUSE(eu);
+ NMG_CK_EDGE(eu->e_p);
+ NMG_CK_VERTEXUSE(eu->vu_p);
+ NMG_CK_VERTEX(eu->vu_p->v_p);
+ NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
+ fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map,
eu->vu_p->v_p));
+ }
+ } else if (BU_LIST_FIRST_MAGIC(&lu->down_hd)
+ == NMG_VERTEXUSE_MAGIC) {
+ v = BU_LIST_PNEXT(vertexuse, &lu->down_hd)->v_p;
+ NMG_CK_VERTEX(v);
+ NMG_CK_VERTEX_G(v->vg_p);
+ fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, v));
+ } else
+ bu_log("jack_faces: loopuse mess up! (1)\n");
+ fprintf(fp_psurf, ";\n");
+ }
+ }
-#if MEMORY_LEAK_CHECKING
- rt_g.debug |= DEBUG_MEM_FULL;
-#endif
- jack_tree_state = rt_initial_tree_state; /* struct copy */
- jack_tree_state.ts_tol = &tol;
- jack_tree_state.ts_ttol = &ttol;
- jack_tree_state.ts_m = &the_model;
+ /* Shell contains loops. */
+ for (BU_LIST_FOR(lu, loopuse, &s->lu_hd)) {
+ NMG_CK_LOOPUSE(lu);
+ if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_EDGEUSE_MAGIC) {
+ for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
+ NMG_CK_EDGEUSE(eu);
+ NMG_CK_EDGE(eu->e_p);
+ NMG_CK_VERTEXUSE(eu->vu_p);
+ NMG_CK_VERTEX(eu->vu_p->v_p);
+ NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
+ fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, eu->vu_p->v_p));
+ }
+ } else if (BU_LIST_FIRST_MAGIC(&lu->down_hd)
+ == NMG_VERTEXUSE_MAGIC) {
+ v = BU_LIST_PNEXT(vertexuse, &lu->down_hd)->v_p;
+ NMG_CK_VERTEX(v);
+ NMG_CK_VERTEX_G(v->vg_p);
+ fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, v));
+ } else
+ bu_log("jack_faces: loopuse mess up! (1)\n");
+ fprintf(fp_psurf, ";\n");
+ }
- ttol.magic = RT_TESS_TOL_MAGIC;
- /* Defaults, updated by command line options. */
- ttol.abs = 0.0;
- ttol.rel = 0.01;
- ttol.norm = 0.0;
+ /* Shell contains edges. */
+ for (BU_LIST_FOR(eu, edgeuse, &s->eu_hd)) {
+ NMG_CK_EDGEUSE(eu);
+ NMG_CK_EDGE(eu->e_p);
+ NMG_CK_VERTEXUSE(eu->vu_p);
+ NMG_CK_VERTEX(eu->vu_p->v_p);
+ NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
+ fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, eu->vu_p->v_p));
+ }
+ if (BU_LIST_FIRST_MAGIC(&s->eu_hd) == NMG_EDGEUSE_MAGIC)
+ fprintf(fp_psurf, ";\n");
- /* FIXME: These need to be improved */
- tol.magic = BN_TOL_MAGIC;
- tol.dist = 0.0005;
- tol.dist_sq = tol.dist * tol.dist;
- tol.perp = 1e-5;
- tol.para = 1 - tol.perp;
+ /* Shell contains a single vertex. */
+ if (s->vu_p) {
+ NMG_CK_VERTEXUSE(s->vu_p);
+ NMG_CK_VERTEX(s->vu_p->v_p);
+ NMG_CK_VERTEX_G(s->vu_p->v_p->vg_p);
+ fprintf(fp_psurf, "%d;\n", NMG_INDEX_GET(map, s->vu_p->v_p));
+ }
- /* For visualization purposes, in the debug plot files */
- {
- extern fastf_t nmg_eue_dist; /* librt/nmg_plot.c */
+ if (BU_LIST_IS_EMPTY(&s->fu_hd) &&
+ BU_LIST_IS_EMPTY(&s->lu_hd) &&
+ BU_LIST_IS_EMPTY(&s->eu_hd) && !s->vu_p) {
+ bu_log("WARNING jack_faces: empty shell\n");
+ }
- /* WTF: This value is specific to the Bradley */
- /* Set it here, before the bu_getopt() */
- nmg_eue_dist = 2.0;
}
+ fprintf(fp_psurf, ";;\n");
+}
- rt_init_resource( &rt_uniresource, 0, NULL );
- the_model = nmg_mm();
- BU_LIST_INIT( &rt_g.rtg_vlfree ); /* for vlist macros */
+/*
+ * N M G _ T O _ P S U R F
+ *
+ * Convert an nmg region into Jack format. This routine makes a
+ * list of unique vertices and writes them to the ascii Jack
+ * data base file. Then a routine to generate the face vertex
+ * data is called.
+ */
+void
+nmg_to_psurf(struct nmgregion *r, FILE *fp_psurf)
+ /* NMG region to be converted. */
+ /* Jack format file to write vertex list to. */
+{
+ int i;
+ int *map; /* map from v->index to Jack vert # */
+ struct bu_ptbl vtab; /* vertex table */
- /* Get command line arguments. */
- while ((c = bu_getopt(argc, argv, "a:dfn:p:r:u:vx:D:P:X:")) != EOF) {
- switch (c) {
- case 'a': /* Absolute tolerance. */
- ttol.abs = atof(bu_optarg);
- break;
- case 'd':
- debug_plots = 1;
- break;
- case 'f':
- no_file_output = 1;
- break;
- case 'n': /* Surface normal tolerance. */
- ttol.norm = atof(bu_optarg);
- break;
- case 'p': /* Prefix for Jack file names. */
- prefix = bu_optarg;
- break;
- case 'r': /* Relative tolerance. */
- ttol.rel = atof(bu_optarg);
- break;
- case 'u':
- nmg_eue_dist = atof(bu_optarg);
- break;
- case 'v':
- verbose++;
- break;
- case 'P':
- ncpu = atoi( bu_optarg );
- rt_g.debug = 1;
- break;
- case 'x':
- sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.debug );
- break;
- case 'D':
- tol.dist = atof(bu_optarg);
- tol.dist_sq = tol.dist * tol.dist;
- rt_pr_tol( &tol );
- break;
- case 'X':
- sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.NMG_debug );
- NMG_debug = rt_g.NMG_debug;
- break;
- default:
- bu_exit(1, usage, argv[0]);
- break;
- }
- }
+ map = (int *)bu_calloc(r->m_p->maxindex, sizeof(int *), "Jack vert map");
- if (bu_optind+1 >= argc) {
- bu_exit(1, usage, argv[0]);
- }
+ /* Built list of vertex structs */
+ nmg_vertex_tabulate( &vtab, &r->l.magic );
- /* Open BRL-CAD database */
- argc -= bu_optind;
- argv += bu_optind;
- if ((dbip = db_open(argv[0], "r")) == DBI_NULL) {
- perror(argv[0]);
- bu_exit(1, "Unable to open geometry database file [%s]\n", argv[0]);
- }
- if ( db_dirbuild( dbip ) ) {
- bu_exit(1, "db_dirbuild failed\n" );
- }
+ /* FIXME: What to do if 0 vertices? */
- /* Create .fig file name and open it. */
- bu_vls_init( &fig_file );
- /* Ignore leading path name. */
- if ((dot = strrchr(argv[0], '/')) != (char *)NULL) {
- if (prefix)
- bu_vls_strcpy( &fig_file, prefix );
- bu_vls_strcat( &fig_file, dot+1 );
- } else {
- if (prefix)
- bu_vls_strcpy( &fig_file, prefix );
- bu_vls_strcat( &fig_file, argv[0] );
+ /* Print list of unique vertices and convert from mm to cm. */
+ for (i = 0; i < BU_PTBL_END(&vtab); i++) {
+ struct vertex *v;
+ struct vertex_g *vg;
+ v = (struct vertex *)BU_PTBL_GET(&vtab, i);
+ NMG_CK_VERTEX(v);
+ vg = v->vg_p;
+ NMG_CK_VERTEX_G(vg);
+ NMG_INDEX_ASSIGN( map, v, i+1 ); /* map[v->index] = i+1 */
+ fprintf(fp_psurf, "%f\t%f\t%f\n",
+ vg->coord[X] / 10.,
+ vg->coord[Y] / 10.,
+ vg->coord[Z] / 10.);
}
+ fprintf(fp_psurf, ";;\n");
- /* Get rid of any file name extension (probably .g). */
- if ((dot = strrchr(bu_vls_addr(&fig_file), '.')) != (char *)NULL) {
- *dot = '\0';
- /* Recalculate shorter VLS length. Ugh. */
- bu_vls_trunc( &fig_file, dot - bu_vls_addr(&fig_file) );
- }
- bu_vls_strcat( &fig_file, ".fig"); /* Add required Jack suffix. */
+ jack_faces(r, fp_psurf, map);
- if ((fp_fig = fopen(bu_vls_addr(&fig_file), "wb")) == NULL) {
- perror(bu_vls_addr(&fig_file));
- bu_exit(2, "Unable to open fig file [%s]\n", bu_vls_addr(&fig_file));
- }
- fprintf(fp_fig, "figure {\n");
- bu_vls_init(&base_seg); /* .fig figure file's main segment. */
-
- BN_CK_TOL(jack_tree_state.ts_tol);
- RT_CK_TESS_TOL(jack_tree_state.ts_ttol);
-
- /* Walk indicated tree(s). Each region will be output separately */
- (void) db_walk_tree(dbip, argc-1, (const char **)(argv+1),
- 1, /* ncpu */
- &jack_tree_state,
- 0, /* take all regions */
- do_region_end,
- nmg_booltree_leaf_tess,
- (genptr_t)NULL); /* in librt/nmg_bool.c */
-
- fprintf(fp_fig, "\troot=%s_seg.base;\n", bu_vls_addr(&base_seg));
- fprintf(fp_fig, "}\n");
- fclose(fp_fig);
- bu_vls_free(&fig_file);
- bu_vls_free(&base_seg);
-
- percent = 0;
- if (regions_tried>0) percent = ((double)regions_done * 100) /
regions_tried;
- printf("Tried %d regions, %d converted successfully. %g%%\n",
- regions_tried, regions_done, percent);
-
- /* Release dynamic storage */
- nmg_km(the_model);
- rt_vlist_cleanup();
- db_close(dbip);
-
-#if MEMORY_LEAK_CHECKING
- bu_prmem("After complete G-JACK conversion");
-#endif
-
- return 0;
+ bu_ptbl_free(&vtab);
+ bu_free( (char *)map, "Jack vert map" );
}
+
/*
* D O _ R E G I O N _ E N D
*
@@ -251,10 +220,9 @@
*
* This routine must be prepared to run in parallel.
*/
-union tree *do_region_end(struct db_tree_state *tsp, const struct db_full_path
*pathp, union tree *curtree, genptr_t client_data)
+union tree *do_region_end(struct db_tree_state *tsp, const struct db_full_path
*pathp, union tree *curtree, genptr_t UNUSED(client_data))
{
union tree *ret_tree;
- struct bu_list vhead;
struct nmgregion *r;
RT_CK_FULL_PATH(pathp);
@@ -263,8 +231,6 @@
BN_CK_TOL(tsp->ts_tol);
NMG_CK_MODEL(*tsp->ts_m);
- BU_LIST_INIT(&vhead);
-
if (RT_G_DEBUG&DEBUG_TREEWALK || verbose) {
char *sofar = db_path_to_string(pathp);
bu_log("\ndo_region_end(%d %d%%) %s\n",
@@ -423,155 +389,174 @@
}
/*
- * N M G _ T O _ P S U R F
- *
- * Convert an nmg region into Jack format. This routine makes a
- * list of unique vertices and writes them to the ascii Jack
- * data base file. Then a routine to generate the face vertex
- * data is called.
+ * M A I N
*/
-
-void
-nmg_to_psurf(struct nmgregion *r, FILE *fp_psurf)
- /* NMG region to be converted. */
- /* Jack format file to write vertex list to. */
+int
+main(int argc, char **argv)
{
- int i;
- int *map; /* map from v->index to Jack vert # */
- struct bu_ptbl vtab; /* vertex table */
+ char *dot;
+ int c;
+ double percent;
+ struct bu_vls fig_file;
- map = (int *)bu_calloc(r->m_p->maxindex, sizeof(int *), "Jack vert map");
+ bu_setlinebuf( stderr );
- /* Built list of vertex structs */
- nmg_vertex_tabulate( &vtab, &r->l.magic );
+ jack_tree_state = rt_initial_tree_state; /* struct copy */
+ jack_tree_state.ts_tol = &tol;
+ jack_tree_state.ts_ttol = &ttol;
+ jack_tree_state.ts_m = &the_model;
- /* FIXME: What to do if 0 vertices? */
+ ttol.magic = RT_TESS_TOL_MAGIC;
+ /* Defaults, updated by command line options. */
+ ttol.abs = 0.0;
+ ttol.rel = 0.01;
+ ttol.norm = 0.0;
- /* Print list of unique vertices and convert from mm to cm. */
- for (i = 0; i < BU_PTBL_END(&vtab); i++) {
- struct vertex *v;
- struct vertex_g *vg;
- v = (struct vertex *)BU_PTBL_GET(&vtab, i);
- NMG_CK_VERTEX(v);
- vg = v->vg_p;
- NMG_CK_VERTEX_G(vg);
- NMG_INDEX_ASSIGN( map, v, i+1 ); /* map[v->index] = i+1 */
- fprintf(fp_psurf, "%f\t%f\t%f\n",
- vg->coord[X] / 10.,
- vg->coord[Y] / 10.,
- vg->coord[Z] / 10.);
- }
- fprintf(fp_psurf, ";;\n");
+ /* FIXME: These need to be improved */
+ tol.magic = BN_TOL_MAGIC;
+ tol.dist = 0.0005;
+ tol.dist_sq = tol.dist * tol.dist;
+ tol.perp = 1e-5;
+ tol.para = 1 - tol.perp;
- jack_faces(r, fp_psurf, map);
+ /* For visualization purposes, in the debug plot files */
+ {
+ extern fastf_t nmg_eue_dist; /* librt/nmg_plot.c */
- bu_ptbl_free(&vtab);
- bu_free( (char *)map, "Jack vert map" );
-}
+ /* WTF: This value is specific to the Bradley */
+ /* Set it here, before the bu_getopt() */
+ nmg_eue_dist = 2.0;
+ }
+ rt_init_resource( &rt_uniresource, 0, NULL );
-/*
- * J A C K _ F A C E S
- *
- * Continues the conversion of an nmg into Jack format. Before
- * this routine is called, a list of unique vertices has been
- * stored in a heap. Using this heap and the nmg structure, a
- * list of face vertices is written to the Jack data base file.
- */
-void
-jack_faces(struct nmgregion *r, FILE *fp_psurf, int *map)
- /* NMG region to be converted. */
- /* Jack format file to write face vertices to. */
+ the_model = nmg_mm();
+ BU_LIST_INIT( &rt_g.rtg_vlfree ); /* for vlist macros */
-{
- struct edgeuse *eu;
- struct faceuse *fu;
- struct loopuse *lu;
- struct shell *s;
- struct vertex *v;
-
- for (BU_LIST_FOR(s, shell, &r->s_hd)) {
- /* Shell is made of faces. */
- for (BU_LIST_FOR(fu, faceuse, &s->fu_hd)) {
- NMG_CK_FACEUSE(fu);
- if (fu->orientation != OT_SAME)
- continue;
- for (BU_LIST_FOR(lu, loopuse, &fu->lu_hd)) {
- NMG_CK_LOOPUSE(lu);
- if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_EDGEUSE_MAGIC) {
- for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
- NMG_CK_EDGEUSE(eu);
- NMG_CK_EDGE(eu->e_p);
- NMG_CK_VERTEXUSE(eu->vu_p);
- NMG_CK_VERTEX(eu->vu_p->v_p);
- NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
- fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map,
eu->vu_p->v_p));
- }
- } else if (BU_LIST_FIRST_MAGIC(&lu->down_hd)
- == NMG_VERTEXUSE_MAGIC) {
- v = BU_LIST_PNEXT(vertexuse, &lu->down_hd)->v_p;
- NMG_CK_VERTEX(v);
- NMG_CK_VERTEX_G(v->vg_p);
- fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, v));
- } else
- bu_log("jack_faces: loopuse mess up! (1)\n");
- fprintf(fp_psurf, ";\n");
- }
+ /* Get command line arguments. */
+ while ((c = bu_getopt(argc, argv, "a:dfn:p:r:u:vx:D:P:X:")) != EOF) {
+ switch (c) {
+ case 'a': /* Absolute tolerance. */
+ ttol.abs = atof(bu_optarg);
+ break;
+ case 'd':
+ debug_plots = 1;
+ break;
+ case 'f':
+ no_file_output = 1;
+ break;
+ case 'n': /* Surface normal tolerance. */
+ ttol.norm = atof(bu_optarg);
+ break;
+ case 'p': /* Prefix for Jack file names. */
+ prefix = bu_optarg;
+ break;
+ case 'r': /* Relative tolerance. */
+ ttol.rel = atof(bu_optarg);
+ break;
+ case 'u':
+ nmg_eue_dist = atof(bu_optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'P':
+ ncpu = atoi( bu_optarg );
+ rt_g.debug = 1;
+ break;
+ case 'x':
+ sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.debug );
+ break;
+ case 'D':
+ tol.dist = atof(bu_optarg);
+ tol.dist_sq = tol.dist * tol.dist;
+ rt_pr_tol( &tol );
+ break;
+ case 'X':
+ sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.NMG_debug );
+ NMG_debug = rt_g.NMG_debug;
+ break;
+ default:
+ bu_exit(1, usage, argv[0]);
+ break;
}
+ }
- /* Shell contains loops. */
- for (BU_LIST_FOR(lu, loopuse, &s->lu_hd)) {
- NMG_CK_LOOPUSE(lu);
- if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_EDGEUSE_MAGIC) {
- for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
- NMG_CK_EDGEUSE(eu);
- NMG_CK_EDGE(eu->e_p);
- NMG_CK_VERTEXUSE(eu->vu_p);
- NMG_CK_VERTEX(eu->vu_p->v_p);
- NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
- fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, eu->vu_p->v_p));
- }
- } else if (BU_LIST_FIRST_MAGIC(&lu->down_hd)
- == NMG_VERTEXUSE_MAGIC) {
- v = BU_LIST_PNEXT(vertexuse, &lu->down_hd)->v_p;
- NMG_CK_VERTEX(v);
- NMG_CK_VERTEX_G(v->vg_p);
- fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, v));
- } else
- bu_log("jack_faces: loopuse mess up! (1)\n");
- fprintf(fp_psurf, ";\n");
- }
+ if (bu_optind+1 >= argc) {
+ bu_exit(1, usage, argv[0]);
+ }
- /* Shell contains edges. */
- for (BU_LIST_FOR(eu, edgeuse, &s->eu_hd)) {
- NMG_CK_EDGEUSE(eu);
- NMG_CK_EDGE(eu->e_p);
- NMG_CK_VERTEXUSE(eu->vu_p);
- NMG_CK_VERTEX(eu->vu_p->v_p);
- NMG_CK_VERTEX_G(eu->vu_p->v_p->vg_p);
- fprintf(fp_psurf, "%d ", NMG_INDEX_GET(map, eu->vu_p->v_p));
- }
- if (BU_LIST_FIRST_MAGIC(&s->eu_hd) == NMG_EDGEUSE_MAGIC)
- fprintf(fp_psurf, ";\n");
+ /* Open BRL-CAD database */
+ argc -= bu_optind;
+ argv += bu_optind;
+ if ((dbip = db_open(argv[0], "r")) == DBI_NULL) {
+ perror(argv[0]);
+ bu_exit(1, "Unable to open geometry database file [%s]\n", argv[0]);
+ }
+ if ( db_dirbuild( dbip ) ) {
+ bu_exit(1, "db_dirbuild failed\n" );
+ }
- /* Shell contains a single vertex. */
- if (s->vu_p) {
- NMG_CK_VERTEXUSE(s->vu_p);
- NMG_CK_VERTEX(s->vu_p->v_p);
- NMG_CK_VERTEX_G(s->vu_p->v_p->vg_p);
- fprintf(fp_psurf, "%d;\n", NMG_INDEX_GET(map, s->vu_p->v_p));
- }
+ /* Create .fig file name and open it. */
+ bu_vls_init( &fig_file );
+ /* Ignore leading path name. */
+ if ((dot = strrchr(argv[0], '/')) != (char *)NULL) {
+ if (prefix)
+ bu_vls_strcpy( &fig_file, prefix );
+ bu_vls_strcat( &fig_file, dot+1 );
+ } else {
+ if (prefix)
+ bu_vls_strcpy( &fig_file, prefix );
+ bu_vls_strcat( &fig_file, argv[0] );
+ }
- if (BU_LIST_IS_EMPTY(&s->fu_hd) &&
- BU_LIST_IS_EMPTY(&s->lu_hd) &&
- BU_LIST_IS_EMPTY(&s->eu_hd) && !s->vu_p) {
- bu_log("WARNING jack_faces: empty shell\n");
- }
+ /* Get rid of any file name extension (probably .g). */
+ if ((dot = strrchr(bu_vls_addr(&fig_file), '.')) != (char *)NULL) {
+ *dot = '\0';
+ /* Recalculate shorter VLS length. Ugh. */
+ bu_vls_trunc( &fig_file, dot - bu_vls_addr(&fig_file) );
+ }
+ bu_vls_strcat( &fig_file, ".fig"); /* Add required Jack suffix. */
+ if ((fp_fig = fopen(bu_vls_addr(&fig_file), "wb")) == NULL) {
+ perror(bu_vls_addr(&fig_file));
+ bu_exit(2, "Unable to open fig file [%s]\n", bu_vls_addr(&fig_file));
}
- fprintf(fp_psurf, ";;\n");
+ fprintf(fp_fig, "figure {\n");
+ bu_vls_init(&base_seg); /* .fig figure file's main segment. */
+
+ BN_CK_TOL(jack_tree_state.ts_tol);
+ RT_CK_TESS_TOL(jack_tree_state.ts_ttol);
+
+ /* Walk indicated tree(s). Each region will be output separately */
+ (void) db_walk_tree(dbip, argc-1, (const char **)(argv+1),
+ 1, /* ncpu */
+ &jack_tree_state,
+ 0, /* take all regions */
+ do_region_end,
+ nmg_booltree_leaf_tess,
+ (genptr_t)NULL); /* in librt/nmg_bool.c */
+
+ fprintf(fp_fig, "\troot=%s_seg.base;\n", bu_vls_addr(&base_seg));
+ fprintf(fp_fig, "}\n");
+ fclose(fp_fig);
+ bu_vls_free(&fig_file);
+ bu_vls_free(&base_seg);
+
+ percent = 0;
+ if (regions_tried>0) percent = ((double)regions_done * 100) /
regions_tried;
+ printf("Tried %d regions, %d converted successfully. %g%%\n",
+ regions_tried, regions_done, percent);
+
+ /* Release dynamic storage */
+ nmg_km(the_model);
+ rt_vlist_cleanup();
+ db_close(dbip);
+
+ return 0;
}
+
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits