From ac40ef4631989da578f6542329eef56a3fac2ff7 Mon Sep 17 00:00:00 2001 From: zzzzrrr Date: Fri, 22 Jan 2010 15:22:08 -0500 Subject: [PATCH] code cleanup --- poly2tri/common/shapes.cc | 1 + poly2tri/common/shapes.h | 32 ++++++++++----------- poly2tri/sweep/cdt.h | 1 - poly2tri/sweep/mesh.cc | 49 --------------------------------- poly2tri/sweep/mesh.h | 48 -------------------------------- poly2tri/sweep/sweep_context.cc | 24 ---------------- wscript | 1 - 7 files changed, 17 insertions(+), 139 deletions(-) delete mode 100644 poly2tri/sweep/mesh.cc delete mode 100644 poly2tri/sweep/mesh.h diff --git a/poly2tri/common/shapes.cc b/poly2tri/common/shapes.cc index 41cf662..c2f0250 100644 --- a/poly2tri/common/shapes.cc +++ b/poly2tri/common/shapes.cc @@ -29,6 +29,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "shapes.h" +#include Triangle::Triangle(Point& a, Point& b, Point& c) { diff --git a/poly2tri/common/shapes.h b/poly2tri/common/shapes.h index 9d2c09c..3d4c993 100644 --- a/poly2tri/common/shapes.h +++ b/poly2tri/common/shapes.h @@ -37,8 +37,6 @@ #include #include #include -#include -#include struct Node; struct Edge; @@ -50,51 +48,57 @@ struct Point { /// Default constructor does nothing (for performance). Point() { - x = 0.0; y = 0.0; + x = 0.0; + y = 0.0; } /// The edges this point constitutes an upper ending point std::vector edge_list; /// Construct using coordinates. - Point(double x, double y) : x(x), y(y) - { - } + Point(double x, double y) : x(x), y(y) {} /// Set this point to all zeros. void set_zero() { - x = 0.0f; y = 0.0f; + x = 0.0f; + y = 0.0f; } /// Set this point to some specified coordinates. void set(double x_, double y_) { - x = x_; y = y_; + x = x_; + y = y_; } /// Negate this point. Point operator -() const { - Point v; v.set(-x, -y); return v; + Point v; + v.set(-x, -y); + return v; } /// Add a point to this point. void operator +=(const Point& v) { - x += v.x; y += v.y; + x += v.x; + y += v.y; } /// Subtract a point from this point. void operator -=(const Point& v) { - x -= v.x; y -= v.y; + x -= v.x; + y -= v.y; } /// Multiply this point by a scalar. void operator *=(double a) { - x *= a; y *= a; + x *= a; + y *= a; } /// Get the length of this point (the norm). @@ -112,10 +116,6 @@ struct Point { return len; } - void DebugPrint() - { - printf("%f,%f ", x, y); - } }; // Represents a simple polygon's edge diff --git a/poly2tri/sweep/cdt.h b/poly2tri/sweep/cdt.h index ebee8ab..94da14b 100644 --- a/poly2tri/sweep/cdt.h +++ b/poly2tri/sweep/cdt.h @@ -29,7 +29,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "advancing_front.h" -#include "mesh.h" #include "sweep_context.h" #include "sweep.h" diff --git a/poly2tri/sweep/mesh.cc b/poly2tri/sweep/mesh.cc deleted file mode 100644 index aa31f52..0000000 --- a/poly2tri/sweep/mesh.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "mesh.h" - -// Recursively collect interior triangles and clean the mesh -// Excludes exterior triangles outside constrained edges -// Depth first search - -void Mesh::clean(Triangle& triangle) -{ - /* - if(triangle != NULL && !triangle.interior) - { - triangle.interior = true; - triangles += triangle; - for(i <- 0 until 3) - if(!triangle.edges(i)) - clean(triangle.neighbors(i)); - } - */ -} diff --git a/poly2tri/sweep/mesh.h b/poly2tri/sweep/mesh.h deleted file mode 100644 index be31e13..0000000 --- a/poly2tri/sweep/mesh.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -using namespace std; - -class Triangle; - -class Mesh -{ -public: - -/// Triangles that constitute the mesh -vector map; - -// Debug triangles -//val debug = new ArrayBuffer[Triangle] -//val triangles = new ArrayBuffer[Triangle] - -void clean(Triangle& triangle); -}; diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index 0194200..db42e6c 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -79,25 +79,8 @@ void SweepContext::InitTriangulation() tail_ = new Point(xmin - dx, ymin - dy); // Sort points along y-axis - double init_time = glfwGetTime(); std::sort(points_, points_ + point_count_, cmp); - double dt = glfwGetTime() - init_time; - printf("Sort time (secs) = %f\n", dt); - /* - printf("*************************\n"); - for (int i = 0; i < point_count_; i++) { - printf("%f,%f ", points_[i]->x, points_[i]->y); - printf("%p\n", points_[i]); - } - - /* - printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - for(int i = 0; i < edge_list.size(); i++) { - edge_list[i]->p->DebugPrint(); edge_list[i]->q->DebugPrint(); - printf("%p, %p\n", edge_list[i]->p, edge_list[i]->q); - } - */ } void SweepContext::InitEdges(Point** polyline, const int& point_count) @@ -106,13 +89,6 @@ void SweepContext::InitEdges(Point** polyline, const int& point_count) int j = i < point_count - 1 ? i + 1 : 0; edge_list.push_back(new Edge(*polyline[i], *polyline[j])); } - - /* - for(int i = 0; i < edge_list.size(); i++) { - edge_list[i]->p->DebugPrint(); edge_list[i]->q->DebugPrint(); - printf("%p, %p\n", edge_list[i]->p, edge_list[i]->q); - } - */ } Point* SweepContext::GetPoint(const int& index) diff --git a/wscript b/wscript index 9660a95..a7593e2 100644 --- a/wscript +++ b/wscript @@ -7,7 +7,6 @@ blddir = 'build' p2t_source_files = ['poly2tri/common/shapes.cc', 'poly2tri/sweep/cdt.cc', 'poly2tri/sweep/advancing_front.cc', - 'poly2tri/sweep/mesh.cc', 'poly2tri/sweep/sweep_context.cc', 'poly2tri/sweep/sweep.cc']