BRL-CAD
nurb.c
Go to the documentation of this file.
1 /* N U R B . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1987-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 
21 /** @file libwdb/nurb.c
22  *
23  * Library for writing NURB objects into
24  * MGED databases from arbitrary procedures.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <math.h>
31 #include <string.h>
32 #include "bio.h"
33 
34 #include "db.h"
35 #include "vmath.h"
36 #include "bn.h"
37 #include "nurb.h"
38 #include "raytrace.h"
39 #include "rtgeom.h"
40 #include "wdb.h"
41 
42 
43 int
44 mk_bspline(struct rt_wdb *wdbp, const char *name, struct face_g_snurb **surfs)
45 {
46  struct rt_nurb_internal *ni;
47 
48  BU_ALLOC(ni, struct rt_nurb_internal);
49  ni->magic = RT_NURB_INTERNAL_MAGIC;
50  ni->srfs = surfs;
51 
52  for (ni->nsrf = 0; ni->srfs[ni->nsrf] != NULL; ni->nsrf++)
53  ; /* NIL */
54 
55  return wdb_export(wdbp, name, (void *)ni, ID_BSPLINE, mk_conv2mm);
56 }
57 
58 
59 /*
60  * Local Variables:
61  * mode: C
62  * tab-width: 8
63  * indent-tabs-mode: t
64  * c-file-style: "stroustrup"
65  * End:
66  * ex: shiftwidth=4 tabstop=8
67  */
#define RT_NURB_INTERNAL_MAGIC
Definition: magic.h:101
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
#define ID_BSPLINE
B-spline object.
Definition: raytrace.h:467
int mk_bspline(struct rt_wdb *wdbp, const char *name, struct face_g_snurb **surfs)
Definition: nurb.c:44
int wdb_export(struct rt_wdb *wdbp, const char *name, void *gp, int id, double local2mm)
Definition: wdb.c:265
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37