BRL-CAD
arb8_brep.cpp
Go to the documentation of this file.
1 /* A R B 8 _ B R E P . C P P
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-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 arb8_brep.cpp
21  *
22  * Convert an Arbitrary Regular Polyhedron with as many as 8 vertices
23  * to b-rep form
24  *
25  */
26 
27 #include "common.h"
28 
29 #include "raytrace.h"
30 #include "rtgeom.h"
31 #include "nmg.h"
32 #include "brep.h"
33 
34 extern "C" {
35  extern void rt_arb_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol);
36  extern void rt_nmg_brep(ON_Brep **bi, struct rt_db_internal *ip, const struct bn_tol *tol);
37 }
38 
39 
40 extern "C" void
41 rt_arb_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol)
42 {
43  struct rt_db_internal *tmp_internal;
44  struct rt_tess_tol ttmptol;
45 
46  BU_ALLOC(tmp_internal, struct rt_db_internal);
47  RT_DB_INTERNAL_INIT(tmp_internal);
48 
49  ttmptol.abs = 0;
50  ttmptol.rel = 0.01;
51  ttmptol.norm = 0;
52 
53  const struct rt_tess_tol *ttol = &ttmptol;
54  struct model *arbm = nmg_mm();
55  struct nmgregion *arbr;
56 
57  tmp_internal->idb_ptr = (void *)ip->idb_ptr;
58  rt_arb_tess(&arbr, arbm, tmp_internal, ttol, tol);
59  tmp_internal->idb_ptr = (void *)arbm;
60  rt_nmg_brep(b, tmp_internal, tol);
61 
62  FREE_MODEL(arbm);
63  bu_free(tmp_internal, "free temporary rt_db_internal");
64 }
65 
66 
67 // Local Variables:
68 // tab-width: 8
69 // mode: C++
70 // c-basic-offset: 4
71 // indent-tabs-mode: t
72 // c-file-style: "stroustrup"
73 // End:
74 // ex: shiftwidth=4 tabstop=8
void rt_arb_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol)
Definition: arb8_brep.cpp:41
Header file for the BRL-CAD common definitions.
double rel
rel dist tol
Definition: raytrace.h:181
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
#define RT_DB_INTERNAL_INIT(_p)
Definition: raytrace.h:199
void rt_arb_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
Definition: arb8.c:1475
void rt_nmg_brep(ON_Brep **bi, struct rt_db_internal *ip, const struct bn_tol *tol)
Support for uniform tolerances.
Definition: tol.h:71
struct model * nmg_mm(void)
Definition: nmg_mk.c:235
void * idb_ptr
Definition: raytrace.h:195
double abs
absolute dist tol
Definition: raytrace.h:180
double norm
normal tol
Definition: raytrace.h:182
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328