Revision: 64343
http://sourceforge.net/p/brlcad/code/64343
Author: starseeker
Date: 2015-03-06 20:44:09 +0000 (Fri, 06 Mar 2015)
Log Message:
-----------
Check for ear status change in convex case.
Modified Paths:
--------------
brlcad/trunk/src/libbn/polygon.c
brlcad/trunk/src/libbn/tests/bn_polygon_triangulate.c
Modified: brlcad/trunk/src/libbn/polygon.c
===================================================================
--- brlcad/trunk/src/libbn/polygon.c 2015-03-06 17:08:41 UTC (rev 64342)
+++ brlcad/trunk/src/libbn/polygon.c 2015-03-06 20:44:09 UTC (rev 64343)
@@ -443,9 +443,17 @@
/* Update the status of the two neighbor points */
if (vp->isConvex) {
/* Check ear status */
+ int prev_ear_status = vp->isEar;
struct pt_vertex *p = PT_NEXT(vp);
struct pt_vertex *n = PT_PREV(vp);
vp->isEar = is_ear(vp->index, p->index, n->index, lists->reflex_list,
pts);
+ if (prev_ear_status != vp->isEar) {
+ if (vp->isEar) {
+ PT_ADD_EAR_VREF(lists->ear_list, vp, pts);
+ } else {
+ PT_DEQUEUE_EAR_VREF(lists->ear_list, vp);
+ }
+ }
} else {
struct pt_vertex *p = PT_NEXT(vp);
struct pt_vertex *n = PT_PREV(vp);
@@ -462,9 +470,17 @@
}
}
if (vn->isConvex) {
+ int prev_ear_status = vn->isEar;
struct pt_vertex *p = PT_NEXT(vn);
struct pt_vertex *n = PT_PREV(vn);
vn->isEar = is_ear(vn->index, p->index, n->index, lists->reflex_list,
pts);
+ if (prev_ear_status != vn->isEar) {
+ if (vn->isEar) {
+ PT_ADD_EAR_VREF(lists->ear_list, vn, pts);
+ } else {
+ PT_DEQUEUE_EAR_VREF(lists->ear_list, vn);
+ }
+ }
} else {
struct pt_vertex *p = PT_NEXT(vn);
struct pt_vertex *n = PT_PREV(vn);
@@ -562,12 +578,9 @@
if (vref->v->isEar) PT_ADD_EAR_VREF(ear_list, vref->v, pts);
}
- /* If we didn't find any ears, something is wrong - possibly non CCW
inputs */
+ /* If we didn't find any ears, something is wrong */
if (BU_LIST_IS_EMPTY(&(lists->ear_list->l))) {
ret = 1;
- if (BU_LIST_IS_EMPTY(&(lists->convex_list->l)) &&
!BU_LIST_IS_EMPTY(&(lists->vertex_list->l))) {
- bu_log("No convex points were found - this probably indicates the
points are not in CCW order\n");
- }
goto cleanup;
}
Modified: brlcad/trunk/src/libbn/tests/bn_polygon_triangulate.c
===================================================================
--- brlcad/trunk/src/libbn/tests/bn_polygon_triangulate.c 2015-03-06
17:08:41 UTC (rev 64342)
+++ brlcad/trunk/src/libbn/tests/bn_polygon_triangulate.c 2015-03-06
20:44:09 UTC (rev 64343)
@@ -39,60 +39,87 @@
int
main(int UNUSED(argc), const char **UNUSED(argv))
{
- int num_faces = 0;
- int *faces = NULL;
+ {
+ int num_faces = 0;
+ int *faces = NULL;
- /* 44 point polygon derived from NIST MBE PMI sample 1 shape */
- point2d_t points[44] = {{0}};
- V2SET(points[0], 2757.83, 2422.83);
- V2SET(points[1], 2707.83, 2422.83);
- V2SET(points[2], 2657.83, 2372.83);
- V2SET(points[3], 2657.83, 2347.83);
- V2SET(points[4], 2632.83, 2322.83);
- V2SET(points[5], 2600.33, 2322.83);
- V2SET(points[6], 2600.33, 2307.83);
- V2SET(points[7], 2590.33, 2297.83);
- V2SET(points[8], 2525.33, 2297.83);
- V2SET(points[9], 2515.33, 2307.83);
- V2SET(points[10], 2515.33, 2322.83);
- V2SET(points[11], 2300.33, 2322.83);
- V2SET(points[12], 2300.33, 2307.83);
- V2SET(points[13], 2290.33, 2297.83);
- V2SET(points[14], 2225.33, 2297.83);
- V2SET(points[15], 2215.33, 2307.83);
- V2SET(points[16], 2215.33, 2322.83);
- V2SET(points[17], 2182.83, 2322.83);
- V2SET(points[18], 2157.83, 2347.83);
- V2SET(points[19], 2157.83, 2372.83);
- V2SET(points[20], 2107.83, 2422.83);
- V2SET(points[21], 2057.83, 2422.83);
- V2SET(points[22], 2007.83, 2372.83);
- V2SET(points[23], 2007.83, 2022.83);
- V2SET(points[24], 2057.83, 1972.83);
- V2SET(points[25], 2107.83, 1972.83);
- V2SET(points[26], 2157.83, 2022.83);
- V2SET(points[27], 2157.83, 2047.83);
- V2SET(points[28], 2182.83, 2072.83);
- V2SET(points[29], 2268.96, 2072.83);
- V2SET(points[30], 2289.17, 2107.83);
- V2SET(points[31], 2306.49, 2107.83);
- V2SET(points[32], 2326.69, 2072.83);
- V2SET(points[33], 2488.96, 2072.83);
- V2SET(points[34], 2509.17, 2107.83);
- V2SET(points[35], 2526.49, 2107.83);
- V2SET(points[36], 2546.69, 2072.83);
- V2SET(points[37], 2632.83, 2072.83);
- V2SET(points[38], 2657.83, 2047.83);
- V2SET(points[39], 2657.83, 2022.83);
- V2SET(points[40], 2707.83, 1972.83);
- V2SET(points[41], 2757.83, 1972.83);
- V2SET(points[42], 2807.83, 2022.83);
- V2SET(points[43], 2807.83, 2372.83);
+ /* 44 point polygon derived from NIST MBE PMI sample 1 shape */
+ point2d_t points[44] = {{0}};
+ V2SET(points[0], 2757.83, 2422.83);
+ V2SET(points[1], 2707.83, 2422.83);
+ V2SET(points[2], 2657.83, 2372.83);
+ V2SET(points[3], 2657.83, 2347.83);
+ V2SET(points[4], 2632.83, 2322.83);
+ V2SET(points[5], 2600.33, 2322.83);
+ V2SET(points[6], 2600.33, 2307.83);
+ V2SET(points[7], 2590.33, 2297.83);
+ V2SET(points[8], 2525.33, 2297.83);
+ V2SET(points[9], 2515.33, 2307.83);
+ V2SET(points[10], 2515.33, 2322.83);
+ V2SET(points[11], 2300.33, 2322.83);
+ V2SET(points[12], 2300.33, 2307.83);
+ V2SET(points[13], 2290.33, 2297.83);
+ V2SET(points[14], 2225.33, 2297.83);
+ V2SET(points[15], 2215.33, 2307.83);
+ V2SET(points[16], 2215.33, 2322.83);
+ V2SET(points[17], 2182.83, 2322.83);
+ V2SET(points[18], 2157.83, 2347.83);
+ V2SET(points[19], 2157.83, 2372.83);
+ V2SET(points[20], 2107.83, 2422.83);
+ V2SET(points[21], 2057.83, 2422.83);
+ V2SET(points[22], 2007.83, 2372.83);
+ V2SET(points[23], 2007.83, 2022.83);
+ V2SET(points[24], 2057.83, 1972.83);
+ V2SET(points[25], 2107.83, 1972.83);
+ V2SET(points[26], 2157.83, 2022.83);
+ V2SET(points[27], 2157.83, 2047.83);
+ V2SET(points[28], 2182.83, 2072.83);
+ V2SET(points[29], 2268.96, 2072.83);
+ V2SET(points[30], 2289.17, 2107.83);
+ V2SET(points[31], 2306.49, 2107.83);
+ V2SET(points[32], 2326.69, 2072.83);
+ V2SET(points[33], 2488.96, 2072.83);
+ V2SET(points[34], 2509.17, 2107.83);
+ V2SET(points[35], 2526.49, 2107.83);
+ V2SET(points[36], 2546.69, 2072.83);
+ V2SET(points[37], 2632.83, 2072.83);
+ V2SET(points[38], 2657.83, 2047.83);
+ V2SET(points[39], 2657.83, 2022.83);
+ V2SET(points[40], 2707.83, 1972.83);
+ V2SET(points[41], 2757.83, 1972.83);
+ V2SET(points[42], 2807.83, 2022.83);
+ V2SET(points[43], 2807.83, 2372.83);
- if (bn_polygon_triangulate(&faces, &num_faces, (const point2d_t *)points,
44)) {
- return 1;
+ if (bn_polygon_triangulate(&faces, &num_faces, (const point2d_t
*)points, 44)) {
+ return 1;
+ }
}
+ {
+ int num_faces = 0;
+ int *faces = NULL;
+ /* 13 point polygon derived from NIST MBE PMI sample 3 shape */
+ point2d_t points[13] = {{0}};
+ V2SET(points[0], 801.392008, 748.924528);
+ V2SET(points[1], 801.392008, 729.874528);
+ V2SET(points[2], 1164.916808, 729.874528);
+ V2SET(points[3], 1164.916808, 748.924528);
+ V2SET(points[4], 1152.216808, 761.624528);
+ V2SET(points[5], 1125.394408, 761.624528);
+ V2SET(points[6], 1110.154408, 746.384528);
+ V2SET(points[7], 1046.654408, 746.384528);
+ V2SET(points[8], 1046.654408, 758.994272);
+ V2SET(points[9], 919.654408, 758.994272);
+ V2SET(points[10], 919.654408, 746.384528);
+ V2SET(points[11], 856.154408, 746.384528);
+ V2SET(points[12], 840.914408, 761.624528);
+ V2SET(points[13], 814.092008, 761.624528);
+
+ if (bn_polygon_triangulate(&faces, &num_faces, (const point2d_t
*)points, 13)) {
+ return 1;
+ }
+ }
+
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits