[brlcad-commits] SF.net SVN: brlcad:[51999] brlcad/trunk/src/librt/primitives/nmg/ nmg_rt_segs.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2012-08-14 13:18:03
|
Revision: 51999 http://brlcad.svn.sourceforge.net/brlcad/?rev=51999&view=rev Author: brlcad Date: 2012-08-14 13:17:52 +0000 (Tue, 14 Aug 2012) Log Message: ----------- apply sf patch 3549356 from ksuzee (Reduction in src/librt/primitives/nmg/nmg_rt_segs.c). the body of functions state5() and state6() were united, put into a common 'state5and6' (slightly patch mod) function. Modified Paths: -------------- brlcad/trunk/src/librt/primitives/nmg/nmg_rt_segs.c Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_rt_segs.c =================================================================== --- brlcad/trunk/src/librt/primitives/nmg/nmg_rt_segs.c 2012-08-14 05:55:53 UTC (rev 51998) +++ brlcad/trunk/src/librt/primitives/nmg/nmg_rt_segs.c 2012-08-14 13:17:52 UTC (rev 51999) @@ -682,15 +682,8 @@ return ret_val; } - -HIDDEN int -state5(struct seg *seghead, struct seg **seg_p, int *seg_count, struct hitmiss *a_hit, struct soltab *stp, struct application *ap, struct bn_tol *tol) - /* intersection w/ ray */ - /* The segment we're building */ - /* The number of valid segments built */ - /* The input hit point */ - - +static inline int +state5and6(struct seg *seghead, struct seg **seg_p, int *seg_count, struct hitmiss *a_hit, struct soltab *stp, struct application *ap, struct bn_tol *tol, int ret_val_7) { int ret_val = -1; double delta; @@ -752,7 +745,7 @@ BN_CK_TOL(tol); delta = fabs((*seg_p)->seg_in.hit_dist - a_hit->hit.hit_dist); if (delta < tol->dist) { - ret_val = 5; + ret_val = ret_val_7; } else { /* complete the segment */ BU_LIST_MAGIC_SET(&((*seg_p)->l), RT_SEG_MAGIC); @@ -776,98 +769,27 @@ return ret_val; } - HIDDEN int -state6(struct seg *seghead, struct seg **seg_p, int *seg_count, struct hitmiss *a_hit, struct soltab *stp, struct application *ap, struct bn_tol *tol) +state5(struct seg *seghead, struct seg **seg_p, int *seg_count, struct hitmiss *a_hit, struct soltab *stp, struct application *ap, struct bn_tol *tol) /* intersection w/ ray */ /* The segment we're building */ /* The number of valid segments built */ /* The input hit point */ - { - int ret_val = -1; - double delta; + return state5and6(seghead, seg_p, seg_count, a_hit, stp, ap, tol, 5); +} - NMG_CK_HITMISS(a_hit); - switch (a_hit->in_out) { - case HMG_HIT_OUT_ON: - case HMG_HIT_OUT_IN: - CK_SEGP(seg_p); - BN_CK_TOL(tol); - delta = fabs((*seg_p)->seg_in.hit_dist - a_hit->hit.hit_dist); - if (delta < tol->dist) { - ret_val = 5; - } else { - /* complete the segment */ - BU_LIST_MAGIC_SET(&((*seg_p)->l), RT_SEG_MAGIC); - BU_LIST_INSERT(&(seghead->l), &((*seg_p)->l)); - (*seg_count)++; +HIDDEN int +state6(struct seg *seghead, struct seg **seg_p, int *seg_count, struct hitmiss *a_hit, struct soltab *stp, struct application *ap, struct bn_tol *tol) + /* intersection w/ ray */ + /* The segment we're building */ + /* The number of valid segments built */ + /* The input hit point */ - /* start new segment */ - (*seg_p) = (struct seg *)NULL; - set_inpoint(seg_p, a_hit, stp, ap); - ret_val = 1; - } - break; - case HMG_HIT_IN_IN: - case HMG_HIT_ON_IN: - case HMG_HIT_IN_ON: - case HMG_HIT_ON_ON: - ret_val = 1; - break; - case HMG_HIT_ON_OUT: - case HMG_HIT_IN_OUT: - set_outpoint(seg_p, a_hit); - ret_val = 2; - break; - case HMG_HIT_OUT_OUT: - CK_SEGP(seg_p); - BN_CK_TOL(tol); - delta = fabs((*seg_p)->seg_in.hit_dist - a_hit->hit.hit_dist); - if (delta < tol->dist) { - ret_val = 6; - } else { - /* complete the segment */ - BU_LIST_MAGIC_SET(&((*seg_p)->l), RT_SEG_MAGIC); - BU_LIST_INSERT(&(seghead->l), &((*seg_p)->l)); - (*seg_count)++; - - /* start new segment */ - (*seg_p) = (struct seg *)NULL; - set_inpoint(seg_p, a_hit, stp, ap); - set_outpoint(seg_p, a_hit); - ret_val = 3; - } - break; - case HMG_HIT_ANY_ANY: - CK_SEGP(seg_p); - BN_CK_TOL(tol); - delta = fabs((*seg_p)->seg_in.hit_dist - a_hit->hit.hit_dist); - if (delta < tol->dist) { - ret_val = 6; - } else { - /* complete the segment */ - BU_LIST_MAGIC_SET(&((*seg_p)->l), RT_SEG_MAGIC); - BU_LIST_INSERT(&(seghead->l), &((*seg_p)->l)); - (*seg_count)++; - - /* start new segment */ - (*seg_p) = (struct seg *)NULL; - set_inpoint(seg_p, a_hit, stp, ap); - set_outpoint(seg_p, a_hit); - ret_val = 4; - } - break; - default: - bu_log("%s[line:%d]: bogus hit in/out status\n", - __FILE__, __LINE__); - nmg_rt_segs_exit("Goodbye\n"); - break; - } - - return ret_val; +{ + return state5and6(seghead, seg_p, seg_count, a_hit, stp, ap, tol, 6); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |