Revision: 75773
http://sourceforge.net/p/brlcad/code/75773
Author: starseeker
Date: 2020-05-12 17:59:28 +0000 (Tue, 12 May 2020)
Log Message:
-----------
Leave the bot check drawing code closer to the form of the original, rather
than attempting to accumulate vlists and draw at the end, so we get similar
results. Either using bn_vlblock containers incorrectly or they're not the
right container for the original approach...
Modified Paths:
--------------
brlcad/trunk/src/libged/bot/bot.cpp
brlcad/trunk/src/libged/bot/check.cpp
Modified: brlcad/trunk/src/libged/bot/bot.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/bot.cpp 2020-05-12 17:26:19 UTC (rev 75772)
+++ brlcad/trunk/src/libged/bot/bot.cpp 2020-05-12 17:59:28 UTC (rev 75773)
@@ -155,7 +155,7 @@
argc--; argv++;
struct _ged_bot_info *gb = (struct _ged_bot_info *)bs;
-
+
if (!argc) {
bu_vls_printf(gb->gedp->ged_result_str, "%s\n%s\n", usage_string,
purpose_string);
return GED_ERROR;
Modified: brlcad/trunk/src/libged/bot/check.cpp
===================================================================
--- brlcad/trunk/src/libged/bot/check.cpp 2020-05-12 17:26:19 UTC (rev
75772)
+++ brlcad/trunk/src/libged/bot/check.cpp 2020-05-12 17:59:28 UTC (rev
75773)
@@ -227,13 +227,18 @@
}
static void
-draw_edges(struct bn_vlblock *vbp, struct rt_bot_internal *bot, int num_edges,
int edges[], struct bu_color *color)
+draw_edges(struct ged *gedp, struct rt_bot_internal *bot, int num_edges, int
edges[], struct bu_color *color, const char *draw_name)
{
struct bu_list *vhead;
point_t a,b;
unsigned char draw_color[3];
bu_color_to_rgb_chars(color, draw_color);
+ struct bn_vlblock *vbp;
+ struct bu_list local_vlist;
+ BU_LIST_INIT(&local_vlist);
+ vbp = bn_vlblock_init(&local_vlist, 32);
+
for (int curr_edge = 0; curr_edge < num_edges; curr_edge++) {
int p1 = edges[curr_edge*2];
int p2 = edges[curr_edge*2+1];
@@ -243,9 +248,12 @@
BN_ADD_VLIST(vbp->free_vlist_hd, vhead, a, BN_VLIST_LINE_MOVE);
BN_ADD_VLIST(vbp->free_vlist_hd, vhead, b, BN_VLIST_LINE_DRAW);
}
+
+ _ged_cvt_vlblock_to_solids(gedp, vbp, draw_name, 0);
+ bn_vlist_cleanup(&local_vlist);
+ bn_vlblock_free(vbp);
}
-
static int
_bot_check_msgs(void *bs, int argc, const char **argv, const char *us, const
char *ps)
{
@@ -277,7 +285,6 @@
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;
struct bg_trimesh_faces degenerate = BG_TRIMESH_FACES_INIT_NULL;
struct bg_trimesh_edges *degen_edges, *all_edges, *other_edges;
@@ -302,11 +309,16 @@
bg_free_trimesh_edges(all_edges);
BU_FREE(all_edges, struct bg_trimesh_edges);
- draw_edges(vbp, bot, degen_edges->count, degen_edges->edges, color);
+ struct bu_vls dg_name = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&dg_name, "%s_degen_faces", gib->gb->dp->d_namep);
+
+ draw_edges(gib->gb->gedp, bot, degen_edges->count,
degen_edges->edges, color, bu_vls_cstr(&dg_name));
struct bu_color red = BU_COLOR_INIT_ZERO;
bu_color_from_str(&red, "255/0/0");
- draw_edges(vbp, bot, other_edges->count, other_edges->edges, &red);
+ draw_edges(gib->gb->gedp, bot, other_edges->count,
other_edges->edges, &red, bu_vls_cstr(&dg_name));
+ bu_vls_free(&dg_name);
+
bg_free_trimesh_edges(degen_edges);
BU_FREE(degen_edges, struct bg_trimesh_edges);
bg_free_trimesh_edges(other_edges);
@@ -319,16 +331,6 @@
bu_vls_printf(gib->vls, degenerate_faces ? "1" : "0");
- if (gib->gb->visualize) {
- struct bu_vls sname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&sname, "_%s_degen_faces", gib->gb->solid_name.c_str());
- if (db_lookup(gib->gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&sname),
LOOKUP_QUIET) != RT_DIR_NULL) {
- dl_erasePathFromDisplay(gib->gb->gedp->ged_gdp->gd_headDisplay,
gib->gb->gedp->ged_wdbp->dbip, gib->gb->gedp->ged_free_vlist_callback,
bu_vls_cstr(&sname), 1, gib->gb->gedp->freesolid);
- }
- _ged_cvt_vlblock_to_solids(gib->gb->gedp, vbp, bu_vls_cstr(&sname), 0);
- bu_vls_free(&sname);
- }
-
return GED_OK;
}
@@ -347,9 +349,7 @@
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;
-
int num_faces, num_edges;
num_faces = (int)bot->num_faces;
num_edges = num_faces * 3;
@@ -381,11 +381,16 @@
bg_free_trimesh_edges(all_edges);
BU_FREE(all_edges, struct bg_trimesh_edges);
- draw_edges(vbp, bot, error_edges.count, error_edges.edges, color);
+ struct bu_vls ee_name = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&ee_name, "%s_extra_edges", gib->gb->dp->d_namep);
+
+ draw_edges(gib->gb->gedp, bot, error_edges.count,
error_edges.edges, color, bu_vls_cstr(&ee_name));
struct bu_color red = BU_COLOR_INIT_ZERO;
bu_color_from_str(&red, "255/0/0");
- draw_edges(vbp, bot, other_edges->count, other_edges->edges, &red);
+ draw_edges(gib->gb->gedp, bot, other_edges->count,
other_edges->edges, &red, bu_vls_cstr(&ee_name));
+ bu_vls_free(&ee_name);
+
bg_free_trimesh_edges(&error_edges);
bg_free_trimesh_edges(other_edges);
BU_FREE(other_edges, struct bg_trimesh_edges);
@@ -399,16 +404,6 @@
bu_vls_printf(gib->vls, extra_edges ? "1" : "0");
- if (gib->gb->visualize) {
- struct bu_vls sname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&sname, "_%s_extra_edges", gib->gb->solid_name.c_str());
- if (db_lookup(gib->gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&sname),
LOOKUP_QUIET) != RT_DIR_NULL) {
- dl_erasePathFromDisplay(gib->gb->gedp->ged_gdp->gd_headDisplay,
gib->gb->gedp->ged_wdbp->dbip, gib->gb->gedp->ged_free_vlist_callback,
bu_vls_cstr(&sname), 1, gib->gb->gedp->freesolid);
- }
- _ged_cvt_vlblock_to_solids(gib->gb->gedp, vbp, bu_vls_cstr(&sname), 0);
- bu_vls_free(&sname);
- }
-
return GED_OK;
}
@@ -427,9 +422,7 @@
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;
-
int num_faces, num_edges;
num_faces = (int)bot->num_faces;
num_edges = num_faces * 3;
@@ -453,7 +446,7 @@
if (flipped_edges) {
/* second pass - generate error edge array and draw it */
error_edges.count = 0;
- error_edges.edges = (int *)bu_calloc(flipped_edges * 2,
sizeof(int), "error edges");
+ error_edges.edges = (int *)bu_calloc(flipped_edges * 2,
sizeof(int), "flipped edges");
flipped_edges = bg_trimesh_misoriented_edges(num_edges, edge_list,
bg_trimesh_edge_gather, &error_edges);
all_edges = edges_from_half_edges(edge_list, num_edges);
@@ -461,11 +454,16 @@
bg_free_trimesh_edges(all_edges);
BU_FREE(all_edges, struct bg_trimesh_edges);
- draw_edges(vbp, bot, error_edges.count, error_edges.edges, color);
+ struct bu_vls ee_name = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&ee_name, "%s_flipped_edges", gib->gb->dp->d_namep);
+
+ draw_edges(gib->gb->gedp, bot, error_edges.count,
error_edges.edges, color, bu_vls_cstr(&ee_name));
struct bu_color red = BU_COLOR_INIT_ZERO;
bu_color_from_str(&red, "255/0/0");
- draw_edges(vbp, bot, other_edges->count, other_edges->edges, &red);
+ draw_edges(gib->gb->gedp, bot, other_edges->count,
other_edges->edges, &red, bu_vls_cstr(&ee_name));
+ bu_vls_free(&ee_name);
+
bg_free_trimesh_edges(&error_edges);
bg_free_trimesh_edges(other_edges);
BU_FREE(other_edges, struct bg_trimesh_edges);
@@ -479,16 +477,6 @@
bu_vls_printf(gib->vls, flipped_edges ? "1" : "0");
- if (gib->gb->visualize) {
- struct bu_vls sname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&sname, "_%s_flipped_edges",
gib->gb->solid_name.c_str());
- if (db_lookup(gib->gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&sname),
LOOKUP_QUIET) != RT_DIR_NULL) {
- dl_erasePathFromDisplay(gib->gb->gedp->ged_gdp->gd_headDisplay,
gib->gb->gedp->ged_wdbp->dbip, gib->gb->gedp->ged_free_vlist_callback,
bu_vls_cstr(&sname), 1, gib->gb->gedp->freesolid);
- }
- _ged_cvt_vlblock_to_solids(gib->gb->gedp, vbp, bu_vls_cstr(&sname), 0);
- bu_vls_free(&sname);
- }
-
return GED_OK;
}
@@ -507,9 +495,7 @@
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;
-
int num_faces, num_edges;
num_faces = (int)bot->num_faces;
num_edges = num_faces * 3;
@@ -541,11 +527,16 @@
bg_free_trimesh_edges(all_edges);
BU_FREE(all_edges, struct bg_trimesh_edges);
- draw_edges(vbp, bot, error_edges.count, error_edges.edges, color);
+ struct bu_vls ee_name = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&ee_name, "%s_open_edges", gib->gb->dp->d_namep);
+
+ draw_edges(gib->gb->gedp, bot, error_edges.count,
error_edges.edges, color, bu_vls_cstr(&ee_name));
struct bu_color red = BU_COLOR_INIT_ZERO;
bu_color_from_str(&red, "255/0/0");
- draw_edges(vbp, bot, other_edges->count, other_edges->edges, &red);
+ draw_edges(gib->gb->gedp, bot, other_edges->count,
other_edges->edges, &red, bu_vls_cstr(&ee_name));
+ bu_vls_free(&ee_name);
+
bg_free_trimesh_edges(&error_edges);
bg_free_trimesh_edges(other_edges);
BU_FREE(other_edges, struct bg_trimesh_edges);
@@ -559,16 +550,6 @@
bu_vls_printf(gib->vls, open_edges ? "1" : "0");
- if (gib->gb->visualize) {
- struct bu_vls sname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&sname, "_%s_open_edges", gib->gb->solid_name.c_str());
- if (db_lookup(gib->gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&sname),
LOOKUP_QUIET) != RT_DIR_NULL) {
- dl_erasePathFromDisplay(gib->gb->gedp->ged_gdp->gd_headDisplay,
gib->gb->gedp->ged_wdbp->dbip, gib->gb->gedp->ged_free_vlist_callback,
bu_vls_cstr(&sname), 1, gib->gb->gedp->freesolid);
- }
- _ged_cvt_vlblock_to_solids(gib->gb->gedp, vbp, bu_vls_cstr(&sname), 0);
- bu_vls_free(&sname);
- }
-
return GED_OK;
}
@@ -585,7 +566,6 @@
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 bn_vlblock *vbp = gib->gb->vbp;
struct bg_trimesh_solid_errors errors = BG_TRIMESH_SOLID_ERRORS_INIT_NULL;
int not_solid;
@@ -627,30 +607,31 @@
struct bu_color purple = BU_COLOR_INIT_ZERO;
bu_color_from_str(&purple, "255/0/255");
- draw_edges(vbp, bot, other_edges->count, other_edges->edges, &red);
- draw_edges(vbp, bot, errors.unmatched.count, errors.unmatched.edges,
&yellow);
- draw_edges(vbp, bot, errors.misoriented.count,
errors.misoriented.edges, &orange);
- draw_edges(vbp, bot, errors.excess.count, errors.excess.edges, &purple);
+ struct bu_vls ns_name = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&ns_name, "%s_non_solid_ne", gib->gb->dp->d_namep);
+ draw_edges(gib->gb->gedp, bot, other_edges->count, other_edges->edges,
&red, bu_vls_cstr(&ns_name));
+ bu_vls_sprintf(&ns_name, "%s_non_solid_ue", gib->gb->dp->d_namep);
+ draw_edges(gib->gb->gedp, bot, errors.unmatched.count,
errors.unmatched.edges, &yellow, bu_vls_cstr(&ns_name));
+ bu_vls_sprintf(&ns_name, "%s_non_solid_me", gib->gb->dp->d_namep);
+ draw_edges(gib->gb->gedp, bot, errors.misoriented.count,
errors.misoriented.edges, &orange, bu_vls_cstr(&ns_name));
+ bu_vls_sprintf(&ns_name, "%s_non_solid_ee", gib->gb->dp->d_namep);
+ draw_edges(gib->gb->gedp, bot, errors.excess.count,
errors.excess.edges, &purple, bu_vls_cstr(&ns_name));
+
if (errors.degenerate.count > 0) {
struct bu_color blue = BU_COLOR_INIT_ZERO;
bu_color_from_str(&blue, "0/0/255");
- draw_edges(vbp, bot, degen_edges->count, degen_edges->edges, &blue);
+ bu_vls_sprintf(&ns_name, "%s_non_solid_de", gib->gb->dp->d_namep);
+ draw_edges(gib->gb->gedp, bot, degen_edges->count,
degen_edges->edges, &blue, bu_vls_cstr(&ns_name));
bg_free_trimesh_edges(degen_edges);
BU_FREE(degen_edges, struct bg_trimesh_edges);
}
+ bu_vls_free(&ns_name);
bg_free_trimesh_edges(other_edges);
BU_FREE(other_edges, struct bg_trimesh_edges);
bg_free_trimesh_solid_errors(&errors);
- struct bu_vls sname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&sname, "_%s_not_solid", gib->gb->solid_name.c_str());
- if (db_lookup(gib->gb->gedp->ged_wdbp->dbip, bu_vls_cstr(&sname),
LOOKUP_QUIET) != RT_DIR_NULL) {
- dl_erasePathFromDisplay(gib->gb->gedp->ged_gdp->gd_headDisplay,
gib->gb->gedp->ged_wdbp->dbip, gib->gb->gedp->ged_free_vlist_callback,
bu_vls_cstr(&sname), 1, gib->gb->gedp->freesolid);
- }
- _ged_cvt_vlblock_to_solids(gib->gb->gedp, vbp, bu_vls_cstr(&sname), 0);
- bu_vls_free(&sname);
}
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