From 79e57e08e79a4001a685637ef9e3f9e2d158b216 Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Sun, 10 May 2015 14:06:21 +1000 Subject: [PATCH 1/3] Fix Triangulate_MONO for triangle input Without this, "triangulating" a triangle results in two copies of itself. --- src/polypartition.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/polypartition.cpp b/src/polypartition.cpp index d24f860..6da4818 100644 --- a/src/polypartition.cpp +++ b/src/polypartition.cpp @@ -1409,6 +1409,7 @@ int TPPLPartition::TriangulateMonotone(TPPLPoly *inPoly, list *triangl if(numpoints < 3) return 0; if(numpoints == 3) { triangles->push_back(*inPoly); + return 1; } topindex = 0; bottomindex=0; From 561ad37488f4bd7fd9fc4a10f75a537a4478b881 Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Sun, 10 May 2015 14:53:45 +1000 Subject: [PATCH 2/3] Fix inconsistent indentation --- src/polypartition.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/polypartition.h b/src/polypartition.h index fa12e33..42a83e5 100644 --- a/src/polypartition.h +++ b/src/polypartition.h @@ -71,10 +71,11 @@ struct TPPLPoint { if((x == p.x)&&(y==p.y)) return false; else return true; } - }; - - //Polygon implemented as an array of points with a 'hole' flag - class TPPLPoly { +}; + + +//Polygon implemented as an array of points with a 'hole' flag +class TPPLPoly { protected: TPPLPoint *points; @@ -139,9 +140,10 @@ struct TPPLPoint { // TPPL_CCW : sets vertices in counter-clockwise order // TPPL_CW : sets vertices in clockwise order void SetOrientation(int orientation); - }; - - class TPPLPartition { +}; + + +class TPPLPartition { protected: struct PartitionVertex { bool isActive; @@ -344,7 +346,7 @@ struct TPPLPoint { // parts : resulting list of convex polygons //returns 1 on success, 0 on failure int ConvexPartition_OPT(TPPLPoly *poly, std::list *parts); - }; - - +}; + + #endif From 2573d1eb474c43b9bbb827e5b715479487a14a65 Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Sun, 10 May 2015 14:55:53 +1000 Subject: [PATCH 3/3] Implement vertex id This enables the library user to map the output vertices in the final triangulation/partition back to the input vertices. This allows additional vertex attributes to be mapped from the input vertices onto the output triangle vertices in a straightforward way. --- src/polypartition.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/polypartition.h b/src/polypartition.h index 42a83e5..3fc483f 100644 --- a/src/polypartition.h +++ b/src/polypartition.h @@ -33,6 +33,9 @@ typedef double tppl_float; struct TPPLPoint { tppl_float x; tppl_float y; + // User-specified vertex identifier. Note that this isn't used internally + // by the library, but will be faithfully copied around. + int id; TPPLPoint operator + (const TPPLPoint& p) const { TPPLPoint r;