Revision: 55133
http://brlcad.svn.sourceforge.net/brlcad/?rev=55133&view=rev
Author: brlcad
Date: 2013-04-12 03:16:46 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
quell shadow and == warnings, provide an EQ macro that does a tight comparison
Modified Paths:
--------------
brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h
Modified: brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h 2013-04-12
03:12:23 UTC (rev 55132)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/common/shapes.h 2013-04-12
03:16:46 UTC (rev 55133)
@@ -50,6 +50,8 @@
#include <assert.h>
#include <cmath>
+#define EQ(v1, v2) ((v1 - v2 > -__FLT_EPSILON__) && (v1 - v2 <
__FLT_EPSILON__))
+
namespace p2t {
struct Edge;
@@ -69,7 +71,7 @@
std::vector<Edge*> edge_list;
/// Construct using coordinates.
- P2T_EXPORT Point(double x, double y) : x(x), y(y) {}
+ P2T_EXPORT Point(double x_, double y_) : x(x_), y(y_) {}
/// Set this point to all zeros.
P2T_EXPORT void set_zero()
@@ -142,11 +144,11 @@
if (p1.y > p2.y) {
q = &p1;
p = &p2;
- } else if (p1.y == p2.y) {
+ } else if (EQ(p1.y, p2.y)) {
if (p1.x > p2.x) {
q = &p1;
p = &p2;
- } else if (p1.x == p2.x) {
+ } else if (EQ(p1.x, p2.x)) {
// Repeat points
assert(false);
}
@@ -236,7 +238,7 @@
{
if (a->y < b->y) {
return true;
- } else if (a->y == b->y) {
+ } else if (EQ(a->y, b->y)) {
// Make sure q is point with greater x value
if (a->x < b->x) {
return true;
@@ -265,7 +267,7 @@
inline bool operator ==(const Point& a, const Point& b)
{
- return a.x == b.x && a.y == b.y;
+ return EQ(a.x, b.x) && EQ(a.y, b.y);
}
inline bool operator !=(const Point& a, const Point& b)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits