Skip to content

Commit

Permalink
More cleanup in error cases
Browse files Browse the repository at this point in the history
May want to allow an environment variable or some such to keep the working .g
for debugging in case of problems, but by default clean up after ourselves.
  • Loading branch information
starseeker committed Dec 4, 2023
1 parent 6101897 commit 5e73430
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/libged/facetize/tri_booleval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ _ged_facetize_booleval(struct _ged_facetize_state *s, int argc, struct directory
// materially contribute to the final object shape, but for some
// applications like visualization there are cases where "something is
// better than nothing" applies
bu_file_delete(wfile);
return -1;
}
}
Expand All @@ -498,11 +499,17 @@ _ged_facetize_booleval(struct _ged_facetize_state *s, int argc, struct directory
// the tree walk to set up Manifold data. Using the working copy
// means we will be getting the correct triangle data for each solid
struct db_i *wdbip = db_open(wfile, DB_OPEN_READONLY);
if (!wdbip)
if (!wdbip) {
bu_file_delete(wfile);
return BRLCAD_ERROR;
if (db_dirbuild(wdbip) < 0)
}
if (db_dirbuild(wdbip) < 0) {
bu_file_delete(wfile);
return BRLCAD_ERROR;
}
db_update_nref(wdbip, &rt_uniresource);

// Need wdbp in the next two stages for tolerances
struct rt_wdb *wwdbp = wdb_dbopen(wdbip, RT_WDB_TYPE_DB_DEFAULT);

/* Second stage is to prepare Manifold versions of the instances of the BoT
Expand Down Expand Up @@ -540,19 +547,25 @@ _ged_facetize_booleval(struct _ged_facetize_state *s, int argc, struct directory

if (i < 0) {
bu_free(av, "av");
db_close(wdbip);
bu_file_delete(wfile);
return -1;
}
bu_free(av, "av");
}

// TODO - We don't have a tree - whether that's an error or not depends
if (!s->facetize_tree) {
db_close(wdbip);
bu_file_delete(wfile);
return 0;
}

// Third stage is to execute the boolean operations
union tree *ftree = rt_booltree_evaluate(s->facetize_tree, &RTG.rtg_vlfree, &wwdbp->wdb_tol, &rt_uniresource, &manifold_do_bool, 0, (void *)s);
if (!ftree) {
db_close(wdbip);
bu_file_delete(wfile);
return -1;
}

Expand Down

0 comments on commit 5e73430

Please sign in to comment.