From 50b65f72c02382d826802fa7c76ebc7bf53611fc Mon Sep 17 00:00:00 2001 From: neoraider Date: Thu, 27 Sep 2007 08:27:04 +0000 Subject: Einige Warnungen mit -Wall gefixt --- Polygon.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Polygon.cpp') diff --git a/Polygon.cpp b/Polygon.cpp index eb63a61..7eaeaa9 100644 --- a/Polygon.cpp +++ b/Polygon.cpp @@ -24,7 +24,7 @@ Polygon::Direction Polygon::getDirection() const { } float Polygon::area() const { - return fabs(signedArea()); + return fabsf(signedArea()); } float Polygon::perimeter() const { @@ -135,9 +135,9 @@ bool Polygon::isConcave(const Direction &dir, const Vertex &v1, const Vertex &v2 return (v1.getX()-v2.getX())*(v3.getY()-v2.getY()) > (v3.getX()-v2.getX())*(v1.getY()-v2.getY()); case Triangle::CCW: return (v1.getX()-v2.getX())*(v3.getY()-v2.getY()) < (v3.getX()-v2.getX())*(v1.getY()-v2.getY()); + default: + return false; } - - return false; } bool Polygon::intersections(std::vector *intersections) const { @@ -180,10 +180,10 @@ bool Polygon::simplify(std::list &polygons) const { if(!intersections(&ins)) return false; - int s = size(); - int start = 0; + size_t s = size(); + size_t start = 0; - for(int i = 1; i < s; i++) { + for(size_t i = 1; i < s; i++) { if(at(i).getX() < at(start).getX()) start = i; else if(at(i).getX() == at(start).getX() && at(i).getY() < at(start).getY()) @@ -192,7 +192,7 @@ bool Polygon::simplify(std::list &polygons) const { int dir = Triangle(at((s+start-1)%s), at(start), at((start+1)%s)).getDirection(); - int i2 = start; + size_t i2 = start; const Vertex *v2 = &at(i2); bool intersected; @@ -201,7 +201,7 @@ bool Polygon::simplify(std::list &polygons) const { do { intersected = false; - int i = i2; + size_t i = i2; if(dir == Triangle::CW) i2 = (i2+1)%s; @@ -216,7 +216,7 @@ bool Polygon::simplify(std::list &polygons) const { Intersection *intr = NULL; Vertex *v = NULL; float dv = 0; - int v3, v4; + size_t v3 = 0, v4 = 0; for(std::vector::iterator in = ins.begin(); in != ins.end(); ++in) { float di = v2->distanceSq(in->v); @@ -276,7 +276,7 @@ bool Polygon::simplify(std::list &polygons) const { polygons.back().push_back(polygons.front().back()); polygons.front().pop_back(); - if(v->distanceSq(polygons.back().back()) < 1E-6) + if(v->distanceSq(polygons.back().back()) < 1E-12) break; } } -- cgit v1.2.3