当前位置: 首页>>代码示例>>C++>>正文


C++ VSCALE函数代码示例

本文整理汇总了C++中VSCALE函数的典型用法代码示例。如果您正苦于以下问题:C++ VSCALE函数的具体用法?C++ VSCALE怎么用?C++ VSCALE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VSCALE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VADD2

void writeRectangularBox
(
    rt_wdb* wdbp,
    Form&   form,
    bool    translate
) {
    char    name[NAMELEN + 1];
    point_t min, max;

    if (translate) {
      VADD2(min, form.data.pt[0], form.tr_vec);
      VADD2(max, form.data.pt[1], form.tr_vec);
    } else {
      VMOVE(min, form.data.pt[0]);
      VMOVE(max, form.data.pt[1]);
    }

    VSCALE(min, min, IntavalUnitInMm);
    VSCALE(max, max, IntavalUnitInMm);

    sprintf(name, "s%lu.rpp", (long unsigned int)++rpp_counter);
    mk_rpp(wdbp, name, min, max);
    addToRegion(form.compnr, name);

    if (form.s_compnr >= 1000)
	excludeFromRegion(form.s_compnr, name);
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:27,代码来源:write_brl.cpp

示例2: move_walk

static int
move_walk(ClientData UNUSED(clientData), Tcl_Interp *interp, int UNUSED(objc), Tcl_Obj *const *objv)
{
    struct isst_s *isst;
    Togl *togl;
    vect_t vec;
    int flag;

    if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
	return TCL_ERROR;

    isst = (struct isst_s *) Togl_GetClientData(togl);

    if (Tcl_GetIntFromObj(interp, objv[2], &flag) != TCL_OK)
	return TCL_ERROR;

    if (flag >= 0) {
	VSUB2(vec, isst->camera.focus, isst->camera.pos);
	VSCALE(vec, vec, 0.1 * isst->tie->radius);
	VADD2(isst->camera.pos, isst->camera.pos, vec);
	VADD2(isst->camera.focus, isst->camera.focus, vec);
    } else {
	VSUB2(vec, isst->camera.pos, isst->camera.focus);
	VSCALE(vec, vec, 0.1 * isst->tie->radius);
	VADD2(isst->camera.pos, isst->camera.pos, vec);
	VADD2(isst->camera.focus, isst->camera.focus, vec);
    }
    isst->dirty = 1;
    return TCL_OK;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:30,代码来源:isst_tcltk.c

示例3: gridRotate

/*
  void gridRotate(fastf_t azim, fastf_t elev, fastf_t roll,
  fastf_t *des_H, fastf_t *des_V)

  Creates the unit vectors H and V which are the horizontal
  and vertical components of the grid in target coordinates.
  The vectors are found from the azimuth and elevation of the
  viewing angle according to a simplification of the rotation
  matrix from grid coordinates to target coordinates.
  To see that the vectors are, indeed, unit vectors, recall
  the trigonometric relation:

  sin(A)^2 + cos(A)^2  =  1 .

*/
void
gridRotate(fastf_t azim, fastf_t elev, fastf_t roll, fastf_t *des_H, fastf_t *des_V)
{
    fastf_t sn_azm = sin(azim);
    fastf_t cs_azm = cos(azim);
    fastf_t sn_elv = sin(elev);

    des_H[0] = -sn_azm;
    des_H[1] =  cs_azm;
    des_H[2] =  0.0;
    des_V[0] = -sn_elv*cs_azm;
    des_V[1] = -sn_elv*sn_azm;
    des_V[2] =  cos(elev);

    if (!ZERO(roll)) {
	fastf_t tmp_V[3], tmp_H[3], prime_V[3];
	fastf_t sn_roll = sin(roll);
	fastf_t cs_roll = cos(roll);

	VSCALE(tmp_V, des_V, cs_roll);
	VSCALE(tmp_H, des_H, sn_roll);
	VADD2(prime_V, tmp_V, tmp_H);
	VSCALE(tmp_V, des_V, -sn_roll);
	VSCALE(tmp_H, des_H, cs_roll);
	VADD2(des_H, tmp_V, tmp_H);
	VMOVE(des_V, prime_V);
    }
    return;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:44,代码来源:gridrotate.c

示例4: ged_model2view_lu

int
ged_model2view_lu(struct ged *gedp, int argc, const char *argv[])
{
    fastf_t f;
    point_t view_pt;
    double model_pt[3]; /* intentionally double for scan */
    static const char *usage = "x y z";

    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
    GED_CHECK_VIEW(gedp, GED_ERROR);
    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);

    /* initialize result */
    bu_vls_trunc(gedp->ged_result_str, 0);

    if (argc != 4)
	goto bad;

    if (sscanf(argv[1], "%lf", &model_pt[X]) != 1 ||
	sscanf(argv[2], "%lf", &model_pt[Y]) != 1 ||
	sscanf(argv[3], "%lf", &model_pt[Z]) != 1)
	goto bad;

    VSCALE(model_pt, model_pt, gedp->ged_wdbp->dbip->dbi_local2base);
    MAT4X3PNT(view_pt, gedp->ged_gvp->gv_model2view, model_pt);
    f = gedp->ged_gvp->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local;
    VSCALE(view_pt, view_pt, f);
    bn_encode_vect(gedp->ged_result_str, view_pt);

    return GED_OK;

bad:
    bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
    return GED_ERROR;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:35,代码来源:model2view_lu.c

示例5: rt_superell_export4

int
rt_superell_export4(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
    struct rt_superell_internal *tip;
    union record *rec;

    if (dbip) RT_CK_DBI(dbip);

    RT_CK_DB_INTERNAL(ip);
    if (ip->idb_type != ID_SUPERELL) return -1;
    tip = (struct rt_superell_internal *)ip->idb_ptr;
    RT_SUPERELL_CK_MAGIC(tip);

    BU_CK_EXTERNAL(ep);
    ep->ext_nbytes = sizeof(union record);
    ep->ext_buf = (uint8_t *)bu_calloc(1, ep->ext_nbytes, "superell external");
    rec = (union record *)ep->ext_buf;

    rec->s.s_id = ID_SOLID;
    rec->s.s_type = SUPERELL;

    /* NOTE: This also converts to dbfloat_t */
    VSCALE(&rec->s.s_values[0], tip->v, local2mm);
    VSCALE(&rec->s.s_values[3], tip->a, local2mm);
    VSCALE(&rec->s.s_values[6], tip->b, local2mm);
    VSCALE(&rec->s.s_values[9], tip->c, local2mm);

    printf("SUPERELL: %g %g\n", tip->n, tip->e);

    rec->s.s_values[12] = tip->n;
    rec->s.s_values[13] = tip->e;

    return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:34,代码来源:superell.c

示例6: rt_superell_export5

/**
 * The external format is:
 * V point
 * A vector
 * B vector
 * C vector
 */
int
rt_superell_export5(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
{
    struct rt_superell_internal *eip;

    /* must be double for import and export */
    double vec[ELEMENTS_PER_VECT*4 + 2];

    if (dbip) RT_CK_DBI(dbip);

    RT_CK_DB_INTERNAL(ip);
    if (ip->idb_type != ID_SUPERELL) return -1;
    eip = (struct rt_superell_internal *)ip->idb_ptr;
    RT_SUPERELL_CK_MAGIC(eip);

    BU_CK_EXTERNAL(ep);
    ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * (ELEMENTS_PER_VECT*4 + 2);
    ep->ext_buf = (uint8_t *)bu_malloc(ep->ext_nbytes, "superell 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);

    vec[4*ELEMENTS_PER_VECT] = eip->n;
    vec[4*ELEMENTS_PER_VECT + 1] = eip->e;

    /* Convert from internal (host) to database (network) format */
    bu_cv_htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT*4 + 2);

    return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:40,代码来源:superell.c

示例7: _ged_do_tra

int
_ged_do_tra(struct ged *gedp,
            char coord,
            vect_t tvec,
            int (*func)())
{
    point_t delta;
    point_t work;
    point_t vc, nvc;

    if (func != (int (*)())0)
        return (*func)(gedp, coord, tvec);

    switch (coord) {
    case 'm':
        VSCALE(delta, tvec, -gedp->ged_wdbp->dbip->dbi_base2local);
        MAT_DELTAS_GET_NEG(vc, gedp->ged_gvp->gv_center);
        break;
    case 'v':
    default:
        VSCALE(tvec, tvec, -2.0*gedp->ged_wdbp->dbip->dbi_base2local*gedp->ged_gvp->gv_isize);
        MAT4X3PNT(work, gedp->ged_gvp->gv_view2model, tvec);
        MAT_DELTAS_GET_NEG(vc, gedp->ged_gvp->gv_center);
        VSUB2(delta, work, vc);
        break;
    }

    VSUB2(nvc, vc, delta);
    MAT_DELTAS_VEC_NEG(gedp->ged_gvp->gv_center, nvc);
    ged_view_update(gedp->ged_gvp);

    return GED_OK;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:33,代码来源:vutil.c

示例8: _ged_scale_rpc

int
_ged_scale_rpc(struct ged *gedp, struct rt_rpc_internal *rpc, const char *attribute, fastf_t sf, int rflag)
{
    RT_RPC_CK_MAGIC(rpc);

    switch (attribute[0]) {
	case 'b':
	case 'B':
	    if (!rflag)
		sf /= MAGNITUDE(rpc->rpc_B);

	    VSCALE(rpc->rpc_B, rpc->rpc_B, sf);
	    break;
	case 'h':
	case 'H':
	    if (!rflag)
		sf /= MAGNITUDE(rpc->rpc_H);

	    VSCALE(rpc->rpc_H, rpc->rpc_H, sf);
	    break;
	case 'r':
	case 'R':
	    if (rflag)
		rpc->rpc_r *= sf;
	    else
		rpc->rpc_r = sf;

	    break;
	default:
	    bu_vls_printf(gedp->ged_result_str, "bad rpc attribute - %s", attribute);
	    return GED_ERROR;
    }

    return GED_OK;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:35,代码来源:scale_rpc.c

示例9: top

void
top(fastf_t *vec1, fastf_t *vec2, fastf_t *t)
{
    fastf_t	tooch, mag;
    vect_t	del, tvec;
    int i, j;

    tooch = t[2] * .25;
    del[0] = vec2[0] - vec1[0];
    del[1] = 0.0;
    del[2] = vec2[2] - vec1[2];
    mag = MAGNITUDE( del );
    VSCALE(tvec, del, tooch/mag);
    VSUB2(&sol.s_values[0], vec1, tvec);
    VADD2(del, del, tvec);
    VADD2(&sol.s_values[3], del, tvec);
    tvec[0] = tvec[2] = 0.0;
    tvec[1] = t[1] - t[0];
    VCROSS(del, tvec, &sol.s_values[3]);
    mag = MAGNITUDE( del );
    if (del[2] < 0)
	mag *= -1.0;
    VSCALE(&sol.s_values[9], del, t[2]/mag);
    VADD2(&sol.s_values[6], &sol.s_values[3], &sol.s_values[9]);
    VMOVE(&sol.s_values[12], tvec);

    for (i=3; i<=9; i+=3) {
	j = i + 12;
	VADD2(&sol.s_values[j], &sol.s_values[i], tvec);
    }
}
开发者ID:cciechad,项目名称:brlcad,代码行数:31,代码来源:track.c

示例10: main

int
main(int argc, char **argv)
{
    int c;
    fastf_t time, viewsize;

    fastf_t eyept[3], viewrot[16], angle[3], quat[4];
    int anim_mat2ypr(fastf_t *, fastf_t *), anim_mat2zyx(const fastf_t *, fastf_t *), anim_mat2quat(fastf_t *, const fastf_t *);

    if (!get_args(argc, argv))
	fprintf(stderr, "anim_keyread: get_args error");

    while (!feof(stdin)) {
	/* read one keyframe */
	scanf("%lf", &time);
	scanf("%lf", &viewsize);
	scanf("%lf %lf %lf", eyept, eyept+1, eyept+2);
	/* read in transposed matrix */
	scanf("%lf %lf %lf %lf", viewrot+0, viewrot+4, viewrot+8, viewrot+12);
	scanf("%lf %lf %lf %lf", viewrot+1, viewrot+5, viewrot+9, viewrot+13);
	scanf("%lf %lf %lf %lf", viewrot+2, viewrot+6, viewrot+10, viewrot+14);
	scanf("%lf %lf %lf %lf", viewrot+3, viewrot+7, viewrot+11, viewrot+15);

	if (feof(stdin)) break;

	printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t", time, viewsize,
	       eyept[0], eyept[1], eyept[2]);


	if (mode==YPR) {
	    anim_v_unpermute(viewrot);
	    c = anim_mat2ypr(angle, viewrot);
	    if (c==ERROR1)
		fprintf(stderr, "Warning: yaw and roll arbitrarily defined at time = %f.\n", time);
	    else if (c==ERROR2)
		fprintf(stderr, "Keyread: can't interpret matrix at time = %f.\n", time);
	    if (units == DEGREES)
		VSCALE(angle, angle, RTOD);
	    printf("%.10g\t%.10g\t%.10g\n", angle[0], angle[1], angle[2]);
	}
	else if (mode==XYZ) {
	    c = anim_mat2zyx(angle, viewrot);
	    if (c==ERROR1)
		fprintf(stderr, "Warning: x and z rotations arbitrarily defined at time = %f.\n", time);
	    else if (c==ERROR2)
		fprintf(stderr, "Keyread: can't interpret matrix at time = %f\n.", time);
	    if (units == DEGREES)
		VSCALE(angle, angle, RTOD);
	    printf("%.10g\t%.10g\t%.10g\n", angle[X], angle[Y], angle[Z]);
	}
	else if (mode==QUATERNION) {
	    anim_mat2quat(quat, viewrot);
	    printf("%.10g\t%.10g\t%.10g\t%.10g\n", quat[X], quat[Y], quat[Z], quat[W]);
	}
    }
    return( 0 );
}
开发者ID:cciechad,项目名称:brlcad,代码行数:57,代码来源:anim_keyread.c

示例11: rt_arbn_centroid

void
rt_arbn_centroid(point_t *cent, const struct rt_db_internal *ip)
{
    struct poly_face *faces;
    struct rt_arbn_internal *aip = (struct rt_arbn_internal *)ip->idb_ptr;
    size_t i;
    point_t arbit_point = VINIT_ZERO;
    fastf_t volume = 0.0;

    *cent[0] = 0.0;
    *cent[1] = 0.0;
    *cent[2] = 0.0;

    if (cent == NULL)
	return;

    /* allocate array of face structs */
    faces = (struct poly_face *)bu_calloc(aip->neqn, sizeof(struct poly_face), "rt_arbn_centroid: faces");
    for (i = 0; i < aip->neqn; i++) {
	/* allocate array of pt structs, max number of verts per faces = (# of faces) - 1 */
	faces[i].pts = (point_t *)bu_calloc(aip->neqn - 1, sizeof(point_t), "rt_arbn_centroid: pts");
    }
    rt_arbn_faces_area(faces, aip);
    for (i = 0; i < aip->neqn; i++) {
	bn_polygon_centroid(&faces[i].cent, faces[i].npts, (const point_t *) faces[i].pts);
	VADD2(arbit_point, arbit_point, faces[i].cent);

    }
    VSCALE(arbit_point, arbit_point, (1/aip->neqn));

    for (i = 0; i < aip->neqn; i++) {
	vect_t tmp = VINIT_ZERO;
	/* calculate volume */
	VSCALE(tmp, faces[i].plane_eqn, faces[i].area);
	faces[i].vol_pyramid = (VDOT(faces[i].pts[0], tmp)/3);
	volume += faces[i].vol_pyramid;
	/*Vector from arbit_point to centroid of face, results in h of pyramid */
	VSUB2(faces[i].cent_pyramid, faces[i].cent, arbit_point);
	/*centroid of pyramid is 1/4 up from the bottom */
	VSCALE(faces[i].cent_pyramid, faces[i].cent_pyramid, 0.75f);
	/* now cent_pyramid is back in the polyhedron */
	VADD2(faces[i].cent_pyramid, faces[i].cent_pyramid, arbit_point);
	/* weight centroid of pyramid by pyramid's volume */
	VSCALE(faces[i].cent_pyramid, faces[i].cent_pyramid, faces[i].vol_pyramid);
	/* add cent_pyramid to the centroid of the polyhedron */
	VADD2(*cent, *cent, faces[i].cent_pyramid);
    }
    /* reverse the weighting */
    VSCALE(*cent, *cent, (1/volume));
    for (i = 0; i < aip->neqn; i++) {
	bu_free((char *)faces[i].pts, "rt_arbn_centroid: pts");
    }
    bu_free((char *)faces, "rt_arbn_centroid: faces");
}
开发者ID:kanzure,项目名称:brlcad,代码行数:54,代码来源:arbn.c

示例12: get_cbar

HIDDEN void
get_cbar(void)
{
    int eid, pid;
    int g1, g2;
    point_t pt1, pt2;
    fastf_t radius;
    vect_t height;
    struct pbar *pb;
    char cbar_name[NAMESIZE+1];

    eid = atoi( curr_rec[1] );

    pid = atoi( curr_rec[2] );
    if ( !pid )
    {
	if ( bar_def_pid )
	    pid = bar_def_pid;
	else
	    pid = eid;
    }

    g1 = atoi( curr_rec[3] );

    g2 = atoi( curr_rec[4] );

    get_grid( g1, pt1 );
    get_grid( g2, pt2 );

    for ( BU_LIST_FOR( pb, pbar, &pbar_head.l ) )
    {
	if ( pb->pid == pid )
	    break;
    }

    if ( BU_LIST_IS_HEAD( &pb->l, &pbar_head.l ) )
    {
	log_line( "Non-existent PID referenced in CBAR" );
	return;
    }

    VSCALE( pt1, pt1, conv[units] );
    VSCALE( pt2, pt2, conv[units] );

    radius = sqrt( pb->area/bn_pi );
    radius = radius * conv[units];

    VSUB2( height, pt2, pt1 );

    sprintf( cbar_name, "cbar.%d", eid );
    mk_rcc( fpout, cbar_name, pt1, height, radius );

    mk_addmember( cbar_name, &pb->head.l, NULL, WMOP_UNION );
}
开发者ID:cciechad,项目名称:brlcad,代码行数:54,代码来源:nastran-g.c

示例13: rr_refract

/*
 * R E F R A C T
 *
 * Compute the refracted ray 'v_2' from the incident ray 'v_1' with
 * the refractive indices 'ri_2' and 'ri_1' respectively.
 * Using Schnell's Law:
 *
 * theta_1 = angle of v_1 with surface normal
 * theta_2 = angle of v_2 with reversed surface normal
 * ri_1 * sin(theta_1) = ri_2 * sin(theta_2)
 *
 * sin(theta_2) = ri_1/ri_2 * sin(theta_1)
 *
 * The above condition is undefined for ri_1/ri_2 * sin(theta_1)
 * being greater than 1, and this represents the condition for total
 * reflection, the 'critical angle' is the angle theta_1 for which
 * ri_1/ri_2 * sin(theta_1) equals 1.
 *
 * Returns TRUE if refracted, FALSE if reflected.
 *
 * Note:  output (v_2) can be same storage as an input.
 */
HIDDEN int
rr_refract(vect_t v_1, vect_t norml, double ri_1, double ri_2, vect_t v_2)
{
    vect_t w, u;
    fastf_t beta;

    if (NEAR_ZERO(ri_1, 0.0001) || NEAR_ZERO(ri_2, 0.0001)) {
	bu_log("rr_refract:ri1=%g, ri2=%g\n", ri_1, ri_2);
	beta = 1;
    } else {
	beta = ri_1/ri_2;		/* temp */
	if (beta > 10000) {
	    bu_log("rr_refract:  beta=%g\n", beta);
	    beta = 1000;
	}
    }
    VSCALE(w, v_1, beta);
    VCROSS(u, w, norml);

    /*
     *	|w X norml| = |w||norml| * sin(theta_1)
     *	        |u| = ri_1/ri_2 * sin(theta_1) = sin(theta_2)
     */
    if ((beta = VDOT(u, u)) > 1.0) {
	/* Past critical angle, total reflection.
	 * Calculate reflected (bounced) incident ray.
	 */
	if (R_DEBUG&RDEBUG_REFRACT) bu_log("rr_refract: reflected.  ri1=%g ri2=%g beta=%g\n",
					   ri_1, ri_2, beta);
	VREVERSE(u, v_1);
	beta = 2 * VDOT(u, norml);
	VSCALE(w, norml, beta);
	VSUB2(v_2, w, u);
	return 0;		/* reflected */
    } else {
	/*
	 * 1 - beta = 1 - sin(theta_2)^^2
	 *	    = cos(theta_2)^^2.
	 * beta = -1.0 * cos(theta_2) - Dot(w, norml).
	 */
	if (R_DEBUG&RDEBUG_REFRACT) bu_log("rr_refract: refracted.  ri1=%g ri2=%g beta=%g\n",
					   ri_1, ri_2, beta);
	beta = -sqrt(1.0 - beta) - VDOT(w, norml);
	VSCALE(u, norml, beta);
	VADD2(v_2, w, u);
	return 1;		/* refracted */
    }
    /* NOTREACHED */
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:71,代码来源:refract.c

示例14: render_flos_work

void
render_flos_work(render_t *render, struct tie_s *tie, struct tie_ray_s *ray, vect_t *pixel) {
    struct tie_id_s id, tid;
    vect_t vec;
    fastf_t angle;
    struct render_flos_s *rd;

    rd = (struct render_flos_s *)render->data;

    if (tie_work(tie, ray, &id, render_hit, NULL) != NULL) {
	VSET(*pixel, 0.0, 0.5, 0.0);
    } else
	return;

    VSUB2(vec, ray->pos, id.pos);
    VUNITIZE(vec);
    angle = VDOT(vec, id.norm);

    /* Determine if direct line of sight to fragment */
    VMOVE(ray->pos, rd->frag_pos);
    VSUB2(ray->dir, id.pos, rd->frag_pos);
    VUNITIZE(ray->dir);

    if (tie_work(tie, ray, &tid, render_hit, NULL)) {
	if (fabs (id.pos[0] - tid.pos[0]) < TIE_PREC
	    && fabs (id.pos[1] - tid.pos[1]) < TIE_PREC
	    && fabs (id.pos[2] - tid.pos[2]) < TIE_PREC)
	{
	    VSET(*pixel, 1.0, 0.0, 0.0);
	}
    }

    VSCALE(*pixel, *pixel, (0.5+angle*0.5));
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:34,代码来源:flos.c

示例15: rt_xxx_export5

/**
 * Export an XXX from internal form to external format.  Note that
 * this means converting all integers to Big-Endian format and
 * floating point data to IEEE double.
 *
 * Apply the transformation to mm units as well.
 */
int
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;

    /* 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;
    RT_XXX_CK_MAGIC(xxx_ip);
    if (dbip) RT_CK_DBI(dbip);

    BU_CK_EXTERNAL(ep);
    ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT;
    ep->ext_buf = (void *)bu_calloc(1, ep->ext_nbytes, "xxx external");

    /* 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.
     */
    VSCALE(vec, xxx_ip->v, local2mm);

    /* Convert from internal (host) to database (network) format */
    bu_cv_htond(ep->ext_buf, (unsigned char *)vec, ELEMENTS_PER_VECT);

    return 0;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:36,代码来源:xxx.c


注:本文中的VSCALE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。