本文整理汇总了C++中bu_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ bu_malloc函数的具体用法?C++ bu_malloc怎么用?C++ bu_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bu_malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_quad
void
do_quad(char *line)
{
int element_id;
int pt1, pt2, pt3, pt4;
fastf_t thick = 0.0;
int pos = 0;
bu_strlcpy(field, &line[8], sizeof(field));
element_id = atoi( field );
if ( debug )
bu_log( "do_quad: %s\n", line );
if ( !bot )
bot = element_id;
if ( faces == NULL )
{
faces = (int *)bu_malloc( GRID_BLOCK*3*sizeof( int ), "faces" );
thickness = (fastf_t *)bu_malloc( GRID_BLOCK*sizeof( fastf_t ), "thickness" );
facemode = (char *)bu_malloc( GRID_BLOCK*sizeof( char ), "facemode" );
face_size = GRID_BLOCK;
face_count = 0;
}
bu_strlcpy(field, &line[24], sizeof(field));
pt1 = atoi( field );
bu_strlcpy(field, &line[32], sizeof(field));
pt2 = atoi( field );
bu_strlcpy(field, &line[40], sizeof(field));
pt3 = atoi( field );
bu_strlcpy(field, &line[48], sizeof(field));
pt4 = atoi( field );
if ( mode == PLATE_MODE )
{
bu_strlcpy(field, &line[56], sizeof(field));
thick = atof( field ) * 25.4;
bu_strlcpy(field, &line[64], sizeof(field));
pos = atoi( field );
if ( pos == 0 ) /* use default */
pos = POS_FRONT;
if ( pos != POS_CENTER && pos != POS_FRONT )
{
bu_log( "do_quad: illegal postion parameter (%d), must be one or two\n", pos );
bu_log( "\telement %d, component %d, group %d\n", element_id, comp_id, group_id );
return;
}
}
Add_bot_face( pt1, pt2, pt3, thick, pos );
Add_bot_face( pt1, pt3, pt4, thick, pos );
}
开发者ID:cciechad,项目名称:brlcad,代码行数:60,代码来源:importFg4Section.c
示例2: icv_create
icv_image_t *
icv_create(int width, int height, ICV_COLOR_SPACE color_space)
{
icv_image_t *bif;
BU_ALLOC(bif, struct icv_image);
bif->width = width;
bif->height = height;
bif->color_space = color_space;
bif->alpha_channel = 0;
bif->magic = ICV_IMAGE_MAGIC;
switch (color_space) {
case ICV_COLOR_SPACE_RGB :
/* Add all the other three channel images here (eg. HSV, YCbCr etc.) */
bif->data = (double *) bu_malloc(bif->height*bif->width*3*sizeof(double), "Image Data");
bif->channels = 3;
break;
case ICV_COLOR_SPACE_GRAY :
bif->data = (double *) bu_malloc(bif->height*bif->width*1*sizeof(double), "Image Data");
bif->channels = 1;
break;
default :
bu_exit(1, "icv_create_image : Color Space Not Defined");
break;
}
return icv_zero(bif);
}
开发者ID:kanzure,项目名称:brlcad,代码行数:26,代码来源:fileformat.c
示例3: texture_perlin_init
void
texture_perlin_init(struct texture_perlin_s *P)
{
int i, j, k;
P->PV = (int *)bu_malloc(sizeof(int)*(2*B+2), "PV");
P->RV = (vect_t *)bu_malloc(sizeof(vect_t)*(2*B+2), "RV");
/* Generate Random Vectors */
for (i = 0; i < B; i++) {
P->RV[i][0] = (fastf_t)((PRAND % (2*B)) - B) / B;
P->RV[i][1] = (fastf_t)((PRAND % (2*B)) - B) / B;
P->RV[i][2] = (fastf_t)((PRAND % (2*B)) - B) / B;
VUNITIZE(P->RV[i]);
P->PV[i] = i;
}
/* Permute Indices into Vector List G */
for (i = 0; i < B; i++) {
k = P->PV[i];
P->PV[i] = P->PV[j = PRAND % B];
P->PV[j] = k;
}
for (i = 0; i < B + 2; i++) {
P->PV[B+i] = P->PV[i];
VMOVE(P->RV[B+i], P->RV[i]);
}
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:29,代码来源:texture_perlin.c
示例4: db_dup_full_path
void
db_dup_full_path(struct db_full_path *newp, const struct db_full_path *oldp)
{
unsigned int i = 0;
RT_CK_FULL_PATH(newp);
RT_CK_FULL_PATH(oldp);
newp->fp_maxlen = oldp->fp_maxlen;
newp->fp_len = oldp->fp_len;
if (oldp->fp_len <= 0) {
newp->fp_names = (struct directory **)0;
newp->fp_bool = (int *)0;
return;
}
newp->fp_names = (struct directory **)bu_malloc(newp->fp_maxlen * sizeof(struct directory *),
"db_full_path array (duplicate)");
memcpy((char *)newp->fp_names, (char *)oldp->fp_names, newp->fp_len * sizeof(struct directory *));
newp->fp_bool = (int *)bu_malloc(newp->fp_maxlen * sizeof(int),
"db_full_path bool array (duplicate)");
memcpy((char *)newp->fp_bool, (char *)oldp->fp_bool, newp->fp_len * sizeof(int));
newp->fp_mat = (matp_t *)bu_calloc(newp->fp_maxlen, sizeof(matp_t),
"db_full_path mat array (duplicate)");
for (i = 0; i < newp->fp_len; i++) {
if (oldp->fp_mat[i]) {
newp->fp_mat[i] = (matp_t)bu_calloc(1, sizeof(mat_t), "transformation matrix");
MAT_COPY(newp->fp_mat[i], oldp->fp_mat[i]);
}
}
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
示例5: nmg_construct_edge_g_cnurb
static struct edge_g_cnurb *
nmg_construct_edge_g_cnurb(const struct edge_g_cnurb *original, void **structArray)
{
struct edge_g_cnurb *ret;
NMG_GETSTRUCT(ret, edge_g_cnurb);
ret->l.magic = NMG_EDGE_G_CNURB_MAGIC;
BU_LIST_INIT(&ret->eu_hd2);
ret->order = original->order;
ret->k.magic = NMG_KNOT_VECTOR_MAGIC;
ret->k.k_size = original->k.k_size;
ret->k.knots = (fastf_t *)bu_malloc(ret->k.k_size * sizeof(fastf_t), "nmg_construct_edge_g_cnurb(): k.knots");
memcpy(ret->k.knots, original->k.knots, ret->k.k_size * sizeof(fastf_t));
ret->c_size = original->c_size;
ret->pt_type = original->pt_type;
ret->ctl_points = (fastf_t *)bu_malloc(ret->c_size * RT_NURB_EXTRACT_COORDS(ret->pt_type) * sizeof(fastf_t),
"nmg_construct_edge_g_cnurb(): ctl_points");
memcpy(ret->ctl_points, original->ctl_points, ret->c_size * RT_NURB_EXTRACT_COORDS(ret->pt_type) * sizeof(fastf_t));
ret->index = original->index;
structArray[ret->index] = ret;
return ret;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:29,代码来源:nmg_copy.c
示例6: create_brlcad_db
/*
* Write the nmg to a BRL-CAD style data base.
*/
int
create_brlcad_db(struct rt_wdb *fpout, struct model *m, char *reg_name, char *grp_name)
{
char *rname, *sname;
int empty_model;
struct shell *s;
struct nmgregion *r;
rname = (char *)bu_malloc(sizeof(reg_name) + 3, "rname"); /* Region name. */
sname = (char *)bu_malloc(sizeof(reg_name) + 3, "sname"); /* Solid name. */
snprintf(sname, sizeof(reg_name) + 2, "s.%s", reg_name);
empty_model = nmg_kill_zero_length_edgeuses(m);
if (empty_model) {
bu_log("Warning: skipping empty model.");
return 0;
}
nmg_rebound(m, &tol);
r = BU_LIST_FIRST(nmgregion, &m->r_hd);
s = BU_LIST_FIRST(shell, &r->s_hd);
mk_bot_from_nmg(fpout, sname, s); /* Make BOT object. */
snprintf(rname, sizeof(reg_name) + 2, "r.%s", reg_name);
mk_comb1(fpout, rname, sname, 1); /* Put object in a region. */
if (grp_name) {
mk_comb1(fpout, grp_name, rname, 1); /* Region in group. */
}
return 0;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:31,代码来源:jack-g.c
示例7: rt_nurb_new_snurb
/**
* Create a place holder for a nurb surface.
*/
struct face_g_snurb *
rt_nurb_new_snurb(int u_order, int v_order, int n_u, int n_v, int n_rows, int n_cols, int pt_type, struct resource *res)
{
register struct face_g_snurb * srf;
int pnum;
if (res) RT_CK_RESOURCE(res);
GET_SNURB(srf);
srf->order[0] = u_order;
srf->order[1] = v_order;
srf->dir = RT_NURB_SPLIT_ROW;
srf->u.k_size = n_u;
srf->v.k_size = n_v;
srf->s_size[0] = n_rows;
srf->s_size[1] = n_cols;
srf->pt_type = pt_type;
pnum = sizeof (fastf_t) * n_rows * n_cols * RT_NURB_EXTRACT_COORDS(pt_type);
srf->u.knots = (fastf_t *) bu_malloc (
n_u * sizeof (fastf_t), "rt_nurb_new_snurb: u kv knot values");
srf->v.knots = (fastf_t *) bu_malloc (
n_v * sizeof (fastf_t), "rt_nurb_new_snurb: v kv knot values");
srf->ctl_points = (fastf_t *) bu_malloc(
pnum, "rt_nurb_new_snurb: control mesh points");
return srf;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:33,代码来源:nurb_util.c
示例8: superell_surf_area_general
/* This attempts to find the surface area by subdividing the uv plane
* into squares, and finding the approximate surface area of each
* square.
*/
static fastf_t
superell_surf_area_general(const struct rt_superell_internal *sip, vect_t mags, fastf_t side_length)
{
fastf_t area = 0;
fastf_t u, v;
/* There are M_PI / side_length + 1 values because both ends have
to be stored */
int row_length = sizeof(point_t) * (M_PI / side_length + 1);
point_t *row1 = (point_t *)bu_malloc(row_length, "superell_surf_area_general");
point_t *row2 = (point_t *)bu_malloc(row_length, "superell_surf_area_general");
int idx = 0;
/* This function keeps a moving window of two rows at any time,
* and calculates the area of space between those two rows. It
* calculates the first row outside of the loop so that at each
* iteration it only has to calculate the second. Following
* standard definitions of u and v, u ranges from -pi to pi, and v
* ranges from -pi/2 to pi/2. Using an extra index variable allows
* the code to compute the index into the array very efficiently.
*/
for (v = -M_PI_2; v < M_PI_2; v += side_length, idx++) {
superell_xyz_from_uv(row1[idx], -M_PI, v, mags, sip);
}
/* This starts at -M_PI + side_length because the first row is
* computed outside the loop, which allows the loop to always
* calculate the second row of the pair.
*/
for (u = -M_PI + side_length; u < M_PI; u += side_length) {
idx = 0;
for (v = -M_PI_2; v < M_PI_2; v += side_length, idx++) {
superell_xyz_from_uv(row2[idx], u + side_length, v, mags, sip);
}
idx = 0;
/* This ends at -M_PI / 2 - side_length because if it kept
* going it would overflow the array, since it always looks at
* the square to the right of its current index.
*/
for (v = - M_PI_2; v < M_PI_2 - side_length; v += side_length, idx++) {
area +=
bn_dist_pt3_pt3(row1[idx], row1[idx + 1]) *
bn_dist_pt3_pt3(row1[idx], row2[idx]);
}
memcpy(row1, row2, row_length);
}
bu_free(row1, "superell_surf_area_general");
bu_free(row2, "superell_surf_area_general");
return area;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:63,代码来源:superell.c
示例9: wdb_add_operand
HIDDEN int
wdb_add_operand(Tcl_Interp *interp, struct bu_list *hp, char *name)
{
char *ptr_lparen;
char *ptr_rparen;
int name_len;
union tree *node;
struct tokens *tok;
BU_CK_LIST_HEAD(hp);
ptr_lparen = strchr(name, '(');
ptr_rparen = strchr(name, ')');
RT_GET_TREE( node, &rt_uniresource );
node->magic = RT_TREE_MAGIC;
node->tr_op = OP_DB_LEAF;
node->tr_l.tl_mat = (matp_t)NULL;
if (ptr_lparen || ptr_rparen) {
int tmp1, tmp2;
if (ptr_rparen)
tmp1 = ptr_rparen - name;
else
tmp1 = (-1);
if (ptr_lparen)
tmp2 = ptr_lparen - name;
else
tmp2 = (-1);
if (tmp2 == (-1) && tmp1 > 0)
name_len = tmp1;
else if (tmp1 == (-1) && tmp2 > 0)
name_len = tmp2;
else if (tmp1 > 0 && tmp2 > 0) {
if (tmp1 < tmp2)
name_len = tmp1;
else
name_len = tmp2;
}
else {
Tcl_AppendResult(interp, "Cannot determine length of operand name: ",
name, ", aborting\n", (char *)NULL);
return (0);
}
} else
name_len = strlen( name );
node->tr_l.tl_name = (char *)bu_malloc(name_len+1, "node name");
bu_strlcpy(node->tr_l.tl_name, name, name_len+1);
tok = (struct tokens *)bu_malloc(sizeof(struct tokens), "tok");
tok->type = WDB_TOK_TREE;
tok->tp = node;
BU_LIST_INSERT(hp, &tok->l);
return (name_len);
}
开发者ID:cciechad,项目名称:brlcad,代码行数:57,代码来源:wdb_comb_std.c
示例10: render_surfel_init
void render_surfel_init(render_t *render, uint32_t num, render_surfel_pt_t *list) {
render_surfel_t *d;
render->work = render_surfel_work;
render->free = render_surfel_free;
render->data = (render_surfel_t *)bu_malloc(sizeof(render_surfel_t), "render data");
d = (render_surfel_t *)render->data;
d->list = (render_surfel_pt_t *)bu_malloc(num * sizeof(render_surfel_pt_t), "data list");
d->num = num;
d->list = list;
}
开发者ID:cciechad,项目名称:brlcad,代码行数:11,代码来源:surfel.c
示例11: rt_nurb_c_xsplit
/**
* rt_nurb_c_xsplit()
*
* Split a NURB curve by inserting a multiple knot and return the
* result of the two curves.
*
* Algorithm:
*
* Insert a multiple knot of the curve order. A parameter is give for
* the knot value for which the curve will be split.
*/
struct edge_g_cnurb *
rt_nurb_c_xsplit(struct edge_g_cnurb *crv, fastf_t param)
{
struct knot_vector new_kv;
struct oslo_mat * oslo;
int k_index;
struct edge_g_cnurb * crv1, * crv2;
int coords;
NMG_CK_CNURB(crv);
coords = RT_NURB_EXTRACT_COORDS(crv->pt_type),
k_index = crv->order;
rt_nurb_kvmult(&new_kv, &crv->k, crv->order, param, (struct resource *)NULL);
oslo = (struct oslo_mat *)
rt_nurb_calc_oslo(crv->order, &crv->k, &new_kv, (struct resource *)NULL);
GET_CNURB(crv1);
crv1->order = crv->order;
rt_nurb_kvextract(&crv1->k, &new_kv, 0, k_index + crv->order, (struct resource *)NULL);
crv1->pt_type = crv->pt_type;
crv1->c_size = crv1->k.k_size - crv1->order;
crv1->ctl_points = (fastf_t *)
bu_malloc(sizeof(fastf_t) * crv1->c_size *
RT_NURB_EXTRACT_COORDS(crv1->pt_type),
"rt_nurb_c_xsplit: crv1 control points");
GET_CNURB(crv2);
crv2->order = crv->order;
rt_nurb_kvextract(&crv2->k, &new_kv, k_index, new_kv.k_size, (struct resource *)NULL);
crv2->pt_type = crv->pt_type;
crv2->c_size = crv2->k.k_size - crv2->order;
crv2->ctl_points = (fastf_t *)
bu_malloc(sizeof(fastf_t) * crv2->c_size *
RT_NURB_EXTRACT_COORDS(crv2->pt_type),
"rt_nurb_c_xsplit: crv2 row mesh control points");
rt_nurb_map_oslo(oslo, crv->ctl_points, crv1->ctl_points,
coords, coords, 0, k_index, crv->pt_type);
rt_nurb_map_oslo(oslo, crv->ctl_points, crv2->ctl_points,
coords, coords, k_index, new_kv.k_size - crv2->order,
crv2->pt_type);
rt_nurb_free_oslo(oslo, (struct resource *)NULL);
bu_free((char *) new_kv.knots, "rt_nurb_c_xsplit: new_kv.knots");
BU_LIST_APPEND(&crv1->l, &crv2->l);
return crv1;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:64,代码来源:nurb_xsplit.c
示例12: rt_nurb_solve
/**
* Solve must be passed two matrices that are of the form of pointer
* to double arrays. mat_1 is the n by n matrix that is to be
* decomposed and mat_2 is the matrix that contains the left side of
* the equation. The variable solution which is double is also to be
* created by the user and consisting of n elements of which the
* solution set is passed back.
*
* Arguments mat_1 and mat_2 are modified by this call.
* The solution is written into the solution[] array.
*/
void
rt_nurb_solve(fastf_t *mat_1, fastf_t *mat_2, fastf_t *solution, int dim, int coords)
/* A and b array of the system Ax= b*/
/* dimension of the matrix */
/* Number of coordinates for mat_2 and solution */
{
register int i, k;
fastf_t *y;
fastf_t * b;
fastf_t * s;
y = (fastf_t *) bu_malloc(sizeof (fastf_t) * dim,
"rt_nurb_solve: y");/* Create temp array */
b = (fastf_t *) bu_malloc(sizeof (fastf_t) * dim,
"rt_nurb_solve: b");/* Create temp array */
s = (fastf_t *) bu_malloc(sizeof (fastf_t) * dim,
"rt_nurb_solve: s");/* Create temp array */
rt_nurb_doolittle (mat_1, mat_2, dim, coords);/* Create LU decomposition */
for (k =0; k < coords; k++) {
fastf_t * ptr;
ptr = mat_2 + k;
for (i = 0; i < dim; i++) {
b[i] = *ptr;
ptr += coords;
}
/* Solve the system Ly =b */
rt_nurb_forw_solve (mat_1, b, y, dim);
/* Solve the system Ux = y */
rt_nurb_back_solve (mat_1, y, s, dim);
ptr = solution + k;
for (i=0; i < dim; i++) {
*ptr = s[i];
ptr += coords;
}
}
bu_free ((char *)y, "rt_nurb_solve: y"); /* Free up storage */
bu_free ((char *)b, "rt_nurb_solve: b"); /* Free up storage */
bu_free ((char *)s, "rt_nurb_solve: s"); /* Free up storage */
}
开发者ID:kanzure,项目名称:brlcad,代码行数:63,代码来源:nurb_solve.c
示例13: texture_image_init
void texture_image_init(texture_t *texture, short w, short h, unsigned char *image) {
texture_image_t *td;
texture->data = bu_malloc(sizeof(texture_image_t), "texture data");
texture->free = texture_image_free;
texture->work = (texture_work_t *)texture_image_work;
td = (texture_image_t *)texture->data;
td->w = w;
td->h = h;
td->image = (unsigned char *)bu_malloc(3*w*h, "texture image");
memcpy(td->image, image, 3*w*h);
}
开发者ID:cciechad,项目名称:brlcad,代码行数:13,代码来源:texture_image.c
示例14: pop_init
/**
* P O P _ I N I T --- initialize a population of a given size
*/
void
pop_init (struct population *p, int size)
{
p->parent = bu_malloc(sizeof(struct individual) * size, "parent");
p->child = bu_malloc(sizeof(struct individual) * size, "child");
p->size = size;
p->db_c = p->db_p = DBI_NULL;
p->name = bu_malloc(sizeof(char *) * size, "names");
#define SEED 33
/* init in main() bn_rand_init(randomer, SEED);*/
bn_rand_init(randomer, SEED);
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:16,代码来源:population.c
示例15: bn_gauss_init
/* bn_gauss_init Initialize a random number struct for gaussian
* numbers.
*
* @par Entry
* setseed Seed to use.
* method method to use to generate numbers (not used)
*
* @par Exit
* Returns a pointer toa bn_msr_guass structure.
* returns 0 on error.
*
* @par Calls
* bu_malloc
*
* @par Uses
* None.
*
* @par Method @code
* malloc up a structure
* get table space
* set seed and pointer.
* if setseed != 0 then seed = setseed
@endcode
*/
struct bn_gauss *
bn_gauss_init(long int setseed, int method)
{
struct bn_gauss *p;
p = (struct bn_gauss *) bu_malloc(sizeof(struct bn_gauss), "bn_msr_guass");
p->msr_gausses=(double *) bu_malloc(BN_MSR_MAXTBL*sizeof(double), "msr guass table");
p->msr_gauss_doubles=(double *) bu_malloc(BN_MSR_MAXTBL*sizeof(double), "msr guass doubles");
p->msr_gauss_seed = 1;
p->msr_gauss_ptr = 0;
p->msr_gauss_dbl_ptr = 0;
if (setseed&0x7fffffff) p->msr_gauss_seed=setseed&0x7fffffff;
p->magic = BN_GAUSS_MAGIC;
return(p);
}
开发者ID:cciechad,项目名称:brlcad,代码行数:39,代码来源:msr.c
示例16: bu_vls_extend
/**
* b u _ v l s _ e x t e n d
*
* Ensure that the provided VLS has at least 'extra' characters of
* space available.
*/
void
bu_vls_extend(register struct bu_vls *vp, unsigned int extra)
{
BU_CK_VLS(vp);
/* increment by at least 40 bytes */
if ( extra < _VLS_ALLOC_MIN )
extra = _VLS_ALLOC_MIN;
/* first time allocation */
if ( vp->vls_max <= 0 || vp->vls_str == (char *)0 ) {
vp->vls_max = extra;
vp->vls_str = (char *)bu_malloc( (size_t)vp->vls_max, bu_vls_message );
vp->vls_len = 0;
vp->vls_offset = 0;
*vp->vls_str = '\0';
return;
}
/* need more space? */
if ( vp->vls_offset + vp->vls_len + extra >= (size_t)vp->vls_max ) {
vp->vls_max += extra;
if ( vp->vls_max < _VLS_ALLOC_STEP ) {
/* extend to at least this much */
vp->vls_max = _VLS_ALLOC_STEP;
}
vp->vls_str = (char *)bu_realloc( vp->vls_str, (size_t)vp->vls_max, bu_vls_message );
}
}
开发者ID:cciechad,项目名称:brlcad,代码行数:35,代码来源:vls.c
示例17: db_ls
int
db_ls(const struct db_i *dbip, int flags, struct directory ***dpv)
{
int i;
int objcount = 0;
struct directory *dp;
RT_CK_DBI(dbip);
for (i = 0; i < RT_DBNHASH; i++) {
for (dp = dbip->dbi_Head[i]; dp != RT_DIR_NULL; dp = dp->d_forw) {
objcount += dp_eval_flags(dp, flags);
}
}
if (objcount > 0) {
(*dpv) = (struct directory **)bu_malloc(sizeof(struct directory *) * (objcount + 1), "directory pointer array");
objcount = 0;
for (i = 0; i < RT_DBNHASH; i++) {
for (dp = dbip->dbi_Head[i]; dp != RT_DIR_NULL; dp = dp->d_forw) {
if (dp_eval_flags(dp,flags)) {
(*dpv)[objcount] = dp;
objcount++;
}
}
}
(*dpv)[objcount] = NULL;
}
return objcount;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:29,代码来源:ls.c
示例18: rt_nurb_kvmerge
/**
* rt_nurb_kvmerge()
*
* Merge two knot vectors together and return the new resulting knot
* vector.
*/
void
rt_nurb_kvmerge(struct knot_vector *new_knots, const struct knot_vector *kv1, const struct knot_vector *kv2, struct resource *res)
{
int kv1_ptr = 0;
int kv2_ptr = 0;
int new_ptr;
if (res) RT_CK_RESOURCE(res);
new_knots->k_size = kv1->k_size + kv2->k_size;
new_knots->knots = (fastf_t *) bu_malloc(
sizeof (fastf_t) * new_knots->k_size,
"rt_nurb_kvmerge: new knot values");
for (new_ptr = 0; new_ptr < new_knots->k_size; new_ptr++) {
if (kv1_ptr >= kv1->k_size)
new_knots->knots[new_ptr] = kv2->knots[kv2_ptr++];
else if (kv2_ptr >= kv2->k_size)
new_knots->knots[new_ptr] = kv1->knots[kv1_ptr++];
else if (kv1->knots[kv1_ptr] < kv2->knots[kv2_ptr])
new_knots->knots[new_ptr] = kv1->knots[kv1_ptr++];
else
new_knots->knots[new_ptr] = kv2->knots[kv2_ptr++];
}
}
开发者ID:kanzure,项目名称:brlcad,代码行数:32,代码来源:nurb_knot.c
示例19: db_add_node_to_full_path
void
db_add_node_to_full_path(struct db_full_path *pp, struct directory *dp)
{
RT_CK_FULL_PATH(pp);
if (pp->fp_maxlen <= 0) {
pp->fp_maxlen = 32;
pp->fp_names = (struct directory **)bu_malloc(
pp->fp_maxlen * sizeof(struct directory *),
"db_full_path array");
pp->fp_bool = (int *)bu_calloc(pp->fp_maxlen, sizeof(int),
"db_full_path bool array");
pp->fp_mat = (matp_t *)bu_calloc(pp->fp_maxlen, sizeof(matp_t),
"db_full_path matrices array");
} else if (pp->fp_len >= pp->fp_maxlen) {
pp->fp_maxlen *= 4;
pp->fp_names = (struct directory **)bu_realloc(
(char *)pp->fp_names,
pp->fp_maxlen * sizeof(struct directory *),
"enlarged db_full_path array");
pp->fp_bool = (int *)bu_realloc(
(char *)pp->fp_bool,
pp->fp_maxlen * sizeof(int),
"enlarged db_full_path bool array");
pp->fp_mat = (matp_t *)bu_realloc(
(char *)pp->fp_mat,
pp->fp_maxlen * sizeof(matp_t),
"enlarged db_full_path matrices array");
}
pp->fp_names[pp->fp_len++] = dp;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
示例20: db_argv_to_path
int
db_argv_to_path(struct db_full_path *pp, struct db_i *dbip, int argc, const char *const *argv)
{
struct directory *dp;
int ret = 0;
int i;
RT_CK_DBI(dbip);
/* Make a path structure just big enough */
pp->magic = DB_FULL_PATH_MAGIC;
pp->fp_maxlen = pp->fp_len = argc;
pp->fp_names = (struct directory **)bu_malloc(
pp->fp_maxlen * sizeof(struct directory *),
"db_argv_to_path path array");
pp->fp_bool = (int *)bu_calloc(pp->fp_maxlen, sizeof(int),
"db_argv_to_path bool array");
pp->fp_mat = (matp_t *)bu_calloc(pp->fp_maxlen, sizeof(matp_t),
"db_string_to_path mat array");
for (i = 0; i<argc; i++) {
if ((dp = db_lookup(dbip, argv[i], LOOKUP_NOISY)) == RT_DIR_NULL) {
bu_log("db_argv_to_path() failed on element %d='%s'\n",
i, argv[i]);
ret = -1; /* FAILED */
/* Fall through, storing null dp in this location */
}
pp->fp_names[i] = dp;
}
return ret;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:31,代码来源:db_fullpath.c
注:本文中的bu_malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论