BRL-CAD
tie.c File Reference
#include "tie.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "bio.h"
#include "tieprivate.h"
Include dependency graph for tie.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIE_TAB1   "\1\0\0\2\2\1" /* Triangle Index Table */
 
#define TIE_DEGENERATE_THRESHOLD   0.0001
 

Functions

void TIE_VAL() tie_init (struct tie_s *tie, unsigned int tri_num, unsigned int kdmethod)
 
void TIE_VAL() tie_free (struct tie_s *tie)
 
void TIE_VAL() tie_prep (struct tie_s *tie)
 
void *TIE_VAL() tie_work (struct tie_s *tie, struct tie_ray_s *ray, struct tie_id_s *id, void *(*hitfunc)(struct tie_ray_s *, struct tie_id_s *, struct tie_tri_s *, void *ptr), void *ptr)
 
void TIE_VAL() tie_push (struct tie_s *tie, TIE_3 **tlist, unsigned int tnum, void *plist, unsigned int pstride)
 

Detailed Description

tie.c

Definition in file tie.c.

Macro Definition Documentation

#define TIE_TAB1   "\1\0\0\2\2\1" /* Triangle Index Table */

Definition at line 44 of file tie.c.

Referenced by tie_work().

#define TIE_DEGENERATE_THRESHOLD   0.0001

Definition at line 46 of file tie.c.

Function Documentation

void TIE_VAL() tie_init ( struct tie_s *  tie,
unsigned int  tri_num,
unsigned int  kdmethod 
)

Initialize a struct tie_s data structure

This needs to be called before any other libtie data structures are called.

Parameters
tiepointer to a struct tie_t
tri_numinitial number of triangles to allocate for. tie_push may expand the buffer, if needed.
kdmethodEither TIE_KDTREE_FAST or TIE_KDTREE_OPTIMAL
Returns
void

Definition at line 137 of file tie.c.

References bu_calloc().

Referenced by bottie_allocn_float().

Here is the call graph for this function:

void TIE_VAL() tie_free ( struct tie_s *  tie)

Free up all the stuff associated with libtie

All of the KDTREE nodes and triangles that we have allocated need to be freed in a controlled manner. This routine does that.

Parameters
tiepointer to a struct tie_t
Returns
void

Definition at line 160 of file tie.c.

References bu_free(), and tie_kdtree_free().

Referenced by bottie_free_double(), and bottie_prep_double().

Here is the call graph for this function:

void TIE_VAL() tie_prep ( struct tie_s *  tie)

Get ready to shoot rays at triangles

Build the KDTREE tree for the triangles we have

Parameters
tiepointer to a struct struct tie_s which now has all the triangles in it.
Returns
void

Definition at line 180 of file tie.c.

References tie_kdtree_prep().

Referenced by bottie_prep_float().

Here is the call graph for this function:

void* TIE_VAL() tie_work ( struct tie_s *  tie,
struct tie_ray_s *  ray,
struct tie_id_s *  id,
void *(*)(struct tie_ray_s *, struct tie_id_s *, struct tie_tri_s *, void *ptr)  hitfunc,
void *  ptr 
)

Shoot a ray at some triangles

The user-provided hitfunc is called at each ray/triangle intersection. Calls are guaranteed to be made in the ray-intersection order. The last argument (void *ptr) is passed to the hitfunc as-is, to allow application specific data to be passed to the hitfunc.

Parameters
tiea struct struct tie_s universe
raythe ray to be intersected with the geometry
idthe intersection data for each intersection
hitfuncthe application routine to be called upon ray/triangle intersection.

This function should return 0 if the ray is to continue propagating through the geometry, or non-zero if ray intersection should cease.

Parameters
ptra pointer to be passed to the hitfunc when it is called.
Returns
the return value from the user hitfunc() is used.

In the event that the ray does not hit anything, or the ray exits the geometry space, a null value will be returned.

Return values
0ray did not hit anything, or ray was propagated through the geometry completely.
!0the value returned from the last invocation of hitfunc()

Definition at line 217 of file tie.c.

References data, tie_stack_s::far, tie_stack_s::near, tie_stack_s::node, TIE_HAS_CHILDREN, TIE_PREC, TIE_TAB1, tie_geom_s::tri_list, tie_geom_s::tri_num, OSL::Strings::v, and ZERO.

void TIE_VAL() tie_push ( struct tie_s *  tie,
TIE_3 **  tlist,
unsigned int  tnum,
void *  plist,
unsigned int  pstride 
)

Add a triangle

Add a new triangle to the universe to be raytraced.

Parameters
tiethe universe
tlistis an array of TIE_3 vertex triplets (v0, v1, v2) that form each triangle.
tnumis the number of triangles (tlist = 3 * tnum of TIE_3's).
plistis a list of pointer data that gets assigned to the ptr of each triangle.

This will typically be 4-byte (32-bit architecture) spaced array of pointers that associate the triangle pointer with your arbitrary structure, i.e. a mesh.

Parameters
pstrideis the number of bytes to increment the pointer list as it assigns a pointer to each mesh, typically a value of 4 (for 32-bit machines). If you have a single pointer that groups all triangles to a common structure then you can use a value of 0 for pstride. This will give the pointer of all triangles the pointer address of plist.
Returns
void

Definition at line 446 of file tie.c.

References bu_log(), bu_realloc(), tie_check_degenerate, OSL::Strings::u, OSL::Strings::v, and V3ARGS.

Here is the call graph for this function: