BRLCAD

#include "common.h"
#include <math.h>
#include "bio.h"
#include "vmath.h"
#include "raytrace.h"
#include "nurb.h"
Go to the source code of this file.
Data Structures  
struct  _interior_line 
Macros  
#define  QUAD1 0 
#define  QUAD2 1 
#define  QUAD3 2 
#define  QUAD4 3 
#define  TRIM_OUT 0 
#define  TRIM_IN 1 
#define  TRIM_ON 2 
#define  CASE_A 0 
#define  CASE_B 2 
#define  CASE_C 3 
Functions  
void  rt_clip_cnurb (struct bu_list *plist, struct edge_g_cnurb *crv, fastf_t u, fastf_t v) 
int  rt_trim_case (struct edge_g_cnurb *trim, fastf_t u, fastf_t v) 
int  rt_process_caseb (struct edge_g_cnurb *trim, fastf_t u, fastf_t v) 
int  rt_nurb_uv_dist (struct edge_g_cnurb *trim, fastf_t u, fastf_t v) 
int  rt_process_casec (struct edge_g_cnurb *trim, fastf_t u, fastf_t v) 
int  rt_uv_in_trim (struct edge_g_cnurb *trim, fastf_t u, fastf_t v) 
fastf_t  rt_trim_line_pt_dist (struct _interior_line *l, fastf_t *pt, int pt_type) 
int  _SIGN (fastf_t f) 
int  nmg_uv_in_lu (const fastf_t u, const fastf_t v, const struct loopuse *lu) 
Trimming curve routines.
Definition in file nurb_trim.c.
#define QUAD1 0 
Definition at line 46 of file nurb_trim.c.
Referenced by rt_process_caseb(), and rt_trim_case().
#define QUAD2 1 
Definition at line 47 of file nurb_trim.c.
Referenced by rt_process_caseb(), and rt_trim_case().
#define QUAD3 2 
Definition at line 48 of file nurb_trim.c.
Referenced by rt_process_caseb(), and rt_trim_case().
#define QUAD4 3 
Definition at line 49 of file nurb_trim.c.
Referenced by rt_process_caseb(), and rt_trim_case().
#define TRIM_OUT 0 
Definition at line 52 of file nurb_trim.c.
Referenced by rt_nurb_uv_dist(), rt_process_caseb(), rt_process_casec(), and rt_uv_in_trim().
#define TRIM_IN 1 
Definition at line 53 of file nurb_trim.c.
Referenced by rt_process_caseb(), and rt_process_casec().
#define TRIM_ON 2 
Definition at line 54 of file nurb_trim.c.
Referenced by rt_nurb_uv_dist(), and rt_process_casec().
#define CASE_A 0 
Definition at line 61 of file nurb_trim.c.
Referenced by rt_uv_in_trim().
#define CASE_B 2 
Definition at line 62 of file nurb_trim.c.
Referenced by rt_process_casec(), and rt_uv_in_trim().
#define CASE_C 3 
Definition at line 63 of file nurb_trim.c.
Referenced by rt_process_casec(), and rt_uv_in_trim().
We try to clip a curve so that it can be either Case A or Case C. Sometimes one of the curves is still Case C though, but it is much smaller than the original, and further clipping will either show that it is on the curve or provide all Case B or Case A curves. We try to pick the best axis to clip against, but this may not always work. One extra step that was included, that is not in the paper for curves but is for surfaces, is the fact that sometimes the curve is not clipped enough, if the maximum clip is less than .2 then we subdivide the curve in three equal parts, at .3 and .6 . Subdivision is done using the Oslo Algorithm, rather than the other methods which were prossed.
Definition at line 384 of file nurb_trim.c.
References _SIGN(), _interior_line::axis, BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_INSERT, _interior_line::o_dist, rt_nurb_c_xsplit(), rt_nurb_free_cnurb(), rt_trim_line_pt_dist(), OSL::Strings::u, and OSL::Strings::v.
Referenced by rt_process_casec().
This routine determines what quadrants the trimming curves lies in, It then uses a table look up to determine the whether its CASE{A, B, C}, One difference from the paper is the fact that if any of the points lie on the axis of the u, v quadrant system then the axis is only in either Quadrant 1 or Quadrant 2 and not q3 or q4. This handles the case of endpoint problems correctly.
Definition at line 80 of file nurb_trim.c.
References QUAD1, QUAD2, QUAD3, QUAD4, and OSL::Strings::v.
Referenced by rt_process_casec(), and rt_uv_in_trim().
Process Case B curves.
If the two endpoints of the curve lie in different quadrants than the axis crosses the curve an odd number of times (TRIM_IN). Otherwise the curve crosses the u, v axis a even number of times (TRIM_OUT). No further processing is required.
Definition at line 133 of file nurb_trim.c.
References QUAD1, QUAD2, QUAD3, QUAD4, TRIM_IN, TRIM_OUT, and OSL::Strings::v.
Referenced by rt_process_casec(), and rt_uv_in_trim().
Only check end points of the curve
Definition at line 177 of file nurb_trim.c.
References NEAR_ZERO, TRIM_ON, TRIM_OUT, OSL::Strings::u, and OSL::Strings::v.
Referenced by rt_process_casec().
Process Case C curves;
A check is placed here to determine if the u, v is on the curve. Determine how many times the curve will cross the u, v axis. If the curve crosses an odd number of times than the point is IN, else the point is OUT. Since a Case C curve need processing a call to clip the curve so that it becomes either Case B or Case A is required to determine the number of crossings accurately. Thus we need to keep the original curve and expect the calling routine to free the storage. Additional curves are generated in this routine, each of these new curves are processed, and then are deleted before exiting this procedure.
Definition at line 242 of file nurb_trim.c.
References BU_LIST_DEQUEUE, BU_LIST_INIT, BU_LIST_WHILE, CASE_B, CASE_C, clip(), nurb_c_to_bezier(), nurb_crv_is_bezier(), rt_clip_cnurb(), rt_nurb_free_cnurb(), rt_nurb_uv_dist(), rt_process_caseb(), rt_trim_case(), TRIM_IN, TRIM_ON, and TRIM_OUT.
Referenced by rt_uv_in_trim().
This routine will be called several times, once for each portion of the trimming curve. It returns whether a line extended from the <u, v> point will cross the trimming curve an even or odd number of times. Or the <u, v> point could be on the curve in which case TRIM_ON will be returned. The algorithm uses the approach taken Tom Sederburge and uses bezier clipping to produce caseA and caseB curves. If the original trimming curve is a CASE C curve then further processing is required.
Definition at line 308 of file nurb_trim.c.
References bu_log(), CASE_A, CASE_B, CASE_C, rt_process_caseb(), rt_process_casec(), rt_trim_case(), and TRIM_OUT.
Referenced by nmg_uv_in_lu().
fastf_t rt_trim_line_pt_dist  (  struct _interior_line *  l, 
fastf_t *  pt,  
int  pt_type  
) 
This routines is used to determine how far a point is from the u, v quadrant axes.
Equations 3, 4, 5 in Sederberg '90 paper
Definition at line 335 of file nurb_trim.c.
References _interior_line::axis, and _interior_line::o_dist.
Referenced by rt_clip_cnurb().
int _SIGN  (  fastf_t  f  ) 
Return the SIGN of the value
Definition at line 360 of file nurb_trim.c.
Referenced by rt_clip_cnurb().
Definition at line 497 of file nurb_trim.c.
References bu_bomb(), BU_LIST_FIRST_MAGIC, BU_LIST_FOR, bu_log(), NMG_CK_LOOPUSE(), NMG_EDGE_G_CNURB_MAGIC, NMG_EDGEUSE_MAGIC, NMG_VERTEXUSE_A_CNURB_MAGIC, rt_uv_in_trim(), and ZERO.
Referenced by isect_ray_snurb_face().