44 db_corrupt_handler(
struct db_i *dbip,
const char *
name, off_t offset,
size_t size,
int UNUSED(type),
void *
data)
48 union record *rp = NULL;
49 mat_t diskmat = MAT_INIT_ZERO;
59 bu_log(
"Database seek failure, unable to seek [%s]\n", name);
71 bu_log(
"Database read failure, unable to read [%s]\n", name);
76 rp = (
union record *)ext.
ext_buf;
77 if (rp[0].u_id != ID_COMB) {
84 nodecount = ext.
ext_nbytes/
sizeof(
union record) - 1;
85 for (j = 0; j < nodecount; j++) {
90 || fabs(diskmat[0]) > 1 || fabs(diskmat[1]) > 1 || fabs(diskmat[2]) > 1
91 || fabs(diskmat[4]) > 1 || fabs(diskmat[5]) > 1 || fabs(diskmat[6]) > 1
92 || fabs(diskmat[8]) > 1 || fabs(diskmat[9]) > 1 || fabs(diskmat[10]) > 1) {
99 || fabs(diskmat[0]) > 1 || fabs(diskmat[1]) > 1 || fabs(diskmat[2]) > 1
100 || fabs(diskmat[4]) > 1 || fabs(diskmat[5]) > 1 || fabs(diskmat[6]) > 1
101 || fabs(diskmat[8]) > 1 || fabs(diskmat[9]) > 1 || fabs(diskmat[10]) > 1)
103 bu_log(
"WARNING: Invalid matrix detected within %s\n", name);
132 v4flip = getenv(
"LIBRT_V4FLIP");
140 db_scan(dbip, db_corrupt_handler, 0, &cnt);
145 bu_log(
"%zu of %zu objects were NOT fixed by flipping endian interpretation. Manual inspection and repair required.\n", cnt.
found - cnt.
fixed, cnt.
found);
void bu_log(const char *,...) _BU_ATTR_PRINTF12
int bu_fseek(FILE *stream, off_t offset, int origin)
int db_version(struct db_i *dbip)
void bu_free_external(struct bu_external *ep)
Header file for the BRL-CAD common definitions.
void flip_mat_dbmat(fastf_t *ff, const dbfloat_t *dbp, int flip)
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
int rt_db_flip_endian(struct db_i *dbip)
#define UNUSED(parameter)
int bn_mat_ck(const char *title, const mat_t m)
FILE * dbi_fp
PRIVATE: object hash table.
#define BU_EXTERNAL_INIT(_p)
int db_scan(struct db_i *, int(*handler)(struct db_i *, const char *name, off_t addr, size_t nrec, int flags, void *client_data), int do_old_matter, void *client_data)
int bu_str_true(const char *str)