BRL-CAD
#include "common.h"
#include <string.h>
#include "bio.h"
#include "bu/parallel.h"
#include "vmath.h"
#include "raytrace.h"
Include dependency graph for bool.c:

Go to the source code of this file.

Macros

#define BOOL_FALSE   0
 
#define BOOL_TRUE   1
 
#define HITS_TODO   (hits_needed - hits_avail)
 

Functions

void rt_weave0seg (struct seg *segp, struct partition *PartHdp, struct application *ap)
 
void rt_boolweave (struct seg *out_hd, struct seg *in_hd, struct partition *PartHdp, struct application *ap)
 
int rt_defoverlap (register struct application *ap, register struct partition *pp, struct region *reg1, struct region *reg2, struct partition *pheadp)
 
void rt_get_region_seglist_for_partition (struct bu_ptbl *sl, const struct partition *pp, const struct region *regp)
 
int rt_tree_max_raynum (register const union tree *tp, register const struct partition *pp)
 
void rt_fastgen_vol_vol_overlap (struct region **fr1, struct region **fr2, const struct partition *pp)
 
int rt_fdiff (double a, double b)
 
void rt_fastgen_plate_vol_overlap (struct region **fr1, struct region **fr2, struct partition *pp, struct application *ap)
 
void rt_default_multioverlap (struct application *ap, struct partition *pp, struct bu_ptbl *regiontable, struct partition *InputHdp)
 
void rt_silent_logoverlap (struct application *ap, const struct partition *pp, const struct bu_ptbl *regiontable, const struct partition *InputHdp)
 
void rt_default_logoverlap (struct application *ap, const struct partition *pp, const struct bu_ptbl *regiontable, const struct partition *InputHdp)
 
int rt_overlap_tables_equal (struct region *const *a, struct region *const *b)
 
int rt_tree_test_ready (register const union tree *tp, register const struct bu_bitv *solidbits, register const struct region *regionp, register const struct partition *pp)
 
int rt_bool_partition_eligible (register const struct bu_ptbl *regiontable, register const struct bu_bitv *solidbits, register const struct partition *pp)
 
void rt_grow_boolstack (register struct resource *resp)
 
int rt_booleval (register union tree *treep, struct partition *partp, struct region **trueregp, struct resource *resp)
 
int rt_boolfinal (struct partition *InputHdp, struct partition *FinalHdp, fastf_t startdist, fastf_t enddist, struct bu_ptbl *regiontable, struct application *ap, const struct bu_bitv *solidbits)
 
double rt_reldiff (double a, double b)
 
int rt_partition_len (const struct partition *partheadp)
 
void rt_rebuild_overlaps (struct partition *PartHdp, struct application *ap, int rebuild_fastgen_plates_only)
 

Detailed Description

Ray Tracing program, Boolean region evaluator.

Note to developers - Do not use the hit_point field in these routines, as for some solid types it has been filled in by the g_xxx_shot() routine, and for other solid types it may not have been. In particular, copying a garbage hit_point from a structure which has not yet been filled in, into a structure which won't be filled in again, gives wrong results. Thanks to Keith Bowman for finding this obscure bug.

Definition in file bool.c.

Macro Definition Documentation

#define BOOL_FALSE   0

Definition at line 49 of file bool.c.

Referenced by rt_booleval(), and rt_boolfinal().

#define BOOL_TRUE   1

Definition at line 50 of file bool.c.

Referenced by rt_booleval().

#define HITS_TODO   (hits_needed - hits_avail)

Referenced by rt_boolfinal().

Function Documentation

void rt_weave0seg ( struct seg segp,
struct partition PartHdp,
struct application ap 
)

If a zero thickness segment abuts another partition, it will be fused in, later.

If it is free standing, then it will remain as a zero thickness partition, which probably signals going through some solid an odd number of times, or hitting an NMG wire edge or NMG lone vertex.

Definition at line 62 of file bool.c.

References application::a_resource, application::a_rt_i, APPEND_PT, bu_bomb(), bu_log(), bu_ptbl_ins_unique(), DEBUG_PARTITION, bn_tol::dist, GET_PT_INIT, hit::hit_dist, hit::hit_surfno, partition::pt_forw, partition::pt_inhit, partition::pt_inseg, partition::pt_outhit, partition::pt_outseg, partition::pt_seglist, RT_CK_PT_HD, RT_CK_RESOURCE, RT_CK_RTI, RT_G_DEBUG, rt_i::rti_tol, seg::seg_in, seg::seg_out, and seg::seg_stp.

Referenced by rt_boolweave().

Here is the call graph for this function:

int rt_defoverlap ( register struct application ap,
register struct partition pp,
struct region reg1,
struct region reg2,
struct partition pheadp 
)
void rt_get_region_seglist_for_partition ( struct bu_ptbl sl,
const struct partition pp,
const struct region regp 
)

Given one of the regions that is involved in a given partition (whether the boolean formula for this region is BOOL_TRUE in this part or not), return a bu_ptbl list containing all the segments in this partition which came from solids that appear as terms in the boolean formula for the given region.

The bu_ptbl is initialized here, and must be freed by the caller. It will contain a pointer to at least one segment.

Definition at line 637 of file bool.c.

References bu_bomb(), BU_PTBL_FOR, bu_ptbl_init(), bu_ptbl_ins_unique(), BU_PTBL_LEN, partition::pt_seglist, RT_CK_REGION, and RT_CK_SEG.

Referenced by rt_fastgen_vol_vol_overlap().

Here is the call graph for this function:

int rt_tree_max_raynum ( register const union tree tp,
register const struct partition pp 
)

Find the maximum value of the raynum (seg_rayp->index) encountered in the segments contributing to this region.

Returns -

Maximum ray index

-1 If no rays are contributing segs for this region.

Definition at line 671 of file bool.c.

References bu_bomb(), BU_PTBL_FOR, hit::hit_rayp, xray::index, OP_INTERSECT, OP_NOP, OP_NOT, OP_SOLID, OP_SUBTRACT, OP_UNION, OP_XOR, partition::pt_seglist, RT_CK_PARTITION, RT_CK_TREE, seg::seg_in, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tr_a, tree::tr_b, and tree::tree_leaf::tu_stp.

Referenced by rt_default_multioverlap().

Here is the call graph for this function:

void rt_fastgen_vol_vol_overlap ( struct region **  fr1,
struct region **  fr2,
const struct partition pp 
)

Handle FASTGEN volume/volume overlap. Look at underlying segs. If one is less than 1/4", take the longer. Otherwise take the shorter.

Required to null out one of the two regions.

Definition at line 720 of file bool.c.

References bu_log(), BU_PTBL_FOR, bu_ptbl_free(), BU_PTBL_INIT_ZERO, DEBUG_PARTITION, hit::hit_dist, MAX_FASTF, partition::pt_inhit, partition::pt_outhit, REGION_NULL, RT_CK_REGION, RT_CK_SEG, RT_G_DEBUG, rt_get_region_seglist_for_partition(), and seg::seg_in.

Referenced by rt_default_multioverlap().

Here is the call graph for this function:

int rt_fdiff ( double  a,
double  b 
)

Definition at line 789 of file bool.c.

References bu_log(), DEBUG_FDIFF, out, RT_G_DEBUG, and ZERO.

Here is the call graph for this function:

void rt_fastgen_plate_vol_overlap ( struct region **  fr1,
struct region **  fr2,
struct partition pp,
struct application ap 
)

Handle FASTGEN plate/volume overlap.

Measure width of preceding partition, which must have been claimed by the volume mode region fr2.

If less than 1/4", delete preceding partition, and plate wins this part. If less than 1/4", plate wins this part, previous partition untouched. If previous partition is claimed by plate mode region fr1, then overlap is left in output???

Required to null out one of the two regions.

Definition at line 852 of file bool.c.

References application::a_resource, bu_log(), DEBUG_PARTITION, DEQUEUE_PT, FREE_PT, hit::hit_dist, partition::pt_back, PT_HD_MAGIC, partition::pt_inhit, partition::pt_magic, partition::pt_outhit, partition::pt_regionp, REGION_NULL, RT_CK_AP, RT_CK_PT, RT_CK_REGION, and RT_G_DEBUG.

Referenced by rt_default_multioverlap().

Here is the call graph for this function:

int rt_overlap_tables_equal ( struct region *const *  a,
struct region *const *  b 
)

Overlap tables are NULL terminated arrays of region pointers. The order of entries may be different between the two.

Returns - 1 The tables match 0 The tables do not match

Definition at line 1195 of file bool.c.

Referenced by rt_boolfinal().

int rt_tree_test_ready ( register const union tree tp,
register const struct bu_bitv solidbits,
register const struct region regionp,
register const struct partition pp 
)

Test to see if a region is ready to be evaluated over a given partition, i.e. if all the prerequisites have been satisfied.

Returns - !0 Region is ready for (correct) evaluation. 0 Region is not ready

Definition at line 1236 of file bool.c.

References BU_BITTEST, bu_bomb(), BU_CK_BITV, OP_INTERSECT, OP_NOP, OP_NOT, OP_SOLID, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_PT, RT_CK_REGION, RT_CK_TREE, soltab::st_bit, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tr_a, tree::tr_b, and tree::tree_leaf::tu_stp.

Referenced by rt_bool_partition_eligible().

Here is the call graph for this function:

int rt_bool_partition_eligible ( register const struct bu_ptbl regiontable,
register const struct bu_bitv solidbits,
register const struct partition pp 
)

If every solid in every region participating in this ray-partition has already been intersected with the ray, then this partition can be safely evaluated.

Returns - !0 Partition is ready for (correct) evaluation. 0 Partition is not ready

Definition at line 1286 of file bool.c.

References BU_CK_BITV, BU_CK_PTBL, BU_PTBL_FOR, region::reg_treetop, RT_CK_PT, RT_CK_REGION, and rt_tree_test_ready().

Referenced by rt_boolfinal().

Here is the call graph for this function:

void rt_grow_boolstack ( register struct resource resp)

Definition at line 1310 of file bool.c.

References bu_malloc(), bu_realloc(), resource::re_boolslen, and resource::re_boolstack.

Referenced by rt_booleval().

Here is the call graph for this function:

int rt_booleval ( register union tree treep,
struct partition partp,
struct region **  trueregp,
struct resource resp 
)

Using a stack to recall state, evaluate a boolean expression without recursion.

For use with XOR, a pointer to the "first valid subtree" would be a useful addition, for rt_boolregions().

Returns - !0 tree is BOOL_TRUE 0 tree is BOOL_FALSE -1 tree is in error (GUARD)

Definition at line 1335 of file bool.c.

References BOOL_FALSE, BOOL_TRUE, bu_log(), BU_PTBL_FOR, OP_GUARD, OP_INTERSECT, OP_NOP, OP_NOT, OP_SOLID, OP_SUBTRACT, OP_UNION, OP_XNOP, OP_XOR, partition::pt_seglist, resource::re_boolslen, resource::re_boolstack, resource::re_cpu, REGION_NULL, RT_CK_PT, RT_CK_RESOURCE, RT_CK_TREE, rt_grow_boolstack(), tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tr_a, tree::tr_b, tr_regionp, TREE_NULL, and tree::tree_leaf::tu_stp.

Referenced by rt_boolfinal().

Here is the call graph for this function:

double rt_reldiff ( double  a,
double  b 
)

Definition at line 1916 of file bool.c.

References ZERO.