BRL-CAD
#include "common.h"
#include <stdio.h>
#include <math.h>
#include "vmath.h"
#include "db.h"
#include "nmg.h"
#include "rtgeom.h"
#include "raytrace.h"
#include "./xxx.h"
Include dependency graph for xxx.c:

Go to the source code of this file.

Functions

int rt_xxx_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
 
void rt_xxx_print (const struct soltab *stp)
 
int rt_xxx_shot (struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
 
void rt_xxx_norm (struct hit *hitp, struct soltab *stp, struct xray *rp)
 
void rt_xxx_curve (struct curvature *cvp, struct hit *hitp, struct soltab *stp)
 
void rt_xxx_uv (struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
 
void rt_xxx_free (struct soltab *stp)
 
int rt_xxx_plot (struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
 
int rt_xxx_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_xxx_import5 (struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip)
 
int rt_xxx_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
 
int rt_xxx_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
 
void rt_xxx_ifree (struct rt_db_internal *ip)
 

Detailed Description

Intersect a ray with an 'xxx' primitive object.

Adding a new solid type:

Design disk record

define rt_xxx_internal — parameters for solid define xxx_specific — raytracing form, possibly w/precomputed terms define rt_xxx_parse — struct bu_structparse for "db get", "db adjust", ...

code import/export4/describe/print/ifree/plot/prep/shot/curve/uv/tess

edit db.h add solidrec s_type define edit rtgeom.h to add rt_xxx_internal edit bu/magic.h to add RT_XXX_INTERNAL_MAGIC edit table.c: RT_DECLARE_INTERFACE() struct rt_functab entry rt_id_solid() edit raytrace.h to make ID_XXX, increment ID_MAXIMUM edit db_scan.c to add the new solid to db_scan() edit CMakeLists.txt to add g_xxx.c to compile

go to src/libwdb and create mk_xxx() routine go to src/conv and edit g2asc.c and asc2g.c to support the new solid go to src/librt and edit tcl.c to add the new solid to rt_solid_type_lookup[] also add the interface table and to rt_id_solid() in table.c; you MUST add the appropriate RTFUNCTAB_FUNC_X_CAST macro for each function rt_xxx_X you add (see entire list in raytrace.h) go to src/mged and create the edit support

Definition in file xxx.c.

Function Documentation

int rt_xxx_prep ( struct soltab stp,
struct rt_db_internal ip,
struct rt_i rtip 
)

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

Returns - 0 XXX is OK !0 Error in description

Implicit return - A struct xxx_specific is created, and its address is stored in stp->st_specific for use by xxx_shot().

Definition at line 88 of file xxx.c.

References rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, RT_CK_RTI, RT_CK_SOLTAB, and RT_XXX_CK_MAGIC.

void rt_xxx_print ( const struct soltab stp)

Definition at line 104 of file xxx.c.

References if(), RT_CK_SOLTAB, and soltab::st_specific.

Here is the call graph for this function:

int rt_xxx_shot ( struct soltab stp,
struct xray rp,
struct application ap,
struct seg seghead 
)

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

Returns - 0 MISS >0 HIT

Definition at line 124 of file xxx.c.

References application::a_resource, BU_LIST_INSERT, if(), seg::l, RT_CK_APPLICATION, RT_CK_RAY, RT_CK_SOLTAB, RT_GET_SEG, and soltab::st_specific.

Here is the call graph for this function:

void rt_xxx_norm ( struct hit hitp,
struct soltab stp,
struct xray rp 
)

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

Definition at line 164 of file xxx.c.

References hit::hit_dist, hit::hit_point, if(), xray::r_dir, xray::r_pt, RT_CK_SOLTAB, and soltab::st_specific.

Here is the call graph for this function:

void rt_xxx_curve ( struct curvature cvp,
struct hit hitp,
struct soltab stp 
)

Return the curvature of the xxx.

Definition at line 181 of file xxx.c.

References bn_vec_ortho(), curvature::crv_c1, curvature::crv_c2, curvature::crv_pdir, hit::hit_normal, if(), RT_CK_SOLTAB, and soltab::st_specific.

Here is the call graph for this function:

void rt_xxx_uv ( struct application ap,
struct soltab stp,
struct hit hitp,
struct uvcoord uvp 
)

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

u = azimuth, v = elevation

Definition at line 204 of file xxx.c.

References if(), RT_CK_APPLICATION, RT_CK_HIT, RT_CK_SOLTAB, and soltab::st_specific.

Here is the call graph for this function:

void rt_xxx_free ( struct soltab stp)

Definition at line 219 of file xxx.c.

References bu_free(), if(), RT_CK_SOLTAB, and soltab::st_specific.

Here is the call graph for this function:

int rt_xxx_plot ( struct bu_list vhead,
struct rt_db_internal ip,
const struct rt_tess_tol ttol,
const struct bn_tol tol,
const struct rt_view_info info 
)

Definition at line 233 of file xxx.c.

References BU_CK_LIST_HEAD, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, and RT_XXX_CK_MAGIC.

int rt_xxx_tess ( struct nmgregion **  r,
struct model *  m,
struct rt_db_internal ip,
const struct rt_tess_tol ttol,
const struct bn_tol tol 
)

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

Definition at line 252 of file xxx.c.

References rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, and RT_XXX_CK_MAGIC.

int rt_xxx_import5 ( struct rt_db_internal ip,
const struct bu_external ep,
const mat_t  mat,
const struct db_i dbip 
)

Import an XXX from the database format to the internal format. Note that the data read will be in network order. This means Big-Endian integers and IEEE doubles for floating point.

Apply modeling transformations as well.

Definition at line 274 of file xxx.c.

References bn_mat_identity, BU_ALLOC, BU_ASSERT_LONG, BU_CK_EXTERNAL, bu_cv_ntohd(), bu_external::ext_buf, bu_external::ext_nbytes, ID_XXX, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, rt_xxx_internal::magic, OBJ, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_XXX_INTERNAL_MAGIC, SIZEOF_NETWORK_DOUBLE, and rt_xxx_internal::v.

Here is the call graph for this function:

int rt_xxx_export5 ( struct bu_external ep,
const struct rt_db_internal ip,
double  local2mm,
const struct db_i dbip 
)

Export an XXX from internal form to external format. Note that this means converting all integers to Big-Endian format and floating point data to IEEE double.

Apply the transformation to mm units as well.

Definition at line 318 of file xxx.c.

References bu_calloc(), BU_CK_EXTERNAL, bu_cv_htond(), bu_external::ext_buf, bu_external::ext_nbytes, ID_XXX, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_XXX_CK_MAGIC, SIZEOF_NETWORK_DOUBLE, and rt_xxx_internal::v.

Here is the call graph for this function:

int rt_xxx_describe ( struct bu_vls str,
const struct rt_db_internal ip,
int  verbose,
double  mm2local 
)

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 354 of file xxx.c.

References bu_vls_strcat(), rt_db_internal::idb_ptr, RT_XXX_CK_MAGIC, rt_xxx_internal::v, X, Y, and Z.

Here is the call graph for this function:

void rt_xxx_ifree ( struct rt_db_internal ip)

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

Definition at line 381 of file xxx.c.

References bu_free(), rt_db_internal::idb_ptr, rt_xxx_internal::magic, RT_CK_DB_INTERNAL, and RT_XXX_CK_MAGIC.

Here is the call graph for this function: