Revision: 53401
http://brlcad.svn.sourceforge.net/brlcad/?rev=53401&view=rev
Author: brlcad
Date: 2012-10-30 02:12:38 +0000 (Tue, 30 Oct 2012)
Log Message:
-----------
big whoosh repair of the assumption that fastf_t are doubles. critically, all import/export routines CANNOT be fastf_t since that's intended to be a variadic type (that's why there's a typedef). we have to convert fastf_t to double before export and after import. use the ELEMENTS_PER_* defines to convey the type where appropiate and helpful for documenting intent.
Modified Paths:
--------------
brlcad/trunk/src/librt/binunif/db5_bin.c
brlcad/trunk/src/librt/comb/comb.c
brlcad/trunk/src/librt/db_match.c
brlcad/trunk/src/librt/primitives/arb8/arb8.c
brlcad/trunk/src/librt/primitives/arbn/arbn.c
brlcad/trunk/src/librt/primitives/ars/ars.c
brlcad/trunk/src/librt/primitives/bot/bot.c
brlcad/trunk/src/librt/primitives/bspline/bspline.cpp
brlcad/trunk/src/librt/primitives/cline/cline.c
brlcad/trunk/src/librt/primitives/dsp/dsp.c
brlcad/trunk/src/librt/primitives/ehy/ehy.c
brlcad/trunk/src/librt/primitives/ell/ell.c
brlcad/trunk/src/librt/primitives/epa/epa.c
brlcad/trunk/src/librt/primitives/eto/eto.c
brlcad/trunk/src/librt/primitives/extrude/extrude.c
brlcad/trunk/src/librt/primitives/grip/grip.c
brlcad/trunk/src/librt/primitives/half/half.c
brlcad/trunk/src/librt/primitives/hyp/hyp.c
brlcad/trunk/src/librt/primitives/metaball/metaball.c
brlcad/trunk/src/librt/primitives/nmg/nmg.c
brlcad/trunk/src/librt/primitives/part/part.c
brlcad/trunk/src/librt/primitives/pipe/pipe.c
brlcad/trunk/src/librt/primitives/pnts/pnts.c
brlcad/trunk/src/librt/primitives/revolve/revolve.c
brlcad/trunk/src/librt/primitives/rhc/rhc.c
brlcad/trunk/src/librt/primitives/rpc/rpc.c
brlcad/trunk/src/librt/primitives/sketch/sketch.c
brlcad/trunk/src/librt/primitives/tgc/tgc.c
brlcad/trunk/src/librt/primitives/tor/tor.c
brlcad/trunk/src/librt/primitives/xxx/xxx.c
brlcad/trunk/src/librt/vlist.c
Modified: brlcad/trunk/src/librt/binunif/db5_bin.c
===================================================================
--- brlcad/trunk/src/librt/binunif/db5_bin.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/binunif/db5_bin.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -161,8 +161,7 @@
bip->count = ep->ext_nbytes/SIZEOF_NETWORK_DOUBLE;
bip->u.uint8 = (unsigned char *) bu_malloc( bip->count * sizeof(double),
"rt_binunif_internal" );
- ntohd( (unsigned char *) bip->u.uint8,
- ep->ext_buf, bip->count );
+ ntohd( (unsigned char *) bip->u.uint8, ep->ext_buf, bip->count );
break;
case DB5_MINORTYPE_BINU_8BITINT:
case DB5_MINORTYPE_BINU_8BITINT_U:
Modified: brlcad/trunk/src/librt/comb/comb.c
===================================================================
--- brlcad/trunk/src/librt/comb/comb.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/comb/comb.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -195,9 +195,11 @@
/* Encoding of the matrix */
if (mi != (ssize_t)-1) {
- htond(ssp->matp,
- (const unsigned char *)tp->tr_l.tl_mat,
- ELEMENTS_PER_MAT);
+ /* must be double for import and export */
+ double scanmat[ELEMENTS_PER_MAT];
+
+ MAT_COPY(scanmat, tp->tr_l.tl_mat); /* convert fastf_t to double */
+ htond(ssp->matp, (const unsigned char *)scanmat, ELEMENTS_PER_MAT);
ssp->matp += ELEMENTS_PER_MAT * SIZEOF_NETWORK_DOUBLE;
}
@@ -543,11 +545,16 @@
} else {
mat_t diskmat;
+ /* must be double for import and export */
+ double scanmat[16];
+
/* Unpack indicated matrix mi */
BU_ASSERT_SIZE_T(mi, <, nmat);
- ntohd((unsigned char *)diskmat,
- &matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE],
- ELEMENTS_PER_MAT);
+
+ /* read matrix */
+ ntohd((unsigned char *)scanmat, &matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE], ELEMENTS_PER_MAT);
+ MAT_COPY(diskmat, scanmat); /* convert double to fastf_t */
+
if (!mat || bn_mat_is_identity(mat)) {
tp->tr_l.tl_mat = bn_mat_dup(diskmat);
} else {
@@ -661,11 +668,16 @@
} else {
mat_t diskmat;
+ /* must be double for import and export */
+ double scanmat[16];
+
/* Unpack indicated matrix mi */
BU_ASSERT_SIZE_T(mi, <, nmat);
- ntohd((unsigned char *)diskmat,
- &matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE],
- ELEMENTS_PER_MAT);
+
+ /* read matrix */
+ ntohd((unsigned char *)scanmat, &matp[mi*ELEMENTS_PER_MAT*SIZEOF_NETWORK_DOUBLE], ELEMENTS_PER_MAT);
+ MAT_COPY(diskmat, scanmat); /* convert double to fastf_t */
+
if (!mat || bn_mat_is_identity(mat)) {
tp->tr_l.tl_mat = bn_mat_dup(diskmat);
} else {
Modified: brlcad/trunk/src/librt/db_match.c
===================================================================
--- brlcad/trunk/src/librt/db_match.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/db_match.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -137,10 +137,13 @@
if (dp->d_major_type == DB5_MAJORTYPE_BRLCAD) {
struct directory *dp2;
+ /* initialize for good measure */
+ RT_DB_INTERNAL_INIT(&intern);
+
if (dp->d_minor_type == DB5_MINORTYPE_BRLCAD_EXTRUDE) {
struct rt_extrude_internal *extr;
- if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, resp) < 0)
+ if (rt_db_get_internal(&intern, dp, dbip, NULL, resp) < 0)
continue;
extr = (struct rt_extrude_internal *)intern.idb_ptr;
RT_EXTRUDE_CK_MAGIC(extr);
@@ -154,7 +157,7 @@
} else if (dp->d_minor_type == DB5_MINORTYPE_BRLCAD_REVOLVE) {
struct rt_revolve_internal *revolve;
- if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, resp) < 0)
+ if (rt_db_get_internal(&intern, dp, dbip, NULL, resp) < 0)
continue;
revolve = (struct rt_revolve_internal *)intern.idb_ptr;
RT_REVOLVE_CK_MAGIC(revolve);
@@ -168,7 +171,7 @@
} else if (dp->d_minor_type == DB5_MINORTYPE_BRLCAD_DSP) {
struct rt_dsp_internal *dsp;
- if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, resp) < 0)
+ if (rt_db_get_internal(&intern, dp, dbip, NULL, resp) < 0)
continue;
dsp = (struct rt_dsp_internal *)intern.idb_ptr;
RT_DSP_CK_MAGIC(dsp);
@@ -183,7 +186,7 @@
}
if (!(dp->d_flags & RT_DIR_COMB))
continue;
- if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, resp) < 0)
+ if (rt_db_get_internal(&intern, dp, dbip, NULL, resp) < 0)
continue;
if (intern.idb_type != ID_COMBINATION) {
bu_log("NOTICE: %s was marked a combination, but isn't one? Clearing flag\n",
Modified: brlcad/trunk/src/librt/primitives/arb8/arb8.c
===================================================================
--- brlcad/trunk/src/librt/primitives/arb8/arb8.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/arb8/arb8.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1262,8 +1262,10 @@
{
struct rt_arb_internal *aip;
register int i;
- fastf_t vec[3*8];
+ /* must be double for import and export */
+ double vec[3*8];
+
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
if (dbip) RT_CK_DBI(dbip);
@@ -1295,9 +1297,11 @@
rt_arb_export5(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;
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*8];
+
RT_CK_DB_INTERNAL(ip);
if (dbip) RT_CK_DBI(dbip);
@@ -1306,12 +1310,12 @@
RT_ARB_CK_MAGIC(aip);
BU_CK_EXTERNAL(ep);
- ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 8 * 3;
+ ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 8 * ELEMENTS_PER_VECT;
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);
+ VSCALE(&vec[i*ELEMENTS_PER_VECT], aip->pt[i], local2mm);
}
- htond(ep->ext_buf, (unsigned char *)vec, 8*3);
+ htond(ep->ext_buf, (unsigned char *)vec, 8*ELEMENTS_PER_VECT);
return 0;
}
Modified: brlcad/trunk/src/librt/primitives/arbn/arbn.c
===================================================================
--- brlcad/trunk/src/librt/primitives/arbn/arbn.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/arbn/arbn.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -829,6 +829,9 @@
struct rt_arbn_internal *aip;
size_t i;
+ /* must be double for import and export */
+ double *scan;
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -847,9 +850,18 @@
aip->magic = RT_ARBN_INTERNAL_MAGIC;
aip->neqn = ntohl(*(uint32_t *)rp->n.n_neqn);
if (aip->neqn <= 0) return -1;
+
aip->eqn = (plane_t *)bu_malloc(aip->neqn*sizeof(plane_t), "arbn plane eqn[]");
+ scan = (double *)bu_malloc(aip->neqn*sizeof(double)*ELEMENTS_PER_PLANE, "scan array");
- ntohd((unsigned char *)aip->eqn, (unsigned char *)(&rp[1]), aip->neqn*4);
+ ntohd((unsigned char *)scan, (unsigned char *)(&rp[1]), aip->neqn*ELEMENTS_PER_PLANE);
+ for (i=0; i<aip->neqn; i++) {
+ aip->eqn[i][X] = scan[(i*ELEMENTS_PER_PLANE)+0]; /* convert double to fastf_t */
+ aip->eqn[i][Y] = scan[(i*ELEMENTS_PER_PLANE)+1]; /* convert double to fastf_t */
+ aip->eqn[i][Z] = scan[(i*ELEMENTS_PER_PLANE)+2]; /* convert double to fastf_t */
+ aip->eqn[i][W] = scan[(i*ELEMENTS_PER_PLANE)+3]; /* convert double to fastf_t */
+ }
+ bu_free(scan, "scan array");
/* Transform by the matrix */
if (mat == NULL) mat = bn_mat_identity;
@@ -891,10 +903,12 @@
struct rt_arbn_internal *aip;
union record *rec;
size_t ngrans;
- double *sbuf; /* scalling buffer */
- double *sp;
size_t i;
+ /* scaling buffer must be double, not fastf_t */
+ double *sbuf;
+ double *sp;
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -908,7 +922,7 @@
* The network format for a double is 8 bytes and there are 4
* doubles per plane equation.
*/
- ngrans = (aip->neqn * 8 * 4 + sizeof(union record)-1) /
+ ngrans = (aip->neqn * 8 * ELEMENTS_PER_PLANE + sizeof(union record)-1) /
sizeof(union record);
BU_CK_EXTERNAL(ep);
@@ -922,7 +936,7 @@
/* Take the data from the caller, and scale it, into sbuf */
sp = sbuf = (double *)bu_malloc(
- aip->neqn * sizeof(double) * 4, "arbn temp");
+ aip->neqn * sizeof(double) * ELEMENTS_PER_PLANE, "arbn temp");
for (i=0; i<aip->neqn; i++) {
/* Normal is unscaled, should have unit length; d is scaled */
*sp++ = aip->eqn[i][X];
@@ -931,7 +945,7 @@
*sp++ = aip->eqn[i][W] * local2mm;
}
- htond((unsigned char *)&rec[1], (unsigned char *)sbuf, aip->neqn * 4);
+ htond((unsigned char *)&rec[1], (unsigned char *)sbuf, aip->neqn * ELEMENTS_PER_PLANE);
bu_free((char *)sbuf, "arbn temp");
return 0; /* OK */
@@ -952,6 +966,8 @@
unsigned long neqn;
int double_count;
size_t byte_count;
+
+ /* must be double for import and export */
double *eqn;
RT_CK_DB_INTERNAL(ip);
@@ -975,7 +991,7 @@
if (aip->neqn <= 0) return -1;
eqn = (double *)bu_malloc(byte_count, "arbn plane eqn[] temp buf");
- ntohd((unsigned char *)eqn, (unsigned char *)ep->ext_buf + 4, double_count);
+ ntohd((unsigned char *)eqn, (unsigned char *)ep->ext_buf + ELEMENTS_PER_PLANE, double_count);
aip->eqn = (plane_t *)bu_malloc(double_count * sizeof(fastf_t), "arbn plane eqn[]");
for (i=0; i < aip->neqn; i++) {
HMOVE(aip->eqn[i], &eqn[i*ELEMENTS_PER_PLANE]);
@@ -1021,11 +1037,13 @@
{
struct rt_arbn_internal *aip;
size_t i;
- double *vec;
- double *sp;
int double_count;
int byte_count;
+ /* must be double for export */
+ double *vec;
+ double *sp;
+
RT_CK_DB_INTERNAL(ip);
if (dbip) RT_CK_DBI(dbip);
@@ -1039,7 +1057,7 @@
byte_count = double_count * SIZEOF_NETWORK_DOUBLE;
BU_CK_EXTERNAL(ep);
- ep->ext_nbytes = 4 + byte_count;
+ ep->ext_nbytes = SIZEOF_NETWORK_LONG + byte_count;
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "arbn external");
*(uint32_t *)ep->ext_buf = htonl(aip->neqn);
@@ -1055,7 +1073,7 @@
}
/* Convert from internal (host) to database (network) format */
- htond((unsigned char *)ep->ext_buf + 4, (unsigned char *)vec, double_count);
+ htond((unsigned char *)ep->ext_buf + SIZEOF_NETWORK_LONG, (unsigned char *)vec, double_count);
bu_free((char *)vec, "arbn temp");
return 0; /* OK */
@@ -1218,7 +1236,7 @@
i * sizeof(plane_t),
"arbn->eqn");
for (j=arbn->neqn; j<i; j++) {
- VSETALLN(arbn->eqn[j], 0.0, 4);
+ HSETALL(arbn->eqn[j], 0.0);
}
arbn->neqn = i;
@@ -1233,7 +1251,7 @@
len = 0;
(void)tcl_list_to_fastf_array(brlcad_interp, argv[1], &new_planes, &len);
- if (len%4) {
+ if (len%ELEMENTS_PER_PLANE) {
bu_vls_printf(logstr,
"ERROR: Incorrect number of plane coefficients\n");
if (len)
@@ -1243,7 +1261,7 @@
if (arbn->eqn)
bu_free((char *)arbn->eqn, "arbn->eqn");
arbn->eqn = (plane_t *)new_planes;
- arbn->neqn = (size_t)len / 4;
+ arbn->neqn = (size_t)len / ELEMENTS_PER_PLANE;
for (i=0; i<arbn->neqn; i++)
VUNITIZE(arbn->eqn[i]);
} else if (argv[0][0] == 'P') {
@@ -1264,10 +1282,10 @@
bu_vls_printf(logstr, "ERROR: plane number out of range\n");
return BRLCAD_ERROR;
}
- len = 4;
+ len = ELEMENTS_PER_PLANE;
array = (fastf_t *)&arbn->eqn[i];
if (tcl_list_to_fastf_array(brlcad_interp, argv[1],
- &array, &len) != 4) {
+ &array, &len) != ELEMENTS_PER_PLANE) {
bu_vls_printf(logstr,
"ERROR: incorrect number of coefficients for a plane\n");
return BRLCAD_ERROR;
Modified: brlcad/trunk/src/librt/primitives/ars/ars.c
===================================================================
--- brlcad/trunk/src/librt/primitives/ars/ars.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/ars/ars.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -314,9 +314,11 @@
struct rt_ars_internal *ari;
register size_t i, j;
register unsigned char *cp;
- vect_t tmp_vec;
register fastf_t *fp;
+ /* must be double for import and export */
+ double tmp_pnt[ELEMENTS_PER_POINT];
+
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
if (dbip) RT_CK_DBI(dbip);
@@ -342,14 +344,14 @@
(ari->ncurves+1), sizeof(fastf_t *), "ars curve ptrs");
if (mat == NULL) mat = bn_mat_identity;
for (i=0; i < ari->ncurves; i++) {
- ari->curves[i] = (fastf_t *)bu_calloc((ari->pts_per_curve + 1) * 3,
+ ari->curves[i] = (fastf_t *)bu_calloc((ari->pts_per_curve + 1) * ELEMENTS_PER_POINT,
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;
+ ntohd((unsigned char *)tmp_pnt, cp, ELEMENTS_PER_POINT);
+ MAT4X3PNT(fp, mat, tmp_pnt);
+ cp += ELEMENTS_PER_POINT * SIZEOF_NETWORK_DOUBLE;
+ fp += ELEMENTS_PER_POINT;
}
VMOVE(fp, ari->curves[i]); /* duplicate first point */
}
@@ -368,9 +370,11 @@
{
struct rt_ars_internal *arip;
unsigned char *cp;
- vect_t tmp_vec;
size_t cur; /* current curve number */
+ /* must be double for import and export */
+ double tmp_pnt[ELEMENTS_PER_POINT];
+
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_ARS) return -1;
arip = (struct rt_ars_internal *)ip->idb_ptr;
@@ -379,8 +383,7 @@
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
- ep->ext_nbytes = 2 * SIZEOF_NETWORK_LONG +
- 3 * arip->ncurves * arip->pts_per_curve * SIZEOF_NETWORK_DOUBLE;
+ ep->ext_nbytes = 2 * SIZEOF_NETWORK_LONG + ELEMENTS_PER_POINT * 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;
@@ -395,10 +398,10 @@
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;
+ VSCALE(tmp_pnt, fp, local2mm);
+ htond(cp, (unsigned char *)tmp_pnt, ELEMENTS_PER_POINT);
+ cp += ELEMENTS_PER_POINT * SIZEOF_NETWORK_DOUBLE;
+ fp += ELEMENTS_PER_POINT;
}
}
return 0;
Modified: brlcad/trunk/src/librt/primitives/bot/bot.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/bot.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/bot/bot.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -781,29 +781,33 @@
if (mat == NULL) mat = bn_mat_identity;
for (i = 0; i < bot_ip->num_vertices; i++) {
- point_t tmp;
+ double tmp[ELEMENTS_PER_POINT];
- ntohd((unsigned char *)tmp, (const unsigned char *)(&rp->bot.bot_data[i*24]), 3);
- MAT4X3PNT(&(bot_ip->vertices[i*3]), mat, tmp);
+ ntohd((unsigned char *)tmp, (const unsigned char *)(&rp->bot.bot_data[i*24]), ELEMENTS_PER_POINT);
+ MAT4X3PNT(&(bot_ip->vertices[i*ELEMENTS_PER_POINT]), mat, tmp);
}
- chars_used = bot_ip->num_vertices * 3 * 8;
+ chars_used = bot_ip->num_vertices * ELEMENTS_PER_POINT * 8;
for (i = 0; i < bot_ip->num_faces; i++) {
size_t idx=chars_used + i * 12;
- bot_ip->faces[i*3 + 0] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 0]);
- bot_ip->faces[i*3 + 1] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 4]);
- bot_ip->faces[i*3 + 2] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 8]);
+ bot_ip->faces[i*ELEMENTS_PER_POINT + 0] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 0]);
+ bot_ip->faces[i*ELEMENTS_PER_POINT + 1] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 4]);
+ bot_ip->faces[i*ELEMENTS_PER_POINT + 2] = ntohl(*(uint32_t *)&rp->bot.bot_data[idx + 8]);
}
if (bot_ip->mode == RT_BOT_PLATE || bot_ip->mode == RT_BOT_PLATE_NOCOS) {
- chars_used = bot_ip->num_vertices * 3 * 8 + bot_ip->num_faces * 12;
+ chars_used = bot_ip->num_vertices * ELEMENTS_PER_POINT * 8 + bot_ip->num_faces * 12;
bot_ip->thickness = (fastf_t *)bu_calloc(bot_ip->num_faces, sizeof(fastf_t), "BOT thickness");
- for (i = 0; i < bot_ip->num_faces; i++)
- ntohd((unsigned char *)&(bot_ip->thickness[i]),
- (const unsigned char *)(&rp->bot.bot_data[chars_used + i*8]), 1);
+ for (i = 0; i < bot_ip->num_faces; i++) {
+ double scan;
+
+ ntohd((unsigned char *)&scan, (const unsigned char *)(&rp->bot.bot_data[chars_used + i*8]), 1);
+ bot_ip->thickness[i] = scan; /* convert double to fastf_t */
+ }
+
bot_ip->face_mode = bu_hex_to_bitv((const char *)(&rp->bot.bot_data[chars_used + bot_ip->num_faces * 8]));
} else {
bot_ip->thickness = (fastf_t *)NULL;
@@ -842,7 +846,7 @@
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = sizeof(struct bot_rec) - 1 +
- bot_ip->num_vertices * 3 * 8 + bot_ip->num_faces * 3 * 4;
+ bot_ip->num_vertices * ELEMENTS_PER_POINT * 8 + bot_ip->num_faces * ELEMENTS_PER_POINT * 4;
if (bot_ip->mode == RT_BOT_PLATE || bot_ip->mode == RT_BOT_PLATE_NOCOS) {
if (!bot_ip->face_mode) {
bot_ip->face_mode = bu_bitv_new(bot_ip->num_faces);
@@ -881,10 +885,11 @@
* record format
*/
for (i = 0; i < bot_ip->num_vertices; i++) {
- point_t tmp;
+ /* must be double for import and export */
+ double tmp[ELEMENTS_PER_POINT];
- VSCALE(tmp, &bot_ip->vertices[i*3], local2mm);
- htond((unsigned char *)&rec->bot.bot_data[i*24], (const unsigned char *)tmp, 3);
+ VSCALE(tmp, &bot_ip->vertices[i*ELEMENTS_PER_POINT], local2mm);
+ htond((unsigned char *)&rec->bot.bot_data[i*24], (const unsigned char *)tmp, ELEMENTS_PER_POINT);
}
chars_used = bot_ip->num_vertices * 24;
@@ -892,16 +897,18 @@
for (i = 0; i < bot_ip->num_faces; i++) {
size_t idx=chars_used + i * 12;
- *(uint32_t *)&rec->bot.bot_data[idx + 0] = htonl(bot_ip->faces[i*3+0]);
- *(uint32_t *)&rec->bot.bot_data[idx + 4] = htonl(bot_ip->faces[i*3+1]);
- *(uint32_t *)&rec->bot.bot_data[idx + 8] = htonl(bot_ip->faces[i*3+2]);
+ *(uint32_t *)&rec->bot.bot_data[idx + 0] = htonl(bot_ip->faces[i*ELEMENTS_PER_POINT+0]);
+ *(uint32_t *)&rec->bot.bot_data[idx + 4] = htonl(bot_ip->faces[i*ELEMENTS_PER_POINT+1]);
+ *(uint32_t *)&rec->bot.bot_data[idx + 8] = htonl(bot_ip->faces[i*ELEMENTS_PER_POINT+2]);
}
chars_used += bot_ip->num_faces * 12;
if (bot_ip->mode == RT_BOT_PLATE || bot_ip->mode == RT_BOT_PLATE_NOCOS) {
for (i = 0; i < bot_ip->num_faces; i++) {
- fastf_t tmp;
+ /* must be double for import and export */
+ double tmp;
+
tmp = bot_ip->thickness[i] * local2mm;
htond((unsigned char *)&rec->bot.bot_data[chars_used], (const unsigned char *)&tmp, 1);
chars_used += 8;
@@ -946,7 +953,7 @@
bip->bot_flags = *cp++;
if (bip->num_vertices > 0) {
- bip->vertices = (fastf_t *)bu_calloc(bip->num_vertices * 3, sizeof(fastf_t), "BOT vertices");
+ bip->vertices = (fastf_t *)bu_calloc(bip->num_vertices * ELEMENTS_PER_POINT, sizeof(fastf_t), "BOT vertices");
} else {
bip->vertices = (fastf_t *)NULL;
}
@@ -966,11 +973,12 @@
mat = bn_mat_identity;
for (i = 0; i < bip->num_vertices; i++) {
- point_t tmp;
+ /* must be double for import and export */
+ double tmp[ELEMENTS_PER_POINT];
- ntohd((unsigned char *)tmp, (const unsigned char *)cp, 3);
- cp += SIZEOF_NETWORK_DOUBLE * 3;
- MAT4X3PNT(&(bip->vertices[i*3]), mat, tmp);
+ ntohd((unsigned char *)tmp, (const unsigned char *)cp, ELEMENTS_PER_POINT);
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_POINT;
+ MAT4X3PNT(&(bip->vertices[i*ELEMENTS_PER_POINT]), mat, tmp);
}
for (i = 0; i < bip->num_faces; i++) {
@@ -985,7 +993,9 @@
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);
+ double scan;
+ ntohd((unsigned char *)&scan, cp, 1);
+ bip->thickness[i] = scan; /* convert double to fastf_t */
cp += SIZEOF_NETWORK_DOUBLE;
}
bip->face_mode = bu_hex_to_bitv((const char *)cp);
@@ -996,7 +1006,8 @@
}
if (bip->bot_flags & RT_BOT_HAS_SURFACE_NORMALS) {
- vect_t tmp;
+ /* must be double for import and export */
+ double tmp[ELEMENTS_PER_VECT];
bip->num_normals = ntohl(*(uint32_t *)&cp[0]);
cp += SIZEOF_NETWORK_LONG;
@@ -1013,9 +1024,9 @@
bip->normals = (fastf_t *)bu_calloc(bip->num_normals * 3, sizeof(fastf_t), "BOT normals");
for (i = 0; i < bip->num_normals; i++) {
- ntohd((unsigned char *)tmp, (const unsigned char *)cp, 3);
- cp += SIZEOF_NETWORK_DOUBLE * 3;
- MAT4X3VEC(&(bip->normals[i*3]), mat, tmp);
+ ntohd((unsigned char *)tmp, (const unsigned char *)cp, ELEMENTS_PER_VECT);
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
+ MAT4X3VEC(&(bip->normals[i*ELEMENTS_PER_VECT]), mat, tmp);
}
}
if (bip->num_face_normals > 0) {
@@ -1103,12 +1114,13 @@
rem -= 3;
for (i = 0; i < bip->num_vertices; i++) {
- point_t tmp;
+ /* must be double for import and export */
+ double tmp[ELEMENTS_PER_POINT];
- VSCALE(tmp, &bip->vertices[i*3], local2mm);
- htond(cp, (unsigned char *)tmp, 3);
- cp += SIZEOF_NETWORK_DOUBLE * 3;
- rem -= SIZEOF_NETWORK_DOUBLE * 3;
+ VSCALE(tmp, &bip->vertices[i*ELEMENTS_PER_POINT], local2mm);
+ htond(cp, (unsigned char *)tmp, ELEMENTS_PER_POINT);
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_POINT;
+ rem -= SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_POINT;
}
for (i = 0; i < bip->num_faces; i++) {
@@ -1127,7 +1139,8 @@
if (bip->mode == RT_BOT_PLATE || bip->mode == RT_BOT_PLATE_NOCOS) {
for (i = 0; i < bip->num_faces; i++) {
- fastf_t tmp;
+ /* must be double for import and export */
+ double tmp;
tmp = bip->thickness[i] * local2mm;
htond(cp, (const unsigned char *)&tmp, 1);
@@ -1153,21 +1166,33 @@
rem -= SIZEOF_NETWORK_LONG;
if (bip->num_normals > 0) {
- htond(cp, (unsigned char*)bip->normals, bip->num_normals*3);
- cp += SIZEOF_NETWORK_DOUBLE * 3 * bip->num_normals;
- rem -= SIZEOF_NETWORK_DOUBLE * 3 * bip->num_normals;
+ /* must be double for import and export */
+ double *normals;
+ normals = (double *)bu_malloc(bip->num_normals*ELEMENTS_PER_VECT*sizeof(double), "normals");
+
+ /* convert fastf_t to double */
+ for (i=0; i < bip->num_normals * ELEMENTS_PER_VECT; i++) {
+ normals[i] = bip->normals[i];
+ }
+
+ htond(cp, (unsigned char*)normals, bip->num_normals*ELEMENTS_PER_VECT);
+
+ bu_free(normals, "normals");
+
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT * bip->num_normals;
+ rem -= SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT * bip->num_normals;
}
if (bip->num_face_normals > 0) {
for (i = 0; i < bip->num_face_normals; i++) {
- *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*3 + 0]);
+ *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*ELEMENTS_PER_VECT + 0]);
cp += SIZEOF_NETWORK_LONG;
rem -= SIZEOF_NETWORK_LONG;
- *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*3 + 1]);
+ *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*ELEMENTS_PER_VECT + 1]);
cp += SIZEOF_NETWORK_LONG;
rem -= SIZEOF_NETWORK_LONG;
- *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*3 + 2]);
+ *(uint32_t *)&cp[0] = htonl(bip->face_normals[i*ELEMENTS_PER_VECT + 2]);
cp += SIZEOF_NETWORK_LONG;
rem -= SIZEOF_NETWORK_LONG;
}
@@ -1399,7 +1424,7 @@
botop->num_vertices = botip->num_vertices;
botop->num_faces = botip->num_faces;
if (botop->num_vertices > 0) {
- botop->vertices = (fastf_t *)bu_malloc(botip->num_vertices * 3 * sizeof(fastf_t), "botop->vertices");
+ botop->vertices = (fastf_t *)bu_malloc(botip->num_vertices * ELEMENTS_PER_POINT * sizeof(fastf_t), "botop->vertices");
}
if (botop->num_faces > 0) {
botop->faces = (int *)bu_malloc(botip->num_faces * 3 * sizeof(int), "botop->faces");
@@ -1435,8 +1460,8 @@
}
for (i = 0; i < botip->num_vertices; i++) {
- MAT4X3PNT(pt, mat, &botip->vertices[i*3]);
- VMOVE(&botop->vertices[i*3], pt);
+ MAT4X3PNT(pt, mat, &botip->vertices[i*ELEMENTS_PER_POINT]);
+ VMOVE(&botop->vertices[i*ELEMENTS_PER_POINT], pt);
}
for (i = 0; i < botip->num_normals; i++) {
@@ -1469,7 +1494,7 @@
fastf_t tmp_dist;
fastf_t tmpx, tmpy;
- MAT4X3PNT(v, mat, &bot->vertices[idx*3])
+ MAT4X3PNT(v, mat, &bot->vertices[idx*ELEMENTS_PER_POINT])
tmpx = v[X] - pt2[X];
tmpy = v[Y] - pt2[Y];
tmp_dist = tmpx * tmpx + tmpy * tmpy;
Modified: brlcad/trunk/src/librt/primitives/bspline/bspline.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/bspline/bspline.cpp 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/bspline/bspline.cpp 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1054,8 +1054,14 @@
cp += SIZEOF_NETWORK_LONG;
for (s = 0; s < sip->nsrf; s++) {
- register struct face_g_snurb *srf = sip->srfs[s];
+ int i;
+ struct face_g_snurb *srf = sip->srfs[s];
+ /* must be double for import and export */
+ double *uknots;
+ double *vknots;
+ double *points;
+
NMG_CK_SNURB(srf);
coords = RT_NURB_EXTRACT_COORDS(srf->pt_type);
@@ -1073,14 +1079,36 @@
cp += SIZEOF_NETWORK_LONG;
*(uint32_t *)cp = htonl(srf->s_size[1]);
cp += SIZEOF_NETWORK_LONG;
- htond(cp, (unsigned char *)srf->u.knots, srf->u.k_size);
+
+ /* alloate for export */
+ uknots = (double *)bu_malloc(srf->u.k_size * sizeof(double), "uknots");
+ vknots = (double *)bu_malloc(srf->v.k_size * sizeof(double), "vknots");
+ points = (double *)bu_malloc(coords * srf->s_size[0] * srf->s_size[1] * sizeof(double), "points");
+
+ /* convert fastf_t to double */
+ for (i=0; i<srf->u.k_size; i++) {
+ uknots[i] = srf->u.knots[i];
+ }
+ for (i=0; i<srf->v.k_size; i++) {
+ vknots[i] = srf->v.knots[i];
+ }
+ for (i=0; i<coords * srf->s_size[0] * srf->s_size[1]; i++) {
+ points[i] = srf->ctl_points[i];
+ }
+
+ /* serialize */
+ htond(cp, (unsigned char *)uknots, srf->u.k_size);
cp += srf->u.k_size * SIZEOF_NETWORK_DOUBLE;
- htond(cp, (unsigned char *)srf->v.knots, srf->v.k_size);
+ htond(cp, (unsigned char *)vknots, srf->v.k_size);
cp += srf->v.k_size * SIZEOF_NETWORK_DOUBLE;
-
htond(cp, (unsigned char *)srf->ctl_points,
coords * srf->s_size[0] * srf->s_size[1]);
cp += coords * srf->s_size[0] * srf->s_size[1] * SIZEOF_NETWORK_DOUBLE;
+
+ /* release our arrays */
+ bu_free(uknots, "uknots");
+ bu_free(vknots, "vknots");
+ bu_free(points, "points");
}
bu_log("DEPRECATED: The 'bspline' primitive is no longer supported. Use 'brep' NURBS instead.\n");
@@ -1126,6 +1154,11 @@
int order[2], u_size, v_size;
int s_size[2];
+ /* must be double for import and export */
+ double *uknots;
+ double *vknots;
+ double *points;
+
pt_type = ntohl(*(uint32_t *)cp);
cp += SIZEOF_NETWORK_LONG;
order[0] = ntohl(*(uint32_t *)cp);
@@ -1154,17 +1187,39 @@
srf = sip->srfs[s];
coords = RT_NURB_EXTRACT_COORDS(srf->pt_type);
- ntohd((unsigned char *)srf->u.knots, cp, srf->u.k_size);
+ uknots = (double *)bu_malloc(srf->u.k_size * sizeof(double), "uknots");
+ vknots = (double *)bu_malloc(srf->v.k_size * sizeof(double), "vknots");
+
+ ntohd((unsigned char *)uknots, cp, srf->u.k_size);
cp += srf->u.k_size * SIZEOF_NETWORK_DOUBLE;
- ntohd((unsigned char *)srf->v.knots, cp, srf->v.k_size);
+ ntohd((unsigned char *)vknots, cp, srf->v.k_size);
cp += srf->v.k_size * SIZEOF_NETWORK_DOUBLE;
+ /* convert double to fastf_t */
+ for (i=0; i<srf->u.k_size; i++) {
+ srf->u.knots[i] = uknots[i];
+ }
+ for (i=0; i<srf->v.k_size; i++) {
+ srf->v.knots[i] = vknots[i];
+ }
+
+ bu_free(uknots, "uknots");
+ bu_free(vknots, "vknots");
+
rt_nurb_kvnorm(&srf->u);
rt_nurb_kvnorm(&srf->v);
- ntohd((unsigned char *)srf->ctl_points, cp,
- coords * srf->s_size[0] * srf->s_size[1]);
+ points = (double *)bu_malloc(coords * srf->s_size[0] * srf->s_size[1] * sizeof(double), "points");
+ ntohd((unsigned char *)points, cp, coords * srf->s_size[0] * srf->s_size[1]);
+
+ /* convert double to fastf_t */
+ for (i=0; i < coords * srf->s_size[0] * srf->s_size[1]; i++) {
+ srf->ctl_points[i] = points[i];
+ }
+
+ bu_free(points, "points");
+
cp += coords * srf->s_size[0] * srf->s_size[1] * SIZEOF_NETWORK_DOUBLE;
if (mat == NULL) mat = bn_mat_identity;
Modified: brlcad/trunk/src/librt/primitives/cline/cline.c
===================================================================
--- brlcad/trunk/src/librt/primitives/cline/cline.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/cline/cline.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -830,8 +830,11 @@
{
struct rt_cline_internal *cline_ip;
union record *rp;
- point_t work;
+ /* must be double for import and export */
+ double work[ELEMENTS_PER_POINT];
+ double scan;
+
BU_CK_EXTERNAL(ep);
rp = (union record *)ep->ext_buf;
/* Check record type */
@@ -852,13 +855,13 @@
cline_ip->magic = RT_CLINE_INTERNAL_MAGIC;
if (mat == NULL) mat = bn_mat_identity;
- ntohd((unsigned char *)(&cline_ip->thickness), rp->cli.cli_thick, 1);
- cline_ip->thickness /= mat[15];
- ntohd((unsigned char *)(&cline_ip->radius), rp->cli.cli_radius, 1);
- cline_ip->radius /= mat[15];
- ntohd((unsigned char *)(&work), rp->cli.cli_V, 3);
+ ntohd((unsigned char *)&scan, rp->cli.cli_thick, 1);
+ cline_ip->thickness = scan / mat[15];
+ ntohd((unsigned char *)&scan, rp->cli.cli_radius, 1);
+ cline_ip->radius = scan / mat[15];
+ ntohd((unsigned char *)&work, rp->cli.cli_V, ELEMENTS_PER_POINT);
MAT4X3PNT(cline_ip->v, mat, work);
- ntohd((unsigned char *)(&work), rp->cli.cli_h, 3);
+ ntohd((unsigned char *)&work, rp->cli.cli_h, ELEMENTS_PER_POINT);
MAT4X3VEC(cline_ip->h, mat, work);
return 0; /* OK */
@@ -875,9 +878,11 @@
{
struct rt_cline_internal *cline_ip;
union record *rec;
- fastf_t tmp;
- point_t work;
+ /* must be double for import and export */
+ double tmp;
+ double work[ELEMENTS_PER_VECT];
+
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_CLINE) return -1;
cline_ip = (struct rt_cline_internal *)ip->idb_ptr;
@@ -898,9 +903,9 @@
tmp = cline_ip->radius * local2mm;
htond(rec->cli.cli_radius, (unsigned char *)(&tmp), 1);
VSCALE(work, cline_ip->v, local2mm);
- htond(rec->cli.cli_V, (unsigned char *)work, 3);
+ htond(rec->cli.cli_V, (unsigned char *)work, ELEMENTS_PER_VECT);
VSCALE(work, cline_ip->h, local2mm);
- htond(rec->cli.cli_h, (unsigned char *)work, 3);
+ htond(rec->cli.cli_h, (unsigned char *)work, ELEMENTS_PER_VECT);
return 0;
}
@@ -916,8 +921,10 @@
rt_cline_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
struct rt_cline_internal *cline_ip;
- fastf_t vec[8];
+ /* must be double for import and export */
+ double vec[8];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -954,8 +961,10 @@
rt_cline_export5(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];
+ /* must be double for import and export */
+ double vec[8];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/dsp/dsp.c
===================================================================
--- brlcad/trunk/src/librt/primitives/dsp/dsp.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/dsp/dsp.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -4391,6 +4391,9 @@
struct rt_dsp_internal *dsp_ip;
unsigned char *cp;
+ /* must be double for import and export */
+ double scanmat[16];
+
if (resp) RT_CK_RESOURCE(resp);
if (RT_G_DEBUG & DEBUG_HF)
@@ -4437,8 +4440,10 @@
}
/* convert matrix */
- ntohd((unsigned char *)dsp_ip->dsp_stom, cp, 16);
- cp += SIZEOF_NETWORK_DOUBLE * 16;
+ ntohd((unsigned char *)scanmat, cp, ELEMENTS_PER_MAT);
+ MAT_COPY(dsp_ip->dsp_stom, scanmat); /* double to fastf_t */
+
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_MAT;
bn_mat_inv(dsp_ip->dsp_mtos, dsp_ip->dsp_stom);
/* convert smooth flag */
@@ -4500,6 +4505,9 @@
unsigned char *cp;
size_t rem;
+ /* must be double for import and export */
+ double scanmat[16];
+
if (resp) RT_CK_RESOURCE(resp);
if (dbip) RT_CK_DBI(dbip);
@@ -4545,10 +4553,12 @@
*/
dsp_ip->dsp_stom[15] *= local2mm;
- htond(cp, (unsigned char *)dsp_ip->dsp_stom, 16);
- cp += SIZEOF_NETWORK_DOUBLE * 16;
- rem -= SIZEOF_NETWORK_DOUBLE * 16;
+ MAT_COPY(scanmat, dsp_ip->dsp_stom); /* convert fastf_t to double */
+ htond(cp, (unsigned char *)scanmat, ELEMENTS_PER_MAT);
+ cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_MAT;
+ rem -= SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_MAT;
+
*(uint16_t *)cp = htons((uint16_t)dsp_ip->dsp_smooth);
cp += SIZEOF_NETWORK_SHORT;
rem -= SIZEOF_NETWORK_SHORT;
Modified: brlcad/trunk/src/librt/primitives/ehy/ehy.c
===================================================================
--- brlcad/trunk/src/librt/primitives/ehy/ehy.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/ehy/ehy.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1752,8 +1752,10 @@
rt_ehy_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_ehy_internal *xip;
- fastf_t vec[3*4];
+ /* must be double for import and export */
+ double vec[3*4];
+
BU_CK_EXTERNAL(ep);
if (dbip) RT_CK_DBI(dbip);
@@ -1800,8 +1802,10 @@
rt_ehy_export5(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];
+ /* must be double for import and export */
+ double vec[3*4];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/ell/ell.c
===================================================================
--- brlcad/trunk/src/librt/primitives/ell/ell.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/ell/ell.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1369,8 +1369,10 @@
rt_ell_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
struct rt_ell_internal *eip;
- fastf_t vec[ELEMENTS_PER_VECT*4];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*4];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
@@ -1412,8 +1414,10 @@
rt_ell_export5(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];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*4];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/epa/epa.c
===================================================================
--- brlcad/trunk/src/librt/primitives/epa/epa.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/epa/epa.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1722,8 +1722,10 @@
rt_epa_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_epa_internal *xip;
- fastf_t vec[11];
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -1769,9 +1771,11 @@
rt_epa_export5(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;
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/eto/eto.c
===================================================================
--- brlcad/trunk/src/librt/primitives/eto/eto.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/eto/eto.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1406,8 +1406,10 @@
rt_eto_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_eto_internal *tip;
- fastf_t vec[11];
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -1450,8 +1452,10 @@
rt_eto_export5(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];
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/extrude/extrude.c
===================================================================
--- brlcad/trunk/src/librt/primitives/extrude/extrude.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/extrude/extrude.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -2313,8 +2313,10 @@
char *sketch_name;
union record *rp;
char *ptr;
- point_t tmp_vec;
+ /* must be double for import and export */
+ double tmp_vec[ELEMENTS_PER_VECT];
+
BU_CK_EXTERNAL(ep);
rp = (union record *)ep->ext_buf;
/* Check record type */
@@ -2378,7 +2380,10 @@
rt_extrude_export4(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;
+
+ /* must be double for import and export */
+ double tmp_vec[ELEMENTS_PER_VECT];
+
union record *rec;
unsigned char *ptr;
@@ -2425,10 +2430,12 @@
rt_extrude_export5(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;
size_t rem;
+ /* must be double for import and export */
+ double tmp_vec[4][ELEMENTS_PER_VECT];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -2478,8 +2485,10 @@
struct directory *dp;
char *sketch_name;
unsigned char *ptr;
- point_t tmp_vec[4];
+ /* must be double for import and export */
+ double tmp_vec[4][ELEMENTS_PER_VECT];
+
BU_CK_EXTERNAL(ep);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/grip/grip.c
===================================================================
--- brlcad/trunk/src/librt/primitives/grip/grip.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/grip/grip.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -368,9 +368,11 @@
rt_grp_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_grip_internal *gip;
- fastf_t vec[7];
double f, t;
+ /* must be double for import and export */
+ double vec[7];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
@@ -420,8 +422,10 @@
rt_grp_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_grip_internal *gip;
- fastf_t vec[7];
+ /* must be double for import and export */
+ double vec[7];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/half/half.c
===================================================================
--- brlcad/trunk/src/librt/primitives/half/half.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/half/half.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -657,16 +657,18 @@
int
rt_hlf_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
+ register double f, t;
struct rt_half_internal *hip;
point_t tmp_pt, new_pt;
- plane_t tmp_plane;
- register double f, t;
+ /* must be double for import and export */
+ double tmp_plane[ELEMENTS_PER_PLANE];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
- BU_ASSERT_LONG(ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 4);
+ BU_ASSERT_LONG(ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_PLANE);
RT_CK_DB_INTERNAL(ip);
ip->idb_major_type = DB5_MAJORTYPE_BRLCAD;
@@ -678,7 +680,7 @@
hip->magic = RT_HALF_INTERNAL_MAGIC;
/* Convert from database (network) to internal (host) format */
- ntohd((unsigned char *)tmp_plane, ep->ext_buf, 4);
+ ntohd((unsigned char *)tmp_plane, ep->ext_buf, ELEMENTS_PER_PLANE);
/* to apply modeling transformations, create a temporary normal
* vector and point on the plane
@@ -718,8 +720,11 @@
rt_hlf_export5(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;
+ /* must be double for import and export */
+ double scaled_dist;
+ double eqn[ELEMENTS_PER_VECT];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -735,10 +740,13 @@
scaled_dist = hip->eqn[W] * local2mm;
/* Convert from internal (host) to database (network) format */
+
/* the normal */
- htond((unsigned char *)ep->ext_buf, (unsigned char *)hip->eqn, 3);
+ VMOVE(eqn, hip->eqn); /* convert fastf_t to double */
+ htond((unsigned char *)ep->ext_buf, (unsigned char *)eqn, ELEMENTS_PER_VECT);
+
/* the distance */
- htond(((unsigned char *)(ep->ext_buf)) + SIZEOF_NETWORK_DOUBLE*3,
+ htond(((unsigned char *)(ep->ext_buf)) + SIZEOF_NETWORK_DOUBLE*ELEMENTS_PER_VECT,
(unsigned char *)&scaled_dist, 1);
return 0;
Modified: brlcad/trunk/src/librt/primitives/hyp/hyp.c
===================================================================
--- brlcad/trunk/src/librt/primitives/hyp/hyp.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/hyp/hyp.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1195,8 +1195,10 @@
rt_hyp_import5(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip)
{
struct rt_hyp_internal *hyp_ip;
- fastf_t vec[ELEMENTS_PER_VECT*4];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*4];
+
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
if (dbip) RT_CK_DBI(dbip);
@@ -1224,7 +1226,7 @@
MAT4X3VEC(hyp_ip->hyp_A, mat, &vec[2*3]);
if (!ZERO(mat[15]))
- hyp_ip->hyp_b = vec[ 9] / mat[15];
+ hyp_ip->hyp_b = vec[9] / mat[15];
else
hyp_ip->hyp_b = INFINITY;
hyp_ip->hyp_bnr = vec[10] ;
@@ -1246,8 +1248,10 @@
rt_hyp_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_hyp_internal *hyp_ip;
- fastf_t vec[ELEMENTS_PER_VECT * 4];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT * 4];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/metaball/metaball.c
===================================================================
--- brlcad/trunk/src/librt/primitives/metaball/metaball.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/metaball/metaball.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -708,14 +708,16 @@
{
struct wdb_metaballpt *mbpt;
struct rt_metaball_internal *mb;
- fastf_t *buf;
int metaball_count = 0, i;
+ /* must be double for import and export */
+ double *buf;
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
metaball_count = ntohl(*(uint32_t *)ep->ext_buf);
- buf = (fastf_t *)bu_malloc((metaball_count*5+1)*SIZEOF_NETWORK_DOUBLE, "rt_metaball_import5: buf");
+ buf = (double *)bu_malloc((metaball_count*5+1)*SIZEOF_NETWORK_DOUBLE, "rt_metaball_import5: buf");
ntohd((unsigned char *)buf, (unsigned char *)ep->ext_buf+2*SIZEOF_NETWORK_LONG, metaball_count*5+1);
RT_CK_DB_INTERNAL(ip);
@@ -765,7 +767,8 @@
struct rt_metaball_internal *mb;
struct wdb_metaballpt *mbpt;
int metaball_count = 0, i = 1;
- fastf_t *buf = NULL;
+ /* must be double for import and export */
+ double *buf = NULL;
if (dbip) RT_CK_DBI(dbip);
@@ -788,7 +791,7 @@
*(uint32_t *)(ep->ext_buf + SIZEOF_NETWORK_LONG) = htonl(mb->method);
/* pack the point data */
- buf = (fastf_t *)bu_malloc((metaball_count*5+1)*SIZEOF_NETWORK_DOUBLE, "rt_metaball_export5: buf");
+ buf = (double *)bu_malloc((metaball_count*5+1)*SIZEOF_NETWORK_DOUBLE, "rt_metaball_export5: buf");
buf[0] = mb->threshold;
for (BU_LIST_FOR(mbpt, wdb_metaballpt, &mb->metaball_ctrl_head), i+=5) {
VSCALE(&buf[i], mbpt->coord, local2mm);
@@ -796,7 +799,7 @@
buf[i+4] = mbpt->sweat;
}
htond((unsigned char *)ep->ext_buf + 2*SIZEOF_NETWORK_LONG, (unsigned char *)buf, 1 + 5 * metaball_count);
- bu_free((genptr_t)buf, "rt_metaball_export5: buf");
+ bu_free(buf, "rt_metaball_export5: buf");
return 0;
}
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -845,8 +845,12 @@
/* If zero, means literal array of values */
{
+ int i;
unsigned char *cp;
+ /* always write doubles to disk */
+ double *scanp;
+
if (pt_type)
count *= RT_NURB_EXTRACT_COORDS(pt_type);
@@ -854,28 +858,31 @@
*(uint32_t *)&cp[0] = htonl(DISK_DOUBLE_ARRAY_MAGIC);
*(uint32_t *)&cp[4] = htonl(count);
if (pt_type == 0 || ZERO(scale - 1.0)) {
- htond(cp + (4+4), (unsigned char *)fp, count);
+ scanp = (double *)bu_malloc(count * sizeof(double), "scanp");
+ /* convert fastf_t to double */
+ for (i=0; i<count; i++) {
+ scanp[i] = fp[i];
+ }
+ htond(cp + (4+4), (unsigned char *)scanp, count);
+ bu_free(scanp, "scanp");
} else {
- fastf_t *newdata;
-
/* Need to scale data by 'scale' ! */
- newdata = (fastf_t *)bu_malloc(count*sizeof(fastf_t), "rt_nmg_export4_fastf");
+ scanp = (double *)bu_malloc(count*sizeof(double), "scanp");
if (RT_NURB_IS_PT_RATIONAL(pt_type)) {
/* Don't scale the homogeneous (rational) coord */
- int i;
int nelem; /* # elements per tuple */
nelem = RT_NURB_EXTRACT_COORDS(pt_type);
for (i = 0; i < count; i += nelem) {
- VSCALEN(&newdata[i], &fp[i], scale, nelem-1);
- newdata[i+nelem-1] = fp[i+nelem-1];
+ VSCALEN(&scanp[i], &fp[i], scale, nelem-1);
+ scanp[i+nelem-1] = fp[i+nelem-1];
}
} else {
/* Scale everything as one long array */
- VSCALEN(newdata, fp, scale, count);
+ VSCALEN(scanp, fp, scale, count);
}
- htond(cp + (4+4), (unsigned char *)newdata, count);
- bu_free((char *)newdata, "rt_nmg_export4_fastf");
+ htond(cp + (4+4), (unsigned char *)scanp, count);
+ bu_free(scanp, "rt_nmg_export4_fastf");
}
cp += (4+4) + count * 8;
rt_nmg_fastf_p = cp;
@@ -890,10 +897,15 @@
rt_nmg_import4_fastf(const unsigned char *base, struct nmg_exp_counts *ecnt, long int subscript, const matp_t mat, int len, int pt_type)
{
const unsigned char *cp;
+
+ int i;
int count;
fastf_t *ret;
- fastf_t *tmp;
+ /* must be double for import and export */
+ double *tmp;
+ double *scanp;
+
if (ecnt[subscript].byte_offset <= 0 || ecnt[subscript].kind != NMG_KIND_DOUBLE_ARRAY) {
bu_log("subscript=%d, byte_offset=%d, kind=%d (expected %d)\n",
subscript, ecnt[subscript].byte_offset,
@@ -922,7 +934,13 @@
}
ret = (fastf_t *)bu_malloc(count * sizeof(fastf_t), "rt_nmg_import4_fastf[]");
if (!mat) {
- ntohd((unsigned char *)ret, cp + (4+4), count);
+ scanp = (double *)bu_malloc(count * sizeof(double), "scanp");
+ ntohd((unsigned char *)scanp, cp + (4+4), count);
+ /* read as double, return as fastf_t */
+ for (i=0; i<count; i++) {
+ ret[i] = scanp[i];
+ }
+ bu_free(scanp, "scanp");
return ret;
}
@@ -931,8 +949,9 @@
* Need to know width of data points, may be 3, or 4-tuples.
* The vector times matrix calculation can't be done in place.
*/
- tmp = (fastf_t *)bu_malloc(count * sizeof(fastf_t), "rt_nmg_import4_fastf tmp[]");
+ tmp = (double *)bu_malloc(count * sizeof(double), "rt_nmg_import4_fastf tmp[]");
ntohd((unsigned char *)tmp, cp + (4+4), count);
+
switch (RT_NURB_EXTRACT_COORDS(pt_type)) {
case 3:
if (RT_NURB_IS_PT_RATIONAL(pt_type)) bu_bomb("rt_nmg_import4_fastf() Rational 3-tuple?\n");
@@ -949,7 +968,9 @@
default:
bu_bomb("rt_nmg_import4_fastf() unsupported # of coords in ctl_point\n");
}
- bu_free((char *)tmp, "rt_nmg_import4_fastf tmp[]");
+
+ bu_free(tmp, "rt_nmg_import4_fastf tmp[]");
+
return ret;
}
@@ -1054,14 +1075,18 @@
case NMG_KIND_NMGREGION_A: {
struct nmgregion_a *r = (struct nmgregion_a *)ip;
struct disk_nmgregion_a *d;
- point_t min, max;
+
+ /* must be double for import and export */
+ double min[ELEMENTS_PER_POINT];
+ double max[ELEMENTS_PER_POINT];
+
d = &((struct disk_nmgregion_a *)op)[oindex];
NMG_CK_REGION_A(r);
PUTMAGIC(DISK_REGION_A_MAGIC);
VSCALE(min, r->min_pt, local2mm);
VSCALE(max, r->max_pt, local2mm);
- htond(d->min_pt, (unsigned char *)min, 3);
- htond(d->max_pt, (unsigned char *)max, 3);
+ htond(d->min_pt, (unsigned char *)min, ELEMENTS_PER_POINT);
+ htond(d->max_pt, (unsigned char *)max, ELEMENTS_PER_POINT);
}
return;
case NMG_KIND_SHELL: {
@@ -1082,14 +1107,18 @@
case NMG_KIND_SHELL_A: {
struct shell_a *sa = (struct shell_a *)ip;
struct disk_shell_a *d;
- point_t min, max;
+
+ /* must be double for import and export */
+ double min[ELEMENTS_PER_POINT];
+ double max[ELEMENTS_PER_POINT];
+
d = &((struct disk_shell_a *)op)[oindex];
NMG_CK_SHELL_A(sa);
PUTMAGIC(DISK_SHELL_A_MAGIC);
VSCALE(min, sa->min_pt, local2mm);
VSCALE(max, sa->max_pt, local2mm);
- htond(d->min_pt, (unsigned char *)min, 3);
- htond(d->max_pt, (unsigned char *)max, 3);
+ htond(d->min_pt, (unsigned char *)min, ELEMENTS_PER_POINT);
+ htond(d->max_pt, (unsigned char *)max, ELEMENTS_PER_POINT);
}
return;
case NMG_KIND_FACEUSE: {
@@ -1124,14 +1153,20 @@
case NMG_KIND_FACE_G_PLANE: {
struct face_g_plane *fg = (struct face_g_plane *)ip;
struct disk_face_g_plane *d;
- plane_t plane;
+
+ /* must be double for import and export */
+ double plane[ELEMENTS_PER_PLANE];
+
d = &((struct disk_face_g_plane *)op)[oindex];
NMG_CK_FACE_G_PLANE(fg);
PUTMAGIC(DISK_FACE_G_PLANE_MAGIC);
INDEXL(d, fg, f_hd);
+
+ /* convert fastf_t to double */
VMOVE(plane, fg->N);
plane[W] = fg->N[W] * local2mm;
- htond(d->N, (unsigned char *)plane, 4);
+
+ htond(d->N, (unsigned char *)plane, ELEMENTS_PER_PLANE);
}
return;
case NMG_KIND_FACE_G_SNURB: {
@@ -1190,14 +1225,20 @@
case NMG_KIND_LOOP_G: {
struct loop_g *lg = (struct loop_g *)ip;
struct disk_loop_g *d;
- point_t min, max;
+
+ /* must be double for import and export */
+ double min[ELEMENTS_PER_POINT];
+ double max[ELEMENTS_PER_POINT];
+
d = &((struct disk_loop_g *)op)[oindex];
NMG_CK_LOOP_G(lg);
PUTMAGIC(DISK_LOOP_G_MAGIC);
+
VSCALE(min, lg->min_pt, local2mm);
VSCALE(max, lg->max_pt, local2mm);
- htond(d->min_pt, (unsigned char *)min, 3);
- htond(d->max_pt, (unsigned char *)max, 3);
+
+ htond(d->min_pt, (unsigned char *)min, ELEMENTS_PER_POINT);
+ htond(d->max_pt, (unsigned char *)max, ELEMENTS_PER_POINT);
}
return;
case NMG_KIND_EDGEUSE: {
@@ -1234,14 +1275,22 @@
case NMG_KIND_EDGE_G_LSEG: {
struct edge_g_lseg *eg = (struct edge_g_lseg *)ip;
struct disk_edge_g_lseg *d;
- point_t pt;
+
+ /* must be double for import and export */
+ double pt[ELEMENTS_PER_POINT];
+ double dir[ELEMENTS_PER_VECT];
+
d = &((struct disk_edge_g_lseg *)op)[oindex];
NMG_CK_EDGE_G_LSEG(eg);
PUTMAGIC(DISK_EDGE_G_LSEG_MAGIC);
INDEXL(d, eg, eu_hd2);
+
+ /* convert fastf_t to double */
VSCALE(pt, eg->e_pt, local2mm);
- htond(d->e_pt, (unsigned char *)pt, 3);
- htond(d->e_dir, (unsigned char *)eg->e_dir, 3);
+ VMOVE(dir, eg->e_dir);
+
+ htond(d->e_pt, (unsigned char *)pt, ELEMENTS_PER_POINT);
+ htond(d->e_dir, (unsigned char *)dir, ELEMENTS_PER_VECT);
}
return;
case NMG_KIND_EDGE_G_CNURB: {
@@ -1291,23 +1340,35 @@
case NMG_KIND_VERTEXUSE_A_PLANE: {
struct vertexuse_a_plane *vua = (struct vertexuse_a_plane *)ip;
struct disk_vertexuse_a_plane *d;
+
+ /* must be double for import and export */
+ double normal[ELEMENTS_PER_VECT];
+
d = &((struct disk_vertexuse_a_plane *)op)[oindex];
NMG_CK_VERTEXUSE_A_PLANE(vua);
PUTMAGIC(DISK_VERTEXUSE_A_PLANE_MAGIC);
+
/* Normal vectors don't scale */
/* This is not a plane equation here */
- htond(d->N, (unsigned char *)vua->N, 3);
+ VMOVE(normal, vua->N); /* convert fastf_t to double */
+ htond(d->N, (unsigned char *)normal, ELEMENTS_PER_VECT);
}
return;
case NMG_KIND_VERTEXUSE_A_CNURB: {
struct vertexuse_a_cnurb *vua = (struct vertexuse_a_cnurb *)ip;
struct disk_vertexuse_a_cnurb *d;
+ /* must be double for import and export */
+ double param[3];
+
d = &((struct disk_vertexuse_a_cnurb *)op)[oindex];
NMG_CK_VERTEXUSE_A_CNURB(vua);
PUTMAGIC(DISK_VERTEXUSE_A_CNURB_MAGIC);
+
/* (u, v) parameters on curves don't scale */
- htond(d->param, (unsigned char *)vua->param, 3);
+ VMOVE(param, vua->param); /* convert fastf_t to double */
+
+ htond(d->param, (unsigned char *)param, 3);
}
return;
case NMG_KIND_VERTEX: {
@@ -1323,12 +1384,16 @@
case NMG_KIND_VERTEX_G: {
struct vertex_g *vg = (struct vertex_g *)ip;
struct disk_vertex_g *d;
- point_t pt;
+
+ /* must be double for import and export */
+ double pt[ELEMENTS_PER_POINT];
+
d = &((struct disk_vertex_g *)op)[oindex];
NMG_CK_VERTEX_G(vg);
PUTMAGIC(DISK_VERTEX_G_MAGIC);
VSCALE(pt, vg->coord, local2mm);
- htond(d->coord, (unsigned char *)pt, 3);
+
+ htond(d->coord, (unsigned char *)pt, ELEMENTS_PER_POINT);
}
return;
}
@@ -1418,12 +1483,20 @@
case NMG_KIND_NMGREGION_A: {
struct nmgregion_a *r = (struct nmgregion_a *)op;
struct disk_nmgregion_a *d;
- point_t min, max;
+ point_t min;
+ point_t max;
+
+ /* must be double for import and export */
+ double scanmin[ELEMENTS_PER_POINT];
+ double scanmax[ELEMENTS_PER_POINT];
+
d = &((struct disk_nmgregion_a *)ip)[iindex];
NMG_CK_REGION_A(r);
NMG_CK_DISKMAGIC(d->magic, DISK_REGION_A_MAGIC);
- ntohd((unsigned char *)min, d->min_pt, 3);
- ntohd((unsigned char *)max, d->max_pt, 3);
+ ntohd((unsigned char *)scanmin, d->min_pt, ELEMENTS_PER_POINT);
+ VMOVE(min, scanmin); /* convert double to fastf_t */
+ ntohd((unsigned char *)scanmax, d->max_pt, ELEMENTS_PER_POINT);
+ VMOVE(max, scanmax); /* convert double to fastf_t */
bn_rotate_bbox(r->min_pt, r->max_pt, mat, min, max);
}
return 0;
@@ -1446,12 +1519,20 @@
case NMG_KIND_SHELL_A: {
struct shell_a *sa = (struct shell_a *)op;
struct disk_shell_a *d;
- point_t min, max;
+ point_t min;
+ point_t max;
+
+ /* must be double for import and export */
+ double scanmin[ELEMENTS_PER_POINT];
+ double scanmax[ELEMENTS_PER_POINT];
+
d = &((struct disk_shell_a *)ip)[iindex];
NMG_CK_SHELL_A(sa);
NMG_CK_DISKMAGIC(d->magic, DISK_SHELL_A_MAGIC);
- ntohd((unsigned char *)min, d->min_pt, 3);
- ntohd((unsigned char *)max, d->max_pt, 3);
+ ntohd((unsigned char *)scanmin, d->min_pt, ELEMENTS_PER_POINT);
+ VMOVE(min, scanmin); /* convert double to fastf_t */
+ ntohd((unsigned char *)scanmax, d->max_pt, ELEMENTS_PER_POINT);
+ VMOVE(max, scanmax); /* convert double to fastf_t */
bn_rotate_bbox(sa->min_pt, sa->max_pt, mat, min, max);
}
return 0;
@@ -1493,11 +1574,16 @@
struct face_g_plane *fg = (struct face_g_plane *)op;
struct disk_face_g_plane *d;
plane_t plane;
+
+ /* must be double for import and export */
+ double scan[ELEMENTS_PER_PLANE];
+
d = &((struct disk_face_g_plane *)ip)[iindex];
NMG_CK_FACE_G_PLANE(fg);
NMG_CK_DISKMAGIC(d->magic, DISK_FACE_G_PLANE_MAGIC);
INDEXL_HD(d, fg, f_hd, fg->f_hd);
- ntohd((unsigned char *)plane, d->N, 4);
+ ntohd((unsigned char *)scan, d->N, ELEMENTS_PER_PLANE);
+ HMOVE(plane, scan); /* convert double to fastf_t */
bn_rotate_plane(fg->N, mat, plane);
}
return 0;
@@ -1568,12 +1654,20 @@
case NMG_KIND_LOOP_G: {
struct loop_g *lg = (struct loop_g *)op;
struct disk_loop_g *d;
- point_t min, max;
+ point_t min;
+ point_t max;
+
+ /* must be double for import and export */
+ double scanmin[ELEMENTS_PER_POINT];
+ double scanmax[ELEMENTS_PER_POINT];
+
d = &((struct disk_loop_g *)ip)[iindex];
NMG_CK_LOOP_G(lg);
NMG_CK_DISKMAGIC(d->magic, DISK_LOOP_G_MAGIC);
- ntohd((unsigned char *)min, d->min_pt, 3);
- ntohd((unsigned char *)max, d->max_pt, 3);
+ ntohd((unsigned char *)scanmin, d->min_pt, ELEMENTS_PER_POINT);
+ VMOVE(min, scanmin); /* convert double to fastf_t */
+ ntohd((unsigned char *)scanmax, d->max_pt, ELEMENTS_PER_POINT);
+ VMOVE(max, scanmax); /* convert double to fastf_t */
bn_rotate_bbox(lg->min_pt, lg->max_pt, mat, min, max);
}
return 0;
@@ -1633,13 +1727,19 @@
point_t pt;
vect_t dir;
+ /* must be double for import and export */
+ double scanpt[ELEMENTS_PER_POINT];
+ double scandir[ELEMENTS_PER_VECT];
+
d = &((struct disk_edge_g_lseg *)ip)[iindex];
NMG_CK_EDGE_G_LSEG(eg);
NMG_CK_DISKMAGIC(d->magic, DISK_EDGE_G_LSEG_MAGIC);
/* Forw subscript points to edgeuse, not edgeuse2 */
INDEXL_HD2(d, eg, eu_hd2, eg->eu_hd2);
- ntohd((unsigned char *)pt, d->e_pt, 3);
- ntohd((unsigned char *)dir, d->e_dir, 3);
+ ntohd((unsigned char *)scanpt, d->e_pt, ELEMENTS_PER_POINT);
+ VMOVE(pt, scanpt); /* convert double to fastf_t */
+ ntohd((unsigned char *)scandir, d->e_dir, ELEMENTS_PER_VECT);
+ VMOVE(dir, scandir); /* convert double to fastf_t */
MAT4X3PNT(eg->e_pt, mat, pt);
MAT4X3VEC(eg->e_dir, mat, dir);
}
@@ -1698,22 +1798,29 @@
case NMG_KIND_VERTEXUSE_A_PLANE: {
struct vertexuse_a_plane *vua = (struct vertexuse_a_plane *)op;
struct disk_vertexuse_a_plane *d;
- vect_t norm;
+ /* must be double for import and export */
+ double norm[ELEMENTS_PER_VECT];
+
d = &((struct disk_vertexuse_a_plane *)ip)[iindex];
NMG_CK_VERTEXUSE_A_PLANE(vua);
NMG_CK_DISKMAGIC(d->magic, DISK_VERTEXUSE_A_PLANE_MAGIC);
- ntohd((unsigned char *)norm, d->N, 3);
+ ntohd((unsigned char *)norm, d->N, ELEMENTS_PER_VECT);
MAT4X3VEC(vua->N, mat, norm);
}
return 0;
case NMG_KIND_VERTEXUSE_A_CNURB: {
struct vertexuse_a_cnurb *vua = (struct vertexuse_a_cnurb *)op;
struct disk_vertexuse_a_cnurb *d;
+
+ /* must be double for import and export */
+ double scan[3];
+
d = &((struct disk_vertexuse_a_cnurb *)ip)[iindex];
NMG_CK_VERTEXUSE_A_CNURB(vua);
NMG_CK_DISKMAGIC(d->magic, DISK_VERTEXUSE_A_CNURB_MAGIC);
/* These parameters are invariant w.r.t. 'mat' */
- ntohd((unsigned char *)vua->param, d->param, 3);
+ ntohd((unsigned char *)scan, d->param, 3);
+ VMOVE(vua->param, scan); /* convert double to fastf_t */
}
return 0;
case NMG_KIND_VERTEX: {
@@ -1729,11 +1836,13 @@
case NMG_KIND_VERTEX_G: {
struct vertex_g *vg = (struct vertex_g *)op;
struct disk_vertex_g *d;
- point_t pt;
+ /* must be double for import and export */
+ double pt[ELEMENTS_PER_POINT];
+
d = &((struct disk_vertex_g *)ip)[iindex];
NMG_CK_VERTEX_G(vg);
NMG_CK_DISKMAGIC(d->magic, DISK_VERTEX_G_MAGIC);
- ntohd((unsigned char *)pt, d->coord, 3);
+ ntohd((unsigned char *)pt, d->coord, ELEMENTS_PER_POINT);
MAT4X3PNT(vg->coord, mat, pt);
}
return 0;
Modified: brlcad/trunk/src/librt/primitives/part/part.c
===================================================================
--- brlcad/trunk/src/librt/primitives/part/part.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/part/part.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1450,14 +1450,16 @@
int
rt_part_import4(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
- point_t v;
- vect_t h;
- double vrad;
- double hrad;
fastf_t maxrad, minrad;
union record *rp;
struct rt_part_internal *part;
+ /* must be double for import and export */
+ double v[ELEMENTS_PER_POINT];
+ double h[ELEMENTS_PER_VECT];
+ double vrad;
+ double hrad;
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -1469,8 +1471,8 @@
}
/* Convert from database to internal format */
- ntohd((unsigned char *)v, rp->part.p_v, 3);
- ntohd((unsigned char *)h, rp->part.p_h, 3);
+ ntohd((unsigned char *)v, rp->part.p_v, ELEMENTS_PER_POINT);
+ ntohd((unsigned char *)h, rp->part.p_h, ELEMENTS_PER_VECT);
ntohd((unsigned char *)&vrad, rp->part.p_vrad, 1);
ntohd((unsigned char *)&hrad, rp->part.p_hrad, 1);
@@ -1541,11 +1543,13 @@
{
struct rt_part_internal *pip;
union record *rec;
- point_t vert;
- vect_t hi;
- fastf_t vrad;
- fastf_t hrad;
+ /* must be double for import and export */
+ double vert[ELEMENTS_PER_POINT];
+ double hi[ELEMENTS_PER_VECT];
+ double vrad;
+ double hrad;
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -1566,8 +1570,8 @@
/* pip->part_type is not converted -- internal only */
rec->part.p_id = DBID_PARTICLE;
- htond(rec->part.p_v, (unsigned char *)vert, 3);
- htond(rec->part.p_h, (unsigned char *)hi, 3);
+ htond(rec->part.p_v, (unsigned char *)vert, ELEMENTS_PER_POINT);
+ htond(rec->part.p_h, (unsigned char *)hi, ELEMENTS_PER_VECT);
htond(rec->part.p_vrad, (unsigned char *)&vrad, 1);
htond(rec->part.p_hrad, (unsigned char *)&hrad, 1);
@@ -1583,8 +1587,10 @@
{
fastf_t maxrad, minrad;
struct rt_part_internal *part;
- fastf_t vec[8];
+ /* must be double for import and export */
+ double vec[8];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -1661,8 +1667,10 @@
rt_part_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_part_internal *pip;
- fastf_t vec[8];
+ /* must be double for import and export */
+ double vec[8];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/pipe/pipe.c
===================================================================
--- brlcad/trunk/src/librt/primitives/pipe/pipe.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/pipe/pipe.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -3351,6 +3351,9 @@
struct rt_pipe_internal *pip;
union record *rp;
+ /* must be double for import and export */
+ double scan[ELEMENTS_PER_VECT];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -3378,11 +3381,18 @@
BU_LIST_INIT(&pip->pipe_segs_head);
if (mat == NULL) mat = bn_mat_identity;
for (exp_pipept = &rp->pwr.pwr_data[pip->pipe_count-1]; exp_pipept >= &rp->pwr.pwr_data[0]; exp_pipept--) {
- ntohd((unsigned char *)&tmp.pp_id, exp_pipept->epp_id, 1);
- ntohd((unsigned char *)&tmp.pp_od, exp_pipept->epp_od, 1);
- ntohd((unsigned char *)&tmp.pp_bendradius, exp_pipept->epp_bendradius, 1);
- ntohd((unsigned char *)tmp.pp_coord, exp_pipept->epp_coord, 3);
+ ntohd((unsigned char *)&scan[0], exp_pipept->epp_id, 1);
+ tmp.pp_id = scan[0]; /* convert double to fastf_t */
+ ntohd((unsigned char *)&scan[1], exp_pipept->epp_od, 1);
+ tmp.pp_od = scan[1]; /* convert double to fastf_t */
+
+ ntohd((unsigned char *)&scan[2], exp_pipept->epp_bendradius, 1);
+ tmp.pp_bendradius = scan[2]; /* convert double to fastf_t */
+
+ ntohd((unsigned char *)scan, exp_pipept->epp_coord, ELEMENTS_PER_VECT);
+ VMOVE(tmp.pp_coord, scan); /* convert double to fastf_t */
+
/* Apply modeling transformations */
BU_GET(ptp, struct wdb_pipept);
ptp->l.magic = WDB_PIPESEG_MAGIC;
@@ -3449,15 +3459,26 @@
/* Convert the pipe segments to external form */
epp = &rec->pwr.pwr_data[0];
for (BU_LIST_FOR(ppt, wdb_pipept, headp), epp++) {
+ double scan[ELEMENTS_PER_POINT];
+
/* Convert from user units to mm */
VSCALE(tmp.pp_coord, ppt->pp_coord, local2mm);
tmp.pp_id = ppt->pp_id * local2mm;
tmp.pp_od = ppt->pp_od * local2mm;
tmp.pp_bendradius = ppt->pp_bendradius * local2mm;
- htond(epp->epp_coord, (unsigned char *)tmp.pp_coord, 3);
- htond(epp->epp_id, (unsigned char *)&tmp.pp_id, 1);
- htond(epp->epp_od, (unsigned char *)&tmp.pp_od, 1);
- htond(epp->epp_bendradius, (unsigned char *)&tmp.pp_bendradius, 1);
+
+
+ VMOVE(scan, tmp.pp_coord); /* convert fastf_t to double */
+ htond(epp->epp_coord, (unsigned char *)scan, ELEMENTS_PER_POINT);
+
+ scan[0] = tmp.pp_id; /* convert fastf_t to double */
+ htond(epp->epp_id, (unsigned char *)&scan[0], 1);
+
+ scan[1] = tmp.pp_od; /* convert fastf_t to double */
+ htond(epp->epp_od, (unsigned char *)&scan[1], 1);
+
+ scan[2] = tmp.pp_bendradius; /* convert fastf_t to double */
+ htond(epp->epp_bendradius, (unsigned char *)&scan[2], 1);
}
return 0;
@@ -3472,7 +3493,10 @@
{
struct wdb_pipept *ptp;
struct rt_pipe_internal *pip;
- fastf_t *vec;
+
+ /* must be double for import and export */
+ double *vec;
+
size_t total_count;
int double_count;
int byte_count;
@@ -3498,7 +3522,8 @@
pip->pipe_magic = RT_PIPE_INTERNAL_MAGIC;
pip->pipe_count = pipe_count;
- vec = (fastf_t *)bu_malloc(byte_count, "rt_pipe_import5: vec");
+ vec = (double *)bu_malloc(byte_count, "rt_pipe_import5: vec");
+
/* Convert from database (network) to internal (host) format */
ntohd((unsigned char *)vec, (unsigned char *)ep->ext_buf + 4, double_count);
@@ -3534,13 +3559,15 @@
struct rt_pipe_internal *pip;
struct bu_list *headp;
struct wdb_pipept *ppt;
- fastf_t *vec;
int total_count;
int double_count;
int byte_count;
unsigned long pipe_count;
int i = 0;
+ /* must be double for import and export */
+ double *vec;
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -3563,7 +3590,7 @@
double_count = pipe_count * 6;
byte_count = double_count * SIZEOF_NETWORK_DOUBLE;
total_count = 4 + byte_count;
- vec = (fastf_t *)bu_malloc(byte_count, "rt_pipe_export5: vec");
+ vec = (double *)bu_malloc(byte_count, "rt_pipe_export5: vec");
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = total_count;
Modified: brlcad/trunk/src/librt/primitives/pnts/pnts.c
===================================================================
--- brlcad/trunk/src/librt/primitives/pnts/pnts.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/pnts/pnts.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -113,6 +113,9 @@
unsigned long pointDataSize;
unsigned char *buf = NULL;
+ /* must be double for import and export */
+ double scan;
+
if (dbip) RT_CK_DBI(dbip);
/* acquire internal pnts structure */
@@ -128,7 +131,8 @@
external->ext_buf = (genptr_t) bu_calloc(sizeof(unsigned char), external->ext_nbytes, "pnts external");
buf = (unsigned char *)external->ext_buf;
- htond(buf, (unsigned char *)&pnts->scale, 1);
+ scan = pnts->scale; /* convert fastf_t to double */
+ htond(buf, (unsigned char *)&scan, 1);
buf += SIZEOF_NETWORK_DOUBLE;
*(uint16_t *)buf = htons((unsigned short)pnts->type);
buf += SIZEOF_NETWORK_SHORT;
@@ -356,6 +360,9 @@
unsigned char *buf = NULL;
unsigned long i;
+ /* must be double for import and export */
+ double scan;
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(internal);
@@ -374,7 +381,8 @@
pnts->point = NULL;
/* unpack the header */
- ntohd((unsigned char *)&pnts->scale, buf, 1);
+ ntohd((unsigned char *)&scan, buf, 1);
+ pnts->scale = scan; /* convert double to fastf_t */
buf += SIZEOF_NETWORK_DOUBLE;
pnts->type = (rt_pnt_type)ntohs(*(uint16_t *)buf);
buf += SIZEOF_NETWORK_SHORT;
Modified: brlcad/trunk/src/librt/primitives/revolve/revolve.c
===================================================================
--- brlcad/trunk/src/librt/primitives/revolve/revolve.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/revolve/revolve.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1467,8 +1467,10 @@
rt_revolve_import5(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip, struct resource *resp)
{
struct rt_revolve_internal *rip;
- fastf_t vv[ELEMENTS_PER_VECT*3 + 1];
+ /* must be double for import and export */
+ double vv[ELEMENTS_PER_VECT*3 + 1];
+
char *sketch_name;
unsigned char *ptr;
struct directory *dp;
@@ -1613,7 +1615,10 @@
rt_revolve_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_revolve_internal *rip;
- fastf_t vec[ELEMENTS_PER_VECT*3 + 1];
+
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*3 + 1];
+
unsigned char *ptr;
if (dbip) RT_CK_DBI(dbip);
Modified: brlcad/trunk/src/librt/primitives/rhc/rhc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/rhc/rhc.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/rhc/rhc.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1546,8 +1546,10 @@
rt_rhc_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_rhc_internal *xip;
- fastf_t vec[11];
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) {
RT_CK_DBI(dbip);
}
@@ -1597,8 +1599,10 @@
rt_rhc_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_rhc_internal *xip;
- fastf_t vec[11];
+ /* must be double for import and export */
+ double vec[11];
+
if (dbip) {
RT_CK_DBI(dbip);
}
Modified: brlcad/trunk/src/librt/primitives/rpc/rpc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/rpc/rpc.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/rpc/rpc.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1412,8 +1412,10 @@
rt_rpc_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_rpc_internal *xip;
- fastf_t vec[10];
+ /* must be double for import and export */
+ double vec[10];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -1457,9 +1459,11 @@
rt_rpc_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_rpc_internal *xip;
- fastf_t vec[10];
fastf_t f, mag_b, mag_h;
+ /* must be double for import and export */
+ double vec[10];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
Modified: brlcad/trunk/src/librt/primitives/sketch/sketch.c
===================================================================
--- brlcad/trunk/src/librt/primitives/sketch/sketch.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/sketch/sketch.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -961,12 +961,15 @@
{
struct rt_sketch_internal *sketch_ip;
union record *rp;
- vect_t v;
size_t seg_no;
unsigned char *ptr;
struct rt_curve *crv;
size_t i;
+ /* must be double for import and export */
+ double v[ELEMENTS_PER_VECT];
+ double *vp;
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
@@ -991,22 +994,32 @@
sketch_ip->magic = RT_SKETCH_INTERNAL_MAGIC;
if (mat == NULL) mat = bn_mat_identity;
- ntohd((unsigned char *)v, rp->skt.skt_V, 3);
+ ntohd((unsigned char *)v, rp->skt.skt_V, ELEMENTS_PER_VECT);
MAT4X3PNT(sketch_ip->V, mat, v);
- ntohd((unsigned char *)v, rp->skt.skt_uvec, 3);
+ ntohd((unsigned char *)v, rp->skt.skt_uvec, ELEMENTS_PER_VECT);
MAT4X3VEC(sketch_ip->u_vec, mat, v);
- ntohd((unsigned char *)v, rp->skt.skt_vvec, 3);
+ ntohd((unsigned char *)v, rp->skt.skt_vvec, ELEMENTS_PER_VECT);
MAT4X3VEC(sketch_ip->v_vec, mat, v);
sketch_ip->vert_count = ntohl(*(uint32_t *)rp->skt.skt_vert_count);
sketch_ip->curve.count = ntohl(*(uint32_t *)rp->skt.skt_count);
ptr = (unsigned char *)rp;
ptr += sizeof(struct sketch_rec);
- if (sketch_ip->vert_count)
+ if (sketch_ip->vert_count) {
sketch_ip->verts = (point2d_t *)bu_calloc(sketch_ip->vert_count, sizeof(point2d_t), "sketch_ip->vert");
- ntohd((unsigned char *)sketch_ip->verts, ptr, sketch_ip->vert_count*2);
- ptr += 16 * sketch_ip->vert_count;
+ vp = (double *)bu_calloc(sketch_ip->vert_count, sizeof(double)*ELEMENTS_PER_VECT2D, "vp");
+ ntohd((unsigned char *)vp, ptr, sketch_ip->vert_count*ELEMENTS_PER_VECT2D);
+ /* convert double to fastf_t */
+ for (i=0; i<sketch_ip->vert_count; i++) {
+ sketch_ip->verts[i][X] = vp[(i*ELEMENTS_PER_VECT2D)+0];
+ sketch_ip->verts[i][Y] = vp[(i*ELEMENTS_PER_VECT2D)+1];
+ }
+
+ bu_free(vp, "vp");
+ ptr += 16 * sketch_ip->vert_count;
+ }
+
if (sketch_ip->curve.count)
sketch_ip->curve.segment = (genptr_t *)bu_calloc(sketch_ip->curve.count, sizeof(genptr_t), "segs");
else
@@ -1018,6 +1031,10 @@
struct nurb_seg *nsg;
struct bezier_seg *bsg;
+ /* must be double for import and export */
+ double scan;
+ double *scanp;
+
magic = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
switch (magic) {
@@ -1041,7 +1058,8 @@
ptr += SIZEOF_NETWORK_LONG;
csg->center_is_left = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
- ntohd((unsigned char *)&csg->radius, ptr, 1);
+ ntohd((unsigned char *)&scan, ptr, 1);
+ csg->radius = scan; /* convert double to fastf_t */
ptr += SIZEOF_NETWORK_DOUBLE;
sketch_ip->curve.segment[seg_no] = (genptr_t)csg;
break;
@@ -1054,8 +1072,17 @@
ptr += SIZEOF_NETWORK_LONG;
nsg->k.k_size = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
+
nsg->k.knots = (fastf_t *)bu_malloc(nsg->k.k_size * sizeof(fastf_t), "nsg->k.knots");
- ntohd((unsigned char *)nsg->k.knots, ptr, nsg->k.k_size);
+ scanp = (double *)bu_malloc(nsg->k.k_size * sizeof(double), "scanp");
+ ntohd((unsigned char *)scanp, ptr, nsg->k.k_size);
+
+ /* convert double to fastf_t */
+ for (i=0; i<(size_t)nsg->k.k_size; i++) {
+ nsg->k.knots[i] = scanp[i];
+ }
+ bu_free(scanp, "scanp");
+
ptr += SIZEOF_NETWORK_DOUBLE * nsg->k.k_size;
nsg->c_size = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
@@ -1066,10 +1093,19 @@
}
if (RT_NURB_IS_PT_RATIONAL(nsg->pt_type)) {
nsg->weights = (fastf_t *)bu_malloc(nsg->c_size * sizeof(fastf_t), "nsg->weights");
- ntohd((unsigned char *)nsg->weights, ptr, nsg->c_size);
+ scanp = (double *)bu_malloc(nsg->c_size * sizeof(double), "scanp");
+ ntohd((unsigned char *)scanp, ptr, nsg->c_size);
+
+ /* convert double to fastf_t */
+ for (i=0; i<(size_t)nsg->k.k_size; i++) {
+ nsg->weights[i] = scanp[i];
+ }
+ bu_free(scanp, "scanp");
+
ptr += SIZEOF_NETWORK_DOUBLE * nsg->c_size;
- } else
+ } else {
nsg->weights = (fastf_t *)NULL;
+ }
sketch_ip->curve.segment[seg_no] = (genptr_t)nsg;
break;
case CURVE_BEZIER_MAGIC:
@@ -1119,9 +1155,11 @@
struct rt_sketch_internal *sketch_ip;
union record *rec;
size_t i, seg_no, nbytes=0, ngran;
- vect_t tmp_vec;
unsigned char *ptr;
+ /* must be double for import and export */
+ double tmp_vec[ELEMENTS_PER_VECT];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -1180,11 +1218,13 @@
* to database record format
*/
VSCALE(tmp_vec, sketch_ip->V, local2mm);
- htond(rec->skt.skt_V, (unsigned char *)tmp_vec, 3);
+ htond(rec->skt.skt_V, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
/* uvec and uvec are unit vectors, do not convert to/from mm */
- htond(rec->skt.skt_uvec, (unsigned char *)sketch_ip->u_vec, 3);
- htond(rec->skt.skt_vvec, (unsigned char *)sketch_ip->v_vec, 3);
+ VMOVE(tmp_vec, sketch_ip->u_vec); /* convert fastf_t to double */
+ htond(rec->skt.skt_uvec, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
+ VMOVE(tmp_vec, sketch_ip->v_vec); /* convert fastf_t to double */
+ htond(rec->skt.skt_vvec, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
*(uint32_t *)rec->skt.skt_vert_count = htonl(sketch_ip->vert_count);
*(uint32_t *)rec->skt.skt_count = htonl(sketch_ip->curve.count);
@@ -1194,10 +1234,11 @@
ptr += sizeof(struct sketch_rec);
/* convert 2D points to mm */
for (i=0; i<sketch_ip->vert_count; i++) {
- point2d_t pt2d;
+ /* must be double for import and export */
+ double pt2d[ELEMENTS_PER_VECT2D];
- V2SCALE(pt2d, sketch_ip->verts[i], local2mm)
- htond(ptr, (const unsigned char *)pt2d, 2);
+ V2SCALE(pt2d, sketch_ip->verts[i], local2mm);
+ htond(ptr, (const unsigned char *)pt2d, ELEMENTS_PER_VECT2D);
ptr += 16;
}
@@ -1207,8 +1248,11 @@
struct nurb_seg *nseg;
struct bezier_seg *bseg;
uint32_t *lng;
- fastf_t tmp_fastf;
+ /* must be double for import and export */
+ double tmp_fastf;
+ double *scanp;
+
/* write segment type ID, and segment parameters */
lng = (uint32_t *)sketch_ip->curve.segment[seg_no];
switch (*lng) {
@@ -1247,7 +1291,13 @@
ptr += SIZEOF_NETWORK_LONG;
*(uint32_t *)ptr = htonl(nseg->k.k_size);
ptr += SIZEOF_NETWORK_LONG;
- htond(ptr, (const unsigned char *)nseg->k.knots, nseg->k.k_size);
+ scanp = (double *)bu_malloc(nseg->k.k_size * sizeof(double), "scanp");
+ /* convert fastf_t to double */
+ for (i=0; i<(size_t)nseg->k.k_size; i++) {
+ scanp[i] = nseg->k.knots[i];
+ }
+ htond(ptr, (const unsigned char *)scanp, nseg->k.k_size);
+ bu_free(scanp, "scanp");
ptr += nseg->k.k_size * 8;
*(uint32_t *)ptr = htonl(nseg->c_size);
ptr += SIZEOF_NETWORK_LONG;
@@ -1256,7 +1306,13 @@
ptr += SIZEOF_NETWORK_LONG;
}
if (RT_NURB_IS_PT_RATIONAL(nseg->pt_type)) {
- htond(ptr, (const unsigned char *)nseg->weights, nseg->c_size);
+ scanp = (double *)bu_malloc(nseg->c_size * sizeof(double), "scanp");
+ /* convert fastf_t to double */
+ for (i=0; i<(size_t)nseg->c_size; i++) {
+ scanp[i] = nseg->weights[i];
+ }
+ htond(ptr, (const unsigned char *)scanp, nseg->c_size);
+ bu_free(scanp, "scanp");
ptr += SIZEOF_NETWORK_DOUBLE * nseg->c_size;
}
break;
@@ -1301,12 +1357,15 @@
rt_sketch_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
{
struct rt_sketch_internal *sketch_ip;
- vect_t v;
size_t seg_no;
unsigned char *ptr;
struct rt_curve *crv;
size_t i;
+ /* must be double for import and export */
+ double v[ELEMENTS_PER_VECT];
+ double *vp;
+
if (bu_debug&BU_DEBUG_MEM_CHECK) {
bu_log("Barrier check at start of sketch_import5():\n");
bu_mem_barriercheck();
@@ -1325,25 +1384,35 @@
ptr = ep->ext_buf;
if (mat == NULL) mat = bn_mat_identity;
- ntohd((unsigned char *)v, ptr, 3);
+ ntohd((unsigned char *)v, ptr, ELEMENTS_PER_VECT);
MAT4X3PNT(sketch_ip->V, mat, v);
- ptr += SIZEOF_NETWORK_DOUBLE * 3;
- ntohd((unsigned char *)v, ptr, 3);
+ ptr += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
+ ntohd((unsigned char *)v, ptr, ELEMENTS_PER_VECT);
MAT4X3VEC(sketch_ip->u_vec, mat, v);
- ptr += SIZEOF_NETWORK_DOUBLE * 3;
- ntohd((unsigned char *)v, ptr, 3);
+ ptr += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
+ ntohd((unsigned char *)v, ptr, ELEMENTS_PER_VECT);
MAT4X3VEC(sketch_ip->v_vec, mat, v);
- ptr += SIZEOF_NETWORK_DOUBLE * 3;
+ ptr += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
sketch_ip->vert_count = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
sketch_ip->curve.count = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
- if (sketch_ip->vert_count)
+ if (sketch_ip->vert_count) {
sketch_ip->verts = (point2d_t *)bu_calloc(sketch_ip->vert_count, sizeof(point2d_t), "sketch_ip->vert");
- ntohd((unsigned char *)sketch_ip->verts, ptr, sketch_ip->vert_count*2);
- ptr += SIZEOF_NETWORK_DOUBLE * 2 * sketch_ip->vert_count;
+ vp = (double *)bu_calloc(sketch_ip->vert_count, sizeof(double)*ELEMENTS_PER_VECT2D, "vp");
+ ntohd((unsigned char *)vp, ptr, sketch_ip->vert_count*2);
+ /* convert double to fastf_t */
+ for (i=0; i<sketch_ip->vert_count; i++) {
+ sketch_ip->verts[i][X] = vp[(i*ELEMENTS_PER_VECT2D)+0];
+ sketch_ip->verts[i][Y] = vp[(i*ELEMENTS_PER_VECT2D)+1];
+ }
+
+ bu_free(vp, "vp");
+ ptr += SIZEOF_NETWORK_DOUBLE * 2 * sketch_ip->vert_count;
+ }
+
if (sketch_ip->curve.count)
sketch_ip->curve.segment = (genptr_t *)bu_calloc(sketch_ip->curve.count, sizeof(genptr_t), "segs");
else
@@ -1355,6 +1424,10 @@
struct nurb_seg *nsg;
struct bezier_seg *bsg;
+ /* must be double for import and export */
+ double scan;
+ double *scanp;
+
magic = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
switch (magic) {
@@ -1378,7 +1451,8 @@
ptr += SIZEOF_NETWORK_LONG;
csg->center_is_left = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
- ntohd((unsigned char *)&csg->radius, ptr, 1);
+ ntohd((unsigned char *)&scan, ptr, 1);
+ csg->radius = scan; /* double to fastf_t */
ptr += SIZEOF_NETWORK_DOUBLE;
sketch_ip->curve.segment[seg_no] = (genptr_t)csg;
break;
@@ -1391,8 +1465,17 @@
ptr += SIZEOF_NETWORK_LONG;
nsg->k.k_size = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
+
nsg->k.knots = (fastf_t *)bu_malloc(nsg->k.k_size * sizeof(fastf_t), "nsg->k.knots");
- ntohd((unsigned char *)nsg->k.knots, ptr, nsg->k.k_size);
+ scanp = (double *)bu_malloc(nsg->k.k_size * sizeof(double), "scanp");
+ ntohd((unsigned char *)scanp, ptr, nsg->k.k_size);
+
+ /* convert double to fastf_t */
+ for (i=0; i<(size_t)nsg->k.k_size; i++) {
+ nsg->k.knots[i] = scanp[i];
+ }
+ bu_free(scanp, "scanp");
+
ptr += SIZEOF_NETWORK_DOUBLE * nsg->k.k_size;
nsg->c_size = ntohl(*(uint32_t *)ptr);
ptr += SIZEOF_NETWORK_LONG;
@@ -1403,7 +1486,15 @@
}
if (RT_NURB_IS_PT_RATIONAL(nsg->pt_type)) {
nsg->weights = (fastf_t *)bu_malloc(nsg->c_size * sizeof(fastf_t), "nsg->weights");
- ntohd((unsigned char *)nsg->weights, ptr, nsg->c_size);
+ scanp = (double *)bu_malloc(nsg->c_size * sizeof(double), "scanp");
+ ntohd((unsigned char *)scanp, ptr, nsg->c_size);
+
+ /* convert double to fastf_t */
+ for (i=0; i<(size_t)nsg->k.k_size; i++) {
+ nsg->weights[i] = scanp[i];
+ }
+ bu_free(scanp, "scanp");
+
ptr += SIZEOF_NETWORK_DOUBLE * nsg->c_size;
} else
nsg->weights = (fastf_t *)NULL;
@@ -1459,8 +1550,10 @@
unsigned char *cp;
size_t seg_no;
size_t i;
- vect_t tmp_vec;
+ /* must be double for import and export */
+ double tmp_vec[ELEMENTS_PER_VECT];
+
if (bu_debug&BU_DEBUG_MEM_CHECK) {
bu_log("Barrier check at start of sketch_export5():\n");
bu_mem_barriercheck();
@@ -1476,7 +1569,7 @@
BU_CK_EXTERNAL(ep);
/* tally up size of buffer needed */
- ep->ext_nbytes = 3 * (3 * SIZEOF_NETWORK_DOUBLE) /* V, u_vec, v_vec */
+ ep->ext_nbytes = 3 * (ELEMENTS_PER_VECT * SIZEOF_NETWORK_DOUBLE) /* V, u_vec, v_vec */
+ 2 * SIZEOF_NETWORK_LONG /* vert_count and count */
+ 2 * sketch_ip->vert_count * SIZEOF_NETWORK_DOUBLE /* 2D-vertices */
+ sketch_ip->curve.count * SIZEOF_NETWORK_LONG; /* reverse flags */
@@ -1526,14 +1619,16 @@
/* scale and export */
VSCALE(tmp_vec, sketch_ip->V, local2mm);
- htond(cp, (unsigned char *)tmp_vec, 3);
- cp += 3 * SIZEOF_NETWORK_DOUBLE;
+ htond(cp, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
+ cp += ELEMENTS_PER_VECT * SIZEOF_NETWORK_DOUBLE;
/* uvec and uvec are unit vectors, do not convert to/from mm */
- htond(cp, (unsigned char *)sketch_ip->u_vec, 3);
- cp += 3 * SIZEOF_NETWORK_DOUBLE;
- htond(cp, (unsigned char *)sketch_ip->v_vec, 3);
- cp += 3 * SIZEOF_NETWORK_DOUBLE;
+ VMOVE(tmp_vec, sketch_ip->u_vec); /* convert fastf_t to double */
+ htond(cp, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
+ cp += ELEMENTS_PER_VECT * SIZEOF_NETWORK_DOUBLE;
+ VMOVE(tmp_vec, sketch_ip->v_vec); /* convert fastf_t to double */
+ htond(cp, (unsigned char *)tmp_vec, ELEMENTS_PER_VECT);
+ cp += ELEMENTS_PER_VECT * SIZEOF_NETWORK_DOUBLE;
*(uint32_t *)cp = htonl(sketch_ip->vert_count);
cp += SIZEOF_NETWORK_LONG;
@@ -1542,10 +1637,11 @@
/* convert 2D points to mm */
for (i=0; i<sketch_ip->vert_count; i++) {
- point2d_t pt2d;
+ /* must be double for import and export */
+ double pt2d[ELEMENTS_PER_VECT2D];
- V2SCALE(pt2d, sketch_ip->verts[i], local2mm)
- htond(cp, (const unsigned char *)pt2d, 2);
+ V2SCALE(pt2d, sketch_ip->verts[i], local2mm);
+ htond(cp, (const unsigned char *)pt2d, ELEMENTS_PER_VECT2D);
cp += 2 * SIZEOF_NETWORK_DOUBLE;
}
@@ -1555,8 +1651,11 @@
struct nurb_seg *nseg;
struct bezier_seg *bseg;
uint32_t *lng;
- fastf_t tmp_fastf;
+ /* must be double for import and export */
+ double scan;
+ double *scanp;
+
/* write segment type ID, and segment parameters */
lng = (uint32_t *)sketch_ip->curve.segment[seg_no];
switch (*lng) {
@@ -1581,8 +1680,8 @@
cp += SIZEOF_NETWORK_LONG;
*(uint32_t *)cp = htonl(cseg->center_is_left);
cp += SIZEOF_NETWORK_LONG;
- tmp_fastf = cseg->radius * local2mm;
- htond(cp, (unsigned char *)&tmp_fastf, 1);
+ scan = cseg->radius * local2mm;
+ htond(cp, (unsigned char *)&scan, 1);
cp += SIZEOF_NETWORK_DOUBLE;
break;
case CURVE_NURB_MAGIC:
@@ -1595,7 +1694,13 @@
cp += SIZEOF_NETWORK_LONG;
*(uint32_t *)cp = htonl(nseg->k.k_size);
cp += SIZEOF_NETWORK_LONG;
+ scanp = (double *)bu_malloc(nseg->k.k_size * sizeof(double), "scanp");
+ /* convert fastf_t to double */
+ for (i=0; i<(size_t)nseg->k.k_size; i++) {
+ scanp[i] = nseg->k.knots[i];
+ }
htond(cp, (const unsigned char *)nseg->k.knots, nseg->k.k_size);
+ bu_free(scanp, "scanp");
cp += nseg->k.k_size * SIZEOF_NETWORK_DOUBLE;
*(uint32_t *)cp = htonl(nseg->c_size);
cp += SIZEOF_NETWORK_LONG;
@@ -1604,7 +1709,13 @@
cp += SIZEOF_NETWORK_LONG;
}
if (RT_NURB_IS_PT_RATIONAL(nseg->pt_type)) {
- htond(cp, (const unsigned char *)nseg->weights, nseg->c_size);
+ scanp = (double *)bu_malloc(nseg->c_size * sizeof(double), "scanp");
+ /* convert fastf_t to double */
+ for (i=0; i<(size_t)nseg->c_size; i++) {
+ scanp[i] = nseg->weights[i];
+ }
+ htond(cp, (const unsigned char *)scanp, nseg->c_size);
+ bu_free(scanp, "scanp");
cp += SIZEOF_NETWORK_DOUBLE * nseg->c_size;
}
break;
Modified: brlcad/trunk/src/librt/primitives/tgc/tgc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/tgc/tgc.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/tgc/tgc.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1635,12 +1635,14 @@
rt_tgc_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
struct rt_tgc_internal *tip;
- fastf_t vec[3*6];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*6];
+
if (dbip) RT_CK_DBI(dbip);
BU_CK_EXTERNAL(ep);
- BU_ASSERT_LONG(ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * 3*6);
+ BU_ASSERT_LONG(ep->ext_nbytes, ==, SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT*6);
RT_CK_DB_INTERNAL(ip);
ip->idb_major_type = DB5_MAJORTYPE_BRLCAD;
@@ -1652,16 +1654,16 @@
tip->magic = RT_TGC_INTERNAL_MAGIC;
/* Convert from database (network) to internal (host) format */
- ntohd((unsigned char *)vec, ep->ext_buf, 3*6);
+ ntohd((unsigned char *)vec, ep->ext_buf, ELEMENTS_PER_VECT*6);
/* Apply modeling transformations */
if (mat == NULL) mat = bn_mat_identity;
- MAT4X3PNT(tip->v, mat, &vec[0*3]);
- MAT4X3VEC(tip->h, mat, &vec[1*3]);
- MAT4X3VEC(tip->a, mat, &vec[2*3]);
- MAT4X3VEC(tip->b, mat, &vec[3*3]);
- MAT4X3VEC(tip->c, mat, &vec[4*3]);
- MAT4X3VEC(tip->d, mat, &vec[5*3]);
+ MAT4X3PNT(tip->v, mat, &vec[0*ELEMENTS_PER_VECT]);
+ MAT4X3VEC(tip->h, mat, &vec[1*ELEMENTS_PER_VECT]);
+ MAT4X3VEC(tip->a, mat, &vec[2*ELEMENTS_PER_VECT]);
+ MAT4X3VEC(tip->b, mat, &vec[3*ELEMENTS_PER_VECT]);
+ MAT4X3VEC(tip->c, mat, &vec[4*ELEMENTS_PER_VECT]);
+ MAT4X3VEC(tip->d, mat, &vec[5*ELEMENTS_PER_VECT]);
return 0; /* OK */
}
@@ -1674,8 +1676,10 @@
rt_tgc_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_tgc_internal *tip;
- fastf_t vec[3*6];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT*6];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -1684,19 +1688,19 @@
RT_TGC_CK_MAGIC(tip);
BU_CK_EXTERNAL(ep);
- ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 3*6;
+ ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT*6;
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "tgc external");
/* scale 'em into local buffer */
- VSCALE(&vec[0*3], tip->v, local2mm);
- VSCALE(&vec[1*3], tip->h, local2mm);
- VSCALE(&vec[2*3], tip->a, local2mm);
- VSCALE(&vec[3*3], tip->b, local2mm);
- VSCALE(&vec[4*3], tip->c, local2mm);
- VSCALE(&vec[5*3], tip->d, local2mm);
+ VSCALE(&vec[0*ELEMENTS_PER_VECT], tip->v, local2mm);
+ VSCALE(&vec[1*ELEMENTS_PER_VECT], tip->h, local2mm);
+ VSCALE(&vec[2*ELEMENTS_PER_VECT], tip->a, local2mm);
+ VSCALE(&vec[3*ELEMENTS_PER_VECT], tip->b, local2mm);
+ VSCALE(&vec[4*ELEMENTS_PER_VECT], tip->c, local2mm);
+ VSCALE(&vec[5*ELEMENTS_PER_VECT], tip->d, local2mm);
/* Convert from internal (host) to database (network) format */
- htond(ep->ext_buf, (unsigned char *)vec, 3*6);
+ htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT*6);
return 0;
}
@@ -1895,8 +1899,8 @@
{
struct rt_tgc_internal *tip;
register int i;
- fastf_t top[16*3];
- fastf_t bottom[16*3];
+ fastf_t top[16*ELEMENTS_PER_VECT];
+ fastf_t bottom[16*ELEMENTS_PER_VECT];
vect_t work; /* Vec addition work area */
BU_CK_LIST_HEAD(vhead);
Modified: brlcad/trunk/src/librt/primitives/tor/tor.c
===================================================================
--- brlcad/trunk/src/librt/primitives/tor/tor.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/tor/tor.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -1455,9 +1455,11 @@
int
rt_tor_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
- double vec[2*3+2];
struct rt_tor_internal *tip;
+ /* must be double for export */
+ double vec[2*3+2];
+
if (dbip) RT_CK_DBI(dbip);
RT_CK_DB_INTERNAL(ip);
@@ -1588,6 +1590,8 @@
rt_tor_import5(struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
{
struct rt_tor_internal *tip;
+
+ /* must be double for import and export */
struct rec {
double v[3];
double h[3];
@@ -1629,7 +1633,7 @@
tip->r_b = tip->r_a;
/* Calculate two mutually perpendicular vectors, perpendicular to N */
- bn_vec_ortho(tip->a, tip->h); /* a has unit length */
+ bn_vec_ortho(tip->a, tip->h); /* a has unit length */
VCROSS(tip->b, tip->h, tip->a); /* |A| = |H| = 1, so |B|=1 */
VSCALE(tip->a, tip->a, tip->r_a);
Modified: brlcad/trunk/src/librt/primitives/xxx/xxx.c
===================================================================
--- brlcad/trunk/src/librt/primitives/xxx/xxx.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/primitives/xxx/xxx.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -295,8 +295,10 @@
rt_xxx_import5(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip)
{
struct rt_xxx_internal *xxx_ip;
- fastf_t vv[ELEMENTS_PER_VECT*1];
+ /* must be double for import and export */
+ double vv[ELEMENTS_PER_VECT*1];
+
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
if (dbip) RT_CK_DBI(dbip);
@@ -338,8 +340,10 @@
rt_xxx_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
struct rt_xxx_internal *xxx_ip;
- fastf_t vec[ELEMENTS_PER_VECT];
+ /* must be double for import and export */
+ double vec[ELEMENTS_PER_VECT];
+
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_XXX) return -1;
xxx_ip = (struct rt_xxx_internal *)ip->idb_ptr;
@@ -358,7 +362,7 @@
VSCALE(vec, xxx_ip->v, local2mm);
/* Convert from internal (host) to database (network) format */
- htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT*1);
+ htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT);
return 0;
}
Modified: brlcad/trunk/src/librt/vlist.c
===================================================================
--- brlcad/trunk/src/librt/vlist.c 2012-10-30 01:52:12 UTC (rev 53400)
+++ brlcad/trunk/src/librt/vlist.c 2012-10-30 02:12:38 UTC (rev 53401)
@@ -385,7 +385,7 @@
* nelem[4], String[n+1], cmds[nelem*1], pts[3*nelem*8]
*/
namelen = strlen(name)+1;
- nbytes = namelen + 4 + nelem * (1+3*8) + 2;
+ nbytes = namelen + 4 + nelem * (1+ELEMENTS_PER_VECT*SIZEOF_NETWORK_DOUBLE) + 2;
/* FIXME: this is pretty much an abuse of vls. should be using
* vlb for variable-length byte buffers.
@@ -412,9 +412,14 @@
register int i;
register int nused = vp->nused;
register point_t *pt = vp->pt;
- for (i = 0; i < nused; i++, pt++) {
- htond(bp, (unsigned char *)pt, 3);
- bp += 3*8;
+
+ /* must be double for import and export */
+ double point[ELEMENTS_PER_POINT];
+
+ for (i = 0; i < nused; i++) {
+ VMOVE(point, pt[i]); /* convert fastf_t to double */
+ htond(bp, (unsigned char *)point, ELEMENTS_PER_VECT);
+ bp += ELEMENTS_PER_VECT*SIZEOF_NETWORK_DOUBLE;
}
}
}
@@ -432,8 +437,10 @@
size_t nelem;
size_t namelen;
size_t i;
- point_t point;
+ /* must be double for import and export */
+ double point[ELEMENTS_PER_POINT];
+
BU_CK_VLS(namevls);
nelem = ntohl(*(uint32_t *)buf);
@@ -449,8 +456,8 @@
int cmd;
cmd = *bp++;
- ntohd((unsigned char *)point, pp, 3);
- pp += 3*8;
+ ntohd((unsigned char *)point, pp, ELEMENTS_PER_POINT);
+ pp += ELEMENTS_PER_POINT*SIZEOF_NETWORK_DOUBLE;
BN_ADD_VLIST(&rt_g.rtg_vlfree, hp, point, cmd);
}
}
@@ -629,7 +636,7 @@
size_t ret;
int i, j;
int cc = 0;
- char inbuf[8] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
+ char inbuf[SIZEOF_NETWORK_DOUBLE] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
for (i = 0; i < up->narg; i++) {
switch (up->targ) {
@@ -637,12 +644,15 @@
arg[i] = getshort(fp);
break;
case TIEEE:
- ret = fread(inbuf, 8, 1, fp);
+ {
+ double scan;
+ ret = fread(inbuf, SIZEOF_NETWORK_DOUBLE, 1, fp);
if (ret != 1)
bu_log("WARNING: uplot read failure\n");
- ntohd((unsigned char *)&arg[i],
- (unsigned char *)inbuf, 1);
+ ntohd((unsigned char *)&scan, (unsigned char *)inbuf, 1);
+ arg[i] = scan; /* convert double to fastf_t */
break;
+ }
case TSTRING:
j = 0;
while (!feof(fp) &&
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|