Revision: 52643
http://brlcad.svn.sourceforge.net/brlcad/?rev=52643&view=rev
Author: r_weiss
Date: 2012-10-01 21:18:13 +0000 (Mon, 01 Oct 2012)
Log Message:
-----------
Within file "nmg_inter.c" updated function "nmg_coplanar_face_vertex_fuse" to
use function "nmg_vertex_fuse" instead of its own fusing code. Updated function
"nmg_vertex_fuse" within file "nmg_fuse.c" to also accept a bu_ptbl structure
as input.
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/nmg/nmg_fuse.c
brlcad/trunk/src/librt/primitives/nmg/nmg_inter.c
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_fuse.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_fuse.c 2012-10-01 20:59:20 UTC
(rev 52642)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_fuse.c 2012-10-01 21:18:13 UTC
(rev 52643)
@@ -313,30 +313,57 @@
/**
* N M G _ V E R T E X _ F U S E
*
- * Fuse together any vertices that are geometrically
- * identical, within the tolerance.
+ * Fuse together any vertices that are geometrically identical, within
+ * distance tolerance. This function may be passed a pointer to an NMG
+ * object or a pointer to a bu_ptbl structure containing a list of
+ * pointers to NMG vertex structures. If a bu_ptbl structure was passed
+ * into this function, the calling function must free this structure.
*/
int
nmg_vertex_fuse(const uint32_t *magic_p, const struct bn_tol *tol)
{
- struct bu_ptbl t1;
+ struct bu_ptbl *t1;
+ struct bu_ptbl tmp;
+ size_t t1_len;
int total = 0;
+ const uint32_t *tmp_magic_p;
BN_CK_TOL(tol);
- nmg_vertex_tabulate(&t1, magic_p);
+ if (!magic_p) {
+ bu_bomb("nmg_vertex_fuse(): passed null pointer");
+ }
+ if (*magic_p == BU_PTBL_MAGIC) {
+ t1 = (struct bu_ptbl *)magic_p;
+ t1_len = BU_PTBL_LEN(t1);
+ if (t1_len) {
+ tmp_magic_p = (const uint32_t *)BU_PTBL_GET((struct bu_ptbl
*)magic_p, 0);
+ if (*tmp_magic_p != NMG_VERTEX_MAGIC) {
+ bu_bomb("nmg_vertex_fuse(): passed bu_ptbl structure not
containing vertex");
+ }
+ }
+ } else {
+ t1 = &tmp;
+ nmg_vertex_tabulate(t1, magic_p);
+ t1_len = BU_PTBL_LEN(t1);
+ }
+
/* if there are no vertex, do nothing */
- if (!BU_PTBL_END(&t1)) {
+ if (!t1_len) {
return 0;
}
- total = nmg_ptbl_vfuse(&t1, tol);
+ total = nmg_ptbl_vfuse(t1, tol);
- bu_ptbl_free(&t1);
+ /* if bu_ptbl was passed into this function don't free it here */
+ if (*magic_p != BU_PTBL_MAGIC) {
+ bu_ptbl_free(t1);
+ }
if (rt_g.NMG_debug & DEBUG_BASIC && total > 0)
bu_log("nmg_vertex_fuse() %d\n", total);
+
return total;
}
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_inter.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_inter.c 2012-10-01 20:59:20 UTC
(rev 52642)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_inter.c 2012-10-01 21:18:13 UTC
(rev 52643)
@@ -2363,54 +2363,45 @@
static void
nmg_coplanar_face_vertex_fuse(struct faceuse *fu1, struct faceuse *fu2, struct
bn_tol *tol)
{
- struct bu_ptbl fu1_verts;
- struct bu_ptbl fu2_verts;
- int i, j;
- vect_t norm;
+ struct bu_ptbl verts;
+ struct faceuse *faces[4];
+ struct loopuse *lu;
+ struct edgeuse *eu;
+ struct vertexuse *vu;
+ int i;
- NMG_CK_FACEUSE(fu1);
- NMG_CK_FACEUSE(fu2);
- BN_CK_TOL(tol);
+ bu_ptbl_init(&verts, 128, "&verts");
- NMG_GET_FU_NORMAL(norm, fu1);
+ faces[0] = fu1;
+ faces[1] = fu1->fumate_p;
+ faces[2] = fu2;
+ faces[3] = fu2->fumate_p;
- nmg_vertex_tabulate(&fu1_verts, &fu1->l.magic);
- nmg_vertex_tabulate(&fu2_verts, &fu2->l.magic);
-
- for (i=0; i<BU_PTBL_END(&fu1_verts); i++) {
- struct vertex *v1;
-
- v1 = (struct vertex *)BU_PTBL_GET(&fu1_verts, i);
-
- for (j=0; j<BU_PTBL_END(&fu2_verts); j++) {
- struct vertex *v2;
- vect_t diff;
- vect_t diff_unit;
- fastf_t len_sq, inv_len;
- fastf_t dot;
-
- v2 = (struct vertex *)BU_PTBL_GET(&fu2_verts, j);
-
- if (v1 == v2)
- continue;
-
- VSUB2(diff, v1->vg_p->coord, v2->vg_p->coord);
- len_sq = MAGSQ(diff);
- if (len_sq > 4.0*tol->dist_sq)
- continue;
-
- inv_len = 1.0 / sqrt(len_sq);
-
- VSCALE(diff_unit, diff, inv_len);
-
- dot = VDOT(norm, diff_unit);
- if (BN_VECT_ARE_PARALLEL(dot, tol)) {
- /* fuse these two vertices */
- nmg_jv(v2, v1);
- break;
+ for (i = 0 ; i < 4 ; i++) {
+ NMG_CK_FACEUSE(faces[i]);
+ for (BU_LIST_FOR(lu, loopuse, &faces[i]->lu_hd)) {
+ NMG_CK_LOOPUSE(lu);
+ if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_EDGEUSE_MAGIC) {
+ for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
+ NMG_CK_EDGEUSE(eu);
+ NMG_CK_VERTEXUSE(eu->vu_p);
+ NMG_CK_VERTEX(eu->vu_p->v_p);
+ (void)bu_ptbl_ins_unique(&verts, (long *)eu->vu_p->v_p);
+ }
+ } else if (BU_LIST_FIRST_MAGIC(&lu->down_hd) ==
NMG_VERTEXUSE_MAGIC) {
+ vu = BU_LIST_FIRST(vertexuse, &lu->down_hd);
+ NMG_CK_VERTEXUSE(vu);
+ NMG_CK_VERTEX(vu->v_p);
+ (void)bu_ptbl_ins_unique(&verts, (long *)vu->v_p);
+ } else {
+ bu_bomb("nmg_coplanar_face_vertex_fuse(): invalid loopuse");
}
}
}
+
+ (void)nmg_vertex_fuse((const uint32_t *)&verts, tol);
+
+ bu_ptbl_free(&verts);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits