summaryrefslogtreecommitdiffstats
path: root/src/2geom
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-11-09 23:15:51 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-11-09 23:15:51 +0000
commite74f90ca3ce8c75e84d48b66a8a4e594c415b541 (patch)
treee306ccc400c5ed90995bd9130f3ddf0c55a17fe5 /src/2geom
parentallow for _option in radiobuttons for XML translation (diff)
downloadinkscape-e74f90ca3ce8c75e84d48b66a8a4e594c415b541.tar.gz
inkscape-e74f90ca3ce8c75e84d48b66a8a4e594c415b541.zip
Remove geom.cpp and geom.h. Now use 2geom/geom.cpp and 2geom.h.
Add conversion functions between Geom::Point and NR::Point (bzr r4050)
Diffstat (limited to 'src/2geom')
-rw-r--r--src/2geom/coord.h11
-rw-r--r--src/2geom/geom.cpp3
-rw-r--r--src/2geom/geom.h8
-rw-r--r--src/2geom/point.h11
-rw-r--r--src/2geom/utils.h4
5 files changed, 37 insertions, 0 deletions
diff --git a/src/2geom/coord.h b/src/2geom/coord.h
index 6636b4ad7..34a585bf9 100644
--- a/src/2geom/coord.h
+++ b/src/2geom/coord.h
@@ -46,9 +46,20 @@ typedef double Coord;
const Coord EPSILON = 1e-5; //1e-18;
+
+#ifdef near
+#define lib2geom_near_save near
+#undef near
+#endif
+
//IMPL: NearConcept
inline bool near(Coord a, Coord b, double eps=EPSILON) { return fabs(a-b) <= eps; }
+#ifdef lib2geom_near_save
+#define near lib2geom_near_save
+#undef lib2geom_near_save
+#endif
+
} /* namespace Geom */
diff --git a/src/2geom/geom.cpp b/src/2geom/geom.cpp
index d2f2ef29b..e93247899 100644
--- a/src/2geom/geom.cpp
+++ b/src/2geom/geom.cpp
@@ -9,6 +9,7 @@
#include "geom.h"
#include "point.h"
+namespace Geom {
/**
* Finds the intersection of the two (infinite) lines
* defined by the points p such that dot(n0, p) == d0 and dot(n1, p) == d1.
@@ -206,6 +207,8 @@ int centroid(std::vector<Geom::Point> p, Geom::Point& centroid, double &area) {
return 2;
}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/2geom/geom.h b/src/2geom/geom.h
index 5386edbd7..c24acea63 100644
--- a/src/2geom/geom.h
+++ b/src/2geom/geom.h
@@ -31,12 +31,16 @@
* the specific language governing rights and limitations.
*
*/
+#ifndef SEEN_2Geom_GEOM_H
+#define SEEN_2Geom_GEOM_H
//TODO: move somewhere else
#include <vector>
#include "point.h"
+namespace Geom {
+
enum IntersectorKind {
intersects = 0,
parallel,
@@ -66,3 +70,7 @@ line_twopoint_intersect(Geom::Point const &p00, Geom::Point const &p01,
Geom::Point &result);
int centroid(std::vector<Geom::Point> p, Geom::Point& centroid, double &area);
+
+}
+
+#endif
diff --git a/src/2geom/point.h b/src/2geom/point.h
index 030776915..bf7dc444f 100644
--- a/src/2geom/point.h
+++ b/src/2geom/point.h
@@ -174,11 +174,22 @@ extern double atan2(Point const p);
/** compute the angle turning from a to b (signed). */
extern double angle_between(Point const a, Point const b);
+
+#ifdef near
+#define lib2geom_near_save near
+#undef near
+#endif
+
//IMPL: NearConcept
inline bool near(Point const &a, Point const &b, double const eps=EPSILON) {
return ( near(a[X],b[X],eps) && near(a[Y],b[Y],eps) );
}
+#ifdef lib2geom_near_save
+#define near lib2geom_near_save
+#undef lib2geom_near_save
+#endif
+
/** Returns p * Geom::rotate_degrees(90), but more efficient.
*
* Angle direction in Inkscape code: If you use the traditional mathematics convention that y
diff --git a/src/2geom/utils.h b/src/2geom/utils.h
index 2be995248..a96a34dff 100644
--- a/src/2geom/utils.h
+++ b/src/2geom/utils.h
@@ -33,6 +33,8 @@
#include <cmath>
#include <stdexcept>
+namespace Geom {
+
class NotImplemented : public std::logic_error {
public:
NotImplemented() : std::logic_error("method not implemented") {}
@@ -79,4 +81,6 @@ inline double decimal_round(double const x, int const places) {
return round( x * multiplier ) / multiplier;
}
+}
+
#endif