Revision: 45557
http://brlcad.svn.sourceforge.net/brlcad/?rev=45557&view=rev
Author: r_weiss
Date: 2011-07-20 23:30:03 +0000 (Wed, 20 Jul 2011)
Log Message:
-----------
Updated functions vertex_neighborhood, get_pole_dist_to_face,
guess_class_from_hitlist_min, guess_class_from_hitlist_max,
isect_ray_snurb_face, record_face_hit, edge_hit_ray_state, ray_hit_vertex,
nmg_class_ray_vs_shell within file nmg_rt_isect.c. Many changes are to support
the prototype version of nmg_triangulate_fu. The changes associated with this
prototype are disabled by default. The prototype related changes create a
unitized version of the ray direction vector where needed. The remaining
changes which are not related to the prototype function nmg_triangulate_fu are
enabled. These enabled changes fix floating point 0.0 compares replacing them
with SMALL_FASTF. The result will be more reliable classification of nmg
objects during nmg boolean operations which will improve the operation of such
commands as the mged 'facetize' and 'ev'. The prototype changes are a work in
progress.
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/nmg/nmg_rt_isect.c
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_rt_isect.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_rt_isect.c 2011-07-20
20:25:17 UTC (rev 45556)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_rt_isect.c 2011-07-20
23:30:03 UTC (rev 45557)
@@ -416,7 +416,7 @@
/* if plane point is "inside" edge B, plane point is PCA */
VSUB2(VtoPole_prj, Pole_prj_pt, vu->v_p->vg_p->coord);
- if (VDOT(leftB, VtoPole_prj) >= 0.0) {
+ if (VDOT(leftB, VtoPole_prj) > -SMALL_FASTF) {
/* plane point is "inside" edge B */
if (rt_g.NMG_debug & DEBUG_RT_ISECT)
bu_log("\tplane point inside face\n");
@@ -435,7 +435,7 @@
/* if plane point is "inside" edge A, plane point is PCA */
VSUB2(VtoPole_prj, Pole_prj_pt, vu->v_p->vg_p->coord);
- if (VDOT(leftA, VtoPole_prj) >= 0.0) {
+ if (VDOT(leftA, VtoPole_prj) > -SMALL_FASTF) {
/* plane point is "inside" edge A */
if (rt_g.NMG_debug & DEBUG_RT_ISECT)
bu_log("\tplane point inside face\n");
@@ -463,7 +463,7 @@
VPRINT("VtoPole_prj", VtoPole_prj);
}
- if (VDOT(leftA, VtoPole_prj) >= 0.0) {
+ if (VDOT(leftA, VtoPole_prj) > -SMALL_FASTF) {
/* plane point is "inside" edge A */
if (rt_g.NMG_debug & DEBUG_RT_ISECT)
bu_log("\tplane point inside face\n");
@@ -483,7 +483,7 @@
VPRINT("LeftB", leftB);
VPRINT("VtoPole_prj", VtoPole_prj);
}
- if (VDOT(leftB, VtoPole_prj) >= 0.0) {
+ if (VDOT(leftB, VtoPole_prj) > -SMALL_FASTF) {
/* plane point is "inside" edge B */
if (rt_g.NMG_debug & DEBUG_RT_ISECT)
bu_log("\tplane point inside face\n");
@@ -517,7 +517,7 @@
dotB = VDOT(leftB, VtoPole_prj);
if (dotA < dotB) {
- if (dotA >= 0.0) {
+ if (dotA > -SMALL_FASTF) {
/* Point is "inside" face,
* PCA is plane projection point.
*/
@@ -534,7 +534,7 @@
VMOVE(Pole_pca, pcaA);
}
} else {
- if (dotB >= 0.0) {
+ if (dotB > -SMALL_FASTF) {
/* Point is "inside" face,
* PCA is plane projection point
*/
@@ -736,6 +736,9 @@
struct edgeuse *eu;
vect_t edge_vect;
int found_faces;
+#ifdef TRI_PROTOTYPE
+ vect_t r_dir_unit;
+#endif
NMG_CK_VERTEXUSE(vu_p);
NMG_CK_VERTEX(vu_p->v_p);
@@ -750,8 +753,15 @@
if (t > dimen) dimen = t;
}
+#ifdef TRI_PROTOTYPE
+ VMOVE(r_dir_unit, rd->rp->r_dir);
+ VUNITIZE(r_dir_unit);
+ VJOIN1(North_Pole, vu_p->v_p->vg_p->coord, -dimen, r_dir_unit);
+ VJOIN1(South_Pole, vu_p->v_p->vg_p->coord, dimen, r_dir_unit);
+#else
VJOIN1(North_Pole, vu_p->v_p->vg_p->coord, -dimen, rd->rp->r_dir);
VJOIN1(South_Pole, vu_p->v_p->vg_p->coord, dimen, rd->rp->r_dir);
+#endif
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
VPRINT("\tNorth Pole", North_Pole);
@@ -890,7 +900,11 @@
/* we've found a vertex floating in space */
myhit->outbound_use = myhit->inbound_use = (long *)North_vu;
myhit->in_out = HMG_HIT_ANY_ANY;
+#ifdef TRI_PROTOTYPE
+ VREVERSE(myhit->hit.hit_normal, r_dir_unit);
+#else
VREVERSE(myhit->hit.hit_normal, rd->rp->r_dir);
+#endif
return;
}
@@ -906,7 +920,7 @@
cos_angle = VDOT(norm, VtoPole);
if (BN_VECT_ARE_PERP(cos_angle, rd->tol))
myhit->in_out |= NMG_RAY_STATE_ON << 4;
- else if (cos_angle > 0.0)
+ else if (cos_angle > SMALL_FASTF)
myhit->in_out |= NMG_RAY_STATE_OUTSIDE << 4;
else
myhit->in_out |= NMG_RAY_STATE_INSIDE << 4;
@@ -919,7 +933,7 @@
cos_angle = VDOT(norm, VtoPole);
if (BN_VECT_ARE_PERP(cos_angle, rd->tol))
myhit->in_out |= NMG_RAY_STATE_ON;
- else if (cos_angle > 0.0)
+ else if (cos_angle > SMALL_FASTF)
myhit->in_out |= NMG_RAY_STATE_OUTSIDE;
else
myhit->in_out |= NMG_RAY_STATE_INSIDE;
@@ -963,7 +977,13 @@
{
struct hitmiss *myhit;
vect_t v;
+#ifdef TRI_PROTOTYPE
+ vect_t r_dir_unit;
+ VMOVE(r_dir_unit, rd->rp->r_dir);
+ VUNITIZE(r_dir_unit);
+#endif
+
if (rt_g.NMG_debug & DEBUG_RT_ISECT)
bu_log("ray_hit_vertex x%x (%g %g %g) status=%d\n",
vu_p->v_p, V3ARGS(vu_p->v_p->vg_p->coord), status);
@@ -983,7 +1003,11 @@
/* v = vector from ray point to hit vertex */
VSUB2(v, vu_p->v_p->vg_p->coord, rd->rp->r_pt);
+#ifdef TRI_PROTOTYPE
+ myhit->hit.hit_dist = VDOT(v, r_dir_unit); /* distance along ray */
+#else
myhit->hit.hit_dist = VDOT(v, rd->rp->r_dir); /* distance along ray */
+#endif
VMOVE(myhit->hit.hit_point, vu_p->v_p->vg_p->coord);
myhit->hit.hit_private = (genptr_t) vu_p->v_p;
@@ -1174,7 +1198,13 @@
vect_t eu_vec;
vect_t norm;
int faces_found;
+#ifdef TRI_PROTOTYPE
+ vect_t r_dir_unit;
+ VMOVE(r_dir_unit, rd->rp->r_dir);
+ VUNITIZE(r_dir_unit);
+#endif
+
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
eu_p = BU_LIST_PNEXT_CIRC(edgeuse, eu);
bu_log("edge_hit_ray_state(%g %g %g -> %g %g %g _vs_ %g %g %g)\n",
@@ -1224,7 +1254,11 @@
goto next_edgeuse;
}
+#ifdef TRI_PROTOTYPE
+ cos_angle = VDOT(edge_left, r_dir_unit);
+#else
cos_angle = VDOT(edge_left, rd->rp->r_dir);
+#endif
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
bu_log("left_vect:(%g %g %g) cos_angle:%g\n",
@@ -1263,9 +1297,17 @@
eu_p = BU_LIST_PNEXT_CIRC(edgeuse, eu);
VSUB2(eu_vec, eu->vu_p->v_p->vg_p->coord,
eu_p->vu_p->v_p->vg_p->coord);
+#ifdef TRI_PROTOTYPE
+ VCROSS(edge_left, eu_vec, r_dir_unit);
+#else
VCROSS(edge_left, eu_vec, rd->rp->r_dir);
+#endif
VCROSS(myhit->inbound_norm, eu_vec, edge_left);
- if (VDOT(myhit->inbound_norm, rd->rp->r_dir) > 0.0) {
+#ifdef TRI_PROTOTYPE
+ if (VDOT(myhit->inbound_norm, r_dir_unit) > SMALL_FASTF) {
+#else
+ if (VDOT(myhit->inbound_norm, rd->rp->r_dir) > SMALL_FASTF) {
+#endif
VREVERSE(myhit->inbound_norm, myhit->inbound_norm);
}
VMOVE(myhit->outbound_norm, myhit->inbound_norm);
@@ -1283,7 +1325,11 @@
if (MAGSQ(norm) < VDIVIDE_TOL)
bu_bomb("edge_hit_ray_state() null normal!\n");
+#ifdef TRI_PROTOTYPE
+ cos_angle = VDOT(norm, r_dir_unit);
+#else
cos_angle = VDOT(norm, rd->rp->r_dir);
+#endif
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
VPRINT("\ninb face normal", norm);
@@ -1292,7 +1338,7 @@
if (BN_VECT_ARE_PERP(cos_angle, rd->tol))
myhit->in_out |= NMG_RAY_STATE_ON << 4;
- else if (cos_angle < 0.0)
+ else if (cos_angle < -SMALL_FASTF)
myhit->in_out |= NMG_RAY_STATE_OUTSIDE << 4;
else /* (cos_angle > 0.0) */
myhit->in_out |= NMG_RAY_STATE_INSIDE << 4;
@@ -1301,7 +1347,11 @@
/* Compute the ray state on the outbound side */
NMG_GET_FU_NORMAL(norm, outb_fu);
VMOVE(myhit->outbound_norm, norm);
+#ifdef TRI_PROTOTYPE
+ cos_angle = VDOT(norm, r_dir_unit);
+#else
cos_angle = VDOT(norm, rd->rp->r_dir);
+#endif
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
VPRINT("\noutb face normal", norm);
@@ -1310,7 +1360,7 @@
if (BN_VECT_ARE_PERP(cos_angle, rd->tol))
myhit->in_out |= NMG_RAY_STATE_ON;
- else if (cos_angle > 0.0)
+ else if (cos_angle > SMALL_FASTF)
myhit->in_out |= NMG_RAY_STATE_OUTSIDE;
else /* (cos_angle < 0.0) */
myhit->in_out |= NMG_RAY_STATE_INSIDE;
@@ -1440,7 +1490,13 @@
struct hitmiss *myhit;
int vhit1, vhit2;
double dist_along_ray;
+#ifdef TRI_PROTOTYPE
+ vect_t r_dir_unit;
+ VMOVE(r_dir_unit, rd->rp->r_dir);
+ VUNITIZE(r_dir_unit);
+#endif
+
status = bn_isect_line_lseg(&dist_along_ray,
rd->rp->r_pt, rd->rp->r_dir,
eu_p->vu_p->v_p->vg_p->coord,
@@ -1529,8 +1585,11 @@
/* a hit on an edge */
point_t pt;
+#ifdef TRI_PROTOTYPE
+ VJOIN1(pt, rd->rp->r_pt, dist_along_ray, r_dir_unit);
+#else
VJOIN1(pt, rd->rp->r_pt, dist_along_ray, rd->rp->r_dir);
-
+#endif
ray_hit_edge(rd, eu_p, dist_along_ray, pt);
break;
@@ -1699,6 +1758,9 @@
record_face_hit(struct ray_data *rd, struct hitmiss *myhit, fastf_t *plane_pt,
double dist, struct faceuse *fu_p, fastf_t *norm)
{
double cos_angle;
+#ifdef TRI_PROTOTYPE
+ vect_t r_dir_unit;
+#endif
BU_LIST_MAGIC_SET(&myhit->l, NMG_RT_HIT_MAGIC);
myhit->outbound_use = (long *)fu_p;
@@ -1715,7 +1777,13 @@
/* compute what the ray-state is before and after this
* encountering this hit point.
*/
+#ifdef TRI_PROTOTYPE
+ VMOVE(r_dir_unit, rd->rp->r_dir);
+ VUNITIZE(r_dir_unit);
+ cos_angle = VDOT(norm, r_dir_unit);
+#else
cos_angle = VDOT(norm, rd->rp->r_dir);
+#endif
if (rt_g.NMG_debug & DEBUG_RT_ISECT) {
VPRINT("face Normal", norm);
bu_log("cos_angle wrt ray direction: %g\n", cos_angle);
@@ -1749,7 +1817,7 @@
bu_log("%s[%d]: Ray is in plane of face?\n",
__FILE__, __LINE__);
bu_bomb("record_face_hit() I quit\n");
- } else if (cos_angle > 0.0) {
+ } else if (cos_angle > SMALL_FASTF) {
myhit->in_out = HMG_HIT_IN_OUT;
VREVERSE(myhit->outbound_norm, norm);
myhit->outbound_use = (long *)fu_p;
@@ -1767,7 +1835,7 @@
bu_log("%s[%d]: Ray is in plane of face?\n",
__FILE__, __LINE__);
bu_bomb("record_face_hit() I quit\n");
- } else if (cos_angle > 0.0) {
+ } else if (cos_angle > SMALL_FASTF) {
myhit->in_out = HMG_HIT_OUT_IN;
VREVERSE(myhit->inbound_norm, norm);
myhit->inbound_use = (long *)fu_p;
@@ -2006,7 +2074,7 @@
myhit->hit.hit_dist,
V3ARGS(myhit->hit.hit_point),
V3ARGS(myhit->hit.hit_normal));
- if (dot > 0.0)
+ if (dot > SMALL_FASTF)
bu_log("\t\tdot = %g (exit point)\n", dot);
else
bu_log("\t\tdot = %g (entrance point)\n", dot);
@@ -2019,7 +2087,7 @@
bu_log("%s[%d]: Ray is in plane of face?\n",
__FILE__, __LINE__);
bu_bomb("record_face_hit() I quit\n");
- } else if (dot > 0.0) {
+ } else if (dot > SMALL_FASTF) {
myhit->in_out = HMG_HIT_IN_OUT;
VMOVE(myhit->outbound_norm, myhit->hit.hit_normal);
myhit->outbound_use = (long *)fu;
@@ -2037,7 +2105,7 @@
bu_log("%s[%d]: Ray is in plane of face?\n",
__FILE__, __LINE__);
bu_bomb("record_face_hit() I quit\n");
- } else if (dot > 0.0) {
+ } else if (dot > SMALL_FASTF) {
myhit->in_out = HMG_HIT_OUT_IN;
VREVERSE(myhit->inbound_norm, myhit->hit.hit_normal);
myhit->inbound_use = (long *)fu;
@@ -2482,7 +2550,7 @@
if (a_hit->hit.hit_dist < -rd->tol->dist)
continue;
- } else if (a_hit->hit.hit_dist < 0.0)
+ } else if (a_hit->hit.hit_dist < -SMALL_FASTF)
continue;
if (a_hit->in_out == HMG_HIT_ANY_ANY)
@@ -2575,7 +2643,7 @@
if (a_hit->hit.hit_dist > rd->tol->dist)
continue;
- } else if (a_hit->hit.hit_dist > 0.0)
+ } else if (a_hit->hit.hit_dist > SMALL_FASTF)
continue;
if (a_hit->in_out == HMG_HIT_ANY_ANY)
@@ -2672,8 +2740,9 @@
int minus_class, plus_class;
int hari_kari_minus, hari_kari_plus;
-
+#ifndef TRI_PROTOTYPE
VUNITIZE(rp->r_dir);
+#endif
NMG_CK_SHELL(s);
BN_CK_TOL(tol);
@@ -2746,7 +2815,7 @@
if (rt_g.NMG_debug & (DEBUG_CLASSIFY|DEBUG_RT_ISECT)) {
bu_log("%s[%d]: shell Hits:\n", __FILE__, __LINE__);
for (BU_LIST_FOR(a_hit, hitmiss, &rd.rd_hit)) {
- if (a_hit->hit.hit_dist >= 0.0)
+ if (a_hit->hit.hit_dist > -SMALL_FASTF)
bu_log("Positive dist hit\n");
else
bu_log("Negative dist hit\n");
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits