BRL-CAD
ars_brep.cpp
Go to the documentation of this file.
1 /* A R S _ B R E P . C P P
2  * BRL-CAD
3  *
4  * Copyright (c) 2012-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 ars_brep.cpp
21  *
22  * Convert an ARS (Arbitrary faceted solid) to b-rep form
23  *
24  */
25 
26 #include "common.h"
27 
28 #include "raytrace.h"
29 #include "rtgeom.h"
30 #include "nmg.h"
31 #include "brep.h"
32 
33 extern "C" {
34  extern void rt_ars_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol);
35  extern void rt_nmg_brep(ON_Brep **bi, struct rt_db_internal *ip, const struct bn_tol *tol);
36 }
37 
38 
39 extern "C" void
40 rt_ars_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol)
41 {
42  struct rt_db_internal *tmp_internal;
43  struct rt_tess_tol ttmptol;
44 
45  BU_ALLOC(tmp_internal, struct rt_db_internal);
46  RT_DB_INTERNAL_INIT(tmp_internal);
47 
48  ttmptol.abs = 0;
49  ttmptol.rel = 0.01;
50  ttmptol.norm = 0;
51 
52  const struct rt_tess_tol *ttol = &ttmptol;
53  struct model *arsm = nmg_mm();
54  struct nmgregion *arsr;
55 
56  tmp_internal->idb_ptr = (void *)ip->idb_ptr;
57  rt_ars_tess(&arsr, arsm, tmp_internal, ttol, tol);
58  tmp_internal->idb_ptr = (void *)arsm;
59  rt_nmg_brep(b, tmp_internal, tol);
60 
61  FREE_MODEL(arsm);
62  bu_free(tmp_internal, "free temporary rt_db_internal");
63 }
64 
65 
66 // Local Variables:
67 // tab-width: 8
68 // mode: C++
69 // c-basic-offset: 4
70 // indent-tabs-mode: t
71 // c-file-style: "stroustrup"
72 // End:
73 // ex: shiftwidth=4 tabstop=8
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
Support for uniform tolerances.
Definition: tol.h:71
void rt_nmg_brep(ON_Brep **bi, struct rt_db_internal *ip, const struct bn_tol *tol)
struct model * nmg_mm(void)
Definition: nmg_mk.c:235
void * idb_ptr
Definition: raytrace.h:195
void rt_ars_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol)
Definition: ars_brep.cpp:40
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
void rt_ars_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
Definition: ars.c:481