From b07110840e5974ca40938bfe5b80fe152736a015 Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Thu, 12 Jul 2018 14:23:29 +0200 Subject: [PATCH] some work on util --- src/util/geo/Box.h | 11 +- src/util/geo/Geo.h | 778 ++++++++++++++++++----------------- src/util/geo/GeoNew.h | 780 ------------------------------------ src/util/geo/Grid.h | 1 + src/util/geo/Grid.tpp | 40 +- src/util/geo/Line.h | 7 +- src/util/geo/Point.h | 4 +- src/util/graph/Graph.h | 1 + src/util/tests/TestMain.cpp | 108 +++-- 9 files changed, 523 insertions(+), 1207 deletions(-) delete mode 100644 src/util/geo/GeoNew.h diff --git a/src/util/geo/Box.h b/src/util/geo/Box.h index 5eef056..4b0e3ff 100644 --- a/src/util/geo/Box.h +++ b/src/util/geo/Box.h @@ -8,17 +8,22 @@ #include "./Point.h" namespace util { -namespace geon { +namespace geo { template class Box { public: // maximum inverse box as default value of box - Box() : _ll(std::numeric_limits::max), _ur(std::numeric_limits::min) {} + Box() + : _ll(std::numeric_limits::max(), std::numeric_limits::max()), + _ur(std::numeric_limits::min(), std::numeric_limits::min()) {} Box(const Point& ll, const Point& ur) : _ll(ll), _ur(ur) {} const Point& getLowerLeft() const { return _ll; } const Point& getUpperRight() const { return _ur; } + Point& getLowerLeft() { return _ll; } + Point& getUpperRight() { return _ur; } + void setLowerLeft(const Point& ll) { _ll = ll; } void setUpperRight(const Point& ur) { _ur = ur; } @@ -33,7 +38,7 @@ class Box { Point _ll, _ur; }; -} // namespace geon +} // namespace geo } // namespace util #endif // UTIL_GEO_BOX_H_ diff --git a/src/util/geo/Geo.h b/src/util/geo/Geo.h index f8ca8d7..27a1391 100644 --- a/src/util/geo/Geo.h +++ b/src/util/geo/Geo.h @@ -7,43 +7,28 @@ #define _USE_MATH_DEFINES #include -#include -#include #include "util/Misc.h" +#include "util/geo/Box.h" +#include "util/geo/Line.h" +#include "util/geo/Point.h" // ------------------- // Geometry stuff // ------------------ -namespace bgeo = boost::geometry; - namespace util { namespace geo { -template -using Point = bgeo::model::point; - -template -using Line = bgeo::model::linestring>; - -template -using MultiLine = bgeo::model::multi_linestring>; - -template -using Polygon = bgeo::model::polygon>; - -template -using MultiPolygon = bgeo::model::multi_polygon>; - -template -using Box = bgeo::model::box>; - // convenience aliases typedef Point DPoint; typedef Point FPoint; typedef Point IPoint; +typedef LineSegment DLineSegment; +typedef LineSegment FLineSegment; +typedef LineSegment ILineSegment; + typedef Line DLine; typedef Line FLine; typedef Line ILine; @@ -52,197 +37,232 @@ typedef Box DBox; typedef Box FBox; typedef Box IBox; -typedef Polygon DPolygon; -typedef Polygon FPolygon; -typedef Polygon IPolygon; +const static double EPSILON = 0.0000001; + +// typedef Polygon DPolygon; +// typedef Polygon FPolygon; +// typedef Polygon IPolygon; // _____________________________________________________________________________ -template -inline Line rotate(const Line& geo, double deg, const Point& center) { - Line ret; +// template +// inline Line rotate(const Line& geo, double deg, const Point& center) +// { +// Line ret; - bgeo::strategy::transform::translate_transformer translate( - -center.template get<0>(), -center.template get<1>()); - bgeo::strategy::transform::rotate_transformer rotate( - deg); - bgeo::strategy::transform::translate_transformer translateBack( - center.template get<0>(), center.template get<1>()); +// bgeo::strategy::transform::translate_transformer translate( +// -center.getX(), -center.getY()); +// bgeo::strategy::transform::rotate_transformer rotate( +// deg); +// bgeo::strategy::transform::translate_transformer translateBack( +// center.getX(), center.getY()); - bgeo::strategy::transform::ublas_transformer translateRotate( - prod(rotate.matrix(), translate.matrix())); - bgeo::strategy::transform::ublas_transformer all( - prod(translateBack.matrix(), translateRotate.matrix())); +// bgeo::strategy::transform::ublas_transformer translateRotate( +// prod(rotate.matrix(), translate.matrix())); +// bgeo::strategy::transform::ublas_transformer all( +// prod(translateBack.matrix(), translateRotate.matrix())); - bgeo::transform(geo, ret, all); +// bgeo::transform(geo, ret, all); - return ret; -} +// return ret; +// } // _____________________________________________________________________________ -template -inline MultiLine rotate(const MultiLine& geo, double deg, - const Point& center) { - MultiLine ret; +// template +// inline MultiLine rotate(const MultiLine& geo, double deg, +// const Point& center) { +// MultiLine ret; - bgeo::strategy::transform::translate_transformer translate( - -center.template get<0>(), -center.template get<1>()); - bgeo::strategy::transform::rotate_transformer rotate( - deg); - bgeo::strategy::transform::translate_transformer translateBack( - center.template get<0>(), center.template get<1>()); +// bgeo::strategy::transform::translate_transformer translate( +// -center.getX(), -center.getY()); +// bgeo::strategy::transform::rotate_transformer rotate( +// deg); +// bgeo::strategy::transform::translate_transformer translateBack( +// center.getX(), center.getY()); - bgeo::strategy::transform::ublas_transformer translateRotate( - prod(rotate.matrix(), translate.matrix())); - bgeo::strategy::transform::ublas_transformer all( - prod(translateBack.matrix(), translateRotate.matrix())); +// bgeo::strategy::transform::ublas_transformer translateRotate( +// prod(rotate.matrix(), translate.matrix())); +// bgeo::strategy::transform::ublas_transformer all( +// prod(translateBack.matrix(), translateRotate.matrix())); - bgeo::transform(geo, ret, all); +// bgeo::transform(geo, ret, all); - return ret; -} +// return ret; +// } // _____________________________________________________________________________ template inline Box pad(const Box& box, double padding) { - return Box(Point(box.min_corner().template get<0>() - padding, - box.min_corner().template get<1>() - padding), - Point(box.max_corner().template get<0>() + padding, - box.max_corner().template get<1>() + padding)); + return Box(Point(box.getLowerLeft().getX() - padding, + box.getLowerLeft().getY() - padding), + Point(box.getUpperRight().getX() + padding, + box.getUpperRight().getY() + padding)); } // _____________________________________________________________________________ template -inline Line rotate(const Line& geo, double deg) { - Point center; - bgeo::centroid(geo, center); - return rotate(geo, deg, center); +inline Point rotate(const Point& p, double deg) { + return p; } +// _____________________________________________________________________________ +// template +// inline Line rotate(const Line& geo, double deg) { +// Point center; +// bgeo::centroid(geo, center); +// return rotate(geo, deg, center); +// } + +// _____________________________________________________________________________ +// template +// inline MultiLine rotate(const MultiLine& geo, double deg) { +// Point center; +// bgeo::centroid(geo, center); +// return rotate(geo, deg, center); +// } + // _____________________________________________________________________________ template -inline MultiLine rotate(const MultiLine& geo, double deg) { - Point center; - bgeo::centroid(geo, center); - return rotate(geo, deg, center); -} - -// _____________________________________________________________________________ -template