v3d.h
Go to the documentation of this file.
1 /*
2  *
3  * v3d.h
4  *
5  * Routines for voxelizing (analytic volume sampling)
6  * polyhedra to a regular Cartesian grid using r3d.
7  *
8  * Devon Powell
9  * 15 October 2015
10  *
11  * Copyright (c) 2015, The Board of Trustees of the Leland Stanford Junior University,
12  * through SLAC National Accelerator Laboratory (subject to receipt of any required approvals
13  * from the U.S. Dept. of Energy). All rights reserved. Redistribution and use in source and
14  * binary forms, with or without modification, are permitted provided that the following
15  * conditions are met:
16  * (1) Redistributions of source code must retain the above copyright notice,
17  * this list of conditions and the following disclaimer.
18  * (2) Redistributions in binary form must reproduce the above copyright notice,
19  * this list of conditions and the following disclaimer in the documentation and/or other
20  * materials provided with the distribution.
21  * (3) Neither the name of the Leland Stanford Junior University, SLAC National Accelerator
22  * Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse
23  * or promote products derived from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
26  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER, THE UNITED STATES GOVERNMENT, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
33  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  * You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to
36  * the features, functionality or performance of the source code ("Enhancements") to anyone;
37  * however, if you choose to make your Enhancements available either publicly, or directly to
38  * SLAC National Accelerator Laboratory, without imposing a separate written license agreement
39  * for such Enhancements, then you hereby grant the following license: a non-exclusive,
40  * royalty-free perpetual license to install, use, modify, prepare derivative works,
41  * incorporate into other computer software, distribute, and sublicense such Enhancements or
42  * derivative works thereof, in binary and source code form.
43  *
44  */
45 
46 #ifndef _V3D_H_
47 #define _V3D_H_
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #include "r3d.h"
54 
85 void r3d_voxelize(r3d_poly* poly, r3d_dvec3 ibox[2], r3d_real* dest_grid, r3d_rvec3 d, r3d_int polyorder);
86 
104 void r3d_clamp_ibox(r3d_poly* poly, r3d_dvec3 ibox[2], r3d_dvec3 clampbox[2], r3d_rvec3 d);
105 
119 void r3d_get_ibox(r3d_poly* poly, r3d_dvec3 ibox[2], r3d_rvec3 d);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif // _V3D_H_
Integer vector struct for grid indexing.
Definition: r3d.h:65
void r3d_clamp_ibox(r3d_poly *poly, r3d_dvec3 ibox[2], r3d_dvec3 clampbox[2], r3d_rvec3 d)
Get the minimal box of grid indices for a polyhedron, given a grid cell spacing, also clamping it to ...
void r3d_get_ibox(r3d_poly *poly, r3d_dvec3 ibox[2], r3d_rvec3 d)
Get the minimal box of grid indices for a polyhedron, given a grid cell spacing.
Vector struct.
Definition: r3d.h:56
void r3d_voxelize(r3d_poly *poly, r3d_dvec3 ibox[2], r3d_real *dest_grid, r3d_rvec3 d, r3d_int polyorder)
Voxelize a polyhedron to the destination grid.
int32_t r3d_int
Integer type used for grid indexing and bit flags.
Definition: r3d.h:46
A polyhedron.
Definition: r3d.h:99
double r3d_real
Real type specifying the precision to be used in calculations.
Definition: r3d.h:40