BRL-CAD

Definitions and functions supporting raytracing BRL-CAD geometry. More...

Collaboration diagram for Raytracing:

Modules

 The Solids Table
 The LIBRT Solids Table.
 
 The Function Table
 Object-oriented interface to BRL-CAD geometry.
 
 Generate Rays via Pattern Templates
 Functionality for generating patterns of rays.
 
 Shoot Rays
 Ray Tracing program shot coordinator. This is the heart of LIBRT's ray-tracing capability.
 
 Booleweave
 Boolean weaving of raytracing segments.
 

Files

file  calc.h
 In memory format for non-geometry objects in BRL-CAD databases.
 

Functions

int rt_matrix_transform (struct rt_db_internal *output, const mat_t matrix, struct rt_db_internal *input, int free_input, struct db_i *dbip, struct resource *resource)
 
int rt_rpp_region (struct rt_i *rtip, const char *reg_name, fastf_t *min_rpp, fastf_t *max_rpp)
 
int rt_in_rpp (struct xray *rp, const fastf_t *invdir, const fastf_t *min, const fastf_t *max)
 
int rt_bound_internal (struct db_i *dbip, struct directory *dp, point_t rpp_min, point_t rpp_max)
 
int rt_bound_instance (point_t *bmin, point_t *bmax, struct directory *dp, struct db_i *dbip, const struct bg_tess_tol *ttol, const struct bn_tol *tol, mat_t *s_mat, struct resource *res)
 
int rt_obj_bounds (struct bu_vls *msgs, struct db_i *dbip, int argc, const char *argv[], int use_air, point_t rpp_min, point_t rpp_max)
 
int rt_shader_mat (mat_t model_to_shader, const struct rt_i *rtip, const struct region *rp, point_t p_min, point_t p_max, struct resource *resp)
 
struct rt_db_internalrt_mirror (struct db_i *dpip, struct rt_db_internal *ip, point_t mirror_pt, vect_t mirror_dir, struct resource *resp)
 
void rt_plot_all_bboxes (FILE *fp, struct rt_i *rtip)
 
void rt_plot_all_solids (FILE *fp, struct rt_i *rtip, struct resource *resp)
 
void rt_pr_fallback_angle (struct bu_vls *str, const char *prefix, const double angles[5])
 
void rt_find_fallback_angle (double angles[5], const vect_t vec)
 
void rt_pr_tol (const struct bn_tol *tol)
 
int rt_poly_roots (bn_poly_t *eqn, bn_complex_t roots[], const char *name)
 

Detailed Description

Definitions and functions supporting raytracing BRL-CAD geometry.

Function Documentation

◆ rt_matrix_transform()

int rt_matrix_transform ( struct rt_db_internal output,
const mat_t  matrix,
struct rt_db_internal input,
int  free_input,
struct db_i dbip,
struct resource resource 
)

apply a matrix transformation to a given input object, setting the resultant transformed object as the output solid. if freeflag is set, the input object will be released.

returns zero if matrix transform was applied, non-zero on failure.

◆ rt_rpp_region()

int rt_rpp_region ( struct rt_i rtip,
const char *  reg_name,
fastf_t min_rpp,
fastf_t max_rpp 
)

Calculate the bounding RPP for a region given the name of the region node in the database. See remarks in _rt_getregion() above for name conventions. Returns 0 for failure (and prints a diagnostic), or 1 for success.

◆ rt_in_rpp()

int rt_in_rpp ( struct xray rp,
const fastf_t invdir,
const fastf_t min,
const fastf_t max 
)

Compute the intersections of a ray with a rectangular parallelepiped (RPP) that has faces parallel to the coordinate planes

The algorithm here was developed by Gary Kuehl for GIFT. A good description of the approach used can be found in "??" by XYZZY and Barsky, ACM Transactions on Graphics, Vol 3 No 1, January 1984.

Note: The computation of entry and exit distance is mandatory, as the final test catches the majority of misses.

Note: A hit is returned if the intersect is behind the start point.

Returns - 0 if ray does not hit RPP, !0 if ray hits RPP.

Implicit return - rp->r_min = dist from start of ray to point at which ray ENTERS solid rp->r_max = dist from start of ray to point at which ray LEAVES solid

◆ rt_bound_internal()

int rt_bound_internal ( struct db_i dbip,
struct directory dp,
point_t  rpp_min,
point_t  rpp_max 
)

Calculate the bounding RPP of the internal format passed in 'ip'. The bounding RPP is returned in rpp_min and rpp_max in mm

Todo:
This function needs to be modified to eliminate the rt_gettree() call and the related parameters. In that case calling code needs to call another function before calling this function That function must create a union tree with tr_a.tu_op=OP_SOLID. It can look as follows : union tree * rt_comb_tree(const struct db_i *dbip, const struct rt_db_internal *ip). The tree is set in the struct rt_db_internal * ip argument. Once a suitable tree is set in the ip, then this function can be called with the struct rt_db_internal
  • to return the BB properly without getting stuck during tree traversal in rt_bound_tree()

Returns - 0 success -1 failure, the model bounds could not be got

◆ rt_bound_instance()

int rt_bound_instance ( point_t bmin,
point_t bmax,
struct directory dp,
struct db_i dbip,
const struct bg_tess_tol ttol,
const struct bn_tol tol,
mat_t s_mat,
struct resource res 
)

Given the info defining a comb tree instance, calculate its bounding box (using ft_plot methods as a fallback.) This routine has its origins in the drawing code

◆ rt_obj_bounds()

int rt_obj_bounds ( struct bu_vls msgs,
struct db_i dbip,
int  argc,
const char *  argv[],
int  use_air,
point_t  rpp_min,
point_t  rpp_max 
)

Given an argc/argv list of objects, calculate their collective bounding box

◆ rt_shader_mat()

int rt_shader_mat ( mat_t  model_to_shader,
const struct rt_i rtip,
const struct region rp,
point_t  p_min,
point_t  p_max,
struct resource resp 
)

Given a region, return a matrix which maps model coordinates into region "shader space". This is a space where points in the model within the bounding box of the region are mapped into "region" space (the coordinate system in which the region is defined). The area occupied by the region's bounding box (in region coordinates) are then mapped into the unit cube. This unit cube defines "shader space".

Returns: 0 OK <0 Failure

◆ rt_mirror()

struct rt_db_internal* rt_mirror ( struct db_i dpip,
struct rt_db_internal ip,
point_t  mirror_pt,
vect_t  mirror_dir,
struct resource resp 
)

◆ rt_plot_all_bboxes()

void rt_plot_all_bboxes ( FILE *  fp,
struct rt_i rtip 
)

◆ rt_plot_all_solids()

void rt_plot_all_solids ( FILE *  fp,
struct rt_i rtip,
struct resource resp 
)

◆ rt_pr_fallback_angle()

void rt_pr_fallback_angle ( struct bu_vls str,
const char *  prefix,
const double  angles[5] 
)

◆ rt_find_fallback_angle()

void rt_find_fallback_angle ( double  angles[5],
const vect_t  vec 
)

◆ rt_pr_tol()

void rt_pr_tol ( const struct bn_tol tol)

◆ rt_poly_roots()

int rt_poly_roots ( bn_poly_t eqn,
bn_complex_t  roots[],
const char *  name 
)

Find the roots of a polynomial

Todo:
  • should this be moved to libbn?

WARNING: The polynomial given as input is destroyed by this routine. The caller must save it if it is important!

NOTE : This routine is written for polynomials with real coefficients ONLY. To use with complex coefficients, the Complex Math library should be used throughout. Some changes in the algorithm will also be required.