g_vol.c File Reference

#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include "machine.h"
#include "vmath.h"
#include "db.h"
#include "nmg.h"
#include "rtgeom.h"
#include "raytrace.h"
#include "./debug.h"
#include "./fixpt.h"

Include dependency graph for g_vol.c:

Go to the source code of this file.

Data Structures

struct  rt_vol_specific

Defines

#define VOL_NULL   ((struct rt_vol_specific *)0)
#define VOL_O(m)   bu_offsetof(struct rt_vol_internal, m)
#define NORM_ZPOS   3
#define NORM_YPOS   2
#define NORM_XPOS   1
#define NORM_XNEG   (-1)
#define NORM_YNEG   (-2)
#define NORM_ZNEG   (-3)
#define VOL_XWIDEN   2
#define VOL_YWIDEN   2
#define VOL_ZWIDEN   2
#define VOL(_vip, _xx, _yy, _zz)
#define OK(_vip, _v)   ( (int)(_v) >= (_vip)->lo && (int)(_v) <= (_vip)->hi )

Functions

void rt_vol_plate (point_t a, point_t b, point_t c, point_t d, mat_t mat, struct bu_list *vhead, struct rt_vol_internal *vip)
int rt_vol_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
int rt_vol_import (struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
int rt_vol_export (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_vol_import5 (struct rt_db_internal *ip, const struct bu_external *ep, const fastf_t *mat, const struct db_i *dbip)
int rt_vol_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_vol_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
void rt_vol_ifree (struct rt_db_internal *ip)
int rt_vol_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
void rt_vol_print (register const struct soltab *stp)
void rt_vol_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
void rt_vol_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
void rt_vol_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
void rt_vol_free (struct soltab *stp)
int rt_vol_class (void)
int rt_vol_plot (struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
void rt_vol_plate (fastf_t *a, fastf_t *b, fastf_t *c, fastf_t *d, register fastf_t *mat, register struct bu_list *vhead, register struct rt_vol_internal *vip)
int rt_vol_tess (struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)

Variables

const struct bu_structparse rt_vol_parse []


Detailed Description

Intersect a ray with a 3-D volume. The volume is described as a concatenation of bw(5) files.

Authors - Michael John Muuss Phil Dykstra

Source - SECAD/VLD Computing Consortium, Bldg 394 The U. S. Army Ballistic Research Laboratory Aberdeen Proving Ground, Maryland 21005

Definition in file g_vol.c.


Define Documentation

#define VOL_NULL   ((struct rt_vol_specific *)0)
 

Definition at line 78 of file g_vol.c.

#define VOL_O  )     bu_offsetof(struct rt_vol_internal, m)
 

Definition at line 80 of file g_vol.c.

#define NORM_ZPOS   3
 

Definition at line 107 of file g_vol.c.

#define NORM_YPOS   2
 

Definition at line 108 of file g_vol.c.

#define NORM_XPOS   1
 

Definition at line 109 of file g_vol.c.

#define NORM_XNEG   (-1)
 

Definition at line 110 of file g_vol.c.

#define NORM_YNEG   (-2)
 

Definition at line 111 of file g_vol.c.

#define NORM_ZNEG   (-3)
 

Definition at line 112 of file g_vol.c.

#define VOL_XWIDEN   2
 

Definition at line 120 of file g_vol.c.

Referenced by rt_vol_import(), and rt_vol_import5().

#define VOL_YWIDEN   2
 

Definition at line 121 of file g_vol.c.

Referenced by rt_vol_import(), and rt_vol_import5().

#define VOL_ZWIDEN   2
 

Definition at line 122 of file g_vol.c.

Referenced by rt_vol_import(), and rt_vol_import5().

#define VOL _vip,
_xx,
_yy,
_zz   ) 
 

Value:

(_vip)->map[ \
        (((_zz)+VOL_ZWIDEN) * ((_vip)->ydim + VOL_YWIDEN*2)+ \
         ((_yy)+VOL_YWIDEN))* ((_vip)->xdim + VOL_XWIDEN*2)+ \
          (_xx)+VOL_XWIDEN ]

Definition at line 123 of file g_vol.c.

Referenced by rt_vol_import(), rt_vol_import5(), rt_vol_plot(), rt_vol_shot(), and rt_vol_tess().

#define OK _vip,
_v   )     ( (int)(_v) >= (_vip)->lo && (int)(_v) <= (_vip)->hi )
 

Definition at line 128 of file g_vol.c.

Referenced by rt_vol_plot(), rt_vol_shot(), and rt_vol_tess().


Function Documentation

void rt_vol_plate point_t  a,
point_t  b,
point_t  c,
point_t  d,
mat_t  mat,
struct bu_list vhead,
struct rt_vol_internal vip
 

int rt_vol_shot struct soltab stp,
register struct xray rp,
struct application ap,
struct seg seghead
 

R T _ V O L _ S H O T

Transform the ray into local coordinates of the volume ("ideal space"). Step through the 3-D array, in local coordinates. Return intersection segments.

Definition at line 142 of file g_vol.c.

References application::a_resource, BU_LIST_INSERT, BU_LIST_IS_EMPTY, BU_LIST_LAST, bu_log(), rt_vol_internal::cellsize, DEBUG_VOL, hit::hit_dist, hit::hit_surfno, INFINITY, seg::l, MAT4X3PNT, MAT4X3VEC, NEAR_ZERO, OK, RT_G_DEBUG, RT_GET_SEG, rt_in_rpp(), seg::seg_in, seg::seg_stp, SQRT_SMALL_FASTF, soltab::st_specific, tail, val, VJOIN1, VOL, rt_vol_specific::vol_i, rt_vol_specific::vol_large, rt_vol_specific::vol_mat, rt_vol_specific::vol_origin, VPRINT, VSETALL, X, rt_vol_internal::xdim, Y, rt_vol_internal::ydim, Z, and rt_vol_internal::zdim.

Here is the call graph for this function:

int rt_vol_import struct rt_db_internal ip,
const struct bu_external ep,
const fastf_t mat,
const struct db_i dbip
 

R T _ V O L _ I M P O R T

Read in the information from the string solid record. Then, as a service to the application, read in the bitmap and set up some of the associated internal variables.

Definition at line 424 of file g_vol.c.

References bn_mat_mul(), bu_calloc(), BU_CK_EXTERNAL, bu_log(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), bu_struct_parse(), bu_struct_print(), bu_vls_free(), bu_vls_init(), bu_vls_strcpy(), rt_vol_internal::cellsize, DB5_MAJORTYPE_BRLCAD, DBID_STRSOL, bu_external::ext_buf, fp, rt_vol_internal::hi, ID_VOL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, rt_vol_internal::lo, rt_vol_internal::magic, rt_vol_internal::mat, MAT_COPY, MAT_IDN, NULL, perror(), RT_CK_DB_INTERNAL, RT_VOL_INTERNAL_MAGIC, rt_vol_parse, record::ss, record::strsol::ss_args, record::u_id, VOL, VOL_XWIDEN, VOL_YWIDEN, VOL_ZWIDEN, and VSETALL.

Here is the call graph for this function:

int rt_vol_export struct bu_external ep,
const struct rt_db_internal ip,
double  local2mm,
const struct db_i dbip
 

R T _ V O L _ E X P O R T

The name will be added by the caller.

Definition at line 522 of file g_vol.c.

References bu_calloc(), BU_CK_EXTERNAL, bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_struct_print(), DB_SS_LEN, DB_SS_NGRAN, DBID_STRSOL, bu_external::ext_buf, bu_external::ext_nbytes, ID_VOL, rt_db_internal::idb_ptr, rt_vol_internal::mat, NAMESIZE, RT_CK_DB_INTERNAL, RT_VOL_CK_MAGIC, rt_vol_parse, record::ss, record::strsol::ss_args, record::strsol::ss_id, and record::strsol::ss_keyword.

Here is the call graph for this function:

int rt_vol_import5 struct rt_db_internal ip,
const struct bu_external ep,
const fastf_t mat,
const struct db_i dbip
 

R T _ V O L _ I M P O R T 5

Read in the information from the string solid record. Then, as a service to the application, read in the bitmap and set up some of the associated internal variables.

Definition at line 562 of file g_vol.c.

References bn_mat_mul(), bu_calloc(), BU_CK_EXTERNAL, bu_log(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), bu_struct_parse(), bu_struct_print(), bu_vls_free(), bu_vls_init(), bu_vls_strncpy(), rt_vol_internal::cellsize, DB5_MAJORTYPE_BRLCAD, bu_external::ext_buf, bu_external::ext_nbytes, fp, rt_vol_internal::hi, ID_VOL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, rt_vol_internal::lo, rt_vol_internal::magic, rt_vol_internal::mat, MAT_COPY, MAT_IDN, NULL, perror(), RT_CK_DB_INTERNAL, RT_VOL_INTERNAL_MAGIC, rt_vol_parse, VOL, VOL_XWIDEN, VOL_YWIDEN, VOL_ZWIDEN, and VSETALL.

Here is the call graph for this function:

int rt_vol_export5 struct bu_external ep,
const struct rt_db_internal ip,
double  local2mm,
const struct db_i dbip
 

R T _ V O L _ E X P O R T 5

The name will be added by the caller.

Definition at line 654 of file g_vol.c.

References bu_calloc(), BU_CK_EXTERNAL, bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strlen(), bu_vls_struct_print(), bu_external::ext_buf, bu_external::ext_nbytes, ID_VOL, rt_db_internal::idb_ptr, rt_vol_internal::mat, RT_CK_DB_INTERNAL, RT_VOL_CK_MAGIC, and rt_vol_parse.

Here is the call graph for this function:

int rt_vol_describe struct bu_vls str,
const struct rt_db_internal ip,
int  verbose,
double  mm2local
 

R T _ V O L _ D E S C R I B E

Make human-readable formatted presentation of this solid. First line describes type of solid. Additional lines are indented one tab, and give parameter values.

Definition at line 690 of file g_vol.c.

References bu_vls_init(), bu_vls_printf(), bu_vls_strcat(), bu_vls_trunc2(), bu_vls_vlscat(), rt_db_internal::idb_ptr, INTCLAMP, RT_VOL_CK_MAGIC, V3INTCLAMPARGS, and VSCALE.

Here is the call graph for this function:

void rt_vol_ifree struct rt_db_internal ip  ) 
 

R T _ V O L _ I F R E E

Free the storage associated with the rt_db_internal version of this solid.

Definition at line 732 of file g_vol.c.

References bu_free(), GENPTR_NULL, rt_db_internal::idb_ptr, rt_vol_internal::magic, rt_vol_internal::map, RT_CK_DB_INTERNAL, and RT_VOL_CK_MAGIC.

Here is the call graph for this function:

int rt_vol_prep struct soltab stp,
struct rt_db_internal ip,
struct rt_i rtip
 

R T _ V O L _ P R E P

Returns - 0 OK !0 Failure

Implicit return - A struct rt_vol_specific is created, and it's address is stored in stp->st_specific for use by rt_vol_shot().

Definition at line 760 of file g_vol.c.

References bn_mat_inv(), bn_rotate_bbox(), BU_GETSTRUCT, rt_vol_internal::cellsize, rt_db_internal::idb_ptr, MAGNITUDE, rt_vol_internal::map, rt_vol_internal::mat, MAT3X3VEC, RT_VOL_CK_MAGIC, soltab::st_aradius, soltab::st_bradius, soltab::st_center, soltab::st_max, soltab::st_min, soltab::st_specific, VADD2, VADD2SCALE, rt_vol_specific::vol_i, rt_vol_specific::vol_large, rt_vol_specific::vol_mat, rt_vol_specific::vol_origin, rt_vol_specific::vol_xnorm, rt_vol_specific::vol_ynorm, rt_vol_specific::vol_znorm, VSCALE, VSET, VSETALL, VSUB2, rt_vol_internal::xdim, rt_vol_internal::ydim, and rt_vol_internal::zdim.

Here is the call graph for this function:

void rt_vol_print register const struct soltab stp  ) 
 

R T _ V O L _ P R I N T

Definition at line 813 of file g_vol.c.

References bu_log(), rt_vol_internal::cellsize, rt_vol_internal::file, rt_vol_specific::vol_i, rt_vol_specific::vol_origin, VPRINT, rt_vol_internal::xdim, rt_vol_internal::ydim, and rt_vol_internal::zdim.

Here is the call graph for this function:

void rt_vol_norm register struct hit hitp,
struct soltab stp,
register struct xray rp
 

R T _ V O L _ N O R M

Given one ray distance, return the normal and entry/exit point. This is mostly a matter of translating the stored code into the proper normal.

Definition at line 835 of file g_vol.c.

References bu_log(), NORM_XNEG, NORM_XPOS, NORM_YNEG, NORM_YPOS, NORM_ZNEG, NORM_ZPOS, soltab::st_specific, VJOIN1, VMOVE, rt_vol_specific::vol_xnorm, rt_vol_specific::vol_ynorm, rt_vol_specific::vol_znorm, VREVERSE, and VSETALL.

Here is the call graph for this function:

void rt_vol_curve register struct curvature cvp,
register struct hit hitp,
struct soltab stp
 

R T _ V O L _ C U R V E

Everything has sharp edges. This makes things easy.

Definition at line 878 of file g_vol.c.

References bn_vec_ortho().

Here is the call graph for this function:

void rt_vol_uv struct application ap,
struct soltab stp,
register struct hit hitp,
register struct uvcoord uvp
 

R T _ V O L _ U V

Map the hit point in 2-D into the range 0..1 untransformed X becomes U, and Y becomes V.

Definition at line 894 of file g_vol.c.

void rt_vol_free struct soltab stp  ) 
 

R T _ V O L _ F R E E

Definition at line 906 of file g_vol.c.

References bu_free(), rt_vol_internal::map, soltab::st_specific, and rt_vol_specific::vol_i.

Here is the call graph for this function:

int rt_vol_class void   ) 
 

Definition at line 916 of file g_vol.c.

int rt_vol_plot struct bu_list vhead,
struct rt_db_internal ip,
const struct rt_tess_tol ttol,
const struct bn_tol tol
 

R T _ V O L _ P L O T

Definition at line 925 of file g_vol.c.

References rt_db_internal::idb_ptr, OK, RT_CK_DB_INTERNAL, RT_VOL_CK_MAGIC, VOL, VSET, rt_vol_internal::xdim, rt_vol_internal::ydim, and rt_vol_internal::zdim.

void rt_vol_plate fastf_t a,
fastf_t b,
fastf_t c,
fastf_t d,
register fastf_t mat,
register struct bu_list vhead,
register struct rt_vol_internal vip
 

R T _ V O L _ P L A T E

Definition at line 1021 of file g_vol.c.

References BN_VLIST_LINE_DRAW, BN_VLIST_LINE_MOVE, LOCAL, MAT4X3PNT, RT_ADD_VLIST, and VELMUL.

int rt_vol_tess struct nmgregion **  r,
struct model m,
struct rt_db_internal ip,
const struct rt_tess_tol ttol,
const struct bn_tol tol
 

R T _ V O L _ T E S S

Definition at line 1049 of file g_vol.c.

References BN_CK_TOL, BU_LIST_FIRST, rt_vol_internal::cellsize, rt_db_internal::idb_ptr, rt_vol_internal::mat, MAT4X3PNT, nmg_cface(), NMG_CK_MODEL, nmg_fu_planeeqn(), nmg_mm(), nmg_mrsv(), nmg_vertex_gv(), NULL, OK, RT_CK_DB_INTERNAL, RT_CK_TESS_TOL, RT_VOL_CK_MAGIC, nmgregion::s_hd, VELMUL, VOL, VSET, rt_vol_internal::xdim, rt_vol_internal::ydim, and rt_vol_internal::zdim.

Here is the call graph for this function:


Variable Documentation

const struct bu_structparse rt_vol_parse[]
 

Initial value:

 {



        {"%s",  RT_VOL_NAME_LEN, "file",        bu_offsetofarray(struct rt_vol_internal, file), BU_STRUCTPARSE_FUNC_NULL },

        {"%d",  1, "w",         VOL_O(xdim),    BU_STRUCTPARSE_FUNC_NULL },
        {"%d",  1, "n",         VOL_O(ydim),    BU_STRUCTPARSE_FUNC_NULL },
        {"%d",  1, "d",         VOL_O(zdim),    BU_STRUCTPARSE_FUNC_NULL },
        {"%d",  1, "lo",        VOL_O(lo),              BU_STRUCTPARSE_FUNC_NULL },
        {"%d",  1, "hi",        VOL_O(hi),              BU_STRUCTPARSE_FUNC_NULL },
        {"%f",  ELEMENTS_PER_VECT, "size",bu_offsetofarray(struct rt_vol_internal, cellsize), BU_STRUCTPARSE_FUNC_NULL },
        {"%f",  16, "mat", bu_offsetofarray(struct rt_vol_internal,mat), BU_STRUCTPARSE_FUNC_NULL },
        {"",    0, (char *)0,   0,                      BU_STRUCTPARSE_FUNC_NULL }
}

Definition at line 82 of file g_vol.c.

Referenced by rt_vol_export(), rt_vol_export5(), rt_vol_import(), and rt_vol_import5().


Generated on Mon Sep 18 01:25:06 2006 for BRL-CAD by  doxygen 1.4.6