Revision: 65260
http://sourceforge.net/p/brlcad/code/65260
Author: starseeker
Date: 2015-06-11 13:01:57 +0000 (Thu, 11 Jun 2015)
Log Message:
-----------
Make the tolerance user settable with gdiff
Modified Paths:
--------------
brlcad/trunk/src/libanalyze/raydiff.c
brlcad/trunk/src/libged/gdiff.c
Modified: brlcad/trunk/src/libanalyze/raydiff.c
===================================================================
--- brlcad/trunk/src/libanalyze/raydiff.c 2015-06-11 13:01:31 UTC (rev
65259)
+++ brlcad/trunk/src/libanalyze/raydiff.c 2015-06-11 13:01:57 UTC (rev
65260)
@@ -246,8 +246,8 @@
xdata->pn = 2;
xdata->n_vec = (vect_t *)bu_calloc(xdata->vn + 1, sizeof(vect_t), "vects
array");
xdata->n_p = (fastf_t *)bu_calloc(xdata->pn + 1, sizeof(fastf_t), "params
array");
- xdata->n_p[0] = 50; /* TODO - get tolerances from caller */
- xdata->n_p[1] = 50;
+ xdata->n_p[0] = tol->dist;
+ xdata->n_p[1] = tol->dist;
VSET(xdata->n_vec[0], 0, max[1], 0);
VSET(xdata->n_vec[1], 0, 0, max[2]);
ret = rt_pattern(xdata, RT_PATTERN_RECT_ORTHOGRID);
@@ -263,8 +263,8 @@
ydata->pn = 2;
ydata->n_vec = (vect_t *)bu_calloc(ydata->vn + 1, sizeof(vect_t), "vects
array");
ydata->n_p = (fastf_t *)bu_calloc(ydata->pn + 1, sizeof(fastf_t), "params
array");
- ydata->n_p[0] = 50; /* TODO - get tolerances from caller */
- ydata->n_p[1] = 50;
+ ydata->n_p[0] = tol->dist;
+ ydata->n_p[1] = tol->dist;
VSET(ydata->n_vec[0], max[0], 0, 0);
VSET(ydata->n_vec[1], 0, 0, max[2]);
ret = rt_pattern(ydata, RT_PATTERN_RECT_ORTHOGRID);
@@ -279,8 +279,8 @@
zdata->pn = 2;
zdata->n_vec = (vect_t *)bu_calloc(zdata->vn + 1, sizeof(vect_t), "vects
array");
zdata->n_p = (fastf_t *)bu_calloc(zdata->pn + 1, sizeof(fastf_t), "params
array");
- zdata->n_p[0] = 50; /* TODO - get tolerances from caller */
- zdata->n_p[1] = 50;
+ zdata->n_p[0] = tol->dist;
+ zdata->n_p[1] = tol->dist;
VSET(zdata->n_vec[0], max[0], 0, 0);
VSET(zdata->n_vec[1], 0, max[1], 0);
ret = rt_pattern(zdata, RT_PATTERN_RECT_ORTHOGRID);
@@ -324,7 +324,7 @@
*/
{
int i, j;
- ncpus = 2;
+ /*ncpus = 2;*/
state = (struct raydiff_container *)bu_calloc(ncpus+1, sizeof(struct
raydiff_container), "resources");
for (i = 0; i < ncpus+1; i++) {
state[i].rtip = rtip;
Modified: brlcad/trunk/src/libged/gdiff.c
===================================================================
--- brlcad/trunk/src/libged/gdiff.c 2015-06-11 13:01:31 UTC (rev 65259)
+++ brlcad/trunk/src/libged/gdiff.c 2015-06-11 13:01:57 UTC (rev 65260)
@@ -28,7 +28,7 @@
#include <string.h>
#include "bu/cmd.h"
-#include "bu/getopt.h"
+#include "bu/opt.h"
#include "analyze.h"
#include "./ged_private.h"
@@ -49,68 +49,44 @@
int left_dbip_specified = 0;
int right_dbip_specified = 0;
*/
- int c = 0;
int do_diff_raytrace = 0;
int view_left = 0;
int view_right = 0;
int view_overlap = 0;
- struct bu_vls tmpstr = BU_VLS_INIT_ZERO;
+ const char *left_obj;
+ const char *right_obj;
+ fastf_t len_tol = BN_TOL_DIST;
+ int ret_ac = 0;
+ const char **unknown;
+
+ struct bu_opt_desc d[6];
+ BU_OPT(d[0], "t", "tol", 1, 1, &bu_opt_fastf_t, (void *)&len_tol, "#",
"Tolerance")
+ BU_OPT(d[1], "R", "ray-diff", 0, 0, NULL, (void *)&do_diff_raytrace, "",
"Test for differences with raytracing")
+ BU_OPT(d[2], "l", "view-left", 0, 0, NULL, (void *)&view_left, "",
"Visualize volumes added only by left object")
+ BU_OPT(d[3], "b", "view-both", 0, 0, NULL, (void *)&view_overlap, "",
"Visualize volumes common to both objects")
+ BU_OPT(d[4], "r", "view-right", 0, 0, NULL, (void *)&view_right, "",
"Visualize volumes added only by right object")
+ BU_OPT_NULL(d[5]);
+
GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+ unknown = (const char **)bu_calloc(argc, sizeof(char *), "non-option argv
array");
+ ret_ac = bu_opt_parse(&unknown, argc, NULL, argc-1, argv+1, d);
+
/* initialize result */
bu_vls_trunc(gedp->ged_result_str, 0);
- if (argc < 3) {
+ if (ret_ac != 2) {
bu_vls_printf(gedp->ged_result_str, "Usage: %s", gdiff_usage());
+ bu_free((char *)unknown, "free unknown args container");
return GED_ERROR;
+ } else {
+ left_obj = unknown[0];
+ right_obj = unknown[1];
}
- /* skip command name */
- bu_optind = 1;
- bu_opterr = 1;
+ tol.dist = len_tol;
- /* parse args */
- while ((c=bu_getopt(argc, (char * const *)argv, "O:N:vhRlrb?")) != -1) {
- if (bu_optopt == '?')
- c='h';
- switch (c) {
- case 'O' :
-/* use is commented out after this while
- left_dbip_specified = 1;
-*/
- bu_vls_sprintf(&tmpstr, "%s", bu_optarg);
- /*bu_log("Have origin database: %s", bu_vls_addr(&tmpstr));*/
- break;
- case 'N' :
-/* use is commented out after this while
- right_dbip_specified = 1;
-*/
- bu_vls_sprintf(&tmpstr, "%s", bu_optarg);
- /*bu_log("Have new database: %s", bu_vls_addr(&tmpstr));*/
- break;
- case 'v' :
- /*bu_log("Reporting mode is verbose");*/
- break;
- case 'R' :
- do_diff_raytrace = 1;
- /*bu_log("Raytrace based evaluation of differences between
objects.");*/
- break;
- case 'l' :
- view_left = 1;
- break;
- case 'b' :
- view_overlap = 1;
- break;
- case 'r' :
- view_right = 1;
- break;
- default:
- bu_vls_printf(gedp->ged_result_str, "Usage: %s", gdiff_usage());
- return GED_ERROR;
- }
- }
-
/* There are possible convention-based interpretations of 1, 2, 3, 4 and n
args
* beyond those used as options. For the shortest cases, the
interpretation depends
* on whether one or two .g files are known:
@@ -160,16 +136,12 @@
}
*/
-
- if ((argc - bu_optind) != 2) {
- return GED_ERROR;
- }
/*
bu_log("left: %s", argv[bu_optind]);
bu_log("right: %s", argv[bu_optind+1]);
*/
if (do_diff_raytrace) {
- analyze_raydiff(&results, gedp->ged_wdbp->dbip, argv[bu_optind],
argv[bu_optind+1], &tol);
+ analyze_raydiff(&results, gedp->ged_wdbp->dbip, left_obj, right_obj,
&tol);
/* TODO - may want to integrate with a "regular" diff and report
intelligently. Needs
* some thought. */
@@ -247,6 +219,7 @@
analyze_raydiff_results_free(results);
}
+ bu_free((char *)unknown, "free unknown args container");
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