BRL-CAD
nmg.c
Go to the documentation of this file.
1 /* N M G . 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 
21 /** @file libwdb/nmg.c
22  *
23  * libwdb support for writing an NMG to disk.
24  *
25  */
26 
27 #include "common.h"
28 
29 #include <math.h>
30 #include "bio.h"
31 
32 #include "vmath.h"
33 #include "bn.h"
34 #include "rtgeom.h"
35 #include "nmg.h"
36 #include "raytrace.h"
37 #include "wdb.h"
38 
39 
40 int
41 mk_nmg(struct rt_wdb *filep, const char *name, struct model *m)
42 {
43  NMG_CK_MODEL(m);
44 
45  /* FIXME: wdb_export is documented as always free'ing the entity
46  * passed to it. that means this routine needs to make a copy of
47  * the geometry.
48  */
49 
50  return wdb_export(filep, name, (void *)m, ID_NMG, mk_conv2mm);
51 }
52 
53 
54 int
55 mk_bot_from_nmg(struct rt_wdb *ofp, const char *name, struct shell *s)
56 {
57  struct rt_bot_internal *botp;
58 
59  botp = nmg_bot(s, &ofp->wdb_tol);
60 
61  /* FIXME: wdb_export is documented as always free'ing the entity
62  * passed to it. that means this routine needs to make a copy of
63  * the geometry.
64  */
65 
66  return wdb_export(ofp, name, (void *)botp, ID_BOT, mk_conv2mm);
67 }
68 
69 
70 /*
71  * Local Variables:
72  * mode: C
73  * tab-width: 8
74  * indent-tabs-mode: t
75  * c-file-style: "stroustrup"
76  * End:
77  * ex: shiftwidth=4 tabstop=8
78  */
struct rt_bot_internal * nmg_bot(struct shell *s, const struct bn_tol *tol)
Definition: nmg_misc.c:10826
if lu s
Definition: nmg_mod.c:3860
Definition: clone.c:90
#define ID_BOT
Bag o' triangles.
Definition: raytrace.h:488
Header file for the BRL-CAD common definitions.
int mk_nmg(struct rt_wdb *filep, const char *name, struct model *m)
Definition: nmg.c:41
int wdb_export(struct rt_wdb *wdbp, const char *name, void *gp, int id, double local2mm)
Definition: wdb.c:265
#define ID_NMG
n-Manifold Geometry solid
Definition: raytrace.h:469
int mk_bot_from_nmg(struct rt_wdb *ofp, const char *name, struct shell *s)
Definition: nmg.c:55
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
struct bn_tol wdb_tol
Definition: raytrace.h:1269