BRL-CAD
nurb_copy.c
Go to the documentation of this file.
1 /* N U R B _ C O P Y . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1991-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup nurb */
21 /** @{ */
22 /** @file primitives/bspline/nurb_copy.c
23  *
24  * Duplicate the nurb surface.
25  *
26  */
27 /** @} */
28 
29 #include "common.h"
30 
31 #include "bio.h"
32 
33 #include "vmath.h"
34 #include "nmg.h"
35 #include "raytrace.h"
36 #include "nurb.h"
37 
38 struct face_g_snurb *
39 rt_nurb_scopy(const struct face_g_snurb *srf, struct resource *res)
40 {
41  register struct face_g_snurb * n;
42  int i;
43 
44  NMG_CK_SNURB(srf);
45 
46  n = (struct face_g_snurb *) rt_nurb_new_snurb(srf->order[0], srf->order[1],
47  srf->u.k_size, srf->v.k_size,
48  srf->s_size[0], srf->s_size[1],
49  srf->pt_type, res);
50 
51  for (i = 0; i < srf->u.k_size; i++)
52  n->u.knots[i] = srf->u.knots[i];
53 
54  for (i = 0; i < srf->v.k_size; i++)
55  n->v.knots[i] = srf->v.knots[i];
56 
57  for (i = 0; i < srf->s_size[0] * srf->s_size[1] *
58  RT_NURB_EXTRACT_COORDS(srf->pt_type); i++)
59  {
60 
61  n->ctl_points[i] = srf->ctl_points[i];
62  }
63 
64  return (struct face_g_snurb *) n;
65 }
66 
67 
68 struct edge_g_cnurb *
69 rt_nurb_crv_copy(const struct edge_g_cnurb *crv)
70 {
71  register struct edge_g_cnurb * n;
72  int i;
73 
74  NMG_CK_CNURB(crv);
75 
76  n = (struct edge_g_cnurb *) rt_nurb_new_cnurb(crv->order,
77  crv->k.k_size, crv->c_size, crv->pt_type);
78 
79  for (i = 0; i < crv->k.k_size; i++)
80  n->k.knots[i] = crv->k.knots[i];
81 
82  for (i = 0; i < crv->c_size *
83  RT_NURB_EXTRACT_COORDS(crv->pt_type); i++)
84  n->ctl_points[i] = crv->ctl_points[i];
85 
86  return (struct edge_g_cnurb *) n;
87 }
88 
89 
90 /*
91  * Local Variables:
92  * mode: C
93  * tab-width: 8
94  * indent-tabs-mode: t
95  * c-file-style: "stroustrup"
96  * End:
97  * ex: shiftwidth=4 tabstop=8
98  */
struct edge_g_cnurb * rt_nurb_new_cnurb(int order, int n_knots, int n_pts, int pt_type)
Definition: nurb_util.c:77
struct face_g_snurb * rt_nurb_scopy(const struct face_g_snurb *srf, struct resource *res)
Definition: nurb_copy.c:39
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)
Definition: nurb_util.c:42
Header file for the BRL-CAD common definitions.
struct edge_g_cnurb * rt_nurb_crv_copy(const struct edge_g_cnurb *crv)
Definition: nurb_copy.c:69