BRL-CAD
revolve.c File Reference
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "vmath.h"
#include "bu/cv.h"
#include "bu/debug.h"
#include "db.h"
#include "nmg.h"
#include "rtgeom.h"
#include "raytrace.h"
#include "./revolve.h"
Include dependency graph for revolve.c:

Go to the source code of this file.

Macros

#define START_FACE_POS   -1
 
#define START_FACE_NEG   -2
 
#define END_FACE_POS   -3
 
#define END_FACE_NEG   -4
 
#define HORIZ_SURF   -5
 
#define MAX_HITS   64
 

Functions

int rt_sketch_contains (struct rt_sketch_internal *, point2d_t)
 
void rt_sketch_bounds (struct rt_sketch_internal *, fastf_t *)
 
void rt_revolve_make (const struct rt_functab *ftp, struct rt_db_internal *intern)
 
int rt_revolve_bbox (struct rt_db_internal *ip, point_t *min, point_t *max, const struct bn_tol *tol)
 
int rt_revolve_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
 
void rt_revolve_print (const struct soltab *stp)
 
int rt_revolve_shot (struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
 
void rt_revolve_norm (struct hit *hitp, struct soltab *stp, struct xray *rp)
 
void rt_revolve_curve (struct curvature *cvp, struct hit *hitp, struct soltab *stp)
 
void rt_revolve_uv (struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
 
void rt_revolve_free (struct soltab *stp)
 
int rt_revolve_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_revolve_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_revolve_import5 (struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip, struct resource *resp)
 
int rt_revolve_xform (struct rt_db_internal *op, const mat_t mat, struct rt_db_internal *ip, int release, struct db_i *dbip, struct resource *resp)
 
int rt_revolve_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
 
int rt_revolve_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
 
void rt_revolve_ifree (struct rt_db_internal *ip)
 

Detailed Description

Intersect a ray with an 'revolve' primitive object.

Definition in file revolve.c.

Macro Definition Documentation

#define START_FACE_POS   -1

Definition at line 47 of file revolve.c.

Referenced by rt_revolve_norm(), rt_revolve_shot(), and rt_revolve_uv().

#define START_FACE_NEG   -2

Definition at line 48 of file revolve.c.

Referenced by rt_revolve_norm(), rt_revolve_shot(), and rt_revolve_uv().

#define END_FACE_POS   -3

Definition at line 49 of file revolve.c.

Referenced by rt_revolve_norm(), rt_revolve_shot(), and rt_revolve_uv().

#define END_FACE_NEG   -4

Definition at line 50 of file revolve.c.

Referenced by rt_revolve_norm(), rt_revolve_shot(), and rt_revolve_uv().

#define HORIZ_SURF   -5

Definition at line 51 of file revolve.c.

Referenced by rt_revolve_norm(), rt_revolve_shot(), and rt_revolve_uv().

#define MAX_HITS   64

Definition at line 53 of file revolve.c.

Referenced by rt_revolve_shot().

Function Documentation

int rt_sketch_contains ( struct rt_sketch_internal *  ,
point2d_t   
)

Definition at line 253 of file sketch.c.

References bu_log(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, FMAX, FMIN, X, and Y.

Referenced by rt_revolve_shot().

Here is the call graph for this function:

void rt_sketch_bounds ( struct rt_sketch_internal *  ,
fastf_t  
)

Definition at line 355 of file sketch.c.

References bu_log(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, FMAX, FMIN, X, and Y.

Referenced by rt_revolve_bbox(), and rt_revolve_prep().

Here is the call graph for this function:

void rt_revolve_make ( const struct rt_functab ftp,
struct rt_db_internal intern 
)

Routine to make a new REVOLVE solid. The only purpose of this routine is to initialize the internal to legal values (e.g., vls)

Definition at line 65 of file revolve.c.

References BU_ALLOC, BU_ASSERT, BU_VLS_INIT, ID_REVOLVE, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, OBJ, and RT_REVOLVE_INTERNAL_MAGIC.

int rt_revolve_bbox ( struct rt_db_internal ip,
point_t *  min,
point_t *  max,
const struct bn_tol tol 
)

Calculate a bounding RPP around a sketch

Definition at line 88 of file revolve.c.

References bu_calloc(), bu_free(), bu_log(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, FMAX, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, rt_sketch_bounds(), X, Y, Z, and ZERO.

Here is the call graph for this function:

int rt_revolve_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 REVOLVE, and if so, precompute various terms of the formula.

Returns - 0 REVOLVE is OK !0 Error in description

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

Definition at line 208 of file revolve.c.

References revolve_specific::ang, revolve_specific::bounds, bu_calloc(), BU_GET, bu_log(), bu_vls_addr(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, revolve_specific::ends, FMAX, ID_REVOLVE, rt_db_internal::idb_ptr, OBJ, revolve_specific::rEnd, RT_CK_DB_INTERNAL, RT_CK_RTI, rt_sketch_bounds(), revolve_specific::sketch_name, revolve_specific::skt, soltab::st_aradius, soltab::st_bradius, soltab::st_center, soltab::st_id, soltab::st_max, soltab::st_meth, soltab::st_min, soltab::st_specific, revolve_specific::v3d, X, revolve_specific::xUnit, Y, revolve_specific::yUnit, Z, ZERO, and revolve_specific::zUnit.

Here is the call graph for this function:

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

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

Returns - 0 MISS >0 HIT

calculate hyperbola parameters

[ (x*x) / aa^2 ] - [ (y-h)^2 / bb^2 ] = 1

x = aa cosh(t - k); y = h + bb sinh(t - k);

if (ur[Z] == 1) { bb = inf; // ray becomes a line parallel to sketch's y-axis instead of a hyberbola } if (ur[Z] == 0) { bb = 0; // ray becomes a line parallel to sketch's x-axis instead of a hyperbola // all hits must have x > aa }

Definition at line 366 of file revolve.c.

References application::a_resource, revolve_specific::ang, bn_poly_add(), bn_poly_mul(), bn_poly_scale(), bn_poly_sub(), bn_pr_roots(), BU_LIST_INSERT, bu_log(), bn_poly::cf, CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, directory::d_namep, bn_poly::dgr, END_FACE_NEG, END_FACE_POS, revolve_specific::ends, FMAX, FMIN, HORIZ_SURF, seg::l, M_PI, MAX_FASTF, MAX_HITS, NEAR_ZERO, out, xray::r_dir, xray::r_pt, revolve_specific::rEnd, RT_DOT_TOL, RT_GET_SEG, RT_HIT_MAGIC, RT_LEN_TOL, RT_PCOEF_TOL, rt_poly_roots(), rt_sketch_contains(), revolve_specific::skt, SMALL, soltab::st_dp, soltab::st_specific, START_FACE_NEG, START_FACE_POS, revolve_specific::v3d, VPRINT, VSET, X, revolve_specific::xUnit, Y, revolve_specific::yUnit, Z, ZERO, and revolve_specific::zUnit.

Here is the call graph for this function:

void rt_revolve_norm ( struct hit hitp,
struct soltab stp,
struct xray rp 
)
void rt_revolve_curve ( struct curvature cvp,
struct hit hitp,
struct soltab stp 
)

Return the curvature of the revolve.

Definition at line 1082 of file revolve.c.

References bn_vec_ortho(), curvature::crv_c1, curvature::crv_c2, curvature::crv_pdir, hit::hit_normal, RT_CK_HIT, and RT_CK_SOLTAB.

Here is the call graph for this function:

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

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

u = azimuth, v = elevation

Definition at line 1103 of file revolve.c.

References revolve_specific::ang, revolve_specific::bounds, bu_log(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, END_FACE_NEG, END_FACE_POS, hit::hit_dist, hit::hit_rayp, hit::hit_surfno, hit::hit_vpriv, HORIZ_SURF, if(), xray::r_dir, xray::r_pt, RT_CK_APPLICATION, revolve_specific::skt, soltab::st_specific, START_FACE_NEG, START_FACE_POS, uvcoord::uv_u, uvcoord::uv_v, X, Y, Z, and ZERO.

Here is the call graph for this function:

void rt_revolve_free ( struct soltab stp)

Definition at line 1195 of file revolve.c.

References bu_free(), BU_PUT, revolve_specific::ends, and soltab::st_specific.

Here is the call graph for this function:

int rt_revolve_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 1205 of file revolve.c.

References add(), BN_VLIST_LINE_DRAW, BN_VLIST_LINE_MOVE, bu_calloc(), BU_CK_LIST_HEAD, bu_free(), bu_log(), CURVE_BEZIER_MAGIC, CURVE_CARC_MAGIC, CURVE_LSEG_MAGIC, CURVE_NURB_MAGIC, curve_to_vlist(), rt_db_internal::idb_ptr, M_SQRT1_2, RT_ADD_VLIST, RT_CK_DB_INTERNAL, X, Y, and ZERO.

Here is the call graph for this function:

int rt_revolve_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 1427 of file revolve.c.

References bu_log(), rt_db_internal::idb_ptr, and RT_CK_DB_INTERNAL.

Here is the call graph for this function:

int rt_revolve_import5 ( struct rt_db_internal ip,
const struct bu_external ep,
const mat_t  mat,
const struct db_i dbip,
struct resource resp 
)

Import an REVOLVE 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 1466 of file revolve.c.

References bn_mat_identity, BU_ALLOC, BU_CK_EXTERNAL, bu_cv_ntohd(), bu_free(), bu_log(), bu_vls_init(), bu_vls_strcpy(), db_lookup(), bu_external::ext_buf, ID_REVOLVE, ID_SKETCH, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, LOOKUP_NOISY, OBJ, RT_CK_DB_INTERNAL, RT_CK_DBI, rt_db_get_internal(), RT_DIR_NULL, RT_REVOLVE_INTERNAL_MAGIC, and SIZEOF_NETWORK_DOUBLE.

Here is the call graph for this function:

int rt_revolve_xform ( struct rt_db_internal op,
const mat_t  mat,
struct rt_db_internal ip,
int  release,
struct db_i dbip,
struct resource resp 
)

Apply a transformation matrix to the specified 'ip' input revolve object, storing the results in the specified 'op' out pointer or creating a copy if NULL.

Definition at line 1538 of file revolve.c.

References BU_ALLOC, bu_avs_init(), BU_AVS_MAGIC, bu_avs_merge(), bu_debug, BU_DEBUG_MEM_CHECK, bu_log(), bu_mem_barriercheck(), bu_vls_init(), bu_vls_vlscat(), bu_attribute_value_set::count, ID_REVOLVE, rt_db_internal::idb_avs, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, bu_attribute_value_set::magic, OBJ, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_CK_RESOURCE, rt_copy_sketch(), rt_db_free_internal(), RT_DB_INTERNAL_INIT, and RT_REVOLVE_INTERNAL_MAGIC.

Here is the call graph for this function:

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

Export an REVOLVE 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 1611 of file revolve.c.

References bu_calloc(), BU_CK_EXTERNAL, bu_cv_htond(), bu_strlcpy, bu_vls_addr(), bu_vls_strlen(), bu_external::ext_buf, bu_external::ext_nbytes, ID_REVOLVE, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, RT_CK_DBI, and SIZEOF_NETWORK_DOUBLE.

Here is the call graph for this function:

int rt_revolve_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 1657 of file revolve.c.

References bu_vls_strcat(), bu_vls_vlscat(), rt_db_internal::idb_ptr, X, Y, and Z.

Here is the call graph for this function:

void rt_revolve_ifree ( struct rt_db_internal ip)

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

Definition at line 1703 of file revolve.c.

References bu_free(), bu_log(), bu_vls_free(), BU_VLS_IS_INITIALIZED, rt_db_internal::idb_ptr, and RT_CK_DB_INTERNAL.

Here is the call graph for this function: