BRL-CAD
libbrep (NURBS)

Files

file  brep.h
 
file  libbrep_brep_tools.h
 

Data Structures

struct  _on_brep_placeholder
 
struct  _bounding_volume_placeholder
 
struct  _brep_cdbitem
 

Macros

#define BREP_MAX_ITERATIONS   100
 
#define BREP_INTERSECTION_ROOT_EPSILON   1e-6
 
#define BREP_INTERSECTION_ROOT_SETTLE   1e-2
 
#define BREP_GRAZING_DOT_TOL   0.000017453
 
#define DO_VECTOR   1
 
#define NE   1
 
#define NW   2
 
#define SW   3
 
#define SE   4
 

Typedefs

typedef struct _on_brep_placeholder ON_Brep
 
typedef struct _bounding_volume_placeholder BrepBoundingVolume
 
typedef struct _brep_cdbitem brep_cdbitem
 

Functions

bool ON_NearZero (double val, double epsilon)
 Return truthfully whether a value is within a specified epsilon distance from zero. More...
 
double ON_Curve_Get_Horizontal_Tangent (const ON_Curve *curve, double min, double max, double zero_tol)
 Search for a horizontal tangent on the curve between two curve parameters. More...
 
double ON_Curve_Get_Vertical_Tangent (const ON_Curve *curve, double min, double max, double zero_tol)
 Search for a vertical tangent on the curve between two curve parameters. More...
 
int ON_Curve_Has_Tangent (const ON_Curve *curve, double ct_min, double ct_max, double t_tol)
 Test whether a curve interval contains one or more horizontal or vertical tangents. More...
 
BREP_EXPORT bool ON_Surface_IsFlat (ON_Plane *frames, double f_tol)
 Perform flatness test of surface. More...
 
BREP_EXPORT bool ON_Surface_IsFlat_U (ON_Plane *frames, double f_tol)
 Perform flatness test of surface in U only. More...
 
BREP_EXPORT bool ON_Surface_IsFlat_V (ON_Plane *frames, double f_tol)
 Perform flatness test of surface in V only. More...
 
BREP_EXPORT bool ON_Surface_IsStraight (ON_Plane *frames, double s_tol)
 Perform straightness test of surface. More...
 
BREP_EXPORT bool ON_Surface_SubSurface (const ON_Surface *srf, ON_Interval *u_val, ON_Interval *v_val, ON_Surface **t1, ON_Surface **t2, ON_Surface **t3, ON_Surface **t4, ON_Surface **result)
 Create a surface based on a subset of a parent surface. More...
 
BREP_EXPORT bool ON_Surface_Quad_Split (const ON_Surface *srf, const ON_Interval &u, const ON_Interval &v, double upt, double vpt, ON_Surface **q0, ON_Surface **q1, ON_Surface **q2, ON_Surface **q3)
 Create four sub-surfaces from a parent surface. More...
 

Detailed Description

Macro Definition Documentation

#define BREP_MAX_ITERATIONS   100

Maximum number of newton iterations on root finding

Definition at line 63 of file brep.h.

Referenced by brlcad::brep_getSurfacePoint(), and utah_newton_solver().

#define BREP_INTERSECTION_ROOT_EPSILON   1e-6

Root finding threshold

Definition at line 66 of file brep.h.

Referenced by brlcad::brep_getSurfacePoint(), toUV(), and utah_newton_solver().

#define BREP_INTERSECTION_ROOT_SETTLE   1e-2

Definition at line 69 of file brep.h.

Referenced by brlcad::brep_getSurfacePoint().

#define BREP_GRAZING_DOT_TOL   0.000017453

Jungle Gym epsilon tighten BREP grazing tolerance to 0.000017453(0.001 degrees) was using RT_DOT_TOL at 0.001 (0.05 degrees)

Definition at line 74 of file brep.h.

Referenced by rt_brep_shot().

#define DO_VECTOR   1

Use vector operations? For debugging

Definition at line 77 of file brep.h.

#define NE   1

Definition at line 40 of file libbrep_brep_tools.h.

#define NW   2

Definition at line 43 of file libbrep_brep_tools.h.

#define SW   3

Definition at line 46 of file libbrep_brep_tools.h.

#define SE   4

Definition at line 49 of file libbrep_brep_tools.h.

Typedef Documentation

typedef struct _on_brep_placeholder ON_Brep
typedef struct _brep_cdbitem brep_cdbitem

Function Documentation

bool ON_NearZero ( double  val,
double  epsilon 
)

Return truthfully whether a value is within a specified epsilon distance from zero.

Parameters
valvalue to be tested
epsilondistance from zero defining the interval to be treated as "near" zero for the test
Returns
true if the value is within the near-zero interval specified by epsilon, false otherwise.

Definition at line 34 of file libbrep_brep_tools.cpp.

Referenced by add_points_to_closed_seams(), CurveSegment::Curve(), curve_fitting(), curve_interval_from_params(), get_curve_intervals_inside_or_on_face(), get_joinable_ssi_curves(), interval_2d_to_3d(), interval_3d_to_2d(), is_loop_valid(), is_same_surface(), newton_pci(), ON_Curve_Get_Tangent(), ON_Curve_Has_Tangent(), ON_Intersect(), CurvePoint::operator!=(), CurvePointAbsoluteCompare::operator()(), CurvePoint::operator<(), PointPair::operator<(), CurvePoint::operator==(), split_face_into_loops(), split_overlaps_at_intersections(), sub_curve(), tolerance_2d_from_3d(), triangle_intersection(), and uv_interval_from_points().

double ON_Curve_Get_Horizontal_Tangent ( const ON_Curve *  curve,
double  min,
double  max,
double  zero_tol 
)

Search for a horizontal tangent on the curve between two curve parameters.

Parameters
curvecurve to be tested
minminimum curve parameter value
maxmaximum curve parameter value
zero_toltolerance to use when testing for near-zero values
Returns
t parameter corresponding to the point on the curve with the horizontal tangent.

Definition at line 67 of file libbrep_brep_tools.cpp.

References ON_Curve_Get_Tangent().

Here is the call graph for this function:

double ON_Curve_Get_Vertical_Tangent ( const ON_Curve *  curve,
double  min,
double  max,
double  zero_tol 
)

Search for a vertical tangent on the curve between two curve parameters.

Parameters
curvecurve to be tested
minminimum curve parameter value
maxmaximum curve parameter value
zero_toltolerance to use when testing for near-zero values
Returns
t parameter corresponding to the point on the curve with the vertical tangent.

Definition at line 71 of file libbrep_brep_tools.cpp.

References ON_Curve_Get_Tangent().

Here is the call graph for this function:

int ON_Curve_Has_Tangent ( const ON_Curve *  curve,
double  ct_min,
double  ct_max,
double  t_tol 
)

Test whether a curve interval contains one or more horizontal or vertical tangents.

Parameters
curveON_Curve to be tested
ct_minminimum t parameter value of the curve interval to be tested
ct_maxmaximum t parameter value of the curve interval to be tested
t_toltolerance used to decide when a curve is a line tangent to X or Y axis
Returns
0 if there are no tangent points in the interval, 1 if there is a single vertical tangent, 2 if there is a single horizontal tangent, and 3 if multiple tangents are present.

Definition at line 75 of file libbrep_brep_tools.cpp.

References ON_NearZero().

Here is the call graph for this function:

BREP_EXPORT bool ON_Surface_IsFlat ( ON_Plane *  frames,
double  f_tol 
)

Perform flatness test of surface.

*   3-------------------2
*   |                   |
*   |    6         8    |
*   |                   |
*  V|         4         |
*   |                   |
*   |    5         7    |
*   |                   |
*   0-------------------1
*      U
* 

Determine whether a given surface is flat enough, i.e. it falls beneath our simple flatness constraints. The flatness constraint in this case is a sampling of normals across the surface such that the product of their combined dot products is close to 1.

\[ \prod_{i=1}^{7} n_i \dot n_{i+1} = 1 \]

This code is using a slightly different placement of the interior normal tests as compared to Abert's approach:

   +-------------------+
   |                   |
   |    +         +    |
   |                   |
 V |         +         |
   |                   |
   |    +         +    |
   |                   |
   +-------------------+
             U

The "+" indicates the normal sample.

The frenet frames are stored in the frames arrays according to the following index values:

   3-------------------2
   |                   |
   |    6         8    |
   |                   |
 V |         4         |
   |                   |
   |    5         7    |
   |                   |
   0-------------------1
             U
Parameters
framesArray of 9 frenet frames
f_tolFlatness tolerance - 0 always evaluates to flat, 1 would be a perfectly flat surface. Generally something in the range 0.8-0.9 should suffice in raytracing subdivision (per Abert, 2005)

Definition at line 117 of file libbrep_brep_tools.cpp.

BREP_EXPORT bool ON_Surface_IsFlat_U ( ON_Plane *  frames,
double  f_tol 
)

Perform flatness test of surface in U only.

Array index conventions are the same as ON_Surface_IsFlat.

Parameters
framesArray of 9 frenet frames
s_tolStraightness tolerance - 0 always evaluates to straight, 1 requires perfect straightness

Definition at line 132 of file libbrep_brep_tools.cpp.

BREP_EXPORT bool ON_Surface_IsFlat_V ( ON_Plane *  frames,
double  f_tol 
)

Perform flatness test of surface in V only.

Array index conventions are the same as ON_Surface_IsFlat.

Parameters
framesArray of 9 frenet frames
s_tolStraightness tolerance - 0 always evaluates to straight, 1 requires perfect straightness

Definition at line 161 of file libbrep_brep_tools.cpp.

BREP_EXPORT bool ON_Surface_IsStraight ( ON_Plane *  frames,
double  s_tol 
)

Perform straightness test of surface.

The straightness test compares flatness criteria to running product of the tangent vector of the frenet frame projected onto each other tangent in the frame set. Array index conventions are the same as ON_Surface_IsFlat.

Parameters
framesArray of 9 frenet frames
s_tolStraightness tolerance - 0 always evaluates to straight, 1 requires perfect straightness

Definition at line 190 of file libbrep_brep_tools.cpp.

BREP_EXPORT bool ON_Surface_SubSurface ( const ON_Surface *  srf,
ON_Interval *  u_val,
ON_Interval *  v_val,
ON_Surface **  t1,
ON_Surface **  t2,
ON_Surface **  t3,
ON_Surface **  t4,
ON_Surface **  result 
)

Create a surface based on a subset of a parent surface.

Create a NURBS surface that corresponds to a subset of an input surface, as defined by UV intervals. The t parameters may be NULL, in which case working surfaces will be created by the function. If supplied, existing surfaces are reused to avoid extra malloc operations and memory usage associated with creating the working surfaces.

Parameters
srfparent ON_Surface
u_valU interval of proposed subsurface
v_valV interval of proposed subsurface
t1surface used during split algorithm
t2surface used during split algorithm
t3surface used during split algorithm
t4surface holding final result of split passes
[out]resultfinal subsurface - holds *t4 if it was non-NULL as an input, else holds a pointer to the new ON_Surface
Returns
true if surface creation is successful or if the subsurface is the same as the parent surface, false if one or more split operations failed.

Definition at line 239 of file libbrep_brep_tools.cpp.

References ON_Surface_Create_Scratch_Surfaces().

Here is the call graph for this function:

BREP_EXPORT bool ON_Surface_Quad_Split ( const ON_Surface *  srf,
const ON_Interval &  u,
const ON_Interval &  v,
double  upt,
double  vpt,
ON_Surface **  q0,
ON_Surface **  q1,
ON_Surface **  q2,
ON_Surface **  q3 
)

Create four sub-surfaces from a parent surface.

Create four NURBS surfaces that corresponds to subsets of an input surface, as defined by UV intervals and a point within the U and V intervals.

   *---------------------*
   |          |          |
   |    q3    |    q2    |
   |          |          |
 V |----------+----------|
   |          |          |
   |    q0    |    q1    |
   |          |          |
   *---------------------*
             U

+ is the point (upt, vpt) that defines the quads
* points represent the mins and maxes of the U and V domains
Parameters
srfparent ON_Surface
uU interval of parent surface
vV interval of parent surface
uptU interval point for quad definition
uptU interval point for quad definition
q0surface calculated by split algorithm
q1surface calculated by split algorithm
q2surface calculated by split algorithm
q3surface calculated by split algorithm
Returns
true if surfaces are successfully created, false if one or more split operations failed, the q* containers are not NULL, or the upt,vpt coordinates are not contained within the UV interval.

Definition at line 303 of file libbrep_brep_tools.cpp.

References bu_log().

Here is the call graph for this function: