srb.c File Reference

#include "srb.h"

Go to the source code of this file.

Data Structures

struct  _SRBVERTEX
struct  _SRBEDGE
struct  _SRBTRIANGLE
struct  _SRBRAY
struct  _SRBPYRAMID
struct  _SRB

Defines

#define _SRB_ARRAY_LENGTH(array)   ( sizeof( (array) ) / sizeof( (array)[ 0 ] ) )
#define _SRB_MIN3(a, b, c)   ( ( a < b ) ? ( ( a < c ) ? 0 : 2 ) : ( ( b < c ) ? 1 : 2 ) )
#define _SRB_DISTANCE_SQUARED(x1, y1, z1, x2, y2, z2)
#define _SRB_VERTEX(vertices, at)   ( (vertices) + ( 3 * (at) ) )
#define _SRB_TRIANGLE(triangles, at)   ( (triangles) + ( 3 * (at) ) )
#define _SRB_EDGE_MIDPOINT(E, _x, _y, _z)
#define _SRB_EDGE_FIND_CHILD(P, V1, V2, E)   ( (E) = _SRB_IS_EDGE( (P)->E1, (V1), (V2) ) ? (P)->E1 : (P)->E2 )
#define _SRB_IS_EDGE(E, _V1, _V2)   ( ( (E)->V1 == (_V1) && (E)->V2 == (_V2) ) || ( (E)->V1 == (_V2) && (E)->V2 == (_V1) ) )
#define _SRB_TRIANGLE_CENTER(T, _x, _y, _z)

Typedefs

typedef _SRBVERTEX SRBVERTEX
typedef _SRBEDGE SRBEDGE
typedef _SRBTRIANGLE SRBTRIANGLE
typedef _SRBRAY SRBRAY
typedef _SRBPYRAMID SRBPYRAMID
typedef _SRB SRB

Functions

static SRBVERTEX_srb_vertex_new (SRB *srb, double x, double y, double z)
static SRBVERTEX_srb_vertex_new_at (SRB *srb, int at, double x, double y, double z)
static SRBVERTEX_srb_vertex_at (SRB *srb, int at)
static SRBEDGE_srb_edge_new (SRB *srb, SRBVERTEX *V1, SRBVERTEX *V2)
static SRBEDGE_srb_edge_new_at_tail (SRB *srb, SRBVERTEX *V1, SRBVERTEX *V2)
static SRBEDGE_srb_edge_find (SRB *srb, SRBVERTEX *V1, SRBVERTEX *V2)
static SRBEDGE_srb_edge_new_unique (SRB *srb, SRBVERTEX *V1, SRBVERTEX *V2)
static void _srb_edge_set_triangle (SRBEDGE *E, SRBTRIANGLE *T)
static SRBTRIANGLE_srb_triangle_new (SRB *srb, SRBEDGE *E1, SRBEDGE *E2, SRBEDGE *E3, SRBVERTEX *V1, SRBVERTEX *V2, SRBVERTEX *V3)
static void _srb_init (SRB *srb, SRBPARAMS *params)
static int _srb_init_2d (SRB *srb, SRBPARAMS *params, double *vertices, int vertex_count)
static int _srb_init_3d (SRB *srb, SRBPARAMS *params, double *vertices, int vertex_count, int *triangles, int triangle_count)
static _srb_finalize (SRB *srb)
static void _srb_set_midpoint_2d (SRBEDGE *E, SRBVERTEX *V, SRBPARAMS *params)
static int _srb_tesselate_2d (SRB *srb, SRBEDGE *E, SRBPARAMS *params)
static int _srb_tesselate_3d (SRB *srb, SRBTRIANGLE *T)
static void _srb_mesh_delete (SRBMESH *mesh)
static SRBMESH_srb_mesh_new (int vertex_count, int triangle_count)
static void _srb_fan_delete (SRBFAN *fan)
static SRBFAN_srb_fan_new (int vertex_count)
static void _srb_pyramid_face_area (SRBPYRAMID *triangle)
static void _srb_pyramid_volume_and_surface_area (SRBPYRAMID *pyramid)
static SRBMESH_srb_to_mesh (SRB *srb, SRBPARAMS *params)
static SRBFAN_srb_to_fan (SRB *srb, SRBPARAMS *params)
double _srb_interpolate_3d (SRBPARAMS *params, double x, double y, double z)
double _srb_interpolate_2d (SRBPARAMS *params, double x, double y, double z, int dir)
void _srb_cast_ray (SRBRAY *ray, SRBPARAMS *params)
static void _srb_initial_cast (SRB *srb, SRBPARAMS *params)
static int _srb_cast_2d (SRB *srb, SRBPARAMS *params)
static int _srb_cast_3d (SRB *srb, SRBPARAMS *params)
static void _srb_tolerance_cast (SRB *srb, SRBPARAMS *params, double x, double y, double z, double *sum_dm, double *sum_dc_minus_dm)
static int _srb_has_converged (SRB *srb, SRBPARAMS *params, double sum_dm, double sum_dc_minus_dm)
static int _srb_has_converged_3d (SRB *srb, SRBPARAMS *params)
static int _srb_has_converged_2d (SRB *srb, SRBPARAMS *params)
SRBMESHsrb_run_3d (SRBPARAMS *params)
SRBFANsrb_run_2d (SRBPARAMS *params)
void srb_mesh_destroy (SRBMESH *mesh)
void srb_fan_destroy (SRBFAN *fan)

Variables

static double ____srb_octahedron_vertices [6 *3]
static int ____srb_octahedron_triangles [8 *3]
static double ____srb_quadrilateral_vertices [4 *3]


Define Documentation

#define _SRB_ARRAY_LENGTH ( array   )     ( sizeof( (array) ) / sizeof( (array)[ 0 ] ) )

Definition at line 33 of file srb.c.

#define _SRB_MIN3 ( a,
b,
 )     ( ( a < b ) ? ( ( a < c ) ? 0 : 2 ) : ( ( b < c ) ? 1 : 2 ) )

Definition at line 37 of file srb.c.

#define _SRB_DISTANCE_SQUARED ( x1,
y1,
z1,
x2,
y2,
z2   ) 

Value:

( ( (x2) - (x1) ) * ( (x2) - (x1) ) +\
     ( (y2) - (y1) ) * ( (y2) - (y1) ) +\
     ( (z2) - (z1) ) * ( (z2) - (z1) )   )

Definition at line 41 of file srb.c.

#define _SRB_VERTEX ( vertices,
at   )     ( (vertices) + ( 3 * (at) ) )

Definition at line 50 of file srb.c.

#define _SRB_TRIANGLE ( triangles,
at   )     ( (triangles) + ( 3 * (at) ) )

Definition at line 53 of file srb.c.

#define _SRB_EDGE_MIDPOINT ( E,
_x,
_y,
_z   ) 

Value:

(_x) = ( (E)->V1->x + (E)->V2->x ) / 2.0;\
   (_y) = ( (E)->V1->y + (E)->V2->y ) / 2.0;\
   (_z) = ( (E)->V1->z + (E)->V2->z ) / 2.0

Definition at line 94 of file srb.c.

#define _SRB_EDGE_FIND_CHILD ( P,
V1,
V2,
 )     ( (E) = _SRB_IS_EDGE( (P)->E1, (V1), (V2) ) ? (P)->E1 : (P)->E2 )

Definition at line 100 of file srb.c.

#define _SRB_IS_EDGE ( E,
_V1,
_V2   )     ( ( (E)->V1 == (_V1) && (E)->V2 == (_V2) ) || ( (E)->V1 == (_V2) && (E)->V2 == (_V1) ) )

Definition at line 105 of file srb.c.

#define _SRB_TRIANGLE_CENTER ( T,
_x,
_y,
_z   ) 

Value:

(_x) = ( (T)->V1->x + (T)->V2->x + (T)->V3->x ) / 3.0;\
   (_y) = ( (T)->V1->y + (T)->V2->y + (T)->V3->y ) / 3.0;\
   (_z) = ( (T)->V1->z + (T)->V2->z + (T)->V3->z ) / 3.0

Definition at line 122 of file srb.c.


Typedef Documentation

typedef struct _SRBVERTEX SRBVERTEX

Definition at line 60 of file srb.c.

typedef struct _SRBEDGE SRBEDGE

Definition at line 63 of file srb.c.

typedef struct _SRBTRIANGLE SRBTRIANGLE

Definition at line 66 of file srb.c.

typedef struct _SRBRAY SRBRAY

typedef struct _SRBPYRAMID SRBPYRAMID

typedef struct _SRB SRB


Function Documentation

static SRBVERTEX* _srb_vertex_new ( SRB srb,
double  x,
double  y,
double  z 
) [static]

Definition at line 180 of file srb.c.

static SRBVERTEX* _srb_vertex_new_at ( SRB srb,
int  at,
double  x,
double  y,
double  z 
) [static]

Definition at line 204 of file srb.c.

static SRBVERTEX* _srb_vertex_at ( SRB srb,
int  at 
) [static]

Definition at line 234 of file srb.c.

static SRBEDGE* _srb_edge_new ( SRB srb,
SRBVERTEX V1,
SRBVERTEX V2 
) [static]

Definition at line 250 of file srb.c.

static SRBEDGE* _srb_edge_new_at_tail ( SRB srb,
SRBVERTEX V1,
SRBVERTEX V2 
) [static]

Definition at line 279 of file srb.c.

static SRBEDGE* _srb_edge_find ( SRB srb,
SRBVERTEX V1,
SRBVERTEX V2 
) [static]

Definition at line 307 of file srb.c.

static SRBEDGE* _srb_edge_new_unique ( SRB srb,
SRBVERTEX V1,
SRBVERTEX V2 
) [static]

Definition at line 323 of file srb.c.

static void _srb_edge_set_triangle ( SRBEDGE E,
SRBTRIANGLE T 
) [static]

Definition at line 334 of file srb.c.

static SRBTRIANGLE* _srb_triangle_new ( SRB srb,
SRBEDGE E1,
SRBEDGE E2,
SRBEDGE E3,
SRBVERTEX V1,
SRBVERTEX V2,
SRBVERTEX V3 
) [static]

Definition at line 344 of file srb.c.

static void _srb_init ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 375 of file srb.c.

static int _srb_init_2d ( SRB srb,
SRBPARAMS params,
double *  vertices,
int  vertex_count 
) [static]

Definition at line 394 of file srb.c.

static int _srb_init_3d ( SRB srb,
SRBPARAMS params,
double *  vertices,
int  vertex_count,
int *  triangles,
int  triangle_count 
) [static]

Definition at line 453 of file srb.c.

static _srb_finalize ( SRB srb  )  [static]

Definition at line 505 of file srb.c.

static void _srb_set_midpoint_2d ( SRBEDGE E,
SRBVERTEX V,
SRBPARAMS params 
) [static]

Definition at line 542 of file srb.c.

static int _srb_tesselate_2d ( SRB srb,
SRBEDGE E,
SRBPARAMS params 
) [static]

Definition at line 577 of file srb.c.

static int _srb_tesselate_3d ( SRB srb,
SRBTRIANGLE T 
) [static]

Definition at line 629 of file srb.c.

static void _srb_mesh_delete ( SRBMESH mesh  )  [static]

Definition at line 765 of file srb.c.

static SRBMESH* _srb_mesh_new ( int  vertex_count,
int  triangle_count 
) [static]

Definition at line 773 of file srb.c.

static void _srb_fan_delete ( SRBFAN fan  )  [static]

Definition at line 799 of file srb.c.

static SRBFAN* _srb_fan_new ( int  vertex_count  )  [static]

Definition at line 806 of file srb.c.

static void _srb_pyramid_face_area ( SRBPYRAMID triangle  )  [static]

Definition at line 830 of file srb.c.

static void _srb_pyramid_volume_and_surface_area ( SRBPYRAMID pyramid  )  [static]

Definition at line 856 of file srb.c.

static SRBMESH* _srb_to_mesh ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 896 of file srb.c.

static SRBFAN* _srb_to_fan ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 996 of file srb.c.

double _srb_interpolate_3d ( SRBPARAMS params,
double  x,
double  y,
double  z 
)

Definition at line 1107 of file srb.c.

double _srb_interpolate_2d ( SRBPARAMS params,
double  x,
double  y,
double  z,
int  dir 
)

Definition at line 1169 of file srb.c.

void _srb_cast_ray ( SRBRAY ray,
SRBPARAMS params 
)

Definition at line 1256 of file srb.c.

static void _srb_initial_cast ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 1329 of file srb.c.

static int _srb_cast_2d ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 1360 of file srb.c.

static int _srb_cast_3d ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 1413 of file srb.c.

static void _srb_tolerance_cast ( SRB srb,
SRBPARAMS params,
double  x,
double  y,
double  z,
double *  sum_dm,
double *  sum_dc_minus_dm 
) [static]

Definition at line 1467 of file srb.c.

static int _srb_has_converged ( SRB srb,
SRBPARAMS params,
double  sum_dm,
double  sum_dc_minus_dm 
) [static]

Definition at line 1509 of file srb.c.

static int _srb_has_converged_3d ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 1525 of file srb.c.

static int _srb_has_converged_2d ( SRB srb,
SRBPARAMS params 
) [static]

Definition at line 1551 of file srb.c.

SRBMESH* srb_run_3d ( SRBPARAMS params  ) 

Definition at line 1602 of file srb.c.

SRBFAN* srb_run_2d ( SRBPARAMS params  ) 

Definition at line 1654 of file srb.c.

void srb_mesh_destroy ( SRBMESH mesh  ) 

Definition at line 1693 of file srb.c.

void srb_fan_destroy ( SRBFAN fan  ) 

Definition at line 1697 of file srb.c.


Variable Documentation

double ____srb_octahedron_vertices[6 *3] [static]

Initial value:

   { 
   1.0, 0.0, 0.0,
   0.0, 1.0, 0.0,
   -1.0, 0.0, 0.0,
   0.0, -1.0, 0.0,
   0.0, 0.0, 1.0,
   0.0, 0.0, -1.0
   }

Definition at line 1577 of file srb.c.

int ____srb_octahedron_triangles[8 *3] [static]

Initial value:

   { 
   0, 1, 4,
   1, 2, 4,
   2, 3, 4,
   3, 0, 4,
   1, 0, 5,
   2, 1, 5,
   3, 2, 5,
   0, 3, 5
   }

Definition at line 1589 of file srb.c.

double ____srb_quadrilateral_vertices[4 *3] [static]

Initial value:

   { 
   1.0, 0.0, 0.0,
   0.0, 1.0, 0.0,
   -1.0, 0.0, 0.0,
   0.0, -1.0, 0.0
   }

Definition at line 1645 of file srb.c.


Generated on Mon Jan 7 13:34:11 2008 for Rayburst Open-Source Code by  doxygen 1.4.7