BRL-CAD
primitive_util.c File Reference
#include "../librt_private.h"
Include dependency graph for primitive_util.c:

Go to the source code of this file.

Macros

#define DEFAULT_REL_TOL   .1
 

Functions

fastf_t primitive_get_absolute_tolerance (const struct rt_tess_tol *ttol, fastf_t rel_to_abs)
 
fastf_t primitive_diagonal_samples (struct rt_db_internal *ip, const struct rt_view_info *info)
 
fastf_t primitive_curve_count (struct rt_db_internal *ip, const struct rt_view_info *info)
 
int approximate_parabolic_curve (struct rt_pt_node *pts, fastf_t p, int num_new_points)
 
int approximate_hyperbolic_curve (struct rt_pt_node *pts, fastf_t a, fastf_t b, int num_new_points)
 
void ellipse_point_at_radian (point_t result, const vect_t center, const vect_t axis_a, const vect_t axis_b, fastf_t radian)
 
void plot_ellipse (struct bu_list *vhead, const vect_t center, const vect_t axis_a, const vect_t axis_b, int num_points)
 

Detailed Description

General utility routines for librt primitives that are not part of the librt API. Prototypes for these routines are located in librt_private.h.

Definition in file primitive_util.c.

Macro Definition Documentation

#define DEFAULT_REL_TOL   .1

If only the absolute tolerance is valid (positive), it is returned.

If only the relative tolerance is valid (in (0.0, 1.0)), the return value is the relative tolerance multiplied by rel_to_abs.

If both tolerances are valid, the smaller is used. If neither is valid, a default of .1 * rel_to_abs is used.

Definition at line 38 of file primitive_util.c.

Referenced by primitive_get_absolute_tolerance().

Function Documentation

fastf_t primitive_diagonal_samples ( struct rt_db_internal ip,
const struct rt_view_info info 
)

Gives a rough estimate of the maximum number of times a primitive's bounding box diagonal will be sampled based on the sample density of the view.

Practically, it is an estimate of the maximum number of pixels that would be used if the diagonal line were drawn in the current view window.

It is currently used in adaptive plot routines to help choose how many sample points should be used for plotted curves.

Definition at line 78 of file primitive_util.c.

References rt_functab::ft_bbox, rt_db_internal::idb_meth, rt_view_info::point_spacing, and rt_view_info::tol.

fastf_t primitive_curve_count ( struct rt_db_internal ip,
const struct rt_view_info info 
)

Estimate the number of evenly spaced cross-section curves needed to meet a target curve spacing.

Definition at line 100 of file primitive_util.c.

References rt_view_info::curve_spacing, rt_functab::ft_bbox, rt_db_internal::idb_meth, rt_view_info::tol, X, Y, and Z.

Referenced by rt_ell_adaptive_plot(), rt_eto_adaptive_plot(), rt_rhc_adaptive_plot(), rt_rpc_adaptive_plot(), and rt_tor_adaptive_plot().

int approximate_parabolic_curve ( struct rt_pt_node pts,
fastf_t  p,
int  num_new_points 
)

Definition at line 178 of file primitive_util.c.

References BU_ALLOC, rt_pt_node::next, rt_pt_node::p, OSL::Strings::v, Y, and Z.

int approximate_hyperbolic_curve ( struct rt_pt_node pts,
fastf_t  a,
fastf_t  b,
int  num_new_points 
)

Definition at line 278 of file primitive_util.c.

References BU_ALLOC, rt_pt_node::next, rt_pt_node::p, OSL::Strings::v, Y, and Z.

void ellipse_point_at_radian ( point_t  result,
const vect_t  center,
const vect_t  axis_a,
const vect_t  axis_b,
fastf_t  radian 
)
void plot_ellipse ( struct bu_list vhead,
const vect_t  center,
const vect_t  axis_a,
const vect_t  axis_b,
int  num_points 
)

Definition at line 355 of file primitive_util.c.

References BN_VLIST_LINE_DRAW, BN_VLIST_LINE_MOVE, ellipse_point_at_radian(), rt_pt_node::p, and RT_ADD_VLIST.

Referenced by rt_eto_adaptive_plot(), rt_tgc_adaptive_plot(), and rt_tor_adaptive_plot().

Here is the call graph for this function: