Revision: 77700
http://sourceforge.net/p/brlcad/code/77700
Author: starseeker
Date: 2020-11-06 20:56:36 +0000 (Fri, 06 Nov 2020)
Log Message:
-----------
Merge from trunk - r77690 through r77699
Modified Paths:
--------------
brlcad/branches/extbuild/include/rt/geom.h
brlcad/branches/extbuild/include/wdb.h
brlcad/branches/extbuild/src/libbu/mappedfile.c
brlcad/branches/extbuild/src/libged/search/search.c
brlcad/branches/extbuild/src/libged/typein/typein.c
brlcad/branches/extbuild/src/librt/db_fullpath.c
brlcad/branches/extbuild/src/librt/primitives/vol/vol.c
brlcad/branches/extbuild/src/librt/search.c
brlcad/branches/extbuild/src/libwdb/vol.c
brlcad/branches/extbuild/src/mged/edsol.c
brlcad/branches/extbuild/src/tclscripts/checker/OverlapFileTool.tcl
Property Changed:
----------------
brlcad/branches/extbuild/
brlcad/branches/extbuild/include/
brlcad/branches/extbuild/src/libbu/
Index: brlcad/branches/extbuild
===================================================================
--- brlcad/branches/extbuild 2020-11-06 17:40:36 UTC (rev 77699)
+++ brlcad/branches/extbuild 2020-11-06 20:56:36 UTC (rev 77700)
Property changes on: brlcad/branches/extbuild
___________________________________________________________________
Modified: svn:mergeinfo
## -11,4 +11,4 ##
/brlcad/branches/osg:62110-62113
/brlcad/branches/prep-cache:68236-68933
/brlcad/branches/tcltk86:68300-75257
-/brlcad/trunk:77547-77689
\ No newline at end of property
+/brlcad/trunk:77547-77699
\ No newline at end of property
Index: brlcad/branches/extbuild/include
===================================================================
--- brlcad/branches/extbuild/include 2020-11-06 17:40:36 UTC (rev 77699)
+++ brlcad/branches/extbuild/include 2020-11-06 20:56:36 UTC (rev 77700)
Property changes on: brlcad/branches/extbuild/include
___________________________________________________________________
Modified: svn:mergeinfo
## -10,4 +10,4 ##
/brlcad/branches/osg/include:62110-62113
/brlcad/branches/prep-cache/include:68236-68933
/brlcad/branches/tcltk86/include:68300-75257
-/brlcad/trunk/include:77660-77689
\ No newline at end of property
+/brlcad/trunk/include:77660-77699
\ No newline at end of property
Modified: brlcad/branches/extbuild/include/rt/geom.h
===================================================================
--- brlcad/branches/extbuild/include/rt/geom.h 2020-11-06 17:40:36 UTC (rev
77699)
+++ brlcad/branches/extbuild/include/rt/geom.h 2020-11-06 20:56:36 UTC (rev
77700)
@@ -348,7 +348,7 @@
#define RT_VOL_NAME_LEN 128
struct rt_vol_internal {
uint32_t magic;
- char file[RT_VOL_NAME_LEN];
+ char name[RT_VOL_NAME_LEN];
/* NOTE: [xyz]dim/lo/hi cannot be size_t until rel8 as they are
* written out to disk via bu_vls_struct_print() as 32-bit ints.
*/
@@ -359,6 +359,10 @@
uint32_t hi; /**< @brief High threshold */
vect_t cellsize; /**< @brief ideal coords: size of each cell */
mat_t mat; /**< @brief convert local coords to model space */
+ struct rt_db_internal *bip; /* @brief db object for data*/
+#define RT_VOL_SRC_FILE 'f'
+#define RT_VOL_SRC_OBJ 'o'
+ char datasrc;/**< @brief which type of data source */
/* REMAINING ELEMENTS PROVIDED BY IMPORT, UNUSED BY EXPORT */
unsigned char *map;
};
Modified: brlcad/branches/extbuild/include/wdb.h
===================================================================
--- brlcad/branches/extbuild/include/wdb.h 2020-11-06 17:40:36 UTC (rev
77699)
+++ brlcad/branches/extbuild/include/wdb.h 2020-11-06 20:56:36 UTC (rev
77700)
@@ -648,7 +648,7 @@
/**
* 3-D Volume primitive.
*/
-WDB_EXPORT extern int mk_vol(struct rt_wdb *fp, const char *name, const char
*file,
+WDB_EXPORT extern int mk_vol(struct rt_wdb *fp, const char *name, char
datasrc, const char *file,
size_t xdim, size_t ydim, size_t zdim, size_t lo,
size_t hi,
const vect_t cellsize, const matp_t mat);
Index: brlcad/branches/extbuild/src/libbu
===================================================================
--- brlcad/branches/extbuild/src/libbu 2020-11-06 17:40:36 UTC (rev 77699)
+++ brlcad/branches/extbuild/src/libbu 2020-11-06 20:56:36 UTC (rev 77700)
Property changes on: brlcad/branches/extbuild/src/libbu
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,4 ##
/brlcad/branches/brep-debug/src/libbu:69168,69927,69995-69996,70148-70149,70347-70349,70377,70526-70527,71006-71007,71009-71022,71046-71047,71049,71096-71100
/brlcad/branches/dm-fb-merge/src/libbu:75426-76198
/brlcad/branches/tcltk86/src/libbu:68300-75257
-/brlcad/trunk/src/libbu:77547-77657
\ No newline at end of property
+/brlcad/trunk/src/libbu:77547-77657,77690-77699
\ No newline at end of property
Modified: brlcad/branches/extbuild/src/libbu/mappedfile.c
===================================================================
--- brlcad/branches/extbuild/src/libbu/mappedfile.c 2020-11-06 17:40:36 UTC
(rev 77699)
+++ brlcad/branches/extbuild/src/libbu/mappedfile.c 2020-11-06 20:56:36 UTC
(rev 77700)
@@ -203,7 +203,7 @@
bu_semaphore_acquire(BU_SEM_MAPPEDFILE);
if (mp->appl)
bu_free(mp->appl, "appl");
- mp->appl = bu_strdup("_INVALID_");
+ mp->appl = NULL;
bu_semaphore_release(BU_SEM_MAPPEDFILE);
return;
@@ -365,22 +365,20 @@
mp->uses = 1;
mp->buflen = sb.st_size;
mp->modtime = sb.st_mtime;
- mp->buf = MAP_FAILED;
+ mp->buf = NULL;
/* Attempt to memory-map the file */
bu_semaphore_acquire(BU_SEM_SYSCALL);
-#ifdef HAVE_SYS_MMAN_H
+#if defined(HAVE_SYS_MMAN_H)
mp->buf = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
-#else
-# ifdef HAVE_WINDOWS_H
+#elif defined(HAVE_WINDOWS_H)
/* FIXME: shouldn't need to preserve handle */
mp->buf = win_mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0,
&(mp->handle));
-# endif
#endif /* HAVE_SYS_MMAN_H */
bu_semaphore_release(BU_SEM_SYSCALL);
/* If cannot memory-map, read it in manually */
- if (mp->buf != MAP_FAILED) {
+ if (mp->buf && mp->buf != MAP_FAILED) {
mp->is_mapped = 1;
} else {
ssize_t bytes_to_go = sb.st_size;
@@ -401,7 +399,6 @@
if (UNLIKELY(readval < 0)) {
bu_semaphore_release(BU_SEM_SYSCALL);
perror("read");
- bu_free(mp->buf, name);
goto fail;
} else {
nbytes += readval;
@@ -412,7 +409,6 @@
if (UNLIKELY(nbytes != sb.st_size)) {
perror(name);
- bu_free(mp->buf, name);
goto fail;
}
}
@@ -436,27 +432,29 @@
bu_semaphore_release(BU_SEM_SYSCALL);
}
- if (mp->name)
+ if (mp->name) {
bu_free(mp->name, "mp->name");
- if (mp->appl)
+ mp->name = NULL;
+ }
+ if (mp->appl) {
bu_free(mp->appl, "mp->appl");
+ mp->appl = NULL;
+ }
if (mp->buf) {
- if (mp->is_mapped)
-#ifdef HAVE_SYS_MMAN_H
+ if (mp->is_mapped) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
+#if defined(HAVE_SYS_MMAN_H)
munmap(mp->buf, (size_t)mp->buflen);
-#else
-# ifdef HAVE_WINDOWS_H
- win_munmap(mp->buf, (size_t)mp->buflen, mp->handle);
-# endif
+#elif defined(HAVE_WINDOWS_H)
+ win_munmap(mp->buf, (size_t)mp->buflen, mp->handle);
#endif
- else
+ bu_semaphore_release(BU_SEM_SYSCALL);
+ } else if (mp->buf != MAP_FAILED) {
bu_free(mp->buf, name);
+ }
+ mp->buf = NULL;
}
- mp->name = NULL;
- mp->appl = NULL;
- mp->buf = MAP_FAILED;
-
if (UNLIKELY(bu_debug&BU_DEBUG_MAPPED_FILE))
bu_log("bu_open_mapped_file(%s, %s) can't open file\n", name, appl ?
appl: "(NULL)");
Modified: brlcad/branches/extbuild/src/libged/search/search.c
===================================================================
--- brlcad/branches/extbuild/src/libged/search/search.c 2020-11-06 17:40:36 UTC
(rev 77699)
+++ brlcad/branches/extbuild/src/libged/search/search.c 2020-11-06 20:56:36 UTC
(rev 77700)
@@ -38,6 +38,7 @@
#include "bu/getopt.h"
#include "bu/path.h"
#include "bu/sort.h"
+#include "bu/defines.h"
#include "../alphanum.h"
#include "../ged_private.h"
@@ -47,8 +48,13 @@
{
struct directory *dp1 = *(struct directory **)d1;
struct directory *dp2 = *(struct directory **)d2;
- int ret = alphanum_impl((const char *)dp2->d_namep, (const char
*)dp1->d_namep, arg);
- return ret;
+ if (dp1 == dp2)
+ return 0;
+ else if (!dp1)
+ return 1;
+ else if (!dp2)
+ return -1;
+ return alphanum_impl((const char *)dp2->d_namep, (const char
*)dp1->d_namep, arg);
}
struct fp_cmp_vls {
@@ -63,12 +69,23 @@
struct db_full_path *fp1 = *(struct db_full_path **)d1;
struct db_full_path *fp2 = *(struct db_full_path **)d2;
struct fp_cmp_vls *data = (struct fp_cmp_vls *)arg;
+
+ BU_ASSERT(data != NULL);
+
+ if (fp1 == fp2)
+ return 0;
+ else if (!fp1)
+ return 1;
+ else if (!fp2)
+ return -1;
+
bu_vls_trunc(data->left, 0);
bu_vls_trunc(data->right, 0);
+
db_fullpath_to_vls(data->left, fp1, data->dbip, data->print_verbose_info);
db_fullpath_to_vls(data->right, fp2, data->dbip, data->print_verbose_info);
- int ret = alphanum_impl(bu_vls_cstr(data->right), bu_vls_cstr(data->left),
arg);
- return ret;
+
+ return alphanum_impl(bu_vls_cstr(data->right), bu_vls_cstr(data->left),
arg);
}
@@ -244,6 +261,26 @@
}
+HIDDEN void
+search_print_objs_to_vls(const struct bu_ptbl *objs, struct bu_vls *out)
+{
+ size_t len;
+
+ if (!objs || !out)
+ return;
+
+ len = BU_PTBL_LEN(objs);
+ if (len > 0) {
+ bu_sort((void *)BU_PTBL_BASEADDR(objs), len, sizeof(struct directory
*), dp_name_compare, NULL);
+
+ while (len-- > 0) {
+ struct directory *uniq_dp = (struct directory *)BU_PTBL_GET(objs,
len);
+ bu_vls_printf(out, "%s\n", uniq_dp->d_namep);
+ }
+ }
+}
+
+
int
ged_search_core(struct ged *gedp, int argc, const char *argv_orig[])
{
@@ -455,7 +492,6 @@
* return one unique list of objects. If one or more paths are non-local,
* each path is treated as its own search */
if (all_local) {
- size_t len;
struct bu_ptbl *uniq_db_objs;
BU_ALLOC(uniq_db_objs, struct bu_ptbl);
@@ -479,16 +515,8 @@
}
}
- /* For this return, we want a list of all unique leaf objects */
- bu_sort((void *)BU_PTBL_BASEADDR(uniq_db_objs),
BU_PTBL_LEN(uniq_db_objs), sizeof(struct directory *), dp_name_compare, NULL);
+ search_print_objs_to_vls(uniq_db_objs, gedp->ged_result_str);
- len = BU_PTBL_LEN(uniq_db_objs);
- while (len > 0) {
- struct directory *uniq_dp = (struct directory
*)BU_PTBL_GET(uniq_db_objs, len-1);
- bu_vls_printf(gedp->ged_result_str, "%s\n", uniq_dp->d_namep);
- len--;
- }
-
bu_ptbl_free(uniq_db_objs);
bu_free(uniq_db_objs, "free unique object container");
@@ -531,22 +559,14 @@
}
}
- sr_len = j = BU_PTBL_LEN(search_results);
- if (sr_len > 0) {
- bu_sort((void *)BU_PTBL_BASEADDR(search_results),
sr_len, sizeof(struct directory *), dp_name_compare, NULL);
+ search_print_objs_to_vls(search_results,
gedp->ged_result_str);
- while (j > 0) {
- struct directory *uniq_dp = (struct directory
*)BU_PTBL_GET(search_results, j-1);
- bu_vls_printf(gedp->ged_result_str, "%s\n",
uniq_dp->d_namep);
- j--;
- }
- }
+ db_search_free(search_results);
+ bu_free(search_results, "free search container");
/* Make sure to clear the flag in case of subsequent
searches of different types */
+ flags = flags & ~(DB_SEARCH_FLAT);
- flags = flags & ~(DB_SEARCH_FLAT);
- db_search_free(search_results);
- bu_free(search_results, "free search container");
} else {
struct directory *curr_path = search->paths[path_cnt];
@@ -565,12 +585,11 @@
if (sr_len > 0) {
bu_sort((void
*)BU_PTBL_BASEADDR(search_results), sr_len, sizeof(struct directory *),
fp_name_compare, (void *)sdata);
- while (j > 0) {
- struct db_full_path *dfptr = (struct
db_full_path *)BU_PTBL_GET(search_results, j-1);
+ while (j-- > 0) {
+ struct db_full_path *dfptr = (struct
db_full_path *)BU_PTBL_GET(search_results, j);
bu_vls_trunc(&fullpath_string, 0);
db_fullpath_to_vls(&fullpath_string,
dfptr, gedp->ged_wdbp->dbip, print_verbose_info);
bu_vls_printf(gedp->ged_result_str,
"%s\n", bu_vls_addr(&fullpath_string));
- j--;
}
}
break;
@@ -577,22 +596,15 @@
case 1:
flags |= DB_SEARCH_RETURN_UNIQ_DP;
(void)db_search(search_results, flags,
bu_vls_addr(&search_string), 1, &curr_path, gedp->ged_wdbp->dbip, ctx);
- sr_len = j = BU_PTBL_LEN(search_results);
- if (sr_len > 0) {
- bu_sort((void
*)BU_PTBL_BASEADDR(search_results), sr_len, sizeof(struct directory *),
dp_name_compare, NULL);
+ search_print_objs_to_vls(search_results,
gedp->ged_result_str);
- while (j > 0) {
- struct directory *uniq_dp = (struct
directory *)BU_PTBL_GET(search_results, j-1);
- bu_vls_printf(gedp->ged_result_str,
"%s\n", uniq_dp->d_namep);
- j--;
- }
- }
break;
default:
bu_log("Warning - ignoring unknown search type
%d\n", search->search_type);
break;
}
+
db_search_free(search_results);
bu_free(search_results, "free search container");
bu_vls_free(&fullpath_string);
Modified: brlcad/branches/extbuild/src/libged/typein/typein.c
===================================================================
--- brlcad/branches/extbuild/src/libged/typein/typein.c 2020-11-06 17:40:36 UTC
(rev 77699)
+++ brlcad/branches/extbuild/src/libged/typein/typein.c 2020-11-06 20:56:36 UTC
(rev 77700)
@@ -107,7 +107,8 @@
static const char *p_vol[] = {
- "Enter name of file containing voxel data: ",
+ "Take data from file or database binary object [f|o]: ",
+ "Enter name of file/object: ",
"Enter X, Y, Z dimensions of file (number of cells): ",
"Enter Y dimension of file (number of cells): ",
"Enter Z dimension of file (number of cells): ",
@@ -998,15 +999,23 @@
intern->idb_ptr = (void *)vol;
vol->magic = RT_VOL_INTERNAL_MAGIC;
- bu_strlcpy(vol->file, cmd_argvs[3], sizeof(vol->file));
- vol->xdim = atoi(cmd_argvs[4]);
- vol->ydim = atoi(cmd_argvs[5]);
- vol->zdim = atoi(cmd_argvs[6]);
- vol->lo = atoi(cmd_argvs[7]);
- vol->hi = atoi(cmd_argvs[8]);
- vol->cellsize[0] = atof(cmd_argvs[9]) *
gedp->ged_wdbp->dbip->dbi_local2base;
- vol->cellsize[1] = atof(cmd_argvs[10]) *
gedp->ged_wdbp->dbip->dbi_local2base;
- vol->cellsize[2] = atof(cmd_argvs[11]) *
gedp->ged_wdbp->dbip->dbi_local2base;
+ bu_strlcpy(vol->name, cmd_argvs[4], sizeof(vol->name));
+ vol->xdim = atoi(cmd_argvs[5]);
+ vol->ydim = atoi(cmd_argvs[6]);
+ vol->zdim = atoi(cmd_argvs[7]);
+ vol->lo = atoi(cmd_argvs[8]);
+ vol->hi = atoi(cmd_argvs[9]);
+ vol->cellsize[0] = atof(cmd_argvs[10]) *
gedp->ged_wdbp->dbip->dbi_local2base;
+ vol->cellsize[1] = atof(cmd_argvs[11]) *
gedp->ged_wdbp->dbip->dbi_local2base;
+ vol->cellsize[2] = atof(cmd_argvs[12]) *
gedp->ged_wdbp->dbip->dbi_local2base;
+
+ if (*cmd_argvs[3] == 'f' || *cmd_argvs[3] == 'F')
+ vol->datasrc = RT_VOL_SRC_FILE;
+ else if (*cmd_argvs[3] == 'o' || *cmd_argvs[3] == 'O')
+ vol->datasrc = RT_VOL_SRC_OBJ;
+ else
+ return GED_ERROR;
+
MAT_IDN(vol->mat);
return GED_OK;
@@ -3206,7 +3215,7 @@
menu = p_submodel;
fn_in = submodel_in;
} else if (BU_STR_EQUAL(argv[2], "vol")) {
- nvals = 9;
+ nvals = 10;
menu = p_vol;
fn_in = vol_in;
} else if (BU_STR_EQUAL(argv[2], "hf")) {
Modified: brlcad/branches/extbuild/src/librt/db_fullpath.c
===================================================================
--- brlcad/branches/extbuild/src/librt/db_fullpath.c 2020-11-06 17:40:36 UTC
(rev 77699)
+++ brlcad/branches/extbuild/src/librt/db_fullpath.c 2020-11-06 20:56:36 UTC
(rev 77700)
@@ -257,13 +257,13 @@
int type;
const struct bn_tol tol = {BN_TOL_MAGIC, BN_TOL_DIST, BN_TOL_DIST *
BN_TOL_DIST, 1e-6, 1.0 - 1e-6 };
- if (!full_path)
+ if (!full_path || full_path->fp_len == 0)
return;
BU_CK_VLS(vls);
RT_CK_FULL_PATH(full_path);
- if (!full_path->fp_names[0]) {
+ if (full_path->fp_names == NULL) {
bu_vls_strcat(vls, "**NULL**");
return;
}
Modified: brlcad/branches/extbuild/src/librt/primitives/vol/vol.c
===================================================================
--- brlcad/branches/extbuild/src/librt/primitives/vol/vol.c 2020-11-06
17:40:36 UTC (rev 77699)
+++ brlcad/branches/extbuild/src/librt/primitives/vol/vol.c 2020-11-06
20:56:36 UTC (rev 77700)
@@ -65,7 +65,9 @@
#define VOL_O(m) bu_offsetof(struct rt_vol_internal, m)
const struct bu_structparse rt_vol_parse[] = {
- {"%s", RT_VOL_NAME_LEN, "file", bu_offsetof(struct rt_vol_internal, file),
BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
+ {"%s", RT_VOL_NAME_LEN, "file", bu_offsetof(struct rt_vol_internal, name),
BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
+ {"%s", RT_VOL_NAME_LEN, "name", bu_offsetof(struct rt_vol_internal, name),
BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
+ {"%c", 1, "src", VOL_O(datasrc), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "w", VOL_O(xdim), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "n", VOL_O(ydim), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%d", 1, "d", VOL_O(zdim), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
@@ -79,7 +81,8 @@
extern void rt_vol_plate(point_t a, point_t b, point_t c, point_t d,
mat_t mat, struct bu_list *vhead, struct
rt_vol_internal *vip);
-
+extern int rt_retrieve_binunif(struct rt_db_internal *intern, const struct
db_i *dbip, const char *name);
+extern int rt_binunif_describe(struct bu_vls *str, const struct
rt_db_internal *ip, int verbose, double mm2local);
/*
* Codes to represent surface normals.
* In a bitmap, there are only 4 possible normals.
@@ -115,7 +118,6 @@
static int rt_vol_normtab[3] = { NORM_XPOS, NORM_YPOS, NORM_ZPOS };
-
/**
* Transform the ray into local coordinates of the volume ("ideal space").
* Step through the 3-D array, in local coordinates.
@@ -472,7 +474,7 @@
bu_vls_free(&str);
/* Check for reasonable values */
- if (vip->file[0] == '\0' || vip->xdim < 1 ||
+ if (vip->name[0] == '\0' || vip->xdim < 1 ||
vip->ydim < 1 || vip->zdim < 1 || vip->mat[15] <= 0.0 ||
vip->hi > 255) {
bu_struct_print("Unreasonable VOL parameters", rt_vol_parse,
@@ -492,8 +494,8 @@
vip->map = (unsigned char *)bu_calloc(1, nbytes, "vol_import4 bitmap");
bu_semaphore_acquire(BU_SEM_SYSCALL); /* lock */
- if ((fp = fopen(vip->file, "rb")) == NULL) {
- perror(vip->file);
+ if ((fp = fopen(vip->name, "rb")) == NULL) {
+ perror(vip->name);
bu_semaphore_release(BU_SEM_SYSCALL); /* unlock */
return -1;
}
@@ -508,7 +510,7 @@
bu_semaphore_release(BU_SEM_SYSCALL); /* unlock */
if (ret < 1) {
bu_log("rt_vol_import4(%s): Unable to read whole VOL, y=%zu,
z=%zu\n",
- vip->file, y, z);
+ vip->name, y, z);
bu_semaphore_acquire(BU_SEM_SYSCALL); /* lock */
fclose(fp);
bu_semaphore_release(BU_SEM_SYSCALL); /* unlock */
@@ -612,6 +614,163 @@
/**
+ * Read VOL data from external file
+ * Returns :
+ * 0 success
+ * !0 fail
+ */
+static int
+vol_file_data(struct rt_vol_internal *vip)
+{
+ size_t nbytes;
+
+ size_t bytes = vip->xdim * vip->ydim * vip->zdim;
+ nbytes = vol_from_file(vip->name, vip->xdim, vip->ydim, vip->zdim,
&vip->map);
+ if (nbytes != bytes) {
+ bu_log("WARNING: unexpected VOL bytes (read %zu, expected %zu) in
%s\n", nbytes, bytes, vip->name);
+ }
+
+ return 0;
+}
+
+
+/**
+ * Read VOL data from in database object
+ * Returns :
+ * 0 success
+ * !0 fail
+ */
+static int
+get_obj_data(struct rt_vol_internal *vip, const struct db_i *dbip)
+{
+ struct rt_binunif_internal *bip;
+ int ret;
+ int nbytes;
+
+ BU_ALLOC(vip->bip, struct rt_db_internal);
+
+ ret = rt_retrieve_binunif(vip->bip, dbip, vip->name);
+ if (ret)
+ return -1;
+
+ if (RT_G_DEBUG & RT_DEBUG_HF) {
+ bu_log("db_internal magic: 0x%08x major: %d minor: %d\n",
+ vip->bip->idb_magic,
+ vip->bip->idb_major_type,
+ vip->bip->idb_minor_type);
+ }
+
+ bip = (struct rt_binunif_internal *)vip->bip->idb_ptr;
+
+ if (RT_G_DEBUG & RT_DEBUG_HF)
+ bu_log("binunif magic: 0x%08x type: %d count:%zu data[0]:%u\n",
+ bip->magic, bip->type, bip->count, bip->u.uint8[0]);
+
+ if (bip->type != DB5_MINORTYPE_BINU_8BITINT_U
+ || (size_t)bip->count != (size_t)(vip->xdim*vip->ydim*vip->zdim))
+ {
+ size_t i = 0;
+ size_t size;
+ struct bu_vls binudesc = BU_VLS_INIT_ZERO;
+ rt_binunif_describe(&binudesc, vip->bip, 0, dbip->dbi_base2local);
+
+ /* skip the first title line*/
+ size = bu_vls_strlen(&binudesc);
+ while (size > 0 && i < size && bu_vls_cstr(&binudesc)[0] != '\n') {
+ bu_vls_nibble(&binudesc, 1);
+ }
+ if (bu_vls_cstr(&binudesc)[0] == '\n')
+ bu_vls_nibble(&binudesc, 1);
+
+ bu_log("ERROR: Binary object '%s' has invalid data (expected type %d,
found %d).\n"
+ " Expecting %zu 8-bit unsigned char (nuc) integer data
values.\n"
+ " Encountered %s\n",
+ vip->name,
+ DB5_MINORTYPE_BINU_8BITINT_U,
+ bip->type,
+ (size_t)(vip->xdim*vip->ydim*vip->zdim),
+ bu_vls_cstr(&binudesc));
+ return -2;
+ }
+
+ nbytes =
(vip->xdim+VOL_XWIDEN*2)*(vip->ydim+VOL_YWIDEN*2)*(vip->zdim+VOL_ZWIDEN*2);
+
+ size_t y, z;
+ if (!vip->map) {
+ unsigned char* cp;
+
+ vip->map = (unsigned char *)bu_calloc(1, nbytes, "vol_import4 bitmap");
+ cp = (unsigned char *)bip->u.uint8;
+
+ for (z = 0; z < vip->zdim; z++) {
+ for (y = 0; y < vip->ydim; y++) {
+ void *data = &VOLMAP(vip->map, vip->xdim, vip->ydim, 0, y, z);
+
+ memcpy(data, cp, vip->xdim);
+ cp+= vip->xdim;
+ }
+ }
+ }
+ return 0;
+}
+
+/**
+ * Retrieve VOL data from data source
+ * Returns :
+ * 0 success
+ * !0 fail
+ */
+static int
+get_vol_data(struct rt_vol_internal *vip, const mat_t mat, const struct db_i
*dbip)
+{
+ mat_t tmp;
+ char *p;
+
+ /* Apply Modelling transform */
+ bn_mat_mul(tmp, mat, vip->mat);
+ MAT_COPY(vip->mat, tmp);
+ p = vip->name;
+
+ switch (vip->datasrc) {
+case RT_VOL_SRC_FILE:
+ /* Retrieve the data from an external file */
+ if (RT_G_DEBUG & RT_DEBUG_HF)
+ bu_log("getting data from file \"%s\"\n", p);
+
+ if(vol_file_data(vip) != 0) {
+ return 1;
+ p = "file";
+ }
+ else {
+ return 0;
+ }
+ break;
+case RT_VOL_SRC_OBJ:
+ /* Retrieve the data from an internal db object */
+ if (RT_G_DEBUG & RT_DEBUG_HF)
+ bu_log("getting data from object \"%s\"\n", p);
+
+ if (get_obj_data(vip, dbip) != 0) {
+ p = "object";
+ return 1;
+ } else {
+ RT_CK_DB_INTERNAL(vip->bip);
+ RT_CK_BINUNIF(vip->bip->idb_ptr);
+ return 0;
+ }
+ break;
+default:
+bu_log("%s:%d Odd vol data src '%c' s/b '%c' or '%c'\n",
+ __FILE__, __LINE__, vip->datasrc,
+ RT_VOL_SRC_FILE, RT_VOL_SRC_OBJ);
+ }
+
+ bu_log("%s", dbip->dbi_filename);
+ return 0; //temporary
+}
+
+
+/**
* Read in the information from the string solid record.
* Then, as a service to the application, read in the bitmap
* and set up some of the associated internal variables.
@@ -621,7 +780,6 @@
{
register struct rt_vol_internal *vip;
struct bu_vls str = BU_VLS_INIT_ZERO;
- size_t nbytes;
mat_t tmat;
if (dbip) RT_CK_DBI(dbip);
@@ -651,9 +809,8 @@
return -2;
}
bu_vls_free(&str);
-
/* Check for reasonable values */
- if (vip->file[0] == '\0'
+ if (vip->name[0] == '\0'
|| vip->xdim < 1 || vip->ydim < 1 || vip->zdim < 1
|| vip->mat[15] <= 0.0 || vip->hi > 255)
{
@@ -668,15 +825,8 @@
bn_mat_mul(tmat, mat, vip->mat);
MAT_COPY(vip->mat, tmat);
- if (bu_file_exists(vip->file, NULL)) {
- size_t bytes = vip->xdim * vip->ydim * vip->zdim;
- nbytes = vol_from_file(vip->file, vip->xdim, vip->ydim, vip->zdim,
&vip->map);
- if (nbytes != bytes) {
- bu_log("WARNING: unexpected VOL bytes (read %zu, expected %zu) in
%s\n", nbytes, bytes, vip->file);
- }
- } else {
- bu_log("WARNING: VOL data file missing [%s]\n", vip->file);
- }
+ if (get_vol_data(vip, mat, dbip) == 1)
+ bu_log("Couldn't find the associated file/object %s",vip->name);
return 0;
}
@@ -735,10 +885,18 @@
/* pretty-print dimensions in local, not storage (mm) units */
VSCALE(local, vip->cellsize, mm2local);
+ if (vip->datasrc == RT_VOL_SRC_FILE) {
bu_vls_printf(&substr, "\tfile=\"%s\"\n\tw=%u n=%u d=%u\n\tlo=%u
hi=%u\n\tsize=%g,%g,%g\n",
- vip->file,
+ vip->name,
vip->xdim, vip->ydim, vip->zdim, vip->lo, vip->hi,
V3INTCLAMPARGS(local));
+ } else {
+ bu_vls_printf(&substr, "\tobject name=\"%s\"\n\tw=%u n=%u d=%u\n\tlo=%u
hi=%u\n\tsize=%g,%g,%g\n",
+ vip->name,
+ vip->xdim, vip->ydim, vip->zdim, vip->lo, vip->hi,
+ V3INTCLAMPARGS(local));
+ }
+
bu_vls_vlscat(str, &substr);
bu_vls_strcat(str, "\tmat=");
@@ -868,7 +1026,7 @@
register const struct rt_vol_specific *volp =
(struct rt_vol_specific *)stp->st_specific;
- bu_log("vol file = %s\n", volp->vol_i.file);
+ bu_log("vol file = %s\n", volp->vol_i.name);
bu_log("dimensions = (%u, %u, %u)\n",
volp->vol_i.xdim, volp->vol_i.ydim,
volp->vol_i.zdim);
Modified: brlcad/branches/extbuild/src/librt/search.c
===================================================================
--- brlcad/branches/extbuild/src/librt/search.c 2020-11-06 17:40:36 UTC (rev
77699)
+++ brlcad/branches/extbuild/src/librt/search.c 2020-11-06 20:56:36 UTC (rev
77700)
@@ -152,8 +152,7 @@
*/
HIDDEN void
db_fullpath_list_subtree(struct db_full_path *path, int curr_bool, union tree
*tp,
- void (*traverse_func) (struct db_full_path *path,
- void *),
+ void (*traverse_func) (struct db_full_path *path, void
*),
void *client_data)
{
struct directory *dp;
@@ -228,8 +227,7 @@
* processing and filtering by the search routines.
*/
HIDDEN void
-db_fullpath_list(struct db_full_path *path,
- void *client_data)
+db_fullpath_list(struct db_full_path *path, void *client_data)
{
struct directory *dp;
struct list_client_data_t *lcd= (struct list_client_data_t *)client_data;
@@ -338,7 +336,8 @@
HIDDEN int
-find_execute_nested_plans(struct db_i *dbip, struct bu_ptbl *results, struct
db_node_t *db_node, struct db_plan_t *plan) {
+find_execute_nested_plans(struct db_i *dbip, struct bu_ptbl *results, struct
db_node_t *db_node, struct db_plan_t *plan)
+{
struct db_plan_t *p = NULL;
int state = 0;
for (p = plan; p && (state = (p->eval)(p, db_node, dbip, results)); p =
p->next)
@@ -526,7 +525,6 @@
int ret = 0;
dp = DB_FULL_PATH_CUR_DIR(db_node->path);
-
if (!dp) {
db_node->matched_filters = 0;
return 0;
@@ -619,7 +617,8 @@
HIDDEN int
-string_to_name_and_val(const char *in, struct bu_vls *name, struct bu_vls
*value) {
+string_to_name_and_val(const char *in, struct bu_vls *name, struct bu_vls
*value)
+{
size_t equalpos = 0;
int checkval = 0;
@@ -1204,7 +1203,8 @@
struct bu_vls value = BU_VLS_INIT_ZERO;
dp = DB_FULL_PATH_CUR_DIR(db_node->path);
- if (!dp) return 0;
+ if (!dp)
+ return 0;
/* Check for unescaped >, < or = characters. If present, the
* attribute must not only be present but the value assigned to
@@ -1440,10 +1440,12 @@
{
/* TODO make this faster by storing the individual "subholes" so they
don't have to be recalculated */
int ret, hole_i, char_i, plain_begin, plain_len;
+ char **filleds = NULL;
char **originals = NULL;
- char **filleds = NULL;
char *name;
- size_t name_len, filled_len, old_filled_len;
+ size_t filled_len = 0;
+ size_t name_len = 0;
+ size_t old_filled_len = 0;
if (0 < plan->p_un.ex._e_nholes) {
originals = (char **)bu_calloc(plan->p_un.ex._e_nholes, sizeof(char *),
"f_exec originals");
@@ -1459,7 +1461,8 @@
} else {
name = db_path_to_string(db_node->path);
}
- name_len = strlen(name);
+ if (name)
+ name_len = strlen(name);
for (hole_i=0; hole_i<plan->p_un.ex._e_nholes; hole_i++) {
plain_begin = 0;
@@ -1745,11 +1748,13 @@
HIDDEN int
f_print(struct db_plan_t *UNUSED(plan), struct db_node_t *db_node, struct db_i
*UNUSED(dbip), struct bu_ptbl *results)
{
- if (!results)
+ if (!results || !db_node)
return 1;
if (db_node->flags & DB_SEARCH_FLAT || db_node->flags &
DB_SEARCH_RETURN_UNIQ_DP) {
- bu_ptbl_ins_unique(results, (long
*)DB_FULL_PATH_CUR_DIR(db_node->path));
+ long *dbfp = (long *)DB_FULL_PATH_CUR_DIR(db_node->path);
+ if (dbfp)
+ bu_ptbl_ins_unique(results, dbfp);
} else {
struct db_full_path *new_entry;
BU_ALLOC(new_entry, struct db_full_path);
@@ -2398,7 +2403,8 @@
HIDDEN void
-find_execute_plans(struct db_i *dbip, struct bu_ptbl *results, struct
db_node_t *db_node, struct db_plan_t *plan) {
+find_execute_plans(struct db_i *dbip, struct bu_ptbl *results, struct
db_node_t *db_node, struct db_plan_t *plan)
+{
struct db_plan_t *p;
for (p = plan; p && (p->eval)(p, db_node, dbip, results); p = p->next)
;
Modified: brlcad/branches/extbuild/src/libwdb/vol.c
===================================================================
--- brlcad/branches/extbuild/src/libwdb/vol.c 2020-11-06 17:40:36 UTC (rev
77699)
+++ brlcad/branches/extbuild/src/libwdb/vol.c 2020-11-06 20:56:36 UTC (rev
77700)
@@ -35,8 +35,9 @@
int
-mk_vol(struct rt_wdb *fp, const char *name, const char *file, size_t xdim,
size_t ydim, size_t zdim, size_t lo, size_t hi, const fastf_t *cellsize, const
matp_t mat)
- /* name of file containing bitmap */
+mk_vol(struct rt_wdb *fp, const char *name, char datasrc, const char *file,
size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi, const fastf_t
*cellsize, const matp_t mat)
+ /* type of data source */
+ /* name of file/object containing bitmap */
/* X dimension of file (w cells) */
/* Y dimension of file (n cells) */
/* Z dimension of file (d cells) */
@@ -49,7 +50,8 @@
BU_ALLOC(vol, struct rt_vol_internal);
vol->magic = RT_VOL_INTERNAL_MAGIC;
- bu_strlcpy(vol->file, file, RT_VOL_NAME_LEN);
+ vol->datasrc = datasrc;
+ bu_strlcpy(vol->name, file, RT_VOL_NAME_LEN);
vol->xdim = xdim;
vol->ydim = ydim;
vol->zdim = zdim;
Modified: brlcad/branches/extbuild/src/mged/edsol.c
===================================================================
--- brlcad/branches/extbuild/src/mged/edsol.c 2020-11-06 17:40:36 UTC (rev
77699)
+++ brlcad/branches/extbuild/src/mged/edsol.c 2020-11-06 20:56:36 UTC (rev
77700)
@@ -4135,14 +4135,14 @@
RT_VOL_CK_MAGIC(vol);
if (inpara == 3) {
- if (stat(vol->file, &stat_buf)) {
- Tcl_AppendResult(INTERP, "Cannot get status of file ",
vol->file, (char *)NULL);
+ if (stat(vol->name, &stat_buf)) {
+ Tcl_AppendResult(INTERP, "Cannot get status of file ",
vol->name, (char *)NULL);
mged_print_result(TCL_ERROR);
return;
}
need_size = es_para[0] * es_para[1] * es_para[2] *
sizeof(unsigned char);
if (stat_buf.st_size < need_size) {
- Tcl_AppendResult(INTERP, "File (", vol->file,
+ Tcl_AppendResult(INTERP, "File (", vol->name,
") is too small, set file name first",
(char *)NULL);
mged_print_result(TCL_ERROR);
return;
@@ -4220,7 +4220,7 @@
RT_VOL_CK_MAGIC(vol);
- fname = get_file_name(vol->file);
+ fname = get_file_name(vol->name);
if (fname) {
struct bu_vls message = BU_VLS_INIT_ZERO;
@@ -4239,7 +4239,7 @@
mged_print_result(TCL_ERROR);
return;
}
- bu_strlcpy(vol->file, fname, RT_VOL_NAME_LEN);
+ bu_strlcpy(vol->name, fname, RT_VOL_NAME_LEN);
}
break;
Modified: brlcad/branches/extbuild/src/tclscripts/checker/OverlapFileTool.tcl
===================================================================
--- brlcad/branches/extbuild/src/tclscripts/checker/OverlapFileTool.tcl
2020-11-06 17:40:36 UTC (rev 77699)
+++ brlcad/branches/extbuild/src/tclscripts/checker/OverlapFileTool.tcl
2020-11-06 20:56:36 UTC (rev 77700)
@@ -21,9 +21,8 @@
#
# Description -
#
-# This is the Overlaps File tool. Which creates a new overlaps file
-# for the checker tool.
-#
+# This is the Overlaps File tool.
+#
package require Tk
package require Itcl
@@ -59,9 +58,6 @@
variable _statusText
variable _progressValue
- method runCheckOverlapsAE { obj } {}
- method runCheckOverlapsTriple { obj } {}
-
method sortPairs {} {}
method rmDupPairs {} {}
@@ -186,7 +182,8 @@
# get _objs from list
set _objs ""
foreach obj [$itk_component(objectsList) get 0 end] {
- append _objs " " $obj
+ set objn [string trim $obj "/"]
+ append _objs $objn
}
# check if user passed the objects list
if { [llength $_objs] == 0 } {
@@ -199,13 +196,26 @@
$itk_component(objectsEntry) configure -state disabled
$this configure -cursor watch
- # run checkoverlaps for all the specified objects
- if { [string length $_objs] > 0 } {
- $this runCheckOverlapsAE $_objs
- $this runCheckOverlapsTriple $_objs
+ # delete any previous overlaps files in the db directory
+ set db_path [eval opendb]
+ set dir [file dirname $db_path]
+ set name [file tail $db_path]
+ set ol_dir [file join $dir "${name}.ck"]
+ set filename [file join $dir "${name}.ck" "ck.${name}.overlaps"]
+ file delete -force -- $ol_dir
+
+ # run overlaps check for all the specified objects
+ if { [catch {exec [file join [bu_dir bin] gchecker] $db_path $_objs}] } {
+ set gcmd "[file join [bu_dir bin] gchecker] $db_path $_objs"
+ puts "gchecker run failed: $gcmd"
}
+
# check for the count of overlaps detected
- set ov_count [llength $pairsList]
+ set fp [open $filename r]
+ set ldata [read $fp]
+ set ov_count [llength [split $ldata "\n"]]
+ incr ov_count -1
+
if { $ov_count == 0 } {
tk_messageBox -type ok -title "No Overlaps Found" -message "No Overlaps
Found"
$itk_component(buttonGo) configure -state normal
@@ -218,27 +228,6 @@
puts "\nCount of overlaps: $ov_count\n"
- # process the overlap pairs
- $this sortPairs
- $this rmDupPairs
-
- # delete any previous overlaps files in the db directory
- set db_path [eval opendb]
- set dir [file dirname $db_path]
- set name [file tail $db_path]
- set ol_dir [file join $dir "${name}.ck"]
- set filename [file join $dir "${name}.ck" "ck.${name}.overlaps"]
- file delete -force -- $ol_dir
-
- # create new folder
- file mkdir $ol_dir
- # write the overlaps file
- set fp [open $filename w+]
- foreach pair [lsort -decreasing -real -index 2 $overlapsList] {
- #puts $pair
- puts $fp $pair
- }
- close $fp
puts "\nOverlaps file saved: $filename"
# run checker tool
@@ -527,70 +516,7 @@
set pairsList [lsort $pairsList]
}
-# runCheckOverlapsTriple
-#
-# runs the check overlaps command for the passed object
-# in triple grid mode
-#
-body OverlapFileTool::runCheckOverlapsTriple { obj } {
- set cmd "check overlaps -g1mm,1mm -q $obj"
- set _statusText "Running $cmd"
- if [ catch {set check_list [eval $cmd]} ] {
- set check_list {}
- }
- set lines [split $check_list \n]
- foreach line $lines {
- regexp {<(.*),.(.*)>: ([0-9]*).* (.*).mm} $line full left right count
depth
- if { [info exists full] == 0 } {
- continue
- }
- set size [expr $count * $depth]
- # swaps the region names by comparing lexicographically
- if { [string compare $left $right] > 0 } {
- lappend pairsList [list $right $left $size]
- } else {
- lappend pairsList [list $left $right $size]
- }
- # unset $full for next line
- unset full
- }
- set _progressValue 90
-}
-# runCheckOverlapsAE
-#
-# runs the check overlaps command for the passed object
-# 16 times for different combinations of az/el values
-# in single grid mode
-#
-body OverlapFileTool::runCheckOverlapsAE { obj } {
- for { set az 0} {$az < 180} {incr az 45} {
- for { set el 0} {$el < 180} {incr el 45} {
- set cmd "check overlaps -G1024 -a$az -e$el -q $obj"
- set _statusText "Running $cmd"
- incr _progressValue 4
- if [catch {set check_list [eval $cmd]}] {
- set check_list {}
- }
- set lines [split $check_list \n]
- foreach line $lines {
- regexp {<(.*),.(.*)>: ([0-9]*).* (.*).mm} $line full left right
count depth
- if { [info exists full] == 0 } {
- continue
- }
- set size [expr $count * $depth]
- # swaps the region names by comparing lexicographically
- if { [string compare $left $right] > 0 } {
- lappend pairsList [list $right $left $size]
- } else {
- lappend pairsList [list $left $right $size]
- }
- # unset $full for next line
- unset full
- }
- }
- }
-}
###########
# end private methods
###########
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