g_submodel.c File Reference

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

Include dependency graph for g_submodel.c:

Go to the source code of this file.

Data Structures

struct  submodel_specific
struct  submodel_gobetween
struct  goodies

Defines

#define RT_SUBMODEL_O(m)   bu_offsetof(struct rt_submodel_internal, m)
#define RT_SUBMODEL_SPECIFIC_MAGIC   0x73756253
#define RT_CK_SUBMODEL_SPECIFIC(_p)   BU_CKMAG(_p,RT_SUBMODEL_SPECIFIC_MAGIC,"submodel_specific")
#define RT_SUBMODEL_SEG_MISS(SEG)   (SEG).seg_stp=RT_SOLTAB_NULL

Functions

int rt_submodel_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
void rt_submodel_print (register const struct soltab *stp)
int rt_submodel_a_miss (struct application *ap)
int rt_submodel_a_hit (struct application *ap, struct partition *PartHeadp, struct seg *segHeadp)
int rt_submodel_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
void rt_submodel_vshot (struct soltab **stp, struct xray **rp, struct seg *segp, int n, struct application *ap)
void rt_submodel_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
void rt_submodel_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
void rt_submodel_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
void rt_submodel_free (register struct soltab *stp)
int rt_submodel_class (const struct soltab *stp, const fastf_t *min, const fastf_t *max, const struct bn_tol *tol)
HIDDEN union treert_submodel_wireframe_leaf (struct db_tree_state *tsp, struct db_full_path *pathp, struct rt_db_internal *ip, genptr_t client_data)
int rt_submodel_plot (struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
int rt_submodel_tess (struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
int rt_submodel_import (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
int rt_submodel_export (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_submodel_import5 (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
int rt_submodel_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_submodel_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
void rt_submodel_ifree (struct rt_db_internal *ip)

Variables

const struct bu_structparse rt_submodel_parse []


Detailed Description

Intersect a ray with an entire subspace full of geometry, possibly included from another .g file, with a subordinate instance of LIBRT.

This solid is particularly useful when instancing millions of copies of a given complex object, such as a detailed tree.

Author - Michael John Muuss

Source - The U. S. Army Research Laboratory Aberdeen Proving Ground, Maryland 21005-5066

Definition in file g_submodel.c.


Define Documentation

#define RT_SUBMODEL_O  )     bu_offsetof(struct rt_submodel_internal, m)
 

Definition at line 61 of file g_submodel.c.

#define RT_SUBMODEL_SPECIFIC_MAGIC   0x73756253
 

Definition at line 77 of file g_submodel.c.

Referenced by rt_submodel_prep().

#define RT_CK_SUBMODEL_SPECIFIC _p   )     BU_CKMAG(_p,RT_SUBMODEL_SPECIFIC_MAGIC,"submodel_specific")
 

Definition at line 78 of file g_submodel.c.

Referenced by rt_submodel_a_hit(), rt_submodel_free(), rt_submodel_print(), and rt_submodel_shot().

#define RT_SUBMODEL_SEG_MISS SEG   )     (SEG).seg_stp=RT_SOLTAB_NULL
 

Definition at line 536 of file g_submodel.c.


Function Documentation

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

R T _ S U B M O D E L _ P R E P

Given a pointer to a GED database record, and a transformation matrix, determine if this is a valid SUBMODEL, and if so, precompute various terms of the formula.

Returns - 0 SUBMODEL is OK !0 Error in description

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

Definition at line 97 of file g_submodel.c.

References bu_ptbl::blen, bn_mat_inv(), bn_rotate_bbox(), BU_GETSTRUCT, bu_log(), BU_PTBL_FOR, BU_PTBL_LEN, BU_PTBL_SET, bu_semaphore_acquire(), bu_semaphore_release(), bu_vls_addr(), bu_vls_strdup(), bu_vls_strlen(), directory::d_namep, db_close(), db_dirbuild(), db_is_directory_non_empty(), db_open(), db_i::dbi_clients, db_i::dbi_filename, db_i::dbi_mf, DBI_NULL, DEBUG_DB, DEBUG_SOLIDS, bu_mapped_file::dont_restat, rt_submodel_internal::file, rt_db_internal::idb_ptr, submodel_specific::m2subm, submodel_specific::magic, MAGNITUDE, MAT_COPY, rt_submodel_internal::meth, rt_i::nsolids, NULL, rt_submodel_internal::root2leaf, RT_CK_DB_INTERNAL, RT_CK_RTI, RT_G_DEBUG, rt_gettrees(), rt_init_resource(), rt_new_rti(), rt_pr_cut_info(), rt_prep_parallel(), RT_SEM_MODEL, RT_SUBMODEL_CK_MAGIC, RT_SUBMODEL_SPECIFIC_MAGIC, rt_i::rti_dbip, rt_i::rti_dont_instance, rt_i::rti_hasty_prep, rt_i::rti_resources, rt_i::rti_space_partition, rt_i::rti_tol, rt_i::rti_treetop, rt_i::rti_ttol, rt_i::rti_uses, submodel_specific::rtip, soltab::st_aradius, soltab::st_bradius, soltab::st_center, soltab::st_dp, soltab::st_max, soltab::st_min, soltab::st_specific, submodel_specific::subm2m, rt_submodel_internal::treetop, rt_i::useair, VADD2SCALE, VSCALE, and VSUB2.

Here is the call graph for this function:

void rt_submodel_print register const struct soltab stp  ) 
 

R T _ S U B M O D E L _ P R I N T

Definition at line 264 of file g_submodel.c.

References bn_mat_print(), bu_log(), bu_log_indent_delta(), submodel_specific::m2subm, RT_CK_SUBMODEL_SPECIFIC, rt_pr_soltab(), RT_VISIT_ALL_SOLTABS_END, RT_VISIT_ALL_SOLTABS_START, submodel_specific::rtip, and submodel_specific::subm2m.

Here is the call graph for this function:

int rt_submodel_a_miss struct application ap  ) 
 

R T _ S U B M O D E L _ A _ M I S S

Definition at line 289 of file g_submodel.c.

Referenced by rt_submodel_shot().

int rt_submodel_a_hit struct application ap,
struct partition PartHeadp,
struct seg segHeadp
 

R T _ S U B M O D E L _ A _ H I T

Definition at line 305 of file g_submodel.c.

References application::a_ray, application::a_resource, application::a_rt_i, application::a_uptr, BU_ASSERT_DOUBLE, BU_LIST_FOR, BU_LIST_INSERT, bu_log(), BU_PTBL_GET, directory::d_namep, submodel_gobetween::delta, hit::hit_dist, hit::hit_normal, hit::hit_point, hit::hit_rayp, hit::hit_surfno, hit::hit_vpriv, seg::l, MAT3X3VEC, MAT4XSCALOR, partition::pt_inseg, partition::pt_outseg, xray::r_dir, xray::r_pt, RT_AP_CHECK, RT_CK_PT, RT_CK_PT_HD, RT_CK_REGION, RT_CK_RTI, RT_CK_SEG, RT_CK_SOLTAB, RT_CK_SUBMODEL_SPECIFIC, RT_GET_SEG, RT_HIT_UVCOORD, seg::seg_in, seg::seg_out, seg::seg_stp, soltab::st_bit, soltab::st_dp, soltab::st_meth, soltab::st_regions, soltab::st_specific, submodel_specific::subm2m, submodel_gobetween::up_ap, submodel_gobetween::up_seghead, submodel_gobetween::up_stp, uvcoord::uv_du, uvcoord::uv_dv, uvcoord::uv_u, uvcoord::uv_v, VDOT, VJOIN1, VPRINT, X, Y, and Z.

Referenced by rt_submodel_shot().

Here is the call graph for this function:

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

R T _ S U B M O D E L _ S H O T

Intersect a ray with a submodel. If an intersection occurs, a struct seg will be acquired and filled in.

Returns - 0 MISS >0 HIT

Definition at line 464 of file g_submodel.c.

References application::a_ray, application::a_resource, application::a_rt_i, BU_ASSERT_LONG, BU_GETSTRUCT, BU_PTBL_END, BU_PTBL_GET, BU_PTBL_SET, submodel_specific::m2subm, MAT3X3VEC, MAT4X3PNT, NULL, xray::r_dir, xray::r_pt, resource::re_cpu, RT_CK_RESOURCE, RT_CK_RTI, RT_CK_SOLTAB, RT_CK_SUBMODEL_SPECIFIC, rt_init_resource(), rt_shootray(), rt_submodel_a_hit(), rt_submodel_a_miss(), rt_i::rti_resources, submodel_specific::rtip, soltab::st_specific, VDOT, and VSUB2.

Here is the call graph for this function:

void rt_submodel_vshot struct soltab **  stp,
struct xray **  rp,
struct seg segp,
int  n,
struct application ap
 

R T _ S U B M O D E L _ V S H O T

Vectorized version.

Definition at line 544 of file g_submodel.c.

References rt_vstub().

Here is the call graph for this function:

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

R T _ S U B M O D E L _ N O R M

Given ONE ray distance, return the normal and entry/exit point.

Definition at line 560 of file g_submodel.c.

References bu_log(), directory::d_namep, RT_CK_HIT, soltab::st_dp, and VDOT.

Here is the call graph for this function:

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

R T _ S U B M O D E L _ C U R V E

Return the curvature of the submodel.

Definition at line 583 of file g_submodel.c.

References bn_vec_ortho(), and bu_log().

Here is the call graph for this function:

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

R T _ S U B M O D E L _ U V

For a hit on the surface of an submodel, return the (u,v) coordinates of the hit point, 0 <= u,v <= 1. u = azimuth v = elevation

Definition at line 603 of file g_submodel.c.

References RT_CK_HIT, X, Y, and Z.

void rt_submodel_free register struct soltab stp  ) 
 

R T _ S U B M O D E L _ F R E E

Definition at line 616 of file g_submodel.c.

References BU_CK_PTBL, bu_free(), BU_PTBL_FOR, NULL, RT_CK_RESOURCE, RT_CK_RTI, RT_CK_SUBMODEL_SPECIFIC, rt_clean_resource(), rt_free_rti(), rt_uniresource, rt_i::rti_resources, and submodel_specific::rtip.

Here is the call graph for this function:

int rt_submodel_class const struct soltab stp,
const fastf_t min,
const fastf_t max,
const struct bn_tol tol
 

R T _ S U B M O D E L _ C L A S S

Definition at line 650 of file g_submodel.c.

References RT_CLASSIFY_UNIMPLEMENTED.

HIDDEN union tree* rt_submodel_wireframe_leaf struct db_tree_state tsp,
struct db_full_path pathp,
struct rt_db_internal ip,
genptr_t  client_data
 

R T _ S U B M O D E L _ W I R E F R A M E _ L E A F

This routine must be prepared to run in parallel. This routine should be generally exported for other uses.

Definition at line 666 of file g_submodel.c.

References BN_CK_TOL, bu_bomb(), bu_free(), bu_is_parallel(), bu_log(), DB_FULL_PATH_CUR_DIR, db_path_to_string(), goodies::dbip, DEBUG_TREEWALK, rt_functab::ft_name, rt_db_internal::idb_meth, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_RESOURCE, RT_CK_TESS_TOL, RT_G_DEBUG, TREE_NULL, db_tree_state::ts_m, db_tree_state::ts_resp, db_tree_state::ts_tol, db_tree_state::ts_ttol, and goodies::vheadp.

Referenced by rt_submodel_plot().

Here is the call graph for this function:

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

R T _ S U B M O D E L _ P L O T

Not unlike mged/dodraw.c drawtrees()

Note: The submodel will be drawn entirely in one color (for mged, typically this is red), because we can't return a vlblock, only one vlist, which by definition, is all one color.

Definition at line 718 of file g_submodel.c.

References bu_log(), bu_vls_addr(), bu_vls_strlen(), db_close(), db_dirbuild(), db_is_directory_non_empty(), db_open(), db_walk_tree(), DBI_NULL, rt_submodel_internal::dbip, goodies::dbip, rt_submodel_internal::file, rt_db_internal::idb_ptr, LOCAL, MAT_COPY, NULL, rt_submodel_internal::root2leaf, RT_CK_DB_INTERNAL, RT_CK_DBI, rt_initial_tree_state, RT_SUBMODEL_CK_MAGIC, rt_submodel_wireframe_leaf(), state, rt_submodel_internal::treetop, and goodies::vheadp.

Here is the call graph for this function:

int rt_submodel_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 _ S U B M O D E L _ T E S S

Returns - -1 failure 0 OK. *r points to nmgregion that holds this tessellation.

Definition at line 786 of file g_submodel.c.

References rt_db_internal::idb_ptr, LOCAL, RT_CK_DB_INTERNAL, and RT_SUBMODEL_CK_MAGIC.

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

R T _ S U B M O D E L _ I M P O R T

Import an SUBMODEL from the database format to the internal format. Apply modeling transformations as well.

Definition at line 804 of file g_submodel.c.

References bn_mat_print(), BU_CK_EXTERNAL, bu_free(), bu_log(), bu_malloc(), bu_struct_parse(), bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strcpy(), bu_vls_strlen(), DB5_MAJORTYPE_BRLCAD, DBID_STRSOL, rt_submodel_internal::dbip, bu_external::ext_buf, ID_NULL, ID_SUBMODEL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, LOCAL, rt_submodel_internal::magic, MAT_COPY, NULL, rt_submodel_internal::root2leaf, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_SUBMODEL_INTERNAL_MAGIC, rt_submodel_parse, record::ss, record::strsol::ss_args, and record::u_id.

Here is the call graph for this function:

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

R T _ S U B M O D E L _ E X P O R T

The name is added by the caller, in the usual place.

Definition at line 865 of file g_submodel.c.

References BU_ASSERT, bu_calloc(), BU_CK_EXTERNAL, bu_log(), 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, rt_submodel_internal::file, ID_SUBMODEL, rt_db_internal::idb_ptr, rt_submodel_internal::meth, NAMESIZE, RT_CK_DB_INTERNAL, RT_SUBMODEL_CK_MAGIC, rt_submodel_parse, record::ss, record::strsol::ss_args, record::strsol::ss_id, record::strsol::ss_keyword, and rt_submodel_internal::treetop.

Here is the call graph for this function:

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

R T _ S U B M O D E L _ I M P O R T 5

Import an SUBMODEL from the database format to the internal format. Apply modeling transformations as well.

Definition at line 909 of file g_submodel.c.

References bn_mat_print(), BU_CK_EXTERNAL, bu_free(), bu_log(), bu_malloc(), bu_struct_parse(), bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strlen(), bu_vls_strncpy(), DB5_MAJORTYPE_BRLCAD, rt_submodel_internal::dbip, bu_external::ext_buf, bu_external::ext_nbytes, ID_NULL, ID_SUBMODEL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, LOCAL, rt_submodel_internal::magic, MAT_COPY, NULL, rt_submodel_internal::root2leaf, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_SUBMODEL_INTERNAL_MAGIC, and rt_submodel_parse.

Here is the call graph for this function:

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

R T _ S U B M O D E L _ E X P O R T 5

The name is added by the caller, in the usual place.

Definition at line 962 of file g_submodel.c.

References BU_ASSERT, bu_calloc(), BU_CK_EXTERNAL, bu_log(), bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strlen(), bu_vls_struct_print(), bu_external::ext_buf, bu_external::ext_nbytes, rt_submodel_internal::file, ID_SUBMODEL, rt_db_internal::idb_ptr, rt_submodel_internal::meth, RT_CK_DB_INTERNAL, RT_SUBMODEL_CK_MAGIC, rt_submodel_parse, and rt_submodel_internal::treetop.

Here is the call graph for this function:

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

R T _ S U B M O D E 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 1001 of file g_submodel.c.

References bu_vls_addr(), bu_vls_printf(), bu_vls_strcat(), rt_submodel_internal::file, rt_db_internal::idb_ptr, rt_submodel_internal::meth, RT_SUBMODEL_CK_MAGIC, and rt_submodel_internal::treetop.

Here is the call graph for this function:

void rt_submodel_ifree struct rt_db_internal ip  ) 
 

R T _ S U B M O D E L _ I F R E E

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

Definition at line 1023 of file g_submodel.c.

References bu_free(), GENPTR_NULL, rt_db_internal::idb_ptr, rt_submodel_internal::magic, RT_CK_DB_INTERNAL, and RT_SUBMODEL_CK_MAGIC.

Here is the call graph for this function:


Variable Documentation

const struct bu_structparse rt_submodel_parse[]
 

Initial value:

 {
        {"%S",  1, "file",      RT_SUBMODEL_O(file),            BU_STRUCTPARSE_FUNC_NULL },
        {"%S",  1, "treetop",   RT_SUBMODEL_O(treetop),         BU_STRUCTPARSE_FUNC_NULL },
        {"%d",  1, "meth",      RT_SUBMODEL_O(meth),            BU_STRUCTPARSE_FUNC_NULL },
        {"",    0, (char *)0, 0,                        BU_STRUCTPARSE_FUNC_NULL }
}

Definition at line 63 of file g_submodel.c.

Referenced by rt_submodel_export(), rt_submodel_export5(), rt_submodel_import(), and rt_submodel_import5().


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