struct edge_g_cnurb *
rt_nurb_c_diff(const struct edge_g_cnurb *crv)
{

    struct edge_g_cnurb *ncrv;
    fastf_t * opts, *npts;
    int i;

    NMG_CK_CNURB(crv);

    ncrv = (struct edge_g_cnurb *) rt_nurb_new_cnurb(crv->order - 1,
						     crv->k.k_size - 2, crv->c_size - 1,
						     crv->pt_type);

    opts = (fastf_t *) crv->ctl_points;
    npts = (fastf_t *) ncrv->ctl_points;

    rt_nurb_mesh_diff(crv->order, opts, npts, crv->k.knots,
		      RT_NURB_EXTRACT_COORDS(crv->pt_type),
		      RT_NURB_EXTRACT_COORDS(ncrv->pt_type),
		      crv->c_size, crv->pt_type);

    for (i = 1; i < crv->k.k_size - 1; i++)
	ncrv->k.knots[ i - 1] = crv->k.knots[i];

    return ncrv;

}
Example #2
0
struct edge_g_cnurb *
rt_nurb_c_refine(const struct edge_g_cnurb *crv, struct knot_vector *kv)
{
    struct oslo_mat * oslo;
    struct edge_g_cnurb * new_crv;
    int i, coords;

    NMG_CK_CNURB(crv);

    coords = RT_NURB_EXTRACT_COORDS(crv->pt_type);

    new_crv = (struct edge_g_cnurb *) rt_nurb_new_cnurb(
	crv->order, kv->k_size, kv->k_size - crv->order,
	crv->pt_type);

    oslo = (struct oslo_mat *) rt_nurb_calc_oslo(
	crv->order, &crv->k, kv, (struct resource *)NULL);

    rt_nurb_map_oslo(oslo, crv->ctl_points,
		     new_crv->ctl_points,
		     coords, coords, 0,
		     kv->k_size - new_crv->order,
		     new_crv->pt_type);

    new_crv->k.k_size = kv->k_size;

    for (i = 0; i < kv->k_size; i++)
	new_crv->k.knots[i] = kv->knots[i];

    rt_nurb_free_oslo(oslo, (struct resource *)NULL);

    return new_crv;
}
Example #3
0
struct edge_g_cnurb *
rt_nurb_crv_copy(const struct edge_g_cnurb *crv)
{
    register struct edge_g_cnurb * n;
    int i;

    NMG_CK_CNURB(crv);

    n = (struct edge_g_cnurb *) rt_nurb_new_cnurb(crv->order,
						  crv->k.k_size, crv->c_size, crv->pt_type);

    for (i = 0; i < crv->k.k_size; i++)
	n->k.knots[i] = crv->k.knots[i];

    for (i = 0; i < crv->c_size *
	     RT_NURB_EXTRACT_COORDS(crv->pt_type); i++)
	n->ctl_points[i] = crv->ctl_points[i];

    return (struct edge_g_cnurb *) n;
}
Example #4
0
struct edge_g_cnurb *
Get_cnurb_curve(int curve_de, int *linear)
{
    int i;
    int curve;
    struct edge_g_cnurb *crv;

    *linear = 0;

    curve = (curve_de - 1)/2;
    if (curve >= dirarraylen) {
	bu_log("Get_cnurb_curve: DE=%d is too large, dirarraylen = %d\n", curve_de, dirarraylen);
	return (struct edge_g_cnurb *)NULL;
    }

    switch (dir[curve]->type) {
	case 110: {
	    /* line */
	    int pt_type;
	    int type;
	    point_t pt1;
	    point_t start_pt, end_pt;

	    Readrec(dir[curve]->param);
	    Readint(&type, "");
	    if (type != dir[curve]->type) {
		bu_log("Error in Get_cnurb_curve, looking for curve type %d, found %d\n" ,
		       dir[curve]->type, type);
		return (struct edge_g_cnurb *)NULL;

	    }
	    /* Read first point */
	    for (i = 0; i < 3; i++)
		Readcnv(&pt1[i], "");
	    MAT4X3PNT(start_pt, *dir[curve]->rot, pt1);

	    /* Read second point */
	    for (i = 0; i < 3; i++)
		Readcnv(&pt1[i], "");
	    MAT4X3PNT(end_pt, *dir[curve]->rot, pt1);

	    /* pt_type for rational UVW coords */
	    pt_type = RT_NURB_MAKE_PT_TYPE(3, 3, 1);

	    /* make a linear edge_g_cnurb (order=2) */
	    crv = rt_nurb_new_cnurb(2, 4, 2, pt_type);

	    /* insert control mesh */
	    VMOVE(crv->ctl_points, start_pt);
	    VMOVE(&crv->ctl_points[3], end_pt);

	    /* insert knot values */
	    crv->k.knots[0] = 0.0;
	    crv->k.knots[1] = 0.0;
	    crv->k.knots[2] = 1.0;
	    crv->k.knots[3] = 1.0;

	    *linear = 1;

	    return crv;
	}
	case 126:	/* B-spline */
	    crv = Get_cnurb(curve);
	    if (crv->order < 3)
		*linear = 1;
	    return crv;
	default:
	    bu_log("Not yet handling curves of type: %s\n", iges_type(dir[curve]->type));
	    break;
    }

    return (struct edge_g_cnurb *)NULL;
}