g_superell.c File Reference

#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <strings.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#include "db.h"
#include "nmg.h"
#include "raytrace.h"
#include "nurb.h"
#include "rtgeom.h"
#include "./debug.h"

Include dependency graph for g_superell.c:

Go to the source code of this file.

Data Structures

struct  superell_specific
struct  superell_state
struct  superell_vert_strip

Defines

#define SUPERELL_NULL   ((struct superell_specific *)0)
#define SUPERELLOUT(n)   ov+(n-1)*3

Functions

int rt_superell_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
void rt_superell_print (register const struct soltab *stp)
int rt_superell_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
void rt_superell_vshot (struct soltab **stp, struct xray **rp, struct seg *segp, int n, struct application *ap)
void rt_superell_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
void rt_superell_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
void rt_superell_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
void rt_superell_free (register struct soltab *stp)
int rt_superell_class (void)
void rt_superell_16pts (register fastf_t *ov, register fastf_t *V, fastf_t *A, fastf_t *B)
int rt_superell_plot (struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
int rt_superell_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_superell_import (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
int rt_superell_export (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_superell_import5 (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
int rt_superell_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_superell_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
void rt_superell_ifree (struct rt_db_internal *ip)
int rt_superell_tnurb (struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct bn_tol *tol)

Variables

const struct bu_structparse rt_superell_parse []


Detailed Description

Intersect a ray with a Superquadratic Ellipsoid.

NOTICE: this primitive is incomplete and should beconsidered experimental. this primitive will exhibit several instabilities in the existing root solver method.

Authors - Christopher Sean Morrison (Programming) Edwin O. Davisson (Mathematics)

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

Definition in file g_superell.c.


Define Documentation

#define SUPERELL_NULL   ((struct superell_specific *)0)
 

Definition at line 189 of file g_superell.c.

#define SUPERELLOUT  )     ov+(n-1)*3
 

R T _ S U P E R E L L _ 1 6 P T S

Also used by the TGC code

Definition at line 648 of file g_superell.c.

Referenced by rt_superell_16pts().


Function Documentation

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

R T _ S U P E R E L L _ P R E P

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

Returns - 0 SUPERELL is OK !0 Error in description

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

Definition at line 207 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, bn_mat_mul(), bn_mat_trn(), BU_GETSTRUCT, bu_log(), rt_superell_internal::c, bn_tol::dist, rt_superell_internal::e, rt_db_internal::idb_ptr, LOCAL, MAGSQ, MAT3X3VEC, MAT_IDN, rt_superell_internal::n, NEAR_ZERO, R, RT_SUPERELL_CK_MAGIC, rt_i::rti_tol, soltab::st_aradius, soltab::st_bradius, soltab::st_center, soltab::st_max, soltab::st_min, soltab::st_specific, superell_specific::superell_Au, superell_specific::superell_Bu, superell_specific::superell_Cu, superell_specific::superell_e, superell_specific::superell_invmsAu, superell_specific::superell_invmsBu, superell_specific::superell_invmsCu, superell_specific::superell_invR, superell_specific::superell_invRSSR, superell_specific::superell_invsq, superell_specific::superell_n, superell_specific::superell_SoR, superell_specific::superell_V, rt_superell_internal::v, VDOT, VELMUL, VMOVE, VSCALE, VSET, X, Y, and Z.

Here is the call graph for this function:

void rt_superell_print register const struct soltab stp  ) 
 

R T _ S U P E R E L L _ P R I N T

Definition at line 355 of file g_superell.c.

References superell_specific::superell_V, and VPRINT.

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

Definition at line 380 of file g_superell.c.

References bn_pr_roots(), bu_log(), directory::d_namep, LOCAL, MAT4X3VEC, NEAR_ZERO, rt_poly_roots(), soltab::st_dp, soltab::st_specific, superell_specific::superell_invmsAu, superell_specific::superell_invmsBu, superell_specific::superell_invmsCu, superell_specific::superell_SoR, superell_specific::superell_V, VDOT, VPRINT, VSCALE, VSUB2, VUNITIZE, X, Y, and Z.

Here is the call graph for this function:

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

R T _ S U P E R E L L _ V S H O T

This is the Becker vector version.

Definition at line 560 of file g_superell.c.

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

R T _ S U P E R E L L _ N O R M

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

Definition at line 577 of file g_superell.c.

References LOCAL, MAGNITUDE, MAT4X3VEC, soltab::st_specific, superell_specific::superell_invRSSR, superell_specific::superell_V, VJOIN1, VSCALE, and VSUB2.

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

R T _ S U P E R E L L _ C U R V E

Return the curvature of the superellipsoid.

Definition at line 601 of file g_superell.c.

References bu_log().

Here is the call graph for this function:

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

R T _ S U P E R E L L _ U V

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

Definition at line 617 of file g_superell.c.

References bu_log().

Here is the call graph for this function:

void rt_superell_free register struct soltab stp  ) 
 

R T _ S U P E R E L L _ F R E E

Definition at line 627 of file g_superell.c.

References bu_free().

Here is the call graph for this function:

int rt_superell_class void   ) 
 

Definition at line 637 of file g_superell.c.

void rt_superell_16pts register fastf_t ov,
register fastf_t V,
fastf_t A,
fastf_t B
 

Definition at line 650 of file g_superell.c.

References SUPERELLOUT, VADD2, VJOIN2, and VSUB2.

Referenced by rt_superell_plot().

int rt_superell_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 P E R E L L _ P L O T

Definition at line 691 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, BN_VLIST_LINE_DRAW, BN_VLIST_LINE_MOVE, rt_superell_internal::c, ELEMENTS_PER_VECT, rt_db_internal::idb_ptr, RT_ADD_VLIST, RT_CK_DB_INTERNAL, rt_superell_16pts(), RT_SUPERELL_CK_MAGIC, top(), and rt_superell_internal::v.

Here is the call graph for this function:

int rt_superell_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 P E R E L L _ T E S S

Tesssuperellate an superellipsoid.

The strategy is based upon the approach of Jon Leech 3/24/89, from program "sphere", which generates a polygon mesh approximating a sphere by recursive subdivision. First approximation is an octahedron; each level of refinement increases the number of polygons by a factor of 4. Level 3 (128 polygons) is a good tradeoff if gouraud shading is used to render the database.

At the start, points ABC lie on surface of the unit sphere. Pick DEF as the midpoints of the three edges of ABC. Normalize the new points to lie on surface of the unit sphere.

1 B /\ 3 / \ 4 D/____/\ /\ / \ / \ /____\/____\ A F C 0 5 2

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

Definition at line 810 of file g_superell.c.

References bu_log().

Here is the call graph for this function:

int rt_superell_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 P E R E L L _ I M P O R T

Import an superellipsoid/sphere from the database format to the internal structure. Apply modeling transformations as wsuperell.

Definition at line 824 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, BU_CK_EXTERNAL, bu_log(), bu_malloc(), rt_superell_internal::c, DB5_MAJORTYPE_BRLCAD, rt_superell_internal::e, bu_external::ext_buf, ID_SOLID, ID_SUPERELL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, LOCAL, rt_superell_internal::magic, MAT4X3PNT, MAT4X3VEC, rt_superell_internal::n, RT_CK_DB_INTERNAL, rt_fastf_float(), RT_SUPERELL_INTERNAL_MAGIC, record::s, record::solidrec::s_values, record::u_id, and rt_superell_internal::v.

Here is the call graph for this function:

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

R T _ S U P E R E L L _ E X P O R T

Definition at line 864 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, bu_calloc(), BU_CK_EXTERNAL, rt_superell_internal::c, rt_superell_internal::e, bu_external::ext_buf, bu_external::ext_nbytes, ID_SOLID, ID_SUPERELL, rt_db_internal::idb_ptr, rt_superell_internal::n, RT_CK_DB_INTERNAL, RT_SUPERELL_CK_MAGIC, record::s, record::solidrec::s_id, record::solidrec::s_type, record::solidrec::s_values, SUPERELL, rt_superell_internal::v, and VSCALE.

Here is the call graph for this function:

int rt_superell_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 P E R E L L _ I M P O R T 5

Import an superellipsoid/sphere from the database format to the internal structure. Apply modeling transformations as wsuperell.

Definition at line 904 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, BU_ASSERT_LONG, BU_CK_EXTERNAL, bu_malloc(), rt_superell_internal::c, DB5_MAJORTYPE_BRLCAD, rt_superell_internal::e, ELEMENTS_PER_VECT, bu_external::ext_buf, bu_external::ext_nbytes, ID_SUPERELL, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, rt_superell_internal::magic, MAT4X3PNT, MAT4X3VEC, rt_superell_internal::n, ntohd(), RT_CK_DB_INTERNAL, RT_SUPERELL_INTERNAL_MAGIC, SIZEOF_NETWORK_DOUBLE, and rt_superell_internal::v.

Here is the call graph for this function:

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

R T _ S U P E R E L L _ E X P O R T 5

The external format is: V point A vector B vector C vector

Definition at line 946 of file g_superell.c.

References rt_superell_internal::a, rt_superell_internal::b, BU_CK_EXTERNAL, bu_malloc(), rt_superell_internal::c, rt_superell_internal::e, ELEMENTS_PER_VECT, bu_external::ext_buf, bu_external::ext_nbytes, htond(), ID_SUPERELL, rt_db_internal::idb_ptr, rt_superell_internal::n, RT_CK_DB_INTERNAL, RT_SUPERELL_CK_MAGIC, SIZEOF_NETWORK_DOUBLE, rt_superell_internal::v, and VSCALE.

Here is the call graph for this function:

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

R T _ S U P E R E L 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 983 of file g_superell.c.

References bu_vls_strcat(), rt_db_internal::idb_ptr, INTCLAMP, MAGNITUDE, rt_find_fallback_angle(), rt_pr_fallback_angle(), RT_SUPERELL_CK_MAGIC, VSCALE, X, Y, and Z.

Here is the call graph for this function:

void rt_superell_ifree struct rt_db_internal ip  ) 
 

R T _ S U P E R E L L _ I F R E E

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

Definition at line 1052 of file g_superell.c.

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

Here is the call graph for this function:

int rt_superell_tnurb struct nmgregion **  r,
struct model m,
struct rt_db_internal ip,
const struct bn_tol tol
 

R T _ S U P E R E L L _ T N U R B

Definition at line 1075 of file g_superell.c.

References bu_log().

Here is the call graph for this function:


Variable Documentation

const struct bu_structparse rt_superell_parse[]
 

Initial value:

 {
    { "%f", 3, "V", bu_offsetof(struct rt_superell_internal, v[X]), BU_STRUCTPARSE_FUNC_NULL },
    { "%f", 3, "A", bu_offsetof(struct rt_superell_internal, a[X]), BU_STRUCTPARSE_FUNC_NULL },
    { "%f", 3, "B", bu_offsetof(struct rt_superell_internal, b[X]), BU_STRUCTPARSE_FUNC_NULL },
    { "%f", 3, "C", bu_offsetof(struct rt_superell_internal, c[X]), BU_STRUCTPARSE_FUNC_NULL },
    { "%f", 1, "n", bu_offsetof(struct rt_superell_internal, n), BU_STRUCTPARSE_FUNC_NULL },
    { "%f", 1, "e", bu_offsetof(struct rt_superell_internal, e), BU_STRUCTPARSE_FUNC_NULL },
    { {'\0','\0','\0','\0'}, 0, (char *)NULL, 0, BU_STRUCTPARSE_FUNC_NULL }
 }

Definition at line 70 of file g_superell.c.


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