BRL-CAD
bot_oriented_bbox.cpp
Go to the documentation of this file.
1 /* B O T _ O R I E N T E D _ B B O X . 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 bot_oriented_bbox.cpp
21  *
22  *
23  */
24 
25 #include "common.h"
26 
27 #include "raytrace.h"
28 #include "rtgeom.h"
29 
30 #include "gdiam.hpp"
31 
32 extern "C" int
33 rt_bot_oriented_bbox(struct rt_arb_internal *bbox, struct rt_db_internal *ip, const fastf_t UNUSED(tol))
34 {
35 
36  struct rt_bot_internal *bot_ip;
37  gdiam_point *pnt_arr = NULL;
38  gdiam_bbox bb;
39 
41  bot_ip = (struct rt_bot_internal *)ip->idb_ptr;
42  RT_BOT_CK_MAGIC(bot_ip);
43 
44  /* BoT vertices to gdiam */
45  pnt_arr = gdiam_convert((gdiam_real *)bot_ip->vertices, bot_ip->num_vertices);
46 
47  /* Calculate tight bbox */
48  bb = gdiam_approx_mvbb_grid_sample(pnt_arr, bot_ip->num_vertices, 5, 400 );
49 
50  /* gdiam_bbox to struct rt_arb_internal */
51  /* 0, 0, 0 */
52  bb.get_vertex(0, 0, 0, &(bbox->pt[0][0]), &(bbox->pt[0][1]), &(bbox->pt[0][2]));
53  /* 0, 1, 0 */
54  bb.get_vertex(0, 1, 0, &(bbox->pt[1][0]), &(bbox->pt[1][1]), &(bbox->pt[1][2]));
55  /* 0, 1, 1 */
56  bb.get_vertex(0, 1, 1, &(bbox->pt[2][0]), &(bbox->pt[2][1]), &(bbox->pt[2][2]));
57  /* 0, 0, 1 */
58  bb.get_vertex(0, 0, 1, &(bbox->pt[3][0]), &(bbox->pt[3][1]), &(bbox->pt[3][2]));
59  /* 1, 0, 0 */
60  bb.get_vertex(1, 0, 0, &(bbox->pt[4][0]), &(bbox->pt[4][1]), &(bbox->pt[4][2]));
61  /* 1, 1, 0 */
62  bb.get_vertex(1, 1, 0, &(bbox->pt[5][0]), &(bbox->pt[5][1]), &(bbox->pt[5][2]));
63  /* 1, 1, 1 */
64  bb.get_vertex(1, 1, 1, &(bbox->pt[6][0]), &(bbox->pt[6][1]), &(bbox->pt[6][2]));
65  /* 1, 0, 1 */
66  bb.get_vertex(1, 0, 1, &(bbox->pt[7][0]), &(bbox->pt[7][1]), &(bbox->pt[7][2]));
67 
68  return 0;
69 }
70 
71 
72 // Local Variables:
73 // tab-width: 8
74 // mode: C++
75 // c-basic-offset: 4
76 // indent-tabs-mode: t
77 // c-file-style: "stroustrup"
78 // End:
79 // ex: shiftwidth=4 tabstop=8
int rt_bot_oriented_bbox(struct rt_arb_internal *bbox, struct rt_db_internal *ip, const fastf_t tol)
Header file for the BRL-CAD common definitions.
#define RT_CK_DB_INTERNAL(_p)
Definition: raytrace.h:207
#define UNUSED(parameter)
Definition: common.h:239
void * idb_ptr
Definition: raytrace.h:195
double fastf_t
Definition: defines.h:300