Example #1
0
/**
 * rt_nurb_kvmult()
 *
 * Construct a new knot vector which is the same as the passed in knot
 * vector except it has multiplicity of num of val. It checks to see
 * if val already is a multiple knot.
 */
void
rt_nurb_kvmult(struct knot_vector *new_kv, const struct knot_vector *kv, int num, register fastf_t val, struct resource *res)
{
    int n;
    register int i;
    struct knot_vector check;

    if (res) RT_CK_RESOURCE(res);

    n = rt_nurb_kvcheck(val, kv);

    check.k_size = num - n;
    if (check.k_size <= 0) {
	bu_log("rt_nurb_kvmult(new_kv=%p, kv=%p, num=%d, val=%g)\n",
	       (void *)new_kv, (void *)kv, num, val);
	rt_nurb_pr_kv(kv);
	bu_bomb("rt_nurb_kvmult\n");
    }

    check.knots = (fastf_t *) bu_malloc(sizeof(fastf_t) * check.k_size,
					"rt_nurb_kvmult: check knots");

    for (i = 0; i < num - n; i++)
	check.knots[i] = val;

    rt_nurb_kvmerge(new_kv, &check, kv, res);

    /* free up old knot values */
    bu_free((char *)check.knots, "rt_nurb_kvmult:check knots");
}
Example #2
0
void
make_face(fastf_t *a, fastf_t *b, fastf_t *c, fastf_t *d, int order)
{
    register struct face_g_snurb	*srf;
    int	interior_pts = 0;
    int	cur_kv;
    int	i;
    int	ki;
    register fastf_t	*fp;

    srf = rt_nurb_new_snurb( order, order,
                             2*order+interior_pts, 2*order+interior_pts,	/* # knots */
                             2+interior_pts, 2+interior_pts,
                             RT_NURB_MAKE_PT_TYPE(3, RT_NURB_PT_XYZ, RT_NURB_PT_NONRAT ),
                             &rt_uniresource );

    /* Build both knot vectors */
    cur_kv = 0;		/* current knot value */
    ki = 0;			/* current knot index */
    for ( i=0; i<order; i++, ki++ )  {
        srf->u.knots[ki] = srf->v.knots[ki] = cur_kv;
    }
    cur_kv++;
    for ( i=0; i<interior_pts; i++, ki++ )  {
        srf->u.knots[ki] = srf->v.knots[ki] = cur_kv++;
    }
    for ( i=0; i<order; i++, ki++ )  {
        srf->u.knots[ki] = srf->v.knots[ki] = cur_kv;
    }

    rt_nurb_pr_kv( &srf->u );

    /*
     *  The control mesh is stored in row-major order.
     */
    /* Head from point A to B */
#if 0
    row = 0;
    for ( col=0; col < srf->s_curve[1]; col++ )  {
        fp = &srf->ctl_points[col*srf->s_curve[1]+row];
        VSET( fp
    }
#endif

#define SSET(_col, _row, _val)	{ \
	fp = &srf->ctl_points[((_col*srf->s_size[1])+_row)*3]; \
	VMOVE( fp, _val ); }

    /* VADD2SCALE( mid, a, b, 0.5 ); */
    SSET( 0, 0, a );
    SSET( 0, 1, b );
    SSET( 1, 0, d );
    SSET( 1, 1, c );

    si.srfs[si.nsrf++] = srf;
}
void
rt_nurb_s_print(char *c, const struct face_g_snurb *srf)
{

    bu_log("%s\n", c);

    bu_log("order %d %d\n", srf->order[0], srf->order[1]);

    bu_log("u knot vector \n");

    rt_nurb_pr_kv(&srf->u);

    bu_log("v knot vector \n");

    rt_nurb_pr_kv(&srf->v);

    rt_nurb_pr_mesh(srf);

}
Example #4
0
void
make_face(struct rt_nurb_internal *s, fastf_t *a, fastf_t *b, fastf_t *c, fastf_t *d, int order)
{
    int i;
    int ki;
    int cur_kv;
    int interior_pts = 2;
    fastf_t *fp = NULL;
    struct face_g_snurb *srf = NULL;

    srf = rt_nurb_new_snurb(order, order,
			    2*order+interior_pts, 2*order+interior_pts,	/* # knots */
			    2+interior_pts, 2+interior_pts,
			    RT_NURB_MAKE_PT_TYPE(3, RT_NURB_PT_XYZ, RT_NURB_PT_NONRAT),
			    &rt_uniresource);

    /* Build both knot vectors */

    /* current knot value */
    cur_kv = 0;
    /* current knot index */
    ki = 0;

    for (i=0; i<order; i++, ki++) {
	srf->u.knots[ki] = srf->v.knots[ki] = cur_kv;
    }
    cur_kv++;
    for (i=0; i<interior_pts; i++, ki++) {
	srf->u.knots[ki] = srf->v.knots[ki] = cur_kv++;
    }
    for (i=0; i<order; i++, ki++) {
	srf->u.knots[ki] = srf->v.knots[ki] = cur_kv;
    }

    rt_nurb_pr_kv(&srf->u);

    /*
     * The control mesh is stored in row-major order.
     */

    SSET(fp, srf, 0, 0, a);
    SSET(fp, srf, 0, 1, b);
    SSET(fp, srf, 1, 0, d);
    SSET(fp, srf, 1, 1, c);

    s->srfs[s->nsrf++] = srf;
}