v2d.h
Go to the documentation of this file.
1 /*
2  *
3  * v2d.h
4  *
5  * Routines for rasterizing (analytic area sampling)
6  * polygons to a regular Cartesian grid using r2d.
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 _V2D_H_
47 #define _V2D_H_
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #include "r2d.h"
54 
85 void r2d_rasterize(r2d_poly* poly, r2d_dvec2 ibox[2], r2d_real* dest_grid, r2d_rvec2 d, r2d_int polyorder);
86 
104 void r2d_clamp_ibox(r2d_poly* poly, r2d_dvec2 ibox[2], r2d_dvec2 clampbox[2], r2d_rvec2 d);
105 
119 void r2d_get_ibox(r2d_poly* poly, r2d_dvec2 ibox[2], r2d_rvec2 d);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif // _V2D_H_
A polygon.
Definition: r2d.h:97
void r2d_get_ibox(r2d_poly *poly, r2d_dvec2 ibox[2], r2d_rvec2 d)
Get the minimal box of grid indices for a polygon, given a grid cell spacing.
Integer vector struct for grid indexing.
Definition: r2d.h:64
void r2d_clamp_ibox(r2d_poly *poly, r2d_dvec2 ibox[2], r2d_dvec2 clampbox[2], r2d_rvec2 d)
Get the minimal box of grid indices for a polygon, given a grid cell spacing, also clamping it to a u...
void r2d_rasterize(r2d_poly *poly, r2d_dvec2 ibox[2], r2d_real *dest_grid, r2d_rvec2 d, r2d_int polyorder)
Rasterize a polygon to the destination grid.
Vector struct.
Definition: r2d.h:56
double r2d_real
Real type specifying the precision to be used in calculations.
Definition: r2d.h:40
int32_t r2d_int
Integer type used for grid indexing and bit flags.
Definition: r2d.h:46