Revision: 56566
http://sourceforge.net/p/brlcad/code/56566
Author: brlcad
Date: 2013-08-05 07:01:33 +0000 (Mon, 05 Aug 2013)
Log Message:
-----------
another 1057 lines gone, remove libnmg dead code
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c
brlcad/trunk/src/librt/primitives/nmg/nmg_mod.c
brlcad/trunk/src/librt/primitives/nmg/nmg_tri.c
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c 2013-08-05 06:54:27 UTC
(rev 56565)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c 2013-08-05 07:01:33 UTC
(rev 56566)
@@ -7880,86 +7880,7 @@
}
}
}
-#if 1
return 1;
-#else
- if (RTG.NMG_debug & DEBUG_BASIC) {
- bu_log("nmg_make_connect_faces: Looking for edges to split verts in
face = %d\n", verts_in_face);
- for (i=0; i<verts_in_face; i++)
- bu_log("\t x%x (%g %g %g)\n", face_verts[i],
V3ARGS(face_verts[i]->vg_p->coord));
- }
-
- for (i=0; i<verts_in_face-2; i++) {
- for (j=i+1; j<verts_in_face-1; j++) {
- for (k=j+1; k<verts_in_face; k++) {
- struct edgeuse *eu;
-
- if (RTG.NMG_debug & DEBUG_BASIC) {
- bu_log("Checking collinearity of:\n");
- bu_log("\t x%x (%g %g %g)\n", face_verts[i],
V3ARGS(face_verts[i]->vg_p->coord));
- bu_log("\t x%x (%g %g %g)\n", face_verts[j],
V3ARGS(face_verts[j]->vg_p->coord));
- bu_log("\t x%x (%g %g %g)\n", face_verts[k],
V3ARGS(face_verts[k]->vg_p->coord));
- }
-
- if (!bn_3pts_collinear(face_verts[i]->vg_p->coord,
- face_verts[j]->vg_p->coord,
- face_verts[k]->vg_p->coord, tol))
- continue;
- if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\t They are collinear\n");
-
- if ((eu = nmg_findeu(face_verts[i], face_verts[j], (struct
shell *)NULL,
- (struct edgeuse *)NULL, 0)))
- {
- if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\tFound eu between x%x and x%x\n",
face_verts[i], face_verts[j]);
-
- if (!bn_dist_pt3_lseg3(&dist, pca,
- face_verts[i]->vg_p->coord,
- face_verts[j]->vg_p->coord,
- face_verts[k]->vg_p->coord, tol))
- {
- new_eu = nmg_esplit(face_verts[k], eu, 1);
- Join_eus(face_verts[i], face_verts[k],
face_verts[j], tol);
- } else if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\t\tvertex x%x is outside eu\n",
face_verts[k]);
- }
- if ((eu = nmg_findeu(face_verts[i], face_verts[k], (struct
shell *)NULL,
- (struct edgeuse *)NULL, 0)))
- {
- if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\tFound eu between x%x and x%x\n",
face_verts[i], face_verts[k]);
-
- if (!bn_dist_pt3_lseg3(&dist, pca,
- face_verts[i]->vg_p->coord,
- face_verts[k]->vg_p->coord,
- face_verts[j]->vg_p->coord, tol))
- {
- new_eu = nmg_esplit(face_verts[j], eu, 1);
- Join_eus(face_verts[i], face_verts[j],
face_verts[k], tol);
- } else if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\t\tvertex x%x is outside eu\n",
face_verts[j]);
- }
- if ((eu = nmg_findeu(face_verts[j], face_verts[k], (struct
shell *)NULL,
- (struct edgeuse *)NULL, 0)))
- {
- if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\tFound eu between x%x and x%x\n",
face_verts[j], face_verts[k]);
-
- if (!bn_dist_pt3_lseg3(&dist, pca,
- face_verts[j]->vg_p->coord,
- face_verts[k]->vg_p->coord,
- face_verts[i]->vg_p->coord, tol))
- {
- new_eu = nmg_esplit(face_verts[i], eu, 1);
- Join_eus(face_verts[j], face_verts[i],
face_verts[k], tol);
- } else if (RTG.NMG_debug & DEBUG_BASIC)
- bu_log("\t\tvertex x%x is outside eu\n",
face_verts[i]);
- }
- }
- }
- }
-#endif
}
return 0;
}
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_mod.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_mod.c 2013-08-05 06:54:27 UTC
(rev 56565)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_mod.c 2013-08-05 07:01:33 UTC
(rev 56566)
@@ -2662,7 +2662,6 @@
vu = eu->vu_p;
NMG_CK_VERTEXUSE(vu);
-#if 1
if (!nmg_find_repeated_v_in_lu(vu)) continue;
/* avoid splitting a crack if possible */
@@ -2715,47 +2714,6 @@
*/
goto top;
}
-
-#else
- v = vu->v_p;
- NMG_CK_VERTEX(v);
-
- /*
- * For each vertexuse on vertex list, check to see if it points up
- * to the this loop. If so, then there is a duplicated vertex.
- * Ordinarily, the vertex list will be *very* short, so this
- * strategy is likely to be faster than a table-based approach,
- * for most cases.
- */
- for (BU_LIST_FOR(tvu, vertexuse, &v->vu_hd)) {
- struct edgeuse *teu;
- struct loopuse *tlu;
-
- if (tvu == vu) continue;
- if (*tvu->up.magic_p != NMG_EDGEUSE_MAGIC) continue;
- teu = tvu->up.eu_p;
- NMG_CK_EDGEUSE(teu);
- if (*teu->up.magic_p != NMG_LOOPUSE_MAGIC) continue;
- tlu = teu->up.lu_p;
- NMG_CK_LOOPUSE(tlu);
- if (tlu != lu) continue;
- /*
- * Repeated vertex exists, Split loop into two loops
- */
- newlu = nmg_split_lu_at_vu(lu, vu);
- NMG_CK_LOOPUSE(newlu);
- NMG_CK_LOOP(newlu->l_p);
- nmg_loop_g(newlu->l_p, tol);
-
- /* Ensure there are no duplications in new loop */
- nmg_split_touchingloops(newlu, tol);
-
- /* There is no telling where we will be in the remainder of
- * original loop, check 'em all.
- */
- goto top;
- }
-#endif
}
Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_tri.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_tri.c 2013-08-05 06:54:27 UTC
(rev 56565)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_tri.c 2013-08-05 07:01:33 UTC
(rev 56566)
@@ -117,71 +117,6 @@
static struct pt2d *find_pt2d(struct bu_list *tbl2d, struct vertexuse *vu);
static FILE *plot_fp;
-
-
-/* Disable unused functions print_2d_eu, print_trap, and print_tlist. */
-#if 0
-static void
-print_2d_eu(char *s, struct edgeuse *eu, struct bu_list *tbl2d)
-{
- struct pt2d *pt, *pt_next;
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_EDGEUSE(eu);
-
- pt = find_pt2d(tbl2d, eu->vu_p);
- pt_next = find_pt2d(tbl2d, (BU_LIST_PNEXT_CIRC(edgeuse, eu))->vu_p);
- bu_log("%s: 0x%08x %g %g -> %g %g\n", s, eu,
- pt->coord[X], pt->coord[Y],
- pt_next->coord[X], pt_next->coord[Y]);
-}
-
-
-static void
-print_trap(struct trap *tp, struct bu_list *tbl2d)
-{
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_TRAP(tp);
-
- bu_log("trap 0x%08x top pt2d: 0x%08x %g %g vu:0x%08x\n",
- tp,
- &tp->top, tp->top->coord[X], tp->top->coord[Y],
- tp->top->vu_p);
-
- if (tp->bot)
- bu_log("\t\tbot pt2d: 0x%08x %g %g vu:0x%08x\n",
- &tp->bot, tp->bot->coord[X], tp->bot->coord[Y],
- tp->bot->vu_p);
- else {
- bu_log("\tbot (nil)\n");
- }
-
- if (tp->e_left)
- print_2d_eu("\t\t e_left", tp->e_left, tbl2d);
-
- if (tp->e_right)
- print_2d_eu("\t\t e_right", tp->e_right, tbl2d);
-}
-
-
-static void
-print_tlist(struct bu_list *tbl2d, struct bu_list *tlist)
-{
- struct trap *tp;
- NMG_CK_TBL2D(tbl2d);
-
- bu_log("Trapezoid list start ----------\n");
- for (BU_LIST_FOR(tp, trap, tlist)) {
- NMG_CK_TRAP(tp);
- print_trap(tp, tbl2d);
- }
- bu_log("Trapezoid list end ----------\n");
-}
-#endif
-/* This is the endif to disable the functions print_2d_eu,
- * print_trap, print_tlist.
- */
-
-
static int flatten_debug=1;
static struct pt2d *
@@ -547,590 +482,7 @@
}
-#define POLY_SIDE 1
-#define HOLE_START 2
-#define POLY_START 3
-#define HOLE_END 4
-#define POLY_END 5
-#define HOLE_POINT 6
-#define POLY_POINT 7
-
-
-/* Disable unused functions vtype2d, poly_start_vertex,
- * poly_side_vertex, poly_end_vertex, hole_start_vertex,
- * hole_end_vertex, and nmg_trap_face.
- */
-#if 0
-/**
- *
- * characterize the edges which meet at this vertex.
- *
- * 1 2 3 4 5 6 7
- *
- * /- -\ ------- -\ /- \---/ -------
- * /-- --\ ---O--- O --\ /-- \-/ ---O--- O
- * O--- ---O --/ \-- /-\ ---O--- O -------
- * \-- --/ -/ \- /---\ -------
- * \- -/
- *
- * Poly Side Poly Start Poly End
- * Hole Start Hole end
- */
-static int
-vtype2d(struct pt2d *v, struct bu_list *tbl2d, const struct bn_tol *tol)
-{
- struct pt2d *p, *n; /* previous/this edge endpoints */
- struct loopuse *lu;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(v);
-
- /* get the next/previous points relative to v */
- p = PT2D_PREV(tbl2d, v);
- n = PT2D_NEXT(tbl2d, v);
-
-
- lu = nmg_find_lu_of_vu(v->vu_p);
-
- if (p == n && n == v) {
- /* loopuse of vertexuse or loopuse of 1 edgeuse */
- if (lu->orientation == OT_SAME)
- return POLY_POINT;
- else if (lu->orientation == OT_OPPOSITE)
- return HOLE_POINT;
- }
-
- if (P_GT_V(n, v) && P_GT_V(p, v)) {
- /*
- * \ /
- * \ /
- * .
- *
- * if this is a convex point, this is a polygon end
- * if it is a concave point, this is a hole end
- */
-
- if (p == n) {
- if (lu->orientation == OT_OPPOSITE)
- return HOLE_END;
- else if (lu->orientation == OT_SAME)
- return POLY_END;
- else {
- bu_log("%s: %d loopuse is not OT_SAME or OT_OPPOSITE\n",
- __FILE__, __LINE__);
- bu_bomb("bombing\n");
- }
- }
-
- if (is_convex(p, v, n, tol)) return POLY_END;
- else return HOLE_END;
-
- }
-
- if (P_LT_V(n, v) && P_LT_V(p, v)) {
- /* .
- * / \
- * / \
- *
- * if this is a convex point, this is a polygon start
- * if this is a concave point, this is a hole start
- */
-
- if (p == n) {
- if (lu->orientation == OT_OPPOSITE)
- return HOLE_START;
- else if (lu->orientation == OT_SAME)
- return POLY_START;
- else {
- bu_log("%s: %d loopuse is not OT_SAME or OT_OPPOSITE\n",
- __FILE__, __LINE__);
- bu_bomb("bombing\n");
- }
- }
-
- if (is_convex(p, v, n, tol))
- return POLY_START;
- else
- return HOLE_START;
- }
- if ((P_GT_V(n, v) && P_LT_V(p, v)) ||
- (P_LT_V(n, v) && P_GT_V(p, v))) {
- /*
- * |
- * |
- * .
- * \
- * \
- *
- * This is the "side" of a polygon.
- */
- return POLY_SIDE;
- }
- bu_log(
- "%s %d HELP! special case:\np:(%g %g) v:(%g %g)\nn:(%g %g)\n",
- __FILE__, __LINE__,
- p->coord[X], p->coord[Y],
- v->coord[X], v->coord[Y],
- n->coord[X], n->coord[Y]);
-
- return 0;
-}
-
-
-/**
- * Polygon point start.
- *
- * O
- * /-\
- * /---\
- * v
- *
- * start new trapezoid
- */
static void
-poly_start_vertex(struct pt2d *pt, struct bu_list *tbl2d, struct bu_list
*tlist)
-{
- struct trap *new_trap;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(pt);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g is polygon start vertex\n",
- pt->coord[X], pt->coord[Y]);
-
- BU_ALLOC(new_trap, struct trap);
- new_trap->top = pt;
- new_trap->bot = (struct pt2d *)NULL;
- new_trap->e_left = pt->vu_p->up.eu_p;
- new_trap->e_right = BU_LIST_PPREV_CIRC(edgeuse, pt->vu_p->up.eu_p);
- BU_LIST_MAGIC_SET(&new_trap->l, NMG_TRAP_MAGIC);
-
- /* add new trapezoid */
- BU_LIST_APPEND(tlist, &new_trap->l);
- NMG_CK_TRAP(new_trap);
-}
-
-
-/**
- * ^
- * /- -\
- * /-- --\
- * O--- ---O
- * \-- --/
- * \- -/
- * v
- *
- * finish trapezoid from vertex, start new trapezoid from vertex
- */
-static void
-poly_side_vertex(struct pt2d *pt, struct pt2d *tbl2d, struct bu_list *tlist)
-{
- struct trap *new_trap, *tp;
- struct edgeuse *upper_edge=NULL, *lower_edge=NULL;
- struct pt2d *pnext, *plast;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(pt);
- pnext = PT2D_NEXT(&tbl2d->l, pt);
- plast = PT2D_PREV(&tbl2d->l, pt);
- if (RTG.NMG_debug & DEBUG_TRI) {
- bu_log("%g %g is polygon side vertex\n",
- pt->coord[X], pt->coord[Y]);
- bu_log("%g %g -> %g %g -> %g %g\n",
- plast->coord[X],
- plast->coord[Y],
- pt->coord[X], pt->coord[Y],
- pnext->coord[X],
- pnext->coord[Y]);
- }
-
- /* find upper edge */
- if (P_LT_V(plast, pt) && P_GT_V(pnext, pt)) {
- /* ascending edge */
- upper_edge = pt->vu_p->up.eu_p;
- lower_edge = plast->vu_p->up.eu_p;
- } else if (P_LT_V(pnext, pt) && P_GT_V(plast, pt)) {
- /* descending edge */
- upper_edge = plast->vu_p->up.eu_p;
- lower_edge = pt->vu_p->up.eu_p;
- }
-
- NMG_CK_EDGEUSE(upper_edge);
- NMG_CK_EDGEUSE(lower_edge);
-
- /* find the uncompleted trapezoid in the tree
- * which contains the upper edge. This is the trapezoid we will
- * complete, and where we will add a new trapezoid
- */
- for (BU_LIST_FOR(tp, trap, tlist)) {
- NMG_CK_TRAP(tp);
- NMG_CK_EDGEUSE(tp->e_left);
- NMG_CK_EDGEUSE(tp->e_right);
- if ((tp->e_left == upper_edge || tp->e_right == upper_edge) &&
- tp->bot == (struct pt2d *)NULL) {
- break;
- }
- }
-
- if (UNLIKELY(!BU_LIST_MAGIC_EQUAL(&tp->l, NMG_TRAP_MAGIC)))
- bu_bomb ("didn't find trapezoid parent\n");
-
- /* complete trapezoid */
- tp->bot = pt;
-
- /* create new trapezoid with other (not upper) edge */
- BU_ALLOC(new_trap, struct trap);
- BU_LIST_MAGIC_SET(&new_trap->l, NMG_TRAP_MAGIC);
- new_trap->top = pt;
- new_trap->bot = (struct pt2d *)NULL;
- if (tp->e_left == upper_edge) {
- new_trap->e_left = lower_edge;
- new_trap->e_right = tp->e_right;
- } else if (tp->e_right == upper_edge) {
- new_trap->e_right = lower_edge;
- new_trap->e_left = tp->e_left;
- } else /* how did I get here? */
- bu_bomb("Why me? Always me!\n");
-
- BU_LIST_INSERT(tlist, &new_trap->l);
- NMG_CK_TRAP(new_trap);
-}
-
-
-/**
- * Polygon point end.
- *
- * ^
- * \---/
- * \-/
- * O
- *
- * complete trapezoid
- */
-static void
-poly_end_vertex(struct pt2d *pt, struct bu_list *tbl2d, struct bu_list *tlist)
-{
- struct trap *tp;
- struct edgeuse *e_left, *e_right;
- struct pt2d *pprev;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(pt);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g is polygon end vertex\n",
- pt->coord[X], pt->coord[Y]);
-
- /* get the two edges which end at this point */
- pprev = PT2D_PREV(tbl2d, pt);
- if (pprev == pt)
- bu_bomb("pprev == pt!\n");
-
- e_left = pprev->vu_p->up.eu_p;
- e_right = pt->vu_p->up.eu_p;
-
- /* find the trapezoid in tree which has
- * both edges ending at this point.
- */
- for (BU_LIST_FOR(tp, trap, tlist)) {
- NMG_CK_TRAP(tp);
- if (tp->e_left == e_left && tp->e_right == e_right && !tp->bot) {
- goto trap_found;
- } else if (tp->e_right == e_left && tp->e_left == e_right &&
- !tp->bot) {
- /* straighten things out for notational convenience*/
- e_right = tp->e_right;
- e_left = tp->e_left;
- goto trap_found;
- }
- }
-
- if (!tp->bot)
- bu_bomb("Didn't find trapezoid to close!\n");
- else
- return;
-
- /* Complete the trapezoid. */
- trap_found:
- tp->bot = pt;
-}
-
-
-/**
- * Hole Start in polygon
- *
- * -------
- * ---O---
- * --/ \--
- * -/ \-
- * v
- *
- * Finish existing trapezoid, start 2 new ones
- */
-static void
-hole_start_vertex(struct pt2d *pt, struct bu_list *tbl2d, struct bu_list
*tlist)
-{
- struct trap *tp, *new_trap;
- vect_t pv, ev, n;
- struct pt2d *e_pt, *next_pt;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(pt);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g is hole start vertex\n",
- pt->coord[X], pt->coord[Y]);
-
- /* we need to find the un-completed trapezoid which encloses this
- * point.
- */
- for (BU_LIST_FOR(tp, trap, tlist)) {
- NMG_CK_TRAP(tp);
- /* obviously, if the trapezoid has been completed, it's not
- * the one we want.
- */
- if (tp->bot) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("Trapezoid %g %g / %g %g completed... Skipping\n",
- tp->top->coord[X],
- tp->top->coord[Y],
- tp->bot->coord[X],
- tp->bot->coord[Y]);
- continue;
- }
-
- /* if point is at the other end of either the left edge
- * or the right edge, we've found the trapezoid to complete.
- *
- * First, we check the left edge
- */
- e_pt = find_pt2d(tbl2d, tp->e_left->vu_p);
- next_pt = find_pt2d(tbl2d,
- (BU_LIST_PNEXT_CIRC(edgeuse, tp->e_left))->vu_p);
-
- if (e_pt->vu_p->v_p == pt->vu_p->v_p ||
- next_pt->vu_p->v_p == pt->vu_p->v_p)
- goto gotit;
-
-
- /* check to see if the point is at the end of the right edge
- * of the trapezoid
- */
- e_pt = find_pt2d(tbl2d, tp->e_right->vu_p);
- next_pt = find_pt2d(tbl2d,
- (BU_LIST_PNEXT_CIRC(edgeuse, tp->e_right))->vu_p);
-
- if (e_pt->vu_p->v_p == pt->vu_p->v_p ||
- next_pt->vu_p->v_p == pt->vu_p->v_p)
- goto gotit;
-
-
- /* if point is right of left edge and left of right edge
- * we've found the trapezoid we need to work with.
- */
-
- /* form a vector from the start point of each edge to pt.
- * if crossing this vector with the vector of the edge
- * produces a vector with a positive Z component then the pt
- * is "inside" the trapezoid as far as this edge is concerned
- */
- e_pt = find_pt2d(tbl2d, tp->e_left->vu_p);
- next_pt = find_pt2d(tbl2d,
- (BU_LIST_PNEXT_CIRC(edgeuse, tp->e_left))->vu_p);
- VSUB2(pv, pt->coord, e_pt->coord);
- VSUB2(ev, next_pt->coord, e_pt->coord);
- VCROSS(n, ev, pv);
- if (n[2] <= 0.0) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("Continue #1\n");
- continue;
- }
-
- e_pt = find_pt2d(tbl2d, tp->e_right->vu_p);
- next_pt = find_pt2d(tbl2d,
- (BU_LIST_PNEXT_CIRC(edgeuse, tp->e_right))->vu_p);
- VSUB2(pv, pt->coord, e_pt->coord);
- VSUB2(ev, next_pt->coord, e_pt->coord);
- VCROSS(n, ev, pv);
- if (n[2] <= 0.0) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("Continue #2\n");
- continue;
- }
-
- goto gotit;
-
- }
-
- bu_log("didn't find trapezoid for hole-start point at:\n\t%g %g %g\n",
- V3ARGS(pt->vu_p->v_p->vg_p->coord));
-
- nmg_stash_model_to_file("tri_lone_hole.g",
- nmg_find_model(&pt->vu_p->l.magic),
- "lone hole start");
-
- bu_bomb("bombing\n");
- gotit:
- /* complete existing trapezoid */
- tp->bot = pt;
- /* create new left and right trapezoids */
-
- BU_ALLOC(new_trap, struct trap);
- new_trap->top = pt;
- new_trap->bot = (struct pt2d *)NULL;
- new_trap->e_left = tp->e_left;
- new_trap->e_right = BU_LIST_PPREV_CIRC(edgeuse, pt->vu_p->up.eu_p);
- BU_LIST_MAGIC_SET(&new_trap->l, NMG_TRAP_MAGIC);
- BU_LIST_APPEND(&tp->l, &new_trap->l);
-
- BU_ALLOC(new_trap, struct trap);
- new_trap->top = pt;
- new_trap->bot = (struct pt2d *)NULL;
- new_trap->e_left = pt->vu_p->up.eu_p;
- new_trap->e_right = tp->e_right;
- BU_LIST_MAGIC_SET(&new_trap->l, NMG_TRAP_MAGIC);
- BU_LIST_APPEND(&tp->l, &new_trap->l);
-}
-
-
-/**
- * Close hole
- *
- * ^
- * -\ /-
- * --\ /--
- * ---O---
- * -------
- *
- * complete right and left trapezoids
- * start new trapezoid
- *
- */
-static void
-hole_end_vertex(struct pt2d *pt, struct bu_list *tbl2d, struct bu_list *tlist)
-{
- struct edgeuse *eunext, *euprev;
- struct trap *tp, *tpnext, *tpprev;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(pt);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g is hole end vertex\n",
- pt->coord[X], pt->coord[Y]);
-
- /* find the trapezoids that will end at this vertex */
- eunext = pt->vu_p->up.eu_p;
- euprev = BU_LIST_PPREV_CIRC(edgeuse, eunext);
- tpnext = tpprev = (struct trap *)NULL;
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- print_2d_eu("eunext", eunext, tbl2d);
- print_2d_eu("euprev", euprev, tbl2d);
- }
-
- for (BU_LIST_FOR(tp, trap, tlist)) {
- NMG_CK_TRAP(tp);
- /* obviously, if the trapezoid has been completed, it's not
- * the one we want.
- */
- NMG_CK_TRAP(tp);
-
- if (tp->bot) {
- continue;
- } else {
- if (RTG.NMG_debug & DEBUG_TRI)
- print_trap(tp, tbl2d);
- }
-
- if (tp->e_left == eunext || tp->e_right == eunext) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("Found tpnext\n");
- tpnext = tp;
- }
-
- if (tp->e_right == euprev || tp->e_left == euprev) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("Found tpprev\n");
- tpprev = tp;
- }
- if (tpnext && tpprev)
- goto gotem;
- }
-
- bu_bomb("couldn't find both trapezoids of hole closing vertex\n");
- gotem:
- NMG_CK_TRAP(tpnext);
- NMG_CK_TRAP(tpprev);
-
- /* finish off the two trapezoids */
- tpnext->bot = pt;
- tpprev->bot = pt;
-
- /* start one new trapezoid */
-
- BU_ALLOC(tp, struct trap);
- tp->top = pt;
- tp->bot = (struct pt2d *)NULL;
- if (tpnext->e_left == eunext) {
- tp->e_right = tpnext->e_right;
- tp->e_left = tpprev->e_left;
- } else if (tpnext->e_right == eunext) {
- tp->e_left = tpnext->e_left;
- tp->e_right = tpprev->e_right;
- } else
- bu_bomb("Which is my left and which is my right?\n");
-
- BU_LIST_MAGIC_SET(&tp->l, NMG_TRAP_MAGIC);
- BU_LIST_APPEND(&tpprev->l, &tp->l);
-}
-
-
-/**
- * N M G _ T R A P _ F A C E
- *
- * Produce the trapezoidal decomposition of a face from the set of
- * 2D points.
- */
-static void
-nmg_trap_face(struct bu_list *tbl2d, struct bu_list *tlist, const struct
bn_tol *tol)
-{
- struct pt2d *pt;
-
- NMG_CK_TBL2D(tbl2d);
-
- for (BU_LIST_FOR(pt, pt2d, tbl2d)) {
- NMG_CK_PT2D(pt);
- switch (vtype2d(pt, tbl2d, tol)) {
- case POLY_SIDE:
- poly_side_vertex(pt, (struct pt2d *)tbl2d, tlist);
- break;
- case HOLE_START:
- hole_start_vertex(pt, tbl2d, tlist);
- break;
- case POLY_START:
- poly_start_vertex(pt, tbl2d, tlist);
- break;
- case HOLE_END:
- hole_end_vertex(pt, tbl2d, tlist);
- break;
- case POLY_END:
- poly_end_vertex(pt, tbl2d, tlist);
- break;
- default:
- bu_log("%g %g is UNKNOWN type vertex %s %d\n",
- pt->coord[X], pt->coord[Y],
- __FILE__, __LINE__);
- break;
- }
- }
-
-}
-#endif
-/* This is the endif to disable the functions vtype2d,
- * poly_start_vertex, poly_side_vertex, poly_end_vertex,
- * hole_start_vertex, hole_end_vertex, nmg_trap_face.
- */
-
-
-static void
map_new_vertexuse(struct bu_list *tbl2d, struct vertexuse *vu_p)
{
struct vertexuse *vu;
@@ -2040,486 +1392,6 @@
}
-/* Disable unused functions skip_cut, cut_diagonals, cut_unimonotone,
- * and nmg_plot_flat_face.
- */
-#if 0
-/**
- * Check to see if the edge between the top/bottom of the trapezoid
- * already exists.
- */
-static int
-skip_cut(struct bu_list *tbl2d, struct pt2d *top, struct pt2d *bot)
-{
- struct vertexuse *vu_top;
- struct vertexuse *vu_bot;
- struct vertexuse *vu;
- struct vertex *v;
- struct faceuse *fu;
- struct edgeuse *eu;
- struct edgeuse *eu_next;
- struct pt2d *top_next, *bot_next;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_PT2D(top);
- NMG_CK_PT2D(bot);
-
-
- top_next = PT2D_NEXT(tbl2d, top);
- bot_next = PT2D_NEXT(tbl2d, bot);
-
- if (top_next == bot || bot_next == top) {
- return 1;
- }
-
- vu_top = top->vu_p;
- vu_bot = bot->vu_p;
- NMG_CK_VERTEXUSE(vu_top);
- NMG_CK_VERTEXUSE(vu_bot);
-
- v = vu_top->v_p;
- NMG_CK_VERTEX(v);
- NMG_CK_VERTEX(vu_bot->v_p);
-
- fu = nmg_find_fu_of_vu(vu_top);
-
- for (BU_LIST_FOR(vu, vertexuse, &v->vu_hd)) {
- /* if parent is edge of this loop/face, and next
- * vertex around loop is the one for vu_bot, don't
- * make the cut.
- */
- if (nmg_find_fu_of_vu(vu) != fu) continue;
- if (!vu->up.magic_p) {
- bu_log("NULL vertexuse up %s %d\n",
- __FILE__, __LINE__);
- bu_bomb("");
- }
- if (*vu->up.magic_p != NMG_EDGEUSE_MAGIC) continue;
- eu = vu->up.eu_p;
- eu_next = BU_LIST_PNEXT_CIRC(edgeuse, eu);
-
- /* if the edge exists, don't try to re-cut it */
- if (eu_next->vu_p->v_p == vu_bot->v_p)
- return 1;
- }
-
- fu = nmg_find_fu_of_vu(vu_bot);
- v = vu_bot->v_p;
- for (BU_LIST_FOR(vu, vertexuse, &v->vu_hd)) {
- /* if parent is edge of this loop/face, and next
- * vertex around loop is the one for vu_bot, don't
- * make the cut.
- */
- if (nmg_find_fu_of_vu(vu) != fu) continue;
- if (!vu->up.magic_p) {
- bu_log("NULL vertexuse up %s %d\n",
- __FILE__, __LINE__);
- bu_bomb("");
- }
- if (*vu->up.magic_p != NMG_EDGEUSE_MAGIC) continue;
- eu = vu->up.eu_p;
- eu_next = BU_LIST_PNEXT_CIRC(edgeuse, eu);
-
- /* if the edge exists, don't try to re-cut it */
- if (eu_next->vu_p->v_p == vu_top->v_p)
- return 1;
- }
- return 0;
-}
-
-
-static void
-cut_diagonals(struct bu_list *tbl2d, struct bu_list *tlist, const struct
faceuse *fu, const struct bn_tol *tol)
-{
- struct trap *tp;
- int cut_count=0;
-
- static const int cut_color[3] = {255, 80, 80};
- static const int join_color[3] = {80, 80, 255};
-
- extern struct loopuse *nmg_find_lu_of_vu(const struct vertexuse *vu);
- struct loopuse *toplu, *botlu;
- struct loopuse *lu;
-
- NMG_CK_TBL2D(tbl2d);
- BN_CK_TOL(tol);
-
- /* Convert trap list to unimonotone polygons */
- for (BU_LIST_FOR(tp, trap, tlist)) {
- /* if top and bottom points are not on same edge of
- * trapezoid, we cut across the trapezoid with a new edge.
- */
-
- /* If the edge already exists in the face, don't bother
- * to add it.
- */
- if (!tp->top || !tp->bot) {
- bu_log("tp->top and/or tp->bot is/are NULL!!!!!!!\n");
- if (RTG.NMG_debug & DEBUG_TRI) {
- nmg_pr_fu_briefly(fu, "");
- if (tp->top)
- bu_log("tp->top is (%g %g %g)\n",
V3ARGS(tp->top->vu_p->v_p->vg_p->coord));
- if (tp->bot)
- bu_log("tp->bot is (%g %g %g)\n",
V3ARGS(tp->bot->vu_p->v_p->vg_p->coord));
- }
- bu_bomb("tp->top and/or tp->bot is/are NULL");
- }
- if (nmg_find_eu_in_face(tp->top->vu_p->v_p, tp->bot->vu_p->v_p, fu,
- (struct edgeuse *)NULL, 0) != (struct edgeuse
*)NULL) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("skipping %g %g/%g %g ... edge exists\n",
- tp->top->coord[X],
- tp->top->coord[Y],
- tp->bot->coord[X],
- tp->bot->coord[Y]);
- continue;
- }
-
-
- if (skip_cut(tbl2d, tp->top, tp->bot)) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("skipping %g %g/%g %g ... pts on same edge\n",
- tp->top->coord[X],
- tp->top->coord[Y],
- tp->bot->coord[X],
- tp->bot->coord[Y]);
- continue;
- }
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- bu_log("trying to cut ...\n");
- print_trap(tp, tbl2d);
- }
-
- /* top/bottom points are not on same side of trapezoid. */
-
- toplu = nmg_find_lu_of_vu(tp->top->vu_p);
- botlu = nmg_find_lu_of_vu(tp->bot->vu_p);
- NMG_CK_VERTEXUSE(tp->top->vu_p);
- NMG_CK_VERTEXUSE(tp->bot->vu_p);
- NMG_CK_LOOPUSE(toplu);
- NMG_CK_LOOPUSE(botlu);
-
- if (toplu == botlu) {
-
- /* if points are the same, this is a split-loop op */
- if (tp->top->vu_p->v_p == tp->bot->vu_p->v_p) {
-
- int touching_jaunt=0;
- struct edgeuse *eu1, *eu2, *eu1_prev, *eu2_prev;
-
- eu1 = tp->top->vu_p->up.eu_p;
- eu2 = tp->bot->vu_p->up.eu_p;
-
- eu1_prev = BU_LIST_PPREV_CIRC(edgeuse, &eu1->l);
- eu2_prev = BU_LIST_PPREV_CIRC(edgeuse, &eu2->l);
- if (NMG_ARE_EUS_ADJACENT(eu1, eu1_prev))
- touching_jaunt = 1;
- else if (NMG_ARE_EUS_ADJACENT(eu2, eu2_prev))
- touching_jaunt = 1;
-
- if (touching_jaunt) {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("splitting self-touching jaunt loop at (%g %g
%g)\n",
- V3ARGS(tp->bot->vu_p->v_p->vg_p->coord));
-
- nmg_loop_split_at_touching_jaunt(toplu, tol);
- } else {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("splitting self-touching loop at (%g %g %g)\n",
- V3ARGS(tp->bot->vu_p->v_p->vg_p->coord));
-
- nmg_split_touchingloops(toplu, tol);
- }
- for (BU_LIST_FOR(lu, loopuse, &fu->lu_hd))
- nmg_lu_reorient(lu);
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- char fname[32];
-
- sprintf(fname, "split%d.g", cut_count);
- nmg_stash_model_to_file(fname,
- nmg_find_model(&toplu->l.magic),
- "after split_touching_loop()");
- cut_count++;
- }
-
- } else {
-
- /* points are in same loop. Cut the loop */
-
- (void)cut_mapped_loop(tbl2d, tp->top,
- tp->bot, cut_color, tol, 1);
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- char fname[32];
-
- sprintf(fname, "cut%d.g", cut_count);
- nmg_stash_model_to_file(fname,
- nmg_find_model(&toplu->l.magic),
- "after cut_mapped_loop()");
- cut_count++;
- }
-
- }
-
- } else {
-
- /* points are in different loops, join the
- * loops together.
- */
-
- if (toplu->orientation == OT_OPPOSITE &&
- botlu->orientation == OT_OPPOSITE)
- bu_bomb("trying to join 2 interior loops in triangulator?\n");
-
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("joining 2 loops @ %g %g -> %g %g\n",
- tp->top->coord[X],
- tp->top->coord[Y],
- tp->bot->coord[X],
- tp->bot->coord[Y]);
-
- join_mapped_loops(tbl2d, tp->top, tp->bot, join_color, tol);
- NMG_CK_LOOPUSE(toplu);
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- char fname[32];
-
- sprintf(fname, "join%d.g", cut_count);
- nmg_stash_model_to_file(fname,
- nmg_find_model(&toplu->l.magic),
- "after join_mapped_loop()");
- cut_count++;
- }
-
- }
-
- if (RTG.NMG_debug & DEBUG_TRI) {
- nmg_tri_plfu(nmg_find_fu_of_vu(tp->top->vu_p), tbl2d);
- print_tlist(tbl2d, tlist);
- }
- }
-
-}
-
-
-/**
- * C U T _ U N I M O N O T O N E
- *
- * Given a unimonotone loopuse, triangulate it into multiple loopuses
- */
-HIDDEN void
-cut_unimonotone(struct bu_list *tbl2d, struct loopuse *lu, const struct bn_tol
*tol)
-{
- struct pt2d *min, *max, *newpt, *first=NULL, *prev, *next, *current;
- struct edgeuse *eu;
- int verts=0;
- int vert_count_sq; /* XXXXX Hack for catching infinite loop */
- int loop_count=0; /* See above */
- static const int cut_color[3] = { 90, 255, 90};
-
- NMG_CK_TBL2D(tbl2d);
- BN_CK_TOL(tol);
- NMG_CK_LOOPUSE(lu);
-
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("cutting unimonotone:\n");
-
- min = max = (struct pt2d *)NULL;
-
- /* find min/max points & count vertex points */
- for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
- newpt = find_pt2d(tbl2d, eu->vu_p);
- if (!newpt) {
- bu_log("why can't I find a 2D point for %g %g %g?\n",
- V3ARGS(eu->vu_p->v_p->vg_p->coord));
- bu_bomb("bombing\n");
- }
-
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g\n", newpt->coord[X], newpt->coord[Y]);
-
- verts++;
-
- if (!min || P_LT_V(newpt, min))
- min = newpt;
- if (!max || P_GT_V(newpt, max))
- max = newpt;
- }
- vert_count_sq = verts * verts;
-
- /* pick the pt which does NOT have the other as a "next" pt in loop
- * as the place from which we start marching around the uni-monotone
- */
- if (PT2D_NEXT(tbl2d, max) == min)
- first = min;
- else if (PT2D_NEXT(tbl2d, min) == max)
- first = max;
- else {
- bu_log("is this a unimonotone loop of just 2 points?:\t%g %g %g and %g
%g %g?\n",
- V3ARGS(min->vu_p->v_p->vg_p->coord),
- V3ARGS(max->vu_p->v_p->vg_p->coord));
-
- bu_bomb("aborting\n");
- }
-
- /* */
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%d verts in unimonotone, Min: %g %g Max: %g %g first:%g %g
0x%08x\n", verts,
- min->coord[X], min->coord[Y],
- max->coord[X], max->coord[Y],
- first->coord[X], first->coord[Y], first);
-
- current = PT2D_NEXT(tbl2d, first);
-
- while (verts > 3) {
-
- loop_count++;
- if (loop_count > vert_count_sq) {
- bu_log("Cut_unimonotone is in an infinite loop!!!\n");
- bu_bomb("Cut_unimonotone is in an infinite loop");
- }
-
- prev = PT2D_PREV(tbl2d, current);
- next = PT2D_NEXT(tbl2d, current);
-
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("%g %g -> %g %g -> %g %g ...\n",
- prev->coord[X],
- prev->coord[Y],
- current->coord[X],
- current->coord[Y],
- next->coord[X],
- next->coord[Y]);
-
- if (is_convex(prev, current, next, tol)) {
- struct pt2d *t;
- /* cut a triangular piece off of the loop to
- * create a new loop.
- */
- NMG_CK_LOOPUSE(lu);
- if (RTG.NMG_debug & DEBUG_TRI) {
- bu_log("Before cut loop:\n");
- nmg_pr_fu_briefly(lu->up.fu_p, "");
- }
- current = cut_mapped_loop(tbl2d, next, prev, cut_color, tol, 0);
- if (RTG.NMG_debug & DEBUG_TRI) {
- bu_log("After cut loop:\n");
- nmg_pr_fu_briefly(lu->up.fu_p, "");
- }
- verts--;
- NMG_CK_LOOPUSE(lu);
-
- if (RTG.NMG_debug & DEBUG_TRI)
- nmg_tri_plfu(lu->up.fu_p, tbl2d);
-
- if (current->vu_p->v_p == first->vu_p->v_p) {
- t = PT2D_NEXT(tbl2d, first);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("\tfirst(0x%08x -> %g %g\n", first, t->coord[X],
t->coord[Y]);
- t = PT2D_NEXT(tbl2d, current);
-
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("\tcurrent(0x%08x) -> %g %g\n", current,
t->coord[X], t->coord[Y]);
-
- current = PT2D_NEXT(tbl2d, current);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("\tcurrent(0x%08x) -> %g %g\n", current,
t->coord[X], t->coord[Y]);
- }
- } else {
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("\tConcave, moving ahead\n");
- current = next;
- }
- }
-}
-
-
-static void
-nmg_plot_flat_face(struct faceuse *fu, struct bu_list *tbl2d)
-{
- struct loopuse *lu;
- struct edgeuse *eu;
- char buf[80];
- vect_t pt;
- struct pt2d *p, *pn;
-
- NMG_CK_TBL2D(tbl2d);
- NMG_CK_FACEUSE(fu);
-
- if (!plot_fp) {
- plot_fp = fopen("triplot.plot3", "wb");
- if (plot_fp == (FILE *)NULL) {
- bu_bomb("ERROR: cannot open triplot.plot3\n");
- }
- }
-
- pl_erase(plot_fp);
- pd_3space(plot_fp,
- fu->f_p->min_pt[0]-1.0,
- fu->f_p->min_pt[1]-1.0,
- fu->f_p->min_pt[2]-1.0,
- fu->f_p->max_pt[0]+1.0,
- fu->f_p->max_pt[1]+1.0,
- fu->f_p->max_pt[2]+1.0);
-
- for (BU_LIST_FOR(lu, loopuse, &fu->lu_hd)) {
- if (BU_LIST_FIRST_MAGIC(&lu->down_hd) == NMG_VERTEXUSE_MAGIC) {
- register struct vertexuse *vu;
-
- vu = BU_LIST_FIRST(vertexuse, &lu->down_hd);
- if (RTG.NMG_debug & DEBUG_TRI)
- bu_log("lone vert @ %g %g %g\n",
- V3ARGS(vu->v_p->vg_p->coord));
-
- pl_color(plot_fp, 200, 200, 100);
-
- p=find_pt2d(tbl2d, vu);
- if (!p)
- bu_bomb("didn't find vertexuse in list!\n");
-
- pdv_3point(plot_fp, p->coord);
- sprintf(buf, "%g, %g", p->coord[0], p->coord[1]);
- pl_label(plot_fp, buf);
-
- continue;
- }
-
- for (BU_LIST_FOR(eu, edgeuse, &lu->down_hd)) {
- register struct edgeuse *eu_pnext;
-
- eu_pnext = BU_LIST_PNEXT_CIRC(edgeuse, &eu->l);
-
- p=find_pt2d(tbl2d, eu->vu_p);
- if (!p)
- bu_bomb("didn't find vertexuse in list!\n");
-
- pn=find_pt2d(tbl2d, eu_pnext->vu_p);
- if (!pn)
- bu_bomb("didn't find vertexuse in list!\n");
-
-
- VSUB2(pt, pn->coord, p->coord);
-
- VSCALE(pt, pt, 0.80);
- VADD2(pt, p->coord, pt);
-
- pl_color(plot_fp, 200, 200, 200);
- pdv_3line(plot_fp, p->coord, pt);
- pd_3move(plot_fp, V3ARGS(p->coord));
-
- sprintf(buf, "%g, %g", p->coord[0], p->coord[1]);
- pl_label(plot_fp, buf);
- }
- }
-}
-#endif
-/* This is the endif to disable the functions skip_cut,
- * cut_diagonals, cut_unimonotone, nmg_plot_flat_face.
- */
-
-
void
nmg_plot_fu(const char *prefix, const struct faceuse *fu, const struct bn_tol
*UNUSED(tol))
{
@@ -3831,11 +2703,8 @@
/* add the new vertexuse to the pt2d table. these new
* vertexuse are from loopuse-mate before the switch.
*/
-#if 1
lu2 = BU_LIST_FIRST(loopuse, &fu->lu_hd);
-#else
- lu2 = next->vu_p->up.eu_p->up.lu_p;
-#endif
+
for (BU_LIST_FOR(eu, edgeuse, &lu2->down_hd)) {
NMG_CK_EDGEUSE(eu);
map_new_vertexuse(tbl2d, eu->vu_p);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits