r3d.h File Reference
#include <stdint.h>

Go to the source code of this file.

Classes

struct  r3d_rvec3
 Vector struct. More...
 
struct  r3d_dvec3
 Integer vector struct for grid indexing. More...
 
struct  r3d_plane
 A plane. More...
 
struct  r3d_orientation
 Perpendicular distances and bit flags for up to 6 faces. More...
 
struct  r3d_vertex
 A doubly-linked vertex. More...
 
struct  r3d_poly
 A polyhedron. More...
 
struct  r3d_dest_grid
 Destination grid information. More...
 

Macros

#define R3D_MAX_VERTS   64
 

Typedefs

typedef double r3d_real
 Real type specifying the precision to be used in calculations. More...
 
typedef int32_t r3d_int
 Integer type used for grid indexing and bit flags. More...
 
typedef int64_t r3d_long
 Long integer type used for grid indexing. More...
 

Functions

void r3d_voxelize_tet (r3d_plane *faces, r3d_dest_grid *grid)
 Voxelize a tetrahedron to the destination grid. More...
 
void r3d_clip_tet (r3d_poly *poly, unsigned char andcmp)
 Clip a polyhedron against four clip planes (find its intersection with a tetrahedron). More...
 
void r3d_reduce (r3d_poly *poly, r3d_int polyorder, r3d_real *moments)
 Integrate a polynomial density over a convex polyhedron using simplicial decomposition. More...
 
void r3du_init_box (r3d_poly *poly, r3d_rvec3 rbounds[2])
 Initialize a polyhedron as an axis-aligned cube. More...
 
void r3du_tet_faces_from_verts (r3d_rvec3 *verts, r3d_plane *faces)
 Get four faces (unit normals and distances to the origin) i from a four-vertex description of a tetrahedron. More...
 
r3d_real r3du_orient (r3d_rvec3 pa, r3d_rvec3 pb, r3d_rvec3 pc, r3d_rvec3 pd)
 Get the signed volume of the tetrahedron defined by the input vertices. More...
 

Macro Definition Documentation

◆ R3D_MAX_VERTS

#define R3D_MAX_VERTS   64

Typedef Documentation

◆ r3d_int

typedef int32_t r3d_int

Integer type used for grid indexing and bit flags.

◆ r3d_long

typedef int64_t r3d_long

Long integer type used for grid indexing.

◆ r3d_real

typedef double r3d_real

Real type specifying the precision to be used in calculations.

Default is double (recommended). float precision is enabled by compiling with -DSINGLE_PRECISION.

Function Documentation

◆ r3d_clip_tet()

void r3d_clip_tet ( r3d_poly poly,
unsigned char  andcmp 
)

Clip a polyhedron against four clip planes (find its intersection with a tetrahedron).

Parameters
[in,out]polyThe polyehdron to be clipped. The distances to the clip plane and bit flags in poly.verts[...].orient must be set prior to calling this function.
[in]andcmpSet of bit flags allowing faces to be skipped. Face f will be skipped if andcmp & (1 << f) evaluates to true.

◆ r3d_reduce()

void r3d_reduce ( r3d_poly poly,
r3d_int  polyorder,
r3d_real moments 
)

Integrate a polynomial density over a convex polyhedron using simplicial decomposition.

Parameters
[in]polyThe polyhedron over which to integrate.
[in]polyorderOrder of the polynomial density field. 0 for constant (1 moment), 1 for linear (4 moments), 2 for quadratic (10 moments).
[in,out]momentsArray to be filled with the integration results, up to the sepcified polyorder. Order of moments is 1, x, y, z, x^2, y^2, z^2, x*y, y*z, z*x.

◆ r3d_voxelize_tet()

void r3d_voxelize_tet ( r3d_plane faces,
r3d_dest_grid grid 
)

Voxelize a tetrahedron to the destination grid.

Parameters
[in]facesThe four faces of the tetrahedron to be voxelized.
[in,out]gridThe destination grid buffer that the tetrahedron will be voxelized to. The results of the voxelization are found in grid.moments.

◆ r3du_init_box()

void r3du_init_box ( r3d_poly poly,
r3d_rvec3  rbounds[2] 
)

Initialize a polyhedron as an axis-aligned cube.

Parameters
[in,out]polyThe polyhedron to initialize.
[in]rboundsAn array of two vectors, giving the lower and upper corners of the box.

◆ r3du_orient()

r3d_real r3du_orient ( r3d_rvec3  pa,
r3d_rvec3  pb,
r3d_rvec3  pc,
r3d_rvec3  pd 
)

Get the signed volume of the tetrahedron defined by the input vertices.

Parameters
[in]pa,pb,pc,pdVertices defining a tetrahedron from which to calculate a volume.
Returns
The signed volume of the input tetrahedron.

◆ r3du_tet_faces_from_verts()

void r3du_tet_faces_from_verts ( r3d_rvec3 verts,
r3d_plane faces 
)

Get four faces (unit normals and distances to the origin) i from a four-vertex description of a tetrahedron.

Parameters
[in]vertsArray of four vectors defining the vertices of the tetrahedron.
[out]facesArray of four planes defining the faces of the tetrahedron.