Revision: 75768
http://sourceforge.net/p/brlcad/code/75768
Author: starseeker
Date: 2020-05-12 15:14:38 +0000 (Tue, 12 May 2020)
Log Message:
-----------
Start reworking arg handling for bot command
Modified Paths:
--------------
brlcad/trunk/src/libged/bot/bot.cpp
brlcad/trunk/src/libged/bot/check.cpp
brlcad/trunk/src/libged/bot/extrude.cpp
brlcad/trunk/src/libged/bot/ged_bot.h
brlcad/trunk/src/libged/bot/remesh.cpp
Modified: brlcad/trunk/src/libged/bot/bot.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/bot.cpp 2020-05-12 14:51:24 UTC (rev 75767)
+++ brlcad/trunk/src/libged/bot/bot.cpp 2020-05-12 15:14:38 UTC (rev 75768)
@@ -51,6 +51,38 @@
#include "./ged_bot.h"
int
+_bot_obj_setup(struct _ged_bot_info *gb, const char *name)
+{
+ gb->dp = db_lookup(gb->gedp->ged_wdbp->dbip, name, LOOKUP_NOISY);
+ if (gb->dp == RT_DIR_NULL) {
+ bu_vls_printf(gb->gedp->ged_result_str, ": %s is not a solid or does
not exist in database", name);
+ return GED_ERROR;
+ } else {
+ int real_flag = (gb->dp->d_addr == RT_DIR_PHONY_ADDR) ? 0 : 1;
+ if (!real_flag) {
+ /* solid doesn't exist */
+ bu_vls_printf(gb->gedp->ged_result_str, ": %s is not a real solid",
name);
+ return GED_ERROR;
+ }
+ }
+
+ gb->solid_name = std::string(name);
+
+ BU_GET(gb->intern, struct rt_db_internal);
+
+ GED_DB_GET_INTERNAL(gb->gedp, gb->intern, gb->dp, bn_mat_identity,
&rt_uniresource, GED_ERROR);
+ RT_CK_DB_INTERNAL(gb->intern);
+
+ if (gb->intern->idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
+ bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
+ return GED_ERROR;
+ }
+
+ return GED_OK;
+}
+
+
+int
_bot_cmd_msgs(void *bs, int argc, const char **argv, const char *us, const
char *ps)
{
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
@@ -68,7 +100,7 @@
extern "C" int
_bot_cmd_get(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname> get
<faces|minEdge|maxEdge|orientation|type|vertices>";
+ const char *usage_string = "bot get
<faces|minEdge|maxEdge|orientation|type|vertices> <objname>";
const char *purpose_string = "Report specific information about a BoT
shape";
if (_bot_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -76,19 +108,20 @@
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
+ argc--; argv++;
+
+ if (argc != 2) {
+ bu_vls_printf(gb->gedp->ged_result_str, "%s", usage_string);
return GED_ERROR;
}
- if (argc < 2) {
- bu_vls_printf(gb->gedp->ged_result_str, "%s", usage_string);
+ if (_bot_obj_setup(gb, argv[1]) == GED_ERROR) {
return GED_ERROR;
}
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern->idb_ptr);
- fastf_t propVal = rt_bot_propget(bot, argv[1]);
+ fastf_t propVal = rt_bot_propget(bot, argv[0]);
/* print result string */
if (!EQUAL(propVal, -1.0)) {
@@ -113,8 +146,8 @@
extern "C" int
_bot_cmd_chull(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname> chull output_bot";
- const char *purpose_string = "Generate the BoT's convex hull and store it
in object <output_bot>";
+ const char *usage_string = "bot [options] chull <objname> [output_bot]";
+ const char *purpose_string = "Generate the BoT's convex hull and store it
in an object";
if (_bot_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
}
@@ -121,12 +154,11 @@
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
+ if (_bot_obj_setup(gb, argv[0]) == GED_ERROR) {
return GED_ERROR;
}
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern->idb_ptr);
int retval = 0;
int fc = 0;
int vc = 0;
@@ -146,8 +178,22 @@
return GED_ERROR;
}
- retval = mk_bot(gb->gedp->ged_wdbp, argv[1], RT_BOT_SOLID, RT_BOT_CCW,
err, vc, fc, (fastf_t *)vert_array, faces, NULL, NULL);
+ struct bu_vls out_name = BU_VLS_INIT_ZERO;
+ if (argc > 1) {
+ bu_vls_sprintf(&out_name, "%s", argv[1]);
+ } else {
+ bu_vls_sprintf(&out_name, "%s.hull", gb->dp->d_namep);
+ }
+ if (db_lookup(gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&out_name),
LOOKUP_NOISY) != RT_DIR_NULL) {
+ bu_vls_printf(gb->gedp->ged_result_str, "Object %s already exists!\n",
bu_vls_cstr(&out_name));
+ bu_vls_free(&out_name);
+ return GED_ERROR;
+ }
+
+ retval = mk_bot(gb->gedp->ged_wdbp, bu_vls_cstr(&out_name), RT_BOT_SOLID,
RT_BOT_CCW, err, vc, fc, (fastf_t *)vert_array, faces, NULL, NULL);
+
+ bu_vls_free(&out_name);
bu_free(faces, "free faces");
bu_free(vert_array, "free verts");
@@ -161,7 +207,7 @@
extern "C" int
_bot_cmd_isect(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname> isect <objname2>";
+ const char *usage_string = "bot [options] isect <objname> <objname2>";
const char *purpose_string = "(TODO) Test if BoT <objname> intersects with
BoT <objname2>";
if (_bot_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -169,31 +215,27 @@
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
- return GED_ERROR;
- }
-
-
if (argc != 2) {
bu_vls_printf(gb->gedp->ged_result_str, "%s", usage_string);
return GED_ERROR;
}
- struct rt_bot_internal *bot = (struct rt_bot_internal *)gb->intern.idb_ptr;
+ if (_bot_obj_setup(gb, argv[0]) == GED_ERROR) {
+ return GED_ERROR;
+ }
+
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)gb->intern->idb_ptr;
+
struct directory *bot_dp_2;
struct rt_db_internal intern_2;
- struct rt_bot_internal *bot_2;
-
- GED_DB_LOOKUP(gb->gedp, bot_dp_2, argv[2], LOOKUP_NOISY, GED_ERROR &
GED_QUIET);
+ GED_DB_LOOKUP(gb->gedp, bot_dp_2, argv[1], LOOKUP_NOISY, GED_ERROR &
GED_QUIET);
GED_DB_GET_INTERNAL(gb->gedp, &intern_2, bot_dp_2, bn_mat_identity,
&rt_uniresource, GED_ERROR);
-
if (intern_2.idb_major_type != DB5_MAJORTYPE_BRLCAD ||
intern_2.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", argv[2]);
+ bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", argv[1]);
rt_db_free_internal(&intern_2);
return GED_ERROR;
}
- bot_2 = (struct rt_bot_internal *)intern_2.idb_ptr;
+ struct rt_bot_internal *bot_2 = (struct rt_bot_internal *)intern_2.idb_ptr;
int fc_1 = (int)bot->num_faces;
int fc_2 = (int)bot_2->num_faces;
@@ -357,94 +399,34 @@
argv[i - cmd_pos] = argv[i];
}
- // This will eventually need to change, as it makes it impossible to just
- // "plug in" new bot subcommands, but for now maintain compatibility with
- // prior bot command behavior by adjusting the positions of argv elements.
- //
- // We want to do the object lookup code once, up front, rather than having
- // to duplicate it in each subcommand.
- const char *primitive = NULL;
-
- const char *sub = argv[0];
- int len = strlen(sub);
- if (bu_strncmp(sub, "get", len) == 0) {
- primitive = argv[argc - 1];
- argc--;
- } else if (bu_strncmp(sub, "extrude", len) == 0) {
- primitive = argv[1];
- argv[1] = argv[2];
- argc--;
- } else if (bu_strncmp(sub, "chull", len) == 0) {
- primitive = argv[1];
- argv[1] = argv[2];
- argc--;
- } else if (bu_strncmp(sub, "isect", len) == 0) {
- primitive = argv[1];
- argv[1] = argv[2];
- argc--;
- } else if (bu_strncmp(sub, "check", len) == 0) {
- primitive = argv[argc - 1];
- argc--;
- } else if (bu_strncmp(sub, "remesh", len) == 0) {
- primitive = argv[1];
- argv[1] = argv[2];
- argc--;
- } else {
- bu_vls_printf(gedp->ged_result_str, "%s is not a known subcommand!",
sub);
- return GED_ERROR;
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ if (gb.visualize) {
+ GED_CHECK_DRAWABLE(gedp, GED_ERROR);
+ gb.vbp = rt_vlblock_init();
}
+ gb.color = color;
- if (!primitive) {
- bu_vls_printf(gedp->ged_result_str, "No primitive object specified");
- if (color) {
- BU_PUT(color, struct bu_color);
- }
- return GED_ERROR;
+ int ret = GED_ERROR;
+ if (bu_cmd(_bot_cmds, argc, argv, 0, (void *)&gb, &ret) == BRLCAD_OK) {
+ ret = GED_OK;
+ goto bot_cleanup;
}
+ bu_vls_printf(gedp->ged_result_str, "subcommand %s not defined", argv[0]);
- GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
- GED_CHECK_DRAWABLE(gedp, GED_ERROR);
- GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
-
- gb.solid_name = std::string(primitive);
- gb.dp = db_lookup(gedp->ged_wdbp->dbip, gb.solid_name.c_str(),
LOOKUP_NOISY);
- if (gb.dp == RT_DIR_NULL) {
- bu_vls_printf(gedp->ged_result_str, ": %s is not a solid or does not
exist in database", gb.solid_name.c_str());
- if (color) {
- BU_PUT(color, struct bu_color);
- }
- return GED_ERROR;
- } else {
- int real_flag = (gb.dp->d_addr == RT_DIR_PHONY_ADDR) ? 0 : 1;
- if (!real_flag) {
- /* solid doesn't exist */
- bu_vls_printf(gedp->ged_result_str, ": %s is not a real solid",
gb.solid_name.c_str());
- if (color) {
- BU_PUT(color, struct bu_color);
- }
- return GED_ERROR;
- }
+bot_cleanup:
+ if (gb.intern) {
+ rt_db_free_internal(gb.intern);
+ BU_PUT(gb.intern, struct rt_db_internal);
}
-
- GED_DB_GET_INTERNAL(gedp, &gb.intern, gb.dp, bn_mat_identity,
&rt_uniresource, GED_ERROR);
- RT_CK_DB_INTERNAL(&gb.intern);
-
- gb.vbp = rt_vlblock_init();
- gb.color = color;
-
- int ret;
- if (bu_cmd(_bot_cmds, argc, argv, 0, (void *)&gb, &ret) == BRLCAD_OK) {
- rt_db_free_internal(&gb.intern);
- return ret;
- } else {
- bu_vls_printf(gedp->ged_result_str, "subcommand %s not defined",
argv[0]);
+ if (gb.visualize) {
+ bn_vlblock_free(gb.vbp);
+ gb.vbp = (struct bn_vlblock *)NULL;
}
-
- bn_vlblock_free(gb.vbp);
- gb.vbp = (struct bn_vlblock *)NULL;
- rt_db_free_internal(&gb.intern);
- return GED_ERROR;
+ if (color) {
+ BU_PUT(color, struct bu_color);
+ }
+ return ret;
}
// Local Variables:
Modified: brlcad/trunk/src/libged/bot/check.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/check.cpp 2020-05-12 14:51:24 UTC (rev
75767)
+++ brlcad/trunk/src/libged/bot/check.cpp 2020-05-12 15:14:38 UTC (rev
75768)
@@ -265,7 +265,7 @@
extern "C" int
_bot_cmd_degen_faces(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname1> degen_faces";
+ const char *usage_string = "bot [options] degen_faces <objname>";
const char *purpose_string = "Check BoT for degenerate faces";
if (_bot_check_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -275,7 +275,7 @@
struct _ged_bot_icheck *gib = (struct _ged_bot_icheck *)bs;
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern->idb_ptr);
struct bu_color *color = gib->gb->color;
struct bn_vlblock *vbp = gib->gb->vbp;
@@ -335,7 +335,7 @@
extern "C" int
_bot_cmd_extra_edges(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname1> extra_edges";
+ const char *usage_string = "bot [options] extra_edges <objname>";
const char *purpose_string = "Check BoT for edges which are not part of
any triangle faces";
if (_bot_check_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -345,7 +345,7 @@
struct _ged_bot_icheck *gib = (struct _ged_bot_icheck *)bs;
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern->idb_ptr);
struct bu_color *color = gib->gb->color;
struct bn_vlblock *vbp = gib->gb->vbp;
@@ -415,7 +415,7 @@
extern "C" int
_bot_cmd_flipped_edges(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname1> flipped_edges";
+ const char *usage_string = "bot [options] flipped_edges <objname>";
const char *purpose_string = "Check BoT for edges which are incorrectly
oriented";
if (_bot_check_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -425,7 +425,7 @@
struct _ged_bot_icheck *gib = (struct _ged_bot_icheck *)bs;
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern->idb_ptr);
struct bu_color *color = gib->gb->color;
struct bn_vlblock *vbp = gib->gb->vbp;
@@ -495,7 +495,7 @@
extern "C" int
_bot_cmd_open_edges(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname1> open_edges";
+ const char *usage_string = "bot [options] open_edges <objname>";
const char *purpose_string = "Check BoT for edges which are not connected
to two triangle faces";
if (_bot_check_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -505,7 +505,7 @@
struct _ged_bot_icheck *gib = (struct _ged_bot_icheck *)bs;
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern->idb_ptr);
struct bu_color *color = gib->gb->color;
struct bn_vlblock *vbp = gib->gb->vbp;
@@ -576,17 +576,15 @@
extern "C" int
_bot_cmd_solid(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname1> solid";
+ const char *usage_string = "bot [options] check solid <objname>";
const char *purpose_string = "Check if BoT defines a topologically closed
solid";
if (_bot_check_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
}
- argc--;argv++;
-
struct _ged_bot_icheck *gib = (struct _ged_bot_icheck *)bs;
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gib->gb->intern->idb_ptr);
struct bn_vlblock *vbp = gib->gb->vbp;
struct bg_trimesh_solid_errors errors = BG_TRIMESH_SOLID_ERRORS_INIT_NULL;
int not_solid;
@@ -663,7 +661,7 @@
{
struct _ged_bot_icheck *gb = (struct _ged_bot_icheck *)bs;
if (!argc || !argv) {
- bu_vls_printf(gb->vls, "bot [options] <objname> check [subcommand]\n");
+ bu_vls_printf(gb->vls, "bot [options] check [subcommand] <objname>\n");
bu_vls_printf(gb->vls, "Available subcommands:\n");
const struct bu_cmdtab *ctp = NULL;
int ret;
@@ -723,14 +721,25 @@
return GED_OK;
}
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, "%s is not of type bot\n",
gb->solid_name.c_str());
- return GED_ERROR;
+ // Skip the "check" subcommand
+ argc--;argv++;
+
+ if (!argc) {
+ _bot_check_help(&gib, 0, NULL);
+ return GED_OK;
}
- argc--; argv++;
+ if (_bot_obj_setup(gb, argv[argc-1]) == GED_ERROR) {
+ return GED_ERROR;
+ }
+ argc--;
- // Must have valid subcommand to process
+ if (!argc) {
+ // No subcommand - do the solid check
+ return _bot_cmd_solid((void *)&gib, 0, NULL);
+ }
+
+ // Have subcommand - must have valid subcommand to process
if (bu_cmd_valid(_bot_check_cmds, argv[0]) != BRLCAD_OK) {
bu_vls_printf(gib.vls, "invalid subcommand \"%s\" specified\n",
argv[0]);
_bot_check_help(&gib, 0, NULL);
Modified: brlcad/trunk/src/libged/bot/extrude.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/extrude.cpp 2020-05-12 14:51:24 UTC (rev
75767)
+++ brlcad/trunk/src/libged/bot/extrude.cpp 2020-05-12 15:14:38 UTC (rev
75768)
@@ -82,7 +82,7 @@
extern "C" int
_bot_cmd_extrude(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname> extrude <output_obj>";
+ const char *usage_string = "bot [options] extrude <objname> [output_obj]";
const char *purpose_string = "generate an ARB6 representation of the
specified plate mode BoT object";
if (_bot_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -90,12 +90,11 @@
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
- return GED_ERROR;
+ if (_bot_obj_setup(gb, argv[0]) == GED_ERROR) {
+ return GED_ERROR;
}
- struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern.idb_ptr);
+ struct rt_bot_internal *bot = (struct rt_bot_internal
*)(gb->intern->idb_ptr);
if (bot->mode != RT_BOT_PLATE && bot->mode != RT_BOT_PLATE_NOCOS) {
bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not a plate
mode bot\n", gb->solid_name.c_str());
return GED_ERROR;
@@ -113,6 +112,23 @@
return GED_OK;
}
+ // Make a comb to hold the union of the new solid primitives
+ struct wmember wcomb;
+ struct bu_vls comb_name = BU_VLS_INIT_ZERO;
+ if (argc > 1) {
+ bu_vls_sprintf(&comb_name, "%s", argv[1]);
+ } else {
+ bu_vls_sprintf(&comb_name, "%s_extrusion.r", gb->dp->d_namep);
+ }
+
+ if (db_lookup(gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&comb_name),
LOOKUP_NOISY) != RT_DIR_NULL) {
+ bu_vls_printf(gb->gedp->ged_result_str, "Object %s already exists!\n",
bu_vls_cstr(&comb_name));
+ bu_vls_free(&comb_name);
+ return GED_ERROR;
+ }
+
+ BU_LIST_INIT(&wcomb.l);
+
// Average the face normals at each vertex to get an average direction in
// which to move each vertex for solid generation.
vect_t *f2n = (vect_t *)bu_calloc(bot->num_faces, sizeof(vect_t), "face
normals");
@@ -139,13 +155,6 @@
VUNITIZE(v2n[i]);
}
- // Make a comb to hold the union of the new solid primitives
- struct wmember wcomb;
- struct bu_vls comb_name = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&comb_name, "%s_solid.r", gb->dp->d_namep);
- // TODO - db_lookup to make sure it doesn't already exist
- BU_LIST_INIT(&wcomb.l);
-
// For each face, define an arb6 using shifted vertices. For each face
// vertex two new points will be constructed - an inner and outer - based
// on the original point, the local face thickness, and the avg face dir
@@ -165,6 +174,7 @@
VSCALE(fnorm, fnorm, -1);
}
VMOVE(pf[j], &bot->vertices[bot->faces[i*3+j]*3]);
+ // TODO - try trig values here for better scaling, up to some sane
max...
VSCALE(pv1[j], fnorm, bot->thickness[i] * ((bot->mode == RT_BOT_CW)
? -1 : 0));
VSCALE(pv2[j], fnorm, -1*bot->thickness[i] * ((bot->mode ==
RT_BOT_CW) ? -1 : 0));
}
Modified: brlcad/trunk/src/libged/bot/ged_bot.h
===================================================================
--- brlcad/trunk/src/libged/bot/ged_bot.h 2020-05-12 14:51:24 UTC (rev
75767)
+++ brlcad/trunk/src/libged/bot/ged_bot.h 2020-05-12 15:14:38 UTC (rev
75768)
@@ -47,7 +47,7 @@
struct _ged_bot_info {
struct ged *gedp = NULL;
- struct rt_db_internal intern;
+ struct rt_db_internal *intern = NULL;
struct directory *dp = NULL;
struct bn_vlblock *vbp = NULL;
struct bu_color *color = NULL;
@@ -64,6 +64,8 @@
const char *name,
int copy);
+int _bot_obj_setup(struct _ged_bot_info *gb, const char *name);
+
int _bot_cmd_msgs(void *bs, int argc, const char **argv, const char *us, const
char *ps);
int _bot_cmd_extrude(void *bs, int argc, const char **argv);
Modified: brlcad/trunk/src/libged/bot/remesh.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/remesh.cpp 2020-05-12 14:51:24 UTC (rev
75767)
+++ brlcad/trunk/src/libged/bot/remesh.cpp 2020-05-12 15:14:38 UTC (rev
75768)
@@ -169,7 +169,7 @@
extern "C" int
_bot_cmd_remesh(void *bs, int argc, const char **argv)
{
- const char *usage_string = "bot [options] <objname> remesh [output_bot]";
+ const char *usage_string = "bot [options] remesh <objname> [output_bot]";
const char *purpose_string = "Store a remeshed version of the BoT in
object <output_bot>";
if (_bot_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
return GED_OK;
@@ -177,13 +177,11 @@
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
- struct ged *gedp = gb->gedp;
-
- if (gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
- bu_vls_printf(gb->gedp->ged_result_str, ": object %s is not of type
bot\n", gb->solid_name.c_str());
+ if (_bot_obj_setup(gb, argv[0]) == GED_ERROR) {
return GED_ERROR;
}
+ struct ged *gedp = gb->gedp;
const char *input_bot_name = gb->dp->d_namep;
const char *output_bot_name;
struct directory *dp_input;
@@ -190,9 +188,7 @@
struct directory *dp_output;
struct rt_bot_internal *input_bot;
- GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
GED_CHECK_READ_ONLY(gedp, GED_ERROR);
- GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
dp_input = dp_output = RT_DIR_NULL;
@@ -228,12 +224,12 @@
GED_CHECK_EXISTS(gedp, output_bot_name, LOOKUP_QUIET, GED_ERROR);
}
- if (gb->intern.idb_major_type != DB5_MAJORTYPE_BRLCAD ||
gb->intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
+ if (gb->intern->idb_major_type != DB5_MAJORTYPE_BRLCAD ||
gb->intern->idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
bu_vls_printf(gedp->ged_result_str, "%s is not a BOT primitive\n",
input_bot_name);
return GED_ERROR;
}
- input_bot = (struct rt_bot_internal *)gb->intern.idb_ptr;
+ input_bot = (struct rt_bot_internal *)gb->intern->idb_ptr;
RT_BOT_CK_MAGIC(input_bot);
bu_log("INPUT BoT has %zu vertices and %zu faces\n",
input_bot->num_vertices, input_bot->num_faces);
@@ -250,10 +246,10 @@
if (BU_STR_EQUAL(input_bot_name, output_bot_name)) {
dp_output = dp_input;
} else {
- GED_DB_DIRADD(gedp, dp_output, output_bot_name, RT_DIR_PHONY_ADDR, 0,
RT_DIR_SOLID, (void *)&gb->intern.idb_type, GED_ERROR);
+ GED_DB_DIRADD(gedp, dp_output, output_bot_name, RT_DIR_PHONY_ADDR, 0,
RT_DIR_SOLID, (void *)&gb->intern->idb_type, GED_ERROR);
}
- GED_DB_PUT_INTERNAL(gedp, dp_output, &gb->intern,
gedp->ged_wdbp->wdb_resp, GED_ERROR);
+ GED_DB_PUT_INTERNAL(gedp, dp_output, gb->intern, gedp->ged_wdbp->wdb_resp,
GED_ERROR);
return GED_OK;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits