BRL-CAD
ars.c
Go to the documentation of this file.
1 /* A R S . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1989-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 /** @file libwdb/ars.c
21  *
22  * libwdb support for writing an ARS.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <math.h>
29 #include "bio.h"
30 
31 #include "vmath.h"
32 #include "bn.h"
33 #include "rtgeom.h"
34 #include "raytrace.h"
35 #include "wdb.h"
36 
37 /*
38  * The input is an array of pointers to an array of fastf_t values.
39  * There is one pointer for each curve. It is anticipated that there
40  * will be pts_per_curve+1 elements per curve, the first point being
41  * repeated as the final point, although this is not checked here.
42  *
43  * Returns -
44  * 0 OK
45  * -1 Fail
46  */
47 int
48 mk_ars(struct rt_wdb *filep, const char *name, size_t ncurves, size_t pts_per_curve, fastf_t **curves)
49 {
50  struct rt_ars_internal *ars;
51 
52  BU_ALLOC(ars, struct rt_ars_internal);
53  ars->magic = RT_ARS_INTERNAL_MAGIC;
54  ars->ncurves = ncurves;
55  ars->pts_per_curve = pts_per_curve;
56  ars->curves = curves;
57 
58  return wdb_export(filep, name, (void *)ars, ID_ARS, mk_conv2mm);
59 }
60 
61 
62 /*
63  * Local Variables:
64  * mode: C
65  * tab-width: 8
66  * indent-tabs-mode: t
67  * c-file-style: "stroustrup"
68  * End:
69  * ex: shiftwidth=4 tabstop=8
70  */
#define ID_ARS
ARS.
Definition: raytrace.h:463
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
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
double fastf_t
Definition: defines.h:300
int mk_ars(struct rt_wdb *filep, const char *name, size_t ncurves, size_t pts_per_curve, fastf_t **curves)
Definition: ars.c:48
#define RT_ARS_INTERNAL_MAGIC
Definition: magic.h:83