BRL-CAD
brep.cpp
Go to the documentation of this file.
1 /* B R E P . C P P
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 brep.cpp
22  *
23  * Library for writing BREP 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 "bu/log.h"
35 #include "db.h"
36 #include "vmath.h"
37 #include "bn.h"
38 #include "wdb.h"
39 
40 
41 int
42 mk_brep(struct rt_wdb* file, const char* name, ON_Brep* brep)
43 {
44  struct rt_brep_internal* bi;
45 
46  BU_ASSERT(brep != NULL);
47  BU_ALLOC(bi, struct rt_brep_internal);
48  bi->magic = RT_BREP_INTERNAL_MAGIC;
49  bi->brep = new ON_Brep(*brep); /* copy the users' brep */
50  if (!bi->brep) {
51  bu_log("mk_brep: Unable to copy BREP\n");
52  }
53  return wdb_export(file, name, (void *)bi, ID_BREP, mk_conv2mm);
54 }
55 
56 
57 // Local Variables:
58 // tab-width: 8
59 // mode: C++
60 // c-basic-offset: 4
61 // indent-tabs-mode: t
62 // c-file-style: "stroustrup"
63 // End:
64 // ex: shiftwidth=4 tabstop=8
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
#define BU_ASSERT(_equation)
Definition: defines.h:216
#define RT_BREP_INTERNAL_MAGIC
Definition: magic.h:86
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
int mk_brep(struct rt_wdb *file, const char *name, ON_Brep *brep)
Definition: brep.cpp:42
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
struct _on_brep_placeholder ON_Brep
#define ID_BREP
B-rep object.
Definition: raytrace.h:509