BRL-CAD
arbn.c
Go to the documentation of this file.
1 /* A R B N . 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/arbn.c
21  *
22  * libwdb support for writing an ARBN.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <math.h>
29 #include "bio.h"
30 
31 #include "bu/malloc.h"
32 #include "vmath.h"
33 #include "bn.h"
34 #include "rtgeom.h"
35 #include "raytrace.h"
36 #include "wdb.h"
37 
38 
39 int
40 mk_arbn(struct rt_wdb *filep, const char *name, size_t neqn, const plane_t *eqn)
41 {
42  struct rt_arbn_internal *arbn;
43  plane_t *equations = NULL;
44  size_t i;
45 
46  if (neqn <= 0)
47  return -1;
48 
49  equations = (plane_t *)bu_malloc(neqn*sizeof(plane_t), "equations");
50  for (i=0; i<neqn; i++) {
51  HMOVE(equations[i], eqn[i]);
52  }
53 
54  BU_ALLOC(arbn, struct rt_arbn_internal);
55  arbn->magic = RT_ARBN_INTERNAL_MAGIC;
56  arbn->neqn = neqn;
57  arbn->eqn = equations;
58 
59  return wdb_export(filep, name, (void *)arbn, ID_ARBN, mk_conv2mm);
60 }
61 
62 
63 /*
64  * Local Variables:
65  * mode: C
66  * tab-width: 8
67  * indent-tabs-mode: t
68  * c-file-style: "stroustrup"
69  * End:
70  * ex: shiftwidth=4 tabstop=8
71  */
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
void * bu_malloc(size_t siz, const char *str)
Definition: malloc.c:314
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
int mk_arbn(struct rt_wdb *filep, const char *name, size_t neqn, const plane_t *eqn)
Definition: arbn.c:40
#define RT_ARBN_INTERNAL_MAGIC
Definition: magic.h:81
#define ID_ARBN
ARB with N faces.
Definition: raytrace.h:472