Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caf4ef87af | ||
|
|
156fb2ba97 |
+9
-12
@@ -738,9 +738,9 @@ $# define MGED_LIBES LIBDM LIBDM_LIBES -L''XLIBDIR -lXi -lXext -lX11 -ly -L../
|
||||
# if defined( __GNUC__ )
|
||||
# define CC gcc
|
||||
# if 1 /* PRODUCTION=1 */
|
||||
# define OPTIMIZER -O2 -fwritable-strings -Wall
|
||||
# define OPTIMIZER -O2 -fwritable-strings
|
||||
# else
|
||||
# define OPTIMIZER -g -fwritable-strings -Wall
|
||||
# define OPTIMIZER -g -fwritable-strings
|
||||
# endif
|
||||
# define CC_DEFS -D_REENTRANT -DSUNOS=55
|
||||
# define CC_OPTS -I''XINCDIR
|
||||
@@ -901,7 +901,7 @@ $# define MGED_LIBES LIBDM LIBDM_LIBES -L''XLIBDIR -lXi -lXext -lX11 -ly -L../
|
||||
# define BSD 44
|
||||
# define HAS_TCP 1
|
||||
# define HAS_SYMLINKS 1
|
||||
# if 0 /* PRODUCTION=1 */
|
||||
# if 1 /* PRODUCTION=1 */
|
||||
# define OPTIMIZER -O2
|
||||
# else
|
||||
# define OPTIMIZER -g
|
||||
@@ -909,7 +909,7 @@ $# define MGED_LIBES LIBDM LIBDM_LIBES -L''XLIBDIR -lXi -lXext -lX11 -ly -L../
|
||||
# if 1 /* PRODUCTION=1 */
|
||||
/* Shared library version support. Requires ELF for Linux. */
|
||||
# define CC gcc
|
||||
# define CC_OPTS -fPIC -Wall
|
||||
# define CC_OPTS -fPIC
|
||||
# define ARCH_SUF so
|
||||
# define LIBVERS ../sh/sharedlibvers.sh
|
||||
# define BUILD_LIBRARY gcc -shared -o
|
||||
@@ -920,7 +920,7 @@ $# define MGED_LIBES LIBDM LIBDM_LIBES -L''XLIBDIR -lXi -lXext -lX11 -ly -L../
|
||||
# define CC gcc
|
||||
# define RANLIB ar -s
|
||||
/* Don't use -ansi, that gives __STRICT_ANSI__. Default is _GNU_SOURCE. */
|
||||
# define CC_OPTS -Wall
|
||||
# define CC_OPTS /**/
|
||||
# endif
|
||||
# define XINCDIR /usr/X11R6/include
|
||||
# define XLIBDIR /usr/X11R6/lib
|
||||
@@ -987,22 +987,19 @@ $# define MGED_LIBES LIBDM LIBDM_LIBES -L''XLIBDIR -lXi -lXext -lX11 -ly -L../
|
||||
# define XINCDIR /usr/X11R6/include
|
||||
# define XLIBDIR /usr/X11R6/lib
|
||||
# define CC gcc
|
||||
# define OPTIMIZER -O2
|
||||
# define LEX_OPTS -l
|
||||
# if 1 /* PRODUCTION=1 */
|
||||
# define OPTIMIZER -O2
|
||||
# else
|
||||
# define OPTIMIZER -g
|
||||
# endif
|
||||
|
||||
# if 1 /* PRODUCTION=1 */
|
||||
/* Shared library version support. */
|
||||
# define CC_DEFS -pipe -fPIC -Wall
|
||||
# define CC_DEFS -pipe -fPIC
|
||||
# define ARCH_SUF so
|
||||
# define LIBVERS ../sh/sharedlibvers.sh
|
||||
# define BUILD_LIBRARY ld -Bshareable -o
|
||||
# define STANDARD_LIBES -lm -Wl,-R -Wl,LIBDIR
|
||||
# else
|
||||
/* Static linked executables */
|
||||
# define CC_DEFS -pipe -Wall
|
||||
# define CC_DEFS -pipe
|
||||
# endif
|
||||
|
||||
# define LIBRT_TIMER timer42
|
||||
|
||||
+1
-2
@@ -23,7 +23,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -36,7 +36,6 @@ long offmany;
|
||||
|
||||
char usage[] = "Usage: pixcmp f1.pix f2.pix\n";
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
+1
-4
@@ -9,7 +9,7 @@
|
||||
g-euclid euclid_format euclid_unformat tankill-g g-tankill \
|
||||
viewpoint-g dxf-g g-nmg g-euclid1 fast4-g proe-g \
|
||||
asc-nmg nmg-rib g-vrml g-acad cy-g nastran-g g-wave \
|
||||
nmg-polysolid g-shell.rect stl-g g4-g5
|
||||
nmg-polysolid g-shell.rect stl-g
|
||||
#define SRCSUFF .c
|
||||
#define MANSECTION 1
|
||||
|
||||
@@ -108,7 +108,4 @@ nmg-rib: nmg-rib.o LIBRT_DEP LIBBN_DEP LIBBU_DEP LIBTCL_DEP
|
||||
g-vrml: g-vrml.o LIBRT_DEP LIBBN_DEP LIBBU_DEP LIBTCL_DEP
|
||||
CC LDFLAGS g-vrml.o LIBWDB LIBRT LIBBN LIBBU LIBBU_LIBES LIBTCL LIBTCL_LIBES LIBES -o g-vrml
|
||||
|
||||
g4-g5: g4-g5.o LIBRT_DEP LIBBN_DEP LIBBU_DEP LIBTCL_DEP
|
||||
CC LDFLAGS g4-g5.o LIBWDB LIBRT LIBBN LIBBU LIBBU_LIBES LIBTCL LIBTCL_LIBES LIBES -o g4-g5
|
||||
|
||||
#include "../Cakefile.rules"
|
||||
|
||||
+51
-2
@@ -3425,8 +3425,9 @@ struct db_i *dbip;
|
||||
case OP_DB_LEAF:
|
||||
if( (dp=db_lookup( dbip, ptr->tr_l.tl_name, LOOKUP_QUIET)) == DIR_NULL )
|
||||
{
|
||||
ptr->tr_l.tl_op = OP_NOP;
|
||||
return( ptr );
|
||||
db_free_tree( ptr );
|
||||
ptr = TREE_NULL;
|
||||
return( TREE_NULL );
|
||||
}
|
||||
|
||||
if( !(dp->d_flags & DIR_REGION) )
|
||||
@@ -3512,6 +3513,54 @@ struct db_i *dbip;
|
||||
/* recurse */
|
||||
ptr->tr_b.tb_left = expand_tree( ptr->tr_b.tb_left, dbip );
|
||||
ptr->tr_b.tb_right = expand_tree( ptr->tr_b.tb_right, dbip );
|
||||
if( (ptr->tr_b.tb_left == TREE_NULL) && (ptr->tr_b.tb_right == TREE_NULL) )
|
||||
{
|
||||
ptr->tr_op = 0;
|
||||
bu_free( (char *)ptr, "union tree" );
|
||||
ptr = TREE_NULL;
|
||||
}
|
||||
else if( ptr->tr_b.tb_right == TREE_NULL )
|
||||
{
|
||||
if( ptr->tr_op == OP_INTERSECT )
|
||||
{
|
||||
/* intersection with nothing is nothing */
|
||||
db_free_tree( ptr->tr_b.tb_left );
|
||||
ptr->tr_op = 0;
|
||||
bu_free( (char *)ptr, "union tree" );
|
||||
ptr = TREE_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
union tree *save;
|
||||
|
||||
/* just return the left tree */
|
||||
save = ptr->tr_b.tb_left;
|
||||
ptr->tr_op = 0;
|
||||
bu_free( (char *)ptr, "union tree" );
|
||||
ptr = save;
|
||||
}
|
||||
}
|
||||
else if( ptr->tr_b.tb_left == TREE_NULL )
|
||||
{
|
||||
if( ptr->tr_op == OP_UNION )
|
||||
{
|
||||
union tree *save;
|
||||
|
||||
/* return the right tree */
|
||||
save = ptr->tr_b.tb_right;
|
||||
ptr->tr_op = 0;
|
||||
bu_free( (char *)ptr, "union tree" );
|
||||
ptr = save;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* result is nothing */
|
||||
db_free_tree( ptr->tr_b.tb_right );
|
||||
ptr->tr_op = 0;
|
||||
bu_free( (char *)ptr, "union tree" );
|
||||
ptr = TREE_NULL;
|
||||
}
|
||||
}
|
||||
return( ptr );
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-2
@@ -175,10 +175,11 @@ genptr_t client_data;
|
||||
}
|
||||
|
||||
static union tree *
|
||||
leaf_stub( tsp, pathp, ip, client_data )
|
||||
leaf_stub( tsp, pathp, ep, id, client_data )
|
||||
struct db_tree_state *tsp;
|
||||
struct db_full_path *pathp;
|
||||
struct rt_db_internal *ip;
|
||||
struct bu_external *ep;
|
||||
int id;
|
||||
genptr_t client_data;
|
||||
{
|
||||
bu_log( "leaf stub called, this shouldn't happen\n" );
|
||||
|
||||
+3
-2
@@ -147,10 +147,11 @@ genptr_t client_data;
|
||||
}
|
||||
|
||||
static union tree *
|
||||
leaf_stub( tsp, pathp, ip, client_data )
|
||||
leaf_stub( tsp, pathp, ep, id, client_data )
|
||||
struct db_tree_state *tsp;
|
||||
struct db_full_path *pathp;
|
||||
struct rt_db_internal *ip;
|
||||
struct bu_external *ep;
|
||||
int id;
|
||||
genptr_t client_data;
|
||||
{
|
||||
struct directory *fp_name; /* name from pathp */
|
||||
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
#include "bn.h"
|
||||
#include "raytrace.h"
|
||||
#include "rtgeom.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
FILE *fp;
|
||||
struct db_i *dbip;
|
||||
struct directory *dp;
|
||||
int i;
|
||||
long errors = 0;
|
||||
struct bn_tol tol;
|
||||
|
||||
/* XXX These need to be improved */
|
||||
tol.magic = BN_TOL_MAGIC;
|
||||
tol.dist = 0.005;
|
||||
tol.dist_sq = tol.dist * tol.dist;
|
||||
tol.perp = 1e-6;
|
||||
tol.para = 1 - tol.perp;
|
||||
|
||||
bu_debug = BU_DEBUG_COREDUMP;
|
||||
|
||||
if( argc != 3 ) {
|
||||
fprintf(stderr, "Usage: %s v4.g v5.g\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (dbip = db_open( argv[1], "r" )) == DBI_NULL ) {
|
||||
perror( argv[1] );
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( (fp = fopen( argv[2], "w" )) == NULL ) {
|
||||
perror( argv[2] );
|
||||
return 3;
|
||||
}
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
db_dirbuild( dbip );
|
||||
|
||||
db5_fwrite_ident( fp, dbip->dbi_title, dbip->dbi_local2base );
|
||||
|
||||
/* Retrieve every item in the input database */
|
||||
for( i = RT_DBNHASH-1; i >= 0; i-- ) {
|
||||
for( dp = dbip->dbi_Head[i]; dp; dp = dp->d_forw ) {
|
||||
struct rt_db_internal intern;
|
||||
int id;
|
||||
int ret;
|
||||
|
||||
fprintf(stderr, "%s\n", dp->d_namep );
|
||||
|
||||
id = rt_db_get_internal( &intern, dp, dbip, NULL );
|
||||
if( id < 0 ) {
|
||||
fprintf(stderr,
|
||||
"%s: rt_db_get_internal(%s) failure, skipping\n",
|
||||
argv[0], dp->d_namep);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
if ( id == ID_HF ) {
|
||||
if (rt_hf_to_dsp( &intern )) {
|
||||
fprintf(stderr,
|
||||
"%s: Conversion from HF to DSP failed for solid %s\n",
|
||||
argv[0], dp->d_namep );
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( id == ID_POLY)
|
||||
{
|
||||
if( rt_pg_to_bot( &intern, &tol ) )
|
||||
{
|
||||
fprintf( stderr, "%s: Conversion from polysolid to BOT failed for solid %s\n",
|
||||
argv[0], dp->d_namep );
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret = rt_fwrite_internal5( fp, dp->d_namep, &intern, 1.0, NULL );
|
||||
if( ret < 0 ) {
|
||||
fprintf(stderr,
|
||||
"%s: rt_fwrite_internal5(%s) failure, skipping\n",
|
||||
argv[0], dp->d_namep);
|
||||
rt_db_free_internal( &intern );
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
rt_db_free_internal( &intern );
|
||||
}
|
||||
}
|
||||
|
||||
fclose( fp );
|
||||
db_close( dbip );
|
||||
|
||||
fprintf(stderr, "%ld objects failed to convert\n", errors);
|
||||
return 0;
|
||||
}
|
||||
@@ -82,9 +82,6 @@ extern "C" {
|
||||
* if( fabs(VDOT(a,b)) >= tol->para ) a & b are parallel
|
||||
* if( fabs(VDOT(a,b)) <= tol->perp ) a & b are perpendicular
|
||||
*
|
||||
* Note:
|
||||
* tol->dist_sq = tol->dist * tol->dist;
|
||||
* tol->para = 1 - tol->perp;
|
||||
*/
|
||||
struct bn_tol {
|
||||
unsigned long magic;
|
||||
@@ -103,18 +100,6 @@ struct bn_tol {
|
||||
|
||||
#define BN_APPROXEQUAL(_a, _b, _tol) (fabs( (_a) - (_b) ) <= _tol->dist)
|
||||
|
||||
/* asize.c */
|
||||
BU_EXTERN(int bn_common_file_size, (int *width,
|
||||
int *height,
|
||||
char *filename,
|
||||
int pixel_size));
|
||||
BU_EXTERN(int bn_common_name_size, (int *width,
|
||||
int *height,
|
||||
char *name));
|
||||
BU_EXTERN(int bn_common_image_zie, (int *width,
|
||||
int *height,
|
||||
int num_pixels));
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* complex.c */
|
||||
/*
|
||||
|
||||
@@ -222,19 +222,6 @@ extern char *realloc();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Sizes of "network" format data.
|
||||
* We use the same convention as the TCP/IP specification,
|
||||
* namely, big-Endian, IEEE format, twos compliment.
|
||||
* This is the BRL-CAD external data representation (XDR).
|
||||
* See also the support routines in libbu/xdr.c
|
||||
*/
|
||||
#define SIZEOF_NETWORK_SHORT 2 /* htons(), bu_gshort(), bu_pshort() */
|
||||
#define SIZEOF_NETWORK_LONG 4 /* htonl(), bu_glong(), bu_plong() */
|
||||
#define SIZEOF_NETWORK_FLOAT 4 /* htonf() */
|
||||
#define SIZEOF_NETWORK_DOUBLE 8 /* htond() */
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* list.c */
|
||||
/*
|
||||
@@ -754,53 +741,6 @@ struct bu_mapped_file {
|
||||
typedef int (*bu_hook_t)BU_ARGS((genptr_t, genptr_t));
|
||||
#define BUHOOK_NULL 0
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* avs.c */
|
||||
/*
|
||||
* Attribute/value sets
|
||||
*/
|
||||
|
||||
/*
|
||||
* B U _ A T T R I B U T E _ V A L U E _ P A I R
|
||||
*
|
||||
* These strings may or may not be individually allocated,
|
||||
* it depends on usage.
|
||||
*/
|
||||
struct bu_attribute_value_pair {
|
||||
const char *name;
|
||||
const char *value;
|
||||
};
|
||||
|
||||
/*
|
||||
* B U _ A T T R I B U T E _ V A L U E _ S E T
|
||||
*
|
||||
* A variable-sized attribute-value-pair array.
|
||||
*
|
||||
* avp points to an array of [max] slots.
|
||||
* The interface routines will realloc to extend as needed.
|
||||
*
|
||||
* In general,
|
||||
* each of the names and values is a local copy made with bu_strdup(),
|
||||
* and each string needs to be freed individually.
|
||||
* However, if a name or value pointer is between
|
||||
* readonly_min and readonly_max, then it is part of a big malloc
|
||||
* block that is being freed by the caller, and should not be individually
|
||||
* freed.
|
||||
*/
|
||||
struct bu_attribute_value_set {
|
||||
long magic;
|
||||
int count; /* # valid entries in avp */
|
||||
int max; /* # allocated slots in avp */
|
||||
struct bu_attribute_value_pair *avp; /* array[max] */
|
||||
char *readonly_min;
|
||||
char *readonly_max;
|
||||
};
|
||||
#define BU_AVS_MAGIC 0x41765321 /* AvS! */
|
||||
#define BU_CK_AVS(_avp) BU_CKMAG(_avp, BU_AVS_MAGIC, "bu_attribute_value_set")
|
||||
|
||||
#define BU_AVS_FOR(_pp, _avp) \
|
||||
(_pp) = &(_avp)->avp[(_avp)->count-1]; (_pp) >= (_avp)->avp; (_pp)--
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* vls.c */
|
||||
/*
|
||||
@@ -859,7 +799,6 @@ extern int bu_debug;
|
||||
|
||||
#define BU_DEBUG_MATH 0x00000100 /* 011 Fundamental math routines (plane.c, mat.c) */
|
||||
#define BU_DEBUG_PTBL 0x00000200 /* 012 bu_ptbl_*() logging */
|
||||
#define BU_DEBUG_AVS 0x00000400 /* 013 bu_avs_*() logging */
|
||||
|
||||
#define BU_DEBUG_TABDATA 0x00010000 /* 025 LIBBN: tabdata */
|
||||
|
||||
@@ -868,7 +807,7 @@ extern int bu_debug;
|
||||
"\020\
|
||||
\025TABDATA\
|
||||
\015?\
|
||||
\013AVS\012PTBL\011MATH\010?\7?\6?\5PARALLEL\
|
||||
\012PTBL\011MATH\010?\7?\6?\5PARALLEL\
|
||||
\4?\3MEM_LOG\2MEM_CHECK\1COREDUMP"
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -952,8 +891,6 @@ struct bu_structparse {
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* B U _ E X T E R N A L
|
||||
*
|
||||
* An "opaque" handle for holding onto objects,
|
||||
* typically in some kind of external form that is not directly
|
||||
* usable without passing through an "importation" function.
|
||||
@@ -1156,23 +1093,6 @@ struct bu_observer {
|
||||
* Source file names listed alphabetically.
|
||||
*/
|
||||
|
||||
/* avs.c */
|
||||
BU_EXTERN(void bu_avs_init, (struct bu_attribute_value_set *avp,
|
||||
int len, CONST char *str));
|
||||
BU_EXTERN(struct bu_attribute_value_set *bu_avs_new, (int len, CONST char *str));
|
||||
BU_EXTERN(int bu_avs_add, (struct bu_attribute_value_set *avp,
|
||||
CONST char *attribute,
|
||||
CONST char *value));
|
||||
extern int bu_avs_add_vls(struct bu_attribute_value_set *avp,
|
||||
const char *attribute,
|
||||
const struct bu_vls *value_vls);
|
||||
extern const char * bu_avs_get( const struct bu_attribute_value_set *avp,
|
||||
const char *attribute );
|
||||
BU_EXTERN(int bu_avs_remove, (struct bu_attribute_value_set *avp,
|
||||
CONST char *attribute));
|
||||
BU_EXTERN(void bu_avs_free, (struct bu_attribute_value_set *avp));
|
||||
extern void bu_avs_print( const struct bu_attribute_value_set *avp, const char *title );
|
||||
|
||||
/* badmagic.c */
|
||||
BU_EXTERN(void bu_badmagic, (CONST long *ptr, long magic,
|
||||
CONST char *str, CONST char *file, int line));
|
||||
@@ -1249,12 +1169,6 @@ BU_EXTERN(void htond, (unsigned char *out,
|
||||
BU_EXTERN(void ntohd, (unsigned char *out,
|
||||
CONST unsigned char *in, int count));
|
||||
|
||||
/* htonf.c */
|
||||
BU_EXTERN(void htonf, (unsigned char *out,
|
||||
CONST unsigned char *in, int count));
|
||||
BU_EXTERN(void ntohf, (unsigned char *out,
|
||||
CONST unsigned char *in, int count));
|
||||
|
||||
/* ispar.c */
|
||||
BU_EXTERN(int bu_is_parallel, () );
|
||||
BU_EXTERN(void bu_kill_parallel, () );
|
||||
@@ -1367,9 +1281,6 @@ BU_EXTERN( int bu_key_eq_to_key_val, (char *in, char **next, st
|
||||
BU_EXTERN( int bu_shader_to_tcl_list, (char *in, struct bu_vls *vls) );
|
||||
BU_EXTERN( int bu_key_val_to_key_eq, (char *in) );
|
||||
BU_EXTERN( int bu_shader_to_key_eq, (char *in, struct bu_vls *vls) );
|
||||
int bu_fwrite_external( FILE *fp, const struct bu_external *ep );
|
||||
void bu_hexdump_external( FILE *fp, CONST struct bu_external *ep, CONST char *str);
|
||||
void bu_free_external(struct bu_external *ep);
|
||||
|
||||
/* printb.c */
|
||||
BU_EXTERN(void bu_vls_printb, (struct bu_vls *vls,
|
||||
|
||||
@@ -59,8 +59,6 @@
|
||||
* HAVE_SBRK Set if unistd.h declares sbrk().
|
||||
* HAVE_UNIX_DOMAIN_SOCKETS
|
||||
*
|
||||
* HAVE_DLOPEN Dynamic library loading support.
|
||||
*
|
||||
* $Header$
|
||||
*/
|
||||
|
||||
@@ -238,7 +236,6 @@
|
||||
# define HAVE_XOSDEFS_H 1
|
||||
# define HAVE_SYS_ERRLIST_DECL 1
|
||||
# define HAVE_POSIX_REGEXEC 1
|
||||
# define HAVE_DLOPEN 1
|
||||
# define TK_READ_DATA_PENDING(f) ((f)->_IO_read_ptr != (f)->_IO_read_end)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,11 +28,10 @@
|
||||
struct db5_ondisk_header {
|
||||
unsigned char db5h_magic1; /* [0] */
|
||||
unsigned char db5h_hflags; /* [1] */
|
||||
unsigned char db5h_aflags; /* [2] */
|
||||
unsigned char db5h_bflags; /* [3] */
|
||||
unsigned char db5h_major_type; /* [4] */
|
||||
unsigned char db5h_minor_type; /* [5] */
|
||||
/* Next is a mandatory variable-size length field starting at [6] */
|
||||
unsigned char db5h_iflags; /* [2] */
|
||||
unsigned char db5h_major_type; /* [3] */
|
||||
unsigned char db5h_minor_type; /* [4] */
|
||||
/* Next is a mandatory variable-size length field starting at [5] */
|
||||
/* Next are optional object name length & data fields */
|
||||
};
|
||||
|
||||
@@ -47,25 +46,28 @@ struct db5_ondisk_header {
|
||||
#define DB5HDR_HFLAGS_NAME_PRESENT 0x20
|
||||
#define DB5HDR_HFLAGS_OBJECT_WIDTH_MASK 0xc0
|
||||
#define DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT 6
|
||||
#define DB5HDR_HFLAGS_NAME_WIDTH_MASK 0x18
|
||||
#define DB5HDR_HFLAGS_NAME_WIDTH_SHIFT 3
|
||||
|
||||
#define DB5HDR_WIDTHCODE_8BIT 0
|
||||
#define DB5HDR_WIDTHCODE_16BIT 1
|
||||
#define DB5HDR_WIDTHCODE_32BIT 2
|
||||
#define DB5HDR_WIDTHCODE_64BIT 3
|
||||
|
||||
/* aflags */
|
||||
#define DB5HDR_AFLAGS_ZZZ_MASK 0x07
|
||||
#define DB5HDR_AFLAGS_PRESENT 0x20
|
||||
#define DB5HDR_AFLAGS_WIDTH_MASK 0xc0
|
||||
#define DB5HDR_AFLAGS_WIDTH_SHIFT 6
|
||||
/* iflags */
|
||||
#define DB5HDR_IFLAGS_ZZZ_MASK 0x07
|
||||
#define DB5HDR_IFLAGS_ZZZ_UNCOMPRESSED 0
|
||||
#define DB5HDR_IFLAGS_ZZZ_GNU_GZIP 1
|
||||
#define DB5HDR_IFLAGS_ZZZ_BURROUGHS_WHEELER 2
|
||||
#define DB5HDR_IFLAGS_ATTRIBUTES_PRESENT 0x20
|
||||
#define DB5HDR_IFLAGS_BODY_PRESENT 0x10
|
||||
#define DB5HDR_IFLAGS_INTERIOR_WIDTH_MASK 0xc0
|
||||
#define DB5HDR_IFLAGS_INTERIOR_WIDTH_SHIFT 6
|
||||
|
||||
/* bflags */
|
||||
#define DB5HDR_BFLAGS_ZZZ_MASK 0x07
|
||||
#define DB5HDR_BFLAGS_PRESENT 0x20
|
||||
#define DB5HDR_BFLAGS_WIDTH_MASK 0xc0
|
||||
#define DB5HDR_BFLAGS_WIDTH_SHIFT 6
|
||||
/* major_type */
|
||||
#define DB5HDR_MAJORTYPE_RESERVED 0
|
||||
#define DB5HDR_MAJORTYPE_BRLCAD_NONGEOM 1
|
||||
#define DB5HDR_MAJORTYPE_BRLCAD_GEOMETRY 2
|
||||
#define DB5HDR_MAJORTYPE_OPAQUE_BINARY 3
|
||||
#define DB5HDR_MAJORTYPE_ATTRIBUTE_ONLY 4
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
@@ -75,74 +77,6 @@ struct db5_ondisk_header {
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
/* Name of global attribute-only object for storing database title & units */
|
||||
#define DB5_GLOBAL_OBJECT_NAME "_GLOBAL"
|
||||
|
||||
/* Kinds of compression */
|
||||
#define DB5_ZZZ_UNCOMPRESSED 0
|
||||
#define DB5_ZZZ_GNU_GZIP 1
|
||||
#define DB5_ZZZ_BURROUGHS_WHEELER 2
|
||||
|
||||
|
||||
/* major_type */
|
||||
#define DB5_MAJORTYPE_RESERVED 0
|
||||
#define DB5_MAJORTYPE_BRLCAD 1
|
||||
#define DB5_MAJORTYPE_ATTRIBUTE_ONLY 2
|
||||
#define DB5_MAJORTYPE_BINARY_MASK 0x18
|
||||
#define DB5_MAJORTYPE_BINARY_EXPM 8
|
||||
#define DB5_MAJORTYPE_BINARY_UNIF 9
|
||||
#define DB5_MAJORTYPE_BINARY_MIME 10
|
||||
|
||||
/*
|
||||
* Minor types
|
||||
*/
|
||||
/* BRL-CAD */
|
||||
#define DB5_MINORTYPE_BRLCAD_TOR 1
|
||||
#define DB5_MINORTYPE_BRLCAD_TGC 2
|
||||
#define DB5_MINORTYPE_BRLCAD_ELL 3
|
||||
#define DB5_MINORTYPE_BRLCAD_ARB8 4
|
||||
#define DB5_MINORTYPE_BRLCAD_ARS 5
|
||||
#define DB5_MINORTYPE_BRLCAD_HALF 6
|
||||
#define DB5_MINORTYPE_BRLCAD_REC 7
|
||||
#define DB5_MINORTYPE_BRLCAD_POLY 8
|
||||
#define DB5_MINORTYPE_BRLCAD_BSPLINE 9
|
||||
#define DB5_MINORTYPE_BRLCAD_SPH 10
|
||||
#define DB5_MINORTYPE_BRLCAD_NMG 11
|
||||
#define DB5_MINORTYPE_BRLCAD_EBM 12
|
||||
#define DB5_MINORTYPE_BRLCAD_VOL 13
|
||||
#define DB5_MINORTYPE_BRLCAD_ARBN 14
|
||||
#define DB5_MINORTYPE_BRLCAD_PIPE 15
|
||||
#define DB5_MINORTYPE_BRLCAD_PARTICLE 16
|
||||
#define DB5_MINORTYPE_BRLCAD_RPC 17
|
||||
#define DB5_MINORTYPE_BRLCAD_RHC 18
|
||||
#define DB5_MINORTYPE_BRLCAD_EPA 19
|
||||
#define DB5_MINORTYPE_BRLCAD_EHY 20
|
||||
#define DB5_MINORTYPE_BRLCAD_ETO 21
|
||||
#define DB5_MINORTYPE_BRLCAD_GRIP 22
|
||||
#define DB5_MINORTYPE_BRLCAD_JOINT 23
|
||||
#define DB5_MINORTYPE_BRLCAD_HF 24
|
||||
#define DB5_MINORTYPE_BRLCAD_DSP 25
|
||||
#define DB5_MINORTYPE_BRLCAD_SKETCH 26
|
||||
#define DB5_MINORTYPE_BRLCAD_EXTRUDE 27
|
||||
#define DB5_MINORTYPE_BRLCAD_SUBMODEL 28
|
||||
#define DB5_MINORTYPE_BRLCAD_CLINE 29
|
||||
#define DB5_MINORTYPE_BRLCAD_BOT 30
|
||||
#define DB5_MINORTYPE_BRLCAD_COMBINATION 31
|
||||
/* Uniform-array binary */
|
||||
#define DB5_MINORTYPE_BINU_WID_MASK 0x30
|
||||
#define DB5_MINORTYPE_BINU_SGN_MASK 0x08
|
||||
#define DB5_MINORTYPE_BINU_ATM_MASK 0x07
|
||||
#define DB5_MINORTYPE_BINU_FLOAT 0x02
|
||||
#define DB5_MINORTYPE_BINU_DOUBLE 0x03
|
||||
#define DB5_MINORTYPE_BINU_8BITINT_U 0x04
|
||||
#define DB5_MINORTYPE_BINU_16BITINT_U 0x05
|
||||
#define DB5_MINORTYPE_BINU_32BITINT_U 0x06
|
||||
#define DB5_MINORTYPE_BINU_64BITINT_U 0x07
|
||||
#define DB5_MINORTYPE_BINU_8BITINT 0x0c
|
||||
#define DB5_MINORTYPE_BINU_16BITINT 0x0d
|
||||
#define DB5_MINORTYPE_BINU_32BITINT 0x0e
|
||||
#define DB5_MINORTYPE_BINU_64BITINT 0x0f
|
||||
|
||||
/*
|
||||
* The "raw internal" form of one database object.
|
||||
* This is what the low-level database routines will operate on.
|
||||
@@ -151,35 +85,26 @@ struct db5_ondisk_header {
|
||||
struct db5_raw_internal {
|
||||
long magic;
|
||||
unsigned char h_object_width; /* DB5HDR_WIDTHCODE_x */
|
||||
unsigned char h_name_present;
|
||||
unsigned char h_name_width; /* DB5HDR_WIDTHCODE_x */
|
||||
unsigned char h_dli;
|
||||
unsigned char a_width; /* DB5HDR_WIDTHCODE_x */
|
||||
unsigned char a_present;
|
||||
unsigned char a_zzz;
|
||||
unsigned char b_width; /* DB5HDR_WIDTHCODE_x */
|
||||
unsigned char b_present;
|
||||
unsigned char b_zzz;
|
||||
unsigned char h_name_present;
|
||||
unsigned char i_object_width; /* DB5HDR_WIDTHCODE_x */
|
||||
unsigned char i_attributes_present;
|
||||
unsigned char i_body_present;
|
||||
unsigned char i_zzz;
|
||||
unsigned char major_type;
|
||||
unsigned char minor_type;
|
||||
long object_length; /* in bytes, on disk */
|
||||
/* These three MUST NOT be passed to bu_free_external()! */
|
||||
struct bu_external name;
|
||||
struct bu_external body;
|
||||
struct bu_external attributes;
|
||||
long name_length;
|
||||
char *name;
|
||||
long interior_length;
|
||||
unsigned char *interior;
|
||||
unsigned char *buf; /* if non-null needs to be bu_free()ed */
|
||||
};
|
||||
#define DB5_RAW_INTERNAL_MAGIC 0x64357269 /* "d5ri" */
|
||||
|
||||
extern const int db5_enc_len[4]; /* convert wid to nbytes */
|
||||
|
||||
extern unsigned char *db5_encode_length(
|
||||
unsigned char *cp,
|
||||
long val,
|
||||
int format);
|
||||
const unsigned char *db5_get_raw_internal_ptr(
|
||||
struct db5_raw_internal *rip,
|
||||
const unsigned char *ip);
|
||||
|
||||
struct attribute_value_pair {
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
#endif /* DB5_H */
|
||||
|
||||
+11
-96
@@ -214,12 +214,10 @@ struct rt_db_internal {
|
||||
int idb_type; /* ID_xxx */
|
||||
CONST struct rt_functab *idb_meth; /* for ft_ifree(), etc. */
|
||||
genptr_t idb_ptr;
|
||||
struct bu_attribute_value_set idb_avs;
|
||||
};
|
||||
#define RT_DB_INTERNAL_MAGIC 0x0dbbd867
|
||||
#define RT_INIT_DB_INTERNAL(_p) {(_p)->idb_magic = RT_DB_INTERNAL_MAGIC; \
|
||||
(_p)->idb_type = -1; (_p)->idb_ptr = GENPTR_NULL;\
|
||||
(_p)->idb_avs.magic = -1;}
|
||||
(_p)->idb_type = -1; (_p)->idb_ptr = GENPTR_NULL;}
|
||||
#define RT_CK_DB_INTERNAL(_p) BU_CKMAG(_p, RT_DB_INTERNAL_MAGIC, "rt_db_internal")
|
||||
|
||||
/*
|
||||
@@ -517,16 +515,9 @@ struct soltab {
|
||||
#define ID_SUBMODEL 28 /* Instanced submodel */
|
||||
#define ID_CLINE 29 /* FASTGEN4 CLINE solid */
|
||||
#define ID_BOT 30 /* Bag o' triangles */
|
||||
#define ID_MAX_SOLID 30 /* Maximum defined ID_xxx for solids */
|
||||
#define ID_MAXIMUM 30 /* Maximum defined ID_xxx value */
|
||||
|
||||
/*
|
||||
* Non-geometric objects
|
||||
*/
|
||||
#define ID_COMBINATION 31 /* Combination Record */
|
||||
#define ID_BINEXPM 32 /* Experimental binary */
|
||||
#define ID_BINUNIF 33 /* Uniform-array binary */
|
||||
#define ID_BINMIME 34 /* MIME-typed binary */
|
||||
#define ID_MAXIMUM 35 /* Maximum defined ID_xxx value */
|
||||
#define ID_COMBINATION (ID_MAXIMUM+1) /* Combination Record (non-geometric) */
|
||||
|
||||
/*
|
||||
* M A T E R _ I N F O
|
||||
@@ -842,35 +833,6 @@ struct rt_comb_internal {
|
||||
#define RT_CHECK_COMB_TCL(_interp,_p) BU_CKMAG_TCL(interp,_p,RT_COMB_MAGIC, "rt_comb_internal" )
|
||||
#define RT_CK_COMB_TCL(_interp,_p) RT_CHECK_COMB_TCL(_interp,_p)
|
||||
|
||||
/*
|
||||
* R T _ B I N U N I F _ I N T E R N A L
|
||||
*
|
||||
* In-memory format for database uniform-array binary object.
|
||||
* Perhaps move to h/wdb.h or h/rtgeom.h?
|
||||
*/
|
||||
struct rt_binunif_internal {
|
||||
long magic;
|
||||
char type;
|
||||
long count;
|
||||
union {
|
||||
float *flt;
|
||||
double *dbl;
|
||||
char *int8;
|
||||
short *int16;
|
||||
int *int32;
|
||||
long *int64;
|
||||
unsigned char *uint8;
|
||||
unsigned short *uint16;
|
||||
unsigned int *uint32;
|
||||
unsigned long *uint64;
|
||||
} u;
|
||||
};
|
||||
#define RT_BINUNIF_INTERNAL_MAGIC 0x42696e55 /* "BinU" */
|
||||
#define RT_CHECK_BINUNIF(_p) BU_CKMAG( _p , RT_BINUNIF_INTERNAL_MAGIC , "rt_binunif_internal" )
|
||||
#define RT_CK_BINUNIF(_p) RT_CHECK_BINUNIF(_p)
|
||||
#define RT_CHECK_BINUNIF_TCL(_interp,_p) BU_CKMAG_TCL(interp,_p,RT_BINUNIF_MAGIC, "rt_binunif_internal" )
|
||||
#define RT_CK_BINUNIF_TCL(_interp,_p) RT_CHECK_BINUNIF_TCL(_interp,_p)
|
||||
|
||||
/*
|
||||
* D B _ T R E E _ S T A T E
|
||||
*
|
||||
@@ -906,7 +868,8 @@ struct db_tree_state {
|
||||
union tree * (*ts_leaf_func) BU_ARGS((
|
||||
struct db_tree_state * /*tsp*/,
|
||||
struct db_full_path * /*pathp*/,
|
||||
struct rt_db_internal * /*ip*/,
|
||||
struct bu_external * /*ep*/,
|
||||
int /*id*/,
|
||||
genptr_t client_data
|
||||
));
|
||||
CONST struct rt_tess_tol *ts_ttol; /* Tessellation tolerance */
|
||||
@@ -1553,8 +1516,8 @@ struct rt_i {
|
||||
int rti_ncut_by_type[CUT_MAXIMUM+1]; /* number of cuts by type */
|
||||
int rti_cut_totobj; /* # objs in all bins, total */
|
||||
int rti_cut_maxdepth;/* max depth of cut tree */
|
||||
struct soltab **rti_sol_by_type[ID_MAX_SOLID+1];
|
||||
int rti_nsol_by_type[ID_MAX_SOLID+1];
|
||||
struct soltab **rti_sol_by_type[ID_MAXIMUM+1];
|
||||
int rti_nsol_by_type[ID_MAXIMUM+1];
|
||||
int rti_maxsol_by_type;
|
||||
int rti_air_discards;/* # of air regions discarded */
|
||||
struct bu_hist rti_hist_cellsize; /* occupancy of cut cells */
|
||||
@@ -1793,14 +1756,6 @@ struct rt_functab {
|
||||
struct rt_db_internal * /*ip*/,
|
||||
CONST struct bn_tol * /*tol*/));
|
||||
#endif
|
||||
int (*ft_import5) BU_ARGS((struct rt_db_internal * /*ip*/,
|
||||
CONST struct bu_external * /*ep*/,
|
||||
CONST mat_t /*mat*/,
|
||||
CONST struct db_i * /*dbip*/));
|
||||
int (*ft_export5) BU_ARGS((struct bu_external * /*ep*/,
|
||||
CONST struct rt_db_internal * /*ip*/,
|
||||
double /*local2mm*/,
|
||||
CONST struct db_i * /*dbip*/));
|
||||
int (*ft_import) BU_ARGS((struct rt_db_internal * /*ip*/,
|
||||
CONST struct bu_external * /*ep*/,
|
||||
CONST mat_t /*mat*/,
|
||||
@@ -2442,7 +2397,8 @@ BU_EXTERN(int db_walk_tree, (struct db_i *dbip, int argc, CONST char **argv,
|
||||
union tree * (*leaf_func) (
|
||||
struct db_tree_state * /*tsp*/,
|
||||
struct db_full_path * /*pathp*/,
|
||||
struct rt_db_internal * /*ip*/,
|
||||
struct bu_external * /*ep*/,
|
||||
int /*id*/,
|
||||
genptr_t client_data ),
|
||||
genptr_t client_data ));
|
||||
BU_EXTERN(int db_path_to_mat, (struct db_i *dbip, struct db_full_path *pathp,
|
||||
@@ -2452,16 +2408,11 @@ BU_EXTERN(void db_apply_anims, (struct db_full_path *pathp,
|
||||
struct mater_info *materp));
|
||||
|
||||
/* dir.c */
|
||||
extern struct rt_i *rt_dirbuild( const char *filename, char *buf, int len );
|
||||
BU_EXTERN(int rt_db_get_internal, (struct rt_db_internal *ip,
|
||||
CONST struct directory *dp,
|
||||
CONST struct db_i *dbip, CONST mat_t mat));
|
||||
BU_EXTERN(int rt_db_put_internal, (struct directory *dp, struct db_i *dbip,
|
||||
struct rt_db_internal *ip));
|
||||
extern int rt_fwrite_internal( FILE *fp, const char *name, const struct rt_db_internal *ip, double conv2mm );
|
||||
extern void rt_db_free_internal( struct rt_db_internal *ip );
|
||||
extern int rt_db_lookup_internal( struct db_i *dbip, const char *obj_name,
|
||||
struct directory **dpp, struct rt_db_internal *ip, int noisy );
|
||||
|
||||
/* db_comb.c */
|
||||
|
||||
@@ -2481,7 +2432,6 @@ BU_EXTERN(struct rt_pt_node *rt_ptalloc, () );
|
||||
|
||||
/* memalloc.c -- non PARALLEL routines */
|
||||
BU_EXTERN(unsigned long rt_memalloc, (struct mem_map **pp, unsigned size) );
|
||||
BU_EXTERN(struct mem_map * rt_memalloc_nosplit, (struct mem_map **pp, unsigned size) );
|
||||
BU_EXTERN(unsigned long rt_memget, (struct mem_map **pp, unsigned int size,
|
||||
unsigned int place) );
|
||||
BU_EXTERN(void rt_memfree, (struct mem_map **pp, unsigned size, unsigned long addr) );
|
||||
@@ -3306,10 +3256,10 @@ BU_EXTERN(int nmg_two_region_vertex_fuse, (struct nmgregion *r1,
|
||||
struct nmgregion *r2, CONST struct bn_tol *tol));
|
||||
BU_EXTERN(union tree *nmg_booltree_leaf_tess, (struct db_tree_state *tsp,
|
||||
struct db_full_path *pathp,
|
||||
struct rt_db_internal *ip, genptr_t client_data));
|
||||
struct bu_external *ep, int id, genptr_t client_data));
|
||||
BU_EXTERN(union tree *nmg_booltree_leaf_tnurb, (struct db_tree_state *tsp,
|
||||
struct db_full_path *pathp,
|
||||
struct rt_db_internal *ip, genptr_t client_data));
|
||||
struct bu_external *ep, int id, genptr_t client_data));
|
||||
BU_EXTERN(union tree *nmg_booltree_evaluate, (union tree *tp,
|
||||
CONST struct bn_tol *tol));
|
||||
BU_EXTERN(void nmg_region_v_unique, (struct nmgregion *r1,
|
||||
@@ -3913,41 +3863,6 @@ BU_EXTERN(void nmg_visit,
|
||||
CONST struct nmg_visit_handlers *htab,
|
||||
genptr_t *state));
|
||||
|
||||
/* db5_types.c */
|
||||
BU_EXTERN(int db5_type_tag_from_major,
|
||||
(char **tag,
|
||||
CONST unsigned char major));
|
||||
|
||||
BU_EXTERN(int db5_type_descrip_from_major,
|
||||
(char **descrip,
|
||||
CONST unsigned char major));
|
||||
|
||||
BU_EXTERN(int db5_type_tag_from_codes,
|
||||
(char **tag,
|
||||
CONST unsigned char major,
|
||||
CONST unsigned char minor));
|
||||
|
||||
BU_EXTERN(int db5_type_descrip_from_codes,
|
||||
(char **descrip,
|
||||
CONST unsigned char major,
|
||||
CONST unsigned char minor));
|
||||
|
||||
BU_EXTERN(int db5_type_codes_from_tag,
|
||||
(unsigned char *major,
|
||||
unsigned char *minor,
|
||||
CONST char *tag));
|
||||
|
||||
BU_EXTERN(int db5_type_codes_from_descrip,
|
||||
(unsigned char *major,
|
||||
unsigned char *minor,
|
||||
CONST char *descrip));
|
||||
|
||||
BU_EXTERN(size_t db5_type_sizeof_h_binu,
|
||||
(CONST unsigned char minor));
|
||||
|
||||
BU_EXTERN(size_t db5_type_sizeof_n_binu,
|
||||
(CONST unsigned char minor));
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
+8
-5
@@ -359,10 +359,13 @@ struct rt_eto_internal {
|
||||
#define DSP_NAME_LEN 128
|
||||
struct rt_dsp_internal{
|
||||
long magic;
|
||||
struct bu_vls dsp_file; /* name of data file */
|
||||
unsigned int dsp_xcnt; /* # samples in row of data */
|
||||
unsigned int dsp_ycnt; /* # of columns in data */
|
||||
unsigned short dsp_smooth; /* bool: surf normal interp */
|
||||
char dsp_file[DSP_NAME_LEN]; /* name of data file */
|
||||
unsigned dsp_xcnt; /* # samples in row of data */
|
||||
unsigned dsp_ycnt; /* # of columns in data */
|
||||
int dsp_smooth; /* bool: surf normal interp */
|
||||
double dsp_xs;
|
||||
double dsp_ys;
|
||||
double dsp_zs;
|
||||
mat_t dsp_mtos; /* model to solid space */
|
||||
/* END OF USER SETABLE VARIABLES, BEGIN INTERNAL STUFF */
|
||||
mat_t dsp_stom; /* solid to model space */
|
||||
@@ -424,7 +427,7 @@ struct rt_extrude_internal
|
||||
vect_t u_vec; /* vector in U parameter direction */
|
||||
vect_t v_vec; /* vector in V parameter direction */
|
||||
int keypoint; /* index of keypoint vertex */
|
||||
char *sketch_name; /* name of sketch object that defines
|
||||
char sketch_name[SKETCH_NAME_LEN]; /* name of sketch object that defines
|
||||
* the curve to be extruded */
|
||||
struct rt_sketch_internal *skt; /* pointer to referenced sketch */
|
||||
};
|
||||
|
||||
@@ -3137,7 +3137,6 @@ will also be changed. The <a href="#mvall">mvall</a> command performs a similar
|
||||
<DT><a NAME="press"><B>press</B> <I>button_label</I></DT>
|
||||
|
||||
<DD>The ``press'' command simulates the pressing of a button.
|
||||
All of these button actions can be be run directly as a command.
|
||||
The <I>button_label</I> indicates which button to simulate.
|
||||
The available buttons are:
|
||||
|
||||
@@ -3184,6 +3183,7 @@ The available buttons are:
|
||||
the viewing cube (the eye rotates about the center if the viewing cube). In
|
||||
``rotate about eye'' mode the view rotations are done about the eye point
|
||||
(the eye rotates in position as in panning a camera)</li>
|
||||
<li>slice -- ??????????????????????</li>
|
||||
</ul>
|
||||
|
||||
<DL>
|
||||
@@ -4442,10 +4442,10 @@ The parameters are (in order):
|
||||
|
||||
<DT><a NAME="translate"><B>translate</B> <I>x y z</I></DT>
|
||||
|
||||
<DD>The ``translate'' command is used to precisely control
|
||||
the translation of an object in both solid edit and object edit modes.
|
||||
The keypoint of the edited object or solid is translated to the specified
|
||||
coordinates.
|
||||
<DD>The ``translate'' command is used in object edit mode to precisely control
|
||||
the translation of an object. The edited object is translated to the specified
|
||||
coordinates. The <a href="#p">p</a> command provides a similar capability for
|
||||
solid editing.
|
||||
|
||||
|
||||
<DL>
|
||||
|
||||
+56
-180
@@ -20,7 +20,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,34 +66,10 @@ char *str;
|
||||
&m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]);
|
||||
}
|
||||
|
||||
/*
|
||||
* B N _ D E C O D E _ T O L
|
||||
*
|
||||
* If the user specifies {}, or only the distance tolerance,
|
||||
* provide the same defaults that LIBRT uses.
|
||||
*/
|
||||
int
|
||||
bn_decode_tol(tol, str)
|
||||
struct bn_tol *tol;
|
||||
const char *str;
|
||||
{
|
||||
tol->magic = BN_TOL_MAGIC;
|
||||
|
||||
/* provide meaningful defaults */
|
||||
tol->dist = 0.005;
|
||||
tol->perp = 1e-6;
|
||||
|
||||
if( *str == '{' ) str++;
|
||||
(void)sscanf(str, "%lf %lf", &tol->dist, &tol->perp);
|
||||
tol->dist_sq = tol->dist * tol->dist;
|
||||
tol->para = 1 - tol->perp;
|
||||
|
||||
return 2; /* You always get something good */
|
||||
}
|
||||
int
|
||||
bn_decode_quat(q, str)
|
||||
quat_t q;
|
||||
const char *str;
|
||||
char *str;
|
||||
{
|
||||
if( *str == '{' ) str++;
|
||||
return sscanf(str, "%lf %lf %lf %lf", &q[0], &q[1], &q[2], &q[3]);
|
||||
@@ -102,7 +78,7 @@ const char *str;
|
||||
int
|
||||
bn_decode_vect(v, str)
|
||||
vect_t v;
|
||||
const char *str;
|
||||
char *str;
|
||||
{
|
||||
if( *str == '{' ) str++;
|
||||
return sscanf(str, "%lf %lf %lf", &v[0], &v[1], &v[2]);
|
||||
@@ -111,37 +87,23 @@ const char *str;
|
||||
int
|
||||
bn_decode_hvect(v, str)
|
||||
hvect_t v;
|
||||
const char *str;
|
||||
char *str;
|
||||
{
|
||||
if( *str == '{' ) str++;
|
||||
return sscanf(str, "%lf %lf %lf %lf", &v[0], &v[1], &v[2], &v[3]);
|
||||
}
|
||||
|
||||
int
|
||||
bn_decode_plane(v, str)
|
||||
plane_t v;
|
||||
const char *str;
|
||||
{
|
||||
if( *str == '{' ) str++;
|
||||
return sscanf(str, "%lf %lf %lf %lf", &v[0], &v[1], &v[2], &v[3]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Encoding routines.
|
||||
* All these tuples should be wrapped in {}s.
|
||||
*/
|
||||
|
||||
void
|
||||
bn_encode_mat(vp, m)
|
||||
struct bu_vls *vp;
|
||||
const mat_t m;
|
||||
mat_t m;
|
||||
{
|
||||
if( m == NULL ) {
|
||||
bu_vls_putc(vp, 'I');
|
||||
return;
|
||||
}
|
||||
|
||||
bu_vls_printf(vp, "{%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g} ",
|
||||
bu_vls_printf(vp, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g",
|
||||
m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7],
|
||||
m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]);
|
||||
}
|
||||
@@ -149,36 +111,31 @@ const mat_t m;
|
||||
void
|
||||
bn_encode_quat(vp, q)
|
||||
struct bu_vls *vp;
|
||||
const quat_t q;
|
||||
quat_t q;
|
||||
{
|
||||
bu_vls_printf(vp, "{%g %g %g %g} ", V4ARGS(q));
|
||||
bu_vls_printf(vp, "%g %g %g %g", V4ARGS(q));
|
||||
}
|
||||
|
||||
void
|
||||
bn_encode_vect(vp, v)
|
||||
struct bu_vls *vp;
|
||||
const vect_t v;
|
||||
vect_t v;
|
||||
{
|
||||
bu_vls_printf(vp, "{%g %g %g} ", V3ARGS(v));
|
||||
bu_vls_printf(vp, "%g %g %g", V3ARGS(v));
|
||||
}
|
||||
|
||||
void
|
||||
bn_encode_hvect(vp, v)
|
||||
struct bu_vls *vp;
|
||||
const hvect_t v;
|
||||
hvect_t v;
|
||||
{
|
||||
bu_vls_printf(vp, "{%g %g %g %g} ", V4ARGS(v));
|
||||
bu_vls_printf(vp, "%g %g %g %g", V4ARGS(v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrappers for macros and multiple-return-value functions
|
||||
*/
|
||||
|
||||
void
|
||||
bn_quat_distance_wrapper(dp, q1, q2)
|
||||
double *dp;
|
||||
const quat_t q1;
|
||||
const quat_t q2;
|
||||
quat_t q1, q2;
|
||||
{
|
||||
*dp = quat_distance(q1, q2);
|
||||
}
|
||||
@@ -228,16 +185,16 @@ CONST vect_t dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* B N _ M A T H _ C M D _ V O I D
|
||||
* B N _ M A T H _ C M D
|
||||
*
|
||||
* Tcl wrappers for the math functions of type void.
|
||||
* Tcl wrappers for the math functions.
|
||||
*
|
||||
* This is where you should put clauses, in the below "if" statement, to add
|
||||
* Tcl support for the LIBBN math routines.
|
||||
*/
|
||||
|
||||
int
|
||||
bn_math_cmd_void(clientData, interp, argc, argv)
|
||||
bn_math_cmd(clientData, interp, argc, argv)
|
||||
ClientData clientData;
|
||||
Tcl_Interp *interp;
|
||||
int argc;
|
||||
@@ -581,120 +538,46 @@ error:
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
static struct math_func_link_void {
|
||||
static struct math_func_link {
|
||||
char *name;
|
||||
void (*func)();
|
||||
} math_funcs_void[] = {
|
||||
{"mat_mul", bn_mat_mul},
|
||||
{"mat_inv", bn_mat_inv},
|
||||
{"mat_trn", bn_mat_trn},
|
||||
{"matXvec", bn_matXvec},
|
||||
{"mat4x3vec", bn_mat4x3vec},
|
||||
{"mat4x3pnt", bn_mat4x3pnt},
|
||||
{"hdivide", bn_hdivide},
|
||||
{"vjoin1", bn_vjoin1},
|
||||
{"mat_ae", bn_mat_ae},
|
||||
{"mat_ae_vec", bn_ae_vec}, /* wrong name! */
|
||||
{"bn_ae_vec", bn_ae_vec},
|
||||
{"mat_aet_vec", bn_aet_vec},
|
||||
{"bn_aet_vec", bn_aet_vec}, /* wrong name! */
|
||||
{"mat_angles", bn_mat_angles},
|
||||
{"mat_eigen2x2", bn_eigen2x2},
|
||||
{"mat_fromto", bn_mat_fromto},
|
||||
{"mat_xrot", bn_mat_xrot},
|
||||
{"mat_yrot", bn_mat_yrot},
|
||||
{"mat_zrot", bn_mat_zrot},
|
||||
{"mat_lookat", bn_mat_lookat},
|
||||
{"mat_vec_ortho", bn_vec_ortho}, /* wrong name! */
|
||||
{"bn_vec_ortho", bn_vec_ortho},
|
||||
{"mat_vec_perp", bn_vec_perp}, /* wrong name! */
|
||||
{"bn_vec_perp", bn_vec_perp},
|
||||
{"mat_scale_about_pt", bn_mat_scale_about_pt_wrapper},
|
||||
{"mat_xform_about_pt", bn_mat_xform_about_pt},
|
||||
{"mat_arb_rot", bn_mat_arb_rot},
|
||||
{"quat_mat2quat", quat_mat2quat},
|
||||
{"quat_quat2mat", quat_quat2mat},
|
||||
{"quat_distance", bn_quat_distance_wrapper},
|
||||
{"quat_double", quat_double},
|
||||
{"quat_bisect", quat_bisect},
|
||||
{"quat_slerp", quat_slerp},
|
||||
{"quat_sberp", quat_sberp},
|
||||
{"quat_make_nearest", quat_make_nearest},
|
||||
{"quat_exp", quat_exp},
|
||||
{"quat_log", quat_log},
|
||||
{0, 0}
|
||||
} math_funcs[] = {
|
||||
"mat_mul", bn_mat_mul,
|
||||
"mat_inv", bn_mat_inv,
|
||||
"mat_trn", bn_mat_trn,
|
||||
"matXvec", bn_matXvec,
|
||||
"mat4x3vec", bn_mat4x3vec,
|
||||
"mat4x3pnt", bn_mat4x3pnt,
|
||||
"hdivide", bn_hdivide,
|
||||
"vjoin1", bn_vjoin1,
|
||||
"mat_ae", bn_mat_ae,
|
||||
"mat_ae_vec", bn_ae_vec,
|
||||
"mat_aet_vec", bn_aet_vec,
|
||||
"mat_angles", bn_mat_angles,
|
||||
"mat_eigen2x2", bn_eigen2x2,
|
||||
"mat_fromto", bn_mat_fromto,
|
||||
"mat_xrot", bn_mat_xrot,
|
||||
"mat_yrot", bn_mat_yrot,
|
||||
"mat_zrot", bn_mat_zrot,
|
||||
"mat_lookat", bn_mat_lookat,
|
||||
"mat_vec_ortho", bn_vec_ortho,
|
||||
"mat_vec_perp", bn_vec_perp,
|
||||
"mat_scale_about_pt", bn_mat_scale_about_pt_wrapper,
|
||||
"mat_xform_about_pt", bn_mat_xform_about_pt,
|
||||
"mat_arb_rot", bn_mat_arb_rot,
|
||||
"quat_mat2quat", quat_mat2quat,
|
||||
"quat_quat2mat", quat_quat2mat,
|
||||
"quat_distance", bn_quat_distance_wrapper,
|
||||
"quat_double", quat_double,
|
||||
"quat_bisect", quat_bisect,
|
||||
"quat_slerp", quat_slerp,
|
||||
"quat_sberp", quat_sberp,
|
||||
"quat_make_nearest", quat_make_nearest,
|
||||
"quat_exp", quat_exp,
|
||||
"quat_log", quat_log,
|
||||
0, 0
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* B N _ M A T H _ C M D _ I N T
|
||||
*
|
||||
* Tcl wrappers for the math functions of type int.
|
||||
*
|
||||
* This is where you should put clauses, in the below "if" statement, to add
|
||||
* Tcl support for the LIBBN math routines.
|
||||
*/
|
||||
|
||||
int
|
||||
bn_math_cmd_int(clientData, interp, argc, argv)
|
||||
ClientData clientData;
|
||||
Tcl_Interp *interp;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int (*math_func)();
|
||||
struct bu_vls result;
|
||||
|
||||
math_func = (int (*)())clientData; /* object-to-function cast */
|
||||
bu_vls_init(&result);
|
||||
|
||||
if (math_func == bn_isect_2planes ) {
|
||||
plane_t a, b;
|
||||
point_t rpp_min;
|
||||
struct bn_tol tol;
|
||||
point_t out_pt;
|
||||
vect_t out_dir;
|
||||
int ret;
|
||||
|
||||
if( argc != 5 ||
|
||||
bn_decode_plane(a, argv[1]) < 4 ||
|
||||
bn_decode_plane(b, argv[2]) < 4 ||
|
||||
bn_decode_vect(rpp_min, argv[3]) < 3 ||
|
||||
bn_decode_tol(&tol, argv[4]) < 2
|
||||
) {
|
||||
bu_vls_printf(&result, "usage: %s plane_a plane_b rpp_min tol\n", argv[0]);
|
||||
goto error;
|
||||
}
|
||||
if( (ret = bn_isect_2planes( out_pt, out_dir, a, b, rpp_min, &tol )) < 0 ) {
|
||||
bu_vls_printf(&result, "bn_isect_2planes() failed, ret=%d\n", ret);
|
||||
goto error;
|
||||
}
|
||||
bn_encode_vect( &result, out_pt );
|
||||
bn_encode_vect( &result, out_dir );
|
||||
} else {
|
||||
bu_vls_printf(&result, "libbn/bn_tcl.c: math function %s not supported yet", argv[0]);
|
||||
goto error;
|
||||
}
|
||||
|
||||
Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL);
|
||||
bu_vls_free(&result);
|
||||
return TCL_OK;
|
||||
|
||||
error:
|
||||
Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL);
|
||||
bu_vls_free(&result);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
static struct math_func_link_int {
|
||||
char *name;
|
||||
int (*func)();
|
||||
} math_funcs_int[] = {
|
||||
{"bn_isect_2planes", bn_isect_2planes},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* B N _ C M D _ C O M M O N _ F I L E _ S I Z E
|
||||
*/
|
||||
@@ -910,18 +793,11 @@ void
|
||||
bn_tcl_setup(interp)
|
||||
Tcl_Interp *interp;
|
||||
{
|
||||
struct math_func_link_void *vp;
|
||||
struct math_func_link_int *ip;
|
||||
struct math_func_link *mp;
|
||||
|
||||
for (vp = math_funcs_void; vp->name != NULL; vp++) {
|
||||
(void)Tcl_CreateCommand(interp, vp->name, bn_math_cmd_void,
|
||||
(ClientData)vp->func, /* Function-to-Object pointer cast */
|
||||
(Tcl_CmdDeleteProc *)NULL);
|
||||
}
|
||||
|
||||
for (ip = math_funcs_int; ip->name != NULL; ip++) {
|
||||
(void)Tcl_CreateCommand(interp, ip->name, bn_math_cmd_int,
|
||||
(ClientData)ip->func, /* Function-to-Object pointer cast */
|
||||
for (mp = math_funcs; mp->name != NULL; mp++) {
|
||||
(void)Tcl_CreateCommand(interp, mp->name, bn_math_cmd,
|
||||
(ClientData)mp->func, /* Function-to-Object pointer cast */
|
||||
(Tcl_CmdDeleteProc *)NULL);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCScomplex[] = "@(#)$Header$ (BRL)";
|
||||
static char RCScomplex[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSmat[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSmat[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+8
-10
@@ -53,7 +53,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char bn_RCSmat[] = "@(#)$Header$ (ARL)";
|
||||
static char bn_RCSmat[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -61,12 +61,6 @@ static const char bn_RCSmat[] = "@(#)$Header$ (ARL)";
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
@@ -328,10 +322,10 @@ CONST mat_t input;
|
||||
LOCAL int z[4]; /* Temporary */
|
||||
LOCAL fastf_t b[4]; /* Temporary */
|
||||
LOCAL fastf_t c[4]; /* Temporary */
|
||||
|
||||
|
||||
bn_mat_copy( output, input ); /* Duplicate */
|
||||
|
||||
/* Initialization */
|
||||
/* Initialization */
|
||||
for( j = 0; j < 4; j++ )
|
||||
z[j] = j;
|
||||
|
||||
@@ -1190,7 +1184,11 @@ int
|
||||
bn_mat_is_identity( m )
|
||||
CONST mat_t m;
|
||||
{
|
||||
return (! memcmp(m, bn_mat_identity, sizeof(mat_t)));
|
||||
if( m[0] != 1 || m[1] != 0 || m[2] != 0 || m[3] != 0 ) return 0;
|
||||
if( m[4] != 0 || m[5] != 1 || m[6] != 0 || m[7] != 0 ) return 0;
|
||||
if( m[8] != 0 || m[9] != 0 || m[10] != 1 || m[11] != 0 ) return 0;
|
||||
if( m[12] != 0 || m[13] != 0 || m[14] != 0 || m[15] != 1 ) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* B N _ M A T _ A R B _ R O T
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -758,7 +758,7 @@ double offset;
|
||||
struct fbm_spec *ep;
|
||||
double result, weight, signal, *spec_wgts;
|
||||
point_t pt;
|
||||
int i;
|
||||
int i, oct;
|
||||
|
||||
/* The first order of business is to see if we have pre-computed
|
||||
* the spectral weights table for these parameters in a previous
|
||||
@@ -825,7 +825,7 @@ double offset;
|
||||
struct fbm_spec *ep;
|
||||
double result, weight, signal, *spec_wgts;
|
||||
point_t pt;
|
||||
int i;
|
||||
int i, oct;
|
||||
|
||||
/* The first order of business is to see if we have pre-computed
|
||||
* the spectral weights table for these parameters in a previous
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
rb_free rb_insert rb_order_stats \
|
||||
rb_rotate rb_search rb_walk \
|
||||
vfont brlcad_path xdr \
|
||||
vls htond htonf units bu_tcl color cmd \
|
||||
cmdhist cmdhist_obj observer avs
|
||||
vls htond units bu_tcl color cmd \
|
||||
cmdhist cmdhist_obj observer
|
||||
|
||||
#define VERSION_VARIABLE bu_version
|
||||
#define LIBRARY_TITLE "The BRL-CAD Utility Library"
|
||||
|
||||
+1
-4
@@ -18,16 +18,13 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_association_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_association_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "bu.h"
|
||||
|
||||
-223
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* A V S . C
|
||||
*
|
||||
* Routines to manage attribute/value sets.
|
||||
*
|
||||
* Author -
|
||||
* Michael John Muuss
|
||||
*
|
||||
* Source -
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5068 USA
|
||||
*
|
||||
* Distribution Status -
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef USE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
|
||||
/*
|
||||
* B U _ A V S _ I N I T
|
||||
*/
|
||||
void
|
||||
bu_avs_init( avp, len, str )
|
||||
struct bu_attribute_value_set *avp;
|
||||
int len;
|
||||
CONST char *str;
|
||||
{
|
||||
if (bu_debug & BU_DEBUG_AVS)
|
||||
bu_log("bu_avs_init(%8x, len=%d, %s)\n", avp, len, str);
|
||||
|
||||
avp->magic = BU_AVS_MAGIC;
|
||||
if( len <= 0 ) len = 32;
|
||||
avp->count = 0;
|
||||
avp->max = len;
|
||||
avp->avp = (struct bu_attribute_value_pair *)bu_calloc(avp->max,
|
||||
sizeof(struct bu_attribute_value_pair), str);
|
||||
avp->readonly_min = avp->readonly_max = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ N E W
|
||||
*
|
||||
* Allocate storage for a new attribute/value set, with at least
|
||||
* 'len' slots pre-allocated.
|
||||
*/
|
||||
struct bu_attribute_value_set *
|
||||
bu_avs_new( len, str )
|
||||
int len;
|
||||
CONST char *str;
|
||||
{
|
||||
struct bu_attribute_value_set *avp;
|
||||
|
||||
BU_GETSTRUCT( avp, bu_attribute_value_set );
|
||||
bu_avs_init( avp, len, "bu_avs_new" );
|
||||
|
||||
if (bu_debug & BU_DEBUG_AVS)
|
||||
bu_log("bu_avs_new(len=%d, %s) = x%x\n", len, str, avp);
|
||||
|
||||
return avp;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ A D D
|
||||
*
|
||||
* If the given attribute exists it will recieve the new value,
|
||||
* othwise the set will be extended to have a new attribute/value pair.
|
||||
*
|
||||
* Returns -
|
||||
* 1 existing attribute updated with new value
|
||||
* 2 set extended with new attribute/value pair
|
||||
*/
|
||||
int
|
||||
bu_avs_add( avp, attribute, value )
|
||||
struct bu_attribute_value_set *avp;
|
||||
CONST char *attribute;
|
||||
CONST char *value;
|
||||
{
|
||||
struct bu_attribute_value_pair *app;
|
||||
|
||||
BU_CK_AVS(avp);
|
||||
|
||||
for( BU_AVS_FOR(app, avp) ) {
|
||||
if( strcmp( app->name, attribute ) != 0 ) continue;
|
||||
if( app->value < avp->readonly_min || app->value > avp->readonly_max )
|
||||
bu_free( (genptr_t)app->value, "app->value" );
|
||||
app->value = bu_strdup( value );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( avp->count >= avp->max ) {
|
||||
/* Allocate more space first */
|
||||
avp->max *= 4;
|
||||
avp->avp = (struct bu_attribute_value_pair *)bu_realloc(
|
||||
avp->avp,
|
||||
avp->max *
|
||||
sizeof(struct bu_attribute_value_pair),
|
||||
"attribute_value_pair.avp[] (add)" );
|
||||
}
|
||||
|
||||
app = &avp->avp[avp->count++];
|
||||
app->name = bu_strdup(attribute);
|
||||
app->value = bu_strdup(value);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ A D D _ V L S
|
||||
*/
|
||||
int
|
||||
bu_avs_add_vls( avp, attribute, value_vls )
|
||||
struct bu_attribute_value_set *avp;
|
||||
const char *attribute;
|
||||
const struct bu_vls *value_vls;
|
||||
{
|
||||
BU_CK_AVS(avp);
|
||||
BU_CK_VLS(value_vls);
|
||||
|
||||
return bu_avs_add( avp, attribute, bu_vls_addr(value_vls) );
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ G E T
|
||||
*/
|
||||
const char *
|
||||
bu_avs_get( const struct bu_attribute_value_set *avp, const char *attribute )
|
||||
{
|
||||
struct bu_attribute_value_pair *app;
|
||||
|
||||
BU_CK_AVS(avp);
|
||||
|
||||
for( BU_AVS_FOR(app, avp) ) {
|
||||
if( strcmp( app->name, attribute ) != 0 ) continue;
|
||||
return app->value;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ R E M O V E
|
||||
*
|
||||
* Returns -
|
||||
* -1 attribute not found in set
|
||||
* 0 OK
|
||||
*/
|
||||
int
|
||||
bu_avs_remove( avp, attribute )
|
||||
struct bu_attribute_value_set *avp;
|
||||
CONST char *attribute;
|
||||
{
|
||||
struct bu_attribute_value_pair *app, *epp;
|
||||
|
||||
BU_CK_AVS(avp);
|
||||
|
||||
for( BU_AVS_FOR(app, avp) ) {
|
||||
if( strcmp( app->name, attribute ) != 0 ) continue;
|
||||
if( app->name < avp->readonly_min || app->name > avp->readonly_max )
|
||||
bu_free( (genptr_t)app->name, "app->name" );
|
||||
if( app->value < avp->readonly_min || app->value > avp->readonly_max )
|
||||
bu_free( (genptr_t)app->value, "app->value" );
|
||||
|
||||
/* Move last one down to fit */
|
||||
epp = &avp->avp[avp->count--];
|
||||
if( app != epp ) {
|
||||
*app = *epp; /* struct copy */
|
||||
}
|
||||
epp->name = 0; /* sanity */
|
||||
epp->value = 0;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ F R E E
|
||||
*/
|
||||
void
|
||||
bu_avs_free( struct bu_attribute_value_set *avp )
|
||||
{
|
||||
struct bu_attribute_value_pair *app;
|
||||
|
||||
BU_CK_AVS(avp);
|
||||
|
||||
for( BU_AVS_FOR(app, avp) ) {
|
||||
if( app->name < avp->readonly_min || app->name > avp->readonly_max )
|
||||
bu_free( (genptr_t)app->name, "app->name" );
|
||||
if( app->value < avp->readonly_min || app->value > avp->readonly_max )
|
||||
bu_free( (genptr_t)app->value, "app->value" );
|
||||
}
|
||||
bu_free( (genptr_t)avp->avp, "avp->avp" );
|
||||
avp->magic = -1L;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ A V S _ P R I N T
|
||||
*/
|
||||
void
|
||||
bu_avs_print( const struct bu_attribute_value_set *avp, const char *title )
|
||||
{
|
||||
struct bu_attribute_value_pair *avpp;
|
||||
int i;
|
||||
|
||||
BU_CK_AVS(avp);
|
||||
|
||||
bu_log("bu_avs_print: %s\n", title);
|
||||
|
||||
avpp = avp->avp;
|
||||
for( i = 0; i < avp->count; i++, avpp++ ) {
|
||||
bu_log(" %s = %s\n", avpp->name, avpp->value );
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* Public Domain, Distribution Unlimitied.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSbadmagic[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSbadmagic[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-2
@@ -21,7 +21,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_bitv_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_bitv_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -31,7 +31,6 @@ static const char libbu_bitv_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "bu.h"
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSbomb[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSbomb[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* Distribution Status -
|
||||
* Public Domain, Distribution Unlimitied.
|
||||
*/
|
||||
static const char RCSbrlcad_path[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSbrlcad_path[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
|
||||
+24
-45
@@ -23,7 +23,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_bu_tcl_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_bu_tcl_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ static const char libbu_bu_tcl_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#include "tcl.h"
|
||||
|
||||
@@ -150,8 +149,7 @@ char *base; /* base addr of users struct */
|
||||
{
|
||||
register char *cp, *loc;
|
||||
register CONST struct bu_structparse *sdp;
|
||||
register int j;
|
||||
register int ii;
|
||||
register int i, j;
|
||||
struct bu_vls str;
|
||||
|
||||
if( desc == (struct bu_structparse *)NULL ) {
|
||||
@@ -207,12 +205,12 @@ char *base; /* base addr of users struct */
|
||||
bu_vls_free( &str );
|
||||
return TCL_ERROR;
|
||||
}
|
||||
for( ii = j = 0;
|
||||
j < sdp->sp_count && argv[0][ii] != '\0';
|
||||
loc[j++] = argv[0][ii++] )
|
||||
for( i = j = 0;
|
||||
j < sdp->sp_count && argv[0][i] != '\0';
|
||||
loc[j++] = argv[0][i++] )
|
||||
;
|
||||
if( ii < sdp->sp_count )
|
||||
loc[ii] = '\0';
|
||||
if( i < sdp->sp_count )
|
||||
loc[i] = '\0';
|
||||
if( sdp->sp_count > 1 ) {
|
||||
loc[sdp->sp_count-1] = '\0';
|
||||
Tcl_AppendResult( interp,
|
||||
@@ -227,13 +225,9 @@ char *base; /* base addr of users struct */
|
||||
bu_vls_addr(&str),
|
||||
(char *)NULL );
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
break;
|
||||
case 'S': {
|
||||
struct bu_vls *vls = (struct bu_vls *)loc;
|
||||
bu_vls_init_if_uninit( vls );
|
||||
bu_vls_strcpy(vls, *argv);
|
||||
break;
|
||||
}
|
||||
case 'i':
|
||||
bu_log(
|
||||
"Error: %%i not implemented. Contact developers.\n" );
|
||||
@@ -247,12 +241,12 @@ char *base; /* base addr of users struct */
|
||||
register int tmpi;
|
||||
register char CONST *cp;
|
||||
|
||||
if( argc < 1 ) { /* XXX - when was ii defined */
|
||||
if( argc < 1 ) {
|
||||
bu_vls_trunc( &str, 0 );
|
||||
bu_vls_printf( &str,
|
||||
"not enough values for \"%s\" argument: should have %d",
|
||||
"not enough values for \"%s\" argument: should have %d, only %d given",
|
||||
sdp->sp_name,
|
||||
sdp->sp_count);
|
||||
sdp->sp_count, i );
|
||||
Tcl_AppendResult( interp,
|
||||
bu_vls_addr(&str),
|
||||
(char *)NULL );
|
||||
@@ -271,11 +265,13 @@ char *base; /* base addr of users struct */
|
||||
Tcl_AppendResult( interp,
|
||||
bu_vls_addr(&str),
|
||||
(char *)NULL );
|
||||
++argv;
|
||||
--argc;
|
||||
break;
|
||||
}
|
||||
/* Normal case: an integer */
|
||||
cp = *argv;
|
||||
for( ii = 0; ii < sdp->sp_count; ++ii ) {
|
||||
for( i = 0; i < sdp->sp_count; ++i ) {
|
||||
if( *cp == '\0' ) {
|
||||
bu_vls_trunc( &str, 0 );
|
||||
bu_vls_printf( &str,
|
||||
@@ -323,6 +319,8 @@ char *base; /* base addr of users struct */
|
||||
argv[0],
|
||||
sdp->sp_count > 1 ? "}" : "",
|
||||
" ", (char *)NULL);
|
||||
--argc;
|
||||
++argv;
|
||||
break; }
|
||||
case 'f': {
|
||||
int dot_seen;
|
||||
@@ -349,14 +347,14 @@ char *base; /* base addr of users struct */
|
||||
(char *)NULL );
|
||||
|
||||
cp = *argv;
|
||||
for( ii = 0; ii < sdp->sp_count; ii++ ) {
|
||||
for( i = 0; i < sdp->sp_count; i++ ) {
|
||||
if( *cp == '\0' ) {
|
||||
bu_vls_trunc( &str, 0 );
|
||||
bu_vls_printf( &str,
|
||||
"not enough values for \"%s\" argument: should have %d, only %d given",
|
||||
sdp->sp_name,
|
||||
sdp->sp_count,
|
||||
ii );
|
||||
i );
|
||||
Tcl_AppendResult( interp,
|
||||
bu_vls_addr(&str),
|
||||
(char *)NULL );
|
||||
@@ -432,36 +430,17 @@ char *base; /* base addr of users struct */
|
||||
argv[0],
|
||||
sdp->sp_count > 1 ? "}" : "",
|
||||
" ", (char *)NULL );
|
||||
--argc;
|
||||
++argv;
|
||||
break; }
|
||||
default: {
|
||||
struct bu_vls vls;
|
||||
|
||||
bu_vls_init(&vls);
|
||||
bu_vls_printf(&vls,
|
||||
"%s line:%d Parse error, unknown format: '%s' for element \"%s\"",
|
||||
__FILE__, __LINE__, sdp->sp_fmt,
|
||||
sdp->sp_name);
|
||||
|
||||
Tcl_AppendResult( interp, bu_vls_addr(&vls),
|
||||
(char *)NULL );
|
||||
|
||||
bu_vls_free( &vls );
|
||||
default:
|
||||
Tcl_AppendResult( interp, "unknown format",
|
||||
(char *)NULL );
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if( sdp->sp_hook ) {
|
||||
sdp->sp_hook( sdp, sdp->sp_name, base, *argv);
|
||||
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if( sdp->sp_name == NULL ) {
|
||||
bu_vls_trunc( &str, 0 );
|
||||
bu_vls_printf( &str, "invalid attribute %s\n", argv[0] );
|
||||
|
||||
+11
-13
@@ -43,11 +43,11 @@ static struct bu_cmdhist_obj HeadCmdHistObj; /* head of command history object
|
||||
|
||||
static struct bu_cmdtab ch_cmds[] =
|
||||
{
|
||||
{"add", bu_cmdhist_add},
|
||||
{"curr", bu_cmdhist_curr},
|
||||
{"next", bu_cmdhist_next},
|
||||
{"prev", bu_cmdhist_prev},
|
||||
{(char *)NULL, CMD_NULL}
|
||||
"add", bu_cmdhist_add,
|
||||
"curr", bu_cmdhist_curr,
|
||||
"next", bu_cmdhist_next,
|
||||
"prev", bu_cmdhist_prev,
|
||||
(char *)NULL, CMD_NULL
|
||||
};
|
||||
|
||||
int
|
||||
@@ -62,12 +62,12 @@ cho_hist(clientData, interp, argc, argv)
|
||||
|
||||
static struct bu_cmdtab cho_cmds[] =
|
||||
{
|
||||
{"add", bu_cmdhist_add},
|
||||
{"curr", bu_cmdhist_curr},
|
||||
{"history", bu_cmdhist_history},
|
||||
{"next", bu_cmdhist_next},
|
||||
{"prev", bu_cmdhist_prev},
|
||||
{(char *)NULL, CMD_NULL}
|
||||
"add", bu_cmdhist_add,
|
||||
"curr", bu_cmdhist_curr,
|
||||
"history", bu_cmdhist_history,
|
||||
"next", bu_cmdhist_next,
|
||||
"prev", bu_cmdhist_prev,
|
||||
(char *)NULL, CMD_NULL
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -118,7 +118,6 @@ cho_deleteProc(clientData)
|
||||
bu_free((genptr_t)chop, "cho_deleteProc: chop");
|
||||
}
|
||||
|
||||
#if 0 /* As far as I can tell, this is not used. CTJ */
|
||||
/*
|
||||
* Close a command history object.
|
||||
*
|
||||
@@ -148,7 +147,6 @@ cho_close_tcl(clientData, interp, argc, argv)
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct bu_cmdhist_obj *
|
||||
cho_open(clientData, interp, name)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* This software is Copyright (C) 1997 by the United States Army
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
static const char libbu_color_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_color_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
|
||||
+3
-18
@@ -23,7 +23,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_convert_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_convert_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -39,27 +39,14 @@ static const char libbu_convert_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#include "vmath.h"
|
||||
#include "bu.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
int bu_cv_w_cookie(genptr_t, int, int, genptr_t, int, int);
|
||||
int bu_cv_ntohss(SIGNED short *, int, genptr_t, int);
|
||||
int bu_cv_ntohus(unsigned short *, int, genptr_t, int);
|
||||
int bu_cv_ntohsl(SIGNED long int *, int, genptr_t, int);
|
||||
int bu_cv_ntohul(unsigned long int *, int, genptr_t, int);
|
||||
int bu_cv_htonss(genptr_t, int, SIGNED short *, int);
|
||||
int bu_cv_htonus(genptr_t, int, unsigned short *, int);
|
||||
int bu_cv_htonsl(genptr_t, int, long *, int);
|
||||
int bu_cv_htonul(genptr_t, int, unsigned long *, int);
|
||||
|
||||
/*
|
||||
* Theses should be moved to a header file soon.
|
||||
*/
|
||||
#define CV_CHANNEL_MASK 0x00ff
|
||||
#define CV_HOST_MASK 0x0100
|
||||
#define CV_SIGNED_MASK 0x0200
|
||||
#define CV_TYPE_MASK 0x1c00 /* 0001 1100 0000 0000 */
|
||||
#define CV_CONVERT_MASK 0x6000 /* 0110 0000 0000 0000 */
|
||||
#define CV_TYPE_MASK 0x1c00
|
||||
#define CV_CONVERT_MASK 0x6000
|
||||
|
||||
#define CV_TYPE_SHIFT 10
|
||||
#define CV_CONVERT_SHIFT 13
|
||||
@@ -328,7 +315,6 @@ int cookie;
|
||||
* outfmt output format
|
||||
*
|
||||
*/
|
||||
int
|
||||
cv(out, outfmt, size, in, infmt, count)
|
||||
genptr_t out;
|
||||
char *outfmt;
|
||||
@@ -514,7 +500,6 @@ register int cookie;
|
||||
* fi
|
||||
* done
|
||||
*/
|
||||
int
|
||||
bu_cv_w_cookie(out, outcookie, size, in, incookie, count)
|
||||
genptr_t out;
|
||||
int outcookie;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* Public Domain, Distribution Unlimitied.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_getopt_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_getopt_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-4
@@ -20,16 +20,13 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCShist[] = "@(#)$Header$ (BRL)";
|
||||
static char RCShist[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
|
||||
|
||||
+7
-7
@@ -41,7 +41,7 @@
|
||||
* Public Domain, Distribution Unlimited
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_htond_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_htond_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -110,7 +110,7 @@ int count;
|
||||
*out++ = in[2];
|
||||
*out++ = in[1];
|
||||
*out++ = in[0];
|
||||
in += SIZEOF_NETWORK_DOUBLE;
|
||||
in += 8;
|
||||
}
|
||||
# define HTOND yes2
|
||||
|
||||
@@ -414,12 +414,12 @@ int count;
|
||||
* IEEE format internally, using big-endian order.
|
||||
* These are the lucky ones.
|
||||
*/
|
||||
if( sizeof(double) != SIZEOF_NETWORK_DOUBLE )
|
||||
bu_bomb("ntohd: sizeof(double) != SIZEOF_NETWORK_DOUBLE\n");
|
||||
if( sizeof(double) != 8 )
|
||||
fprintf(stderr, "ntohd: sizeof(double) != 8\n");
|
||||
# if BSD
|
||||
bcopy( in, out, count*SIZEOF_NETWORK_DOUBLE );
|
||||
bcopy( in, out, count*8 );
|
||||
# else
|
||||
memcpy( out, in, count*SIZEOF_NETWORK_DOUBLE );
|
||||
memcpy( out, in, count*8 );
|
||||
# endif
|
||||
return;
|
||||
# define NTOHD yes1
|
||||
@@ -436,7 +436,7 @@ int count;
|
||||
*out++ = in[2];
|
||||
*out++ = in[1];
|
||||
*out++ = in[0];
|
||||
in += SIZEOF_NETWORK_DOUBLE;
|
||||
in += 8;
|
||||
}
|
||||
# define NTOHD yes2
|
||||
#endif
|
||||
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* H T O N F . C
|
||||
*
|
||||
* Author -
|
||||
* Michael John Muuss
|
||||
*
|
||||
* Source -
|
||||
* SECAD/VLD Computing Consortium, Bldg 394
|
||||
* The U. S. Army Ballistic Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5066
|
||||
*
|
||||
* Release Status -
|
||||
* Public Domain, Distribution Unlimited
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_htond_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
#include <stdio.h>
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* H T O N F
|
||||
*
|
||||
* Host to Network Floats
|
||||
*/
|
||||
void
|
||||
htonf( out, in, count )
|
||||
register unsigned char *out;
|
||||
register CONST unsigned char *in;
|
||||
int count;
|
||||
{
|
||||
#if defined(NATURAL_IEEE)
|
||||
/*
|
||||
* First, the case where the system already operates in
|
||||
* IEEE format internally, using big-endian order.
|
||||
* These are the lucky ones.
|
||||
*/
|
||||
# if BSD
|
||||
bcopy( in, out, count*SIZEOF_NETWORK_FLOAT );
|
||||
# else
|
||||
memcpy( out, in, count*SIZEOF_NETWORK_FLOAT );
|
||||
# endif
|
||||
return;
|
||||
# define HTONF yes1
|
||||
#endif
|
||||
#if defined(REVERSED_IEEE)
|
||||
/* This machine uses IEEE, but in little-endian byte order */
|
||||
register int i;
|
||||
for( i=count-1; i >= 0; i-- ) {
|
||||
*out++ = in[3];
|
||||
*out++ = in[2];
|
||||
*out++ = in[1];
|
||||
*out++ = in[0];
|
||||
in += SIZEOF_NETWORK_FLOAT;
|
||||
}
|
||||
# define HTONF yes2
|
||||
#endif
|
||||
|
||||
/* Now, for the machine-specific stuff. */
|
||||
|
||||
bu_bomb("htonf() not yet supported on this architecture\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* N T O H F
|
||||
*
|
||||
* Network to Host Floats
|
||||
*/
|
||||
void
|
||||
ntohf( out, in, count )
|
||||
register unsigned char *out;
|
||||
register CONST unsigned char *in;
|
||||
int count;
|
||||
{
|
||||
#ifdef NATURAL_IEEE
|
||||
/*
|
||||
* First, the case where the system already operates in
|
||||
* IEEE format internally, using big-endian order.
|
||||
* These are the lucky ones.
|
||||
*/
|
||||
if( sizeof(float) != SIZEOF_NETWORK_FLOAT )
|
||||
bu_bomb("ntohf: sizeof(float) != SIZEOF_NETWORK_FLOAT\n");
|
||||
# if BSD
|
||||
bcopy( in, out, count*SIZEOF_NETWORK_FLOAT );
|
||||
# else
|
||||
memcpy( out, in, count*SIZEOF_NETWORK_FLOAT );
|
||||
# endif
|
||||
return;
|
||||
# define NTOHD yes1
|
||||
#endif
|
||||
#if defined(REVERSED_IEEE)
|
||||
/* This machine uses IEEE, but in little-endian byte order */
|
||||
register int i;
|
||||
for( i=count-1; i >= 0; i-- ) {
|
||||
*out++ = in[3];
|
||||
*out++ = in[2];
|
||||
*out++ = in[1];
|
||||
*out++ = in[0];
|
||||
in += SIZEOF_NETWORK_FLOAT;
|
||||
}
|
||||
# define NTOHD yes2
|
||||
#endif
|
||||
|
||||
bu_bomb("ntohf() not yet supported on this architecture\n");
|
||||
}
|
||||
+1
-2
@@ -18,14 +18,13 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSispar[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSispar[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "bu.h"
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_linebuf_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_linebuf_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_list_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_list_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSlog[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSlog[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+12
-16
@@ -22,7 +22,7 @@
|
||||
* Public Domain, Distribution Unlimitied.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSmagic[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSmagic[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -69,26 +69,22 @@ register long magic;
|
||||
/*
|
||||
* bu.h
|
||||
*/
|
||||
case BU_LIST_HEAD_MAGIC:
|
||||
return "bu_list";
|
||||
case BU_BITV_MAGIC:
|
||||
return "bu_bitv";
|
||||
case BU_HIST_MAGIC:
|
||||
return "bu_hist";
|
||||
case BU_PTBL_MAGIC:
|
||||
return "bu_ptbl";
|
||||
case BU_MAPPED_FILE_MAGIC:
|
||||
return "bu_mapped_file";
|
||||
case BU_AVS_MAGIC:
|
||||
return "bu_attribute_value_set";
|
||||
case BU_VLS_MAGIC:
|
||||
return "bu_vls";
|
||||
case BU_PTBL_MAGIC:
|
||||
return "bu_ptbl";
|
||||
case BU_BITV_MAGIC:
|
||||
return "bu_bitv";
|
||||
case BU_LIST_HEAD_MAGIC:
|
||||
return "bu_list";
|
||||
case BU_HIST_MAGIC:
|
||||
return "bu_hist";
|
||||
case BU_MAPPED_FILE_MAGIC:
|
||||
return "bu_mapped_file";
|
||||
case BU_EXTERNAL_MAGIC:
|
||||
return "bu_external";
|
||||
case BU_COLOR_MAGIC:
|
||||
return "bu_color";
|
||||
case BU_RB_TREE_MAGIC:
|
||||
return "bu_rb_tree";
|
||||
return "red-black tree";
|
||||
|
||||
/*
|
||||
* bn.h
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSmalloc[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSmalloc[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -260,7 +260,7 @@ register genptr_t ptr;
|
||||
unsigned int cnt;
|
||||
CONST char *str;
|
||||
{
|
||||
struct memdebug *mp=NULL;
|
||||
struct memdebug *mp;
|
||||
char *original_ptr = ptr;
|
||||
|
||||
if( bu_debug&BU_DEBUG_MEM_CHECK ) {
|
||||
|
||||
+1
-2
@@ -27,7 +27,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_mappedfile_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_mappedfile_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -35,7 +35,6 @@ static const char libbu_mappedfile_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#ifdef USE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_memset_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_memset_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#if defined(BSD) && (BSD < 43)
|
||||
|
||||
+4
-4
@@ -32,10 +32,10 @@ static int bu_observer_detach_tcl();
|
||||
static int bu_observer_show_tcl();
|
||||
|
||||
struct bu_cmdtab bu_observer_cmds[] = {
|
||||
{"attach", bu_observer_attach_tcl},
|
||||
{"detach", bu_observer_detach_tcl},
|
||||
{"show", bu_observer_show_tcl},
|
||||
{(char *)0, (int (*)())0}
|
||||
"attach", bu_observer_attach_tcl,
|
||||
"detach", bu_observer_detach_tcl,
|
||||
"show", bu_observer_show_tcl,
|
||||
(char *)0, (int (*)())0
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
+4
-20
@@ -15,7 +15,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSparallel[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSparallel[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -23,24 +23,10 @@ static const char RCSparallel[] = "@(#)$Header$ (ARL)";
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "bu.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef CRAY
|
||||
# include <sys/category.h>
|
||||
# include <sys/resource.h>
|
||||
@@ -138,7 +124,8 @@ void
|
||||
bu_nice_set(newnice)
|
||||
int newnice;
|
||||
{
|
||||
int opri, npri;
|
||||
int opri, npri, chg;
|
||||
int bias;
|
||||
|
||||
#ifdef BSD
|
||||
#define PRIO_PROCESS 0 /* From /usr/include/sys/resource.h */
|
||||
@@ -146,8 +133,6 @@ int newnice;
|
||||
setpriority( PRIO_PROCESS, 0, newnice );
|
||||
npri = getpriority( PRIO_PROCESS, 0 );
|
||||
#else
|
||||
int bias, chg;
|
||||
|
||||
/* " nice adds the value of incr to the nice value of the process" */
|
||||
/* "The default nice value is 20" */
|
||||
/* "Upon completion, nice returns the new nice value minus 20" */
|
||||
@@ -393,7 +378,6 @@ bu_set_realtime()
|
||||
# define CHECK_PIDS 1
|
||||
#endif
|
||||
|
||||
#if defined(PARALLEL)
|
||||
/*
|
||||
* B U _ W O R K E R _ T B L _ N O T _ E M P T Y
|
||||
*/
|
||||
@@ -428,6 +412,7 @@ int tbl[MAX_PSW];
|
||||
|
||||
bzero( (char *)tbl, sizeof(tbl) );
|
||||
}
|
||||
|
||||
extern int bu_pid_of_initiating_thread; /* From ispar.c */
|
||||
|
||||
static int bu_nthreads_started = 0; /* # threads started */
|
||||
@@ -483,7 +468,6 @@ bu_parallel_interface()
|
||||
if(cpu) _exit(0);
|
||||
# endif /* SGI */
|
||||
}
|
||||
#endif /* PARALLEL */
|
||||
|
||||
#ifdef SGI_4D
|
||||
/*
|
||||
|
||||
+6
-49
@@ -29,7 +29,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSparse[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSparse[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -1837,9 +1837,6 @@ char *params;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ S H A D E R _ T O _ K E Y _ E Q
|
||||
*/
|
||||
int
|
||||
bu_shader_to_key_eq( in, vls )
|
||||
char *in;
|
||||
@@ -1940,7 +1937,9 @@ struct bu_vls *vls;
|
||||
* 0 OK
|
||||
*/
|
||||
int
|
||||
bu_fwrite_external( FILE *fp, const struct bu_external *ep )
|
||||
bu_fwrite_external( fp, ep )
|
||||
FILE *fp;
|
||||
CONST struct bu_external *ep;
|
||||
{
|
||||
BU_CK_EXTERNAL(ep);
|
||||
|
||||
@@ -1949,54 +1948,12 @@ bu_fwrite_external( FILE *fp, const struct bu_external *ep )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ H E X D U M P _ E X T E R N A L
|
||||
*/
|
||||
void
|
||||
bu_hexdump_external( FILE *fp, CONST struct bu_external *ep, CONST char *str)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
const unsigned char *endp;
|
||||
int i, j, k;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
|
||||
fprintf(fp, "%s:\n", str);
|
||||
if( ep->ext_nbytes <= 0 ) fprintf(fp, "\tWarning: 0 length external buffer\n");
|
||||
|
||||
cp = ep->ext_buf;
|
||||
endp = cp + ep->ext_nbytes;
|
||||
for( i=0; i < ep->ext_nbytes; i += 16 ) {
|
||||
const unsigned char *sp = cp;
|
||||
|
||||
for( j=0; j < 4; j++ ) {
|
||||
for( k=0; k < 4; k++ ) {
|
||||
if( cp >= endp )
|
||||
fprintf(fp, " ");
|
||||
else
|
||||
fprintf(fp, "%2.2x ", *cp++ );
|
||||
}
|
||||
fprintf(fp, " ");
|
||||
}
|
||||
fprintf(fp, " |");
|
||||
|
||||
for( j=0; j < 16; j++,sp++ ) {
|
||||
if( sp >= endp ) break;
|
||||
if( isprint(*sp) )
|
||||
putc(*sp, fp);
|
||||
else
|
||||
putc('.', fp);
|
||||
}
|
||||
|
||||
fprintf(fp, "|\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* B U _ F R E E _ E X T E R N A L
|
||||
*/
|
||||
void
|
||||
bu_free_external( register struct bu_external *ep)
|
||||
bu_free_external( ep )
|
||||
register struct bu_external *ep;
|
||||
{
|
||||
BU_CK_EXTERNAL(ep);
|
||||
if( ep->ext_buf ) {
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_printb_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_printb_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ register CONST char *bits;
|
||||
bu_vls_printf( vls, "%s=0%o <", s, v);
|
||||
else
|
||||
bu_vls_printf( vls, "%s=x%x <", s, v);
|
||||
while ((i = *bits++)) {
|
||||
while (i = *bits++) {
|
||||
if (v & (1L << (i-1))) {
|
||||
if (any)
|
||||
bu_vls_strcat( vls, ",");
|
||||
|
||||
+1
-6
@@ -21,18 +21,13 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_ptbl_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_ptbl_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
#include <stdio.h>
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* B U _ P T B L _ I N I T
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_create_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_create_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static char const libbu_rb_delete_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_delete_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_diag_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_diag_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_extreme_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_extreme_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_free_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_free_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_insert_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_insert_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -51,7 +51,7 @@ struct bu_rb_node *new_node;
|
||||
struct bu_rb_node *grand_parent;
|
||||
struct bu_rb_node *y;
|
||||
int (*compare)();
|
||||
int comparison=0xdeadbeef;
|
||||
int comparison;
|
||||
int direction;
|
||||
int result = 0;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_order_stats_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_order_stats_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_rotate_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_rotate_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
* in all countries except the USA. All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_search_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_search_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
* depth in the tree.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_rb_walk_RCSid[] = "@(#) $Header$";
|
||||
static char libbu_rb_walk_RCSid[] = "@(#) $Header$";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
+3
-5
@@ -24,7 +24,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSsemaphore[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSsemaphore[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -211,10 +211,8 @@ register long *p;
|
||||
}
|
||||
#endif /* convex */
|
||||
|
||||
#if defined(PARALLEL) || defined(DEFINED_BU_SEMAPHORES)
|
||||
static unsigned int bu_nsemaphores = 0;
|
||||
static struct bu_semaphores *bu_semaphores = (struct bu_semaphores *)NULL;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* B U _ S E M A P H O R E _ I N I T
|
||||
@@ -230,11 +228,11 @@ void
|
||||
bu_semaphore_init( nsemaphores )
|
||||
unsigned int nsemaphores;
|
||||
{
|
||||
int i;
|
||||
|
||||
#if !defined(PARALLEL) && !defined(DEFINED_BU_SEMAPHORES)
|
||||
return; /* No support on this hardware */
|
||||
#else
|
||||
int i;
|
||||
|
||||
if( bu_nsemaphores != 0 ) return; /* Already called */
|
||||
bu_semaphores = (struct bu_semaphores *)calloc(
|
||||
nsemaphores,
|
||||
|
||||
+38
-44
@@ -16,7 +16,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_units_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_units_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -24,12 +24,6 @@ static const char libbu_units_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "machine.h"
|
||||
#include "externs.h" /* needed for things like strtod() */
|
||||
#include "bu.h"
|
||||
@@ -38,43 +32,43 @@ static CONST struct cvt_tab {
|
||||
double val;
|
||||
char name[32];
|
||||
} bu_units_tab[] = {
|
||||
{0.0, "none"},
|
||||
{1.0e-7, "angstrom"},
|
||||
{1.0e-7, "decinanometer"},
|
||||
{1.0e-6, "nm"},
|
||||
{1.0e-6, "nanometer"},
|
||||
{1.0e-3, "um"},
|
||||
{1.0e-3, "micrometer"},
|
||||
{1.0e-3, "micron"},
|
||||
{1.0, "mm"},
|
||||
{1.0, "millimeter"},
|
||||
{10.0, "cm"},
|
||||
{10.0, "centimeter"},
|
||||
{1000.0, "m"},
|
||||
{1000.0, "meter"},
|
||||
{1000000.0, "km"},
|
||||
{1000000.0, "kilometer"},
|
||||
{25.4, "in"},
|
||||
{25.4, "inch"},
|
||||
{25.4, "inche"}, /* for plural */
|
||||
{304.8, "ft"},
|
||||
{304.8, "foot"},
|
||||
{304.8, "feet"},
|
||||
{456.2, "cubit"},
|
||||
{914.4, "yd"},
|
||||
{914.4, "yard"},
|
||||
{5029.2, "rd"},
|
||||
{5029.2, "rod"},
|
||||
{1609344.0, "mi"},
|
||||
{1609344.0, "mile"},
|
||||
{1852000.0, "nmile"},
|
||||
{1852000.0, "nautical mile"},
|
||||
{1.495979e+14, "AU"},
|
||||
{1.495979e+14, "astronomical unit"},
|
||||
{9.460730e+18, "lightyear"},
|
||||
{3.085678e+19, "pc"},
|
||||
{3.085678e+19, "parsec"},
|
||||
{0.0, ""} /* LAST ENTRY */
|
||||
0.0, "none",
|
||||
1.0e-7, "angstrom",
|
||||
1.0e-7, "decinanometer",
|
||||
1.0e-6, "nm",
|
||||
1.0e-6, "nanometer",
|
||||
1.0e-3, "um",
|
||||
1.0e-3, "micrometer",
|
||||
1.0e-3, "micron",
|
||||
1.0, "mm",
|
||||
1.0, "millimeter",
|
||||
10.0, "cm",
|
||||
10.0, "centimeter",
|
||||
1000.0, "m",
|
||||
1000.0, "meter",
|
||||
1000000.0, "km",
|
||||
1000000.0, "kilometer",
|
||||
25.4, "in",
|
||||
25.4, "inch",
|
||||
25.4, "inche", /* for plural */
|
||||
304.8, "ft",
|
||||
304.8, "foot",
|
||||
304.8, "feet",
|
||||
456.2, "cubit",
|
||||
914.4, "yd",
|
||||
914.4, "yard",
|
||||
5029.2, "rd",
|
||||
5029.2, "rod",
|
||||
1609344.0, "mi",
|
||||
1609344.0, "mile",
|
||||
1852000.0, "nmile",
|
||||
1852000.0, "nautical mile",
|
||||
1.495979e+14, "AU",
|
||||
1.495979e+14, "astronomical unit",
|
||||
9.460730e+18, "lightyear",
|
||||
3.085678e+19, "pc",
|
||||
3.085678e+19, "parsec",
|
||||
0.0, "" /* LAST ENTRY */
|
||||
};
|
||||
#define BU_UNITS_TABLE_SIZE (sizeof(bu_units_tab) / sizeof(struct cvt_tab) - 1)
|
||||
|
||||
|
||||
+1
-7
@@ -19,7 +19,7 @@
|
||||
* Public Domain, Distribution Unlimited
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_vfont_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_vfont_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -28,17 +28,11 @@ static const char libbu_vfont_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "vfont-if.h"
|
||||
#include "bu.h"
|
||||
|
||||
#define FONTDIR2 "/usr/lib/vfont"
|
||||
#define DEFAULT_FONT "nonie.r.12"
|
||||
#define FONTNAMESZ 128
|
||||
|
||||
/*
|
||||
* Forward Definitions
|
||||
*/
|
||||
int vax_gshort(char *);
|
||||
|
||||
/*
|
||||
* V F O N T _ G E T
|
||||
*
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@
|
||||
* Distribution Status -
|
||||
* Public Domain, Distribution Unlimitied.
|
||||
*/
|
||||
static const char libbu_vls_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char libbu_vls_RCSid[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
@@ -759,7 +759,7 @@ va_list ap;
|
||||
#define FIELDLEN 0x002
|
||||
|
||||
int flags;
|
||||
int fieldlen=-1;
|
||||
int fieldlen;
|
||||
char fbuf[64], buf[1024]; /* % format buffer */
|
||||
|
||||
BU_CK_VLS(vls);
|
||||
@@ -816,7 +816,7 @@ va_list ap;
|
||||
int stringlen = strlen(str);
|
||||
int left_justify;
|
||||
|
||||
if ((left_justify = (fieldlen < 0)))
|
||||
if (left_justify = (fieldlen < 0))
|
||||
fieldlen *= -1;
|
||||
|
||||
if (stringlen >= fieldlen)
|
||||
@@ -859,7 +859,7 @@ va_list ap;
|
||||
int stringlen = bu_vls_strlen(vp);
|
||||
int left_justify;
|
||||
|
||||
if ((left_justify = (fieldlen < 0)))
|
||||
if (left_justify = (fieldlen < 0))
|
||||
fieldlen *= -1;
|
||||
|
||||
if (stringlen >= fieldlen)
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char libbu_xdr_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char libbu_xdr_RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* C M D . C
|
||||
*
|
||||
* Utility routines for handling commands.
|
||||
*
|
||||
*
|
||||
* Source -
|
||||
* SLAD CAD Team
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005
|
||||
*
|
||||
* Author -
|
||||
* Robert G. Parker
|
||||
*/
|
||||
#include "conf.h"
|
||||
#include "tcl.h"
|
||||
#include "machine.h"
|
||||
#include "externs.h"
|
||||
#include "cmd.h"
|
||||
|
||||
/*
|
||||
* Generic command parser.
|
||||
*/
|
||||
int
|
||||
do_cmd(clientData, interp, argc, argv, cmds, cmd_index)
|
||||
ClientData clientData;
|
||||
Tcl_Interp *interp;
|
||||
int argc;
|
||||
char **argv;
|
||||
struct cmdtab *cmds;
|
||||
int cmd_index;
|
||||
{
|
||||
register struct cmdtab *ctp;
|
||||
|
||||
/* sanity */
|
||||
if (cmd_index >= argc) {
|
||||
Tcl_AppendResult(interp,
|
||||
"missing command; must be one of:",
|
||||
(char *)NULL);
|
||||
goto missing_cmd;
|
||||
}
|
||||
|
||||
for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) {
|
||||
if (strcmp(ctp->ct_name, argv[cmd_index]) == 0) {
|
||||
return (*ctp->ct_func)(clientData, interp, argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
Tcl_AppendResult(interp,
|
||||
"unknown command; must be one of:",
|
||||
(char *)NULL);
|
||||
missing_cmd:
|
||||
for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) {
|
||||
Tcl_AppendResult(interp, " ", ctp->ct_name, (char *)NULL);
|
||||
}
|
||||
Tcl_AppendResult(interp, "\n", (char *)NULL);
|
||||
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic routine to register commands with a Tcl interpreter.
|
||||
*/
|
||||
void
|
||||
register_cmds(interp, cmds)
|
||||
Tcl_Interp *interp;
|
||||
struct cmdtab *cmds;
|
||||
{
|
||||
register struct cmdtab *ctp;
|
||||
|
||||
for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++)
|
||||
(void)Tcl_CreateCommand(interp, ctp->ct_name, ctp->ct_func,
|
||||
(ClientData)ctp, (Tcl_CmdDeleteProc *)NULL);
|
||||
}
|
||||
+331
-341
@@ -118,133 +118,121 @@ static mat_t plotmat;
|
||||
*/
|
||||
struct dm *
|
||||
plot_open(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
static int count = 0;
|
||||
struct dm *dmp;
|
||||
Tcl_Obj *obj;
|
||||
static int count = 0;
|
||||
struct dm *dmp;
|
||||
|
||||
BU_GETSTRUCT(dmp, dm);
|
||||
if (dmp == DM_NULL)
|
||||
return DM_NULL;
|
||||
BU_GETSTRUCT(dmp, dm);
|
||||
if(dmp == DM_NULL)
|
||||
return DM_NULL;
|
||||
|
||||
*dmp = dm_plot; /* struct copy */
|
||||
*dmp = dm_plot; /* struct copy */
|
||||
|
||||
dmp->dm_vars.priv_vars = (genptr_t)bu_calloc(1, sizeof(struct plot_vars), "plot_open: plot_vars");
|
||||
BU_GETSTRUCT(dmp->dm_vars.priv_vars, plot_vars);
|
||||
if (dmp->dm_vars.priv_vars == (genptr_t)NULL) {
|
||||
bu_free(dmp, "plot_open: dmp");
|
||||
return DM_NULL;
|
||||
}
|
||||
dmp->dm_vars.priv_vars = (genptr_t)bu_calloc(1, sizeof(struct plot_vars), "plot_open: plot_vars");
|
||||
BU_GETSTRUCT(dmp->dm_vars.priv_vars, plot_vars);
|
||||
if(dmp->dm_vars.priv_vars == (genptr_t)NULL){
|
||||
bu_free(dmp, "plot_open: dmp");
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
bu_vls_init(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls);
|
||||
bu_vls_init(&dmp->dm_pathName);
|
||||
bu_vls_init(&dmp->dm_tkName);
|
||||
bu_vls_printf(&dmp->dm_pathName, ".dm_plot%d", count++);
|
||||
bu_vls_printf(&dmp->dm_tkName, "dm_plot%d", count++);
|
||||
|
||||
bu_vls_init(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls);
|
||||
bu_vls_init(&dmp->dm_pathName);
|
||||
bu_vls_init(&dmp->dm_tkName);
|
||||
bu_vls_printf(&dmp->dm_pathName, ".dm_plot%d", count++);
|
||||
bu_vls_printf(&dmp->dm_tkName, "dm_plot%d", count++);
|
||||
/* skip first argument */
|
||||
--argc; ++argv;
|
||||
|
||||
/* skip first argument */
|
||||
--argc; ++argv;
|
||||
|
||||
/* Process any options */
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D = 1; /* 3-D w/color, by default */
|
||||
while (argv[0] != (char *)0 && argv[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case '3':
|
||||
break;
|
||||
case '2':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D = 0; /* 2-D, for portability */
|
||||
break;
|
||||
case 'g':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->grid = 1;
|
||||
break;
|
||||
case 'f':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->floating = 1;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
/* Enable Z clipping */
|
||||
Tcl_AppendStringsToObj(obj, "Clipped in Z to viewing cube\n", (char *)NULL);
|
||||
/* Process any options */
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D = 1; /* 3-D w/color, by default */
|
||||
while( argv[0] != (char *)0 && argv[0][0] == '-' ) {
|
||||
switch( argv[0][1] ) {
|
||||
case '3':
|
||||
break;
|
||||
case '2':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D = 0; /* 2-D, for portability */
|
||||
break;
|
||||
case 'g':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->grid = 1;
|
||||
break;
|
||||
case 'f':
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->floating = 1;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
/* Enable Z clipping */
|
||||
Tcl_AppendResult(interp, "Clipped in Z to viewing cube\n", (char *)NULL);
|
||||
#if 0
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->zclip = 1;
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->zclip = 1;
|
||||
#else
|
||||
dmp->dm_zclip = 1;
|
||||
dmp->dm_zclip = 1;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
Tcl_AppendStringsToObj(obj, "bad PLOT option ", argv[0], "\n", (char *)NULL);
|
||||
(void)plot_close(dmp);
|
||||
break;
|
||||
default:
|
||||
Tcl_AppendResult(interp, "bad PLOT option ", argv[0], "\n", (char *)NULL);
|
||||
(void)plot_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
if( argv[0] == (char *)0 ) {
|
||||
Tcl_AppendResult(interp, "no filename or filter specified\n", (char *)NULL);
|
||||
(void)plot_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
if (argv[0] == (char *)0) {
|
||||
Tcl_AppendStringsToObj(obj, "no filename or filter specified\n", (char *)NULL);
|
||||
(void)plot_close(dmp);
|
||||
if( argv[0][0] == '|' ) {
|
||||
bu_vls_strcpy(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, &argv[0][1]);
|
||||
while( (++argv)[0] != (char *)0 ) {
|
||||
bu_vls_strcat( &((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, " " );
|
||||
bu_vls_strcat( &((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, argv[0] );
|
||||
}
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe = 1;
|
||||
}else{
|
||||
bu_vls_strcpy(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, argv[0]);
|
||||
}
|
||||
|
||||
if (argv[0][0] == '|') {
|
||||
bu_vls_strcpy(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, &argv[0][1]);
|
||||
while( (++argv)[0] != (char *)0 ) {
|
||||
bu_vls_strcat( &((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, " " );
|
||||
bu_vls_strcat( &((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, argv[0] );
|
||||
}
|
||||
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe = 1;
|
||||
} else {
|
||||
bu_vls_strcpy(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls, argv[0]);
|
||||
}
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe) {
|
||||
if ((((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp =
|
||||
popen( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls), "w")) == NULL) {
|
||||
perror( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls));
|
||||
(void)plot_close(dmp);
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe){
|
||||
if((((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp =
|
||||
popen( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls), "w")) == NULL){
|
||||
perror( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls));
|
||||
(void)plot_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "piped to ",
|
||||
bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls),
|
||||
"\n", (char *)NULL);
|
||||
} else {
|
||||
if ((((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp =
|
||||
fopen( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls), "w" )) == NULL) {
|
||||
perror(bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls));
|
||||
(void)plot_close(dmp);
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
Tcl_AppendResult(interp, "piped to ",
|
||||
bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls),
|
||||
"\n", (char *)NULL);
|
||||
}else{
|
||||
if((((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp =
|
||||
fopen( bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls), "w" )) == NULL){
|
||||
perror(bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls));
|
||||
(void)plot_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "plot stored in ",
|
||||
bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls),
|
||||
"\n", (char *)NULL);
|
||||
}
|
||||
Tcl_AppendResult(interp, "plot stored in ",
|
||||
bu_vls_addr(&((struct plot_vars *)dmp->dm_vars.priv_vars)->vls),
|
||||
"\n", (char *)NULL);
|
||||
}
|
||||
|
||||
setbuf(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->ttybuf);
|
||||
setbuf(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
((struct plot_vars *)dmp->dm_vars.priv_vars)->ttybuf);
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D)
|
||||
pl_3space(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
-2048, -2048, -2048, 2048, 2048, 2048);
|
||||
else
|
||||
pl_space(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
-2048, -2048, 2048, 2048);
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D)
|
||||
pl_3space( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
-2048, -2048, -2048, 2048, 2048, 2048 );
|
||||
else
|
||||
pl_space( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
-2048, -2048, 2048, 2048 );
|
||||
|
||||
bn_mat_idn(plotmat);
|
||||
bn_mat_idn(plotmat);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return dmp;
|
||||
return dmp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -254,19 +242,19 @@ plot_open(argc, argv)
|
||||
*/
|
||||
static int
|
||||
plot_close(dmp)
|
||||
struct dm *dmp;
|
||||
struct dm *dmp;
|
||||
{
|
||||
(void)fflush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
(void)fflush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe)
|
||||
pclose(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp); /* close pipe, eat dead children */
|
||||
else
|
||||
fclose(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->is_pipe)
|
||||
pclose(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp); /* close pipe, eat dead children */
|
||||
else
|
||||
fclose(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
|
||||
bu_vls_free(&dmp->dm_pathName);
|
||||
bu_free(dmp->dm_vars.priv_vars, "plot_close: plot_vars");
|
||||
bu_free(dmp, "plot_close: dmp");
|
||||
return TCL_OK;
|
||||
bu_vls_free(&dmp->dm_pathName);
|
||||
bu_free(dmp->dm_vars.priv_vars, "plot_close: plot_vars");
|
||||
bu_free(dmp, "plot_close: dmp");
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -276,11 +264,11 @@ plot_close(dmp)
|
||||
*/
|
||||
static int
|
||||
plot_drawBegin(dmp)
|
||||
struct dm *dmp;
|
||||
struct dm *dmp;
|
||||
{
|
||||
/* We expect the screen to be blank so far, from last frame flush */
|
||||
/* We expect the screen to be blank so far, from last frame flush */
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -288,13 +276,13 @@ plot_drawBegin(dmp)
|
||||
*/
|
||||
static int
|
||||
plot_drawEnd(dmp)
|
||||
struct dm *dmp;
|
||||
struct dm *dmp;
|
||||
{
|
||||
pl_flush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp); /* BRL-specific command */
|
||||
pl_erase(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp); /* forces drawing */
|
||||
(void)fflush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
pl_flush( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp ); /* BRL-specific command */
|
||||
pl_erase( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp ); /* forces drawing */
|
||||
(void)fflush( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp );
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -305,36 +293,29 @@ plot_drawEnd(dmp)
|
||||
*/
|
||||
static int
|
||||
plot_loadMatrix(dmp, mat, which_eye)
|
||||
struct dm *dmp;
|
||||
mat_t mat;
|
||||
int which_eye;
|
||||
struct dm *dmp;
|
||||
mat_t mat;
|
||||
int which_eye;
|
||||
{
|
||||
Tcl_Obj *obj;
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->debug){
|
||||
struct bu_vls tmp_vls;
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
Tcl_AppendResult(interp, "plot_loadMatrix()\n", (char *)NULL);
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->debug) {
|
||||
struct bu_vls tmp_vls;
|
||||
bu_vls_init(&tmp_vls);
|
||||
bu_vls_printf(&tmp_vls, "which eye = %d\t", which_eye);
|
||||
bu_vls_printf(&tmp_vls, "transformation matrix = \n");
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[0], mat[4], mat[8],mat[12]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[1], mat[5], mat[9],mat[13]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[2], mat[6], mat[10],mat[14]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[3], mat[7], mat[11],mat[15]);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "plot_loadMatrix()\n", (char *)NULL);
|
||||
Tcl_AppendResult(interp, bu_vls_addr(&tmp_vls), (char *)NULL);
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
bu_vls_init(&tmp_vls);
|
||||
bu_vls_printf(&tmp_vls, "which eye = %d\t", which_eye);
|
||||
bu_vls_printf(&tmp_vls, "transformation matrix = \n");
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[0], mat[4], mat[8],mat[12]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[1], mat[5], mat[9],mat[13]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[2], mat[6], mat[10],mat[14]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[3], mat[7], mat[11],mat[15]);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, bu_vls_addr(&tmp_vls), (char *)NULL);
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
bn_mat_copy(plotmat, mat);
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return TCL_OK;
|
||||
bn_mat_copy(plotmat, mat);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -348,138 +329,154 @@ plot_loadMatrix(dmp, mat, which_eye)
|
||||
*/
|
||||
static int
|
||||
plot_drawVList(dmp, vp)
|
||||
struct dm *dmp;
|
||||
register struct rt_vlist *vp;
|
||||
struct dm *dmp;
|
||||
register struct rt_vlist *vp;
|
||||
{
|
||||
static vect_t last;
|
||||
register struct rt_vlist *tvp;
|
||||
register point_t *pt_prev=NULL;
|
||||
register fastf_t dist_prev=1.0;
|
||||
register fastf_t dist;
|
||||
fastf_t delta;
|
||||
int useful = 0;
|
||||
static vect_t last;
|
||||
register struct rt_vlist *tvp;
|
||||
register point_t *pt_prev=NULL;
|
||||
register fastf_t dist_prev=1.0;
|
||||
register fastf_t dist;
|
||||
fastf_t delta;
|
||||
int useful = 0;
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->floating) {
|
||||
rt_vlist_to_uplot(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, &vp->l);
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->floating){
|
||||
rt_vlist_to_uplot(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, &vp->l);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* delta is used in clipping to insure clipped endpoint is slightly
|
||||
* in front of eye plane (perspective mode only).
|
||||
* This value is a SWAG that seems to work OK.
|
||||
*/
|
||||
delta = plotmat[15]*0.0001;
|
||||
if (delta < 0.0)
|
||||
delta = -delta;
|
||||
if (delta < SQRT_SMALL_FASTF)
|
||||
delta = SQRT_SMALL_FASTF;
|
||||
/* delta is used in clipping to insure clipped endpoint is slightly
|
||||
* in front of eye plane (perspective mode only).
|
||||
* This value is a SWAG that seems to work OK.
|
||||
*/
|
||||
delta = plotmat[15]*0.0001;
|
||||
if( delta < 0.0 )
|
||||
delta = -delta;
|
||||
if( delta < SQRT_SMALL_FASTF )
|
||||
delta = SQRT_SMALL_FASTF;
|
||||
|
||||
for (BU_LIST_FOR(tvp, rt_vlist, &vp->l)) {
|
||||
register int i;
|
||||
register int nused = tvp->nused;
|
||||
register int *cmd = tvp->cmd;
|
||||
register point_t *pt = tvp->pt;
|
||||
for (i = 0; i < nused; i++,cmd++,pt++) {
|
||||
static vect_t start, fin;
|
||||
switch (*cmd) {
|
||||
case RT_VLIST_POLY_START:
|
||||
case RT_VLIST_POLY_VERTNORM:
|
||||
continue;
|
||||
case RT_VLIST_POLY_MOVE:
|
||||
case RT_VLIST_LINE_MOVE:
|
||||
/* Move, not draw */
|
||||
if (dmp->dm_perspective > 0) {
|
||||
/* cannot apply perspective transformation to
|
||||
* points behind eye plane!!!!
|
||||
*/
|
||||
dist = VDOT( *pt, &plotmat[12] ) + plotmat[15];
|
||||
if (dist <= 0.0) {
|
||||
pt_prev = pt;
|
||||
dist_prev = dist;
|
||||
continue;
|
||||
} else {
|
||||
MAT4X3PNT(last, plotmat, *pt);
|
||||
dist_prev = dist;
|
||||
pt_prev = pt;
|
||||
}
|
||||
} else
|
||||
MAT4X3PNT(last, plotmat, *pt);
|
||||
continue;
|
||||
case RT_VLIST_POLY_DRAW:
|
||||
case RT_VLIST_POLY_END:
|
||||
case RT_VLIST_LINE_DRAW:
|
||||
for( BU_LIST_FOR( tvp, rt_vlist, &vp->l ) ) {
|
||||
register int i;
|
||||
register int nused = tvp->nused;
|
||||
register int *cmd = tvp->cmd;
|
||||
register point_t *pt = tvp->pt;
|
||||
for( i = 0; i < nused; i++,cmd++,pt++ ) {
|
||||
static vect_t start, fin;
|
||||
switch( *cmd ) {
|
||||
case RT_VLIST_POLY_START:
|
||||
case RT_VLIST_POLY_VERTNORM:
|
||||
continue;
|
||||
case RT_VLIST_POLY_MOVE:
|
||||
case RT_VLIST_LINE_MOVE:
|
||||
/* Move, not draw */
|
||||
if (dmp->dm_perspective > 0)
|
||||
{
|
||||
/* cannot apply perspective transformation to
|
||||
* points behind eye plane!!!!
|
||||
*/
|
||||
dist = VDOT( *pt, &plotmat[12] ) + plotmat[15];
|
||||
if( dist <= 0.0 )
|
||||
{
|
||||
pt_prev = pt;
|
||||
dist_prev = dist;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
MAT4X3PNT( last, plotmat, *pt );
|
||||
dist_prev = dist;
|
||||
pt_prev = pt;
|
||||
}
|
||||
}
|
||||
else
|
||||
MAT4X3PNT( last, plotmat, *pt );
|
||||
continue;
|
||||
case RT_VLIST_POLY_DRAW:
|
||||
case RT_VLIST_POLY_END:
|
||||
case RT_VLIST_LINE_DRAW:
|
||||
/* draw */
|
||||
if (dmp->dm_perspective > 0) {
|
||||
/* cannot apply perspective transformation to
|
||||
* points behind eye plane!!!!
|
||||
*/
|
||||
dist = VDOT( *pt, &plotmat[12] ) + plotmat[15];
|
||||
if (dist <= 0.0) {
|
||||
if (dist_prev <= 0.0) {
|
||||
/* nothing to plot */
|
||||
dist_prev = dist;
|
||||
pt_prev = pt;
|
||||
continue;
|
||||
} else {
|
||||
fastf_t alpha;
|
||||
vect_t diff;
|
||||
point_t tmp_pt;
|
||||
if (dmp->dm_perspective > 0)
|
||||
{
|
||||
/* cannot apply perspective transformation to
|
||||
* points behind eye plane!!!!
|
||||
*/
|
||||
dist = VDOT( *pt, &plotmat[12] ) + plotmat[15];
|
||||
if( dist <= 0.0 )
|
||||
{
|
||||
if( dist_prev <= 0.0 )
|
||||
{
|
||||
/* nothing to plot */
|
||||
dist_prev = dist;
|
||||
pt_prev = pt;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
fastf_t alpha;
|
||||
vect_t diff;
|
||||
point_t tmp_pt;
|
||||
|
||||
/* clip this end */
|
||||
VSUB2( diff, *pt, *pt_prev );
|
||||
alpha = (dist_prev - delta) / (dist_prev - dist);
|
||||
VJOIN1(tmp_pt, *pt_prev, alpha, diff);
|
||||
MAT4X3PNT(fin, plotmat, tmp_pt);
|
||||
}
|
||||
} else {
|
||||
if (dist_prev <= 0.0) {
|
||||
fastf_t alpha;
|
||||
vect_t diff;
|
||||
point_t tmp_pt;
|
||||
/* clip this end */
|
||||
VSUB2( diff, *pt, *pt_prev );
|
||||
alpha = (dist_prev - delta) / ( dist_prev - dist );
|
||||
VJOIN1( tmp_pt, *pt_prev, alpha, diff );
|
||||
MAT4X3PNT( fin, plotmat, tmp_pt );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist_prev <= 0.0 )
|
||||
{
|
||||
fastf_t alpha;
|
||||
vect_t diff;
|
||||
point_t tmp_pt;
|
||||
|
||||
/* clip other end */
|
||||
VSUB2( diff, *pt, *pt_prev );
|
||||
alpha = (-dist_prev + delta) / ( dist - dist_prev );
|
||||
VJOIN1( tmp_pt, *pt_prev, alpha, diff );
|
||||
MAT4X3PNT( last, plotmat, tmp_pt );
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
} else {
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
}
|
||||
}
|
||||
} else
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
VMOVE( start, last );
|
||||
VMOVE( last, fin );
|
||||
break;
|
||||
}
|
||||
if (vclip(start, fin, dmp->dm_clipmin, dmp->dm_clipmax) == 0)
|
||||
continue;
|
||||
/* clip other end */
|
||||
VSUB2( diff, *pt, *pt_prev );
|
||||
alpha = (-dist_prev + delta) / ( dist - dist_prev );
|
||||
VJOIN1( tmp_pt, *pt_prev, alpha, diff );
|
||||
MAT4X3PNT( last, plotmat, tmp_pt );
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
}
|
||||
else
|
||||
{
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
MAT4X3PNT( fin, plotmat, *pt );
|
||||
VMOVE( start, last );
|
||||
VMOVE( last, fin );
|
||||
break;
|
||||
}
|
||||
if(vclip(start, fin, dmp->dm_clipmin, dmp->dm_clipmax) == 0)
|
||||
continue;
|
||||
|
||||
if (((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D)
|
||||
pl_3line(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
(int)(start[X] * 2047),
|
||||
(int)(start[Y] * 2047),
|
||||
(int)(start[Z] * 2047),
|
||||
(int)(fin[X] * 2047),
|
||||
(int)(fin[Y] * 2047),
|
||||
(int)(fin[Z] * 2047));
|
||||
else
|
||||
pl_line(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
(int)(start[X] * 2047),
|
||||
(int)(start[Y] * 2047),
|
||||
(int)(fin[X] * 2047),
|
||||
(int)(fin[Y] * 2047));
|
||||
if(((struct plot_vars *)dmp->dm_vars.priv_vars)->is_3D)
|
||||
pl_3line( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
(int)( start[X] * 2047 ),
|
||||
(int)( start[Y] * 2047 ),
|
||||
(int)( start[Z] * 2047 ),
|
||||
(int)( fin[X] * 2047 ),
|
||||
(int)( fin[Y] * 2047 ),
|
||||
(int)( fin[Z] * 2047 ) );
|
||||
else
|
||||
pl_line( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp,
|
||||
(int)( start[X] * 2047 ),
|
||||
(int)( start[Y] * 2047 ),
|
||||
(int)( fin[X] * 2047 ),
|
||||
(int)( fin[Y] * 2047 ) );
|
||||
|
||||
useful = 1;
|
||||
}
|
||||
}
|
||||
useful = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (useful)
|
||||
return TCL_OK;
|
||||
if(useful)
|
||||
return TCL_OK;
|
||||
|
||||
return TCL_ERROR;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -491,9 +488,9 @@ plot_drawVList(dmp, vp)
|
||||
*/
|
||||
static int
|
||||
plot_normal(dmp)
|
||||
struct dm *dmp;
|
||||
struct dm *dmp;
|
||||
{
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -506,20 +503,20 @@ plot_normal(dmp)
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
plot_drawString2D( dmp, str, x, y, size, use_aspect )
|
||||
struct dm *dmp;
|
||||
register char *str;
|
||||
fastf_t x, y;
|
||||
int size;
|
||||
int use_aspect;
|
||||
struct dm *dmp;
|
||||
register char *str;
|
||||
fastf_t x, y;
|
||||
int size;
|
||||
int use_aspect;
|
||||
{
|
||||
int sx, sy;
|
||||
int sx, sy;
|
||||
|
||||
sx = x * 2047;
|
||||
sy = y + 2047;
|
||||
pl_move(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx, sy);
|
||||
pl_label(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, str);
|
||||
sx = x * 2047;
|
||||
sy = y + 2047;
|
||||
pl_move( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx, sy);
|
||||
pl_label( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, str);
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -528,98 +525,91 @@ plot_drawString2D( dmp, str, x, y, size, use_aspect )
|
||||
*/
|
||||
static int
|
||||
plot_drawLine2D( dmp, x1, y1, x2, y2 )
|
||||
struct dm *dmp;
|
||||
fastf_t x1, y1;
|
||||
fastf_t x2, y2;
|
||||
struct dm *dmp;
|
||||
fastf_t x1, y1;
|
||||
fastf_t x2, y2;
|
||||
{
|
||||
int sx1, sy1;
|
||||
int sx2, sy2;
|
||||
int sx1, sy1;
|
||||
int sx2, sy2;
|
||||
|
||||
sx1 = x1 * 2047;
|
||||
sx2 = x2 * 2047;
|
||||
sy1 = y1 + 2047;
|
||||
sy2 = y2 + 2047;
|
||||
pl_move(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx1, sy1);
|
||||
pl_cont(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx2, sy2);
|
||||
sx1 = x1 * 2047;
|
||||
sx2 = x2 * 2047;
|
||||
sy1 = y1 + 2047;
|
||||
sy2 = y2 + 2047;
|
||||
pl_move( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx1, sy1);
|
||||
pl_cont( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, sx2, sy2);
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
plot_drawPoint2D(dmp, x, y)
|
||||
struct dm *dmp;
|
||||
fastf_t x, y;
|
||||
struct dm *dmp;
|
||||
fastf_t x, y;
|
||||
{
|
||||
return plot_drawLine2D(dmp, x, y, x, y);
|
||||
return plot_drawLine2D( dmp, x, y, x, y );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
plot_setFGColor(dmp, r, g, b, strict)
|
||||
struct dm *dmp;
|
||||
unsigned char r, g, b;
|
||||
int strict;
|
||||
struct dm *dmp;
|
||||
unsigned char r, g, b;
|
||||
int strict;
|
||||
{
|
||||
pl_color(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, (int)r, (int)g, (int)b);
|
||||
return TCL_OK;
|
||||
pl_color( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, (int)r, (int)g, (int)b );
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
plot_setLineAttr(dmp, width, style)
|
||||
struct dm *dmp;
|
||||
int width;
|
||||
int style;
|
||||
struct dm *dmp;
|
||||
int width;
|
||||
int style;
|
||||
{
|
||||
dmp->dm_lineWidth = width;
|
||||
dmp->dm_lineStyle = style;
|
||||
dmp->dm_lineWidth = width;
|
||||
dmp->dm_lineStyle = style;
|
||||
|
||||
if (style == DM_DASHED_LINE)
|
||||
pl_linmod(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, "dotdashed");
|
||||
else
|
||||
pl_linmod(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, "solid");
|
||||
if(style == DM_DASHED_LINE)
|
||||
pl_linmod( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, "dotdashed");
|
||||
else
|
||||
pl_linmod( ((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp, "solid");
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
plot_debug(dmp, lvl)
|
||||
struct dm *dmp;
|
||||
struct dm *dmp;
|
||||
{
|
||||
Tcl_Obj *obj;
|
||||
dmp->dm_debugLevel = lvl;
|
||||
(void)fflush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
Tcl_AppendResult(interp, "flushed\n", (char *)NULL);
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
|
||||
dmp->dm_debugLevel = lvl;
|
||||
(void)fflush(((struct plot_vars *)dmp->dm_vars.priv_vars)->up_fp);
|
||||
Tcl_AppendStringsToObj(obj, "flushed\n", (char *)NULL);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
plot_setWinBounds(dmp, w)
|
||||
struct dm *dmp;
|
||||
register int w[];
|
||||
struct dm *dmp;
|
||||
register int w[];
|
||||
{
|
||||
/* Compute the clipping bounds */
|
||||
dmp->dm_clipmin[0] = w[0] / 2048.;
|
||||
dmp->dm_clipmax[0] = w[1] / 2047.;
|
||||
dmp->dm_clipmin[1] = w[2] / 2048.;
|
||||
dmp->dm_clipmax[1] = w[3] / 2047.;
|
||||
/* Compute the clipping bounds */
|
||||
dmp->dm_clipmin[0] = w[0] / 2048.;
|
||||
dmp->dm_clipmax[0] = w[1] / 2047.;
|
||||
dmp->dm_clipmin[1] = w[2] / 2048.;
|
||||
dmp->dm_clipmax[1] = w[3] / 2047.;
|
||||
|
||||
if (dmp->dm_zclip) {
|
||||
dmp->dm_clipmin[2] = w[4] / 2048.;
|
||||
dmp->dm_clipmax[2] = w[5] / 2047.;
|
||||
} else {
|
||||
dmp->dm_clipmin[2] = -1.0e20;
|
||||
dmp->dm_clipmax[2] = 1.0e20;
|
||||
}
|
||||
if (dmp->dm_zclip) {
|
||||
dmp->dm_clipmin[2] = w[4] / 2048.;
|
||||
dmp->dm_clipmax[2] = w[5] / 2047.;
|
||||
}else{
|
||||
dmp->dm_clipmin[2] = -1.0e20;
|
||||
dmp->dm_clipmax[2] = 1.0e20;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
+165
-197
@@ -121,190 +121,168 @@ static mat_t psmat;
|
||||
*/
|
||||
struct dm *
|
||||
ps_open(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
static int count = 0;
|
||||
struct dm *dmp;
|
||||
Tcl_Obj *obj;
|
||||
static int count = 0;
|
||||
struct dm *dmp;
|
||||
|
||||
BU_GETSTRUCT(dmp, dm);
|
||||
if (dmp == DM_NULL)
|
||||
return DM_NULL;
|
||||
BU_GETSTRUCT(dmp, dm);
|
||||
if(dmp == DM_NULL)
|
||||
return DM_NULL;
|
||||
|
||||
*dmp = dm_ps; /* struct copy */
|
||||
*dmp = dm_ps; /* struct copy */
|
||||
|
||||
dmp->dm_vars.priv_vars = (genptr_t)bu_calloc(1, sizeof(struct ps_vars), "ps_open: ps_vars");
|
||||
if (dmp->dm_vars.priv_vars == (genptr_t)NULL) {
|
||||
bu_free(dmp, "ps_open: dmp");
|
||||
return DM_NULL;
|
||||
dmp->dm_vars.priv_vars = (genptr_t)bu_calloc(1, sizeof(struct ps_vars), "ps_open: ps_vars");
|
||||
if(dmp->dm_vars.priv_vars == (genptr_t)NULL){
|
||||
bu_free(dmp, "ps_open: dmp");
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
bu_vls_init(&dmp->dm_pathName);
|
||||
bu_vls_init(&dmp->dm_tkName);
|
||||
bu_vls_printf(&dmp->dm_pathName, ".dm_ps%d", count++);
|
||||
bu_vls_printf(&dmp->dm_tkName, "dm_ps%d", count++);
|
||||
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator);
|
||||
|
||||
/* set defaults */
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, "Courier");
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, "No Title");
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, "LIBDM dm-ps");
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale = 0.0791;
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth = 4;
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->zclip = 0;
|
||||
|
||||
/* skip first argument */
|
||||
--argc; ++argv;
|
||||
|
||||
/* Process any options */
|
||||
while(argv[0] != (char *)0 && argv[0][0] == '-'){
|
||||
switch(argv[0][1]){
|
||||
case 'f': /* font */
|
||||
if(argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, &argv[0][2]);
|
||||
else{
|
||||
argv++;
|
||||
if(argv[0] == (char *)0 || argv[0][0] == '-'){
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 't': /* title */
|
||||
if(argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, &argv[0][2]);
|
||||
else{
|
||||
argv++;
|
||||
if(argv[0] == (char *)0 || argv[0][0] == '-'){
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 'c': /* creator */
|
||||
if(argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, &argv[0][2]);
|
||||
else{
|
||||
argv++;
|
||||
if(argv[0] == (char *)0 || argv[0][0] == '-'){
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 's': /* size in inches */
|
||||
{
|
||||
fastf_t size;
|
||||
|
||||
if(argv[0][2] != '\0')
|
||||
sscanf(&argv[0][2], "%lf", &size);
|
||||
else{
|
||||
argv++;
|
||||
if(argv[0] == (char *)0 || argv[0][0] == '-'){
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}else
|
||||
sscanf(&argv[0][0], "%lf", &size);
|
||||
}
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
|
||||
bu_vls_init(&dmp->dm_pathName);
|
||||
bu_vls_init(&dmp->dm_tkName);
|
||||
bu_vls_printf(&dmp->dm_pathName, ".dm_ps%d", count++);
|
||||
bu_vls_printf(&dmp->dm_tkName, "dm_ps%d", count++);
|
||||
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title);
|
||||
bu_vls_init(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator);
|
||||
|
||||
/* set defaults */
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, "Courier");
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, "No Title");
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, "LIBDM dm-ps");
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale = 0.0791;
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth = 4;
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->zclip = 0;
|
||||
|
||||
/* skip first argument */
|
||||
--argc; ++argv;
|
||||
|
||||
/* Process any options */
|
||||
while (argv[0] != (char *)0 && argv[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case 'f': /* font */
|
||||
if (argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, &argv[0][2]);
|
||||
else {
|
||||
argv++;
|
||||
if (argv[0] == (char *)0 || argv[0][0] == '-') {
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
} else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 't': /* title */
|
||||
if (argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, &argv[0][2]);
|
||||
else {
|
||||
argv++;
|
||||
if (argv[0] == (char *)0 || argv[0][0] == '-') {
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
} else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 'c': /* creator */
|
||||
if (argv[0][2] != '\0')
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, &argv[0][2]);
|
||||
else {
|
||||
argv++;
|
||||
if (argv[0] == (char *)0 || argv[0][0] == '-') {
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
} else
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator, &argv[0][0]);
|
||||
}
|
||||
break;
|
||||
case 's': /* size in inches */
|
||||
{
|
||||
fastf_t size;
|
||||
|
||||
if (argv[0][2] != '\0')
|
||||
sscanf(&argv[0][2], "%lf", &size);
|
||||
else {
|
||||
argv++;
|
||||
if (argv[0] == (char *)0 || argv[0][0] == '-') {
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
} else
|
||||
sscanf(&argv[0][0], "%lf", &size);
|
||||
}
|
||||
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale = size * 0.017578125;
|
||||
}
|
||||
break;
|
||||
case 'l': /* line width */
|
||||
if (argv[0][2] != '\0')
|
||||
sscanf(&argv[0][2], "%d", &((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth);
|
||||
else{
|
||||
argv++;
|
||||
if (argv[0] == (char *)0 || argv[0][0] == '-') {
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
} else
|
||||
sscanf(&argv[0][0], "%d", &((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth);
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale = size * 0.017578125;
|
||||
}
|
||||
break;
|
||||
case 'l': /* line width */
|
||||
if(argv[0][2] != '\0')
|
||||
sscanf(&argv[0][2], "%d", &((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth);
|
||||
else{
|
||||
argv++;
|
||||
if(argv[0] == (char *)0 || argv[0][0] == '-'){
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}else
|
||||
sscanf(&argv[0][0], "%d", &((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth);
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
#if 0
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->zclip = 1;
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->zclip = 1;
|
||||
#else
|
||||
dmp->dm_zclip = 1;
|
||||
dmp->dm_zclip = 1;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
Tcl_AppendStringsToObj(obj, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
break;
|
||||
default:
|
||||
Tcl_AppendResult(interp, ps_usage, (char *)0);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
if(argv[0] == (char *)0){
|
||||
Tcl_AppendResult(interp, "no filename specified\n", (char *)NULL);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
if(argv[0] == (char *)0) {
|
||||
Tcl_AppendStringsToObj(obj, "no filename specified\n", (char *)NULL);
|
||||
(void)ps_close(dmp);
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname, argv[0]);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
bu_vls_strcpy(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname, argv[0]);
|
||||
|
||||
if ((((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp =
|
||||
fopen(bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname), "w")) == NULL) {
|
||||
Tcl_AppendStringsToObj(obj, "f_ps: Error opening file - ",
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->fname,
|
||||
"\n", (char *)NULL);
|
||||
(void)ps_close(dmp);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return DM_NULL;
|
||||
}
|
||||
if( (((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp =
|
||||
fopen(bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->fname), "w")) == NULL){
|
||||
Tcl_AppendResult(interp, "f_ps: Error opening file - ",
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->fname,
|
||||
"\n", (char *)NULL);
|
||||
(void)ps_close(dmp);
|
||||
return DM_NULL;
|
||||
}
|
||||
|
||||
setbuf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp,
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->ttybuf );
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp,"%%!PS-Adobe-1.0\n\
|
||||
setbuf( ((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp,
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->ttybuf );
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp,"%%!PS-Adobe-1.0\n\
|
||||
%%begin(plot)\n\
|
||||
%%%%DocumentFonts: %s\n",
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font));
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font));
|
||||
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "%%%%Title: %s\n",
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title));
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "%%%%Title: %s\n",
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->title));
|
||||
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "\
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "\
|
||||
%%%%Creator: %s\n\
|
||||
%%%%BoundingBox: 0 0 324 324 %% 4.5in square, for TeX\n\
|
||||
%%%%EndComments\n\
|
||||
\n",
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator));
|
||||
\n", bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->creator));
|
||||
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "\
|
||||
fprintf(((struct ps_vars *)dmp->dm_vars.priv_vars)->ps_fp, "\
|
||||
%d setlinewidth\n\
|
||||
\n\
|
||||
%% Sizes, made functions to avoid scaling if not needed\n\
|
||||
@@ -326,19 +304,17 @@ ps_open(argc, argv)
|
||||
\n\
|
||||
FntH setfont\n\
|
||||
NEWPG\n\
|
||||
",
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth,
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale,
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale);
|
||||
", ((struct ps_vars *)dmp->dm_vars.priv_vars)->linewidth,
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
bu_vls_addr(&((struct ps_vars *)dmp->dm_vars.priv_vars)->font),
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale,
|
||||
((struct ps_vars *)dmp->dm_vars.priv_vars)->scale);
|
||||
|
||||
bn_mat_idn(psmat);
|
||||
bn_mat_idn(psmat);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return dmp;
|
||||
return dmp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -409,33 +385,25 @@ struct dm *dmp;
|
||||
mat_t mat;
|
||||
int which_eye;
|
||||
{
|
||||
Tcl_Obj *obj;
|
||||
if(((struct ps_vars *)dmp->dm_vars.priv_vars)->debug){
|
||||
struct bu_vls tmp_vls;
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
Tcl_AppendResult(interp, "ps_loadMatrix()\n", (char *)NULL);
|
||||
|
||||
if (((struct ps_vars *)dmp->dm_vars.priv_vars)->debug) {
|
||||
struct bu_vls tmp_vls;
|
||||
bu_vls_init(&tmp_vls);
|
||||
bu_vls_printf(&tmp_vls, "which eye = %d\t", which_eye);
|
||||
bu_vls_printf(&tmp_vls, "transformation matrix = \n");
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[0], mat[4], mat[8],mat[12]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[1], mat[5], mat[9],mat[13]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[2], mat[6], mat[10],mat[14]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[3], mat[7], mat[11],mat[15]);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "ps_loadMatrix()\n", (char *)NULL);
|
||||
Tcl_AppendResult(interp, bu_vls_addr(&tmp_vls), (char *)NULL);
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
bu_vls_init(&tmp_vls);
|
||||
bu_vls_printf(&tmp_vls, "which eye = %d\t", which_eye);
|
||||
bu_vls_printf(&tmp_vls, "transformation matrix = \n");
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[0], mat[4], mat[8],mat[12]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[1], mat[5], mat[9],mat[13]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[2], mat[6], mat[10],mat[14]);
|
||||
bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[3], mat[7], mat[11],mat[15]);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, bu_vls_addr(&tmp_vls), (char *)NULL);
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
bn_mat_copy(psmat, mat);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return TCL_OK;
|
||||
bn_mat_copy(psmat, mat);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+239
-397
File diff suppressed because it is too large
Load Diff
+26
-38
@@ -59,32 +59,27 @@ Tcl_Interp *interp;
|
||||
|
||||
HIDDEN int
|
||||
dm_validXType_tcl(clientData, interp, argc, argv)
|
||||
ClientData clientData;
|
||||
Tcl_Interp *interp;
|
||||
int argc;
|
||||
char **argv;
|
||||
ClientData clientData;
|
||||
Tcl_Interp *interp;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct bu_vls vls;
|
||||
Tcl_Obj *obj;
|
||||
struct bu_vls vls;
|
||||
|
||||
bu_vls_init(&vls);
|
||||
bu_vls_init(&vls);
|
||||
|
||||
if(argc != 3){
|
||||
bu_vls_printf(&vls, "helplib dm_validXType");
|
||||
Tcl_Eval(interp, bu_vls_addr(&vls));
|
||||
bu_vls_free(&vls);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if(argc != 3){
|
||||
bu_vls_printf(&vls, "helplib dm_validXType");
|
||||
Tcl_Eval(interp, bu_vls_addr(&vls));
|
||||
bu_vls_free(&vls);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
bu_vls_printf(&vls, "%d", dm_validXType(argv[1], argv[2]));
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
Tcl_AppendStringsToObj(obj, bu_vls_addr(&vls), (char *)NULL);
|
||||
bu_vls_free(&vls);
|
||||
bu_vls_printf(&vls, "%d", dm_validXType(argv[1], argv[2]));
|
||||
Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
|
||||
bu_vls_free(&vls);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return TCL_OK;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
@@ -94,23 +89,16 @@ Tcl_Interp *interp;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
Tcl_Obj *obj;
|
||||
if (argc != 2) {
|
||||
struct bu_vls vls;
|
||||
|
||||
if (argc != 2) {
|
||||
struct bu_vls vls;
|
||||
bu_vls_init(&vls);
|
||||
bu_vls_printf(&vls, "helplib dm_bestXType");
|
||||
Tcl_Eval(interp, bu_vls_addr(&vls));
|
||||
bu_vls_free(&vls);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
bu_vls_init(&vls);
|
||||
bu_vls_printf(&vls, "helplib dm_bestXType");
|
||||
Tcl_Eval(interp, bu_vls_addr(&vls));
|
||||
bu_vls_free(&vls);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
obj = Tcl_GetObjResult(interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
Tcl_AppendStringsToObj(obj, dm_bestXType(argv[1]), (char *)NULL);
|
||||
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
return TCL_OK;
|
||||
Tcl_AppendResult(interp, dm_bestXType(argv[1]), (char *)NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
+1
-2
@@ -20,14 +20,13 @@
|
||||
bomb \
|
||||
db_open db_scan db_lookup db_io db_alloc db_walk \
|
||||
db_path db_tree db_comb db_anim db_match \
|
||||
db5_scan db5_io db5_comb db5_alloc \
|
||||
db5_scan \
|
||||
memalloc \
|
||||
table dir tree prep \
|
||||
g_arb g_ars g_ebm g_ell g_half g_pg g_rec g_sph g_nurb \
|
||||
g_tgc g_torus g_vol g_arbn g_part g_pipe g_nmg \
|
||||
g_rpc g_rhc g_epa g_ehy g_eto g_grip g_hf g_dsp g_sketch g_extrude \
|
||||
g_submodel g_cline g_bot \
|
||||
db5_types db5_bin \
|
||||
cmd mater roots spectrum \
|
||||
rtlex vlist regionfix htbl \
|
||||
nmg_mk nmg_misc nmg_bool nmg_eval nmg_inter nmg_plot nmg_ck \
|
||||
|
||||
+10
-6
@@ -90,7 +90,7 @@ char *argv[];
|
||||
}
|
||||
|
||||
/* Scan the database */
|
||||
db_dirbuild( dbip );
|
||||
db_scan(dbip, (int (*)())db_diradd, 1);
|
||||
|
||||
for( i=2 ; i<argc ; i++ )
|
||||
{
|
||||
@@ -99,7 +99,12 @@ char *argv[];
|
||||
printf( "%s\n" , argv[i] );
|
||||
|
||||
dp = db_lookup( dbip , argv[i] , 1 );
|
||||
if( rt_db_get_internal( &ip, dp, dbip, NULL ) < 0 ) {
|
||||
if( db_get_external( &ep , dp , dbip ) )
|
||||
{
|
||||
bu_log( "db_get_external failed for %s\n" , argv[i] );
|
||||
continue;
|
||||
}
|
||||
if( rt_comb_v4_import( &ip , &ep , NULL ) < 0 ) {
|
||||
bu_log("import of %s failed\n", dp->d_namep);
|
||||
continue;
|
||||
}
|
||||
@@ -110,7 +115,6 @@ char *argv[];
|
||||
if( ip.idb_type != ID_COMBINATION )
|
||||
{
|
||||
bu_log( "idb_type = %d\n" , ip.idb_type );
|
||||
rt_db_free_internal( &ip );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -152,7 +156,7 @@ char *argv[];
|
||||
fwrite( ep.ext_buf, ep.ext_nbytes, 1, fp );
|
||||
fclose(fp);
|
||||
}
|
||||
bu_free_external( &ep );
|
||||
db_free_external( &ep );
|
||||
bu_vls_free( &file );
|
||||
|
||||
/* Convert internal back to external, and write both to files */
|
||||
@@ -166,11 +170,11 @@ char *argv[];
|
||||
fwrite( ep.ext_buf, ep.ext_nbytes, 1, fp );
|
||||
fclose(fp);
|
||||
}
|
||||
bu_free_external( &ep );
|
||||
db_free_external( &ep );
|
||||
bu_vls_free( &file );
|
||||
|
||||
/* Test the lumberjacks */
|
||||
rt_db_free_internal( &ip );
|
||||
ip.idb_meth->ft_ifree( &ip );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* C O N S T . C
|
||||
*
|
||||
* Constants used by the ray tracing library.
|
||||
*
|
||||
* Source -
|
||||
* SECAD/VLD Computing Consortium, Bldg 394
|
||||
* The U. S. Army Ballistic Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005
|
||||
*
|
||||
* Copyright Notice -
|
||||
* This software is Copyright (C) 1989 by the United States Army.
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static char RCSmat[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "machine.h"
|
||||
#include "vmath.h"
|
||||
#include "raytrace.h"
|
||||
|
||||
CONST double rt_pi = 3.14159265358979323846; /* pi */
|
||||
CONST double rt_twopi = 6.28318530717958647692; /* pi*2 */
|
||||
CONST double rt_halfpi = 1.57079632679489661923; /* pi/2 */
|
||||
CONST double rt_quarterpi=0.78539816339744830961; /* pi/4 */
|
||||
CONST double rt_invpi = 0.318309886183790671538; /* 1/pi */
|
||||
CONST double rt_inv2pi = 0.159154943091895335769; /* 1/(pi*2) */
|
||||
CONST double rt_inv4pi = 0.07957747154594766788; /* 1/(pi*4) */
|
||||
|
||||
CONST double rt_inv255 = 1.0/255.0;
|
||||
|
||||
CONST double rt_degtorad = 0.0174532925199433; /* (pi*2)/360 */
|
||||
CONST double rt_radtodeg = 57.29577951308230698802; /* 360/(pi*2) */
|
||||
|
||||
CONST mat_t rt_identity = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
|
||||
#ifdef ipsc860
|
||||
/* Hack to work around the broken iPSC/860 loader. It doesn't
|
||||
* see the definition in global.c, probably because there is no
|
||||
* .text or .data there that it needs.
|
||||
*/
|
||||
struct rt_g rt_g;
|
||||
#endif
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* D B _ A L L O C 5 . C
|
||||
*
|
||||
* Handle disk space allocation in the BRL-CAD v5 database.
|
||||
*
|
||||
* Author -
|
||||
* Michael John Muuss
|
||||
*
|
||||
* Source -
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5068 USA
|
||||
*
|
||||
* Distribution Status -
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef USE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
#include "db5.h"
|
||||
#include "raytrace.h"
|
||||
|
||||
#include "./debug.h"
|
||||
|
||||
/*
|
||||
* D B 5 _ W R I T E _ F R E E
|
||||
*
|
||||
* Create a v5 database "free" object of the specified size,
|
||||
* and place it at the indicated location in the database.
|
||||
*
|
||||
* Returns -
|
||||
* 0 OK
|
||||
* -1 Fail
|
||||
*/
|
||||
int
|
||||
db5_write_free( struct db_i *dbip, struct directory *dp, long length )
|
||||
{
|
||||
struct bu_external ext;
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
RT_CK_DIR(dp);
|
||||
|
||||
BU_INIT_EXTERNAL( &ext );
|
||||
db5_make_free_object( &ext, length );
|
||||
|
||||
if( dp->d_flags & RT_DIR_INMEM ) {
|
||||
bcopy( (char *)ext.ext_buf, dp->d_un.ptr, ext.ext_nbytes );
|
||||
bu_free_external( &ext );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( db_write( dbip, (char *)ext.ext_buf, ext.ext_nbytes, dp->d_addr ) < 0 ) {
|
||||
bu_free_external( &ext );
|
||||
return -1;
|
||||
}
|
||||
bu_free_external( &ext );
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ R E A L L O C
|
||||
*
|
||||
* Change the size of a v5 database object.
|
||||
*
|
||||
* If the object is getting smaller, break it into two pieces,
|
||||
* and write out free objects for both.
|
||||
* The caller is expected to re-write new data on the first one.
|
||||
*
|
||||
* If the object is getting larger, seek a suitable "hole" large enough
|
||||
* to hold it, throwing back any surplus, properly marked.
|
||||
*
|
||||
* If the object is getting larger and there is no suitable "hole"
|
||||
* in the database, extend the file, write a free object in the
|
||||
* new space, and write a free object in the old space.
|
||||
*
|
||||
* There is no point to trying to extend in place, that would require
|
||||
* two searches through the memory map, and doesn't save any disk I/O.
|
||||
*
|
||||
* Returns -
|
||||
* 0 OK
|
||||
* -1 Failure
|
||||
*/
|
||||
int
|
||||
db5_realloc( struct db_i *dbip, struct directory *dp, struct bu_external *ep )
|
||||
{
|
||||
long baseaddr;
|
||||
long baselen;
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
RT_CK_DIR(dp);
|
||||
BU_CK_EXTERNAL(ep);
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) dbip=x%x, dp=x%x, ext_nbytes=%ld\n",
|
||||
dp->d_namep, dbip, dp, ep->ext_nbytes );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes&7, ==, 0 );
|
||||
|
||||
if( ep->ext_nbytes == dp->d_len ) return 0;
|
||||
|
||||
baseaddr = dp->d_addr;
|
||||
baselen = dp->d_len;
|
||||
|
||||
if( dp->d_flags & RT_DIR_INMEM ) {
|
||||
if( dp->d_un.ptr ) {
|
||||
dp->d_un.ptr = bu_realloc( dp->d_un.ptr,
|
||||
ep->ext_nbytes, "db5_realloc() d_un.ptr" );
|
||||
} else {
|
||||
dp->d_un.ptr = bu_malloc( ep->ext_nbytes, "db5_realloc() d_un.ptr" );
|
||||
}
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( dbip->dbi_read_only ) {
|
||||
bu_log("db5_realloc(%s) on READ-ONLY file\n", dp->d_namep);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* If the object is getting smaller... */
|
||||
if( ep->ext_nbytes < dp->d_len ) {
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) object is getting smaller\n", dp->d_namep);
|
||||
|
||||
/* First, erase front half of storage to desired size. */
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
|
||||
/* Second, erase back half of storage to remainder. */
|
||||
dp->d_addr = baseaddr + ep->ext_nbytes;
|
||||
dp->d_len = baselen - ep->ext_nbytes;
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
|
||||
/* Finally, update tables */
|
||||
rt_memfree( &(dbip->dbi_freep), dp->d_len, dp->d_addr );
|
||||
dp->d_addr = baseaddr;
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The object is getting larger... */
|
||||
|
||||
/* Start by zapping existing database object into a free object */
|
||||
if( dp->d_addr != -1L ) {
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) releasing storage at x%x, len=%d\n", dp->d_namep, dp->d_addr, dp->d_len);
|
||||
|
||||
rt_memfree( &(dbip->dbi_freep), dp->d_len, dp->d_addr );
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
baseaddr = dp->d_addr = -1L; /* sanity */
|
||||
}
|
||||
|
||||
/* Can we obtain a free block somewhere else? */
|
||||
{
|
||||
struct mem_map *mmp;
|
||||
long newaddr;
|
||||
|
||||
if( (mmp = rt_memalloc_nosplit( &(dbip->dbi_freep), ep->ext_nbytes )) != MAP_NULL ) {
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) obtained free block at x%x, len=%d\n", dp->d_namep, mmp->m_addr, mmp->m_size );
|
||||
BU_ASSERT_LONG( mmp->m_size, >=, ep->ext_nbytes );
|
||||
if( mmp->m_size == ep->ext_nbytes ) {
|
||||
/* No need to reformat, existing free object is perfect */
|
||||
dp->d_addr = mmp->m_addr;
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
return 0;
|
||||
}
|
||||
newaddr = mmp->m_addr;
|
||||
if( mmp->m_size > ep->ext_nbytes ) {
|
||||
/* Reformat and free the surplus */
|
||||
dp->d_addr = mmp->m_addr + ep->ext_nbytes;
|
||||
dp->d_len = mmp->m_size - ep->ext_nbytes;
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) returning surplus at x%x, len=%d\n", dp->d_namep, dp->d_addr, dp->d_len );
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
rt_memfree( &(dbip->dbi_freep), dp->d_len, dp->d_addr );
|
||||
/* mmp is invalid beyond here! */
|
||||
}
|
||||
dp->d_addr = newaddr;
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
/* Erase the new place */
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) utilizing free block at addr=x%x, len=%d\n", dp->d_namep, dp->d_addr, dp->d_len);
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* No free storage of the desired size, extend the database */
|
||||
dp->d_addr = dbip->dbi_eof;
|
||||
dbip->dbi_eof += ep->ext_nbytes;
|
||||
dp->d_len = ep->ext_nbytes;
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_realloc(%s) extending database addr=x%x, len=%d\n", dp->d_namep, dp->d_addr, dp->d_len);
|
||||
if( db5_write_free( dbip, dp, dp->d_len ) < 0 ) return -1;
|
||||
return 0;
|
||||
}
|
||||
-331
@@ -1,331 +0,0 @@
|
||||
/*
|
||||
* D B 5 _ B I N . C
|
||||
*
|
||||
* Purpose -
|
||||
* Handle bulk binary objects
|
||||
*
|
||||
* Author -
|
||||
* Paul J. Tanenbaum
|
||||
* Source -
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5066
|
||||
*
|
||||
* Copyright Notice -
|
||||
* This software is Copyright (C) 2000 by the United States Army.
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static char RCSell[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
#include "db5.h"
|
||||
#include "nmg.h"
|
||||
#include "raytrace.h"
|
||||
#include "nurb.h"
|
||||
#include "rtgeom.h"
|
||||
#include "./debug.h"
|
||||
|
||||
/*
|
||||
* R T _ B I N U N I F _ I M P O R T 5
|
||||
*
|
||||
* Import a uniform-array binary object from the database format to
|
||||
* the internal structure.
|
||||
*/
|
||||
int
|
||||
rt_binunif_import5( struct rt_db_internal *ip,
|
||||
CONST unsigned char minor_type,
|
||||
CONST struct bu_external *ep,
|
||||
CONST struct db_i *dbip )
|
||||
{
|
||||
struct rt_binunif_internal *bip;
|
||||
int i;
|
||||
unsigned char *srcp;
|
||||
unsigned long *ldestp;
|
||||
unsigned short *sdestp;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
/*
|
||||
* There's no particular size to expect
|
||||
*
|
||||
* BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 3*4 );
|
||||
*/
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_BINUNIF;
|
||||
ip->idb_meth = 0;
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_binunif_internal),
|
||||
"rt_binunif_internal");
|
||||
|
||||
bip = (struct rt_binunif_internal *)ip->idb_ptr;
|
||||
bip->magic = RT_BINUNIF_INTERNAL_MAGIC;
|
||||
bip->type = minor_type;
|
||||
|
||||
/*
|
||||
* Convert from database (network) to internal (host) format
|
||||
*/
|
||||
switch (bip->type) {
|
||||
case DB5_MINORTYPE_BINU_FLOAT:
|
||||
bip->count = ep->ext_nbytes/SIZEOF_NETWORK_FLOAT;
|
||||
bip->u.uint8 = (unsigned char *) bu_malloc( bip->count * sizeof(float),
|
||||
"rt_binunif_internal" );
|
||||
ntohf( (unsigned char *) bip->u.uint8,
|
||||
ep->ext_buf, ep->ext_nbytes/SIZEOF_NETWORK_FLOAT );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_DOUBLE:
|
||||
bip->count = ep->ext_nbytes/SIZEOF_NETWORK_DOUBLE;
|
||||
bip->u.uint8 = (unsigned char *) bu_malloc( bip->count * sizeof(float),
|
||||
"rt_binunif_internal" );
|
||||
ntohd( (unsigned char *) bip->u.uint8,
|
||||
ep->ext_buf, ep->ext_nbytes/SIZEOF_NETWORK_DOUBLE );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_8BITINT:
|
||||
case DB5_MINORTYPE_BINU_8BITINT_U:
|
||||
bip->count = ep->ext_nbytes;
|
||||
bip->u.uint8 = (unsigned char *) bu_malloc( ep->ext_nbytes,
|
||||
"rt_binunif_internal" );
|
||||
bcopy( (char *) bip->u.uint8, (char *) ep->ext_buf, ep->ext_nbytes );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_16BITINT:
|
||||
case DB5_MINORTYPE_BINU_16BITINT_U:
|
||||
bip->count = ep->ext_nbytes/2;
|
||||
bip->u.uint8 = (unsigned char *) bu_malloc( ep->ext_nbytes,
|
||||
"rt_binunif_internal" );
|
||||
srcp = (unsigned char *) ep->ext_buf;
|
||||
sdestp = (unsigned short *) bip->u.uint8;
|
||||
for (i = 0; i < bip->count; ++i, ++sdestp, srcp += 2) {
|
||||
*sdestp = bu_gshort( (unsigned char *) srcp );
|
||||
}
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_32BITINT:
|
||||
case DB5_MINORTYPE_BINU_32BITINT_U:
|
||||
bip->count = ep->ext_nbytes/4;
|
||||
bip->u.uint8 = (unsigned char *) bu_malloc( ep->ext_nbytes,
|
||||
"rt_binunif_internal" );
|
||||
srcp = (unsigned char *) ep->ext_buf;
|
||||
ldestp = (unsigned long *) bip->u.uint8;
|
||||
for (i = 0; i < bip->count; ++i, ++ldestp, srcp += 4) {
|
||||
*ldestp = bu_glong( (unsigned char *) srcp );
|
||||
}
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_64BITINT:
|
||||
case DB5_MINORTYPE_BINU_64BITINT_U:
|
||||
bu_log("rt_binunif_import5() Can't handle 64-bit integers yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N E X P M _ I M P O R T 5
|
||||
*
|
||||
* Import an experimental binary object from the database format to
|
||||
* the internal structure.
|
||||
*/
|
||||
int
|
||||
rt_binexpm_import5( struct rt_db_internal *ip,
|
||||
CONST unsigned char minor_type,
|
||||
CONST struct bu_external *ep,
|
||||
CONST struct db_i *dbip )
|
||||
{
|
||||
bu_log("rt_binexpm_import5() not implemented yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N M I M E _ I M P O R T 5
|
||||
*
|
||||
* Import a MIME-typed binary object from the database format to
|
||||
* the internal structure.
|
||||
*/
|
||||
int
|
||||
rt_binmime_import5( struct rt_db_internal *ip,
|
||||
CONST unsigned char minor_type,
|
||||
CONST struct bu_external *ep,
|
||||
CONST struct db_i *dbip )
|
||||
{
|
||||
bu_log("rt_binmime_import5() not implemented yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N _ I M P O R T 5
|
||||
*
|
||||
* Wrapper for importing binary objects from the database format to
|
||||
* the internal structure.
|
||||
*/
|
||||
int
|
||||
rt_bin_import5( struct rt_db_internal *ip,
|
||||
CONST unsigned char major_type,
|
||||
CONST unsigned char minor_type,
|
||||
CONST struct bu_external *ep,
|
||||
CONST struct db_i *dbip )
|
||||
{
|
||||
switch (major_type) {
|
||||
case DB5_MAJORTYPE_BINARY_EXPM:
|
||||
return rt_binexpm_import5( ip, minor_type, ep, dbip );
|
||||
case DB5_MAJORTYPE_BINARY_UNIF:
|
||||
return rt_binunif_import5( ip, minor_type, ep, dbip );
|
||||
case DB5_MAJORTYPE_BINARY_MIME:
|
||||
return rt_binmime_import5( ip, minor_type, ep, dbip );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N U N I F _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_binunif_export5( struct bu_external *ep,
|
||||
CONST struct rt_db_internal *ip,
|
||||
CONST struct db_i *dbip )
|
||||
{
|
||||
struct rt_binunif_internal *bip;
|
||||
int i;
|
||||
unsigned char *destp;
|
||||
unsigned long *lsrcp;
|
||||
unsigned short *ssrcp;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_BINUNIF ) return -1;
|
||||
bip = (struct rt_binunif_internal *)ip->idb_ptr;
|
||||
RT_CK_BINUNIF(bip);
|
||||
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
|
||||
/*
|
||||
* Convert from internal (host) to database (network) format
|
||||
*/
|
||||
switch (bip->type) {
|
||||
case DB5_MINORTYPE_BINU_FLOAT:
|
||||
ep->ext_nbytes = bip->count * SIZEOF_NETWORK_FLOAT;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes,
|
||||
"binunif external");
|
||||
htonf( ep->ext_buf, (unsigned char *) bip->u.uint8, bip->count );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_DOUBLE:
|
||||
ep->ext_nbytes = bip->count * SIZEOF_NETWORK_DOUBLE;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes,
|
||||
"binunif external");
|
||||
htond( ep->ext_buf, (unsigned char *) bip->u.uint8, bip->count );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_8BITINT:
|
||||
case DB5_MINORTYPE_BINU_8BITINT_U:
|
||||
ep->ext_nbytes = bip->count;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes,
|
||||
"binunif external");
|
||||
bcopy( (char *) ep->ext_buf, (char *) bip->u.uint8, bip->count );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_16BITINT:
|
||||
case DB5_MINORTYPE_BINU_16BITINT_U:
|
||||
ep->ext_nbytes = bip->count * 2;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes,
|
||||
"binunif external");
|
||||
|
||||
ssrcp = (unsigned short *) bip->u.uint8;
|
||||
destp = (unsigned char *) ep->ext_buf;
|
||||
for (i = 0; i < bip->count; ++i, ++destp, ssrcp += 2)
|
||||
(void) bu_pshort( destp, *ssrcp );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_32BITINT:
|
||||
case DB5_MINORTYPE_BINU_32BITINT_U:
|
||||
ep->ext_nbytes = bip->count * 4;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes,
|
||||
"binunif external");
|
||||
|
||||
lsrcp = (unsigned long *) bip->u.uint8;
|
||||
destp = (unsigned char *) ep->ext_buf;
|
||||
for (i = 0; i < bip->count; ++i, ++destp, lsrcp += 4)
|
||||
(void) bu_plong( destp, *lsrcp );
|
||||
break;
|
||||
case DB5_MINORTYPE_BINU_64BITINT:
|
||||
case DB5_MINORTYPE_BINU_64BITINT_U:
|
||||
bu_log("rt_binunif_export5() Can't handle 64-bit integers yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N U N I F _ D E S C R I B E
|
||||
*
|
||||
* Make human-readable formatted presentation of this solid.
|
||||
* First line describes type of solid.
|
||||
* Additional lines are indented one tab, and give parameter values.
|
||||
*/
|
||||
int
|
||||
rt_binunif_describe( struct bu_vls *str,
|
||||
CONST struct rt_db_internal *ip,
|
||||
int verbose,
|
||||
double mm2local )
|
||||
{
|
||||
register struct rt_binunif_internal *bip;
|
||||
char buf[256];
|
||||
unsigned short wid;
|
||||
|
||||
bip = (struct rt_binunif_internal *) ip->idb_ptr;
|
||||
RT_CK_BINUNIF(bip);
|
||||
bu_vls_strcat( str, "uniform-array binary object (BINUNIF)\n");
|
||||
wid = (bip->type & DB5_MINORTYPE_BINU_WID_MASK) >> 4;
|
||||
switch (wid) {
|
||||
case 0:
|
||||
sprintf( buf, "%d ", bip->count ); break;
|
||||
case 1:
|
||||
sprintf( buf, "%d pairs of ", bip->count / 2 ); break;
|
||||
case 2:
|
||||
sprintf( buf, "%d triples of ", bip->count / 3 ); break;
|
||||
case 3:
|
||||
sprintf( buf, "%d quadruples of ", bip->count / 4 ); break;
|
||||
}
|
||||
bu_vls_strcat( str, buf );
|
||||
switch (bip->type & DB5_MINORTYPE_BINU_ATM_MASK) {
|
||||
case DB5_MINORTYPE_BINU_FLOAT:
|
||||
bu_vls_strcat( str, "floats\n"); break;
|
||||
case DB5_MINORTYPE_BINU_DOUBLE:
|
||||
bu_vls_strcat( str, "doubles\n"); break;
|
||||
case DB5_MINORTYPE_BINU_8BITINT:
|
||||
bu_vls_strcat( str, "chars\n"); break;
|
||||
case DB5_MINORTYPE_BINU_16BITINT:
|
||||
bu_vls_strcat( str, "16-bit ints\n"); break;
|
||||
case DB5_MINORTYPE_BINU_32BITINT:
|
||||
bu_vls_strcat( str, "32-bit ints\n"); break;
|
||||
case DB5_MINORTYPE_BINU_64BITINT:
|
||||
bu_vls_strcat( str, "64-bit ints\n"); break;
|
||||
case DB5_MINORTYPE_BINU_8BITINT_U:
|
||||
bu_vls_strcat( str, "unsigned chars\n"); break;
|
||||
case DB5_MINORTYPE_BINU_16BITINT_U:
|
||||
bu_vls_strcat( str, "unsigned 16-bit ints\n"); break;
|
||||
case DB5_MINORTYPE_BINU_32BITINT_U:
|
||||
bu_vls_strcat( str, "unsigned 32-bit ints\n"); break;
|
||||
case DB5_MINORTYPE_BINU_64BITINT_U:
|
||||
bu_vls_strcat( str, "unsigned 64-bit ints\n"); break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B I N U N I F _ I F R E E
|
||||
*
|
||||
* Free the storage associated with the rt_db_internal version of this solid.
|
||||
*/
|
||||
void
|
||||
rt_binunif_ifree( struct rt_db_internal *ip )
|
||||
{
|
||||
struct rt_binunif_internal *bip;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
bip = (struct rt_binunif_internal *)ip->idb_ptr;
|
||||
RT_CK_BINUNIF(bip);
|
||||
bu_free( (genptr_t) bip->u.uint8, "binunif ifree" );
|
||||
bu_free( ip->idb_ptr, "binunif ifree" );
|
||||
ip->idb_ptr = GENPTR_NULL;
|
||||
}
|
||||
@@ -1,628 +0,0 @@
|
||||
/*
|
||||
* D B 5 _ C O M B . C
|
||||
*
|
||||
* Handle import/export of combinations (union tree) in v5 format.
|
||||
*
|
||||
* The on-disk record looks like this:
|
||||
* width byte
|
||||
* n matricies (only non-identity matricies stored).
|
||||
* n leaves
|
||||
* len of RPN expression. (len=0 signals all-union expression)
|
||||
* depth of stack
|
||||
* Section 1: matricies
|
||||
* Section 2: leaves
|
||||
* Section 3: (Optional) RPN expression.
|
||||
*
|
||||
* Encoding of a matrix is (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE) bytes,
|
||||
* in network order (big-Endian, IEEE double precision).
|
||||
*
|
||||
* Author -
|
||||
* Michael John Muuss
|
||||
*
|
||||
* Source -
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5068 USA
|
||||
*
|
||||
* Distribution Status -
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef USE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
#include "bn.h"
|
||||
#include "db5.h"
|
||||
#include "raytrace.h"
|
||||
|
||||
#include "./debug.h"
|
||||
|
||||
|
||||
struct db_tree_counter_state {
|
||||
long magic;
|
||||
long n_mat; /* # leaves with non-identity matricies */
|
||||
long n_leaf; /* # leaf nodes */
|
||||
long n_oper; /* # operator nodes */
|
||||
long leafbytes; /* # bytes for name section */
|
||||
int non_union_seen; /* boolean, 1 = non-unions seen */
|
||||
};
|
||||
#define DB_TREE_COUNTER_STATE_MAGIC 0x64546373 /* dTcs */
|
||||
#define DB_CK_TREE_COUNTER_STATE(_p) BU_CKMAG(_p, DB_TREE_COUNTER_STATE_MAGIC, "db_tree_counter_state");
|
||||
|
||||
/*
|
||||
* D B _ T R E E _ C O U N T E R
|
||||
*
|
||||
* Count number of non-identity matricies,
|
||||
* number of leaf nodes, number of operator nodes, etc.
|
||||
*
|
||||
* Returns -
|
||||
* maximum depth of stack needed to unpack this tree, if serialized.
|
||||
*
|
||||
* Notes -
|
||||
* We over-estimate the size of the width fields used for
|
||||
* holding the matrix subscripts.
|
||||
* The caller is responsible for correcting by saying:
|
||||
* tcsp->leafbytes -= tcsp->n_leaf * (8 - db5_enc_len[wid]);
|
||||
*/
|
||||
long
|
||||
db_tree_counter( CONST union tree *tp, struct db_tree_counter_state *tcsp )
|
||||
{
|
||||
long ldepth, rdepth;
|
||||
|
||||
RT_CK_TREE(tp);
|
||||
DB_CK_TREE_COUNTER_STATE(tcsp);
|
||||
|
||||
switch( tp->tr_op ) {
|
||||
case OP_DB_LEAF:
|
||||
tcsp->n_leaf++;
|
||||
if( tp->tr_l.tl_mat ) tcsp->n_mat++;
|
||||
/* Over-estimate storage requirement for matrix # */
|
||||
tcsp->leafbytes += strlen(tp->tr_l.tl_name) + 1 + 8;
|
||||
return 1;
|
||||
|
||||
case OP_NOT:
|
||||
/* Unary ops */
|
||||
tcsp->n_oper++;
|
||||
tcsp->non_union_seen = 1;
|
||||
return 1 + db_tree_counter( tp->tr_b.tb_left, tcsp );
|
||||
|
||||
case OP_UNION:
|
||||
/* This node is known to be a binary op */
|
||||
tcsp->n_oper++;
|
||||
ldepth = db_tree_counter( tp->tr_b.tb_left, tcsp );
|
||||
rdepth = db_tree_counter( tp->tr_b.tb_right, tcsp );
|
||||
if( ldepth > rdepth ) return ldepth;
|
||||
return rdepth;
|
||||
|
||||
case OP_INTERSECT:
|
||||
case OP_SUBTRACT:
|
||||
case OP_XOR:
|
||||
/* This node is known to be a binary op */
|
||||
tcsp->n_oper++;
|
||||
tcsp->non_union_seen = 1;
|
||||
ldepth = db_tree_counter( tp->tr_b.tb_left, tcsp );
|
||||
rdepth = db_tree_counter( tp->tr_b.tb_right, tcsp );
|
||||
if( ldepth > rdepth ) return ldepth;
|
||||
return rdepth;
|
||||
|
||||
default:
|
||||
bu_log("db_tree_counter: bad op %d\n", tp->tr_op);
|
||||
bu_bomb("db_tree_counter\n");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
#define DB5COMB_TOKEN_LEAF 1
|
||||
#define DB5COMB_TOKEN_UNION 2
|
||||
#define DB5COMB_TOKEN_INTERSECT 3
|
||||
#define DB5COMB_TOKEN_SUBTRACT 4
|
||||
#define DB5COMB_TOKEN_XOR 5
|
||||
#define DB5COMB_TOKEN_NOT 6
|
||||
|
||||
struct rt_comb_v5_serialize_state {
|
||||
long magic;
|
||||
long mat_num;
|
||||
unsigned char *matp;
|
||||
unsigned char *leafp;
|
||||
unsigned char *exprp;
|
||||
int wid;
|
||||
};
|
||||
#define RT_COMB_V5_SERIALIZE_STATE_MAGIC 0x43357373 /* C5ss */
|
||||
#define RT_CK_COMB_V5_SERIALIZE_STATE(_p) BU_CKMAG(_p, RT_COMB_V5_SERIALIZE_STATE_MAGIC, "rt_comb_v5_serialize_state")
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ V 5 _ S E R I A L I Z E
|
||||
*
|
||||
* In one single pass through the tree, serialize out all three
|
||||
* output sections at once.
|
||||
*/
|
||||
void
|
||||
rt_comb_v5_serialize(
|
||||
const union tree *tp,
|
||||
struct rt_comb_v5_serialize_state *ssp)
|
||||
{
|
||||
int n;
|
||||
|
||||
RT_CK_TREE(tp);
|
||||
RT_CK_COMB_V5_SERIALIZE_STATE(ssp);
|
||||
|
||||
switch( tp->tr_op ) {
|
||||
case OP_DB_LEAF:
|
||||
/*
|
||||
* Encoding of the leaf:
|
||||
* A null-terminated name string, and
|
||||
* the matrix subscript. -1 == identity.
|
||||
*/
|
||||
n = strlen(tp->tr_l.tl_name) + 1;
|
||||
bcopy( tp->tr_l.tl_name, ssp->leafp, n );
|
||||
ssp->leafp += n;
|
||||
|
||||
if( tp->tr_l.tl_mat )
|
||||
n = ssp->mat_num++;
|
||||
else
|
||||
n = -1;
|
||||
ssp->leafp = db5_encode_length( ssp->leafp, n, ssp->wid );
|
||||
|
||||
/* Encoding of the matrix */
|
||||
if( tp->tr_l.tl_mat ) {
|
||||
htond( ssp->matp,
|
||||
(const unsigned char *)tp->tr_l.tl_mat,
|
||||
ELEMENTS_PER_MAT );
|
||||
ssp->matp += ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE;
|
||||
}
|
||||
|
||||
/* Encoding of the "leaf" operator */
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_LEAF;
|
||||
return;
|
||||
|
||||
case OP_NOT:
|
||||
/* Unary ops */
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_left, ssp );
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_NOT;
|
||||
return;
|
||||
|
||||
case OP_UNION:
|
||||
/* This node is known to be a binary op */
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_left, ssp );
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_right, ssp );
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_UNION;
|
||||
return;
|
||||
case OP_INTERSECT:
|
||||
/* This node is known to be a binary op */
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_left, ssp );
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_right, ssp );
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_INTERSECT;
|
||||
return;
|
||||
case OP_SUBTRACT:
|
||||
/* This node is known to be a binary op */
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_left, ssp );
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_right, ssp );
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_SUBTRACT;
|
||||
return;
|
||||
case OP_XOR:
|
||||
/* This node is known to be a binary op */
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_left, ssp );
|
||||
rt_comb_v5_serialize( tp->tr_b.tb_right, ssp );
|
||||
if( ssp->exprp )
|
||||
*ssp->exprp++ = DB5COMB_TOKEN_XOR;
|
||||
return;
|
||||
|
||||
default:
|
||||
bu_log("rt_comb_v5_serialize: bad op %d\n", tp->tr_op);
|
||||
bu_bomb("rt_comb_v5_serialize\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_comb_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_comb_internal *comb;
|
||||
struct db_tree_counter_state tcs;
|
||||
struct rt_comb_v5_serialize_state ss;
|
||||
long max_stack_depth;
|
||||
long need;
|
||||
int rpn_len = 0; /* # items in RPN expression */
|
||||
int wid;
|
||||
unsigned char *cp;
|
||||
unsigned char *leafp_end;
|
||||
struct bu_attribute_value_set *avsp;
|
||||
struct bu_vls value;
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
if( ip->idb_type != ID_COMBINATION ) bu_bomb("rt_comb_export5() type not ID_COMBINATION");
|
||||
comb = (struct rt_comb_internal *)ip->idb_ptr;
|
||||
RT_CK_COMB(comb);
|
||||
|
||||
/* First pass -- count number of non-identity matricies,
|
||||
* number of leaf nodes, number of operator nodes.
|
||||
*/
|
||||
bzero( (char *)&tcs, sizeof(tcs) );
|
||||
tcs.magic = DB_TREE_COUNTER_STATE_MAGIC;
|
||||
max_stack_depth = db_tree_counter( comb->tree, &tcs );
|
||||
|
||||
if( tcs.non_union_seen ) {
|
||||
/* RPN expression needs one byte for each leaf or operator node */
|
||||
rpn_len = tcs.n_leaf + tcs.n_oper;
|
||||
} else {
|
||||
rpn_len = 0;
|
||||
}
|
||||
|
||||
wid = db5_select_length_encoding(
|
||||
tcs.n_mat | tcs.n_leaf | tcs.leafbytes |
|
||||
rpn_len | max_stack_depth );
|
||||
|
||||
/* Apply correction factor to tcs.leafbytes now that we know 'wid'.
|
||||
* Ignore the slight chance that a smaller 'wid' might now be possible.
|
||||
*/
|
||||
tcs.leafbytes -= tcs.n_leaf * (8 - db5_enc_len[wid]);
|
||||
|
||||
bu_log("wid=%d, n_max=%d, n_leaf=%d, n_oper=%d, leafbytes=%d, non_union_seen=%d, max_stack_depth=%d, rpn_len=%d\n",
|
||||
wid, tcs.n_mat, tcs.n_leaf, tcs.n_oper, tcs.leafbytes, tcs.non_union_seen, max_stack_depth, rpn_len);
|
||||
|
||||
/* Second pass -- determine amount of on-disk storage needed */
|
||||
need = 1 + /* width code */
|
||||
db5_enc_len[wid] + /* size for nmatricies */
|
||||
db5_enc_len[wid] + /* size for nleaves */
|
||||
db5_enc_len[wid] + /* size for leafbytes */
|
||||
db5_enc_len[wid] + /* size for len of RPN */
|
||||
db5_enc_len[wid] + /* size for max_stack_depth */
|
||||
tcs.n_mat * (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE) + /* sizeof matrix array */
|
||||
tcs.leafbytes + /* size for leaf nodes */
|
||||
rpn_len; /* storage for RPN expression */
|
||||
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = need;
|
||||
#if 0
|
||||
ep->ext_buf = bu_malloc( need, "rt_comb_export5 ext_buf" );
|
||||
#else
|
||||
ep->ext_buf = bu_calloc( 1, need, "rt_comb_export5 ext_buf" );
|
||||
#endif
|
||||
|
||||
/* Build combination's on-disk header section */
|
||||
cp = (unsigned char *)ep->ext_buf;
|
||||
*cp++ = wid;
|
||||
cp = db5_encode_length( cp, tcs.n_mat, wid );
|
||||
cp = db5_encode_length( cp, tcs.n_leaf, wid );
|
||||
cp = db5_encode_length( cp, tcs.leafbytes, wid );
|
||||
cp = db5_encode_length( cp, rpn_len, wid );
|
||||
cp = db5_encode_length( cp, max_stack_depth, wid );
|
||||
|
||||
/*
|
||||
* The output format has three sections:
|
||||
* Section 1: matricies
|
||||
* Section 2: leaf nodes
|
||||
* Section 3: Optional RPN expression
|
||||
*
|
||||
* We have pre-computed the exact size of all three sections,
|
||||
* so they can all be searialized together in one pass.
|
||||
* Establish pointers to the start of each section.
|
||||
*/
|
||||
ss.magic = RT_COMB_V5_SERIALIZE_STATE_MAGIC;
|
||||
ss.wid = wid;
|
||||
ss.mat_num = 0;
|
||||
ss.matp = cp;
|
||||
ss.leafp = cp + tcs.n_mat * (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE);
|
||||
leafp_end = ss.leafp + tcs.leafbytes;
|
||||
if( rpn_len )
|
||||
ss.exprp = leafp_end;
|
||||
else
|
||||
ss.exprp = NULL;
|
||||
|
||||
rt_comb_v5_serialize( comb->tree, &ss );
|
||||
|
||||
BU_ASSERT_LONG( ss.mat_num, ==, tcs.n_mat );
|
||||
BU_ASSERT_PTR( ss.matp, ==, cp + tcs.n_mat * (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE) );
|
||||
BU_ASSERT_PTR( ss.leafp, ==, leafp_end );
|
||||
if( rpn_len )
|
||||
BU_ASSERT_PTR( ss.exprp, <=, ((unsigned char *)ep->ext_buf) + ep->ext_nbytes );
|
||||
|
||||
/* Encode all the other stuff as attributes. */
|
||||
bu_vls_init( &value );
|
||||
/* WARNING: We remove const from the ip pointer!!! */
|
||||
avsp = (struct bu_attribute_value_set *)&ip->idb_avs;
|
||||
if( avsp->magic != BU_AVS_MAGIC )
|
||||
bu_avs_init( avsp, 32, "rt_comb v5 attributes" );
|
||||
if( comb->region_flag ) {
|
||||
/* Presence of this attribute means this comb is a region. */
|
||||
/* Current code values are 0, 1, and 2; all are regions. */
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d", comb->is_fastgen );
|
||||
bu_avs_add_vls( avsp, "region", &value );
|
||||
}
|
||||
if( comb->inherit )
|
||||
bu_avs_add( avsp, "inherit", "1" );
|
||||
if( comb->rgb_valid ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d/%d/%d", V3ARGS(comb->rgb) );
|
||||
bu_avs_add_vls( avsp, "rgb", &value );
|
||||
}
|
||||
/* optical shader string goes out in Tcl format */
|
||||
if( bu_vls_strlen( &comb->shader ) > 0 )
|
||||
bu_avs_add_vls( avsp, "oshader", &comb->shader );
|
||||
if( bu_vls_strlen( &comb->material ) > 0 )
|
||||
bu_avs_add_vls( avsp, "material", &comb->material );
|
||||
if( comb->temperature > 0 ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%f", comb->temperature );
|
||||
bu_avs_add_vls( avsp, "temp", &value );
|
||||
}
|
||||
/* GIFT compatability */
|
||||
if( comb->region_id != 0 ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d", comb->region_id );
|
||||
bu_avs_add_vls( avsp, "region_id", &value );
|
||||
}
|
||||
if( comb->aircode != 0 ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d", comb->aircode );
|
||||
bu_avs_add_vls( avsp, "aircode", &value );
|
||||
}
|
||||
if( comb->GIFTmater != 0 ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d", comb->GIFTmater );
|
||||
bu_avs_add_vls( avsp, "giftmater", &value );
|
||||
}
|
||||
if( comb->los != 0 ) {
|
||||
bu_vls_trunc( &value, 0 );
|
||||
bu_vls_printf( &value, "%d", comb->los );
|
||||
bu_avs_add_vls( avsp, "los", &value );
|
||||
}
|
||||
|
||||
if(getuid()==53)bu_avs_print( avsp, "comb v5 attributes");
|
||||
|
||||
bu_vls_free( &value );
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ I M P O R T 5
|
||||
*
|
||||
* Read a combination object in v5 external (on-disk) format,
|
||||
* and convert it into the internal format described in h/rtgeom.h
|
||||
*
|
||||
* This is an unusual conversion, because some of the data is taken
|
||||
* from attributes, not just from the object body.
|
||||
* By the time this is called, the attributes will already have been
|
||||
* cracked into ip->idb_avs, we get the attributes from there.
|
||||
*
|
||||
* Returns -
|
||||
* 0 OK
|
||||
* -1 FAIL
|
||||
*/
|
||||
int
|
||||
rt_comb_import5(ip, ep, mat, dbip)
|
||||
struct rt_db_internal *ip;
|
||||
const struct bu_external *ep;
|
||||
const mat_t mat;
|
||||
const struct db_i *dbip;
|
||||
{
|
||||
struct rt_comb_internal *comb;
|
||||
unsigned char *cp;
|
||||
int wid;
|
||||
long nmat, nleaf, rpn_len, max_stack_depth;
|
||||
long leafbytes;
|
||||
unsigned char *matp;
|
||||
unsigned char *leafp;
|
||||
unsigned char *leafp_end;
|
||||
unsigned char *exprp;
|
||||
#define MAX_V5_STACK 8000
|
||||
union tree *stack[MAX_V5_STACK];
|
||||
union tree **sp; /* stack pointer */
|
||||
const char *ap;
|
||||
int i;
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ip->idb_type = ID_COMBINATION;
|
||||
ip->idb_meth = &rt_functab[ID_COMBINATION];
|
||||
BU_GETSTRUCT( comb, rt_comb_internal );
|
||||
ip->idb_ptr = (genptr_t)comb;
|
||||
comb->magic = RT_COMB_MAGIC;
|
||||
bu_vls_init( &comb->shader );
|
||||
bu_vls_init( &comb->material );
|
||||
comb->temperature = -1;
|
||||
|
||||
cp = ep->ext_buf;
|
||||
wid = *cp++;
|
||||
cp += db5_decode_length( &nmat, cp, wid );
|
||||
cp += db5_decode_length( &nleaf, cp, wid );
|
||||
cp += db5_decode_length( &leafbytes, cp, wid );
|
||||
cp += db5_decode_length( &rpn_len, cp, wid );
|
||||
cp += db5_decode_length( &max_stack_depth, cp, wid );
|
||||
matp = cp;
|
||||
leafp = cp + nmat * (ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE);
|
||||
exprp = leafp + leafbytes;
|
||||
leafp_end = exprp;
|
||||
bu_log("nmat=%d, nleaf=%d, rpn_len=%d, max_stack_depth=%d\n", nmat, nleaf, rpn_len, max_stack_depth);
|
||||
|
||||
if( rpn_len == 0 ) {
|
||||
int i;
|
||||
for( i = nleaf-1; i >= 0; i-- ) {
|
||||
union tree *tp;
|
||||
int mi;
|
||||
|
||||
BU_GETUNION( tp, tree );
|
||||
tp->tr_l.magic = RT_TREE_MAGIC;
|
||||
tp->tr_l.tl_op = OP_DB_LEAF;
|
||||
tp->tr_l.tl_name = bu_strdup( (const char *)leafp );
|
||||
leafp += strlen( (const char *)leafp) + 1;
|
||||
|
||||
/* Get matrix index */
|
||||
leafp += db5_decode_signed( &mi, leafp, wid );
|
||||
|
||||
if( mi < 0 ) {
|
||||
/* Signal identity matrix */
|
||||
tp->tr_l.tl_mat = NULL;
|
||||
} else {
|
||||
/* Unpack indicated matrix mi */
|
||||
BU_ASSERT_LONG( mi, <, nmat );
|
||||
tp->tr_l.tl_mat = (matp_t)bu_malloc(
|
||||
sizeof(mat_t), "v5comb mat");
|
||||
ntohd( (unsigned char *)tp->tr_l.tl_mat,
|
||||
&matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE],
|
||||
ELEMENTS_PER_MAT);
|
||||
}
|
||||
|
||||
if( comb->tree == TREE_NULL ) {
|
||||
comb->tree = tp;
|
||||
} else {
|
||||
union tree *unionp;
|
||||
BU_GETUNION( unionp, tree );
|
||||
unionp->tr_b.magic = RT_TREE_MAGIC;
|
||||
unionp->tr_b.tb_op = OP_UNION;
|
||||
unionp->tr_b.tb_left = comb->tree;
|
||||
unionp->tr_b.tb_right = tp;
|
||||
comb->tree = unionp;
|
||||
}
|
||||
}
|
||||
BU_ASSERT_PTR( leafp, ==, leafp_end );
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bring the RPN expression back from the disk,
|
||||
* populating leaves and matricies in the order they are encountered.
|
||||
*/
|
||||
if( max_stack_depth > MAX_V5_STACK ) {
|
||||
bu_log("Combination needs stack depth %d, only have %d, aborted\n",
|
||||
max_stack_depth, MAX_V5_STACK);
|
||||
return -1;
|
||||
}
|
||||
sp = &stack[0];
|
||||
|
||||
for( i=0; i < rpn_len; i++,exprp++ ) {
|
||||
union tree *tp;
|
||||
int mi;
|
||||
|
||||
BU_GETUNION( tp, tree );
|
||||
tp->tr_b.magic = RT_TREE_MAGIC;
|
||||
|
||||
switch( *exprp ) {
|
||||
case DB5COMB_TOKEN_LEAF:
|
||||
tp->tr_l.tl_op = OP_DB_LEAF;
|
||||
tp->tr_l.tl_name = bu_strdup( (const char *)leafp );
|
||||
leafp += strlen( (const char *)leafp) + 1;
|
||||
|
||||
/* Get matrix index */
|
||||
mi = bu_glong( leafp );
|
||||
leafp += 4;
|
||||
|
||||
if( mi < 0 ) {
|
||||
/* Signal identity matrix */
|
||||
tp->tr_l.tl_mat = NULL;
|
||||
} else {
|
||||
/* Unpack indicated matrix mi */
|
||||
BU_ASSERT_LONG( mi, <, nmat );
|
||||
tp->tr_l.tl_mat = (matp_t)bu_malloc(
|
||||
sizeof(mat_t), "v5comb mat");
|
||||
ntohd( (unsigned char *)tp->tr_l.tl_mat,
|
||||
&matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE],
|
||||
ELEMENTS_PER_MAT);
|
||||
}
|
||||
break;
|
||||
|
||||
case DB5COMB_TOKEN_UNION:
|
||||
case DB5COMB_TOKEN_INTERSECT:
|
||||
case DB5COMB_TOKEN_SUBTRACT:
|
||||
case DB5COMB_TOKEN_XOR:
|
||||
/* These are all binary operators */
|
||||
tp->tr_b.tb_regionp = REGION_NULL;
|
||||
tp->tr_b.tb_right = *--sp;
|
||||
RT_CK_TREE(tp->tr_b.tb_right);
|
||||
tp->tr_b.tb_left = *--sp;
|
||||
RT_CK_TREE(tp->tr_b.tb_left);
|
||||
switch( *exprp ) {
|
||||
case DB5COMB_TOKEN_UNION:
|
||||
tp->tr_b.tb_op = OP_UNION;
|
||||
break;
|
||||
case DB5COMB_TOKEN_INTERSECT:
|
||||
tp->tr_b.tb_op = OP_INTERSECT;
|
||||
break;
|
||||
case DB5COMB_TOKEN_SUBTRACT:
|
||||
tp->tr_b.tb_op = OP_SUBTRACT;
|
||||
break;
|
||||
case DB5COMB_TOKEN_XOR:
|
||||
tp->tr_b.tb_op = OP_XOR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DB5COMB_TOKEN_NOT:
|
||||
/* This is a unary operator */
|
||||
tp->tr_b.tb_regionp = REGION_NULL;
|
||||
tp->tr_b.tb_left = *--sp;
|
||||
RT_CK_TREE(tp->tr_b.tb_left);
|
||||
tp->tr_b.tb_right = TREE_NULL;
|
||||
tp->tr_b.tb_op = OP_NOT;
|
||||
break;
|
||||
default:
|
||||
bu_log("rt_comb_import5() unknown RPN expression token=%d, import aborted\n", *exprp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Push this node on the stack */
|
||||
*sp++ = tp;
|
||||
}
|
||||
BU_ASSERT_PTR( leafp, ==, leafp_end );
|
||||
|
||||
/* There should only be one thing left on the stack, the result */
|
||||
BU_ASSERT_PTR( sp, ==, &stack[1] );
|
||||
|
||||
comb->tree = stack[0];
|
||||
RT_CK_TREE(comb->tree);
|
||||
|
||||
finish:
|
||||
if( ip->idb_avs.magic != BU_AVS_MAGIC ) return 0; /* OK */
|
||||
if(getuid()==53) bu_avs_print( &ip->idb_avs, "comb5" );
|
||||
|
||||
/* Unpack the attributes */
|
||||
if( (ap = bu_avs_get( &ip->idb_avs, "rgb" )) != NULL ) {
|
||||
int ibuf[3];
|
||||
if( sscanf( ap, "%d/%d/%d", ibuf, ibuf+1, ibuf+2 ) == 3 ) {
|
||||
VMOVE( comb->rgb, ibuf );
|
||||
comb->rgb_valid = 1;
|
||||
} else {
|
||||
bu_log("unable to parse 'rgb' attribute '%s'\n", ap);
|
||||
}
|
||||
}
|
||||
if( (ap = bu_avs_get( &ip->idb_avs, "region" )) != NULL ) {
|
||||
int ibuf[1];
|
||||
if( sscanf( ap, "%d", ibuf ) == 1 ) {
|
||||
/* Presence of this attribute implies it is a region */
|
||||
comb->region_flag = 1;
|
||||
/* Value of this parameter is the FASTGEN code */
|
||||
comb->is_fastgen = ibuf[0];
|
||||
} else {
|
||||
bu_log("unable to parse 'region' attribute '%s'\n", ap);
|
||||
}
|
||||
}
|
||||
if( (ap = bu_avs_get( &ip->idb_avs, "oshader" )) != NULL ) {
|
||||
bu_vls_strcat( &comb->shader, ap );
|
||||
}
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
-1075
File diff suppressed because it is too large
Load Diff
+577
-103
@@ -14,7 +14,7 @@
|
||||
* Public Domain, Distribution Unlimited.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
static char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -35,6 +35,333 @@ static const char RCSid[] = "@(#)$Header$ (ARL)";
|
||||
|
||||
#include "./debug.h"
|
||||
|
||||
#if 0
|
||||
BU_EXTERN(CONST unsigned char *db5_get_raw_internal_ptr, (struct db5_raw_internal *rip, CONST unsigned char *ip));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* D B 5 _ H E A D E R _ I S _ V A L I D
|
||||
*
|
||||
* Verify that this is a valid header for a BRL-CAD v5 database.
|
||||
*
|
||||
* Returns -
|
||||
* 0 Not valid v5 header
|
||||
* 1 Valid v5 header
|
||||
*/
|
||||
int
|
||||
db5_header_is_valid( hp )
|
||||
CONST unsigned char *hp;
|
||||
{
|
||||
CONST struct db5_ondisk_header *odp = (CONST struct db5_ondisk_header *)hp;
|
||||
|
||||
if( odp->db5h_magic1 != DB5HDR_MAGIC1 ) return 0;
|
||||
if( hp[7] != DB5HDR_MAGIC2 ) return 0;
|
||||
|
||||
/* hflags */
|
||||
if( (odp->db5h_hflags & DB5HDR_HFLAGS_DLI_MASK) != DB5HDR_HFLAGS_DLI_HEADER_OBJECT )
|
||||
return 0;
|
||||
if( (odp->db5h_hflags & DB5HDR_HFLAGS_NAME_PRESENT) ) return 0;
|
||||
if( ((odp->db5h_hflags & DB5HDR_HFLAGS_OBJECT_WIDTH_MASK) >> DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT)
|
||||
!= DB5HDR_WIDTHCODE_8BIT ) return 0;
|
||||
|
||||
/* iflags */
|
||||
if( (odp->db5h_iflags & DB5HDR_IFLAGS_ZZZ_MASK) != DB5HDR_IFLAGS_ZZZ_UNCOMPRESSED ) return 0;
|
||||
if( odp->db5h_iflags & DB5HDR_IFLAGS_ATTRIBUTES_PRESENT ) return 0;
|
||||
if( odp->db5h_iflags & DB5HDR_IFLAGS_BODY_PRESENT ) return 0;
|
||||
if( ((odp->db5h_iflags & DB5HDR_IFLAGS_INTERIOR_WIDTH_MASK) >> DB5HDR_IFLAGS_INTERIOR_WIDTH_SHIFT)
|
||||
!= DB5HDR_WIDTHCODE_8BIT ) return 0;
|
||||
|
||||
/* major and minor type */
|
||||
if( odp->db5h_major_type != DB5HDR_MAJORTYPE_RESERVED ) return 0;
|
||||
if( odp->db5h_minor_type != 0 ) return 0;
|
||||
|
||||
/* Check length, known to be 8-bit. Header len=1 8-byte chunk. */
|
||||
if( hp[5] != 1 ) return 0;
|
||||
|
||||
/* Ensure pad is zero */
|
||||
if( hp[6] != 0 ) return 0;
|
||||
|
||||
return 1; /* valid */
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ S E L E C T _ L E N G T H _ E N C O D I N G
|
||||
*
|
||||
* Given a number to encode, decide which is the smallest encoding format
|
||||
* which will contain it.
|
||||
*/
|
||||
int
|
||||
db5_select_length_encoding( len )
|
||||
long len;
|
||||
{
|
||||
if( len <= 255 ) return DB5HDR_WIDTHCODE_8BIT;
|
||||
if( len <= 65535 ) return DB5HDR_WIDTHCODE_16BIT;
|
||||
if( len < 0x7ffffffe ) return DB5HDR_WIDTHCODE_32BIT;
|
||||
return DB5HDR_WIDTHCODE_64BIT;
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ D E C O D E _ L E N G T H
|
||||
*
|
||||
* Given a variable-width length field in network order (XDR),
|
||||
* store it in *lenp.
|
||||
*
|
||||
* Note that for object_length the returned number needs to be
|
||||
* multiplied by 8, while for the other lengths, it is already a byte count.
|
||||
*
|
||||
* Returns -
|
||||
* The number of bytes of input that were decoded.
|
||||
*/
|
||||
int
|
||||
db5_decode_length( lenp, cp, format )
|
||||
long *lenp;
|
||||
CONST unsigned char *cp;
|
||||
int format;
|
||||
{
|
||||
switch( format ) {
|
||||
case DB5HDR_WIDTHCODE_8BIT:
|
||||
*lenp = (*cp);
|
||||
return 1;
|
||||
case DB5HDR_WIDTHCODE_16BIT:
|
||||
*lenp = BU_GSHORT(cp);
|
||||
return 2;
|
||||
case DB5HDR_WIDTHCODE_32BIT:
|
||||
*lenp = BU_GLONG(cp);
|
||||
return 4;
|
||||
case DB5HDR_WIDTHCODE_64BIT:
|
||||
#if 0
|
||||
if( sizeof(long) >= 8 ) {
|
||||
*lenp = BU_GLONGLONG(cp);
|
||||
return 8;
|
||||
}
|
||||
#endif
|
||||
bu_bomb("db5_decode_length(): encountered 64-bit length on 32-bit machine\n");
|
||||
}
|
||||
bu_bomb("db5_decode_length(): unknown width code\n");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ E N C O D E _ L E N G T H
|
||||
*
|
||||
* Given a value and a variable-width format spec,
|
||||
* store it in network order (XDR).
|
||||
*
|
||||
* Returns -
|
||||
* pointer to next available byte.
|
||||
*/
|
||||
unsigned char *
|
||||
db5_encode_length( cp, val, format )
|
||||
unsigned char *cp;
|
||||
long val;
|
||||
int format;
|
||||
{
|
||||
switch( format ) {
|
||||
case DB5HDR_WIDTHCODE_8BIT:
|
||||
*cp = val & 0xFF;
|
||||
return cp+1;
|
||||
case DB5HDR_WIDTHCODE_16BIT:
|
||||
return bu_pshort( cp, (short)val );
|
||||
case DB5HDR_WIDTHCODE_32BIT:
|
||||
return bu_plong( cp, val );
|
||||
case DB5HDR_WIDTHCODE_64BIT:
|
||||
bu_bomb("db5_encode_length(): encountered 64-bit length\n");
|
||||
}
|
||||
bu_bomb("db5_encode_length(): unknown width code\n");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ C R A C K _ D I S K _ H E A D E R
|
||||
*
|
||||
* Returns -
|
||||
* 0 on success
|
||||
* -1 on error
|
||||
*/
|
||||
int
|
||||
db5_crack_disk_header( rip, cp )
|
||||
struct db5_raw_internal *rip;
|
||||
CONST unsigned char *cp;
|
||||
{
|
||||
if( cp[0] != DB5HDR_MAGIC1 ) return 0;
|
||||
|
||||
/* hflags */
|
||||
rip->h_dli = (cp[1] & DB5HDR_HFLAGS_DLI_MASK);
|
||||
rip->h_object_width = (cp[1] & DB5HDR_HFLAGS_OBJECT_WIDTH_MASK) >>
|
||||
DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT;
|
||||
rip->h_name_present = (cp[1] & DB5HDR_HFLAGS_NAME_PRESENT);
|
||||
|
||||
/* iflags */
|
||||
rip->i_object_width = (cp[2] & DB5HDR_IFLAGS_INTERIOR_WIDTH_MASK) >>
|
||||
DB5HDR_IFLAGS_INTERIOR_WIDTH_SHIFT;
|
||||
rip->i_attributes_present = (cp[2] & DB5HDR_IFLAGS_ATTRIBUTES_PRESENT);
|
||||
rip->i_body_present = (cp[2] & DB5HDR_IFLAGS_BODY_PRESENT);
|
||||
rip->i_zzz = (cp[2] & DB5HDR_IFLAGS_ZZZ_MASK);
|
||||
|
||||
rip->major_type = cp[3];
|
||||
rip->minor_type = cp[4];
|
||||
|
||||
if(rt_g.debug&DEBUG_DB) bu_log("db5_crack_disk_header() h_dli=%d, h_object_width=%d, h_name_present=%d, i_object_width=%d, i_attributes_present=%d, i_body_present=%d, i_zzz=%d, major=%d, minor=%d\n",
|
||||
rip->h_dli,
|
||||
rip->h_object_width,
|
||||
rip->h_name_present,
|
||||
rip->i_object_width,
|
||||
rip->i_attributes_present,
|
||||
rip->i_body_present,
|
||||
rip->i_zzz,
|
||||
rip->major_type,
|
||||
rip->minor_type );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ G E T _ R A W _ I N T E R N A L _ P T R
|
||||
*
|
||||
* Returns -
|
||||
* on success, pointer to first unused byte
|
||||
* NULL, on error
|
||||
*/
|
||||
CONST unsigned char *
|
||||
db5_get_raw_internal_ptr( rip, ip )
|
||||
struct db5_raw_internal *rip;
|
||||
unsigned char * CONST ip;
|
||||
{
|
||||
CONST unsigned char *cp = ip;
|
||||
|
||||
if( db5_crack_disk_header( rip, cp ) < 0 ) return NULL;
|
||||
cp += sizeof(struct db5_ondisk_header);
|
||||
|
||||
cp += db5_decode_length( &rip->object_length, cp, rip->h_object_width );
|
||||
rip->object_length <<= 3; /* cvt 8-byte chunks to byte count */
|
||||
|
||||
/* Verify trailing magic number */
|
||||
if( ip[rip->object_length-1] != DB5HDR_MAGIC2 ) {
|
||||
bu_log("db5_get_raw_internal_ptr() bad magic2\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Grab name, if present */
|
||||
if( rip->h_name_present ) {
|
||||
cp += db5_decode_length( &rip->name_length, cp, rip->i_object_width );
|
||||
rip->name = (char *)cp; /* discard CONST */
|
||||
cp += rip->name_length;
|
||||
} else {
|
||||
rip->name_length = 0;
|
||||
rip->name = NULL;
|
||||
}
|
||||
|
||||
/* Point to object interior, if present */
|
||||
if( rip->i_attributes_present || rip->i_body_present ) {
|
||||
/* interior_length will include any pad bytes but not magic2 */
|
||||
/* Because it may be compressed, we don't know exact len yet */
|
||||
rip->interior_length = cp - rip->buf - 1;
|
||||
rip->interior = (unsigned char *)cp; /* discard CONST */
|
||||
} else {
|
||||
rip->interior_length = 0;
|
||||
rip->interior = NULL;
|
||||
}
|
||||
|
||||
rip->buf = NULL; /* no buffer needs freeing */
|
||||
|
||||
return ip + rip->object_length;
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ G E T _ R A W _ I N T E R N A L _ F P
|
||||
*
|
||||
* Returns -
|
||||
* 0 on success
|
||||
* -1 on EOF
|
||||
* -2 on error
|
||||
*/
|
||||
int
|
||||
db5_get_raw_internal_fp( rip, fp )
|
||||
struct db5_raw_internal *rip;
|
||||
FILE *fp;
|
||||
{
|
||||
struct db5_ondisk_header header;
|
||||
unsigned char lenbuf[8];
|
||||
int count;
|
||||
int used;
|
||||
long want, got;
|
||||
unsigned char *cp;
|
||||
|
||||
if( fread( (unsigned char *)&header, sizeof header, 1, fp ) != 1 ) {
|
||||
if( feof(fp) ) return -1;
|
||||
bu_log("db5_get_raw_internal_fp(): fread header error\n");
|
||||
return -2;
|
||||
}
|
||||
if( db5_crack_disk_header( rip, (unsigned char *)&header ) < 0 )
|
||||
return -2;
|
||||
used = sizeof(header);
|
||||
|
||||
switch( rip->h_object_width ) {
|
||||
case DB5HDR_WIDTHCODE_8BIT:
|
||||
count = 1;
|
||||
break;
|
||||
case DB5HDR_WIDTHCODE_16BIT:
|
||||
count = 2;
|
||||
break;
|
||||
case DB5HDR_WIDTHCODE_32BIT:
|
||||
count = 4;
|
||||
break;
|
||||
case DB5HDR_WIDTHCODE_64BIT:
|
||||
count = 8;
|
||||
}
|
||||
if( fread( lenbuf, count, 1, fp ) != 1 ) {
|
||||
bu_log("db5_get_raw_internal_fp(): fread lenbuf error\n");
|
||||
return -2;
|
||||
}
|
||||
used += db5_decode_length( &rip->object_length, lenbuf, rip->h_object_width );
|
||||
rip->object_length <<= 3; /* cvt 8-byte chunks to byte count */
|
||||
|
||||
/* Now that we finally know how large the object is, get it all */
|
||||
rip->buf = (unsigned char *)bu_malloc( rip->object_length, "raw v5 object" );
|
||||
|
||||
*((struct db5_ondisk_header *)rip->buf) = header; /* struct copy */
|
||||
bcopy( lenbuf, rip->buf+sizeof(header), count );
|
||||
|
||||
cp = rip->buf+used;
|
||||
want = rip->object_length-used;
|
||||
BU_ASSERT_LONG( want, >, 0 );
|
||||
if( (got = fread( cp, 1, want, fp )) != want ) {
|
||||
bu_log("db5_get_raw_internal_fp(), want=%ld, got=%ld, database is too short\n",
|
||||
want, got );
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Verify trailing magic number */
|
||||
if( rip->buf[rip->object_length-1] != DB5HDR_MAGIC2 ) {
|
||||
bu_log("db5_get_raw_internal_fp() bad magic2\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Grab name, if present */
|
||||
if( rip->h_name_present ) {
|
||||
cp += db5_decode_length( &rip->name_length, cp, rip->i_object_width );
|
||||
rip->name = (char *)cp;
|
||||
cp += rip->name_length;
|
||||
} else {
|
||||
rip->name_length = 0;
|
||||
rip->name = NULL;
|
||||
}
|
||||
|
||||
/* Point to object interior, if present */
|
||||
if( rip->i_attributes_present || rip->i_body_present ) {
|
||||
/* interior_length will include any pad bytes but not magic2 */
|
||||
/* Because it may be compressed, we don't know exact len yet */
|
||||
rip->interior_length = cp - rip->buf - 1;
|
||||
rip->interior = cp;
|
||||
} else {
|
||||
rip->interior_length = 0;
|
||||
rip->interior = NULL;
|
||||
}
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* D B 5 _ S C A N
|
||||
*
|
||||
@@ -72,13 +399,13 @@ genptr_t client_data; /* argument for handler */
|
||||
|
||||
if( db5_header_is_valid( cp ) == 0 ) {
|
||||
bu_log("db5_scan ERROR: %s is lacking a proper BRL-CAD v5 database header\n", dbip->dbi_filename);
|
||||
goto fatal;
|
||||
return -1;
|
||||
}
|
||||
cp += sizeof(header);
|
||||
addr = sizeof(header);
|
||||
while( addr < eof ) {
|
||||
if( (cp = db5_get_raw_internal_ptr( &raw, cp )) == NULL ) {
|
||||
goto fatal;
|
||||
return -1; /* fatal error */
|
||||
}
|
||||
(*handler)(dbip, &raw, addr, client_data);
|
||||
nrec++;
|
||||
@@ -92,13 +419,13 @@ genptr_t client_data; /* argument for handler */
|
||||
if( fread( header, sizeof header, 1, dbip->dbi_fp ) != 1 ||
|
||||
db5_header_is_valid( header ) == 0 ) {
|
||||
bu_log("db5_scan ERROR: %s is lacking a proper BRL-CAD v5 database header\n", dbip->dbi_filename);
|
||||
goto fatal;
|
||||
return -1;
|
||||
}
|
||||
for(;;) {
|
||||
addr = ftell( dbip->dbi_fp );
|
||||
if( (got = db5_get_raw_internal_fp( &raw, dbip->dbi_fp )) < 0 ) {
|
||||
if( got == -1 ) break; /* EOF */
|
||||
goto fatal;
|
||||
return -1; /* fatal error */
|
||||
}
|
||||
(*handler)(dbip, &raw, addr, client_data);
|
||||
nrec++;
|
||||
@@ -112,11 +439,8 @@ genptr_t client_data; /* argument for handler */
|
||||
}
|
||||
|
||||
dbip->dbi_nrec = nrec; /* # obj in db, not inc. header */
|
||||
return 0; /* success */
|
||||
|
||||
fatal:
|
||||
dbip->dbi_read_only = 1; /* Writing would corrupt it worse */
|
||||
return -1; /* fatal error */
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -146,19 +470,19 @@ genptr_t client_data; /* unused client_data from db_scan() */
|
||||
}
|
||||
|
||||
/* If somehow it doesn't have a name, ignore it */
|
||||
if( rip->name.ext_buf == NULL ) return;
|
||||
if( rip->name == NULL ) return;
|
||||
|
||||
if(rt_g.debug&DEBUG_DB) {
|
||||
bu_log("db5_diradd_handler(dbip=x%x, name='%s', addr=x%x, len=%d)\n",
|
||||
dbip, rip->name, laddr, rip->object_length );
|
||||
}
|
||||
|
||||
if( db_lookup( dbip, rip->name.ext_buf, LOOKUP_QUIET ) != DIR_NULL ) {
|
||||
if( db_lookup( dbip, rip->name, LOOKUP_QUIET ) != DIR_NULL ) {
|
||||
register int c;
|
||||
|
||||
bu_vls_init(&local);
|
||||
bu_vls_strcpy( &local, "A_" );
|
||||
bu_vls_strcat( &local, rip->name.ext_buf );
|
||||
bu_vls_strcat( &local, rip->name );
|
||||
cp = bu_vls_addr(&local);
|
||||
|
||||
for( c = 'A'; c <= 'Z'; c++ ) {
|
||||
@@ -183,39 +507,22 @@ genptr_t client_data; /* unused client_data from db_scan() */
|
||||
dp->d_namep = bu_strdup( cp );
|
||||
bu_vls_free( &local );
|
||||
} else {
|
||||
dp->d_namep = bu_strdup( rip->name.ext_buf );
|
||||
dp->d_namep = bu_strdup( rip->name );
|
||||
}
|
||||
dp->d_un.file_offset = laddr;
|
||||
switch( rip->major_type ) {
|
||||
case DB5_MAJORTYPE_BRLCAD:
|
||||
if( rip->minor_type == ID_COMBINATION ) {
|
||||
struct bu_attribute_value_set avs;
|
||||
|
||||
dp->d_flags = DIR_COMB;
|
||||
if( rip->attributes.ext_nbytes == 0 ) break;
|
||||
/*
|
||||
* Crack open the attributes to
|
||||
* check for the "region=" attribute.
|
||||
*/
|
||||
if( db5_import_attributes( &avs, &rip->attributes ) < 0 ) {
|
||||
bu_log("db5_diradd_handler: Bad attributes on combination '%s'\n",
|
||||
rip->name);
|
||||
break;
|
||||
}
|
||||
if( bu_avs_get( &avs, "region" ) != NULL )
|
||||
dp->d_flags = DIR_COMB|DIR_REGION;
|
||||
bu_avs_free( &avs );
|
||||
} else {
|
||||
dp->d_flags = DIR_SOLID;
|
||||
}
|
||||
case DB5HDR_MAJORTYPE_BRLCAD_NONGEOM:
|
||||
dp->d_flags = DIR_COMB;
|
||||
/* How to check for region attribute here? */
|
||||
break;
|
||||
case DB5_MAJORTYPE_BINARY_EXPM:
|
||||
case DB5_MAJORTYPE_BINARY_UNIF:
|
||||
case DB5_MAJORTYPE_BINARY_MIME:
|
||||
case DB5HDR_MAJORTYPE_BRLCAD_GEOMETRY:
|
||||
dp->d_flags = DIR_SOLID;
|
||||
break;
|
||||
case DB5HDR_MAJORTYPE_OPAQUE_BINARY:
|
||||
/* XXX Do we want to define extra flags for this? */
|
||||
dp->d_flags = 0;
|
||||
break;
|
||||
case DB5_MAJORTYPE_ATTRIBUTE_ONLY:
|
||||
case DB5HDR_MAJORTYPE_ATTRIBUTE_ONLY:
|
||||
dp->d_flags = 0;
|
||||
}
|
||||
dp->d_len = rip->object_length; /* in bytes */
|
||||
@@ -242,7 +549,6 @@ genptr_t client_data; /* unused client_data from db_scan() */
|
||||
* 0 OK
|
||||
* -1 failure
|
||||
*/
|
||||
int
|
||||
db_dirbuild( dbip )
|
||||
struct db_i *dbip;
|
||||
{
|
||||
@@ -259,73 +565,10 @@ struct db_i *dbip;
|
||||
}
|
||||
|
||||
if( db5_header_is_valid( header ) ) {
|
||||
struct directory *dp;
|
||||
struct bu_external ext;
|
||||
struct db5_raw_internal raw;
|
||||
struct bu_attribute_value_set avs;
|
||||
const char *cp;
|
||||
|
||||
/* File is v5 format */
|
||||
bu_log("WARNING: %s is BRL-CAD v5 format.\nWARNING: You probably need a newer version of this program to read it.\n", dbip->dbi_filename);
|
||||
dbip->dbi_version = 5;
|
||||
if( db5_scan( dbip, db5_diradd_handler, NULL ) < 0 ) {
|
||||
bu_log("db_dirbuild(%s): db5_scan() failed\n",
|
||||
dbip->dbi_filename);
|
||||
return -1;
|
||||
}
|
||||
/* Need to retrieve _GLOBAL object and obtain title and units */
|
||||
if( (dp = db_lookup( dbip, DB5_GLOBAL_OBJECT_NAME, LOOKUP_NOISY )) == DIR_NULL ) {
|
||||
bu_log("db_dirbuild(%s): improper v5 database, no %s object\n",
|
||||
dbip->dbi_filename, DB5_GLOBAL_OBJECT_NAME );
|
||||
dbip->dbi_title = bu_strdup(DB5_GLOBAL_OBJECT_NAME);
|
||||
return 0; /* not a fatal error, user may have deleted it */
|
||||
}
|
||||
BU_INIT_EXTERNAL(&ext);
|
||||
if( db_get_external( &ext, dp, dbip ) < 0 ||
|
||||
db5_get_raw_internal_ptr( &raw, ext.ext_buf ) < 0 ) {
|
||||
bu_log("db_dirbuild(%s): improper v5 database, unable to read %s object\n",
|
||||
dbip->dbi_filename, DB5_GLOBAL_OBJECT_NAME );
|
||||
return -1;
|
||||
}
|
||||
if( raw.major_type != DB5_MAJORTYPE_ATTRIBUTE_ONLY ) {
|
||||
bu_log("db_dirbuild(%s): improper v5 database, %s exists but is not an attribute-only object\n",
|
||||
dbip->dbi_filename, DB5_GLOBAL_OBJECT_NAME );
|
||||
dbip->dbi_title = bu_strdup(DB5_GLOBAL_OBJECT_NAME);
|
||||
return 0; /* not a fatal error, need to let user proceed to fix it */
|
||||
}
|
||||
if( db5_import_attributes( &avs, &raw.attributes ) < 0 ) {
|
||||
bu_log("db_dirbuild(%s): improper v5 database, corrupted attribute-only %s object\n",
|
||||
dbip->dbi_filename, DB5_GLOBAL_OBJECT_NAME );
|
||||
bu_free_external(&ext);
|
||||
return -1; /* this is fatal */
|
||||
}
|
||||
BU_CK_AVS( &avs );
|
||||
|
||||
/* Parse out the attributes */
|
||||
if( (cp = bu_avs_get( &avs, "title" )) != NULL ) {
|
||||
dbip->dbi_title = bu_strdup( cp );
|
||||
} else {
|
||||
dbip->dbi_title = bu_strdup( "Untitled BRL-CAD v5 database" );
|
||||
}
|
||||
if( (cp = bu_avs_get( &avs, "units" )) != NULL ) {
|
||||
double dd;
|
||||
if( sscanf( cp, "%lf", &dd ) != 1 ||
|
||||
NEAR_ZERO( dd, VUNITIZE_TOL ) ) {
|
||||
bu_log("db_dirbuild(%s): improper v5 database, %s object attribute 'units'=%s is invalid\n",
|
||||
dbip->dbi_filename, DB5_GLOBAL_OBJECT_NAME,
|
||||
cp );
|
||||
/* Not fatal, just stick with default value from db_open() */
|
||||
} else {
|
||||
dbip->dbi_local2base = dd;
|
||||
dbip->dbi_base2local = 1/dd;
|
||||
}
|
||||
}
|
||||
if( (cp = bu_avs_get( &avs, "regionid_colortable")) != NULL ) {
|
||||
/* XXX Grab the region-id coloring table here */
|
||||
}
|
||||
bu_avs_free( &avs );
|
||||
bu_free_external(&ext); /* not until after done with avs! */
|
||||
return 0;
|
||||
return db5_scan( dbip, db5_diradd_handler, NULL );
|
||||
}
|
||||
|
||||
/* Make a very simple check for a v4 database */
|
||||
@@ -342,3 +585,234 @@ bu_log("WARNING: %s is BRL-CAD v5 format.\nWARNING: You probably need a newer
|
||||
dbip->dbi_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ E X P O R T _ O B J E C T 3
|
||||
*
|
||||
* An experimental routine for merging together the three optional
|
||||
* parts of an object into the final on-disk format.
|
||||
* Results in extra data copies, but serves as a starting point for testing.
|
||||
* Any of name, attrib, and body may be null.
|
||||
*/
|
||||
void
|
||||
db5_export_object3( out, dli, name, attrib, body, major, minor, zzz )
|
||||
struct bu_external *out; /* output */
|
||||
int dli;
|
||||
CONST char *name;
|
||||
CONST struct bu_external *attrib;
|
||||
CONST struct bu_external *body;
|
||||
int major;
|
||||
int minor;
|
||||
int zzz; /* compression, someday */
|
||||
{
|
||||
struct db5_ondisk_header *odp;
|
||||
register unsigned char *cp;
|
||||
long namelen = 0;
|
||||
long need;
|
||||
long ineed = 0; /* sizes of internal parts */
|
||||
int h_width, i_width;
|
||||
long togo;
|
||||
|
||||
/*
|
||||
* First, compute an upper bound on the size buffer needed.
|
||||
* Over-estimate on the length fields just to keep it simple.
|
||||
*/
|
||||
need = sizeof(struct db5_ondisk_header);
|
||||
need += 8; /* for object_length */
|
||||
if( name ) {
|
||||
namelen = strlen(name) + 1; /* includes null */
|
||||
need += namelen + 8;
|
||||
ineed = namelen;
|
||||
}
|
||||
if( attrib ) {
|
||||
BU_CK_EXTERNAL(attrib);
|
||||
need += attrib->ext_nbytes + 8;
|
||||
ineed |= attrib->ext_nbytes;
|
||||
}
|
||||
if( body ) {
|
||||
BU_CK_EXTERNAL(body);
|
||||
need += body->ext_nbytes + 8;
|
||||
ineed |= body->ext_nbytes;
|
||||
}
|
||||
need += 8; /* pad and magic2 */
|
||||
|
||||
/* Allocate the buffer for the combined external representation */
|
||||
out->ext_magic = BU_EXTERNAL_MAGIC;
|
||||
out->ext_nbytes = 0;
|
||||
out->ext_buf = bu_malloc( need, "external object3" );
|
||||
|
||||
/* Determine encoding for the two kinds of length fields */
|
||||
h_width = db5_select_length_encoding( (need+7)>>3 );
|
||||
i_width = db5_select_length_encoding( ineed );
|
||||
|
||||
/* prepare combined external object */
|
||||
odp = (struct db5_ondisk_header *)out->ext_buf;
|
||||
odp->db5h_magic1 = DB5HDR_MAGIC1;
|
||||
|
||||
/* hflags */
|
||||
odp->db5h_hflags = (h_width << DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT) |
|
||||
(dli & DB5HDR_HFLAGS_DLI_MASK);
|
||||
if( name ) odp->db5h_hflags |= DB5HDR_HFLAGS_NAME_PRESENT;
|
||||
|
||||
/* iflags */
|
||||
odp->db5h_iflags = i_width << DB5HDR_IFLAGS_INTERIOR_WIDTH_SHIFT;
|
||||
if( attrib ) odp->db5h_iflags |= DB5HDR_IFLAGS_ATTRIBUTES_PRESENT;
|
||||
if( body ) odp->db5h_iflags |= DB5HDR_IFLAGS_BODY_PRESENT;
|
||||
odp->db5h_iflags |= zzz & DB5HDR_IFLAGS_ZZZ_MASK;
|
||||
|
||||
if( zzz ) bu_bomb("db5_export_object3: compression not supported yet\n");
|
||||
|
||||
/* Object_Type */
|
||||
odp->db5h_major_type = major;
|
||||
odp->db5h_minor_type = minor;
|
||||
|
||||
/* Build up the rest of the record */
|
||||
cp = ((unsigned char *)out->ext_buf) + sizeof(struct db5_ondisk_header);
|
||||
cp = db5_encode_length( cp, 0L, h_width ); /* will be replaced below */
|
||||
|
||||
if( name ) {
|
||||
cp = db5_encode_length( cp, namelen, i_width );
|
||||
bcopy( name, cp, namelen ); /* includes null */
|
||||
cp += namelen;
|
||||
}
|
||||
|
||||
if( attrib ) {
|
||||
cp = db5_encode_length( cp, attrib->ext_nbytes, i_width );
|
||||
bcopy( attrib->ext_buf, cp, attrib->ext_nbytes );
|
||||
cp += attrib->ext_nbytes;
|
||||
}
|
||||
|
||||
if( body ) {
|
||||
cp = db5_encode_length( cp, body->ext_nbytes, i_width );
|
||||
bcopy( body->ext_buf, cp, body->ext_nbytes );
|
||||
cp += body->ext_nbytes;
|
||||
}
|
||||
|
||||
togo = cp - ((unsigned char *)out->ext_buf) + 1;
|
||||
togo &= 7;
|
||||
if( togo != 0 ) {
|
||||
togo = 8 - togo;
|
||||
while( togo-- > 0 ) *cp++ = '\0';
|
||||
}
|
||||
*cp++ = DB5HDR_MAGIC2;
|
||||
|
||||
/* Verify multiple of 8 */
|
||||
togo = cp - ((unsigned char *)out->ext_buf);
|
||||
BU_ASSERT_LONG( togo&7, ==, 0 );
|
||||
|
||||
/* Finally, go back to the header and write the actual object length */
|
||||
cp = ((unsigned char *)out->ext_buf) + sizeof(struct db5_ondisk_header);
|
||||
cp = db5_encode_length( cp, togo>>3, h_width );
|
||||
|
||||
out->ext_nbytes = togo;
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ E X P O R T _ A T T R I B U T E S
|
||||
*
|
||||
* One attempt at encoding attribute-value information in the external
|
||||
* format.
|
||||
* This may not be the best or only way to do it, but it gets things
|
||||
* started, for testing.
|
||||
*
|
||||
* The on-disk encoding is:
|
||||
*
|
||||
* aname1 NULL value1 NULL ... anameN NULL valueN NULL NULL
|
||||
*/
|
||||
void
|
||||
db5_export_attributes( ext, avp )
|
||||
struct bu_external *ext;
|
||||
CONST struct attribute_value_pair *avp;
|
||||
{
|
||||
int need = 0;
|
||||
CONST struct attribute_value_pair *avpp;
|
||||
char *cp;
|
||||
|
||||
/* First pass -- determine how much space is required */
|
||||
for( avpp = avp; avpp->name != NULL; avpp++ ) {
|
||||
need += strlen( avpp->name ) + strlen( avpp->value ) + 2;
|
||||
}
|
||||
need += 1; /* for final null */
|
||||
|
||||
ext->ext_magic = BU_EXTERNAL_MAGIC;
|
||||
ext->ext_nbytes = need;
|
||||
ext->ext_buf = bu_malloc( need, "external attributes" );
|
||||
|
||||
/* Second pass -- store in external form */
|
||||
cp = (char *)ext->ext_buf;
|
||||
for( avpp = avp; avpp->name != NULL; avpp++ ) {
|
||||
need = strlen( avpp->name ) + 1;
|
||||
bcopy( avpp->name, cp, need );
|
||||
cp += need;
|
||||
|
||||
need = strlen( avpp->value ) + 1;
|
||||
bcopy( avpp->value, cp, need );
|
||||
cp += need;
|
||||
}
|
||||
*cp++ = '\0';
|
||||
need = cp - ((char *)ext->ext_buf);
|
||||
BU_ASSERT_LONG( need, ==, ext->ext_nbytes );
|
||||
}
|
||||
|
||||
/*
|
||||
* D B 5 _ F W R I T E _ I D E N T
|
||||
*
|
||||
* Create a header for a v5 database.
|
||||
* This routine has the same calling sequence as db_fwrite_ident()
|
||||
* which makes a v4 database header.
|
||||
*
|
||||
* In the v5 database, two database objects must be created to
|
||||
* match the semantics of what was in the v4 header:
|
||||
*
|
||||
* First, a database header object.
|
||||
*
|
||||
* Second, an attribute-only object named "_GLOBAL" which
|
||||
* contains the attributes "title=" and "units=".
|
||||
*
|
||||
* Returns -
|
||||
* 0 Success
|
||||
* -1 Fatal Error
|
||||
*/
|
||||
int
|
||||
db5_fwrite_ident( fp, title, local2mm )
|
||||
FILE *fp;
|
||||
CONST char *title;
|
||||
double local2mm;
|
||||
{
|
||||
struct attribute_value_pair avp[3];
|
||||
struct bu_vls units;
|
||||
struct bu_external out;
|
||||
struct bu_external attr;
|
||||
|
||||
/* First, write the header object */
|
||||
db5_export_object3( &out, DB5HDR_HFLAGS_DLI_HEADER_OBJECT,
|
||||
NULL, NULL, NULL,
|
||||
DB5HDR_MAJORTYPE_RESERVED, 0,
|
||||
DB5HDR_IFLAGS_ZZZ_UNCOMPRESSED );
|
||||
bu_fwrite_external( fp, &out );
|
||||
bu_free_external( &out );
|
||||
|
||||
/* Second, create the attribute-only object */
|
||||
bu_vls_init( &units );
|
||||
bu_vls_printf( &units, "%.25f", local2mm );
|
||||
|
||||
avp[0].name = "title";
|
||||
avp[0].value = (char *)title; /* un-CONST */
|
||||
avp[1].name = "units";
|
||||
avp[1].value = bu_vls_addr(&units);
|
||||
avp[2].name = NULL;
|
||||
avp[2].value = NULL;
|
||||
|
||||
db5_export_attributes( &attr, avp );
|
||||
db5_export_object3( &out, DB5HDR_HFLAGS_DLI_APPLICATION_DATA_OBJECT,
|
||||
"_GLOBAL", &attr, NULL,
|
||||
DB5HDR_MAJORTYPE_ATTRIBUTE_ONLY, 0,
|
||||
DB5HDR_IFLAGS_ZZZ_UNCOMPRESSED);
|
||||
bu_fwrite_external( fp, &out );
|
||||
bu_free_external( &out );
|
||||
bu_free_external( &attr );
|
||||
|
||||
bu_vls_free( &units );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,339 +0,0 @@
|
||||
/*
|
||||
* D B 5 _ T Y P E S . C
|
||||
*
|
||||
* Purpose -
|
||||
* Map between Major_Types/Minor_Types and ASCII strings
|
||||
*
|
||||
* Author -
|
||||
* Paul J. Tanenbaum
|
||||
* Source -
|
||||
* The U. S. Army Research Laboratory
|
||||
* Aberdeen Proving Ground, Maryland 21005-5066
|
||||
*
|
||||
* Copyright Notice -
|
||||
* This software is Copyright (C) 2000 by the United States Army.
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static char RCSell[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "machine.h"
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
#include "db5.h"
|
||||
#include "nmg.h"
|
||||
#include "raytrace.h"
|
||||
|
||||
struct db5_type {
|
||||
unsigned char major_code;
|
||||
unsigned char minor_code;
|
||||
unsigned char heed_minor;
|
||||
char *tag;
|
||||
char *description;
|
||||
};
|
||||
|
||||
/*
|
||||
* In order to support looking up Major_Types
|
||||
* as well as (Major_Type, Minor_Type) pairs,
|
||||
* every Major_Type needs an entry with heed_minor==0
|
||||
* and it must occur below any of its entries that
|
||||
* have heed_minor==1.
|
||||
*/
|
||||
CONST static struct db5_type type_table[] = {
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_TOR, 1, "tor", "torus"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_TGC, 1, "tgc", "truncated general cone"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_ELL, 1, "ell", "ellipsoid"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_ARB8, 1, "arb8", "arb8"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_ARS, 1, "ars", "waterline"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_HALF, 1, "half", "halfspace"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_REC, 1, "rec", "right elliptical cylinder"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_BSPLINE, 1, "bspline", "B-spline"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_SPH, 1, "sph", "sphere"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_NMG, 1, "nmg", "nmg"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_EBM, 1, "ebm", "extruded bitmap"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_VOL, 1, "vol", "voxels"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_ARBN, 1, "arbn", "arbn"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_PIPE, 1, "pipe", "pipe"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_PARTICLE, 1, "particle", "particle"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_RPC, 1, "rpc", "right parabolic cylinder"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_RHC, 1, "rhc", "right hyperbolic cylinder"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_EPA, 1, "epa", "elliptical paraboloid"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_EHY, 1, "ehy", "elliptical hyperboloid"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_ETO, 1, "eto", "elliptical torus"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_GRIP, 1, "grip", "grip"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_JOINT, 1, "joint", "joint"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_DSP, 1, "dsp", "displacement map (height field)"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_SKETCH, 1, "sketch", "sketch"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_EXTRUDE, 1, "extrude", "extrusion"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_SUBMODEL, 1, "submodel", "submodel"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_CLINE, 1, "cline", "cline"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_BOT, 1, "bot", "bag of triangles"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_COMBINATION, 1, "combination", "combination"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BRLCAD, 0, 0, "brlcad", "BRL-CAD geometry"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_ATTRIBUTE_ONLY, 0, 0, "attribonly", "attribute only"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_EXPM, 0, 0, "binexpm", "experimental binary"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_FLOAT, 1, "bin_float", "array of floats"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_DOUBLE, 1, "bin_double", "array of doubles"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_8BITINT_U, 1, "bin_8u", "array of unsigned 8-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_16BITINT_U, 1, "bin_16u", "array of unsigned 16-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_32BITINT_U, 1, "bin_32u", "array of unsigned 32-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_64BITINT_U, 1, "bin_64u", "array of unsigned 64-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_8BITINT, 1, "bin_8", "array of 8-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_16BITINT, 1, "bin_16", "array of 16-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_32BITINT, 1, "bin_32", "array of 32-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_64BITINT, 1, "bin_64", "array of 64-bit ints"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_UNIF, 0, 0, "binunif", "uniform-array binary"
|
||||
},
|
||||
{
|
||||
DB5_MAJORTYPE_BINARY_MIME, 0, 0, "binmime", "MIME-typed binary"
|
||||
},
|
||||
/*
|
||||
* Following entry must be at end of table
|
||||
*/
|
||||
{
|
||||
DB5_MAJORTYPE_RESERVED, 0, 0, 0, 0
|
||||
},
|
||||
};
|
||||
|
||||
int
|
||||
db5_type_tag_from_major( char **tag, CONST unsigned char major ) {
|
||||
register struct db5_type *tp;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if ((tp -> major_code == major) && !(tp -> heed_minor)) {
|
||||
*tag = tp -> tag;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
db5_type_descrip_from_major( char **descrip, CONST unsigned char major ) {
|
||||
register struct db5_type *tp;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if ((tp -> major_code == major) && !(tp -> heed_minor)) {
|
||||
*descrip = tp -> description;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
db5_type_tag_from_codes( char **tag, CONST unsigned char major,
|
||||
CONST unsigned char minor ) {
|
||||
register struct db5_type *tp;
|
||||
register int found_minors = 0;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if (tp -> major_code == major) {
|
||||
if (tp -> heed_minor)
|
||||
found_minors = 1;
|
||||
if ((tp -> minor_code == minor) || !found_minors) {
|
||||
*tag = tp -> tag;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
db5_type_descrip_from_codes( char **descrip, CONST unsigned char major,
|
||||
CONST unsigned char minor ) {
|
||||
register struct db5_type *tp;
|
||||
register int found_minors = 0;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if (tp -> major_code == major) {
|
||||
if (tp -> heed_minor)
|
||||
found_minors = 1;
|
||||
if ((tp -> minor_code == minor) || !found_minors) {
|
||||
*descrip = tp -> description;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
db5_type_codes_from_tag( unsigned char *major, unsigned char *minor,
|
||||
CONST char *tag ) {
|
||||
register struct db5_type *tp;
|
||||
register int found_minors = 0;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if ((*(tp -> tag) == *tag) && (strcmp(tp -> tag, tag) == 0)) {
|
||||
*major = tp -> major_code;
|
||||
*minor = tp -> minor_code;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
db5_type_codes_from_descrip( unsigned char *major, unsigned char *minor,
|
||||
CONST char *descrip ) {
|
||||
register struct db5_type *tp;
|
||||
register int found_minors = 0;
|
||||
|
||||
for (tp = (struct db5_type *) type_table;
|
||||
tp -> major_code != DB5_MAJORTYPE_RESERVED;
|
||||
++tp) {
|
||||
if ((*(tp -> description) == *descrip)
|
||||
&& (strcmp(tp -> description, descrip) == 0)) {
|
||||
*major = tp -> major_code;
|
||||
*minor = tp -> minor_code;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t
|
||||
db5_type_sizeof_h_binu( CONST unsigned char minor ) {
|
||||
switch ( minor ) {
|
||||
case DB5_MINORTYPE_BINU_FLOAT:
|
||||
return sizeof(float);
|
||||
case DB5_MINORTYPE_BINU_DOUBLE:
|
||||
return sizeof(double);
|
||||
case DB5_MINORTYPE_BINU_8BITINT:
|
||||
case DB5_MINORTYPE_BINU_8BITINT_U:
|
||||
return (size_t) 1;
|
||||
case DB5_MINORTYPE_BINU_16BITINT:
|
||||
case DB5_MINORTYPE_BINU_16BITINT_U:
|
||||
return (size_t) 2;
|
||||
case DB5_MINORTYPE_BINU_32BITINT:
|
||||
case DB5_MINORTYPE_BINU_32BITINT_U:
|
||||
return (size_t) 4;
|
||||
case DB5_MINORTYPE_BINU_64BITINT:
|
||||
case DB5_MINORTYPE_BINU_64BITINT_U:
|
||||
return (size_t) 8;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
db5_type_sizeof_n_binu( CONST unsigned char minor ) {
|
||||
switch ( minor ) {
|
||||
case DB5_MINORTYPE_BINU_FLOAT:
|
||||
return (size_t) SIZEOF_NETWORK_FLOAT;
|
||||
case DB5_MINORTYPE_BINU_DOUBLE:
|
||||
return (size_t) SIZEOF_NETWORK_DOUBLE;
|
||||
case DB5_MINORTYPE_BINU_8BITINT:
|
||||
case DB5_MINORTYPE_BINU_8BITINT_U:
|
||||
return (size_t) 1;
|
||||
case DB5_MINORTYPE_BINU_16BITINT:
|
||||
case DB5_MINORTYPE_BINU_16BITINT_U:
|
||||
return (size_t) 2;
|
||||
case DB5_MINORTYPE_BINU_32BITINT:
|
||||
case DB5_MINORTYPE_BINU_32BITINT_U:
|
||||
return (size_t) 4;
|
||||
case DB5_MINORTYPE_BINU_64BITINT:
|
||||
case DB5_MINORTYPE_BINU_64BITINT_U:
|
||||
return (size_t) 8;
|
||||
}
|
||||
}
|
||||
+6
-20
@@ -152,8 +152,6 @@ int count;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
BU_ASSERT_LONG( dbip->dbi_version, ==, 4 );
|
||||
|
||||
/* Easy case -- see if at end-of-file */
|
||||
old_len = dp->d_len;
|
||||
extra_start = dp->d_addr + dp->d_len * sizeof(union record);
|
||||
@@ -228,8 +226,6 @@ int count;
|
||||
bu_log("db_trunc on READ-ONLY file\n");
|
||||
return(-1);
|
||||
}
|
||||
BU_ASSERT_LONG( dbip->dbi_version, ==, 4 );
|
||||
|
||||
i = db_zapper( dbip, dp, dp->d_len - count );
|
||||
rt_memfree( &(dbip->dbi_freep), (unsigned)count,
|
||||
(dp->d_addr/(sizeof(union record)))+dp->d_len-count );
|
||||
@@ -263,8 +259,7 @@ int recnum;
|
||||
* D B _ D E L E T E
|
||||
*
|
||||
* Delete the indicated database record(s).
|
||||
* Arrange to write "free storage" database markers in it's place,
|
||||
* positively erasing what had been there before.
|
||||
* Mark all records with ID_FREE.
|
||||
*/
|
||||
int
|
||||
db_delete( dbip, dp )
|
||||
@@ -285,21 +280,14 @@ struct directory *dp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( dbip->dbi_version == 4 ) {
|
||||
i = db_zapper( dbip, dp, 0 );
|
||||
rt_memfree( &(dbip->dbi_freep), (unsigned)dp->d_len,
|
||||
dp->d_addr/(sizeof(union record)) );
|
||||
} else if( dbip->dbi_version == 5 ) {
|
||||
i = db5_write_free( dbip, dp, dp->d_len );
|
||||
rt_memfree( &(dbip->dbi_freep), dp->d_len,
|
||||
dp->d_addr );
|
||||
} else {
|
||||
bu_bomb("db_delete() unsupported database version\n");
|
||||
}
|
||||
i = db_zapper( dbip, dp, 0 );
|
||||
|
||||
rt_memfree( &(dbip->dbi_freep), (unsigned)dp->d_len,
|
||||
dp->d_addr/(sizeof(union record)) );
|
||||
|
||||
dp->d_len = 0;
|
||||
dp->d_addr = -1;
|
||||
return i;
|
||||
return(i);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -333,8 +321,6 @@ int start;
|
||||
if( dbip->dbi_read_only )
|
||||
return(-1);
|
||||
|
||||
BU_ASSERT_LONG( dbip->dbi_version, ==, 4 );
|
||||
|
||||
if( (todo = dp->d_len - start) == 0 )
|
||||
return(0); /* OK -- trivial */
|
||||
if( todo < 0 )
|
||||
|
||||
+90
-18
@@ -173,12 +173,12 @@ int op;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ I M P O R T 4
|
||||
* R T _ C O M B _ V 4 _ I M P O R T
|
||||
*
|
||||
* Import a combination record from a V4 database into internal form.
|
||||
*/
|
||||
int
|
||||
rt_comb_import4( ip, ep, matrix, dbip )
|
||||
rt_comb_v4_import( ip, ep, matrix, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
CONST matp_t matrix; /* NULL if identity */
|
||||
@@ -196,7 +196,7 @@ CONST struct db_i *dbip;
|
||||
|
||||
if( rp[0].u_id != ID_COMB )
|
||||
{
|
||||
bu_log( "rt_comb_import4: Attempt to import a non-combination\n" );
|
||||
bu_log( "rt_comb_v4_import: Attempt to import a non-combination\n" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ CONST struct db_i *dbip;
|
||||
{
|
||||
if( rp[j+1].u_id != ID_MEMB )
|
||||
{
|
||||
bu_free( (genptr_t)rt_tree_array , "rt_comb_import4: rt_tree_array" );
|
||||
bu_log( "rt_comb_import4(): granule in external buffer is not ID_MEMB, id=%d\n", rp[j+1].u_id );
|
||||
bu_free( (genptr_t)rt_tree_array , "rt_comb_v4_import: rt_tree_array" );
|
||||
bu_log( "rt_comb_v4_import(): granule in external buffer is not ID_MEMB, id=%d\n", rp[j+1].u_id );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ CONST struct db_i *dbip;
|
||||
rt_tree_array[j].tl_op = OP_SUBTRACT;
|
||||
break;
|
||||
default:
|
||||
bu_log("rt_comb_import4() unknown op=x%x, assuming UNION\n", rp[j+1].M.m_relation );
|
||||
bu_log("rt_comb_v4_import() unknown op=x%x, assuming UNION\n", rp[j+1].M.m_relation );
|
||||
/* Fall through */
|
||||
case 'u':
|
||||
rt_tree_array[j].tl_op = OP_UNION;
|
||||
@@ -292,7 +292,7 @@ CONST struct db_i *dbip;
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_COMBINATION;
|
||||
ip->idb_meth = &rt_functab[ID_COMBINATION];
|
||||
comb = (struct rt_comb_internal *)bu_malloc( sizeof( struct rt_comb_internal ) , "rt_comb_import4: rt_comb_internal" );
|
||||
comb = (struct rt_comb_internal *)bu_malloc( sizeof( struct rt_comb_internal ) , "rt_comb_v4_import: rt_comb_internal" );
|
||||
ip->idb_ptr = (genptr_t)comb;
|
||||
comb->magic = RT_COMB_MAGIC;
|
||||
bu_vls_init( &comb->shader );
|
||||
@@ -361,7 +361,7 @@ CONST struct db_i *dbip;
|
||||
/* convert to TCL format and place into comb->shader */
|
||||
if( bu_shader_to_tcl_list( shader_str, &comb->shader ) )
|
||||
{
|
||||
bu_log( "rt_comb_import4: Error: Cannot convert following shader to TCL format:\n" );
|
||||
bu_log( "rt_comb_v4_import: Error: Cannot convert following shader to TCL format:\n" );
|
||||
bu_log( "\t%s\n", shader_str );
|
||||
bu_vls_free( &comb->shader );
|
||||
}
|
||||
@@ -380,10 +380,10 @@ CONST struct db_i *dbip;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ E X P O R T 4
|
||||
* R T _ C O M B _ V 4 _ E X P O R T
|
||||
*/
|
||||
int
|
||||
rt_comb_export4( ep, ip, local2mm, dbip )
|
||||
rt_comb_v4_export( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
@@ -400,7 +400,7 @@ CONST struct db_i *dbip;
|
||||
struct bu_vls tmp_vls;
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
if( ip->idb_type != ID_COMBINATION ) bu_bomb("rt_comb_export4() type not ID_COMBINATION");
|
||||
if( ip->idb_type != ID_COMBINATION ) bu_bomb("rt_comb_v4_export() type not ID_COMBINATION");
|
||||
comb = (struct rt_comb_internal *)ip->idb_ptr;
|
||||
RT_CK_COMB(comb);
|
||||
|
||||
@@ -408,7 +408,7 @@ CONST struct db_i *dbip;
|
||||
db_non_union_push( comb->tree );
|
||||
if( db_ck_v4gift_tree( comb->tree ) < 0 ) {
|
||||
/* Need to further modify tree */
|
||||
bu_log("rt_comb_export4() Unfinished: need to V4-ify tree\n");
|
||||
bu_log("rt_comb_v4_export() Unfinished: need to V4-ify tree\n");
|
||||
rt_pr_tree( comb->tree, 0 );
|
||||
return -1;
|
||||
}
|
||||
@@ -421,8 +421,8 @@ CONST struct db_i *dbip;
|
||||
|
||||
/* Convert tree into array form */
|
||||
actual_count = db_flatten_tree( rt_tree_array, comb->tree, OP_UNION ) - rt_tree_array;
|
||||
if( actual_count > node_count ) bu_bomb("rt_comb_export4() array overflow!");
|
||||
if( actual_count < node_count ) bu_log("WARNING rt_comb_export4() array underflow! %d < %d", actual_count, node_count);
|
||||
if( actual_count > node_count ) bu_bomb("rt_comb_v4_export() array overflow!");
|
||||
if( actual_count < node_count ) bu_log("WARNING rt_comb_v4_export() array underflow! %d < %d", actual_count, node_count);
|
||||
} else {
|
||||
rt_tree_array = (struct rt_tree_array *)NULL;
|
||||
actual_count = 0;
|
||||
@@ -438,7 +438,7 @@ CONST struct db_i *dbip;
|
||||
for( j = 0; j < node_count; j++ ) {
|
||||
tp = rt_tree_array[j].tl_tree;
|
||||
RT_CK_TREE(tp);
|
||||
if( tp->tr_op != OP_DB_LEAF ) bu_bomb("rt_comb_export4() tree not OP_DB_LEAF");
|
||||
if( tp->tr_op != OP_DB_LEAF ) bu_bomb("rt_comb_v4_export() tree not OP_DB_LEAF");
|
||||
|
||||
rp[j+1].u_id = ID_MEMB;
|
||||
switch( rt_tree_array[j].tl_op ) {
|
||||
@@ -452,7 +452,7 @@ CONST struct db_i *dbip;
|
||||
rp[j+1].M.m_relation = 'u';
|
||||
break;
|
||||
default:
|
||||
bu_bomb("rt_comb_export4() corrupt rt_tree_array");
|
||||
bu_bomb("rt_comb_v4_export() corrupt rt_tree_array");
|
||||
}
|
||||
strncpy( rp[j+1].M.m_instname, tp->tr_l.tl_name, NAMESIZE );
|
||||
if( tp->tr_l.tl_mat ) {
|
||||
@@ -497,7 +497,7 @@ CONST struct db_i *dbip;
|
||||
/* convert TCL list format shader to keyword=value format */
|
||||
if( bu_shader_to_key_eq( bu_vls_addr(&comb->shader), &tmp_vls ) )
|
||||
{
|
||||
bu_log( "rt_comb_export4: Error in combination!\n" );
|
||||
bu_log( "rt_comb_v4_export: Error in combination!\n" );
|
||||
bu_log( "\tCannot convert following shader string to keyword=value format:\n" );
|
||||
bu_log( "\t%s\n", bu_vls_addr(&comb->shader) );
|
||||
rp[0].c.c_matparm[0] = '\0';
|
||||
@@ -790,6 +790,36 @@ double mm2local;
|
||||
}
|
||||
}
|
||||
|
||||
/*==================== BEGIN table.c rt_functab interface ========== */
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ I M P O R T
|
||||
*/
|
||||
int
|
||||
rt_comb_import(ip, ep, mat, dbip)
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
/* XXX Switch out to right routine, based on database version */
|
||||
return rt_comb_v4_import( ip, ep, mat, dbip );
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ E X P O R T
|
||||
*/
|
||||
int
|
||||
rt_comb_export(ep, ip, local2mm, dbip)
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
/* XXX Switch out to right routine, based on database version */
|
||||
return rt_comb_v4_export( ep, ip, local2mm, dbip );
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C O M B _ I F R E E
|
||||
*
|
||||
@@ -843,7 +873,7 @@ double mm2local;
|
||||
* D B _ W R A P _ V 4 _ E X T E R N A L
|
||||
*
|
||||
* Wraps the v4 object body in "ip" into a v4 wrapper in "op".
|
||||
* bu_free_external(ip) will be performed.
|
||||
* db_free_external(ip) will be performed.
|
||||
* op and ip must not point at the same bu_external structure.
|
||||
*
|
||||
* As the v4 database does not really have the notion of "wrapping",
|
||||
@@ -1114,3 +1144,45 @@ CONST struct db_wrapper *wp;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ V 5 _ E X P O R T
|
||||
*/
|
||||
int
|
||||
rt_v5_export( ep, ip, local2mm, dp, wp, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct directory *dp;
|
||||
CONST struct db_wrapper *wp;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct bu_external temp;
|
||||
int ret;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
RT_CK_DIR(dp);
|
||||
|
||||
/* XXX need v5 versions. For testing, use v4 in object body. */
|
||||
|
||||
/* Convert Object Body to external form */
|
||||
if( ip->idb_type == ID_COMBINATION ) {
|
||||
ret = rt_comb_v4_export( &temp, ip, local2mm, dbip );
|
||||
} else {
|
||||
ret = rt_functab[ip->idb_type].ft_export( &temp, ip, local2mm, dbip );
|
||||
}
|
||||
if( ret < 0 ) {
|
||||
bu_log("rt_v5_export(%s): ft_export error %d\n",
|
||||
dp->d_namep, ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
if( (ret = db_wrap_v5_external( ep, &temp, dp, wp )) < 0 ) {
|
||||
bu_log("rt_v5_export(%s): db_wrap_v5_external error %d\n",
|
||||
dp->d_namep, ret );
|
||||
return ret;
|
||||
}
|
||||
/* "temp" has been freed by db_wrap_v4_external() */
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
+36
-58
@@ -20,7 +20,7 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
#endif
|
||||
|
||||
#include "conf.h"
|
||||
@@ -207,7 +207,7 @@ long offset; /* byte offset from start of file */
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
if(rt_g.debug&DEBUG_DB) {
|
||||
bu_log("db_read(dbip=x%x, addr=x%x, count=%d., offset=x%x)\n",
|
||||
bu_log("db_read(dbip=x%x, addr=x%x, count=%d., offset=%d.)\n",
|
||||
dbip, addr, count, offset );
|
||||
}
|
||||
if( count <= 0 || offset < 0 ) {
|
||||
@@ -261,7 +261,7 @@ long offset; /* byte offset from start of file */
|
||||
/* should be HIDDEN */
|
||||
int
|
||||
db_write( dbip, addr, count, offset )
|
||||
struct db_i *dbip;
|
||||
CONST struct db_i *dbip;
|
||||
CONST genptr_t addr;
|
||||
long count;
|
||||
long offset;
|
||||
@@ -270,7 +270,7 @@ long offset;
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
if(rt_g.debug&DEBUG_DB) {
|
||||
bu_log("db_write(dbip=x%x, addr=x%x, count=%d., offset=x%x)\n",
|
||||
bu_log("db_write(dbip=x%x, addr=x%x, count=%d., offset=%d.)\n",
|
||||
dbip, addr, count, offset );
|
||||
}
|
||||
if( dbip->dbi_read_only ) {
|
||||
@@ -296,9 +296,8 @@ long offset;
|
||||
bu_semaphore_release( BU_SEM_SYSCALL );
|
||||
if( got != count ) {
|
||||
perror("db_write");
|
||||
bu_log("db_write(%s): write error. Wanted %d, got %d bytes.\nFile forced read-only.\n",
|
||||
bu_log("db_write(%s): write error. Wanted %d, got %d bytes\n",
|
||||
dbip->dbi_filename, count, got );
|
||||
dbip->dbi_read_only = 1;
|
||||
return(-1);
|
||||
}
|
||||
return(0); /* OK */
|
||||
@@ -312,7 +311,7 @@ long offset;
|
||||
* The bu_external structure represented by 'ep' is initialized here,
|
||||
* the caller need not pre-initialize it. On error, 'ep' is left
|
||||
* un-initialized and need not be freed, to simplify error recovery.
|
||||
* On success, the caller is responsible for calling bu_free_external(ep);
|
||||
* On success, the caller is responsible for calling db_free_external(ep);
|
||||
*
|
||||
* Returns -
|
||||
* -1 error
|
||||
@@ -333,10 +332,7 @@ CONST struct db_i *dbip;
|
||||
return( -1 ); /* was dummy DB entry */
|
||||
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
if( dbip->dbi_version <= 4 )
|
||||
ep->ext_nbytes = dp->d_len * sizeof(union record);
|
||||
else
|
||||
ep->ext_nbytes = dp->d_len;
|
||||
ep->ext_nbytes = dp->d_len * sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_malloc(
|
||||
ep->ext_nbytes, "db_get_ext ext_buf");
|
||||
|
||||
@@ -364,7 +360,7 @@ CONST struct db_i *dbip;
|
||||
* the size has changed since last write.
|
||||
*
|
||||
* Caller is responsible for freeing memory of external representation,
|
||||
* using bu_free_external().
|
||||
* using db_free_external().
|
||||
*/
|
||||
int
|
||||
db_put_external( ep, dp, dbip )
|
||||
@@ -372,6 +368,8 @@ struct bu_external *ep;
|
||||
struct directory *dp;
|
||||
struct db_i *dbip;
|
||||
{
|
||||
union record *rec;
|
||||
int ngran;
|
||||
|
||||
RT_CK_DBI(dbip);
|
||||
RT_CK_DIR(dp);
|
||||
@@ -380,57 +378,36 @@ struct db_i *dbip;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
|
||||
if( dbip->dbi_read_only ) {
|
||||
bu_log("db_put_external(%s): READ-ONLY file\n",
|
||||
dbip->dbi_filename);
|
||||
return(-1);
|
||||
ngran = (ep->ext_nbytes+sizeof(union record)-1)/sizeof(union record);
|
||||
if( ngran != dp->d_len ) {
|
||||
if( ngran < dp->d_len ) {
|
||||
if( db_trunc( dbip, dp, dp->d_len - ngran ) < 0 )
|
||||
return(-2);
|
||||
} else if( ngran > dp->d_len ) {
|
||||
if( db_delete( dbip, dp ) < 0 ||
|
||||
db_alloc( dbip, dp, ngran ) < 0 ) {
|
||||
return(-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Sanity check */
|
||||
if( ngran != dp->d_len ) {
|
||||
bu_log("db_put_external(%s) ngran=%d != dp->d_len %d\n",
|
||||
dp->d_namep, ngran, dp->d_len );
|
||||
bu_bomb("db_io.c: db_put_external()");
|
||||
}
|
||||
|
||||
if( dbip->dbi_version <= 4 ) {
|
||||
union record *rec;
|
||||
int ngran;
|
||||
|
||||
ngran = (ep->ext_nbytes+sizeof(union record)-1)/sizeof(union record);
|
||||
if( ngran != dp->d_len || dp->d_addr == -1L ) {
|
||||
if( ngran < dp->d_len ) {
|
||||
if( db_trunc( dbip, dp, dp->d_len - ngran ) < 0 )
|
||||
return(-2);
|
||||
} else if( ngran > dp->d_len ) {
|
||||
if( db_delete( dbip, dp ) < 0 ||
|
||||
db_alloc( dbip, dp, ngran ) < 0 ) {
|
||||
return(-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Sanity check */
|
||||
if( ngran != dp->d_len ) {
|
||||
bu_log("db_put_external(%s) ngran=%d != dp->d_len %d\n",
|
||||
dp->d_namep, ngran, dp->d_len );
|
||||
bu_bomb("db_io.c: db_put_external()");
|
||||
}
|
||||
|
||||
/* Add name. Depends on solid names always being in the same place */
|
||||
rec = (union record *)ep->ext_buf;
|
||||
NAMEMOVE( dp->d_namep, rec->s.s_name );
|
||||
} else if( dbip->dbi_version == 5 ) {
|
||||
if( ep->ext_nbytes != dp->d_len || dp->d_addr == -1L ) {
|
||||
if( db5_realloc( dbip, dp, ep ) < 0 ) {
|
||||
bu_log("db_put_external(%s) db_realloc5() failed\n", dp->d_namep);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, dp->d_len );
|
||||
} else
|
||||
bu_bomb("db_put_external(): unknown dbi_version\n");
|
||||
/* Add name. Depends on solid names always being in the same place */
|
||||
rec = (union record *)ep->ext_buf;
|
||||
NAMEMOVE( dp->d_namep, rec->s.s_name );
|
||||
|
||||
if( dp->d_flags & RT_DIR_INMEM ) {
|
||||
bcopy( (char *)ep->ext_buf, dp->d_un.ptr, ep->ext_nbytes );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( db_write( dbip, (char *)ep->ext_buf, ep->ext_nbytes, dp->d_addr ) < 0 ) {
|
||||
if( db_put( dbip, dp, (union record *)(ep->ext_buf), 0, ngran ) < 0 )
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -443,7 +420,7 @@ struct db_i *dbip;
|
||||
* and write it into a file.
|
||||
*
|
||||
* Caller is responsible for freeing memory of external representation,
|
||||
* using bu_free_external().
|
||||
* using db_free_external().
|
||||
*
|
||||
* The 'name' field of the external representation is modified to
|
||||
* contain the desired name.
|
||||
@@ -476,13 +453,14 @@ struct bu_external *ep; /* can't be const */
|
||||
|
||||
/*
|
||||
* D B _ F R E E _ E X T E R N A L
|
||||
*
|
||||
* XXX This is a leftover. You should call bu_free_external() instead.
|
||||
*/
|
||||
void
|
||||
db_free_external( ep )
|
||||
register struct bu_external *ep;
|
||||
{
|
||||
BU_CK_EXTERNAL(ep);
|
||||
bu_free_external(ep);
|
||||
if( ep->ext_buf ) {
|
||||
bu_free( ep->ext_buf, "db_get_ext ext_buf" );
|
||||
ep->ext_buf = GENPTR_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -385,15 +385,14 @@ register CONST struct db_i *dbip;
|
||||
flags = "COM";
|
||||
else
|
||||
flags = "Bad";
|
||||
bu_log("x%.8x %s %s=x%.8x len=%.5d use=%.2d nref=%.2d %s",
|
||||
dp,
|
||||
bu_log("%.8x %.16s %s %s=%.8x use=%.2d len=%.3d nref=%.2d",
|
||||
dp, dp->d_namep,
|
||||
dp->d_flags & RT_DIR_INMEM ? "ptr" : "d_addr",
|
||||
flags,
|
||||
dp->d_flags & RT_DIR_INMEM ? " ptr " : "d_addr",
|
||||
dp->d_addr,
|
||||
dp->d_len,
|
||||
dp->d_uses,
|
||||
dp->d_nref,
|
||||
dp->d_namep );
|
||||
dp->d_len,
|
||||
dp->d_nref );
|
||||
if( dp->d_animate )
|
||||
bu_log(" anim=x%x\n", dp->d_animate );
|
||||
else
|
||||
|
||||
+3
-6
@@ -188,21 +188,18 @@ struct db_i *dbip;
|
||||
dp->d_nref = 0;
|
||||
|
||||
/* Examine all COMB nodes */
|
||||
for( i = 0; i < RT_DBNHASH; i++ ) {
|
||||
for( i = 0; i < RT_DBNHASH; i++ )
|
||||
for( dp = dbip->dbi_Head[i]; dp != DIR_NULL; dp = dp->d_forw ){
|
||||
if( !(dp->d_flags & DIR_COMB) )
|
||||
continue;
|
||||
if( rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL) < 0 )
|
||||
continue;
|
||||
if( intern.idb_type != ID_COMBINATION ) {
|
||||
rt_db_free_internal( &intern );
|
||||
if( intern.idb_type != ID_COMBINATION )
|
||||
continue;
|
||||
}
|
||||
comb = (struct rt_comb_internal *)intern.idb_ptr;
|
||||
db_tree_funcleaf( dbip, comb, comb->tree,
|
||||
db_count_refs, (genptr_t)NULL,
|
||||
(genptr_t)NULL, (genptr_t)NULL );
|
||||
rt_db_free_internal( &intern );
|
||||
intern.idb_meth->ft_ifree( &intern );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -330,17 +330,16 @@ struct db_i *dbip; /* input */
|
||||
for( i=0; i < RT_DBNHASH; i++ ) {
|
||||
for( dp = dbip->dbi_Head[i]; dp != DIR_NULL; dp = dp->d_forw ) {
|
||||
RT_CK_DIR(dp);
|
||||
/* XXX Need to go to internal form, if database versions don't match */
|
||||
if( db_get_external( &ext, dp, dbip ) < 0 ) {
|
||||
bu_log("db_dump() read failed on %s, skipping\n", dp->d_namep );
|
||||
continue;
|
||||
}
|
||||
if( wdb_export_external( wdbp, &ext, dp->d_namep, dp->d_flags ) < 0 ) {
|
||||
bu_log("db_dump() write failed on %s, aborting\n", dp->d_namep);
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return -1;
|
||||
}
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
+31
-26
@@ -882,7 +882,7 @@ int depth; /* # arcs in new_path to use */
|
||||
/* Found it, state has been applied, sofar applied,
|
||||
* member's directory entry pushed onto total_path
|
||||
*/
|
||||
rt_db_free_internal( &intern );
|
||||
intern.idb_meth->ft_ifree( &intern );
|
||||
|
||||
/* If member is a leaf, handle leaf processing too. */
|
||||
if( (dp->d_flags & DIR_COMB) == 0 ) {
|
||||
@@ -1057,6 +1057,7 @@ struct combined_tree_state **region_start_statepp;
|
||||
genptr_t client_data;
|
||||
{
|
||||
struct directory *dp;
|
||||
struct bu_external ext;
|
||||
struct rt_db_internal intern;
|
||||
union tree *curtree = TREE_NULL;
|
||||
|
||||
@@ -1081,25 +1082,27 @@ genptr_t client_data;
|
||||
|
||||
/*
|
||||
* Load the entire object into contiguous memory.
|
||||
* Note that this code depends on the d_flags being set properly.
|
||||
*/
|
||||
if( dp->d_addr == RT_DIR_PHONY_ADDR ) return TREE_NULL;
|
||||
if( db_get_external( &ext, dp, tsp->ts_dbip ) < 0 ) {
|
||||
bu_log("db_recurse() db_get_external() FAIL\n");
|
||||
return(TREE_NULL); /* FAIL */
|
||||
}
|
||||
|
||||
if( dp->d_flags & DIR_COMB ) {
|
||||
struct rt_comb_internal *comb;
|
||||
struct db_tree_state nts;
|
||||
int is_region;
|
||||
|
||||
RT_INIT_DB_INTERNAL(&intern);
|
||||
if( rt_db_get_internal( &intern, dp, tsp->ts_dbip, NULL ) < 0 ) {
|
||||
bu_log("db_recurse() rt_db_get_internal(%s) FAIL\n", dp->d_namep);
|
||||
curtree = TREE_NULL; /* FAIL */
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Handle inheritance of material property. */
|
||||
db_dup_db_tree_state( &nts, tsp );
|
||||
|
||||
if( rt_comb_v4_import( &intern , &ext , NULL ) < 0 ) {
|
||||
bu_log("db_recurse() import of %s failed\n", dp->d_namep);
|
||||
db_free_db_tree_state( &nts );
|
||||
curtree = TREE_NULL; /* FAIL */
|
||||
goto out;
|
||||
}
|
||||
comb = (struct rt_comb_internal *)intern.idb_ptr;
|
||||
RT_CK_COMB(comb);
|
||||
if( (is_region = db_apply_state_from_comb( &nts, pathp, comb )) < 0 ) {
|
||||
@@ -1177,6 +1180,16 @@ region_end:
|
||||
db_free_db_tree_state( &nts );
|
||||
if(curtree) RT_CK_TREE(curtree);
|
||||
} else if( dp->d_flags & DIR_SOLID ) {
|
||||
int id;
|
||||
|
||||
/* Get solid ID */
|
||||
if( (id = rt_id_solid( &ext )) == ID_NULL ) {
|
||||
bu_log("db_recurse(%s): defective database record, addr=x%x\n",
|
||||
dp->d_namep,
|
||||
dp->d_addr );
|
||||
curtree = TREE_NULL; /* FAIL */
|
||||
goto out;
|
||||
}
|
||||
|
||||
if( bn_mat_ck( dp->d_namep, tsp->ts_mat ) < 0 ) {
|
||||
bu_log("db_recurse(%s): matrix does not preserve axis perpendicularity.\n",
|
||||
@@ -1186,16 +1199,6 @@ region_end:
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(rt_g.debug&DEBUG_TREEWALK)
|
||||
bu_log("db_recurse() rt_db_get_internal(%s) solid\n", dp->d_namep);
|
||||
|
||||
RT_INIT_DB_INTERNAL(&intern);
|
||||
if( rt_db_get_internal( &intern, dp, tsp->ts_dbip, tsp->ts_mat ) < 0 ) {
|
||||
bu_log("db_recurse() rt_db_get_internal(%s) FAIL\n", dp->d_namep);
|
||||
curtree = TREE_NULL; /* FAIL */
|
||||
goto out;
|
||||
}
|
||||
|
||||
if( (tsp->ts_sofar & TS_SOFAR_REGION) == 0 &&
|
||||
tsp->ts_stop_at_regions == 0 ) {
|
||||
struct combined_tree_state *ctsp;
|
||||
@@ -1232,7 +1235,7 @@ region_end:
|
||||
curtree = TREE_NULL; /* FAIL */
|
||||
goto out;
|
||||
}
|
||||
curtree = tsp->ts_leaf_func( tsp, pathp, &intern, client_data );
|
||||
curtree = tsp->ts_leaf_func( tsp, pathp, &ext, id, client_data );
|
||||
if(curtree) RT_CK_TREE(curtree);
|
||||
} else {
|
||||
bu_log("db_recurse: %s is neither COMB nor SOLID?\n",
|
||||
@@ -1240,7 +1243,8 @@ region_end:
|
||||
curtree = TREE_NULL;
|
||||
}
|
||||
out:
|
||||
rt_db_free_internal( &intern );
|
||||
if( intern.idb_ptr ) intern.idb_meth->ft_ifree( &intern );
|
||||
db_free_external( &ext );
|
||||
if(rt_g.debug&DEBUG_TREEWALK) {
|
||||
char *sofar = db_path_to_string(pathp);
|
||||
bu_log("db_recurse() return curtree=x%x, pathp='%s', *statepp=x%x\n",
|
||||
@@ -1831,17 +1835,17 @@ genptr_t client_data;
|
||||
return(curtree);
|
||||
}
|
||||
|
||||
HIDDEN union tree *db_gettree_leaf( tsp, pathp, ip, client_data )
|
||||
HIDDEN union tree *db_gettree_leaf( tsp, pathp, ext, id, client_data )
|
||||
struct db_tree_state *tsp;
|
||||
struct db_full_path *pathp;
|
||||
struct rt_db_internal *ip;
|
||||
struct bu_external *ext;
|
||||
int id;
|
||||
genptr_t client_data;
|
||||
{
|
||||
register union tree *curtree;
|
||||
|
||||
RT_CK_DBI(tsp->ts_dbip);
|
||||
RT_CK_FULL_PATH(pathp);
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
|
||||
BU_GETUNION( curtree, tree );
|
||||
curtree->magic = RT_TREE_MAGIC;
|
||||
@@ -1870,7 +1874,7 @@ HIDDEN void
|
||||
db_walk_subtree( tp, region_start_statepp, leaf_func, client_data )
|
||||
register union tree *tp;
|
||||
struct combined_tree_state **region_start_statepp;
|
||||
union tree *(*leaf_func) BU_ARGS((struct db_tree_state *, struct db_full_path *, struct rt_db_internal *, void *));
|
||||
union tree *(*leaf_func) BU_ARGS((struct db_tree_state *, struct db_full_path *, struct bu_external *, int, void *));
|
||||
genptr_t client_data;
|
||||
{
|
||||
struct combined_tree_state *ctsp;
|
||||
@@ -2098,7 +2102,8 @@ union tree * (*reg_end_func) BU_ARGS((
|
||||
union tree * (*leaf_func) BU_ARGS((
|
||||
struct db_tree_state * /*tsp*/,
|
||||
struct db_full_path * /*pathp*/,
|
||||
struct rt_db_internal * /*ip*/,
|
||||
struct bu_external * /*ep*/,
|
||||
int /*id*/,
|
||||
genptr_t client_data
|
||||
));
|
||||
genptr_t client_data;
|
||||
|
||||
+20
-7
@@ -1588,12 +1588,14 @@ dgo_wireframe_region_end(tsp, pathp, curtree, client_data)
|
||||
* This routine must be prepared to run in parallel.
|
||||
*/
|
||||
static union tree *
|
||||
dgo_wireframe_leaf(tsp, pathp, ip, client_data)
|
||||
dgo_wireframe_leaf(tsp, pathp, ep, id, client_data)
|
||||
struct db_tree_state *tsp;
|
||||
struct db_full_path *pathp;
|
||||
struct rt_db_internal *ip;
|
||||
struct bu_external *ep;
|
||||
int id;
|
||||
genptr_t client_data;
|
||||
{
|
||||
struct rt_db_internal intern;
|
||||
union tree *curtree;
|
||||
int dashflag; /* draw with dashed lines */
|
||||
struct bu_list vhead;
|
||||
@@ -1607,8 +1609,7 @@ dgo_wireframe_leaf(tsp, pathp, ip, client_data)
|
||||
if (rt_g.debug&DEBUG_TREEWALK) {
|
||||
char *sofar = db_path_to_string(pathp);
|
||||
|
||||
Tcl_AppendResult(dgcdp->interp, "dgo_wireframe_leaf(",
|
||||
ip->idb_meth->ft_name,
|
||||
Tcl_AppendResult(dgcdp->interp, "dgo_wireframe_leaf(", rt_functab[id].ft_name,
|
||||
") path='", sofar, "'\n", (char *)NULL);
|
||||
bu_free((genptr_t)sofar, "path string");
|
||||
}
|
||||
@@ -1618,13 +1619,24 @@ dgo_wireframe_leaf(tsp, pathp, ip, client_data)
|
||||
else
|
||||
dashflag = (tsp->ts_sofar & (TS_SOFAR_MINUS|TS_SOFAR_INTER));
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
RT_INIT_DB_INTERNAL(&intern);
|
||||
if (rt_functab[id].ft_import(&intern, ep, tsp->ts_mat, dgcdp->dgop->dgo_wdbp->dbip) < 0) {
|
||||
Tcl_AppendResult(dgcdp->interp, DB_FULL_PATH_CUR_DIR(pathp)->d_namep,
|
||||
": solid import failure\n", (char *)NULL);
|
||||
|
||||
if (ip->idb_meth->ft_plot(&vhead, ip,
|
||||
if (intern.idb_ptr)
|
||||
rt_functab[id].ft_ifree( &intern );
|
||||
return (TREE_NULL); /* ERROR */
|
||||
}
|
||||
RT_CK_DB_INTERNAL(&intern);
|
||||
|
||||
if (rt_functab[id].ft_plot(&vhead,
|
||||
&intern,
|
||||
tsp->ts_ttol,
|
||||
tsp->ts_tol) < 0) {
|
||||
Tcl_AppendResult(dgcdp->interp, DB_FULL_PATH_CUR_DIR(pathp)->d_namep,
|
||||
": plot failure\n", (char *)NULL);
|
||||
rt_functab[id].ft_ifree(&intern);
|
||||
return (TREE_NULL); /* ERROR */
|
||||
}
|
||||
|
||||
@@ -1634,7 +1646,7 @@ dgo_wireframe_leaf(tsp, pathp, ip, client_data)
|
||||
* solids, this needs to be something different and drawH
|
||||
* has no idea or need to know what type of solid this is.
|
||||
*/
|
||||
if (ip->idb_type == ID_GRIP) {
|
||||
if (intern.idb_type == ID_GRIP) {
|
||||
int r,g,b;
|
||||
r= tsp->ts_mater.ma_color[0];
|
||||
g= tsp->ts_mater.ma_color[1];
|
||||
@@ -1649,6 +1661,7 @@ dgo_wireframe_leaf(tsp, pathp, ip, client_data)
|
||||
} else {
|
||||
dgo_drawH_part2(dashflag, &vhead, pathp, tsp, SOLID_NULL, dgcdp);
|
||||
}
|
||||
rt_functab[id].ft_ifree(&intern);
|
||||
|
||||
/* Indicate success by returning something other than TREE_NULL */
|
||||
BU_GETUNION(curtree, tree);
|
||||
|
||||
+32
-35
@@ -43,7 +43,10 @@ static char RCSdir[] = "@(#)$Header$";
|
||||
* RTI_NULL Fatal Error
|
||||
*/
|
||||
struct rt_i *
|
||||
rt_dirbuild( const char *filename, char *buf, int len )
|
||||
rt_dirbuild(filename, buf, len)
|
||||
CONST char *filename;
|
||||
char *buf;
|
||||
int len;
|
||||
{
|
||||
register struct rt_i *rtip;
|
||||
register struct db_i *dbip; /* Database instance ptr */
|
||||
@@ -88,10 +91,6 @@ CONST mat_t mat;
|
||||
|
||||
BU_INIT_EXTERNAL(&ext);
|
||||
RT_INIT_DB_INTERNAL(ip);
|
||||
|
||||
if( dbip->dbi_version > 4 )
|
||||
return rt_db_get_internal5( ip, dp, dbip, mat );
|
||||
|
||||
if( db_get_external( &ext, dp, dbip ) < 0 )
|
||||
return -2; /* FAIL */
|
||||
|
||||
@@ -103,15 +102,14 @@ CONST mat_t mat;
|
||||
id = rt_id_solid( &ext );
|
||||
}
|
||||
|
||||
/* ip is already initialized and should not be re-initialized */
|
||||
if( rt_functab[id].ft_import( ip, &ext, mat, dbip ) < 0 ) {
|
||||
bu_log("rt_db_get_internal(%s): import failure\n",
|
||||
dp->d_namep );
|
||||
rt_db_free_internal( ip );
|
||||
bu_free_external( &ext );
|
||||
if( ip->idb_ptr ) ip->idb_meth->ft_ifree( ip );
|
||||
db_free_external( &ext );
|
||||
return -1; /* FAIL */
|
||||
}
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_meth = &rt_functab[id];
|
||||
return id; /* OK */
|
||||
@@ -140,26 +138,24 @@ struct rt_db_internal *ip;
|
||||
BU_INIT_EXTERNAL(&ext);
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
if( dbip->dbi_version > 4 )
|
||||
return rt_db_put_internal5( dp, dbip, ip );
|
||||
|
||||
/* Scale change on export is 1.0 -- no change */
|
||||
ret = ip->idb_meth->ft_export( &ext, ip, 1.0, dbip );
|
||||
if( ret < 0 ) {
|
||||
bu_log("rt_db_put_internal(%s): solid export failure\n",
|
||||
dp->d_namep);
|
||||
rt_db_free_internal( ip );
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return -2; /* FAIL */
|
||||
}
|
||||
rt_db_free_internal( ip );
|
||||
|
||||
if( db_put_external( &ext, dp, dbip ) < 0 ) {
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return -1; /* FAIL */
|
||||
}
|
||||
|
||||
bu_free_external( &ext );
|
||||
if( ip->idb_ptr ) ip->idb_meth->ft_ifree( ip );
|
||||
|
||||
RT_INIT_DB_INTERNAL(ip);
|
||||
db_free_external( &ext );
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
@@ -176,22 +172,21 @@ struct rt_db_internal *ip;
|
||||
* <0 error
|
||||
*/
|
||||
int
|
||||
rt_fwrite_internal(
|
||||
FILE *fp,
|
||||
const char *name,
|
||||
const struct rt_db_internal *ip,
|
||||
double conv2mm )
|
||||
rt_fwrite_internal( fp, name, ip, conv2mm )
|
||||
FILE *fp;
|
||||
CONST char *name;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double conv2mm;
|
||||
{
|
||||
struct bu_external ext;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
RT_CK_FUNCTAB( ip->idb_meth );
|
||||
BU_INIT_EXTERNAL( &ext );
|
||||
|
||||
if( ip->idb_meth->ft_export( &ext, ip, conv2mm, NULL /*dbip*/ ) < 0 ) {
|
||||
bu_log("rt_file_put_internal(%s): solid export failure\n",
|
||||
name );
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return(-2); /* FAIL */
|
||||
}
|
||||
BU_CK_EXTERNAL( &ext );
|
||||
@@ -199,10 +194,10 @@ rt_fwrite_internal(
|
||||
if( db_fwrite_external( fp, name, &ext ) < 0 ) {
|
||||
bu_log("rt_fwrite_internal(%s): db_fwrite_external() error\n",
|
||||
name );
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return(-3);
|
||||
}
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return(0);
|
||||
|
||||
}
|
||||
@@ -211,12 +206,12 @@ rt_fwrite_internal(
|
||||
* R T _ D B _ F R E E _ I N T E R N A L
|
||||
*/
|
||||
void
|
||||
rt_db_free_internal( struct rt_db_internal *ip )
|
||||
rt_db_free_internal( ip )
|
||||
struct rt_db_internal *ip;
|
||||
{
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_CK_FUNCTAB( ip->idb_meth );
|
||||
if( ip->idb_ptr ) ip->idb_meth->ft_ifree(ip);
|
||||
if( ip->idb_avs.magic == BU_AVS_MAGIC ) bu_avs_free(&ip->idb_avs);
|
||||
if( ip->idb_ptr ) ip->idb_meth->ft_ifree( ip );
|
||||
RT_INIT_DB_INTERNAL(ip);
|
||||
}
|
||||
|
||||
@@ -231,12 +226,14 @@ rt_db_free_internal( struct rt_db_internal *ip )
|
||||
* ID_NULL on error, otherwise returns the type of the object.
|
||||
*/
|
||||
int
|
||||
rt_db_lookup_internal (
|
||||
struct db_i *dbip,
|
||||
const char *obj_name,
|
||||
struct directory **dpp,
|
||||
struct rt_db_internal *ip,
|
||||
int noisy )
|
||||
rt_db_lookup_internal (dbip, obj_name, dpp, ip, noisy)
|
||||
|
||||
struct db_i *dbip;
|
||||
char *obj_name;
|
||||
struct directory **dpp;
|
||||
struct rt_db_internal *ip;
|
||||
int noisy;
|
||||
|
||||
{
|
||||
struct directory *dp;
|
||||
|
||||
|
||||
+5
-67
@@ -1019,7 +1019,7 @@ register struct uvcoord *uvp;
|
||||
struct rt_db_internal intern;
|
||||
struct rt_arb_internal *aip;
|
||||
|
||||
BU_CK_EXTERNAL(&ext);
|
||||
BU_INIT_EXTERNAL(&ext);
|
||||
if( db_get_external( &ext, stp->st_dp, ap->a_rt_i->rti_dbip ) < 0 ) {
|
||||
bu_log("rt_arb_uv(%s) db_get_external failure\n",
|
||||
stp->st_name);
|
||||
@@ -1030,10 +1030,10 @@ register struct uvcoord *uvp;
|
||||
ap->a_rt_i->rti_dbip ) < 0 ) {
|
||||
bu_log("rt_arb_uv(%s) database import error\n",
|
||||
stp->st_name);
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
return;
|
||||
}
|
||||
bu_free_external( &ext );
|
||||
db_free_external( &ext );
|
||||
RT_CK_DB_INTERNAL( &intern );
|
||||
aip = (struct rt_arb_internal *)intern.idb_ptr;
|
||||
RT_ARB_CK_MAGIC(aip);
|
||||
@@ -1204,7 +1204,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ARB8;
|
||||
ip->idb_meth = &rt_functab[ID_ARB8];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_arb_internal), "rt_arb_internal");
|
||||
@@ -1246,7 +1246,7 @@ CONST struct db_i *dbip;
|
||||
aip = (struct rt_arb_internal *)ip->idb_ptr;
|
||||
RT_ARB_CK_MAGIC(aip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "arb external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -1263,68 +1263,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ A R B _ I M P O R T 5
|
||||
*
|
||||
* Import an arb from the db5 format and convert to the internal structure.
|
||||
* Code duplicated from rt_arb_import() with db5 help from g_ell.c
|
||||
*/
|
||||
int
|
||||
rt_arb_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_arb_internal *aip;
|
||||
register int i;
|
||||
fastf_t vec[3*8];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 3*8);
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ARB8;
|
||||
ip->idb_meth = &rt_functab[ID_ARB8];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_arb_internal), "rt_arb_internal");
|
||||
|
||||
aip = (struct rt_arb_internal *)ip->idb_ptr;
|
||||
aip->magic = RT_ARB_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, 8*3);
|
||||
for (i=0; i<8; i++) {
|
||||
MAT4X3PNT( aip->pt[i], mat, &vec[i*3]);
|
||||
}
|
||||
return 0; /* OK */
|
||||
}
|
||||
/*
|
||||
* R T _ A R B _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_arb_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_arb_internal *aip;
|
||||
fastf_t vec[3*8];
|
||||
register int i;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if (ip->idb_type != ID_ARB8) return -1;
|
||||
aip = (struct rt_arb_internal *)ip->idb_ptr;
|
||||
RT_ARB_CK_MAGIC(aip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 8 * 3;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "arb external");
|
||||
for (i=0; i<8; i++) {
|
||||
VSCALE( &vec[i*3], aip->pt[i], local2mm );
|
||||
}
|
||||
htond( ep->ext_buf, (unsigned char *)vec, 8*3);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* R T _ A R B _ D E S C R I B E
|
||||
*
|
||||
|
||||
+2
-116
@@ -809,7 +809,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ARBN;
|
||||
ip->idb_meth = &rt_functab[ID_ARBN];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_arbn_internal), "rt_arbn_internal");
|
||||
@@ -874,7 +874,7 @@ CONST struct db_i *dbip;
|
||||
ngrans = (aip->neqn * 8 * 4 + sizeof(union record)-1 ) /
|
||||
sizeof(union record);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = (ngrans + 1) * sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "arbn external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -901,120 +901,6 @@ CONST struct db_i *dbip;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ A R B N _ I M P O R T 5
|
||||
*
|
||||
* Convert from "network" doubles to machine specific.
|
||||
* Transform
|
||||
*/
|
||||
int
|
||||
rt_arbn_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_arbn_internal *aip;
|
||||
register int i;
|
||||
unsigned long neqn;
|
||||
int double_count;
|
||||
int byte_count;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
neqn = bu_glong((unsigned char *)ep->ext_buf);
|
||||
double_count = neqn * ELEMENTS_PER_PLANE;
|
||||
byte_count = double_count * SIZEOF_NETWORK_DOUBLE;
|
||||
|
||||
BU_ASSERT_LONG(ep->ext_nbytes, ==, 4+ byte_count);
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ARBN;
|
||||
ip->idb_meth = &rt_functab[ID_ARBN];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_arbn_internal), "rt_arbn_internal");
|
||||
|
||||
aip = (struct rt_arbn_internal *)ip->idb_ptr;
|
||||
aip->magic = RT_ARBN_INTERNAL_MAGIC;
|
||||
aip->neqn = neqn;
|
||||
if (aip->neqn <= 0) return(-1);
|
||||
aip->eqn = (plane_t *)bu_malloc(byte_count, "arbn plane eqn[]");
|
||||
|
||||
ntohd((unsigned char *)aip->eqn, (unsigned char *)ep->ext_buf + 4, double_count);
|
||||
|
||||
/* Transform by the matrix */
|
||||
# include "noalias.h"
|
||||
for (i=0; i < aip->neqn; i++) {
|
||||
point_t orig_pt;
|
||||
point_t pt;
|
||||
vect_t norm;
|
||||
|
||||
/* Pick a point on the original halfspace */
|
||||
VSCALE( orig_pt, aip->eqn[i], aip->eqn[i][3] );
|
||||
|
||||
/* Transform the point, and the normal */
|
||||
MAT4X3VEC( norm, mat, aip->eqn[i] );
|
||||
MAT4X3PNT( pt, mat, orig_pt );
|
||||
|
||||
/* Measure new distance from origin to new point */
|
||||
VMOVE( aip->eqn[i], norm );
|
||||
aip->eqn[i][3] = VDOT( pt, norm );
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ A R B N _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_arbn_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_arbn_internal *aip;
|
||||
int ngrans;
|
||||
register int i;
|
||||
fastf_t *vec;
|
||||
register fastf_t *sp;
|
||||
int double_count;
|
||||
int byte_count;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_ARBN ) return(-1);
|
||||
aip = (struct rt_arbn_internal *)ip->idb_ptr;
|
||||
RT_ARBN_CK_MAGIC(aip);
|
||||
|
||||
if( aip->neqn <= 0 ) return(-1);
|
||||
|
||||
double_count = aip->neqn * ELEMENTS_PER_PLANE;
|
||||
byte_count = double_count * SIZEOF_NETWORK_DOUBLE;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = 4 + byte_count;
|
||||
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "arbn external");
|
||||
|
||||
(void)bu_plong((unsigned char *)ep->ext_buf, aip->neqn);
|
||||
|
||||
/* Take the data from the caller, and scale it, into vec */
|
||||
sp = vec = (double *)bu_malloc(byte_count, "arbn temp");
|
||||
for (i=0; i<aip->neqn; i++) {
|
||||
/* Normal is unscaled, should have unit length; d is scaled */
|
||||
*sp++ = aip->eqn[i][X];
|
||||
*sp++ = aip->eqn[i][Y];
|
||||
*sp++ = aip->eqn[i][Z];
|
||||
*sp++ = aip->eqn[i][3] * local2mm;
|
||||
}
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond((unsigned char *)ep->ext_buf + 4, (unsigned char *)vec, double_count);
|
||||
|
||||
bu_free((char *)vec, "arbn temp");
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ A R B N _ D E S C R I B E
|
||||
*
|
||||
|
||||
+2
-111
@@ -70,7 +70,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ARS;
|
||||
ip->idb_meth = &rt_functab[ID_ARS];
|
||||
ip->idb_ptr = bu_malloc(sizeof(struct rt_ars_internal), "rt_ars_internal");
|
||||
@@ -146,7 +146,7 @@ CONST struct db_i *dbip;
|
||||
|
||||
per_curve_grans = (arip->pts_per_curve+7)/8;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = (1 + per_curve_grans * arip->ncurves) *
|
||||
sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ars external");
|
||||
@@ -195,115 +195,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ A R S _ I M P O R T 5
|
||||
*
|
||||
* Read all the curves in as a two dimensional array.
|
||||
* The caller is responsible for freeing the dynamic memory.
|
||||
*
|
||||
* Note that in each curve array, the first point is replicated
|
||||
* as the last point, to make processing the data easier.
|
||||
*/
|
||||
int
|
||||
rt_ars_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ars_internal *ari;
|
||||
register int i, j;
|
||||
register unsigned char *cp;
|
||||
vect_t tmp_vec;
|
||||
register fastf_t *fp;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
ip->idb_type = ID_ARS;
|
||||
ip->idb_meth = &rt_functab[ID_ARS];
|
||||
ip->idb_ptr = bu_malloc(sizeof(struct rt_ars_internal), "rt_ars_internal");
|
||||
|
||||
ari = (struct rt_ars_internal *)ip->idb_ptr;
|
||||
ari->magic = RT_ARS_INTERNAL_MAGIC;
|
||||
|
||||
cp = (unsigned char *)ep->ext_buf;
|
||||
ari->ncurves = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
ari->pts_per_curve = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
/*
|
||||
* Read all the curves into internal form.
|
||||
*/
|
||||
ari->curves = (fastf_t **)bu_calloc(
|
||||
(ari->ncurves+1), sizeof(fastf_t *), "ars curve ptrs" );
|
||||
for( i=0; i < ari->ncurves; i++ ) {
|
||||
ari->curves[i] = (fastf_t *)bu_calloc( (ari->pts_per_curve + 1) * 3,
|
||||
sizeof( fastf_t ), "ARS points" );
|
||||
fp = ari->curves[i];
|
||||
for( j=0 ; j<ari->pts_per_curve ; j++ ) {
|
||||
ntohd( (unsigned char *)tmp_vec, cp, 3 );
|
||||
MAT4X3PNT( fp, mat, tmp_vec );
|
||||
cp += 3 * SIZEOF_NETWORK_DOUBLE;
|
||||
fp += ELEMENTS_PER_VECT;
|
||||
}
|
||||
VMOVE( fp, ari->curves[i] ); /* duplicate first point */
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ A R S _ E X P O R T 5
|
||||
*
|
||||
* The name will be added by the caller.
|
||||
* Generally, only libwdb will set conv2mm != 1.0
|
||||
*/
|
||||
int
|
||||
rt_ars_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ars_internal *arip;
|
||||
unsigned char *cp;
|
||||
vect_t tmp_vec;
|
||||
int cur; /* current curve number */
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_ARS ) return(-1);
|
||||
arip = (struct rt_ars_internal *)ip->idb_ptr;
|
||||
RT_ARS_CK_MAGIC(arip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = 2 * SIZEOF_NETWORK_LONG +
|
||||
3 * arip->ncurves * arip->pts_per_curve * SIZEOF_NETWORK_DOUBLE;
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ars external");
|
||||
cp = (unsigned char *)ep->ext_buf;
|
||||
|
||||
(void)bu_plong( cp, arip->ncurves );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
(void)bu_plong( cp, arip->pts_per_curve );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
for( cur=0; cur<arip->ncurves; cur++ ) {
|
||||
register fastf_t *fp;
|
||||
int npts;
|
||||
int left;
|
||||
|
||||
fp = arip->curves[cur];
|
||||
for( npts=0; npts < arip->pts_per_curve; npts++ ) {
|
||||
VSCALE( tmp_vec, fp, local2mm );
|
||||
ntohd( cp, (unsigned char *)tmp_vec, 3 );
|
||||
cp += 3 * SIZEOF_NETWORK_DOUBLE;
|
||||
fp += ELEMENTS_PER_VECT;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ A R S _ D E S C R I B E
|
||||
*
|
||||
|
||||
+3
-167
@@ -1130,7 +1130,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_BOT;
|
||||
ip->idb_meth = &rt_functab[ID_BOT];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_bot_internal), "rt_bot_internal");
|
||||
@@ -1209,7 +1209,7 @@ CONST struct db_i *dbip;
|
||||
bot_ip = (struct rt_bot_internal *)ip->idb_ptr;
|
||||
RT_BOT_CK_MAGIC(bot_ip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof( struct bot_rec ) - 1 +
|
||||
bot_ip->num_vertices * 3 * 8 + bot_ip->num_faces * 3 * 4;
|
||||
if( bot_ip->mode == RT_BOT_PLATE || bot_ip->mode == RT_BOT_PLATE_NOCOS )
|
||||
@@ -1291,170 +1291,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B O T _ I M P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_bot_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_bot_internal *bip;
|
||||
register unsigned char *cp;
|
||||
int i;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_BOT;
|
||||
ip->idb_meth = &rt_functab[ID_BOT];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_bot_internal), "rt_bot_internal");
|
||||
|
||||
bip = (struct rt_bot_internal *)ip->idb_ptr;
|
||||
bip->magic = RT_BOT_INTERNAL_MAGIC;
|
||||
|
||||
cp = ep->ext_buf;
|
||||
bip->num_vertices = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
bip->num_faces = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
bip->orientation = *cp++;
|
||||
bip->mode = *cp++;
|
||||
bip->error_mode = *cp++;
|
||||
|
||||
bip->vertices = (fastf_t *)bu_calloc( bip->num_vertices * 3, sizeof( fastf_t ), "BOT vertices" );
|
||||
bip->faces = (int *)bu_calloc( bip->num_faces * 3, sizeof( int ), "BOT faces" );
|
||||
|
||||
for( i=0 ; i<bip->num_vertices ; i++ )
|
||||
{
|
||||
point_t tmp;
|
||||
|
||||
ntohd( (unsigned char *)tmp, (CONST unsigned char *)cp, 3 );
|
||||
cp += SIZEOF_NETWORK_DOUBLE * 3;
|
||||
MAT4X3PNT( &(bip->vertices[i*3]), mat, tmp );
|
||||
}
|
||||
|
||||
for( i=0 ; i<bip->num_faces ; i++ )
|
||||
{
|
||||
bip->faces[i*3] = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
bip->faces[i*3 + 1] = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
bip->faces[i*3 + 2] = bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
}
|
||||
|
||||
if( bip->mode == RT_BOT_PLATE || bip->mode == RT_BOT_PLATE_NOCOS )
|
||||
{
|
||||
bip->thickness = (fastf_t *)bu_calloc( bip->num_faces, sizeof( fastf_t ), "BOT thickness" );
|
||||
for( i=0 ; i<bip->num_faces ; i++ )
|
||||
{
|
||||
ntohd( (unsigned char *)&(bip->thickness[i]), cp, 1 );
|
||||
cp += SIZEOF_NETWORK_DOUBLE;
|
||||
}
|
||||
bip->face_mode = bu_hex_to_bitv( (CONST char *)cp );
|
||||
}
|
||||
else
|
||||
{
|
||||
bip->thickness = (fastf_t *)NULL;
|
||||
bip->face_mode = (struct bu_bitv *)NULL;
|
||||
}
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B O T _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_bot_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_bot_internal *bip;
|
||||
struct bu_vls vls;
|
||||
register unsigned char *cp;
|
||||
int i;
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
if( ip->idb_type != ID_BOT ) return -1;
|
||||
bip = (struct rt_bot_internal *)ip->idb_ptr;
|
||||
RT_BOT_CK_MAGIC( bip );
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
if( bip->mode == RT_BOT_PLATE || bip->mode == RT_BOT_PLATE_NOCOS )
|
||||
{
|
||||
/* build hex string for face mode */
|
||||
bu_vls_init( &vls );
|
||||
if( bip->face_mode )
|
||||
bu_bitv_to_hex( &vls, bip->face_mode );
|
||||
}
|
||||
|
||||
ep->ext_nbytes = 3 /* orientation, mode, error_mode */
|
||||
+ SIZEOF_NETWORK_LONG * (bip->num_faces * 3 + 2) /* faces, num_faces, num_vertices */
|
||||
+ SIZEOF_NETWORK_DOUBLE * bip->num_vertices * 3; /* vertices */
|
||||
|
||||
if( bip->mode == RT_BOT_PLATE || bip->mode == RT_BOT_PLATE_NOCOS )
|
||||
ep->ext_nbytes += SIZEOF_NETWORK_DOUBLE * bip->num_faces /* face thicknesses */
|
||||
+ bu_vls_strlen( &vls ) + 1; /* face modes */
|
||||
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "BOT external" );
|
||||
|
||||
|
||||
cp = ep->ext_buf;
|
||||
|
||||
(void)bu_plong( cp, bip->num_vertices );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
(void)bu_plong( cp, bip->num_faces );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
*cp++ = bip->orientation;
|
||||
*cp++ = bip->mode;
|
||||
*cp++ = bip->error_mode;
|
||||
|
||||
for( i=0 ; i<bip->num_vertices ; i++ )
|
||||
{
|
||||
point_t tmp;
|
||||
|
||||
VSCALE( tmp, &bip->vertices[i*3], local2mm );
|
||||
htond( cp, (unsigned char *)tmp, 3 );
|
||||
cp += SIZEOF_NETWORK_DOUBLE * 3;
|
||||
}
|
||||
|
||||
for( i=0 ; i<bip->num_faces ; i++ )
|
||||
{
|
||||
(void)bu_plong( cp, bip->faces[i*3] );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
(void)bu_plong( cp, bip->faces[i*3 + 1] );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
(void)bu_plong( cp, bip->faces[i*3 + 2] );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
}
|
||||
|
||||
if( bip->mode == RT_BOT_PLATE || bip->mode == RT_BOT_PLATE_NOCOS )
|
||||
{
|
||||
for( i=0 ; i<bip->num_faces ; i++ )
|
||||
{
|
||||
fastf_t tmp;
|
||||
|
||||
tmp = bip->thickness[i] * local2mm;
|
||||
htond( cp, (CONST unsigned char *)&tmp, 1 );
|
||||
cp += SIZEOF_NETWORK_DOUBLE;
|
||||
}
|
||||
strcpy( (char *)cp, bu_vls_addr( &vls ) );
|
||||
cp += bu_vls_strlen( &vls );
|
||||
*cp = '\0';
|
||||
bu_vls_free( &vls );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ B O T _ D E S C R I B E
|
||||
*
|
||||
@@ -1614,7 +1450,7 @@ struct db_i *dbip;
|
||||
|
||||
if( op != ip && !free )
|
||||
{
|
||||
RT_CK_DB_INTERNAL( op );
|
||||
RT_INIT_DB_INTERNAL( op );
|
||||
botop = (struct rt_bot_internal *)bu_malloc( sizeof( struct rt_bot_internal ), "botop" );
|
||||
botop->magic = RT_BOT_INTERNAL_MAGIC;
|
||||
botop->mode = botip->mode;
|
||||
|
||||
+2
-76
@@ -545,7 +545,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_CLINE;
|
||||
ip->idb_meth = &rt_functab[ID_CLINE];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_cline_internal), "rt_cline_internal");
|
||||
@@ -585,7 +585,7 @@ CONST struct db_i *dbip;
|
||||
cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
|
||||
RT_CLINE_CK_MAGIC(cline_ip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "cline external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -605,80 +605,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C L I N E _ I M P O R T 5
|
||||
*
|
||||
* Import an cline from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_cline_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_cline_internal *cline_ip;
|
||||
fastf_t vec[8];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 8 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_CLINE;
|
||||
ip->idb_meth = &rt_functab[ID_CLINE];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_cline_internal), "rt_cline_internal");
|
||||
|
||||
cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
|
||||
cline_ip->magic = RT_CLINE_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, 8 );
|
||||
|
||||
cline_ip->thickness = vec[0] / mat[15];
|
||||
cline_ip->radius = vec[1] / mat[15];
|
||||
MAT4X3PNT(cline_ip->v, mat, &vec[2]);
|
||||
MAT4X3VEC(cline_ip->h, mat, &vec[5]);
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C L I N E _ E X P O R T 5
|
||||
*
|
||||
* The name is added by the caller, in the usual place.
|
||||
*/
|
||||
int
|
||||
rt_cline_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_cline_internal *cline_ip;
|
||||
fastf_t vec[8];
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if (ip->idb_type != ID_CLINE) return(-1);
|
||||
cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
|
||||
RT_CLINE_CK_MAGIC(cline_ip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 8;
|
||||
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "cline external");
|
||||
|
||||
vec[0] = cline_ip->thickness * local2mm;
|
||||
vec[1] = cline_ip->radius * local2mm;
|
||||
VSCALE(&vec[2], cline_ip->v, local2mm);
|
||||
VSCALE(&vec[5], cline_ip->h, local2mm);
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond(ep->ext_buf, (unsigned char *)vec, 8);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ C L I N E _ D E S C R I B E
|
||||
*
|
||||
|
||||
+90
-283
@@ -159,37 +159,22 @@ static CONST vect_t dsp_pl[BBOX_PLANES] = {
|
||||
{0.0, 0.0, 1.0},
|
||||
};
|
||||
|
||||
/*
|
||||
* This function computes the DSP mtos matrix from the stom matrix
|
||||
* whenever the stom matrix is parsed using a bu_structparse.
|
||||
*/
|
||||
static void
|
||||
hook_mtos_from_stom(
|
||||
const struct bu_structparse *ip,
|
||||
const char *sp_name,
|
||||
genptr_t base,
|
||||
char *p)
|
||||
{
|
||||
struct rt_dsp_internal *dsp_ip = (struct rt_dsp_internal *)base;
|
||||
|
||||
bn_mat_inv(dsp_ip->dsp_mtos, dsp_ip->dsp_stom);
|
||||
}
|
||||
|
||||
|
||||
#define DSP_O(m) offsetof(struct rt_dsp_internal, m)
|
||||
#define DSP_AO(a) bu_offsetofarray(struct rt_dsp_internal, a)
|
||||
|
||||
CONST struct bu_structparse rt_dsp_parse[] = {
|
||||
{"%S", DSP_NAME_LEN, "file", DSP_O(dsp_file), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%s", DSP_NAME_LEN, "file", DSP_AO(dsp_file), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "sm", DSP_O(dsp_smooth), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "w", DSP_O(dsp_xcnt), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "n", DSP_O(dsp_ycnt), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%f", 16, "stom", DSP_AO(dsp_stom), hook_mtos_from_stom },
|
||||
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL }
|
||||
{"%f", 16, "stom", DSP_AO(dsp_stom), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL }
|
||||
};
|
||||
|
||||
CONST struct bu_structparse rt_dsp_ptab[] = {
|
||||
{"%S", DSP_NAME_LEN, "file", DSP_O(dsp_file), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%s", DSP_NAME_LEN, "file", DSP_AO(dsp_file), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "sm", DSP_O(dsp_smooth), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "w", DSP_O(dsp_xcnt), BU_STRUCTPARSE_FUNC_NULL },
|
||||
{"%d", 1, "n", DSP_O(dsp_ycnt), BU_STRUCTPARSE_FUNC_NULL },
|
||||
@@ -207,21 +192,15 @@ CONST struct rt_dsp_internal *dsp_ip;
|
||||
{
|
||||
point_t pt, v;
|
||||
RT_DSP_CK_MAGIC(dsp_ip);
|
||||
BU_CK_VLS(&dsp_ip->dsp_file);
|
||||
|
||||
bu_vls_init( vls );
|
||||
|
||||
bu_vls_printf( vls, "Displacement Map\n file='%s' w=%d n=%d sm=%d ",
|
||||
bu_vls_addr(&dsp_ip->dsp_file),
|
||||
dsp_ip->dsp_xcnt,
|
||||
dsp_ip->dsp_ycnt,
|
||||
dsp_ip->dsp_smooth);
|
||||
bu_vls_printf( vls, "Displacement Map\n file='%s' xs=%d ys=%d sm=%d\n",
|
||||
dsp_ip->dsp_file, dsp_ip->dsp_xcnt, dsp_ip->dsp_ycnt, dsp_ip->dsp_smooth);
|
||||
|
||||
VSETALL(pt, 0.0);
|
||||
|
||||
MAT4X3PNT(v, dsp_ip->dsp_stom, pt);
|
||||
|
||||
bu_vls_printf( vls, " (origin at %g %g %g)mm\n", V3ARGS(v));
|
||||
bu_vls_printf( vls, " V=(%g %g %g)mm\n", v);
|
||||
|
||||
bu_vls_printf( vls, " stom=\n");
|
||||
bu_vls_printf( vls, " %8.3f %8.3f %8.3f %8.3f\n",
|
||||
@@ -235,6 +214,7 @@ CONST struct rt_dsp_internal *dsp_ip;
|
||||
|
||||
bu_vls_printf( vls, " %8.3f %8.3f %8.3f %8.3f\n",
|
||||
V4ARGS( &dsp_ip->dsp_stom[12]) );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -250,13 +230,11 @@ register CONST struct soltab *stp;
|
||||
|
||||
|
||||
RT_DSP_CK_MAGIC(dsp);
|
||||
BU_CK_VLS(&dsp->dsp_i.dsp_file);
|
||||
|
||||
dsp_print(&vls, &(dsp->dsp_i) );
|
||||
|
||||
bu_log("%s", bu_vls_addr( &vls));
|
||||
|
||||
if (BU_VLS_IS_INITIALIZED( &vls )) bu_vls_free( &vls );
|
||||
bu_vls_free( &vls );
|
||||
|
||||
}
|
||||
|
||||
@@ -296,8 +274,6 @@ struct rt_i *rtip;
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
|
||||
RT_DSP_CK_MAGIC(dsp_ip);
|
||||
BU_CK_VLS(&dsp_ip->dsp_file);
|
||||
|
||||
BU_CK_MAPPED_FILE(dsp_ip->dsp_mp);
|
||||
|
||||
BU_GETSTRUCT( dsp, dsp_specific );
|
||||
@@ -1926,7 +1902,6 @@ struct seg *seghead;
|
||||
ap->a_x, ap->a_y);
|
||||
}
|
||||
RT_DSP_CK_MAGIC(dsp);
|
||||
BU_CK_VLS(&dsp->dsp_i.dsp_file);
|
||||
BU_CK_MAPPED_FILE(dsp->dsp_i.dsp_mp);
|
||||
|
||||
|
||||
@@ -2162,11 +2137,6 @@ register struct xray *rp;
|
||||
double len;
|
||||
FILE *fd = (FILE *)NULL;
|
||||
|
||||
RT_DSP_CK_MAGIC(dsp);
|
||||
BU_CK_VLS(&dsp->dsp_i.dsp_file);
|
||||
BU_CK_MAPPED_FILE(dsp->dsp_i.dsp_mp);
|
||||
|
||||
|
||||
if (rt_g.debug & DEBUG_HF)
|
||||
bu_log("rt_dsp_norm(%g %g %g)\n", V3ARGS(hitp->hit_normal));
|
||||
|
||||
@@ -2690,26 +2660,78 @@ CONST struct bn_tol *tol;
|
||||
}
|
||||
|
||||
/*
|
||||
* D S P _ G E T _ D A T A
|
||||
* R T _ D S P _ I M P O R T
|
||||
*
|
||||
* Handle things common to both the v4 and v5 database.
|
||||
*
|
||||
* This include applying the modelling transform, and fetching the
|
||||
* actual data.
|
||||
* Import an DSP from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
static int
|
||||
dsp_get_data(struct rt_dsp_internal *dsp_ip,
|
||||
struct rt_db_internal *ip,
|
||||
const struct bu_external *ep,
|
||||
register const mat_t mat,
|
||||
const struct db_i *dbip)
|
||||
int
|
||||
rt_dsp_import( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
mat_t tmp;
|
||||
LOCAL struct rt_dsp_internal *dsp_ip;
|
||||
union record *rp;
|
||||
struct bu_vls str;
|
||||
mat_t tmp;
|
||||
struct bu_mapped_file *mf;
|
||||
int count;
|
||||
int in_cookie, out_cookie;
|
||||
|
||||
/* Apply Modeling transform */
|
||||
#define IMPORT_FAIL(_s) \
|
||||
bu_log("rt_dsp_import(%d) '%s' %s\n", __LINE__, dsp_ip->dsp_file,_s);\
|
||||
bu_free( (char *)dsp_ip , "rt_dsp_import: dsp_ip" ); \
|
||||
ip->idb_type = ID_NULL; \
|
||||
ip->idb_ptr = (genptr_t)NULL; \
|
||||
return -2
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
rp = (union record *)ep->ext_buf;
|
||||
|
||||
if (rt_g.debug & DEBUG_HF)
|
||||
bu_log("rt_dsp_import(%s)\n", rp->ss.ss_args);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Check record type */
|
||||
if (rp->u_id != DBID_STRSOL ) {
|
||||
bu_log("rt_dsp_import: defective record\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_DSP;
|
||||
ip->idb_meth = &rt_functab[ID_DSP];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_dsp_internal), "rt_dsp_internal");
|
||||
dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
|
||||
dsp_ip->magic = RT_DSP_INTERNAL_MAGIC;
|
||||
|
||||
/* set defaults */
|
||||
/* XXX bu_struct_parse does not set the null? */
|
||||
memset(&dsp_ip->dsp_file[0], 0, DSP_NAME_LEN);
|
||||
dsp_ip->dsp_xcnt = dsp_ip->dsp_ycnt = 0;
|
||||
dsp_ip->dsp_xs = dsp_ip->dsp_ys = dsp_ip->dsp_zs = 0.0;
|
||||
dsp_ip->dsp_smooth = 1;
|
||||
bn_mat_idn(dsp_ip->dsp_stom);
|
||||
bn_mat_idn(dsp_ip->dsp_mtos);
|
||||
|
||||
bu_vls_init( &str );
|
||||
bu_vls_strcpy( &str, rp->ss.ss_args );
|
||||
if (bu_struct_parse( &str, rt_dsp_parse, (char *)dsp_ip ) < 0) {
|
||||
bu_vls_free( &str );
|
||||
IMPORT_FAIL("parse error");
|
||||
}
|
||||
|
||||
|
||||
/* Validate parameters */
|
||||
if (dsp_ip->dsp_xcnt == 0 || dsp_ip->dsp_ycnt == 0) {
|
||||
IMPORT_FAIL("zero dimension on map");
|
||||
}
|
||||
|
||||
/* Apply Modeling transoform */
|
||||
bn_mat_copy(tmp, dsp_ip->dsp_stom);
|
||||
bn_mat_mul(dsp_ip->dsp_stom, mat, tmp);
|
||||
|
||||
@@ -2718,15 +2740,12 @@ dsp_get_data(struct rt_dsp_internal *dsp_ip,
|
||||
/* get file */
|
||||
mf = dsp_ip->dsp_mp =
|
||||
bu_open_mapped_file_with_path(dbip->dbi_filepath,
|
||||
bu_vls_addr(&dsp_ip->dsp_file), "dsp");
|
||||
dsp_ip->dsp_file, "dsp");
|
||||
if (!mf) {
|
||||
bu_log("mapped file open failed\n");
|
||||
return -1;
|
||||
IMPORT_FAIL("unable to open");
|
||||
}
|
||||
|
||||
if (dsp_ip->dsp_mp->buflen != dsp_ip->dsp_xcnt*dsp_ip->dsp_ycnt*2) {
|
||||
bu_log("DSP buffer wrong size");
|
||||
return -1;
|
||||
IMPORT_FAIL("buffer wrong size");
|
||||
}
|
||||
|
||||
in_cookie = bu_cv_cookie("nus"); /* data is network unsigned short */
|
||||
@@ -2751,87 +2770,6 @@ dsp_get_data(struct rt_dsp_internal *dsp_ip,
|
||||
} else {
|
||||
dsp_ip->dsp_buf = dsp_ip->dsp_mp->buf;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ D S P _ I M P O R T
|
||||
*
|
||||
* Import an DSP from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_dsp_import( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
LOCAL struct rt_dsp_internal *dsp_ip;
|
||||
union record *rp;
|
||||
struct bu_vls str;
|
||||
mat_t tmp;
|
||||
struct bu_mapped_file *mf;
|
||||
int count;
|
||||
int in_cookie, out_cookie;
|
||||
|
||||
#define IMPORT_FAIL(_s) \
|
||||
bu_log("rt_dsp_import(%d) '%s' %s\n", __LINE__, \
|
||||
bu_vls_addr(&dsp_ip->dsp_file), _s);\
|
||||
bu_free( (char *)dsp_ip , "rt_dsp_import: dsp_ip" ); \
|
||||
ip->idb_type = ID_NULL; \
|
||||
ip->idb_ptr = (genptr_t)NULL; \
|
||||
return -2
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
rp = (union record *)ep->ext_buf;
|
||||
|
||||
if (rt_g.debug & DEBUG_HF)
|
||||
bu_log("rt_dsp_import(%s)\n", rp->ss.ss_args);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Check record type */
|
||||
if (rp->u_id != DBID_STRSOL ) {
|
||||
bu_log("rt_dsp_import: defective record\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_DSP;
|
||||
ip->idb_meth = &rt_functab[ID_DSP];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_dsp_internal), "rt_dsp_internal");
|
||||
dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
|
||||
dsp_ip->magic = RT_DSP_INTERNAL_MAGIC;
|
||||
|
||||
/* set defaults */
|
||||
/* XXX bu_struct_parse does not set the null?
|
||||
* memset(&dsp_ip->dsp_file[0], 0, DSP_NAME_LEN);
|
||||
*/
|
||||
dsp_ip->dsp_xcnt = dsp_ip->dsp_ycnt = 0;
|
||||
|
||||
dsp_ip->dsp_smooth = 1;
|
||||
bn_mat_idn(dsp_ip->dsp_stom);
|
||||
bn_mat_idn(dsp_ip->dsp_mtos);
|
||||
|
||||
bu_vls_init( &str );
|
||||
bu_vls_strcpy( &str, rp->ss.ss_args );
|
||||
if (bu_struct_parse( &str, rt_dsp_parse, (char *)dsp_ip ) < 0) {
|
||||
if (BU_VLS_IS_INITIALIZED( &str )) bu_vls_free( &str );
|
||||
|
||||
IMPORT_FAIL("parse error");
|
||||
}
|
||||
|
||||
|
||||
/* Validate parameters */
|
||||
if (dsp_ip->dsp_xcnt == 0 || dsp_ip->dsp_ycnt == 0) {
|
||||
IMPORT_FAIL("zero dimension on map");
|
||||
}
|
||||
|
||||
if (dsp_get_data(dsp_ip, ip, ep, mat, dbip)) {
|
||||
IMPORT_FAIL("DSP data");
|
||||
}
|
||||
|
||||
if (rt_g.debug & DEBUG_HF) {
|
||||
bu_vls_trunc(&str, 0);
|
||||
@@ -2839,12 +2777,10 @@ CONST struct db_i *dbip;
|
||||
bu_log(" imported as(%s)\n", bu_vls_addr(&str));
|
||||
|
||||
}
|
||||
|
||||
if (BU_VLS_IS_INITIALIZED( &str )) bu_vls_free( &str );
|
||||
bu_vls_free( &str );
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ D S P _ E X P O R T
|
||||
*
|
||||
@@ -2867,12 +2803,10 @@ CONST struct db_i *dbip;
|
||||
if (ip->idb_type != ID_DSP ) return(-1);
|
||||
dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
|
||||
RT_DSP_CK_MAGIC(dsp_ip);
|
||||
BU_CK_VLS(&dsp_ip->dsp_file);
|
||||
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record)*DB_SS_NGRAN;
|
||||
ep->ext_buf = bu_calloc( 1, ep->ext_nbytes, "dsp external");
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "dsp external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
|
||||
dsp = *dsp_ip; /* struct copy */
|
||||
@@ -2893,140 +2827,12 @@ CONST struct db_i *dbip;
|
||||
strncpy( rec->ss.ss_args, bu_vls_addr(&str), DB_SS_LEN-1 );
|
||||
|
||||
|
||||
if (BU_VLS_IS_INITIALIZED( &str )) bu_vls_free( &str );
|
||||
bu_vls_free( &str );
|
||||
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* R T _ D S P _ I M P O R T 5
|
||||
*
|
||||
* Import an DSP from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_dsp_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_dsp_internal *dsp_ip;
|
||||
unsigned short name_len;
|
||||
unsigned char *cp;
|
||||
mat_t tmp;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, >, 141 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
ip->idb_type = ID_DSP;
|
||||
ip->idb_meth = &rt_functab[ID_DSP];
|
||||
dsp_ip = ip->idb_ptr =
|
||||
bu_malloc( sizeof(struct rt_dsp_internal), "rt_dsp_internal");
|
||||
|
||||
dsp_ip->magic = RT_DSP_INTERNAL_MAGIC;
|
||||
|
||||
/* get x, y counts */
|
||||
cp = (unsigned char *)ep->ext_buf;
|
||||
|
||||
dsp_ip->dsp_xcnt = (unsigned) bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
dsp_ip->dsp_ycnt = (unsigned) bu_glong( cp );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
/* convert matrix */
|
||||
ntohd((unsigned char *)dsp_ip->dsp_mtos, cp, 16);
|
||||
cp += SIZEOF_NETWORK_DOUBLE * 16;
|
||||
bn_mat_inv(dsp_ip->dsp_stom, dsp_ip->dsp_mtos);
|
||||
|
||||
|
||||
/* convert smooth flag */
|
||||
dsp_ip->dsp_smooth = bu_gshort( cp );
|
||||
cp += SIZEOF_NETWORK_SHORT;
|
||||
|
||||
/* convert name of data location */
|
||||
bu_vls_init( &dsp_ip->dsp_file );
|
||||
bu_vls_strcpy( &dsp_ip->dsp_file, cp );
|
||||
|
||||
if (dsp_get_data(dsp_ip, ip, ep, mat, dbip)) {
|
||||
IMPORT_FAIL("DSP data");
|
||||
}
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ D S P _ E X P O R T 5
|
||||
*
|
||||
* The name is added by the caller, in the usual place.
|
||||
*/
|
||||
int
|
||||
rt_dsp_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_dsp_internal *dsp_ip;
|
||||
struct rt_dsp_internal dsp;
|
||||
union record *rec;
|
||||
struct bu_vls str;
|
||||
unsigned long name_len;
|
||||
register unsigned long tmp;
|
||||
unsigned char *cp;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if (ip->idb_type != ID_DSP ) return(-1);
|
||||
dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
|
||||
RT_DSP_CK_MAGIC(dsp_ip);
|
||||
|
||||
name_len = bu_vls_strlen(&dsp_ip->dsp_file) + 1;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = 138 + name_len;
|
||||
ep->ext_buf = bu_malloc( ep->ext_nbytes, "dsp external");
|
||||
cp = (unsigned char *)ep->ext_buf;
|
||||
|
||||
memset(ep->ext_buf, 0, ep->ext_nbytes);
|
||||
|
||||
|
||||
/* Now we fill the buffer with the data, making sure everything is
|
||||
* converted to Big-Endian IEEE
|
||||
*/
|
||||
|
||||
bu_plong( cp, (unsigned long)dsp_ip->dsp_xcnt );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
bu_plong( cp, (unsigned long)dsp_ip->dsp_ycnt );
|
||||
cp += SIZEOF_NETWORK_LONG;
|
||||
|
||||
/* Since libwdb users may want to operate in units other
|
||||
* than mm, we offer the opportunity to scale the solid
|
||||
* (to get it into mm) on the way out.
|
||||
*/
|
||||
dsp_ip->dsp_mtos[15] /= local2mm;
|
||||
|
||||
htond(cp, (unsigned char *)dsp_ip->dsp_mtos, 16);
|
||||
cp += SIZEOF_NETWORK_DOUBLE * 16;
|
||||
|
||||
bu_pshort( cp, (int)dsp_ip->dsp_smooth );
|
||||
cp += SIZEOF_NETWORK_SHORT;
|
||||
|
||||
strncpy(cp, bu_vls_addr(&dsp_ip->dsp_file), name_len);
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* R T _ D S P _ D E S C R I B E
|
||||
*
|
||||
@@ -3053,8 +2859,15 @@ double mm2local;
|
||||
|
||||
dsp_print(&vls, dsp_ip);
|
||||
bu_vls_vlscat( str, &vls );
|
||||
bu_vls_free( &vls );
|
||||
|
||||
if (BU_VLS_IS_INITIALIZED( &vls )) bu_vls_free( &vls );
|
||||
#if 0
|
||||
sprintf(buf, "\tV (%g, %g, %g)\n",
|
||||
dsp_ip->v[X] * mm2local,
|
||||
dsp_ip->v[Y] * mm2local,
|
||||
dsp_ip->v[Z] * mm2local );
|
||||
bu_vls_strcat( str, buf );
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -3085,12 +2898,6 @@ struct rt_db_internal *ip;
|
||||
dsp_ip->magic = 0; /* sanity */
|
||||
dsp_ip->dsp_mp = (struct bu_mapped_file *)0;
|
||||
|
||||
if (BU_VLS_IS_INITIALIZED(&dsp_ip->dsp_file))
|
||||
bu_vls_free( &dsp_ip->dsp_file );
|
||||
else
|
||||
bu_log("Freeing Bogus DSP, VLS string not initialized\n");
|
||||
|
||||
|
||||
bu_free( (char *)dsp_ip, "dsp ifree" );
|
||||
ip->idb_ptr = GENPTR_NULL; /* sanity */
|
||||
}
|
||||
|
||||
+2
-148
@@ -540,7 +540,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EBM;
|
||||
ip->idb_meth = &rt_functab[ID_EBM];
|
||||
ip->idb_ptr = bu_calloc(1, sizeof(struct rt_ebm_internal), "rt_ebm_internal");
|
||||
@@ -650,7 +650,7 @@ CONST struct db_i *dbip;
|
||||
/* Apply scale factor */
|
||||
ebm.mat[15] /= local2mm;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record)*DB_SS_NGRAN;
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ebm external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -666,152 +666,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ E B M _ I M P O R T 5
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
int
|
||||
rt_ebm_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
register struct rt_ebm_internal *eip;
|
||||
struct bu_vls str;
|
||||
int nbytes;
|
||||
mat_t tmat;
|
||||
struct bu_mapped_file *mp;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
|
||||
ip->idb_type = ID_EBM;
|
||||
ip->idb_meth = &rt_functab[ID_EBM];
|
||||
ip->idb_ptr = bu_calloc(1, sizeof(struct rt_ebm_internal), "rt_ebm_internal");
|
||||
eip = (struct rt_ebm_internal *)ip->idb_ptr;
|
||||
eip->magic = RT_EBM_INTERNAL_MAGIC;
|
||||
|
||||
/* Provide default orientation info */
|
||||
bn_mat_idn( eip->mat );
|
||||
|
||||
bu_vls_init( &str );
|
||||
bu_vls_strcpy( &str, ep->ext_buf );
|
||||
if( bu_struct_parse( &str, rt_ebm_parse, (char *)eip ) < 0 ) {
|
||||
bu_vls_free( &str );
|
||||
bu_free( (char *)eip , "rt_ebm_import: eip" );
|
||||
ip->idb_type = ID_NULL;
|
||||
ip->idb_ptr = (genptr_t)NULL;
|
||||
return -2;
|
||||
}
|
||||
bu_vls_free( &str );
|
||||
|
||||
/* Check for reasonable values */
|
||||
if( eip->file[0] == '\0' || eip->xdim < 1 ||
|
||||
eip->ydim < 1 || eip->mat[15] <= 0.0 ||
|
||||
eip->tallness <= 0.0 ) {
|
||||
bu_struct_print( "Unreasonable EBM parameters", rt_ebm_parse,
|
||||
(char *)eip );
|
||||
bu_free( (char *)eip , "rt_ebm_import: eip" );
|
||||
ip->idb_type = ID_NULL;
|
||||
ip->idb_ptr = (genptr_t)NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Apply any modeling transforms to get final matrix */
|
||||
bn_mat_mul( tmat, mat, eip->mat );
|
||||
bn_mat_copy( eip->mat, tmat );
|
||||
|
||||
/* Get bit map from .bw(5) file */
|
||||
if( !(mp = bu_open_mapped_file_with_path( dbip->dbi_filepath, eip->file, "ebm" )) ) {
|
||||
bu_log("rt_ebm_import() unable to open '%s'\n", eip->file);
|
||||
bu_free( (char *)eip , "rt_ebm_import: eip" );
|
||||
fail:
|
||||
ip->idb_type = ID_NULL;
|
||||
ip->idb_ptr = (genptr_t)NULL;
|
||||
return -1;
|
||||
}
|
||||
eip->mp = mp;
|
||||
if( mp->buflen < eip->xdim*eip->ydim ) {
|
||||
bu_log("rt_ebm_import() file '%s' is too short %d < %d\n",
|
||||
eip->file, mp->buflen, eip->xdim*eip->ydim );
|
||||
goto fail;
|
||||
}
|
||||
|
||||
nbytes = (eip->xdim+BIT_XWIDEN*2)*(eip->ydim+BIT_YWIDEN*2);
|
||||
|
||||
/* If first use of this file, prepare in-memory buffer */
|
||||
if( !mp->apbuf ) {
|
||||
register int y;
|
||||
unsigned char *cp;
|
||||
|
||||
/* Prevent a multi-processor race */
|
||||
bu_semaphore_acquire(RT_SEM_MODEL);
|
||||
if( mp->apbuf ) {
|
||||
/* someone else beat us, nothing more to do */
|
||||
bu_semaphore_release(RT_SEM_MODEL);
|
||||
return 0;
|
||||
}
|
||||
mp->apbuf = (genptr_t)bu_calloc(
|
||||
1, nbytes, "rt_ebm_import bitmap" );
|
||||
mp->apbuflen = nbytes;
|
||||
|
||||
bu_semaphore_release(RT_SEM_MODEL);
|
||||
|
||||
/* Because of in-memory padding, read each scanline separately */
|
||||
cp = (unsigned char *)mp->buf;
|
||||
for( y=0; y < eip->ydim; y++ ) {
|
||||
/* BIT() addresses into mp->apbuf */
|
||||
bcopy( cp, &BIT( eip, 0, y), eip->xdim );
|
||||
cp += eip->xdim;
|
||||
}
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E B M _ E X P O R T 5
|
||||
*
|
||||
* The name will be added by the caller.
|
||||
*/
|
||||
int
|
||||
rt_ebm_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ebm_internal *eip;
|
||||
struct rt_ebm_internal ebm; /* scaled version */
|
||||
struct bu_vls str;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_EBM ) return(-1);
|
||||
eip = (struct rt_ebm_internal *)ip->idb_ptr;
|
||||
RT_EBM_CK_MAGIC(eip);
|
||||
ebm = *eip; /* struct copy */
|
||||
|
||||
/* Apply scale factor */
|
||||
ebm.mat[15] /= local2mm;
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
|
||||
bu_vls_init( &str );
|
||||
bu_vls_struct_print( &str, rt_ebm_parse, (char *)&ebm );
|
||||
|
||||
ep->ext_nbytes = bu_vls_strlen( &str );
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ebm external");
|
||||
|
||||
strcpy( ep->ext_buf , bu_vls_addr(&str) );
|
||||
bu_vls_free( &str );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E B M _ D E S C R I B E
|
||||
*
|
||||
|
||||
+2
-114
@@ -1429,7 +1429,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EHY;
|
||||
ip->idb_meth = &rt_functab[ID_EHY];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_ehy_internal), "rt_ehy_internal");
|
||||
@@ -1475,7 +1475,7 @@ CONST struct db_i *dbip;
|
||||
xip = (struct rt_ehy_internal *)ip->idb_ptr;
|
||||
RT_EHY_CK_MAGIC(xip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ehy external");
|
||||
ehy = (union record *)ep->ext_buf;
|
||||
@@ -1518,118 +1518,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E H Y _ I M P O R T 5
|
||||
*
|
||||
* Import an EHY from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_ehy_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
LOCAL struct rt_ehy_internal *xip;
|
||||
fastf_t vec[3*4];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 3*4 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EHY;
|
||||
ip->idb_meth = &rt_functab[ID_EHY];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_ehy_internal), "rt_ehy_internal");
|
||||
|
||||
xip = (struct rt_ehy_internal *)ip->idb_ptr;
|
||||
xip->ehy_magic = RT_EHY_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, 3*4 );
|
||||
|
||||
/* Apply modeling transformations */
|
||||
MAT4X3PNT( xip->ehy_V, mat, &vec[0*3] );
|
||||
MAT4X3VEC( xip->ehy_H, mat, &vec[1*3] );
|
||||
MAT4X3VEC( xip->ehy_Au, mat, &vec[2*3] );
|
||||
VUNITIZE( xip->ehy_Au );
|
||||
xip->ehy_r1 = vec[3*3] / mat[15];
|
||||
xip->ehy_r2 = vec[3*3+1] / mat[15];
|
||||
xip->ehy_c = vec[3*3+2] / mat[15];
|
||||
|
||||
if( xip->ehy_r1 < SMALL_FASTF || xip->ehy_r2 < SMALL_FASTF || xip->ehy_c < SMALL_FASTF )
|
||||
{
|
||||
bu_log( "rt_ehy_import: r1, r2, or c are zero\n" );
|
||||
bu_free( (char *)ip->idb_ptr , "rt_ehy_import: ip->idb_ptr" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E H Y _ E X P O R T 5
|
||||
*
|
||||
* The name is added by the caller, in the usual place.
|
||||
*/
|
||||
int
|
||||
rt_ehy_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ehy_internal *xip;
|
||||
fastf_t vec[3*4];
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_EHY ) return(-1);
|
||||
xip = (struct rt_ehy_internal *)ip->idb_ptr;
|
||||
RT_EHY_CK_MAGIC(xip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 3*4;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "ehy external");
|
||||
|
||||
if (!NEAR_ZERO( MAGNITUDE(xip->ehy_Au) - 1., RT_LEN_TOL)) {
|
||||
bu_log("rt_ehy_export: Au not a unit vector!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (MAGNITUDE(xip->ehy_H) < RT_LEN_TOL
|
||||
|| xip->ehy_c < RT_LEN_TOL
|
||||
|| xip->ehy_r1 < RT_LEN_TOL
|
||||
|| xip->ehy_r2 < RT_LEN_TOL) {
|
||||
bu_log("rt_ehy_export: not all dimensions positive!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ( !NEAR_ZERO( VDOT(xip->ehy_Au, xip->ehy_H), RT_DOT_TOL) ) {
|
||||
bu_log("rt_ehy_export: Au and H are not perpendicular!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (xip->ehy_r2 > xip->ehy_r1) {
|
||||
bu_log("rt_ehy_export: semi-minor axis cannot be longer than semi-major axis!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Warning: type conversion */
|
||||
VSCALE( &vec[0*3], xip->ehy_V, local2mm );
|
||||
VSCALE( &vec[1*3], xip->ehy_H, local2mm );
|
||||
/* don't scale ehy_Au (unit vector!!) */
|
||||
VMOVE( &vec[2*3], xip->ehy_Au );
|
||||
vec[3*3] = xip->ehy_r1 * local2mm;
|
||||
vec[3*3+1] = xip->ehy_r2 * local2mm;
|
||||
vec[3*3+2] = xip->ehy_c * local2mm;
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond( ep->ext_buf, (unsigned char *)vec, 3*4 );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E H Y _ D E S C R I B E
|
||||
*
|
||||
|
||||
+5
-86
@@ -1137,7 +1137,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ELL;
|
||||
ip->idb_meth = &rt_functab[ID_ELL];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_ell_internal), "rt_ell_internal");
|
||||
@@ -1174,7 +1174,7 @@ CONST struct db_i *dbip;
|
||||
tip = (struct rt_ell_internal *)ip->idb_ptr;
|
||||
RT_ELL_CK_MAGIC(tip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "ell external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -1191,87 +1191,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E L L _ I M P O R T 5
|
||||
*
|
||||
* Import an ellipsoid/sphere from the database format to
|
||||
* the internal structure.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_ell_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ell_internal *eip;
|
||||
fastf_t vec[ELEMENTS_PER_VECT*4];
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT*4 );
|
||||
|
||||
ip->idb_type = ID_ELL;
|
||||
ip->idb_meth = &rt_functab[ID_ELL];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_ell_internal), "rt_ell_internal");
|
||||
|
||||
eip = (struct rt_ell_internal *)ip->idb_ptr;
|
||||
eip->magic = RT_ELL_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, ELEMENTS_PER_VECT*4 );
|
||||
|
||||
/* Apply modeling transformations */
|
||||
MAT4X3PNT( eip->v, mat, &vec[0*ELEMENTS_PER_VECT] );
|
||||
MAT4X3VEC( eip->a, mat, &vec[1*ELEMENTS_PER_VECT] );
|
||||
MAT4X3VEC( eip->b, mat, &vec[2*ELEMENTS_PER_VECT] );
|
||||
MAT4X3VEC( eip->c, mat, &vec[3*ELEMENTS_PER_VECT] );
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E L L _ E X P O R T 5
|
||||
*
|
||||
* The external format is:
|
||||
* V point
|
||||
* A vector
|
||||
* B vector
|
||||
* C vector
|
||||
*/
|
||||
int
|
||||
rt_ell_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_ell_internal *eip;
|
||||
fastf_t vec[ELEMENTS_PER_VECT*4];
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_ELL ) return -1;
|
||||
eip = (struct rt_ell_internal *)ip->idb_ptr;
|
||||
RT_ELL_CK_MAGIC(eip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT*4;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "ell external");
|
||||
|
||||
/* scale 'em into local buffer */
|
||||
VSCALE( &vec[0*ELEMENTS_PER_VECT], eip->v, local2mm );
|
||||
VSCALE( &vec[1*ELEMENTS_PER_VECT], eip->a, local2mm );
|
||||
VSCALE( &vec[2*ELEMENTS_PER_VECT], eip->b, local2mm );
|
||||
VSCALE( &vec[3*ELEMENTS_PER_VECT], eip->c, local2mm );
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond( ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT*4 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E L L _ D E S C R I B E
|
||||
*
|
||||
@@ -1362,7 +1281,7 @@ struct rt_db_internal *ip;
|
||||
* In order to orient loop CCW, need to start with 0,1-->0,0 transition
|
||||
* at the south pole.
|
||||
*/
|
||||
static CONST fastf_t rt_ell_uvw[5*ELEMENTS_PER_VECT] = {
|
||||
static CONST fastf_t rt_ell_uvw[5*3] = {
|
||||
0, 1, 0,
|
||||
0, 0, 0,
|
||||
1, 0, 0,
|
||||
@@ -1517,8 +1436,8 @@ CONST struct bn_tol *tol;
|
||||
|
||||
/* Loop always has Counter-Clockwise orientation (CCW) */
|
||||
for( i=0; i < 4; i++ ) {
|
||||
nmg_vertexuse_a_cnurb( eu->vu_p, &rt_ell_uvw[i*ELEMENTS_PER_VECT] );
|
||||
nmg_vertexuse_a_cnurb( eu->eumate_p->vu_p, &rt_ell_uvw[(i+1)*ELEMENTS_PER_VECT] );
|
||||
nmg_vertexuse_a_cnurb( eu->vu_p, &rt_ell_uvw[i*3] );
|
||||
nmg_vertexuse_a_cnurb( eu->eumate_p->vu_p, &rt_ell_uvw[(i+1)*3] );
|
||||
eu = BU_LIST_NEXT( edgeuse, &eu->l );
|
||||
}
|
||||
|
||||
|
||||
+2
-113
@@ -1476,7 +1476,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EPA;
|
||||
ip->idb_meth = &rt_functab[ID_EPA];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_epa_internal), "rt_epa_internal");
|
||||
@@ -1522,7 +1522,7 @@ CONST struct db_i *dbip;
|
||||
xip = (struct rt_epa_internal *)ip->idb_ptr;
|
||||
RT_EPA_CK_MAGIC(xip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "epa external");
|
||||
epa = (union record *)ep->ext_buf;
|
||||
@@ -1564,117 +1564,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E P A _ I M P O R T 5
|
||||
*
|
||||
* Import an EPA from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_epa_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
LOCAL struct rt_epa_internal *xip;
|
||||
fastf_t vec[11];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 11 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EPA;
|
||||
ip->idb_meth = &rt_functab[ID_EPA];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_epa_internal), "rt_epa_internal");
|
||||
|
||||
xip = (struct rt_epa_internal *)ip->idb_ptr;
|
||||
xip->epa_magic = RT_EPA_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, 11 );
|
||||
|
||||
/* Apply modeling transformations */
|
||||
MAT4X3PNT( xip->epa_V, mat, &vec[0*3] );
|
||||
MAT4X3VEC( xip->epa_H, mat, &vec[1*3] );
|
||||
MAT4X3VEC( xip->epa_Au, mat, &vec[2*3] );
|
||||
VUNITIZE( xip->epa_Au );
|
||||
xip->epa_r1 = vec[3*3] / mat[15];
|
||||
xip->epa_r2 = vec[3*3+1] / mat[15];
|
||||
|
||||
if( xip->epa_r1 < SMALL_FASTF || xip->epa_r2 < SMALL_FASTF )
|
||||
{
|
||||
bu_log( "rt_epa_import: r1 or r2 are zero\n" );
|
||||
bu_free( (char *)ip->idb_ptr , "rt_epa_import: ip->idb_ptr" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E P A _ E X P O R T 5
|
||||
*
|
||||
* The name is added by the caller, in the usual place.
|
||||
*/
|
||||
int
|
||||
rt_epa_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_epa_internal *xip;
|
||||
fastf_t vec[11];
|
||||
fastf_t mag_h;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_EPA ) return(-1);
|
||||
xip = (struct rt_epa_internal *)ip->idb_ptr;
|
||||
RT_EPA_CK_MAGIC(xip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 11;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "epa external");
|
||||
|
||||
if (!NEAR_ZERO( MAGNITUDE(xip->epa_Au) - 1., RT_LEN_TOL)) {
|
||||
bu_log("rt_epa_export: Au not a unit vector!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
mag_h = MAGNITUDE(xip->epa_H);
|
||||
|
||||
if ( mag_h < RT_LEN_TOL
|
||||
|| xip->epa_r1 < RT_LEN_TOL
|
||||
|| xip->epa_r2 < RT_LEN_TOL) {
|
||||
bu_log("rt_epa_export: not all dimensions positive!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ( !NEAR_ZERO( VDOT(xip->epa_Au, xip->epa_H)/mag_h, RT_DOT_TOL) ) {
|
||||
bu_log("rt_epa_export: Au and H are not perpendicular!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (xip->epa_r2 > xip->epa_r1) {
|
||||
bu_log("rt_epa_export: semi-minor axis cannot be longer than semi-major axis!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* scale 'em into local buffer */
|
||||
VSCALE( &vec[0*3], xip->epa_V, local2mm );
|
||||
VSCALE( &vec[1*3], xip->epa_H, local2mm );
|
||||
VMOVE( &vec[2*3], xip->epa_Au ); /* don't scale a unit vector */
|
||||
vec[3*3] = xip->epa_r1 * local2mm;
|
||||
vec[3*3+1] = xip->epa_r2 * local2mm;
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond( ep->ext_buf, (unsigned char *)vec, 11 );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E P A _ D E S C R I B E
|
||||
*
|
||||
|
||||
+2
-98
@@ -1225,7 +1225,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ETO;
|
||||
ip->idb_meth = &rt_functab[ID_ETO];
|
||||
ip->idb_ptr = bu_malloc(sizeof(struct rt_eto_internal), "rt_eto_internal");
|
||||
@@ -1267,7 +1267,7 @@ CONST struct db_i *dbip;
|
||||
tip = (struct rt_eto_internal *)ip->idb_ptr;
|
||||
RT_ETO_CK_MAGIC(tip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "eto external");
|
||||
eto = (union record *)ep->ext_buf;
|
||||
@@ -1298,102 +1298,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E T O _ I M P O R T 5
|
||||
*
|
||||
* Import a eto from the database format to the internal format.
|
||||
* Apply modeling transformations at the same time.
|
||||
*/
|
||||
int
|
||||
rt_eto_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_eto_internal *tip;
|
||||
fastf_t vec[11];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 11 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_ETO;
|
||||
ip->idb_meth = &rt_functab[ID_ETO];
|
||||
ip->idb_ptr = bu_malloc(sizeof(struct rt_eto_internal), "rt_eto_internal");
|
||||
|
||||
tip = (struct rt_eto_internal *)ip->idb_ptr;
|
||||
tip->eto_magic = RT_ETO_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)vec, ep->ext_buf, 11 );
|
||||
|
||||
/* Apply modeling transformations */
|
||||
MAT4X3PNT( tip->eto_V, mat, &vec[0*3] );
|
||||
MAT4X3VEC( tip->eto_N, mat, &vec[1*3] );
|
||||
MAT4X3VEC( tip->eto_C, mat, &vec[2*3] );
|
||||
tip->eto_r = vec[3*3] / mat[15];
|
||||
tip->eto_rd = vec[3*3+1] / mat[15];
|
||||
|
||||
if( tip->eto_r < SMALL || tip->eto_rd < SMALL ) {
|
||||
bu_log("rt_eto_import: zero length R or Rd vector\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E T O _ E X P O R T 5
|
||||
*
|
||||
* The name will be added by the caller.
|
||||
*/
|
||||
int
|
||||
rt_eto_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_eto_internal *tip;
|
||||
fastf_t vec[11];
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_ETO ) return(-1);
|
||||
tip = (struct rt_eto_internal *)ip->idb_ptr;
|
||||
RT_ETO_CK_MAGIC(tip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 11;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "eto external");
|
||||
|
||||
if (MAGNITUDE(tip->eto_C) < RT_LEN_TOL
|
||||
|| MAGNITUDE(tip->eto_N) < RT_LEN_TOL
|
||||
|| tip->eto_r < RT_LEN_TOL
|
||||
|| tip->eto_rd < RT_LEN_TOL) {
|
||||
bu_log("rt_eto_export: not all dimensions positive!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (tip->eto_rd > MAGNITUDE(tip->eto_C) ) {
|
||||
bu_log("rt_eto_export: semi-minor axis cannot be longer than semi-major axis!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* scale 'em into local buffer */
|
||||
VSCALE( &vec[0*3], tip->eto_V, local2mm );
|
||||
VSCALE( &vec[1*3], tip->eto_N, local2mm );
|
||||
VSCALE( &vec[2*3], tip->eto_C, local2mm );
|
||||
vec[3*3] = tip->eto_r * local2mm;
|
||||
vec[3*3+1] = tip->eto_rd * local2mm;
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
htond( ep->ext_buf, (unsigned char *)vec, 11 );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E T O _ D E S C R I B E
|
||||
*
|
||||
|
||||
+16
-129
@@ -45,11 +45,6 @@ static char RCSextrude[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#ifdef USE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "tcl.h"
|
||||
#include "machine.h"
|
||||
#include "vmath.h"
|
||||
@@ -1243,7 +1238,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EXTRUDE;
|
||||
ip->idb_meth = &rt_functab[ID_EXTRUDE];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_extrude_internal), "rt_extrude_internal");
|
||||
@@ -1272,19 +1267,18 @@ CONST struct db_i *dbip;
|
||||
extrude_ip->skt = (struct rt_sketch_internal *)tmp_ip.idb_ptr;
|
||||
}
|
||||
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_V, ELEMENTS_PER_VECT );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_V, 3 );
|
||||
MAT4X3PNT( extrude_ip->V, mat, tmp_vec );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_h, ELEMENTS_PER_VECT );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_h, 3 );
|
||||
MAT4X3VEC( extrude_ip->h, mat, tmp_vec );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_uvec, ELEMENTS_PER_VECT );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_uvec, 3 );
|
||||
MAT4X3VEC( extrude_ip->u_vec, mat, tmp_vec );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_vvec, ELEMENTS_PER_VECT );
|
||||
ntohd( (unsigned char *)tmp_vec, rp->extr.ex_vvec, 3 );
|
||||
MAT4X3VEC( extrude_ip->v_vec, mat, tmp_vec );
|
||||
extrude_ip->keypoint = bu_glong( rp->extr.ex_key );
|
||||
|
||||
ptr = (char *)rp;
|
||||
ptr += sizeof( struct extr_rec );
|
||||
extrude_ip->sketch_name = (char *)bu_calloc( 17, sizeof( char ), "Extrude sketch name" );
|
||||
strncpy( extrude_ip->sketch_name, ptr, 16 );
|
||||
|
||||
return(0); /* OK */
|
||||
@@ -1312,7 +1306,7 @@ CONST struct db_i *dbip;
|
||||
extrude_ip = (struct rt_extrude_internal *)ip->idb_ptr;
|
||||
RT_EXTRUDE_CK_MAGIC(extrude_ip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = 2*sizeof( union record );
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "extrusion external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -1320,131 +1314,24 @@ CONST struct db_i *dbip;
|
||||
rec->extr.ex_id = DBID_EXTR;
|
||||
|
||||
VSCALE( tmp_vec, extrude_ip->V, local2mm );
|
||||
htond( rec->extr.ex_V, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT );
|
||||
htond( rec->extr.ex_V, (unsigned char *)tmp_vec, 3 );
|
||||
VSCALE( tmp_vec, extrude_ip->h, local2mm );
|
||||
htond( rec->extr.ex_h, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT );
|
||||
htond( rec->extr.ex_h, (unsigned char *)tmp_vec, 3 );
|
||||
VSCALE( tmp_vec, extrude_ip->u_vec, local2mm );
|
||||
htond( rec->extr.ex_uvec, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT );
|
||||
htond( rec->extr.ex_uvec, (unsigned char *)tmp_vec, 3 );
|
||||
VSCALE( tmp_vec, extrude_ip->v_vec, local2mm );
|
||||
htond( rec->extr.ex_vvec, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT );
|
||||
htond( rec->extr.ex_vvec, (unsigned char *)tmp_vec, 3 );
|
||||
bu_plong( rec->extr.ex_key, extrude_ip->keypoint );
|
||||
bu_plong( rec->extr.ex_count, 1 );
|
||||
|
||||
ptr = (unsigned char *)rec;
|
||||
ptr += sizeof( struct extr_rec );
|
||||
|
||||
strcpy( (char *)ptr, extrude_ip->sketch_name );
|
||||
strncpy( (char *)ptr, extrude_ip->sketch_name, 16 );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ E X T R U D E _ E X P O R T 5
|
||||
*
|
||||
* The name is added by the caller, in the usual place.
|
||||
*/
|
||||
int
|
||||
rt_extrude_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_extrude_internal *extrude_ip;
|
||||
vect_t tmp_vec[4];
|
||||
unsigned char *ptr;
|
||||
|
||||
RT_CK_DB_INTERNAL(ip);
|
||||
if( ip->idb_type != ID_EXTRUDE ) return(-1);
|
||||
|
||||
extrude_ip = (struct rt_extrude_internal *)ip->idb_ptr;
|
||||
RT_EXTRUDE_CK_MAGIC(extrude_ip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
ep->ext_nbytes = 4 * ELEMENTS_PER_VECT * SIZEOF_NETWORK_DOUBLE + SIZEOF_NETWORK_LONG + strlen( extrude_ip->sketch_name ) + 1;
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "extrusion external");
|
||||
ptr = (unsigned char *)ep->ext_buf;
|
||||
|
||||
VSCALE( tmp_vec[0], extrude_ip->V, local2mm );
|
||||
VSCALE( tmp_vec[1], extrude_ip->h, local2mm );
|
||||
VSCALE( tmp_vec[2], extrude_ip->u_vec, local2mm );
|
||||
VSCALE( tmp_vec[3], extrude_ip->v_vec, local2mm );
|
||||
htond( ptr, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT*4 );
|
||||
ptr += ELEMENTS_PER_VECT * 4 * SIZEOF_NETWORK_DOUBLE;
|
||||
bu_plong( ptr, extrude_ip->keypoint );
|
||||
ptr += SIZEOF_NETWORK_LONG;
|
||||
strcpy( (char *)ptr, extrude_ip->sketch_name );
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* R T _ E X T R U D E _ I M P O R T 5
|
||||
*
|
||||
* Import an EXTRUDE from the database format to the internal format.
|
||||
* Apply modeling transformations as well.
|
||||
*/
|
||||
int
|
||||
rt_extrude_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
LOCAL struct rt_extrude_internal *extrude_ip;
|
||||
struct rt_db_internal tmp_ip;
|
||||
struct directory *dp;
|
||||
char *sketch_name;
|
||||
unsigned char *ptr;
|
||||
point_t tmp_vec[4];
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_EXTRUDE;
|
||||
ip->idb_meth = &rt_functab[ID_EXTRUDE];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_extrude_internal), "rt_extrude_internal");
|
||||
extrude_ip = (struct rt_extrude_internal *)ip->idb_ptr;
|
||||
extrude_ip->magic = RT_EXTRUDE_INTERNAL_MAGIC;
|
||||
|
||||
ptr = (unsigned char *)ep->ext_buf;
|
||||
sketch_name = (char *)ptr + ELEMENTS_PER_VECT*4*SIZEOF_NETWORK_DOUBLE + SIZEOF_NETWORK_LONG;
|
||||
if( !dbip )
|
||||
extrude_ip->skt = (struct rt_sketch_internal *)NULL;
|
||||
else if( (dp=db_lookup( dbip, sketch_name, LOOKUP_NOISY)) == DIR_NULL )
|
||||
{
|
||||
bu_log( "rt_extrude_import: ERROR: Cannot find sketch (%s) for extrusion\n",
|
||||
sketch_name );
|
||||
extrude_ip->skt = (struct rt_sketch_internal *)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( rt_db_get_internal( &tmp_ip, dp, dbip, bn_mat_identity ) != ID_SKETCH )
|
||||
{
|
||||
bu_log( "rt_extrude_import: ERROR: Cannot import sketch (%s) for extrusion\n",
|
||||
sketch_name );
|
||||
bu_free( ip->idb_ptr, "extrusion" );
|
||||
return( -1 );
|
||||
}
|
||||
else
|
||||
extrude_ip->skt = (struct rt_sketch_internal *)tmp_ip.idb_ptr;
|
||||
}
|
||||
|
||||
ntohd( (unsigned char *)tmp_vec, ptr, ELEMENTS_PER_VECT*4 );
|
||||
MAT4X3PNT( extrude_ip->V, mat, tmp_vec[0] );
|
||||
MAT4X3VEC( extrude_ip->h, mat, tmp_vec[1] );
|
||||
MAT4X3VEC( extrude_ip->u_vec, mat, tmp_vec[2] );
|
||||
MAT4X3VEC( extrude_ip->v_vec, mat, tmp_vec[3] );
|
||||
ptr += ELEMENTS_PER_VECT * 4 * SIZEOF_NETWORK_DOUBLE;
|
||||
extrude_ip->keypoint = bu_glong( ptr );
|
||||
ptr += SIZEOF_NETWORK_LONG;
|
||||
extrude_ip->sketch_name = strdup( (const char *)ptr );
|
||||
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ E X T R U D E _ D E S C R I B E
|
||||
*
|
||||
@@ -1477,7 +1364,7 @@ double mm2local;
|
||||
V3ARGS( u ),
|
||||
V3ARGS( v ) );
|
||||
bu_vls_strcat( str, buf );
|
||||
sprintf( buf, "\tsketch name: %s\n",
|
||||
sprintf( buf, "\tsketch name: %.16s\n",
|
||||
extrude_ip->sketch_name );
|
||||
bu_vls_strcat( str, buf );
|
||||
|
||||
@@ -1502,7 +1389,7 @@ struct rt_db_internal *ip;
|
||||
RT_EXTRUDE_CK_MAGIC(extrude_ip);
|
||||
if( extrude_ip->skt )
|
||||
{
|
||||
RT_CK_DB_INTERNAL( &tmp_ip );
|
||||
RT_INIT_DB_INTERNAL( &tmp_ip );
|
||||
tmp_ip.idb_type = ID_SKETCH;
|
||||
tmp_ip.idb_ptr = (genptr_t)extrude_ip->skt;
|
||||
tmp_ip.idb_meth = &rt_functab[ID_SKETCH];
|
||||
@@ -1510,7 +1397,6 @@ struct rt_db_internal *ip;
|
||||
}
|
||||
extrude_ip->magic = 0; /* sanity */
|
||||
|
||||
bu_free( extrude_ip->sketch_name, "Extrude sketch_name" );
|
||||
bu_free( (char *)extrude_ip, "extrude ifree" );
|
||||
ip->idb_ptr = GENPTR_NULL; /* sanity */
|
||||
}
|
||||
@@ -1538,7 +1424,7 @@ struct db_i *dbip;
|
||||
|
||||
if( op != ip )
|
||||
{
|
||||
RT_CK_DB_INTERNAL( op );
|
||||
RT_INIT_DB_INTERNAL( op );
|
||||
eop = (struct rt_extrude_internal *)bu_malloc( sizeof( struct rt_extrude_internal ), "eop" );
|
||||
eop->magic = RT_EXTRUDE_INTERNAL_MAGIC;
|
||||
op->idb_ptr = (genptr_t)eop;
|
||||
@@ -1563,7 +1449,8 @@ struct db_i *dbip;
|
||||
{
|
||||
eop->skt = eip->skt;
|
||||
eip->skt = (struct rt_sketch_internal *)NULL;
|
||||
rt_db_free_internal( ip );
|
||||
rt_functab[ip->idb_type].ft_ifree( ip );
|
||||
ip->idb_ptr = (genptr_t) 0;
|
||||
}
|
||||
else if( eip->skt )
|
||||
eop->skt = rt_copy_sketch( eip->skt );
|
||||
|
||||
+2
-2
@@ -291,7 +291,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_GRIP;
|
||||
ip->idb_meth = &rt_functab[ID_GRIP];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_grip_internal), "rt_grip_internal");
|
||||
@@ -341,7 +341,7 @@ CONST struct db_i *dbip;
|
||||
gip = (struct rt_grip_internal *)ip->idb_ptr;
|
||||
RT_GRIP_CK_MAGIC(gip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "grip external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
|
||||
+6
-99
@@ -520,9 +520,10 @@ struct db_i *dbip;
|
||||
/*
|
||||
* We are done with the input solid so free it if required.
|
||||
*/
|
||||
if (free && ip != op)
|
||||
rt_db_free_internal( ip );
|
||||
|
||||
if (free && ip != op) {
|
||||
rt_functab[ip->idb_type].ft_ifree( ip );
|
||||
ip->idb_ptr = (genptr_t) 0;
|
||||
}
|
||||
/*
|
||||
* The transformed normal is all that is required.
|
||||
* The new distance is found from the transforemd point on the plane.
|
||||
@@ -572,7 +573,7 @@ CONST struct db_i *dbip;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
RT_INIT_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_HALF;
|
||||
ip->idb_meth = &rt_functab[ID_HALF];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_half_internal), "rt_half_internal");
|
||||
@@ -628,7 +629,7 @@ CONST struct db_i *dbip;
|
||||
hip = (struct rt_half_internal *)ip->idb_ptr;
|
||||
RT_HALF_CK_MAGIC(hip);
|
||||
|
||||
BU_CK_EXTERNAL(ep);
|
||||
BU_INIT_EXTERNAL(ep);
|
||||
ep->ext_nbytes = sizeof(union record);
|
||||
ep->ext_buf = (genptr_t)bu_calloc( 1, ep->ext_nbytes, "half external");
|
||||
rec = (union record *)ep->ext_buf;
|
||||
@@ -641,100 +642,6 @@ CONST struct db_i *dbip;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ H L F _ I M P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_hlf_import5( ip, ep, mat, dbip )
|
||||
struct rt_db_internal *ip;
|
||||
CONST struct bu_external *ep;
|
||||
register CONST mat_t mat;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_half_internal *hip;
|
||||
point_t tmp_pt, new_pt;
|
||||
plane_t tmp_plane;
|
||||
fastf_t tmp_dist;
|
||||
register double f,t;
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
|
||||
BU_ASSERT_LONG( ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 4 );
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
ip->idb_type = ID_HALF;
|
||||
ip->idb_meth = &rt_functab[ID_HALF];
|
||||
ip->idb_ptr = bu_malloc( sizeof(struct rt_half_internal), "rt_half_internal");
|
||||
|
||||
hip = (struct rt_half_internal *)ip->idb_ptr;
|
||||
hip->magic = RT_HALF_INTERNAL_MAGIC;
|
||||
|
||||
/* Convert from database (network) to internal (host) format */
|
||||
ntohd( (unsigned char *)tmp_plane, ep->ext_buf, 4 );
|
||||
|
||||
/* to apply modeling transformations, create a temporary
|
||||
* normal vector and point on the plane
|
||||
*/
|
||||
VSCALE( tmp_pt, tmp_plane, tmp_plane[3] );
|
||||
|
||||
/* transform both the point and the vector */
|
||||
MAT4X3VEC( hip->eqn, mat, tmp_plane );
|
||||
MAT4X3PNT( new_pt, mat, tmp_pt );
|
||||
|
||||
/* and calculate the new distance */
|
||||
hip->eqn[3] = VDOT( hip->eqn, new_pt );
|
||||
|
||||
/* Verify that normal has unit length */
|
||||
f = MAGNITUDE( hip->eqn );
|
||||
if( f < SMALL ) {
|
||||
bu_log("rt_hlf_import: bad normal, len=%g\n", f );
|
||||
return(-1); /* BAD */
|
||||
}
|
||||
t = f - 1.0;
|
||||
if( !NEAR_ZERO( t, 0.001 ) ) {
|
||||
/* Restore normal to unit length */
|
||||
f = 1/f;
|
||||
VSCALE( hip->eqn, hip->eqn, f );
|
||||
hip->eqn[3] *= f;
|
||||
}
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ H A L F _ E X P O R T 5
|
||||
*/
|
||||
int
|
||||
rt_hlf_export5( ep, ip, local2mm, dbip )
|
||||
struct bu_external *ep;
|
||||
CONST struct rt_db_internal *ip;
|
||||
double local2mm;
|
||||
CONST struct db_i *dbip;
|
||||
{
|
||||
struct rt_half_internal *hip;
|
||||
fastf_t scaled_dist;
|
||||
|
||||
RT_CK_DB_INTERNAL( ip );
|
||||
if( ip->idb_type != ID_HALF ) return -1;
|
||||
hip = (struct rt_half_internal *)ip->idb_ptr;
|
||||
RT_HALF_CK_MAGIC( hip );
|
||||
|
||||
BU_CK_EXTERNAL( ep );
|
||||
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 4;
|
||||
ep->ext_buf = (genptr_t)bu_malloc( ep->ext_nbytes, "half external" );
|
||||
|
||||
/* only the distance needs to be scaled */
|
||||
scaled_dist = hip->eqn[3] * local2mm;
|
||||
|
||||
/* Convert from internal (host) to database (network) format */
|
||||
/* the normal */
|
||||
htond( (unsigned char *)ep->ext_buf, (unsigned char *)hip->eqn, 3 );
|
||||
/* the distance */
|
||||
htond( ((unsigned char *)(ep->ext_buf)) + SIZEOF_NETWORK_DOUBLE*3,
|
||||
(unsigned char *)&scaled_dist, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* R T _ H L F _ D E S C R I B E
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user