BRL-CAD
bspline.cpp File Reference
#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "bnetwork.h"
#include "bu/cv.h"
#include "vmath.h"
#include "db.h"
#include "rtgeom.h"
#include "raytrace.h"
#include "nurb.h"
#include "nmg.h"
#include "opennurbs.h"
#include "../../librt_private.h"
Include dependency graph for bspline.cpp:

Go to the source code of this file.

Data Structures

struct  nurb_specific
 
struct  nurb_hit
 

Macros

#define CONVERT_TO_BREP   1
 
#define NEW_WIREFRAME   1
 
#define NULL_HIT   (struct nurb_hit *)0
 
#define SEG_MISS(SEG)   (SEG).seg_stp=(struct soltab *) 0;
 

Functions

void rt_nurb_brep (ON_Brep **b, struct rt_db_internal *ip, const struct bn_tol *tol)
 
int rt_brep_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
 
void rt_brep_print (register const struct soltab *stp)
 
int rt_brep_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
 
void rt_brep_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
 
void rt_brep_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
 
void rt_brep_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
 
void rt_brep_free (register struct soltab *stp)
 
int rt_brep_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)
 
HIDDEN int rt_nurb_grans (struct face_g_snurb *srf)
 
int rt_nurb_bbox (struct rt_db_internal *ip, point_t *min, point_t *max)
 
int rt_nurb_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
 
void rt_nurb_print (register const struct soltab *stp)
 
int rt_nurb_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
 
void rt_nurb_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
 
void rt_nurb_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
 
void rt_nurb_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
 
void rt_nurb_free (register struct soltab *stp)
 
int rt_nurb_class (void)
 
int rt_nurb_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_nurb_tess (struct nmgregion **, struct model *, struct rt_db_internal *, const struct rt_tess_tol *, const struct bn_tol *)
 
int rt_nurb_import4 (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
 
int rt_nurb_export4 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
 
int rt_nurb_bytes (struct face_g_snurb *srf)
 
int rt_nurb_export5 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
 
int rt_nurb_import5 (struct rt_db_internal *ip, const struct bu_external *ep, register const fastf_t *mat, const struct db_i *dbip)
 
void rt_nurb_ifree (struct rt_db_internal *ip)
 
int rt_nurb_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
 
int rt_nurb_get (struct bu_vls *logstr, const struct rt_db_internal *intern, const char *attr)
 
int rt_nurb_adjust (struct bu_vls *logstr, struct rt_db_internal *intern, int argc, const char **argv)
 
int rt_nurb_params (struct pc_pc_set *, const struct rt_db_internal *)
 

Detailed Description

Intersect a ray with a Non Uniform Rational B-Spline.

Definition in file bspline.cpp.

Macro Definition Documentation

#define CONVERT_TO_BREP   1

Definition at line 30 of file bspline.cpp.

#define NEW_WIREFRAME   1

Definition at line 36 of file bspline.cpp.

#define NULL_HIT   (struct nurb_hit *)0

Definition at line 82 of file bspline.cpp.

Referenced by rt_nurb_shot().

#define SEG_MISS (   SEG)    (SEG).seg_stp=(struct soltab *) 0;

Definition at line 470 of file bspline.cpp.

Function Documentation

void rt_nurb_brep ( ON_Brep **  b,
struct rt_db_internal ip,
const struct bn_tol tol 
)

Referenced by rt_nurb_plot(), and rt_nurb_prep().

void rt_brep_print ( register const struct soltab stp)

Referenced by rt_nurb_print().

void rt_brep_norm ( register struct hit hitp,
struct soltab stp,
register struct xray rp 
)

Referenced by rt_nurb_norm().

void rt_brep_curve ( register struct curvature cvp,
register struct hit hitp,
struct soltab stp 
)

Referenced by rt_nurb_curve().

HIDDEN int rt_nurb_grans ( struct face_g_snurb *  srf)

Definition at line 101 of file bspline.cpp.

Referenced by rt_nurb_export4().

int rt_nurb_bbox ( struct rt_db_internal ip,
point_t *  min,
point_t *  max 
)

Calculate the bounding RPP of a bspline

Definition at line 123 of file bspline.cpp.

References nurb_specific::bez_hd, BU_GET, BU_LIST_DEQUEUE, BU_LIST_FOR, BU_LIST_INIT, BU_LIST_WHILE, BU_PUT, rt_db_internal::idb_ptr, nurb_specific::next, rt_nurb_bezier(), rt_nurb_free_snurb(), rt_nurb_s_bound(), rt_nurb_scopy(), s, SMALL_FASTF, nurb_specific::srf, VSETALL, X, Y, and Z.

Here is the call graph for this function:

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

Given a pointer of a GED database record, and a transformation matrix, determine if this is a valid NURB, and if so, prepare the surface so the intersections will work.

Definition at line 200 of file bspline.cpp.

References nurb_specific::bez_hd, BU_GET, BU_LIST_FOR, BU_LIST_INIT, bn_tol::dist, rt_db_internal::idb_ptr, nurb_specific::next, RT_BREP_INTERNAL_MAGIC, rt_brep_prep(), RT_DB_INTERNAL_INIT, rt_nurb_bezier(), rt_nurb_brep(), rt_nurb_s_bound(), rt_nurb_scopy(), rt_i::rti_tol, s, SMALL_FASTF, nurb_specific::srf, soltab::st_aradius, soltab::st_bradius, soltab::st_center, soltab::st_max, soltab::st_min, soltab::st_specific, X, Y, and Z.

Here is the call graph for this function:

void rt_nurb_print ( register const struct soltab stp)

Definition at line 296 of file bspline.cpp.

References bu_log(), if(), nurb_specific::next, rt_brep_print(), rt_nurb_s_print(), nurb_specific::srf, and soltab::st_specific.

Here is the call graph for this function:

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

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

Returns - 0 MISS >0 HIT

Definition at line 326 of file bspline.cpp.

References application::a_resource, application::a_rt_i, application::a_x, application::a_y, nurb_specific::bez_hd, bn_mk_plane_3pts(), bn_vec_ortho(), bu_free(), BU_LIST_FOR, BU_LIST_INSERT, bu_log(), DEBUG_SPLINE, nurb_hit::hit_dist, nurb_hit::hit_point, nurb_hit::hit_private, nurb_hit::hit_surfno, hit::hit_surfno, nurb_hit::hit_uv, if(), seg::l, nurb_specific::next, NULL_HIT, xray::r_dir, xray::r_pt, rt_brep_shot(), RT_G_DEBUG, RT_GET_SEG, rt_in_rpp(), rt_nurb_intersect(), rt_i::rti_tol, s, soltab::st_specific, UV_TOL, VSET, and ZERO.

Here is the call graph for this function:

void rt_nurb_norm ( register struct hit hitp,
struct soltab stp,
register struct xray rp 
)

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

Definition at line 477 of file bspline.cpp.

References hit::hit_normal, hit::hit_private, hit::hit_vpriv, rt_brep_norm(), rt_nurb_s_norm(), OSL::Strings::u, and OSL::Strings::v.

Here is the call graph for this function:

void rt_nurb_curve ( register struct curvature cvp,
register struct hit hitp,
struct soltab stp 
)

Return the curvature of the nurb.

Definition at line 507 of file bspline.cpp.

References bn_vec_ortho(), curvature::crv_c1, curvature::crv_c2, curvature::crv_pdir, hit::hit_normal, hit::hit_private, hit::hit_vpriv, if(), rt_brep_curve(), rt_nurb_curvature(), OSL::Strings::u, and OSL::Strings::v.

Here is the call graph for this function:

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

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

Definition at line 540 of file bspline.cpp.

References hit::hit_vpriv, rt_brep_uv(), uvcoord::uv_u, and uvcoord::uv_v.

Here is the call graph for this function:

void rt_nurb_free ( register struct soltab stp)

Definition at line 555 of file bspline.cpp.

References nurb_specific::bez_hd, bu_bomb(), BU_LIST_DEQUEUE, BU_LIST_WHILE, BU_PUT, if(), nurb_specific::next, rt_brep_free(), rt_nurb_free_snurb(), s, nurb_specific::srf, and soltab::st_specific.

Here is the call graph for this function:

int rt_nurb_class ( void  )

Definition at line 588 of file bspline.cpp.

int rt_nurb_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 595 of file bspline.cpp.

References BN_VLIST_LINE_DRAW, BN_VLIST_LINE_MOVE, BU_CK_LIST_HEAD, bu_free(), rt_db_internal::idb_ptr, M_SQRT1_2, primitive_get_absolute_tolerance(), RT_ADD_VLIST, RT_BREP_INTERNAL_MAGIC, rt_brep_plot(), RT_CK_DB_INTERNAL, RT_DB_INTERNAL_INIT, rt_nurb_brep(), rt_nurb_free_snurb(), rt_nurb_kvknot(), rt_nurb_par_edge(), rt_nurb_s_refine(), and s.

Here is the call graph for this function:

int rt_nurb_tess ( struct nmgregion **  ,
struct model *  ,
struct rt_db_internal ,
const struct rt_tess_tol ,
const struct bn_tol  
)

Definition at line 724 of file bspline.cpp.

int rt_nurb_import4 ( struct rt_db_internal ip,
const struct bu_external ep,
register const fastf_t mat,
const struct db_i dbip 
)

Definition at line 731 of file bspline.cpp.

References bn_mat_identity, BU_ALLOC, BU_CK_EXTERNAL, bu_log(), bu_malloc(), db_i::dbi_version, bu_external::ext_buf, flip_dbfloat(), flip_short(), ID_BSPLINE, rt_db_internal::idb_major_type, rt_db_internal::idb_meth, rt_db_internal::idb_ptr, if(), OBJ, RT_CK_DB_INTERNAL, RT_CK_DBI, RT_NURB_INTERNAL_MAGIC, rt_nurb_kvnorm(), rt_nurb_new_snurb(), rt_nurb_s_bound(), and s.

Here is the call graph for this function:

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

Definition at line 890 of file bspline.cpp.

References bu_calloc(), BU_CK_EXTERNAL, bu_log(), bu_external::ext_buf, bu_external::ext_nbytes, ID_BSPLINE, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, RT_CK_DBI, rt_nurb_grans(), and s.

Here is the call graph for this function:

int rt_nurb_bytes ( struct face_g_snurb *  srf)

Definition at line 978 of file bspline.cpp.

References SIZEOF_NETWORK_DOUBLE, and SIZEOF_NETWORK_LONG.

Referenced by rt_nurb_export5().

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

Definition at line 995 of file bspline.cpp.

References bu_cv_htond(), BU_EXTERNAL_INIT, bu_free(), bu_log(), bu_malloc(), bu_external::ext_buf, bu_external::ext_nbytes, ID_BSPLINE, rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, RT_CK_DBI, rt_nurb_bytes(), s, SIZEOF_NETWORK_DOUBLE, and SIZEOF_NETWORK_LONG.

Here is the call graph for this function:

int rt_nurb_import5 ( struct rt_db_internal ip,
const struct bu_external ep,
register const fastf_t mat,
const struct db_i dbip 
)
void rt_nurb_ifree ( struct rt_db_internal ip)

Definition at line 1216 of file bspline.cpp.

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

Here is the call graph for this function:

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

Definition at line 1241 of file bspline.cpp.

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

Here is the call graph for this function:

int rt_nurb_get ( struct bu_vls logstr,
const struct rt_db_internal intern,
const char *  attr 
)

Definition at line 1311 of file bspline.cpp.

References BRLCAD_ERROR, BRLCAD_OK, bu_vls_printf(), bu_vls_strcat(), bu_vls_strcpy(), and rt_db_internal::idb_ptr.

Here is the call graph for this function:

int rt_nurb_adjust ( struct bu_vls logstr,
struct rt_db_internal intern,
int  argc,
const char **  argv 
)

Definition at line 1356 of file bspline.cpp.

References BRLCAD_ERROR, brlcad_interp, BRLCAD_OK, bu_calloc(), bu_free(), BU_STR_EQUAL, bu_vls_printf(), rt_db_internal::idb_ptr, RT_CK_DB_INTERNAL, rt_nurb_free_snurb(), rt_nurb_new_snurb(), tcl_obj_to_fastf_array(), and tcl_obj_to_int_array().

Here is the call graph for this function:

int rt_nurb_params ( struct pc_pc_set ,
const struct rt_db_internal  
)

Definition at line 1473 of file bspline.cpp.