BRL-CAD
#include "common.h"
#include <math.h>
#include <string.h>
#include "bio.h"
#include "vmath.h"
#include "raytrace.h"
#include "plot3.h"
Include dependency graph for shoot.c:

Go to the source code of this file.

Macros

#define V3PT_DEPARTING_RPP(_step, _lo, _hi, _pt)   PT_DEPARTING_RPP(_step, _lo, _hi, (_pt)[X], (_pt)[Y], (_pt)[Z])
 
#define PT_DEPARTING_RPP(_step, _lo, _hi, _px, _py, _pz)
 

Functions

void rt_res_pieces_init (struct resource *resp, struct rt_i *rtip)
 
void rt_res_pieces_clean (struct resource *resp, struct rt_i *rtip)
 
int rt_find_nugrid (const struct nugridnode *nugnp, int axis, fastf_t val)
 
const union cutterrt_advance_to_next_cell (register struct rt_shootray_status *ssp)
 
fastf_t rt_find_backing_dist (struct rt_shootray_status *ss, struct bu_bitv *backbits)
 
void rt_3move_raydist (FILE *fp, struct xray *rayp, double dist)
 
void rt_3cont_raydist (FILE *fp, struct xray *rayp, double dist)
 
void rt_plot_cell (const union cutter *cutp, const struct rt_shootray_status *ssp, struct bu_list *waiting_segs_hd, struct rt_i *rtip)
 
int rt_shootray (register struct application *ap)
 
const union cutterrt_cell_n_on_ray (register struct application *ap, int n)
 
void rt_zero_res_stats (struct resource *resp)
 
void rt_add_res_stats (register struct rt_i *rtip, register struct resource *resp)
 
struct partitionrt_shootray_simple (struct application *a, point_t origin, vect_t direction)
 

Detailed Description

Ray Tracing program shot coordinator.

This is the heart of LIBRT's ray-tracing capability.

Given a ray, shoot it at all the relevant parts of the model, (building the finished_segs chain), and then call rt_boolregions() to build and evaluate the partition chain. If the ray actually hit anything, call the application's a_hit() routine with a pointer to the partition chain, otherwise, call the application's a_miss() routine.

It is important to note that rays extend infinitely only in the positive direction. The ray is composed of all points P, where

P = r_pt + K * r_dir

for K ranging from 0 to +infinity. There is no looking backwards.

Definition in file shoot.c.

Macro Definition Documentation

#define V3PT_DEPARTING_RPP (   _step,
  _lo,
  _hi,
  _pt 
)    PT_DEPARTING_RPP(_step, _lo, _hi, (_pt)[X], (_pt)[Y], (_pt)[Z])

Definition at line 34 of file shoot.c.

#define PT_DEPARTING_RPP (   _step,
  _lo,
  _hi,
  _px,
  _py,
  _pz 
)
Value:
(((_step)[X] <= 0 && (_px) < (_lo)[X]) || \
((_step)[X] >= 0 && (_px) > (_hi)[X]) || \
((_step)[Y] <= 0 && (_py) < (_lo)[Y]) || \
((_step)[Y] >= 0 && (_py) > (_hi)[Y]) || \
((_step)[Z] <= 0 && (_pz) < (_lo)[Z]) || \
((_step)[Z] >= 0 && (_pz) > (_hi)[Z]))
Definition: color.c:49
Definition: color.c:51
Definition: color.c:50

Definition at line 36 of file shoot.c.

Referenced by rt_advance_to_next_cell().

Function Documentation

int rt_find_nugrid ( const struct nugridnode nugnp,
int  axis,
fastf_t  val 
)

Along the given axis, find which NUgrid cell this value lies in. Use method of binary subdivision.

Definition at line 134 of file shoot.c.

References nugridnode::nu_axis, nugridnode::nu_cells_per_axis, and nu_axis::nu_epos.

Referenced by rt_advance_to_next_cell().

const union cutter* rt_advance_to_next_cell ( register struct rt_shootray_status ssp)

Definition at line 170 of file shoot.c.

References application::a_ray, application::a_rt_i, application::a_x, application::a_y, rt_shootray_status::ap, cutter::bn, boxnode::bn_len, boxnode::bn_max, boxnode::bn_min, boxnode::bn_piecelen, rt_shootray_status::box_end, rt_shootray_status::box_num, rt_shootray_status::box_start, BU_ALLOC, bu_bomb(), bu_free(), bu_log(), cutter::cn, cutnode::cn_axis, cutnode::cn_l, cutnode::cn_r, rt_shootray_status::curcut, rt_shootray_status::curmax, rt_shootray_status::curmin, CUT_BOXNODE, CUT_CUTNODE, CUT_NUGRIDNODE, cutter::cut_type, CUTTER_NULL, DEBUG_ADVANCE, delta, bn_tol::dist, rt_shootray_status::dist_corr, if(), rt_shootray_status::igrid, rt_shootray_status::inv_dir, rt_shootray_status::lastcell, rt_shootray_status::lastcut, rt_shootray_status::model_end, rt_shootray_status::newray, nugridnode::nu_axis, nugridnode::nu_cells_per_axis, nu_axis::nu_epos, nugridnode::nu_grid, nu_axis::nu_spos, nugridnode::nu_stepsize, cutter::nugn, NUGRID_T_ADV, NUGRID_T_SETUP, rt_shootray_status::obox_end, rt_shootray_status::obox_start, rt_shootray_status::odist_corr, rt_shootray_status::old_status, rt_shootray_status::out_axis, PT_DEPARTING_RPP, xray::r_dir, xray::r_max, xray::r_min, xray::r_pt, resource::re_nempty_cells, rt_shootray_status::resp, rt_shootray_status::rstep, rt_find_nugrid(), RT_G_DEBUG, rt_in_rpp(), rt_pr_cut(), rt_i::rti_inf_box, rt_i::rti_tol, SQRT_SMALL_FASTF, top(), rt_shootray_status::tv, V3ARGS, VPRINT, VSET, X, Y, and Z.

Referenced by rt_cell_n_on_ray(), and rt_shootray().

Here is the call graph for this function:

fastf_t rt_find_backing_dist ( struct rt_shootray_status ss,
struct bu_bitv backbits 
)

This routine traces a ray from its start point to model exit through the space partitioning tree. The objective is to find all primitives that use "pieces" and also have a bounding box that extends behind the ray start point. The minimum (most negative) intersection with such a bounding box is returned. The "backbits" bit vector (provided by the caller) gets a bit set for every primitive that meets the above criteria. No primitive intersections are performed.

XXX This routine does not work for NUGRID XXX

Definition at line 651 of file shoot.c.

References application::a_ray, application::a_resource, application::a_rt_i, rt_shootray_status::ap, BACKING_DIST, cutter::bn, boxnode::bn_max, boxnode::bn_min, boxnode::bn_piecelen, boxnode::bn_piecelist, BU_BITSET, BU_BITTEST, BU_CK_BITV, BU_LIST_APPEND, cutter::cn, cutnode::cn_axis, cutnode::cn_l, cutnode::cn_point, cutnode::cn_r, CUT_CUTNODE, cutter::cut_type, bn_tol::dist, rt_shootray_status::inv_dir, bu_bitv::l, rt_i::nsolids, xray::r_dir, xray::r_max, xray::r_min, xray::r_pt, resource::re_solid_bitv, rt_get_solidbitv(), rt_in_rpp(), rt_i::rti_CutHead, rt_i::rti_tol, soltab::st_bit, soltab::st_max, soltab::st_min, and rt_piecelist::stp.

Referenced by rt_shootray().

Here is the call graph for this function:

void rt_3move_raydist ( FILE *  fp,
struct xray rayp,
double  dist 
)

Routines for plotting the progress of one ray through the model.

Definition at line 744 of file shoot.c.

References pdv_3move(), xray::r_dir, and xray::r_pt.

Referenced by rt_plot_cell().

Here is the call graph for this function:

void rt_3cont_raydist ( FILE *  fp,
struct xray rayp,
double  dist 
)

Definition at line 754 of file shoot.c.

References pdv_3cont(), xray::r_dir, and xray::r_pt.

Referenced by rt_plot_cell().

Here is the call graph for this function:

void rt_plot_cell ( const union cutter cutp,
const struct rt_shootray_status ssp,
struct bu_list waiting_segs_hd,
struct rt_i rtip 
)
int rt_shootray ( register struct application ap)

Definition at line 841 of file shoot.c.

References application::a_Final_Part_hdp, application::a_finished_segs_hdp, application::a_hit, application::a_inv_dir, application::a_level, application::a_magic, application::a_miss, application::a_onehit, application::a_purpose, application::a_ray, application::a_ray_length, application::a_resource, application::a_return, application::a_rt_i, application::a_x, application::a_y, rt_shootray_status::abs_inv_dir, rt_shootray_status::ap, BACKING_DIST, cutter::bn, boxnode::bn_len, boxnode::bn_list, boxnode::bn_piecelen, boxnode::bn_piecelist, rt_shootray_status::box_end, rt_shootray_status::box_num, rt_shootray_status::box_start, BU_ALLOC, BU_ASSERT_DOUBLE, BU_ASSERT_PTR, BU_BITSET, BU_BITTEST, BU_BITV_ZEROALL, bu_bomb(), BU_CK_BITV, BU_CK_PTBL, BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_FOR, BU_LIST_INIT, BU_LIST_INSERT, BU_LIST_IS_EMPTY, BU_LIST_IS_INITIALIZED, BU_LIST_MAGIC_EQUAL, BU_LIST_NON_EMPTY, BU_LIST_WHILE, bu_log(), bu_log_indent_delta(), BU_PTBL_FOR, BU_PTBL_GET, bu_ptbl_init(), bu_ptbl_ins_unique(), BU_PTBL_LEN, BU_PTBL_MAGIC, bu_ptbl_reset(), bu_ptbl_rm(), rt_shootray_status::curcut, rt_shootray_status::curmax, rt_shootray_status::curmin, CUT_BOXNODE, CUT_CUTNODE, CUT_NUGRIDNODE, cutter::cut_type, rt_piecestate::cutp, CUTTER_NULL, DEBUG_ADVANCE, DEBUG_ALLHITS, DEBUG_ALLRAYS, DEBUG_PARTITION, DEBUG_SHOOT, bn_tol::dist, rt_shootray_status::dist_corr, rt_htbl::end, rt_functab::ft_piece_hitsegs, rt_functab::ft_piece_shot, rt_functab::ft_shot, rt_functab::ft_use_rpp, hit::hit_dist, hit::hit_rayp, rt_piecestate::htab, rt_shootray_status::inv_dir, bu_ptbl::l, seg::l, bu_bitv::l, rt_shootray_status::lastcell, rt_shootray_status::lastcut, xray::magic, rt_piecestate::maxdist, rt_i::mdl_max, rt_i::mdl_min, rt_piecestate::mindist, rt_shootray_status::model_end, rt_shootray_status::model_start, NEAR_ZERO, rt_i::needprep, rt_shootray_status::newray, rt_i::nsolids, nugridnode::nu_axis, nugridnode::nu_cells_per_axis, nu_axis::nu_epos, nu_axis::nu_spos, cutter::nugn, rt_shootray_status::obox_end, rt_shootray_status::obox_start, rt_shootray_status::odist_corr, rt_shootray_status::old_status, out, partition::pt_back, partition::pt_forw, PT_HD_MAGIC, partition::pt_magic, xray::r_dir, xray::r_max, xray::r_min, xray::r_pt, rt_piecestate::ray_seqno, resource::re_cpu, resource::re_magic, resource::re_ndup, resource::re_nempty_cells, resource::re_nmiss_model, resource::re_nshootray, resource::re_parthead, resource::re_piece_shot_hit, resource::re_piece_shot_miss, resource::re_piece_shots, resource::re_pieces, resource::re_pieces_pending, resource::re_prune_solrpp, resource::re_region_ptbl, resource::re_shot_hit, resource::re_shot_miss, resource::re_shots, resource::re_solid_bitv, RESOURCE_NULL, rt_shootray_status::resp, rt_shootray_status::rstep, rt_advance_to_next_cell(), RT_AP_CHECK, RT_AP_MAGIC, rt_boolfinal(), rt_boolweave(), RT_CK_AP, RT_CK_PIECELIST, RT_CK_PIECESTATE, RT_CK_RAY, RT_CK_RESOURCE, RT_CK_RTI, RT_CK_SOLTAB, rt_find_backing_dist(), RT_FREE_PT_LIST, RT_FREE_SEG_LIST, RT_G_DEBUG, rt_get_solidbitv(), rt_htbl_reset(), rt_in_rpp(), rt_init_resource(), rt_plot_cell(), rt_pr_cut(), rt_pr_partitions(), rt_pr_seg(), rt_prep_parallel(), RT_RAY_MAGIC, rt_res_pieces_init(), rt_uniresource, rt_i::rti_CutHead, rt_i::rti_inf_box, rt_i::rti_nsolids_with_pieces, rt_i::rti_resources, rt_i::rti_tol, seg::seg_in, seg::seg_out, rt_piecestate::shot, SQRT_SMALL_FASTF, soltab::st_bit, soltab::st_max, soltab::st_meth, soltab::st_min, soltab::st_piecestate_num, rt_piecestate::stp, rt_piecelist::stp, UNLIKELY, V3ARGS, VSET, X, Y, and Z.

Referenced by rt_shootray_simple().

Here is the call graph for this function:

const union cutter* rt_cell_n_on_ray ( register struct application ap,
int  n 
)

Definition at line 1547 of file shoot.c.

References application::a_level, application::a_magic, application::a_onehit, application::a_purpose, application::a_ray, application::a_resource, application::a_rt_i, application::a_x, application::a_y, rt_shootray_status::abs_inv_dir, rt_shootray_status::ap, BACKING_DIST, cutter::bn, boxnode::bn_len, rt_shootray_status::box_end, rt_shootray_status::box_start, BU_ASSERT_PTR, bu_bomb(), BU_LIST_IS_INITIALIZED, bu_log(), bu_log_indent_delta(), BU_PTBL_GET, rt_shootray_status::curcut, rt_shootray_status::curmax, rt_shootray_status::curmin, CUT_BOXNODE, CUT_CUTNODE, CUT_NUGRIDNODE, cutter::cut_type, CUTTER_NULL, DEBUG_ALLHITS, DEBUG_ALLRAYS, DEBUG_PARTITION, DEBUG_SHOOT, bn_tol::dist, rt_shootray_status::dist_corr, rt_shootray_status::inv_dir, rt_shootray_status::lastcell, rt_shootray_status::lastcut, xray::magic, rt_i::mdl_max, rt_i::mdl_min, memset(), rt_shootray_status::model_end, rt_shootray_status::model_start, NEAR_ZERO, rt_i::needprep, rt_shootray_status::newray, nugridnode::nu_axis, nugridnode::nu_cells_per_axis, nu_axis::nu_epos, nu_axis::nu_spos, cutter::nugn, rt_shootray_status::obox_end, rt_shootray_status::obox_start, rt_shootray_status::odist_corr, rt_shootray_status::old_status, xray::r_dir, xray::r_max, xray::r_min, xray::r_pt, resource::re_cpu, resource::re_magic, resource::re_parthead, RESOURCE_NULL, rt_shootray_status::resp, rt_shootray_status::rstep, rt_advance_to_next_cell(), RT_AP_CHECK, RT_AP_MAGIC, RT_CK_AP, RT_CK_RAY, RT_CK_RESOURCE, RT_CK_RTI, RT_G_DEBUG, rt_in_rpp(), rt_init_resource(), rt_pr_cut(), rt_prep_parallel(), RT_RAY_MAGIC, rt_uniresource, rt_i::rti_CutHead, rt_i::rti_inf_box, rt_i::rti_resources, rt_i::rti_tol, SQRT_SMALL_FASTF, V3ARGS, VPRINT, VSET, X, Y, and Z.

Here is the call graph for this function:

void rt_add_res_stats ( register struct rt_i rtip,
register struct resource resp 
)