commit 41b89ddb5538bbeb2aad6ddaadb55ee6669e5e92 (HEAD, git-svn, private, master) Author: tfogal <tfogal@5b8196f7-c1c0-4be6-8b13-4feed349168d> Date: Tue Nov 13 13:57:43 2012 +0000 Fix sorting code. Was taking the object type instead of an instance... git-svn-id: https://gforge.sci.utah.edu/svn/basics/trunk@270 5b8196f7-c1c0-4be6-8b13-4feed349168d --- Clipper.cpp | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Clipper.cpp b/Clipper.cpp index cb347c4..5ae4f2d 100644 --- a/Clipper.cpp +++ b/Clipper.cpp @@ -112,11 +112,12 @@ std::vector<FLOATVECTOR3> Clipper::TriPlane(std::vector<FLOATVECTOR3>& posData, return newVertices; } -struct { - bool operator() (const FLOATVECTOR3& i, const FLOATVECTOR3& j) { - return i.x < j.x || (i.x == j.x && i.y < j.y) || (i.x == j.x && i.y == j.y && i.z < j.z); +struct CompSorter { + bool operator() (const FLOATVECTOR3& i, const FLOATVECTOR3& j) const { + return i.x < j.x || (i.x == j.x && i.y < j.y) || + (i.x == j.x && i.y == j.y && i.z < j.z); } -} CompSorter; +}; static bool AngleSorter(const FLOATVECTOR3& i, const FLOATVECTOR3& j, const FLOATVECTOR3& center, const FLOATVECTOR3& refVec, const FLOATVECTOR3& normal) { FLOATVECTOR3 vecI = (i-center).normalized(); @@ -140,8 +141,9 @@ void Clipper::BoxPlane(std::vector<FLOATVECTOR3>& posData, const FLOATVECTOR3 &n if (newVertices.size() < 3) return; // remove duplicate vertices - std::sort(newVertices.begin(), newVertices.end(), CompSorter); - newVertices.erase(std::unique(newVertices.begin(), newVertices.end()), newVertices.end()); + std::sort(newVertices.begin(), newVertices.end(), CompSorter()); + newVertices.erase(std::unique(newVertices.begin(), newVertices.end()), + newVertices.end()); // sort counter clockwise using namespace std::placeholders;
Archive powered by MHonArc 2.6.16.