|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51757 - sandbox/gtl/gtl
From: lucanus.j.simonson_at_[hidden]
Date: 2009-03-13 14:36:01
Author: ljsimons
Date: 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
New Revision: 51757
URL: http://svn.boost.org/trac/boost/changeset/51757
Log:
support for MSVC9 and a couple new features
Added:
sandbox/gtl/gtl/gtl_test.cpp (contents, props changed)
sandbox/gtl/gtl/polygon_45_touch.hpp (contents, props changed)
Text files modified:
sandbox/gtl/gtl/boolean_op.hpp | 121 ++-
sandbox/gtl/gtl/boolean_op_45.hpp | 774 ++++++++++-----------------
sandbox/gtl/gtl/gtl.hpp | 189 ++++++
sandbox/gtl/gtl/interval_concept.hpp | 199 +++---
sandbox/gtl/gtl/isotropy.hpp | 140 +++-
sandbox/gtl/gtl/iterator_geometry_to_set.hpp | 2
sandbox/gtl/gtl/iterator_points_to_compact.hpp | 15
sandbox/gtl/gtl/point_3d_concept.hpp | 49
sandbox/gtl/gtl/point_concept.hpp | 57 +-
sandbox/gtl/gtl/polygon_45_data.hpp | 8
sandbox/gtl/gtl/polygon_45_formation.hpp | 132 ++--
sandbox/gtl/gtl/polygon_45_set_concept.hpp | 161 ++++-
sandbox/gtl/gtl/polygon_45_set_data.hpp | 1117 ++++++++++++++++++++++++++++-----------
sandbox/gtl/gtl/polygon_45_set_view.hpp | 219 ++++--
sandbox/gtl/gtl/polygon_45_with_holes_data.hpp | 18
sandbox/gtl/gtl/polygon_90_data.hpp | 29
sandbox/gtl/gtl/polygon_90_set_concept.hpp | 347 +++++------
sandbox/gtl/gtl/polygon_90_set_data.hpp | 317 ++++++++++
sandbox/gtl/gtl/polygon_90_set_traits.hpp | 14
sandbox/gtl/gtl/polygon_90_set_view.hpp | 213 +++++--
sandbox/gtl/gtl/polygon_90_with_holes_data.hpp | 30
sandbox/gtl/gtl/polygon_arbitrary_formation.hpp | 26
sandbox/gtl/gtl/polygon_formation.hpp | 305 +++++-----
sandbox/gtl/gtl/polygon_set_concept.hpp | 145 +++--
sandbox/gtl/gtl/polygon_set_data.hpp | 32
sandbox/gtl/gtl/polygon_set_view.hpp | 26
sandbox/gtl/gtl/polygon_traits.hpp | 394 +++++++++----
sandbox/gtl/gtl/rectangle_concept.hpp | 403 +++++++-------
sandbox/gtl/gtl/rectangle_data.hpp | 3
sandbox/gtl/gtl/rectangle_formation.hpp | 19
sandbox/gtl/gtl/rectangle_traits.hpp | 7
sandbox/gtl/gtl/scan_arbitrary.hpp | 90 +++
sandbox/gtl/gtl/transform.hpp | 358 ++++++------
sandbox/gtl/gtl/transform_detail.hpp | 6
34 files changed, 3638 insertions(+), 2327 deletions(-)
Modified: sandbox/gtl/gtl/boolean_op.hpp
==============================================================================
--- sandbox/gtl/gtl/boolean_op.hpp (original)
+++ sandbox/gtl/gtl/boolean_op.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -106,6 +106,28 @@
int counts_[2];
};
+ class UnaryCount {
+ public:
+ inline UnaryCount() { count_ = 0; }
+ // constructs from two integers
+ inline explicit UnaryCount(int count) { count_ = count; }
+ inline UnaryCount& operator=(int count) { count_ = count; return *this; }
+ inline UnaryCount& operator=(const UnaryCount& that) { count_ = that.count_; return *this; }
+ inline UnaryCount(const UnaryCount& that) { *this = that; }
+ inline bool operator==(const UnaryCount& that) const { return count_ == that.count_; }
+ inline bool operator!=(const UnaryCount& that) const { return !((*this) == that);}
+ inline UnaryCount& operator+=(const UnaryCount& that) { count_ += that.count_; return *this; }
+ inline UnaryCount& operator-=(const UnaryCount& that) { count_ -= that.count_; return *this; }
+ inline UnaryCount operator+(const UnaryCount& that) const { UnaryCount tmp(*this); tmp += that; return tmp; }
+ inline UnaryCount operator-(const UnaryCount& that) const { UnaryCount tmp(*this); tmp -= that; return tmp; }
+ inline UnaryCount operator-() const { UnaryCount tmp; return tmp - *this; }
+
+ //cast to int operator evaluates data using T binary functor
+ inline operator int() const { return count_ % 2; }
+ private:
+ int count_;
+ };
+
template <class T, typename Unit>
inline BooleanOp<T, Unit>& BooleanOp<T, Unit>::operator=(const BooleanOp& that) {
scanData_ = that.scanData_;
@@ -469,55 +491,64 @@
}
template <typename Unit>
- inline void applyBooleanOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
- BooleanOp<int, Unit> booleanOr;
- std::vector<std::pair<interval_data<Unit>, int> > container;
- std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
- output.reserve(input.size());
- //consider eliminating dependecy on limits with bool flag for initial state
- Unit UnitMax = std::numeric_limits<Unit>::max();
- Unit prevPos = UnitMax;
- Unit prevY = UnitMax;
- int count = 0;
- for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = input.begin();
- itr != input.end(); ++itr) {
- Unit pos = (*itr).first;
- Unit y = (*itr).second.first;
- if(pos != prevPos) {
- booleanOr.advanceScan();
- prevPos = pos;
- prevY = y;
- count = (*itr).second.second;
- continue;
- }
- if(y != prevY && count != 0) {
- interval_data<Unit> ivl(prevY, y);
- container.clear();
- booleanOr.processInterval(container, ivl, count);
- for(unsigned int i = 0; i < container.size(); ++i) {
- std::pair<interval_data<Unit>, int>& element = container[i];
- if(!output.empty() && output.back().first == prevPos &&
- output.back().second.first == element.first.low() &&
- output.back().second.second == element.second * -1) {
- output.pop_back();
- } else {
- output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.low(),
- element.second)));
+ inline void applyUnaryXOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
+ BooleanOp<UnaryCount, Unit> booleanXOr;
+
+ }
+
+ template <typename count_type = int>
+ struct default_arg_workaround {
+ template <typename Unit>
+ static inline void applyBooleanOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
+ BooleanOp<count_type, Unit> booleanOr;
+ std::vector<std::pair<interval_data<Unit>, int> > container;
+ std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
+ output.reserve(input.size());
+ //consider eliminating dependecy on limits with bool flag for initial state
+ Unit UnitMax = std::numeric_limits<Unit>::max();
+ Unit prevPos = UnitMax;
+ Unit prevY = UnitMax;
+ int count = 0;
+ for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = input.begin();
+ itr != input.end(); ++itr) {
+ Unit pos = (*itr).first;
+ Unit y = (*itr).second.first;
+ if(pos != prevPos) {
+ booleanOr.advanceScan();
+ prevPos = pos;
+ prevY = y;
+ count = (*itr).second.second;
+ continue;
+ }
+ if(y != prevY && count != 0) {
+ interval_data<Unit> ivl(prevY, y);
+ container.clear();
+ booleanOr.processInterval(container, ivl, count_type(count));
+ for(unsigned int i = 0; i < container.size(); ++i) {
+ std::pair<interval_data<Unit>, int>& element = container[i];
+ if(!output.empty() && output.back().first == prevPos &&
+ output.back().second.first == element.first.low() &&
+ output.back().second.second == element.second * -1) {
+ output.pop_back();
+ } else {
+ output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.low(),
+ element.second)));
+ }
+ output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.high(),
+ element.second * -1)));
}
- output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.high(),
- element.second * -1)));
}
+ prevY = y;
+ count += (*itr).second.second;
}
- prevY = y;
- count += (*itr).second.second;
- }
- if(output.size() < input.size() / 2) {
- input = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
- } else {
+ if(output.size() < input.size() / 2) {
+ input = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
+ } else {
input.clear();
- }
- input.insert(input.end(), output.begin(), output.end());
- }
+ }
+ input.insert(input.end(), output.begin(), output.end());
+ }
+ };
}
Modified: sandbox/gtl/gtl/boolean_op_45.hpp
==============================================================================
--- sandbox/gtl/gtl/boolean_op_45.hpp (original)
+++ sandbox/gtl/gtl/boolean_op_45.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -49,23 +49,53 @@
int counts[2];
};
-// inline std::ostream& operator<< (std::ostream& o, const Count2& c) {
-// o << c[0] << " " << c[1];
-// return o;
-// }
+ class Count1 {
+ public:
+ inline Count1() { count_ = 0; }
+ inline Count1(int count) { count_ = count; }
+ inline Count1(const Count1& count) { count_ = count.count_; }
+ inline bool operator==(const Count1& count) const { return count_ == count.count_; }
+ inline bool operator!=(const Count1& count) const { return !((*this) == count); }
+ inline Count1& operator=(int count) { count_ = count; return *this; }
+ inline Count1& operator=(const Count1& count) { count_ = count.count_; return *this; }
+ inline Count1& operator+=(const Count1& count){
+ count_ += count.count_;
+ return *this;
+ }
+ inline Count1& operator-=(const Count1& count){
+ count_ -= count.count_;
+ return *this;
+ }
+ inline Count1 operator+(const Count1& count) const {
+ return Count1(*this)+=count;
+ }
+ inline Count1 operator-(const Count1& count) const {
+ return Count1(*this)-=count;
+ }
+ inline Count1 invert() const {
+ return Count1(-count_);
+ }
+ int count_;
+ };
- class Scan45Element {
+ // inline std::ostream& operator<< (std::ostream& o, const Count2& c) {
+ // o << c[0] << " " << c[1];
+ // return o;
+ // }
+
+ template <typename CountType>
+ class Scan45ElementT {
public:
Unit x;
Unit y;
int rise; //-1, 0, +1
- mutable Count2 count;
- inline Scan45Element(){}
- inline Scan45Element(Unit xIn, Unit yIn, int riseIn, Count2 countIn = Count2(0, 0)) :
+ mutable CountType count;
+ inline Scan45ElementT(){}
+ inline Scan45ElementT(Unit xIn, Unit yIn, int riseIn, CountType countIn = CountType()) :
x(xIn), y(yIn), rise(riseIn), count(countIn) {}
- inline Scan45Element(const Scan45Element& that) :
+ inline Scan45ElementT(const Scan45ElementT& that) :
x(that.x), y(that.y), rise(that.rise), count(that.count) {}
- inline Scan45Element& operator=(const Scan45Element& that) {
+ inline Scan45ElementT& operator=(const Scan45ElementT& that) {
x = that.x; y = that.y; rise = that.rise; count = that.count;
return *this;
}
@@ -73,7 +103,7 @@
return y + rise * (xIn - x);
}
- inline bool cross(Point& crossPoint, const Scan45Element& edge, Unit currentX) const {
+ inline bool cross(Point& crossPoint, const Scan45ElementT& edge, Unit currentX) const {
Unit y1 = evalAtX(currentX);
Unit y2 = edge.evalAtX(currentX);
int rise1 = rise;
@@ -100,11 +130,13 @@
return true;
}
};
+
+ typedef Scan45ElementT<Count2> Scan45Element;
-// inline std::ostream& operator<< (std::ostream& o, const Scan45Element& c) {
-// o << c.x << " " << c.y << " " << c.rise << " " << c.count;
-// return o;
-// }
+ // inline std::ostream& operator<< (std::ostream& o, const Scan45Element& c) {
+ // o << c.x << " " << c.y << " " << c.rise << " " << c.count;
+ // return o;
+ // }
class lessScan45ElementRise : public std::binary_function<Scan45Element, Scan45Element, bool> {
public:
@@ -114,7 +146,8 @@
}
};
- class lessScan45Element : public std::binary_function<Scan45Element, Scan45Element, bool> {
+ template <typename CountType>
+ class lessScan45Element {
private:
Unit *x_; //x value at which to apply comparison
int *justBefore_;
@@ -123,7 +156,8 @@
inline lessScan45Element(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
inline lessScan45Element(const lessScan45Element& that) : x_(that.x_), justBefore_(that.justBefore_) {}
inline lessScan45Element& operator=(const lessScan45Element& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
- inline bool operator () (const Scan45Element& elm1, const Scan45Element& elm2) const {
+ inline bool operator () (const Scan45ElementT<CountType>& elm1,
+ const Scan45ElementT<CountType>& elm2) const {
Unit y1 = elm1.evalAtX(*x_);
Unit y2 = elm2.evalAtX(*x_);
if(y1 < y2) return true;
@@ -139,124 +173,101 @@
}
};
- class Scan45Count {
+ template <typename CountType>
+ class Scan45CountT {
public:
- inline Scan45Count() { counts[0] = counts[1] = counts[2] = counts[3] = 0; }
- inline Scan45Count(Count2 count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
- inline Scan45Count(const Count2& count1, const Count2& count2, const Count2& count3,
- const Count2& count4) {
+ inline Scan45CountT() {} //counts[0] = counts[1] = counts[2] = counts[3] = 0; }
+ inline Scan45CountT(CountType count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
+ inline Scan45CountT(const CountType& count1, const CountType& count2, const CountType& count3,
+ const CountType& count4) {
counts[0] = count1;
counts[1] = count2;
counts[2] = count3;
counts[3] = count4;
}
- inline Scan45Count(const Scan45Count& count) {
+ inline Scan45CountT(const Scan45CountT& count) {
(*this) = count;
}
- inline bool operator==(const Scan45Count& count) const {
+ inline bool operator==(const Scan45CountT& count) const {
for(unsigned int i = 0; i < 4; ++i) {
if(counts[i] != count.counts[i]) return false;
}
return true;
}
- inline bool operator!=(const Scan45Count& count) const { return !((*this) == count); }
- inline Scan45Count& operator=(Count2 count) {
+ inline bool operator!=(const Scan45CountT& count) const { return !((*this) == count); }
+ inline Scan45CountT& operator=(CountType count) {
counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
- inline Scan45Count& operator=(const Scan45Count& count) {
+ inline Scan45CountT& operator=(const Scan45CountT& count) {
for(unsigned int i = 0; i < 4; ++i) {
counts[i] = count.counts[i];
}
return *this;
}
- inline Count2& operator[](int index) { return counts[index]; }
- inline Count2 operator[](int index) const {return counts[index]; }
- inline Scan45Count& operator+=(const Scan45Count& count){
+ inline CountType& operator[](int index) { return counts[index]; }
+ inline CountType operator[](int index) const {return counts[index]; }
+ inline Scan45CountT& operator+=(const Scan45CountT& count){
for(unsigned int i = 0; i < 4; ++i) {
counts[i] += count.counts[i];
}
return *this;
}
- inline Scan45Count& operator-=(const Scan45Count& count){
+ inline Scan45CountT& operator-=(const Scan45CountT& count){
for(unsigned int i = 0; i < 4; ++i) {
counts[i] -= count.counts[i];
}
return *this;
}
- inline Scan45Count operator+(const Scan45Count& count) const {
- return Scan45Count(*this)+=count;
+ inline Scan45CountT operator+(const Scan45CountT& count) const {
+ return Scan45CountT(*this)+=count;
}
- inline Scan45Count operator-(const Scan45Count& count) const {
- return Scan45Count(*this)-=count;
+ inline Scan45CountT operator-(const Scan45CountT& count) const {
+ return Scan45CountT(*this)-=count;
}
- inline Scan45Count invert() const {
- return Scan45Count(Count2(0,0))-=(*this);
+ inline Scan45CountT invert() const {
+ return Scan45CountT(CountType())-=(*this);
}
- inline Scan45Count& operator+=(const Scan45Element& element){
+ inline Scan45CountT& operator+=(const Scan45ElementT<CountType>& element){
counts[element.rise+1] += element.count; return *this;
}
private:
- Count2 counts[4];
+ CountType counts[4];
};
-// inline std::ostream& operator<< (std::ostream& o, const Scan45Count& c) {
-// o << c[0] << ", " << c[1] << ", ";
-// o << c[2] << ", " << c[3];
-// return o;
-// }
-
- typedef std::pair<Point, Scan45Count> Scan45Vertex;
-
-// inline std::ostream& operator<< (std::ostream& o, const Scan45Vertex& c) {
-// o << c.first << ": " << c.second;
-// return o;
-// }
-
- //index is the index into the vertex
- static inline Scan45Element getElement(const Scan45Vertex& vertex, int index) {
- return Scan45Element(vertex.first.x(), vertex.first.y(), index - 1, vertex.second[index]);
- }
+ typedef Scan45CountT<Count2> Scan45Count;
- class lessScan45Point : public std::binary_function<Point, Point, bool> {
- public:
- inline lessScan45Point() {} //default constructor is only constructor
- inline bool operator () (const Point& v1, const Point& v2) const {
- return (v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y());
- }
- };
+ // inline std::ostream& operator<< (std::ostream& o, const Scan45Count& c) {
+ // o << c[0] << ", " << c[1] << ", ";
+ // o << c[2] << ", " << c[3];
+ // return o;
+ // }
- class lessScan45Vertex : public std::binary_function<Scan45Vertex, Scan45Vertex, bool> {
- public:
- inline lessScan45Vertex() {} //default constructor is only constructor
- inline bool operator () (const Scan45Vertex& v1, const Scan45Vertex& v2) const {
- return (v1.first.x() < v2.first.x()) || (v1.first.x() == v2.first.x() && v1.first.y() < v2.first.y());
- }
- };
- typedef std::vector<Scan45Vertex> Scan45Vector;
+ // inline std::ostream& operator<< (std::ostream& o, const Scan45Vertex& c) {
+ // o << c.first << ": " << c.second;
+ // return o;
+ // }
- static inline void sortScan45Vector(Scan45Vector& vec) {
- std::sort(vec.begin(), vec.end(), lessScan45Vertex());
- }
//vetex45 is sortable
- class Vertex45 {
+ template <typename ct>
+ class Vertex45T {
public:
Point pt;
int rise; // 1, 0 or -1
- int count; //dxdydTheta
- inline Vertex45() {}
- inline Vertex45(const Point& point, int riseIn, int countIn) : pt(point), rise(riseIn), count(countIn) {}
- inline Vertex45(const Vertex45& vertex) : pt(vertex.pt), rise(vertex.rise), count(vertex.count) {}
- inline Vertex45& operator=(const Vertex45& vertex){
+ ct count; //dxdydTheta
+ inline Vertex45T() {}
+ inline Vertex45T(const Point& point, int riseIn, ct countIn) : pt(point), rise(riseIn), count(countIn) {}
+ inline Vertex45T(const Vertex45T& vertex) : pt(vertex.pt), rise(vertex.rise), count(vertex.count) {}
+ inline Vertex45T& operator=(const Vertex45T& vertex){
pt = vertex.pt; rise = vertex.rise; count = vertex.count; return *this; }
- inline Vertex45(const std::pair<Point, Point>& vertex) {}
- inline Vertex45& operator=(const std::pair<Point, Point>& vertex){ return *this; }
- inline bool operator==(const Vertex45& vertex) const {
+ inline Vertex45T(const std::pair<Point, Point>& vertex) {}
+ inline Vertex45T& operator=(const std::pair<Point, Point>& vertex){ return *this; }
+ inline bool operator==(const Vertex45T& vertex) const {
return pt == vertex.pt && rise == vertex.rise && count == vertex.count; }
- inline bool operator!=(const Vertex45& vertex) const { return !((*this) == vertex); }
+ inline bool operator!=(const Vertex45T& vertex) const { return !((*this) == vertex); }
inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
- inline bool operator<(const Vertex45& vertex) const {
+ inline bool operator<(const Vertex45T& vertex) const {
if(pt.x() < vertex.pt.x()) return true;
if(pt.x() == vertex.pt.x()) {
if(pt.y() < vertex.pt.y()) return true;
@@ -264,28 +275,35 @@
}
return false;
}
- inline bool operator>(const Vertex45& vertex) const { return vertex < (*this); }
- inline bool operator<=(const Vertex45& vertex) const { return !((*this) > vertex); }
- inline bool operator>=(const Vertex45& vertex) const { return !((*this) < vertex); }
+ inline bool operator>(const Vertex45T& vertex) const { return vertex < (*this); }
+ inline bool operator<=(const Vertex45T& vertex) const { return !((*this) > vertex); }
+ inline bool operator>=(const Vertex45T& vertex) const { return !((*this) < vertex); }
inline Unit evalAtX(Unit xIn) const { return pt.y() + rise * (xIn - pt.x()); }
};
-// inline std::ostream& operator<< (std::ostream& o, const Vertex45& c) {
-// o << c.pt << " " << c.rise << " " << c.count;
-// return o;
-// }
+ typedef Vertex45T<int> Vertex45;
+
+ // inline std::ostream& operator<< (std::ostream& o, const Vertex45& c) {
+ // o << c.pt << " " << c.rise << " " << c.count;
+ // return o;
+ // }
//when scanning Vertex45 for polygon formation we need a scanline comparator functor
- class lessVertex45 : public std::binary_function<Vertex45, Vertex45, bool> {
+ class lessVertex45 {
private:
Unit *x_; //x value at which to apply comparison
int *justBefore_;
public:
inline lessVertex45() : x_(0) {}
+
inline lessVertex45(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
+
inline lessVertex45(const lessVertex45& that) : x_(that.x_), justBefore_(that.justBefore_) {}
+
inline lessVertex45& operator=(const lessVertex45& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
- inline bool operator () (const Vertex45& elm1, const Vertex45& elm2) const {
+
+ template <typename ct>
+ inline bool operator () (const Vertex45T<ct>& elm1, const Vertex45T<ct>& elm2) const {
Unit y1 = elm1.evalAtX(*x_);
Unit y2 = elm2.evalAtX(*x_);
if(y1 < y2) return true;
@@ -327,10 +345,108 @@
return predicated_value(prevPt.y() < nextPt.y(), 7, 1);
}
+ template <int op, typename CountType>
+ static int applyLogic(CountType count1, CountType count2){
+ bool l1 = applyLogic<op>(count1);
+ bool l2 = applyLogic<op>(count2);
+ if(l1 && !l2)
+ return -1; //was true before and became false like a trailing edge
+ if(!l1 && l2)
+ return 1; //was false before and became true like a leading edge
+ return 0; //no change in logic between the two counts
+ }
+ template <int op>
+ static bool applyLogic(Count2 count) {
+ if(op == 0) { //apply or
+ return count[0] > 0 || count[1] > 0;
+ } else if(op == 1) { //apply and
+ return count[0] > 0 && count[1] > 0;
+ } else if(op == 2) { //apply not
+ return count[0] > 0 && !(count[1] > 0);
+ } else if(op == 3) { //apply xor
+ return (count[0] > 0) ^ (count[1] > 0);
+ } else
+ return false;
+ }
+
+ template <int op>
+ struct boolean_op_45_output_functor {
+ template <typename cT>
+ void operator()(cT& output, const Count2& count1, const Count2& count2,
+ const Point& pt, int rise, direction_1d end) {
+ int edgeType = applyLogic<op>(count1, count2);
+ if(edgeType) {
+ int multiplier = end == LOW ? -1 : 1;
+ //std::cout << "cross logic: " << edgeType << std::endl;
+ output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
+ //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+ }
+ }
+ };
+
+ template <int op>
+ static bool applyLogic(Count1 count) {
+ if(op == 0) { //apply or
+ return count.count_ > 0;
+ } else if(op == 1) { //apply and
+ return count.count_ > 1;
+ } else if(op == 3) { //apply xor
+ return count.count_ % 2;
+ } else
+ return false;
+ }
+
+ template <int op>
+ struct unary_op_45_output_functor {
+ template <typename cT>
+ void operator()(cT& output, const Count1& count1, const Count1& count2,
+ const Point& pt, int rise, direction_1d end) {
+ int edgeType = applyLogic<op>(count1, count2);
+ if(edgeType) {
+ int multiplier = end == LOW ? -1 : 1;
+ //std::cout << "cross logic: " << edgeType << std::endl;
+ output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
+ //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+ }
+ }
+ };
+
+ class lessScan45Vertex {
+ public:
+ inline lessScan45Vertex() {} //default constructor is only constructor
+ template <typename Scan45Vertex>
+ inline bool operator () (const Scan45Vertex& v1, const Scan45Vertex& v2) const {
+ return (v1.first.x() < v2.first.x()) || (v1.first.x() == v2.first.x() && v1.first.y() < v2.first.y());
+ }
+ };
+ template <typename S45V>
+ static inline void sortScan45Vector(S45V& vec) {
+ std::sort(vec.begin(), vec.end(), lessScan45Vertex());
+ }
+
+ template <typename CountType, typename output_functor>
class Scan45 {
- private:
+ public:
+ typedef Scan45CountT<CountType> Scan45Count;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
+
+ //index is the index into the vertex
+ static inline Scan45Element getElement(const Scan45Vertex& vertex, int index) {
+ return Scan45Element(vertex.first.x(), vertex.first.y(), index - 1, vertex.second[index]);
+ }
+
+ class lessScan45Point : public std::binary_function<Point, Point, bool> {
+ public:
+ inline lessScan45Point() {} //default constructor is only constructor
+ inline bool operator () (const Point& v1, const Point& v2) const {
+ return (v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y());
+ }
+ };
+
+ typedef std::vector<Scan45Vertex> Scan45Vector;
+
//definitions
- typedef std::set<Scan45Element, lessScan45Element> Scan45Data;
+ typedef std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> > Scan45Data;
typedef typename Scan45Data::iterator iterator;
typedef typename Scan45Data::const_iterator const_iterator;
typedef std::set<Point, lessScan45Point> CrossQueue;
@@ -339,18 +455,12 @@
Scan45Data scanData_;
CrossQueue crossQueue_;
Scan45Vector crossVector_;
- Scan45Vector nonIntegerIntersectionVector_;
Unit x_;
int justBefore_;
- int op_; // 0 for OR, 1 for AND, 2 for subtract and 3 for xor
public:
- inline Scan45() : x_((std::numeric_limits<Unit>::min)()), justBefore_(false), op_(0) {
- lessScan45Element lessElm(&x_, &justBefore_);
- scanData_ = std::set<Scan45Element, lessScan45Element>(lessElm);
- }
- inline Scan45(int op) : x_((std::numeric_limits<Unit>::min)()), justBefore_(false), op_(op) {
- lessScan45Element lessElm(&x_, &justBefore_);
- scanData_ = std::set<Scan45Element, lessScan45Element>(lessElm);
+ inline Scan45() : x_(std::numeric_limits<Unit>::min()), justBefore_(false) {
+ lessScan45Element<CountType> lessElm(&x_, &justBefore_);
+ scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
}
inline Scan45(const Scan45& that) { (*this) = that; }
inline Scan45& operator=(const Scan45& that) {
@@ -358,32 +468,14 @@
justBefore_ = that.justBefore_;
crossQueue_ = that.crossQueue_;
crossVector_ = that.crossVector_;
- op_ = that.op_;
- lessScan45Element lessElm(&x_, &justBefore_);
- scanData_ = std::set<Scan45Element, lessScan45Element>(lessElm);
+ lessScan45Element<CountType> lessElm(&x_, &justBefore_);
+ scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
scanData_.insert(scanData_.end(), *itr);
}
return *this;
}
-
-// bool check_invariant() {
-// lessScan45Element lessElm(&x_, &justBefore_);
-// typename Scan45Data::iterator previtr = scanData_.begin();
-// for(typename Scan45Data::iterator itr = scanData_.begin(); itr != scanData_.end(); ++itr) {
-// if(itr != scanData_.begin()) {
-// if(lessElm(*itr, *previtr)) return false;
-// }
-// previtr = itr;
-// }
-// return true;
-// }
-// void assert_invariant() {
-// if(!check_invariant()) {
-// std::cout << "tree invariant violated at " << x_ << " just before is " << justBefore_ << std::endl; //break here
-// }
-// }
-
+
//cT is an output container of Vertex45
//iT is an iterator over Scan45Vertex elements
template <class cT, class iT>
@@ -408,32 +500,18 @@
if(nextX != x_) {
//std::cout << "3\n";
//we need to move to the next scanline stop
- //we need to process cross events, set scanline to the lowest x of the cross events
- //if(nextX == 48032) { //48031
- //std::cout << "at bad x, current x is " << x_ << std::endl; //break here
- //}
+ //we need to process end events then cross events
+ //process end events
if(!crossQueue_.empty() &&
(*crossQueue_.begin()).x() < nextX) {
//std::cout << "4\n";
nextX = std::min(nextX, (*crossQueue_.begin()).x());
}
- //set scanline to the x of the nonIntegerEvents (should be x_ + 1)
- if(!nonIntegerIntersectionVector_.empty() &&
- (*nonIntegerIntersectionVector_.begin()).first.x() < nextX) {
- nextX = (*nonIntegerIntersectionVector_.begin()).first.x();
- }
//std::cout << "6\n";
- //assert_invariant();
justBefore_ = true;
x_ = nextX;
- //assert_invariant();
advance_(output);
- //merge the non integer intersection events with the cross events
- mergeCross_(nonIntegerIntersectionVector_.begin(), nonIntegerIntersectionVector_.end());
- nonIntegerIntersectionVector_.clear();
- //assert_invariant();
justBefore_ = false;
- //assert_invariant();
if(!crossVector_.empty() &&
nextX == (*inputBegin).first.x()) {
inputBegin = mergeCross_(inputBegin, inputEnd);
@@ -480,7 +558,7 @@
//there weren't any edges at this potential cross point
continue;
}
- Count2 countBelow(0, 0);
+ CountType countBelow;
iterator searchDownItr = lowIter;
while(searchDownItr != scanData_.begin()
&& searchDownItr->evalAtX(x_) == vertex.first.y()) {
@@ -504,28 +582,14 @@
if(numEdges == 1) {
//look for the next crossing point and continue
//std::cout << "found only one edge\n";
- //if findCross_ returns true it means the iterator is about to cross its neighbor at non integer
- //point, we need to handle this by faking an event
- if(!findCross_(eraseItrs[0])) {
- continue;
- }
+ findCross_(eraseItrs[0]);
+ continue;
}
//before we erase the elements we need to decide if they should be written out
- Count2 currentCount = countBelow;
+ CountType currentCount = countBelow;
for(unsigned int i = 0; i < numEdges; ++i) {
- int edgeType = applyLogic(currentCount, eraseItrs[i]->count);
- //std::cout << "cross logic: " << edgeType << std::endl;
- if(edgeType == 1) {
- output.insert(output.end(), Vertex45(crossPoint, eraseItrs[i]->rise, -1));
- //output.insert(output.end(), std::pair<Point, Point>(Point(eraseItrs[i]->x, eraseItrs[i]->y),
- // crossPoint));
- //std::cout << "write out: " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << " " << crossPoint << std::endl;
- } else if(edgeType == -1) {
- output.insert(output.end(), Vertex45(crossPoint, eraseItrs[i]->rise, 1));
- //output.insert(output.end(), std::pair<Point, Point>(crossPoint,
- // Point(eraseItrs[i]->x, eraseItrs[i]->y)));
- //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
- }
+ output_functor f;
+ f(output, currentCount, eraseItrs[i]->count, crossPoint, eraseItrs[i]->rise, LOW);
currentCount = eraseItrs[i]->count;
}
//schedule erase of the elements
@@ -545,10 +609,7 @@
}
//erase crossing elements
std::vector<iterator> searchVec;
- //assert_invariant();
for(unsigned int i = 0; i < eraseVec.size(); ++i) {
- //when erasing an element we need to see if the previous element will cross
- //the next element, so add the previous element to the search list
if(eraseVec[i] != scanData_.begin()) {
iterator searchItr = eraseVec[i];
--searchItr;
@@ -558,10 +619,6 @@
}
scanData_.erase(eraseVec[i]);
}
- //assert_invariant();
- //have to search for edges on either side of removed elements
- //crossing only after all elements were removed because two
- //removed elements may be adjacent
for(unsigned int i = 0; i < searchVec.size(); ++i) {
findCross_(searchVec[i]);
}
@@ -570,7 +627,7 @@
template <class iT>
inline iT mergeCross_(iT inputBegin, iT inputEnd) {
Scan45Vector vec;
- std::swap(vec, crossVector_);
+ swap(vec, crossVector_);
iT mergeEnd = inputBegin;
unsigned int mergeCount = 0;
while(mergeEnd != inputEnd &&
@@ -597,242 +654,35 @@
template <class cT, class iT>
inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
//std::cout << "processEvent_\n";
- //if(x_ == 48031) {
- // std::cout << "processing bad x event 48031\n";
- //}
- Count2 verticalCount = Count2(0, 0);
+ CountType verticalCount = CountType();
Point prevPoint;
iterator prevIter = scanData_.end();
- Scan45Vertex niip_0, niip_1, niip_2;
- bool prevNonIntegerIntersection = false;
- Count2 upwardSlopingCount(0, 0);
- bool downwardSlash = false;
- Count2 downwardSlopingCount;
- Count2 downwardSlopingCountFromScanline;
- bool routeThroughUpperLeft = false;
- bool haveDeferredVertex = false;
- Scan45Vertex deferredVertex;
- Unit prevY = std::numeric_limits<Unit>::max();
- while(prevNonIntegerIntersection || haveDeferredVertex || (inputBegin != inputEnd && (*inputBegin).first.x() == x_)) {
+ while(inputBegin != inputEnd &&
+ (*inputBegin).first.x() == x_) {
//std::cout << (*inputBegin) << std::endl;
//std::cout << "loop\n";
- Scan45Vertex vertex;
- if(inputBegin != inputEnd)
- vertex = *inputBegin;
+ Scan45Vertex vertex = *inputBegin;
//std::cout << vertex.first << std::endl;
//if vertical count propigating up fake a null event at the next element
- if(haveDeferredVertex) {
- vertex = deferredVertex;
- haveDeferredVertex = false;
- } else {
- if(inputBegin == inputEnd ||
- (prevNonIntegerIntersection && (*inputBegin).first.y() > prevY+1) ||
- (verticalCount != Count2(0, 0) && (prevIter != scanData_.end() &&
- prevIter->evalAtX(x_) < (*inputBegin).first.y()))) {
- //std::cout << "faking null event\n";
- vertex = Scan45Vertex(Point(x_, prevIter->evalAtX(x_)), Scan45Count());
- } else {
- ++inputBegin;
- //std::cout << "after increment\n";
- //accumulate overlapping changes in Scan45Count
- while(inputBegin != inputEnd &&
- (*inputBegin).first.x() == x_ &&
- (*inputBegin).first.y() == vertex.first.y()) {
- //std::cout << "accumulate\n";
- vertex.second += (*inputBegin).second;
- ++inputBegin;
- }
- }
- }
- Scan45Vertex t_niip_1, t_niip_2;
- bool currentNonIntegerIntersection = false;
- //check for down sloping input and up sloping
- //scanline element below it
- if(prevNonIntegerIntersection) {
- if(!downwardSlash) {
- //modify the input vertex here to re-route the downward sloping 45 edge
- //insert events at x_ + 1 to complete re-routing the downward sloping 45 edge
- //down sloping edge reroutes to the right, then down, then downward sloping
- vertex.second[0] = Count2(0, 0);
- vertex.second[0] -= downwardSlopingCountFromScanline;
- vertex.second[1] += downwardSlopingCount;
- niip_1.second[1] -= downwardSlopingCount;
- niip_1.second[3] -= downwardSlopingCount;
- niip_0.second[3] += downwardSlopingCount;
- niip_0.second[0] += downwardSlopingCount;
- }
- if(routeThroughUpperLeft) {
- vertex.second[3] += upwardSlopingCount;
- vertex.second[1] += upwardSlopingCount;
- }
- downwardSlopingCount = Count2(0, 0);
- } else {
- //check for down sloping input and up sloping
- //scanline element below it
- downwardSlopingCount = Count2(0, 0);
- if(vertex.second[0] != Count2(0, 0)) {
- iterator lowIter = lookUp_(vertex.first.y());
- if(lowIter != scanData_.begin()) {
- //get count from below
- --lowIter;
- if(vertex.first.y() - 1 != prevY && lowIter->rise == 1 && lowIter->evalAtX(x_) == vertex.first.y() - 1) {
- //we have a upward sloping element in the scanline just below the input
- //downward sloping edge at vertex
- deferredVertex = vertex;
- downwardSlopingCount = deferredVertex.second[0];
- haveDeferredVertex = true;
- vertex.first = Point(x_, vertex.first.y() - 1);
- //prevY = vertex.first.y();
- vertex.second = Scan45Count();
- prevIter = lowIter;
-// while(lowIter->evalAtX(x_) == vertex.first.y()) {
-// unsigned int indexAt = lowIter->rise+1;
-// vertex.second[indexAt] = lowIter->count;
-// if(lowIter == scanData_.begin()) break;
-// --lowIter;
-// vertex.second[indexAt] -= lowIter->count;
-// }
- //while(!output.empty() &&
- // output.back().pt == vertex.first)
- // output.pop_back();
- }
- }
- }
- }
- prevY = vertex.first.y();
- if(!haveDeferredVertex)
- prevIter = lookUp_(vertex.first.y()-1);
- if(vertex.second[2] != Count2(0, 0) ||
- (prevIter != scanData_.end() && prevIter->rise == 1 &&
- prevIter->evalAtX(x_) == vertex.first.y())) {
- //look up any downward sloping edge in the tree
- downwardSlopingCountFromScanline = Count2(0, 0);
- iterator upIter = lookUp_(vertex.first.y() + 1);
- if(upIter != scanData_.end() && upIter->evalAtX(x_) == vertex.first.y() + 1) {
- if(upIter->rise == -1) {
- downwardSlopingCountFromScanline += upIter->count;
- if(upIter != scanData_.begin()) {
- --upIter;
- //we want the change in count at the edge
- downwardSlopingCountFromScanline -= (upIter->count - verticalCount);
- }
- }
- }
- downwardSlopingCount += downwardSlopingCountFromScanline;
- if(downwardSlopingCount != Count2(0, 0) ||
- (inputBegin != inputEnd && //not at end of input range
- (*inputBegin).first.x() == x_ && //at current scanline stop
- (*inputBegin).first.y() == vertex.first.y() + 1)) { //at next integral y position
- iT tmpInputItr = inputBegin;
- while(tmpInputItr != inputEnd && //not at end of input range
- (*tmpInputItr).first.x() == x_ && //at current scanline stop
- (*tmpInputItr).first.y() == vertex.first.y() + 1) { //at next integral y position
- downwardSlopingCount += (*tmpInputItr).second[0];
- ++tmpInputItr;
- }
- if(downwardSlopingCount != Count2(0, 0)) {
- //we have hit a non integer intersection between 45 edges at this point in scanning
- //we need to massage the input to "route traffic" around the non-integer point
- //we can insert new input events into nonIntegerIntersectionVector_ to be handled at x_ + 1
- //we can modify the input events at the current vertex, next vertex and vertical count
- currentNonIntegerIntersection = true;
- prevY = vertex.first.y();
- upwardSlopingCount = vertex.second[2];
- Count2 countBelow;
- iterator lowIter = lookUp_(vertex.first.y());
- Count2 upwardSlopingCountFromScanline = Count2(0, 0);
- bool foundUpwardElement = false;
- if(lowIter != scanData_.end() &&
- lowIter->rise == 1) {
- upwardSlopingCountFromScanline = lowIter->count;
- foundUpwardElement = true;
- }
- if(lowIter != scanData_.begin()) {
- //get count from below
- --lowIter;
- countBelow = lowIter->count;
- ++lowIter;
- }
- if(foundUpwardElement)
- upwardSlopingCountFromScanline -= (countBelow - verticalCount);
- upwardSlopingCount += upwardSlopingCountFromScanline;
- //if there is an up sloping edge in the scanline
- //at this y location then we may need to include
- //it in our calculations of counts
- Count2 countOnBottom(countBelow);
- countOnBottom += vertex.second[0];
- countOnBottom += vertex.second[1];
- Count2 countOnLeft = countOnBottom + upwardSlopingCount;
- Count2 countOnTop = countOnLeft + downwardSlopingCount;
- Count2 countOnRight = countOnBottom + downwardSlopingCount;
- bool lb = applyLogic(countOnBottom);
- bool lt = applyLogic(countOnTop);
- bool ll = applyLogic(countOnLeft);
- bool lr = applyLogic(countOnRight);
- if(lb == ll && lt == lr && lt != lb) {
- downwardSlash = true;
- } else {
- downwardSlash = false;
- }
- //modify the input vertex here to re-route the upward sloping 45 edge
- //insert events at x_ + 1 to complete re-routing the upward sloping 45 edge
- t_niip_1.first = Point(x_ + 1, vertex.first.y());
- t_niip_2.first = Point(x_ + 1, vertex.first.y() + 1);
- routeThroughUpperLeft = false;
- if((lb && lr && !ll && !lt) ||
- (!lb && !lr && ll && lt)) {
- //upward slash case, no rerouting needed
- lb = lr; //break here if needed
- } else {
- if((!ll && !lr) ||
- (ll && lt && lr && !lb) ||
- (ll && lt && !lr && lb) ||
- (ll && !lt && lr && lb) ||
- (!ll && !lt && lr && !lb)) {
- //route right then up then upward sloping
- vertex.second[2] = Count2(0, 0);
- vertex.second[2] -= upwardSlopingCountFromScanline;
- vertex.second[1] += upwardSlopingCount;
- t_niip_1.second[1] -= upwardSlopingCount;
- t_niip_1.second[3] -= upwardSlopingCount;
- t_niip_2.second[3] += upwardSlopingCount;
- t_niip_2.second[2] += upwardSlopingCount;
- } else {
- //route up then right then upward sloping
- routeThroughUpperLeft = true;
- vertex.second[2] = Count2(0, 0);
- vertex.second[2] -= upwardSlopingCountFromScanline;
- vertex.second[3] -= upwardSlopingCount;
- t_niip_2.second[1] -= upwardSlopingCount;
- t_niip_2.second[2] += upwardSlopingCount;
- }
- }
-
- }
+ if(verticalCount != CountType() && (prevIter != scanData_.end() &&
+ prevIter->evalAtX(x_) < vertex.first.y())) {
+ //std::cout << "faking null event\n";
+ vertex = Scan45Vertex(Point(x_, prevIter->evalAtX(x_)), Scan45Count());
+ } else {
+ ++inputBegin;
+ //std::cout << "after increment\n";
+ //accumulate overlapping changes in Scan45Count
+ while(inputBegin != inputEnd &&
+ (*inputBegin).first.x() == x_ &&
+ (*inputBegin).first.y() == vertex.first.y()) {
+ //std::cout << "accumulate\n";
+ vertex.second += (*inputBegin).second;
+ ++inputBegin;
}
}
- //write out non integer intersection events
- if(currentNonIntegerIntersection || prevNonIntegerIntersection) {
- if(niip_0.second != Scan45Count()) {
- //write out count below current y
- nonIntegerIntersectionVector_.push_back(niip_0);
- niip_0 = Scan45Vertex();
- }
- if(!currentNonIntegerIntersection) {
- if(niip_1.second != Scan45Count()) {
- //write out count at y
- nonIntegerIntersectionVector_.push_back(niip_1);
- niip_1 = Scan45Vertex();
- }
- }
- //rotate right side non integer intersection point outputs downward
- niip_0 = t_niip_1;
- niip_1 = t_niip_2;
- niip_2 = Scan45Vertex();
- }
//std::cout << vertex.second << std::endl;
//integrate vertex
- Count2 currentCount = verticalCount;// + vertex.second[0];
+ CountType currentCount = verticalCount;// + vertex.second[0];
for(unsigned int i = 0; i < 3; ++i) {
vertex.second[i] = currentCount += vertex.second[i];
}
@@ -840,7 +690,7 @@
//vertex represents the change in state at this point
//get counts at current vertex
- Count2 countBelow;
+ CountType countBelow;
iterator lowIter = lookUp_(vertex.first.y());
if(lowIter != scanData_.begin()) {
//get count from below
@@ -852,20 +702,10 @@
//std::cout << "vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
Scan45Count countAt(countBelow - verticalCount);
//check if the vertical edge should be written out
- if(verticalCount != Count2(0, 0)) {
- int edgeType = applyLogic(countBelow - verticalCount, countBelow);
- //std::cout << "vertical logic: " << edgeType << std::endl;
- if(edgeType == 1) {
- //std::cout << "write out: " << vertex.first << " " << prevPoint << std::endl;
- output.insert(output.end(), Vertex45(prevPoint, 2, 1));
- output.insert(output.end(), Vertex45(vertex.first, 2, -1));
- //output.insert(output.end(), std::pair<Point, Point>(vertex.first, prevPoint));
- } else if(edgeType == -1){
- //std::cout << "write out: " << prevPoint << " " << vertex.first << std::endl;
- output.insert(output.end(), Vertex45(prevPoint, 2, -1));
- output.insert(output.end(), Vertex45(vertex.first, 2, 1));
- //output.insert(output.end(), std::pair<Point, Point>(prevPoint, vertex.first));
- }
+ if(verticalCount != CountType()) {
+ output_functor f;
+ f(output, countBelow - verticalCount, countBelow, prevPoint, 2, HIGH);
+ f(output, countBelow - verticalCount, countBelow, vertex.first, 2, LOW);
}
currentCount = countBelow - verticalCount;
while(lowIter != scanData_.end() &&
@@ -875,17 +715,8 @@
}
Point lp(lowIter->x, lowIter->y);
if(lp != vertex.first) {
- int edgeType = applyLogic(currentCount, lowIter->count);
- //std::cout << "edge logic: " << edgeType << std::endl;
- if(edgeType == 1) {
- //std::cout << "write out: " << lp << " " << vertex.first << std::endl;
- output.insert(output.end(), Vertex45(vertex.first, lowIter->rise, -1));
- //output.insert(output.end(), std::pair<Point, Point>(lp, vertex.first));
- } else if(edgeType == -1) {
- //std::cout << "write out: " << vertex.first << " " << lp << std::endl;
- output.insert(output.end(), Vertex45(vertex.first, lowIter->rise, 1));
- //output.insert(output.end(), std::pair<Point, Point>(vertex.first, lp));
- }
+ output_functor f;
+ f(output, currentCount, lowIter->count, vertex.first, lowIter->rise, LOW);
}
currentCount = lowIter->count;
iterator nextIter = lowIter;
@@ -894,8 +725,6 @@
scanData_.erase(lowIter);
lowIter = nextIter;
}
- //assert_invariant();
- prevNonIntegerIntersection = currentNonIntegerIntersection;
verticalCount += vertex.second[3];
prevPoint = vertex.first;
//std::cout << "new vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
@@ -913,14 +742,12 @@
//std::cout << "insert: " << vertex.first.x() << " " << vertex.first.y() << " " << i-1 <<
// " " << vertex.second[i][0] << " " << vertex.second[i][1] << std::endl;
iterator insertIter = scanData_.insert(scanData_.end(),
- Scan45Element(vertex.first.x(),
- vertex.first.y(),
- i - 1, vertex.second[i]));
+ Scan45ElementT<CountType>(vertex.first.x(),
+ vertex.first.y(),
+ i - 1, vertex.second[i]));
findCross_(insertIter);
- int edgeType = applyLogic(countBelow, vertex.second[i]);
- if(edgeType)
- output.insert(output.end(), Vertex45(vertex.first, i - 1, edgeType));
- //assert_invariant();
+ output_functor f;
+ f(output, countBelow, vertex.second[i], vertex.first, i - 1, HIGH);
}
countBelow = vertex.second[i];
}
@@ -935,13 +762,13 @@
Unit y1 = iter1->evalAtX(x_);
Unit y2 = iter2->evalAtX(x_);
LongUnit delta = (LongUnit)abs((LongUnit)y1 - (LongUnit)y2);
- if(delta + x_ <= (std::numeric_limits<Unit>::max)())
+ if(delta + x_ <= std::numeric_limits<Unit>::max())
crossQueue_.insert(crossQueue_.end(), Point(x_ + delta, y1));
//std::cout << Point(x_ + delta, y1);
}
//neither iter is horizontal
- inline bool scheduleCross1_(iterator iter1, iterator iter2) {
+ inline void scheduleCross1_(iterator iter1, iterator iter2) {
//std::cout << "1, ";
Unit y1 = iter1->evalAtX(x_);
Unit y2 = iter2->evalAtX(x_);
@@ -949,15 +776,14 @@
//note that half the delta cannot exceed the positive inter range
LongUnit delta = y1;
delta -= y2;
- Unit UnitMax = (std::numeric_limits<Unit>::max)();
+ Unit UnitMax = std::numeric_limits<Unit>::max();
if(delta & 1) {
//delta is odd, division by 2 will result in integer trunctaion
if(delta == 1) {
//the cross point is not on the integer grid and cannot be represented
- // //we must throw an exception
- //std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
- //throw(msg);
- return true;
+ //we must throw an exception
+ std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
+ throw(msg);
} else {
//note that result of this subtraction is always positive because itr1 is above itr2 in scanline
LongUnit halfDelta2 = (LongUnit)((((LongUnit)y1) - y2)/2);
@@ -973,10 +799,9 @@
crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta, y2+halfDelta));
//std::cout << Point(x_+halfDelta, y2+halfDelta);
}
- return false;
}
- inline bool findCross_(iterator iter) {
+ inline void findCross_(iterator iter) {
//std::cout << "find cross ";
iterator iteratorBelow = iter;
iterator iteratorAbove = iter;
@@ -989,7 +814,7 @@
} else {
//iter->rise == -1
if(iteratorBelow->rise == 1) {
- return scheduleCross1_(iter, iteratorBelow);
+ scheduleCross1_(iter, iteratorBelow);
} else if(iteratorBelow->rise == 0) {
scheduleCross0_(iteratorBelow, iter);
}
@@ -1004,50 +829,25 @@
} else {
//iter->rise == 1
if(iteratorAbove->rise == -1) {
- return scheduleCross1_(iteratorAbove, iter);
+ scheduleCross1_(iteratorAbove, iter);
} else if(iteratorAbove->rise == 0) {
scheduleCross0_(iteratorAbove, iter);
}
}
}
//std::cout << std::endl;
- return false;
}
inline iterator lookUp_(Unit y){
//if just before then we need to look from 1 not -1
- return scanData_.lower_bound(Scan45Element(x_, y, -1+2*justBefore_));
- }
-
- int applyLogic(Count2 count1, Count2 count2){
- bool l1 = applyLogic(count1);
- bool l2 = applyLogic(count2);
- if(l1 && !l2)
- return -1; //was true before and became false like a trailing edge
- if(!l1 && l2)
- return 1; //was false before and became true like a leading edge
- return 0; //no change in logic between the two counts
- }
- bool applyLogic(Count2 count) {
- if(op_ == 0) { //apply or
- return count[0] > 0 || count[1] > 0;
- }
- if(op_ == 1) { //apply and
- return count[0] > 0 && count[1] > 0;
- }
- if(op_ == 2) { //apply not
- return count[0] > 0 && !(count[1] > 0);
- }
- if(op_ == 3) { //apply xor
- return (count[0] > 0) ^ (count[1] > 0);
- }
- return false;
+ return scanData_.lower_bound(Scan45ElementT<CountType>(x_, y, -1+2*justBefore_));
}
};
-
- static inline void print45Data(const std::set<Scan45Element, lessScan45Element>& data) {
- typename std::set<Scan45Element, lessScan45Element>::const_iterator iter;
+ template <typename CountType>
+ static inline void print45Data(const std::set<Scan45ElementT<CountType>,
+ lessScan45Element<CountType> >& data) {
+ typename std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >::const_iterator iter;
for(iter = data.begin(); iter != data.end(); ++iter) {
std::cout << iter->x << " " << iter->y << " " << iter->rise << std::endl;
}
@@ -1056,10 +856,10 @@
static inline bool testScan45Data() {
Unit x = 0;
int justBefore = false;
- lessScan45Element lessElm(&x, &justBefore);
- std::set<Scan45Element, lessScan45Element> testData(lessElm);
+ lessScan45Element<Count2> lessElm(&x, &justBefore);
+ std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > testData(lessElm);
//Unit size = testData.size();
- typedef std::set<Scan45Element, lessScan45Element> Scan45Data;
+ typedef std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > Scan45Data;
typename Scan45Data::iterator itr10 = testData.insert(testData.end(), Scan45Element(0, 10, 1));
typename Scan45Data::iterator itr20 = testData.insert(testData.end(), Scan45Element(0, 20, 1));
typename Scan45Data::iterator itr30 = testData.insert(testData.end(), Scan45Element(0, 30, -1));
@@ -1093,8 +893,9 @@
static inline bool testScan45Rect() {
std::cout << "testing Scan45Rect\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1141,8 +942,9 @@
static inline bool testScan45P1() {
std::cout << "testing Scan45P1\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1189,8 +991,9 @@
static inline bool testScan45P2() {
std::cout << "testing Scan45P2\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1237,8 +1040,9 @@
static inline bool testScan45And() {
std::cout << "testing Scan45And\n";
- Scan45 scan45(1);
+ Scan45<Count2, boolean_op_45_output_functor<1> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1292,8 +1096,9 @@
static inline bool testScan45Star1() {
std::cout << "testing Scan45Star1\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1346,8 +1151,9 @@
static inline bool testScan45Star2() {
std::cout << "testing Scan45Star2\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1400,8 +1206,9 @@
static inline bool testScan45Star3() {
std::cout << "testing Scan45Star3\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
@@ -1464,8 +1271,9 @@
static inline bool testScan45Star4() {
std::cout << "testing Scan45Star4\n";
- Scan45 scan45(0);
+ Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
std::vector<Vertex45 > result;
+ typedef std::pair<Point, Scan45Count> Scan45Vertex;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
Count2 count(1, 0);
Modified: sandbox/gtl/gtl/gtl.hpp
==============================================================================
--- sandbox/gtl/gtl/gtl.hpp (original)
+++ sandbox/gtl/gtl/gtl.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -24,6 +24,17 @@
#pragma warning (disable:1125)
#endif
+#ifdef WIN32
+#pragma warning( disable: 4996 )
+#pragma warning( disable: 4800 )
+#ifdef max
+#undef max
+#endif
+#ifdef min
+#undef min
+#endif
+#endif
+
#include "isotropy.hpp"
//point
@@ -89,6 +100,7 @@
#include "polygon_45_formation.hpp"
#include "polygon_45_set_data.hpp"
#include "polygon_45_set_traits.hpp"
+#include "polygon_45_touch.hpp"
#include "polygon_45_set_concept.hpp"
#include "polygon_45_set_view.hpp"
@@ -103,6 +115,183 @@
#include "polygon_set_concept.hpp"
+/// \mainpage gtl -- Geometry Template Library
+/// The geometry template library is a Concepts based typesystem that implements that API and algorithms for a large number of planar (2D) geometry operations. The primary algorithms provided by gtl are polygon set operations, so-called Booleans, such as polygon intersection and union. There are three classes of Booleans and associated types, which are axis-parallel (Manhattan), 45-degree restricted and arbitrary angle polygon operations. This is done because it is significantly more efficient to process geometry data when assumptions about whether it is axis-parallel or restricted to 45-degree can be made.
+
+/// \file "gtl.hpp"
+/// \brief Includes all gtl header files in the correct order to use all gtl features. Include gtl.hpp to treat gtl like a package.
+
+/// \file "isotropy.hpp"
+/// \brief Defines abstract ideas such as orientation and direction as data types that are used extensively to aid geometric programming.
+
+//point
+/// \file "point_data.hpp"
+/// \brief Defines a data structure that models point_concept by satisfying the default point_traits.
+/// \file "point_traits.hpp"
+/// \brief Defines the point_traits that must be satisfied for an object to model point_concept.
+/// \file "point_concept.hpp"
+/// \brief Defines behaviors specific to objects that model point_concept.
+
+//point 3d
+/// \file "point_3d_data.hpp"
+/// \brief Defines a data structure that models point_3d_concept by satisfying the default point_3d_traits.
+/// \file "point_3d_traits.hpp"
+/// \brief Defines the point_3d_traits that must be satisfied for an object to model point_3d_concept.
+/// \file "point_3d_concept.hpp"
+/// \brief Defines behaviors specific to objects that model point_3d_concept.
+
+/// \file "transform.hpp"
+/// \brief Defines transformations of cartesian coordinate systems through several types
+/// \file "transform_detail.hpp"
+/// \brief Details of transforms implementation
+
+//interval
+/// \file "interval_data.hpp"
+/// \brief Defines a data structure that models interval_concept by satisfying the default interval_traits.
+/// \file "interval_traits.hpp"
+/// \brief Defines the interval_traits that must be satisfied for an object to model interval_concept.
+/// \file "interval_concept.hpp"
+/// \brief Defines behaviors specific to objects that model interval_concept.
+
+//rectangle
+/// \file "rectangle_data.hpp"
+/// \brief Defines a data structure that models rectangle_concept by satisfying the default rectangle_traits.
+/// \file "rectangle_traits.hpp"
+/// \brief Defines the rectangle_traits that must be satisfied for an object to model rectangle_concept.
+/// \file "rectangle_concept.hpp"
+/// \brief Defines behaviors specific to objects that model rectangle_concept.
+
+//algorithms needed by polygon types
+/// \file "iterator_points_to_compact.hpp"
+/// \brief Details of an iterator filter that converts a sequence of points of a manhattan polygon to non-redundant coordinate values.
+/// \file "iterator_compact_to_points.hpp"
+/// \brief Details of an iterator filter that converts a sequence of non-redundant coordinate values to the points of a manhattan polygon.
+
+//polygons
+/// \file "polygon_45_data.hpp"
+/// \brief Defines a data structure that models polygon_45_concept by satisfying the default rectangle_traits.
+/// \file "polygon_data.hpp"
+/// \brief Defines a data structure that models polygon_concept by satisfying the default rectangle_traits.
+/// \file "polygon_90_data.hpp"
+/// \brief Defines a data structure that models polygon_90_concept by satisfying the default rectangle_traits.
+/// \file "polygon_90_with_holes_data.hpp"
+/// \brief Defines a data structure that models polygon_90_with_holes_concept by satisfying the default rectangle_traits.
+/// \file "polygon_45_with_holes_data.hpp"
+/// \brief Defines a data structure that models polygon_45_with_holes_concept by satisfying the default rectangle_traits.
+/// \file "polygon_with_holes_data.hpp"
+/// \brief Defines a data structure that models polygon_with_holes_concept by satisfying the default rectangle_traits.
+/// \file "polygon_traits.hpp"
+/// \brief Defines the traits that must be satisfied for an object to model any of the polygonal concepts as well as behaviors of those concepts.
+
+//manhattan boolean algorithms
+/// \file "boolean_op.hpp"
+/// \brief Details of the generic framework for scanline algorithm on manhattan polygonal data.
+/// \file "polygon_formation.hpp"
+/// \brief Details of the scanline algorithm for forming polygons from manhattan polygonal data and associating holes to outer shells.
+/// \file "rectangle_formation.hpp"
+/// \brief Details of the scanline algorithm for forming rectangles from manhattan polygonal data.
+/// \file "max_cover.hpp"
+/// \brief Details of the visibility algorithm for computing largest enclosed rectangles contained within manhattan polygonal data.
+/// \file "property_merge.hpp"
+/// \brief Details of the scanline algorithm for merging properties from many manhattan polygonal data inputs.
+/// \file "polygon_90_touch.hpp"
+//
+/// \file "iterator_geometry_to_set.hpp"
+//
+
+//45 boolean op algorithms
+/// \file "boolean_op_45.hpp"
+//
+/// \file "polygon_45_formation.hpp"
+
+//polygon set data types
+/// \file "polygon_90_set_data.hpp"
+//polygon set trait types
+/// \file "polygon_90_set_traits.hpp"
+//polygon set concepts
+/// \file "polygon_90_set_concept.hpp"
+//boolean operator syntax
+/// \file "polygon_90_set_view.hpp"
+//
+
+//45 boolean op algorithms
+/// \file "boolean_op_45.hpp"
+//
+/// \file "polygon_45_formation.hpp"
+//
+/// \file "polygon_45_set_data.hpp"
+//
+/// \file "polygon_45_set_traits.hpp"
+//
+/// \file "polygon_45_touch.hpp"
+//
+/// \file "polygon_45_set_concept.hpp"
+//
+/// \file "polygon_45_set_view.hpp"
+//
+
+//arbitrary polygon algorithms
+/// \file "polygon_arbitrary_formation.hpp"
+//
+/// \file "polygon_set_data.hpp"
+//
+
+//general scanline
+/// \file "scan_arbitrary.hpp"
+//
+/// \file "polygon_set_traits.hpp"
+//
+/// \file "polygon_set_view.hpp"
+//
+
+/// \file "polygon_set_concept.hpp"
+//
+
+
+/// \defgroup d_concepts Concepts
+/// \brief These are the geometry concepts provided by gtl.
+/// \details A geometry concept is the idea of a geometry, a given data structure may model a certain geometry concept if it is able to provide a complete concept traits definition for that concept.
+/// @{
+/// \struct coordinate_concept
+/// \brief coordinate_concept is a numeric
+/// \details Behaviors specific to coordinate_concept are defined in \ref isotropy.hpp
+/// defgroup d_polygon_concept_functions Polygon Concept Functions
+
+/// \struct interval_concept
+/// \brief interval_concept is one dimensional interval
+/// \details Behaviors specific to interval_concept are defined in \ref interval_concept.hpp
+/// \par An interval is inclusive of all the values one the number line between its low and high coordinate values.
+
+/// \struct point_concept
+/// \brief point_concept is two dimensional point
+//
+/// \struct point_3d_concept
+/// \brief point_3d_concept is two dimensional point
+//
+/// \struct rectangle_concept
+/// \brief rectangle_concept is two dimensional axis-parallel (Manhattan) rectangle often used as a bounding box
+//
+/// \struct polygon_concept
+/// \brief polygon_concept is a two dimensional polygon
+//
+/// \struct polygon_with_holes_concept
+/// \brief polygon_with_holes_concept is a refinement of polygon_concept and extends it with holes that are themselves two dimensional polygons
+//
+/// \struct polygon_45_concept
+/// \brief polygon_45_concept is a refinement of polygon_concept and extends it with the restriction that angles formed at corners are multiples of 45 degrees
+//
+/// \struct polygon_45_with_holes_concept
+/// \brief polygon_45_with_holes_concept is a refinement of polygon_45_concept and polygon_with_holes_concept and extends them with the restriction that holes are of conceptual type polygon_45_concept
+//
+/// \struct polygon_90_concept
+/// \brief polygon_90_concept is a refinement of polygon_45_concept and extends it with the restriction that angles formed at corners are right angles and edges are axis-parallel (Manhattan)
+//
+/// \struct polygon_90_with_holes_concept
+/// \brief polygon_90_with_holes_concept is a refinement of polygon_90_concept and polygon_45_with_holes_concept and extends them with the restriction that holes are of conceptual type polygon_90_concept
+//
+/// @}
+//
+
#if __ICC
#pragma warning (default:1125)
#endif
Added: sandbox/gtl/gtl/gtl_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/gtl/gtl_test.cpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -0,0 +1,2139 @@
+#include "gtl.hpp"
+#include <time.h>
+#include <stdlib.h>
+
+namespace gtl {
+ inline bool testPolygon45SetRect() {
+ std::vector<point_data<int> > points;
+ points.push_back(point_data<int>(0,0));
+ points.push_back(point_data<int>(0,10));
+ points.push_back(point_data<int>(10,10));
+ points.push_back(point_data<int>(10,0));
+ polygon_45_data<int> poly;
+ poly.set(points.begin(), points.end());
+ polygon_45_set_data<int> ps;
+ ps.insert(poly);
+ std::vector<polygon_45_data<int> > polys;
+ ps.get_polygons(polys);
+ std::cout << polys.size() << std::endl;
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ return true;
+ }
+
+ inline bool testPolygon45Set() {
+ polygon_45_formation<int>::Polygon45Formation pf(true);
+ typedef boolean_op_45<int>::Vertex45 Vertex45;
+ std::vector<Vertex45> data;
+ // result == 0 8 -1 1
+ data.push_back(Vertex45(point_data<int>(0, 8), -1, 1));
+ // result == 0 8 1 -1
+ data.push_back(Vertex45(point_data<int>(0, 8), 1, -1));
+ // result == 4 0 1 1
+ data.push_back(Vertex45(point_data<int>(4, 0), 1, 1));
+ // result == 4 0 2 1
+ data.push_back(Vertex45(point_data<int>(4, 0), 2, 1));
+ // result == 4 4 2 -1
+ data.push_back(Vertex45(point_data<int>(4, 4), 2, -1));
+ // result == 4 4 -1 -1
+ data.push_back(Vertex45(point_data<int>(4, 4), -1, -1));
+ // result == 4 12 1 1
+ data.push_back(Vertex45(point_data<int>(4, 12), 1, 1));
+ // result == 4 12 2 1
+ data.push_back(Vertex45(point_data<int>(4, 12), 2, 1));
+ // result == 4 16 2 -1
+ data.push_back(Vertex45(point_data<int>(4, 16), 2, 1));
+ // result == 4 16 -1 -1
+ data.push_back(Vertex45(point_data<int>(4, 16), -1, -1));
+ // result == 6 2 1 -1
+ data.push_back(Vertex45(point_data<int>(6, 2), 1, -1));
+ // result == 6 14 -1 1
+ data.push_back(Vertex45(point_data<int>(6, 14), -1, 1));
+ // result == 6 2 -1 1
+ data.push_back(Vertex45(point_data<int>(6, 2), -1, 1));
+ // result == 6 14 1 -1
+ data.push_back(Vertex45(point_data<int>(6, 14), 1, -1));
+ // result == 8 0 -1 -1
+ data.push_back(Vertex45(point_data<int>(8, 0), -1, -1));
+ // result == 8 0 2 -1
+ data.push_back(Vertex45(point_data<int>(8, 0), 2, -1));
+ // result == 8 4 2 1
+ data.push_back(Vertex45(point_data<int>(8, 4), 2, 1));
+ // result == 8 4 1 1
+ data.push_back(Vertex45(point_data<int>(8, 4), 1, 1));
+ // result == 8 12 -1 -1
+ data.push_back(Vertex45(point_data<int>(8, 12), -1, -1));
+ // result == 8 12 2 -1
+ data.push_back(Vertex45(point_data<int>(8, 12), 2, -1));
+ // result == 8 16 2 1
+ data.push_back(Vertex45(point_data<int>(8, 16), 2, 1));
+ // result == 8 16 1 1
+ data.push_back(Vertex45(point_data<int>(8, 16), 1, 1));
+ // result == 12 8 1 -1
+ data.push_back(Vertex45(point_data<int>(12, 8), 1, -1));
+ // result == 12 8 -1 1
+ data.push_back(Vertex45(point_data<int>(12, 8), -1, 1));
+
+ data.push_back(Vertex45(point_data<int>(6, 4), 1, -1));
+ data.push_back(Vertex45(point_data<int>(6, 4), 2, -1));
+ data.push_back(Vertex45(point_data<int>(6, 12), -1, 1));
+ data.push_back(Vertex45(point_data<int>(6, 12), 2, 1));
+ data.push_back(Vertex45(point_data<int>(10, 8), -1, -1));
+ data.push_back(Vertex45(point_data<int>(10, 8), 1, 1));
+
+ std::sort(data.begin(), data.end());
+ std::vector<polygon_45_data<int> > polys;
+ pf.scan(polys, data.begin(), data.end());
+ polygon_45_set_data<int> ps;
+ std::cout << "inserting1\n";
+ //std::vector<point_data<int> > points;
+ //points.push_back(point_data<int>(0,0));
+ //points.push_back(point_data<int>(0,10));
+ //points.push_back(point_data<int>(10,10));
+ //points.push_back(point_data<int>(10,0));
+ //Polygon45 poly;
+ //poly.set(points.begin(), points.end());
+ //ps.insert(poly);
+ ps.insert(polys[0]);
+
+ polygon_45_set_data<int> ps2;
+ std::cout << "inserting2\n";
+ ps2.insert(polys[0]);
+ std::cout << "applying boolean\n";
+ ps |= ps2;
+ std::vector<polygon_45_data<int> > polys2;
+ std::cout << "getting result\n";
+ ps.get_polygons(polys2);
+ std::cout << ps2 << std::endl;
+ std::cout << ps << std::endl;
+ std::cout << polys[0] << std::endl;
+ std::cout << polys2[0] << std::endl;
+ if(polys != polys2) std::cout << "test Polygon45Set failed\n";
+ return polys == polys2;
+ }
+
+ inline bool testPolygon45SetPerterbation() {
+ polygon_45_formation<int>::Polygon45Formation pf(true);
+ typedef boolean_op_45<int>::Vertex45 Vertex45;
+ std::vector<Vertex45> data;
+ // result == 0 8 -1 1
+ data.push_back(Vertex45(point_data<int>(0, 80), -1, 1));
+ // result == 0 8 1 -1
+ data.push_back(Vertex45(point_data<int>(0, 80), 1, -1));
+ // result == 4 0 1 1
+ data.push_back(Vertex45(point_data<int>(40, 0), 1, 1));
+ // result == 4 0 2 1
+ data.push_back(Vertex45(point_data<int>(40, 0), 2, 1));
+ // result == 4 4 2 -1
+ data.push_back(Vertex45(point_data<int>(40, 40), 2, -1));
+ // result == 4 4 -1 -1
+ data.push_back(Vertex45(point_data<int>(40, 40), -1, -1));
+ // result == 4 12 1 1
+ data.push_back(Vertex45(point_data<int>(40, 120), 1, 1));
+ // result == 4 12 2 1
+ data.push_back(Vertex45(point_data<int>(40, 120), 2, 1));
+ // result == 4 16 2 -1
+ data.push_back(Vertex45(point_data<int>(40, 160), 2, 1));
+ // result == 4 16 -1 -1
+ data.push_back(Vertex45(point_data<int>(40, 160), -1, -1));
+ // result == 6 2 1 -1
+ data.push_back(Vertex45(point_data<int>(60, 20), 1, -1));
+ // result == 6 14 -1 1
+ data.push_back(Vertex45(point_data<int>(60, 140), -1, 1));
+ // result == 6 2 -1 1
+ data.push_back(Vertex45(point_data<int>(60, 20), -1, 1));
+ // result == 6 14 1 -1
+ data.push_back(Vertex45(point_data<int>(60, 140), 1, -1));
+ // result == 8 0 -1 -1
+ data.push_back(Vertex45(point_data<int>(80, 0), -1, -1));
+ // result == 8 0 2 -1
+ data.push_back(Vertex45(point_data<int>(80, 0), 2, -1));
+ // result == 8 4 2 1
+ data.push_back(Vertex45(point_data<int>(80, 40), 2, 1));
+ // result == 8 4 1 1
+ data.push_back(Vertex45(point_data<int>(80, 40), 1, 1));
+ // result == 8 12 -1 -1
+ data.push_back(Vertex45(point_data<int>(80, 120), -1, -1));
+ // result == 8 12 2 -1
+ data.push_back(Vertex45(point_data<int>(80, 120), 2, -1));
+ // result == 8 16 2 1
+ data.push_back(Vertex45(point_data<int>(80, 160), 2, 1));
+ // result == 8 16 1 1
+ data.push_back(Vertex45(point_data<int>(80, 160), 1, 1));
+ // result == 12 8 1 -1
+ data.push_back(Vertex45(point_data<int>(120, 80), 1, -1));
+ // result == 12 8 -1 1
+ data.push_back(Vertex45(point_data<int>(120, 80), -1, 1));
+
+ data.push_back(Vertex45(point_data<int>(60, 40), 1, -1));
+ data.push_back(Vertex45(point_data<int>(60, 40), 2, -1));
+ data.push_back(Vertex45(point_data<int>(60, 120), -1, 1));
+ data.push_back(Vertex45(point_data<int>(60, 120), 2, 1));
+ data.push_back(Vertex45(point_data<int>(100, 80), -1, -1));
+ data.push_back(Vertex45(point_data<int>(100, 80), 1, 1));
+
+ std::sort(data.begin(), data.end());
+ std::vector<polygon_45_data<int> > polys;
+ pf.scan(polys, data.begin(), data.end());
+ polygon_45_set_data<int> ps;
+ std::cout << "inserting1\n";
+ //std::vector<point_data<int> > points;
+ //points.push_back(point_data<int>(0,0));
+ //points.push_back(point_data<int>(0,10));
+ //points.push_back(point_data<int>(10,10));
+ //points.push_back(point_data<int>(10,0));
+ //Polygon45 poly;
+ //poly.set(points.begin(), points.end());
+ //ps.insert(poly);
+ polygon_45_set_data<int> preps(polys[0]);
+
+ ps.insert(polys[0]);
+ convolve(polys[0], point_data<int>(0, 1) );
+
+ polygon_45_set_data<int> ps2;
+ std::cout << "inserting2\n";
+ ps2.insert(polys[0]);
+ std::cout << "applying boolean\n";
+ ps |= ps2;
+ std::vector<polygon_45_data<int> > polys2;
+ std::cout << "getting result\n";
+ ps.get_polygons(polys2);
+ std::cout << preps << std::endl;
+ std::cout << ps2 << std::endl;
+ std::cout << ps << std::endl;
+ std::cout << polys[0] << std::endl;
+ std::cout << polys2[0] << std::endl;
+ //if(polys != polys2) std::cout << "test Polygon45Set failed\n";
+ //return polys == polys2;
+ return true;
+ }
+
+ inline int testPolygon45SetDORA() {
+ std::cout << "testPolygon45SetDORA" << std::endl;
+ std::vector<point_data<int> > pts;
+ pts.push_back(point_data<int>(0, 0));
+ pts.push_back(point_data<int>(10, 0));
+ pts.push_back(point_data<int>(10, 10));
+ pts.push_back(point_data<int>(0, 10));
+ polygon_45_data<int> apoly;
+ apoly.set(pts.begin(), pts.end());
+ polygon_45_set_data<int> ps(apoly);
+ polygon_45_set_data<int> ps2(ps);
+ ps2 = apoly;
+ std::vector<polygon_45_data<int> > apolys;
+ apolys.push_back(apoly);
+ ps2.insert(apolys.begin(), apolys.end());
+ apolys.clear();
+ ps2.get(apolys);
+ std::cout << apolys.size() << std::endl;
+ std::cout << (ps == ps2) << std::endl;
+ std::cout << !(ps != ps2) << std::endl;
+ ps2.clear();
+ std::cout << (ps2.value().empty()) << std::endl;
+ ps2.set(apolys.begin(), apolys.end());
+ ps2.set(ps.value());
+ ps.clean();
+ ps2.set_clean(ps.value());
+ ps2.insert(ps.value().begin(), ps.value().end());
+ ps2.clear();
+ for(polygon_45_set_data<int>::iterator_type itr = ps.begin();
+ itr != ps.end(); ++itr) {
+ ps2.insert(*itr);
+ }
+ std::vector<polygon_45_with_holes_data<int> > apolywhs;
+ ps2.get_polygons_with_holes(apolywhs);
+ std::cout << apolywhs.size() << std::endl;
+ ps2 += 1;
+ apolywhs.clear();
+ ps2.get_polygons_with_holes(apolywhs);
+ if(apolywhs.size()) std::cout << apolywhs[0] << std::endl;
+ ps2 -= 1;
+ apolywhs.clear();
+ ps2.get_polygons_with_holes(apolywhs);
+ if(apolywhs.size()) std::cout << apolywhs[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ rectangle_data<int> rect;
+ extents(rect, apolywhs[0]);
+ ps2.clear();
+ ps2.insert(rect);
+ ps2.extents(rect);
+ ps2.clear();
+ ps2.insert(rect);
+ ps2.clear();
+ ps2.insert(apolywhs[0]);
+ apolywhs.clear();
+ ps2.get_trapezoids(apolywhs);
+ if(apolywhs.size()) std::cout << apolywhs[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ ps2 *= ps;
+ std::cout << (ps2 == ps) << std::endl;
+ ps2 ^= ps;
+ std::cout << ps2.empty() << std::endl;
+ axis_transformation atr(axis_transformation::WS);
+ ps2 = ps;
+ ps.transform(atr);
+ transformation<int> tr(atr);
+ tr.invert();
+ ps.transform(tr);
+ ps.scale_up(2);
+ ps.scale_down(2);
+ std::cout << (ps2 == ps) << std::endl;
+ pts.clear();
+ pts.push_back(point_data<int>(0,0));
+ pts.push_back(point_data<int>(10,10));
+ pts.push_back(point_data<int>(10,11));
+ pts.push_back(point_data<int>(0,21));
+ apoly.set(pts.begin(), pts.end());
+ ps2.clear();
+ ps2.insert(apoly);
+ ps2 -= 1;
+ apolywhs.clear();
+ ps2.get_polygons_with_holes(apolywhs);
+ if(apolywhs.size()) std::cout << apolywhs[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ pts.clear();
+ pts.push_back(point_data<int>(0, 0));
+ pts.push_back(point_data<int>(10, 10));
+ pts.push_back(point_data<int>(0, 20));
+ apoly.set(pts.begin(), pts.end());
+ ps2.clear();
+ ps2.insert(apoly);
+ pts.clear();
+ pts.push_back(point_data<int>(0, 5));
+ pts.push_back(point_data<int>(10, 15));
+ pts.push_back(point_data<int>(0, 25));
+ apoly.set(pts.begin(), pts.end());
+ ps2.insert(apoly);
+ apolywhs.clear();
+ ps2.get_polygons_with_holes(apolywhs);
+ if(apolywhs.size()) std::cout << apolywhs[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ return 0;
+
+ }
+
+}
+using namespace gtl;
+
+bool testInterval() {
+ interval_data<int> interval(0, 10), interval2(10, 20);
+ if(!abuts(interval, interval2)) return false;
+ if(!boundaries_intersect(interval, interval2)) return false;
+ if(boundaries_intersect(interval, interval2, false)) return false;
+ if(intersect(interval, interval2, false)) return false;
+ if(!intersect(interval, interval2)) return false;
+ if(euclidean_distance(interval, interval2) != 0) return false;
+ encompass(interval, interval2);
+ set(interval, LOW, 0);
+ high(interval, 10);
+ scale(interval, 2.0f);
+ scale(interval, 0.5f);
+ if(low(interval) != 0) return false;
+ if(high(interval) != 10) return false;
+ move(interval, 10);
+ if(!equivalence(interval, interval2)) return false;
+ flip(interval, 10);
+ bloat(interval, -2);
+ shrink(interval, -2);
+ flip(interval, 10);
+ if(!equivalence(interval, interval2)) return false;
+ interval_data<int> half = get_half(interval, LOW);
+ if(high(half) != 15) return false;
+ convolve(interval, interval2);
+ if(high(interval) != 40) return false;
+ deconvolve(interval, interval2);
+ if(!equivalence(interval, interval2)) return false;
+ reflected_convolve(interval, interval2);
+ if(low(interval) != -10) return false;
+ reflected_deconvolve(interval, interval2);
+ if(!equivalence(interval, interval2)) return false;
+ euclidean_distance(interval, 0);
+ move(interval, 20);
+ if(euclidean_distance(interval, interval2) != 10) return false;
+ interval = interval2;
+ move(interval, -5);
+ if(!intersects(interval, interval2)) return false;
+ move(interval, 15);
+ if(!abuts(interval, interval2)) return false;
+ if(abuts(interval, interval2, HIGH)) return false;
+ move(interval, 10);
+ generalized_intersect(interval, interval2);
+ move(interval, -10);
+ if(!equivalence(interval, interval2)) return false;
+ if(get(interval, LOW) != low(interval)) return false;
+ if(get(interval, HIGH) != high(interval)) return false;
+ if(center(interval2) != 15) return false;
+ if(delta(interval2) != 10) return false;
+ assign(interval, interval2);
+ low(interval, 0);
+ if(low(interval) != 0) return false;
+ high(interval, 10);
+ join_with(interval, interval2);
+ if(high(interval) != high(interval2)) return false;
+ return true;
+}
+
+bool testRectangle() {
+ rectangle_data<int> rect, rect2;
+ horizontal(rect, interval_data<long long>(0, 10));
+ vertical(rect, interval_data<long long>(20, 30));
+ xl(rect2, 0);
+ xh(rect2, 10);
+ yl(rect2, 20);
+ yh(rect2, 30);
+ if(euclidean_distance(rect, rect2) != 0) return false;
+ if(euclidean_distance(rect2, rect) != 0) return false;
+ set(rect, HORIZONTAL, interval_data<long long>(0, 10));
+ if(!equivalence(horizontal(rect), interval_data<long long>(0, 10))) return false;
+ if(!equivalence(vertical(rect2), interval_data<long long>(20, 30))) return false;
+ if(xl(rect) != 0) return false;
+ if(xh(rect) != 10) return false;
+ if(yl(rect) != 20) return false;
+ if(yh(rect) != 30) return false;
+ move(rect, HORIZONTAL, 10);
+ if(xl(rect) != 10) return false;
+ set_points(rect, point_data<int>(0, 20), point_data<long long>(10, 30));
+ if(xl(rect) != 0) return false;
+ convolve(rect, rect2);
+ if(xh(rect) != 20) return false;
+ deconvolve(rect, rect2);
+ if(xh(rect) != 10) return false;
+ reflected_convolve(rect, rect2);
+ reflected_deconvolve(rect, rect2);
+ if(!equivalence(rect, rect2)) return false;
+ convolve(rect, point_data<long long>(100, 200));
+ if(xh(rect) != 110) return false;
+ deconvolve(rect, point_data<int>(100, 200));
+ if(!equivalence(rect, rect2)) return false;
+ xh(rect, 100);
+ if(delta(rect, HORIZONTAL) != 100) return false;
+ if(area(rect) != 1000) return false;
+ if(half_perimeter(rect) != 110) return false;
+ if(perimeter(rect) != 220) return false;
+ if(guess_orientation(rect) != HORIZONTAL) return false;
+ return true;
+}
+
+
+bool testPolygon() {
+ int rect[4] = {0, 10, 20, 30};
+ iterator_compact_to_points<int*, point_data<int> > itr(rect, rect+4);
+ iterator_compact_to_points<int*, point_data<int> > itr_end(rect, rect+4);
+ std::vector<point_data<int> > points;
+ points.insert(points.end(), itr, itr_end);
+ polygon_90_data<int> p90;
+ assign(p90, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p90) != COUNTERCLOCKWISE) return false;
+ polygon_45_data<int> p45;
+ assign(p45, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p45) != COUNTERCLOCKWISE) return false;
+ polygon_data<int> p;
+ assign(p, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p) != COUNTERCLOCKWISE) return false;
+ set_compact(p90, rect, rect+4);
+ if(winding(p90) != COUNTERCLOCKWISE) return false;
+ points.clear();
+ points.push_back(point_data<int>(0, 0));
+ points.push_back(point_data<int>(10, 10));
+ points.push_back(point_data<int>(0, 20));
+ points.push_back(point_data<int>(-10, 10));
+ set_points(p45, points.begin(), points.end());
+ if(winding(p45) != COUNTERCLOCKWISE) return false;
+ std::swap(points[1], points[3]);
+ set_points(p, points.begin(), points.end());
+ if(winding(p) == COUNTERCLOCKWISE) return false;
+ point_data<int> cp;
+ center(cp, p);
+ if(cp != point_data<int>(0, 10)) return false;
+ move(p, HORIZONTAL, 3);
+ rectangle_data<int> bounding_box;
+ extents(bounding_box, p);
+ if(bounding_box != rectangle_data<int>(interval_data<int>(-7, 13), interval_data<int>(0, 20))) return false;
+ if(area(p90) != 400) return false;
+ if(area(p45) != 200) return false;
+ if(perimeter(p90) != 80) return false;
+ return true;
+}
+
+bool testPolygonAssign() {
+ polygon_data<int> p;
+ polygon_45_data<int> p_45;
+ polygon_90_data<int> p_90;
+ polygon_with_holes_data<int> p_wh;
+ polygon_45_with_holes_data<int> p_45_wh;
+ polygon_90_with_holes_data<int> p_90_wh;
+ assign(p, p);
+ assign(p, p_45);
+ assign(p, p_90);
+ //assign(p, p_wh);
+ //assign(p, p_45_wh);
+ //assign(p, p_90_wh);
+ //assign(p_45, p);
+ assign(p_45, p_45);
+ assign(p_45, p_90);
+ //assign(p_45, p_wh);
+ //assign(p_45, p_45_wh);
+ //assign(p_45, p_90_wh);
+ //assign(p_90, p);
+ //assign(p_90, p_45);
+ assign(p_90, p_90);
+ //assign(p_90, p_wh);
+ //assign(p_90, p_45_wh);
+ //assign(p_90, p_90_wh);
+ assign(p_wh, p);
+ assign(p_wh, p_45);
+ assign(p_wh, p_90);
+ assign(p_wh, p_wh);
+ assign(p_wh, p_45_wh);
+ assign(p_wh, p_90_wh);
+ //assign(p_45_wh, p);
+ assign(p_45_wh, p_45);
+ assign(p_45_wh, p_90);
+ //assign(p_45_wh, p_wh);
+ assign(p_45_wh, p_45_wh);
+ //assign(p_90_wh, p);
+ //assign(p_90_wh, p_45);
+ assign(p_90_wh, p_90);
+ assign(p_90_wh, p_90_wh);
+ return true;
+}
+
+int testPropertyMerge() {
+ rectangle_data<int> rect1 = construct<rectangle_data<int> >(0, 1, 10, 11);
+ rectangle_data<int> rect2 = construct<rectangle_data<int> >(5, 6, 17, 18);
+ property_merge_90<int, int> pm;
+ pm.insert(rect1, 0);
+ pm.insert(rect2, 1);
+ std::map<std::set<int>, polygon_90_set_data<int> > result;
+ pm.merge(result);
+ std::vector<rectangle_data<int> > rects;
+ std::set<int> key;
+ key.insert(0);
+ result[key].get(rects);
+ std::cout << rects.size() << std::endl;
+ std::vector<polygon_data<int> > polys;
+ result[key].get(polys);
+ std::cout << polys.size() << std::endl;
+ std::vector<polygon_90_with_holes_data<int> > polywhs;
+ result[key].get(polywhs);
+ std::cout << polys.size() << std::endl;
+ return result.size();
+}
+
+bool testPolygonWithHoles() {
+ int rect[4] = {0, 10, 20, 30};
+ iterator_compact_to_points<int*, point_data<int> > itr(rect, rect+4);
+ iterator_compact_to_points<int*, point_data<int> > itr_end(rect, rect+4);
+ std::vector<point_data<int> > points;
+ points.insert(points.end(), itr, itr_end);
+ polygon_45_with_holes_data<int> p45wh;
+ assign(p45wh, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p45wh) != COUNTERCLOCKWISE) return false;
+ polygon_45_with_holes_data<int> p45;
+ assign(p45, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p45) != COUNTERCLOCKWISE) return false;
+ polygon_45_with_holes_data<int> p;
+ assign(p, rectangle_data<int>(interval_data<int>(0, 10), interval_data<int>(20, 30)));
+ if(winding(p) != COUNTERCLOCKWISE) return false;
+ set_compact(p45wh, rect, rect+4);
+ if(winding(p45wh) != COUNTERCLOCKWISE) return false;
+ points.clear();
+ points.push_back(point_data<int>(0, 0));
+ points.push_back(point_data<int>(10, 10));
+ points.push_back(point_data<int>(0, 20));
+ points.push_back(point_data<int>(-10, 10));
+ set_points(p45, points.begin(), points.end());
+ if(winding(p45) != COUNTERCLOCKWISE) return false;
+ std::swap(points[1], points[3]);
+ set_points(p, points.begin(), points.end());
+ if(winding(p) == COUNTERCLOCKWISE) return false;
+ point_data<int> cp;
+ center(cp, p);
+ if(cp != point_data<int>(0, 10)) return false;
+ move(p, HORIZONTAL, 3);
+ rectangle_data<int> bounding_box;
+ extents(bounding_box, p);
+ if(bounding_box != rectangle_data<int>(interval_data<int>(-7, 13), interval_data<int>(0, 20))) return false;
+ if(area(p45wh) != 400) return false;
+ if(area(p45) != 200) return false;
+ if(perimeter(p45wh) != 80) return false;
+ return true;
+}
+
+using namespace gtl;
+
+typedef int Unit;
+typedef point_data<int> Point;
+typedef interval_data<int> Interval;
+typedef rectangle_data<int> Rectangle;
+typedef polygon_90_data<int> Polygon;
+typedef polygon_90_with_holes_data<int> PolygonWithHoles;
+typedef polygon_45_data<int> Polygon45;
+typedef polygon_45_with_holes_data<int> Polygon45WithHoles;
+typedef polygon_90_set_data<int> PolygonSet;
+typedef polygon_45_set_data<int> Polygon45Set;
+typedef axis_transformation AxisTransform;
+typedef transformation<int> Transform;
+
+int getRandomBool() {
+ return rand()%2;
+}
+int getRandomInt() {
+ return rand()%6-2;
+}
+Point getRandomPoint() {
+ int x = rand()%8;
+ int y = rand()%8;
+ return Point(x, y);
+}
+Polygon45 getRandomTriangle() {
+ Point pts[3];
+ pts[0] = getRandomPoint();
+ pts[1] = pts[2] = pts[0];
+ int disp = getRandomInt();
+ bool dir = getRandomBool();
+ x(pts[2], x(pts[2]) + disp);
+ x(pts[1], x(pts[1]) + disp);
+ if(dir)
+ y(pts[1], y(pts[1]) + disp);
+ else
+ y(pts[1], y(pts[1]) - disp);
+ return Polygon45(pts, pts+3);
+}
+
+bool nonInteger45StessTest() {
+ for(unsigned int tests = 0; tests < 10; ++tests) {
+ Polygon45Set ps1, ps2;
+ std::vector<Polygon45> p45s;
+ for(unsigned int i = 0; i < 10; ++i) {
+ Polygon45 p45 = getRandomTriangle();
+ p45s.push_back(p45);
+ ps1.insert(p45);
+ scale_up(p45, 2);
+ ps2.insert(p45);
+ }
+ std::vector<Polygon45> polys;
+ ps1.get(polys);
+ Polygon45Set ps3;
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ scale_up(polys[i], 2);
+ ps3.insert(polys[i]);
+ }
+ Polygon45Set ps4 = ps3 ^ ps2;
+ std::vector<Polygon45> polys_error;
+ ps4.get(polys_error);
+ for(unsigned int i = 0; i < polys_error.size(); ++i) {
+ //if(polys_error[i].size() > 3) return false;
+ if(area(polys_error[i]) != 1) {
+ if(area(polys_error[i]) == 2) {
+ //if two area 1 errors merge it will have area 2
+ continue;
+ }
+ std::cout << "test failed\n";
+ for(unsigned int j =0; j < p45s.size(); ++j) {
+ std::cout << p45s[j] << std::endl;
+ }
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool validate_polygon_set_op(Polygon45Set& ps45_o,
+ const Polygon45Set& ps45_1,
+ const Polygon45Set& ps45_2,
+ int op_type) {
+ Polygon45Set s_ps_45_o(ps45_o);
+ Polygon45Set s_ps_45_1(ps45_1);
+ Polygon45Set s_ps_45_2(ps45_2);
+ s_ps_45_o.scale_up(2);
+ s_ps_45_1.scale_up(2);
+ s_ps_45_2.scale_up(2);
+ Polygon45Set s_ps_45_validate;
+ if(op_type == 0) {
+ s_ps_45_validate = s_ps_45_1 + s_ps_45_2;
+ s_ps_45_validate += Rectangle(4, 4, 6, 6);
+ } else if(op_type == 1) {
+ s_ps_45_validate = s_ps_45_1 * s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ } else if(op_type == 2) {
+ s_ps_45_validate = s_ps_45_1 ^ s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ } else {
+ s_ps_45_validate = s_ps_45_1 - s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ }
+ if(s_ps_45_validate != s_ps_45_o) {
+ std::cout << "TEST FAILED\n";
+ std::vector<Polygon45> polys;
+ s_ps_45_o.get(polys);
+ std::cout << "Result:\n";
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ polys.clear();
+ s_ps_45_validate.get(polys);
+ std::cout << "Expected Result:\n";
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ //redo the operation, set breakpoints here
+ switch (op_type) {
+ case 0:
+ ps45_o = ps45_1 + ps45_2;
+ ps45_o.get(polys);//needed to force clean
+ break;
+ case 1:
+ ps45_o = ps45_1 * ps45_2;
+ break;
+ case 2:
+ ps45_o = ps45_1 ^ ps45_2;
+ break;
+ default:
+ ps45_o = ps45_1 - ps45_2;
+ };
+ //redo the check, set breakpoints here
+ if(op_type == 0) {
+ s_ps_45_validate = s_ps_45_1 + s_ps_45_2;
+ s_ps_45_validate += Rectangle(4, 4, 6, 6);
+ s_ps_45_validate.get(polys);
+ } else if(op_type == 1) {
+ s_ps_45_validate = s_ps_45_1 * s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ } else if(op_type == 2) {
+ s_ps_45_validate = s_ps_45_1 ^ s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ } else {
+ s_ps_45_validate = s_ps_45_1 - s_ps_45_2;
+ s_ps_45_validate -= Rectangle(4, 4, 6, 6);
+ }
+ return false;
+ }
+ return true;
+}
+
+bool test_two_polygon_sets(const Polygon45Set& ps45_1,
+ const Polygon45Set& ps45_2) {
+ std::cout << "test two polygon sets \n";
+ std::vector<Polygon45> polys;
+ ps45_1.get(polys);
+ std::cout << "LVALUE:\n";
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ polys.clear();
+ ps45_2.get(polys);
+ std::cout << "RVALUE:\n";
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ Polygon45Set ps45_o;
+ std::cout << "OR\n";
+ ps45_o = ps45_1 + ps45_2;
+ polys.clear();
+ ps45_o.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(!validate_polygon_set_op(ps45_o, ps45_1, ps45_2, 0)) return false;
+ std::cout << "AND\n";
+ ps45_o = ps45_1 * ps45_2;
+ polys.clear();
+ ps45_o.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(!validate_polygon_set_op(ps45_o, ps45_1, ps45_2, 1)) return false;
+ std::cout << "XOR\n";
+ ps45_o = ps45_1 ^ ps45_2;
+ polys.clear();
+ ps45_o.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(!validate_polygon_set_op(ps45_o, ps45_1, ps45_2, 2)) return false;
+ std::cout << "SUBTRACT\n";
+ ps45_o = ps45_1 - ps45_2;
+ polys.clear();
+ ps45_o.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(!validate_polygon_set_op(ps45_o, ps45_1, ps45_2, 3)) return false;
+ return true;
+}
+
+bool test_two_polygons(const Polygon45& p45_1,
+ const Polygon45& p45_2) {
+ Polygon45Set ps45_1, ps45_2;
+ ps45_1.insert(p45_1);
+ ps45_2.insert(p45_2);
+ ps45_1.insert(rectangle_data<int>(10, -100, 20, 100));
+ ps45_2.insert(rectangle_data<int>(0, 10, 100, 20));
+ if(!test_two_polygon_sets(ps45_1, ps45_2)) return false;
+ Polygon45Set ps45_1_c = ps45_1 - Rectangle(0, 0, 2, 5);
+ Polygon45Set ps45_2_c = ps45_2 - Rectangle(0, 0, 2, 5);
+ if(!test_two_polygon_sets(ps45_1_c, ps45_2_c)) return false;
+ if(!test_two_polygon_sets(ps45_1_c, ps45_2)) return false;
+ if(!test_two_polygon_sets(ps45_1, ps45_2_c)) return false;
+ return true;
+}
+
+bool test_45_touch() {
+ using namespace gtl;
+ connectivity_extraction_45<int> ce;
+ rectangle_data<int> rect1(0, 0, 10, 10);
+ rectangle_data<int> rect2(5, 5, 15, 15);
+ rectangle_data<int> rect3(5, 20, 15, 25);
+ ce.insert(rect1);
+ ce.insert(rect2);
+ ce.insert(rect3);
+ std::vector<std::set<int> > graph(3);
+ ce.extract(graph);
+ if(graph[0].size() == 1 && graph[1].size() == 1 && graph[2].size() == 0) {
+ std::set<int>::iterator itr = graph[0].begin();
+ std::cout << *itr << std::endl;
+ std::set<int>::iterator itr1 = graph[1].begin();
+ std::cout << *itr1 << std::endl;
+ return true;
+ }
+ std::cout << "test failed\n";
+ return false;
+}
+
+bool test_45_touch_ur() {
+ using namespace gtl;
+ connectivity_extraction_45<int> ce;
+ rectangle_data<int> rect1(0, 0, 5, 5);
+ rectangle_data<int> rect2(5, 5, 10, 10);
+ ce.insert(rect1);
+ ce.insert(rect2);
+ std::vector<std::set<int> > graph(2);
+ ce.extract(graph);
+ if(graph[0].size() == 1 && graph[1].size() == 1) {
+ std::set<int>::iterator itr = graph[0].begin();
+ std::cout << *itr << std::endl;
+ std::set<int>::iterator itr1 = graph[1].begin();
+ std::cout << *itr1 << std::endl;
+ return true;
+ }
+ std::cout << "test failed\n";
+ return false;
+}
+
+bool test_45_touch_r() {
+ using namespace gtl;
+ connectivity_extraction_45<int> ce;
+ rectangle_data<int> rect1(0, 0, 5, 5);
+ rectangle_data<int> rect2(5, 0, 10, 5);
+ ce.insert(rect1);
+ ce.insert(rect2);
+ std::vector<std::set<int> > graph(2);
+ ce.extract(graph);
+ if(graph[0].size() == 1 && graph[1].size() == 1) {
+ std::set<int>::iterator itr = graph[0].begin();
+ std::cout << *itr << std::endl;
+ std::set<int>::iterator itr1 = graph[1].begin();
+ std::cout << *itr1 << std::endl;
+ return true;
+ }
+ std::cout << "test failed\n";
+ return false;
+}
+
+bool test_45_touch_boundaries() {
+ using namespace gtl;
+ connectivity_extraction_45<int> ce;
+ rectangle_data<int> rect1(0, 0, 10, 10);
+ rectangle_data<int> rect2(10, 0, 20, 10);
+ rectangle_data<int> rect3(20, 0, 30, 10);
+ rectangle_data<int> rect4(0, 10, 10, 20);
+ rectangle_data<int> rect5(10, 10, 20, 20);
+ rectangle_data<int> rect6(20, 10, 30, 20);
+ rectangle_data<int> rect7(0, 20, 10, 30);
+ rectangle_data<int> rect8(10, 20, 20, 30);
+ rectangle_data<int> rect9(20, 20, 30, 30);
+ ce.insert(rect1);
+ ce.insert(rect2);
+ ce.insert(rect3);
+ ce.insert(rect4);
+ ce.insert(rect5);
+ ce.insert(rect6);
+ ce.insert(rect7);
+ ce.insert(rect8);
+ ce.insert(rect9);
+ std::vector<std::set<int> > graph(9);
+ ce.extract(graph);
+ for(unsigned int i = 0; i < 9; ++i) {
+ std::cout << i << ": ";
+ for(std::set<int>::iterator itr = graph[i].begin(); itr != graph[i].end(); ++itr) {
+ std::cout << *itr << " ";
+ } std::cout << std::endl;
+ }
+ if(graph[0].size() == 3 && graph[1].size() == 5 && graph[2].size() == 3 &&
+ graph[3].size() == 5 && graph[4].size() == 8 && graph[5].size() == 5 &&
+ graph[6].size() == 3 && graph[7].size() == 5 && graph[8].size() == 3) {
+ return true;
+ }
+ std::cout << "test failed\n";
+ return false;
+}
+
+bool test_45_concept_interact() {
+ using namespace gtl;
+ std::vector<polygon_45_data<int> > polys;
+ polys += rectangle_data<int>(10, 10, 20, 20);
+ polys += rectangle_data<int>(15, 15, 25, 25);
+ polys += rectangle_data<int>(5, 25, 10, 35);
+ interact(polys, rectangle_data<int>(0, 0, 13, 13));
+ if(polys.size() != 1) return false;
+ return true;
+}
+
+bool test_get_rectangles() {
+ using namespace gtl;
+ polygon_90_set_data<int> ps(VERTICAL);
+ ps += rectangle_data<int>(0, 0, 10, 10);
+ ps += rectangle_data<int>(5, 5, 15, 15);
+ std::vector<polygon_90_data<int> > polys;
+ ps.get_rectangles(polys, HORIZONTAL);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(polys.size() != 3) return false;
+ std::vector<rectangle_data<int> > rects;
+ ps.get_rectangles(rects, HORIZONTAL);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() != 3) return false;
+ if(!equivalence(rects[2], rectangle_data<int>(5,10,15,15))) return false;
+
+ get_rectangles(polys, rects, VERTICAL);
+ get_rectangles(rects, polys, HORIZONTAL);
+ return equivalence(rects, polys);
+}
+
+bool test_get_trapezoids() {
+ using namespace gtl;
+ polygon_45_set_data<int> ps;
+ ps += rectangle_data<int>(0, 0, 10, 10);
+ ps += rectangle_data<int>(5, 5, 15, 15);
+ std::vector<polygon_45_data<int> > polys;
+ ps.get_trapezoids(polys, HORIZONTAL);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ if(polys.size() != 3) return false;
+ std::vector<polygon_45_data<int> > rects;
+ ps.get_trapezoids(rects, HORIZONTAL);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() != 3) return false;
+ if(!equivalence(rects[2], rectangle_data<int>(5,10,15,15))) return false;
+ get_trapezoids(polys, rects, VERTICAL);
+ get_trapezoids(rects, polys, HORIZONTAL);
+ return equivalence(rects, polys);
+}
+
+bool test_SQRT1OVER2() {
+ Point pts[] = {
+ Point(100, 100),
+ Point(0, 100),
+ Point(100, 200),
+ Point(0, 300),
+ Point(100, 400),
+ Point(0, 500),
+ Point(100, 500),
+ Point(100, 600),
+ Point(200, 500),
+ Point(300, 600),
+ Point(400, 500),
+ Point(500, 600),
+ Point(500, 500),
+ Point(600, 500),
+ Point(500, 400),
+ Point(600, 300),
+ Point(500, 200),
+ Point(600, 100),
+ Point(500, 100),
+ Point(500, 0),
+ Point(400, 100),
+ Point(300, 0),
+ Point(200, 100),
+ Point(100, 0),
+ Point(100, 100)
+ };
+ Polygon45 p45(pts, pts+25);
+ std::cout << is_45(p45) << std::endl;
+ std::cout << p45 << std::endl;
+ Polygon45Set ps45;
+ ps45 += p45;
+ ps45.resize(10, SQRT1OVER2, ORTHOGONAL);
+ std::vector<Polygon45> polys;
+ ps45.get(polys);
+ if(polys.size() != 1) return false;
+ Point pts2[] = {
+ Point(90, 90),
+ Point(-10, 90),
+ Point(-10, 100),
+ Point(90, 200),
+ Point(-10, 300),
+ Point(90, 400),
+ Point(-10, 500),
+ Point(-10, 510),
+ Point(90, 510),
+ Point(90, 610),
+ Point(100, 610),
+ Point(200, 510),
+ Point(300, 610),
+ Point(400, 510),
+ Point(500, 610),
+ Point(510, 610),
+ Point(510, 510),
+ Point(610, 510),
+ Point(610, 500),
+ Point(510, 400),
+ Point(610, 300),
+ Point(510, 200),
+ Point(610, 100),
+ Point(610, 90),
+ Point(510, 90),
+ Point(510, -10),
+ Point(500, -10),
+ Point(400, 90),
+ Point(300, -10),
+ Point(200, 90),
+ Point(100, -10),
+ Point(90, -10),
+ Point(90, 90)
+ };
+ Polygon45 p45reference(pts2, pts2+33);
+ std::cout << is_45(polys[0]) << std::endl;
+ std::cout << polys[0] << std::endl;
+ std::cout << p45reference << std::endl;
+ std::cout << is_45(p45reference) << std::endl;
+ if(!equivalence(polys[0], p45reference)) {
+ std::cout << "polys don't match\n";
+ return false;
+ }
+ ps45.resize(-10, SQRT1OVER2, ORTHOGONAL);
+ polys.clear();
+ ps45.get(polys);
+ if(polys.size() != 1) return false;
+ std::cout << is_45(polys[0]) << std::endl;
+ std::cout << polys[0] << std::endl;
+ if(!equivalence(polys[0], p45)) {
+ std::cout << "polys don't match\n";
+ return false;
+ }
+ ps45.resize(11, SQRT1OVER2, UNFILLED);
+ polys.clear();
+ ps45.get(polys);
+ if(polys.size() != 1) return false;
+ std::cout << is_45(polys[0]) << std::endl;
+ std::cout << polys[0] << std::endl;
+ return true;
+}
+
+bool test_scaling_by_floating(){
+ Point pts[] = {
+ Point(1, 1),
+ Point(10, 1),
+ Point(1, 10)
+ };
+ Polygon45 poly(pts, pts+3);
+ Polygon45Set ps45;
+ ps45 += poly;
+ ps45.scale(double(2.5));
+ std::vector<Polygon45> polys;
+ ps45.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ std::cout << area(polys[i]) << std::endl;
+ }
+ if(polys.size() != 1) return false;
+ if(area(polys[0]) != 242) return false;
+ scale(ps45, double(1)/double(2.5));
+ polys.clear();
+ ps45.get(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ std::cout << polys[i] << std::endl;
+ }
+ return equivalence(polys, poly);
+}
+
+bool test_directional_resize() {
+ std::vector<Rectangle> rects;
+ rects.push_back(Rectangle(0, 0, 100, 100));
+ resize(rects, -10, 10, -10, 10);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() != 1) return false;
+ if(rects[0] != Rectangle(10, 10, 110, 110)) return false;
+
+ return true;
+}
+
+bool test_self_xor() {
+ std::vector<Rectangle> rects;
+ rects.push_back(Rectangle(0, 0, 10, 10));
+ rects.push_back(Rectangle(5, 5, 15, 15));
+ self_xor(rects);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() == 4) return true;
+ else return false;
+}
+
+bool test_grow_and_45() {
+ polygon_45_set_data<int> ps;
+ ps.insert(Rectangle(0, 0, 5, 5));
+ ps.insert(Rectangle(5, 5, 15, 15));
+ grow_and(ps, 2);
+ std::vector<polygon_45_data<int> > rects;
+ ps.get_trapezoids(rects);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() != 1) return false;
+ return equivalence(rects, Rectangle(3, 3, 7, 7));
+}
+
+bool test_self_xor_45() {
+ polygon_45_set_data<int> ps;
+ ps.insert(Rectangle(0, 0, 10, 10));
+ ps.insert(Rectangle(5, 5, 15, 15));
+ self_xor(ps);
+ std::vector<polygon_45_data<int> > rects;
+ ps.get_trapezoids(rects);
+ for(unsigned int i = 0; i < rects.size(); ++i) {
+ std::cout << rects[i] << std::endl;
+ }
+ if(rects.size() == 4) return true;
+ else return false;
+}
+
+bool testViewCopyConstruct() {
+ PolygonSet ps1, ps2;
+ ps1.insert(Rectangle(0, 0, 10, 10));
+ ps2.insert(Rectangle(5, 5, 15, 15));
+ PolygonSet psr = ps1 - ps2;
+ std::vector<Rectangle> rects;
+ rects += psr;
+ for(unsigned int i = 0; i < rects.size(); ++i)
+ std::cout << rects[i] << std::endl;
+ if( rects.size() != 2) return false;
+ Polygon45Set ps45_1, ps45_2;
+ ps45_1.insert(Rectangle(0, 0, 10, 10));
+ ps45_2.insert(Rectangle(5, 5, 15, 15));
+ Polygon45Set ps45_r = ps45_1 - ps45_2;
+ std::vector<Polygon45> polys;
+ ps45_r.get_trapezoids(polys);
+ for(unsigned int i = 0; i < polys.size(); ++i)
+ std::cout << polys[i] << std::endl;
+ if( polys.size() != 2) return false;
+ return true;
+}
+
+int main() {
+ {
+ PolygonSet ps;
+ Polygon p;
+ assign(ps, p);
+ }
+ if(!testViewCopyConstruct()) return 1;
+ if(!test_grow_and_45()) return 1;
+ if(!test_self_xor_45()) return 1;
+ if(!test_self_xor()) return 1;
+ if(!test_directional_resize()) return 1;
+ if(!test_scaling_by_floating()) return 1;
+ if(!test_SQRT1OVER2()) return 1;
+ if(!test_get_trapezoids()) return 1;
+ if(!test_get_rectangles()) return 1;
+ if(!test_45_concept_interact()) return 1;
+ if(!test_45_touch_r()) return 1;
+ if(!test_45_touch_ur()) return 1;
+ if(!test_45_touch()) return 1;
+ if(!test_45_touch_boundaries()) return 1;
+ {
+ Point pts[] = {Point(0,0), Point(5, 5), Point(5, 0)};
+ Polygon45 p45(pts, pts+3);
+ pts[1] = Point(0, 5);
+ Polygon45 p452(pts, pts+3);
+ if(!test_two_polygons(p45,p452)) return 1;
+ pts[2] = Point(5,5);
+ p45.set(pts, pts+3);
+ if(!test_two_polygons(p45,p452)) return 1;
+ pts[0] = Point(5,0);
+ p452.set(pts, pts+3);
+ if(!test_two_polygons(p45, p452)) return 1;
+ Point pts2[] = {Point(0,5), Point(5, 5), Point(5, 0)};
+ Point pts3[] = {Point(0,0), Point(5, 5), Point(5, 0)};
+ p45.set(pts2, pts2 + 3);
+ p452.set(pts3, pts3+3);
+ if(!test_two_polygons(p45, p452)) return 1;
+ Point pts4[] = {Point(0, 5), Point(2, 3), Point(2,5)};
+ Point pts5[] = {Point(0,0), Point(5, 5), Point(5, 0)};
+ p45.set(pts4, pts4+3);
+ p452.set(pts5, pts5+3);
+ //if(!test_two_polygons(p45, p452)) return 1;
+ }
+ {
+ std::vector<point_data<int> > pts;
+ pts.push_back(point_data<int>(0, 0));
+ pts.push_back(point_data<int>(10, 0));
+ pts.push_back(point_data<int>(10, 10));
+ pts.push_back(point_data<int>(0, 10));
+ std::vector<point_data<int> > pts2;
+ pts2.push_back(point_data<int>(0, 0));
+ pts2.push_back(point_data<int>(10, 10));
+ pts2.push_back(point_data<int>(0, 20));
+ pts2.push_back(point_data<int>(-10, 10));
+ std::vector<point_data<int> > pts3;
+ pts3.push_back(point_data<int>(0, 0));
+ pts3.push_back(point_data<int>(10, 11));
+ pts3.push_back(point_data<int>(0, 20));
+ pts3.push_back(point_data<int>(-100, 8));
+ polygon_data<int> p; p.set(pts3.begin(), pts3.end());
+ polygon_45_data<int> p45; p45.set(pts2.begin(), pts2.end());
+ polygon_90_data<int> p90; p90.set(pts.begin(), pts.end());
+ polygon_with_holes_data<int> pwh; pwh.set(pts3.begin(), pts3.end());
+ polygon_45_with_holes_data<int> p45wh; p45wh.set(pts2.begin(), pts2.end());
+ polygon_90_with_holes_data<int> p90wh; p90wh.set(pts.begin(), pts.end());
+ assign(p, p90);
+ assign(p, p45);
+ assign(p, p);
+ //illegal: assign(p, p90wh);
+ //illegal: assign(p, p45wh);
+ //illegal: assign(p, pwh);
+
+ assign(p45, p90);
+ assign(p45, p45);
+ //illegal: assign(p45, p);
+ //illegal: assign(p45, p90wh);
+ //illegal: assign(p45, p45wh);
+ //illegal: assign(p45, pwh);
+
+ assign(p90, p90);
+ //illegal: assign(p90, p45);
+ //illegal: assign(p90, p);
+ //illegal: assign(p90, p90wh);
+ //illegal: assign(p90, p45wh);
+ //illegal: assign(p90, pwh);
+
+ assign(pwh, p90);
+ assign(pwh, p45);
+ assign(pwh, p);
+ assign(pwh, p90wh);
+ assign(pwh, p45wh);
+ assign(pwh, pwh);
+
+ assign(p45wh, p90);
+ assign(p45wh, p45);
+ //illegal: assign(p45wh, p);
+ assign(p45wh, p90wh);
+ assign(p45wh, p45wh);
+ //illegal: assign(p45wh, pwh);
+
+ assign(p90wh, p90);
+ //illegal: assign(p90wh, p45);
+ //illegal: assign(p90wh, p);
+ assign(p90wh, p90wh);
+ //illegal: assign(p90wh, p45wh);
+ //illegal: assign(p90wh, pwh);
+ pts.clear();
+ pts.push_back(point_data<int>(0, 0));
+ pts.push_back(point_data<int>(3, 0));
+ pts.push_back(point_data<int>(0, 1));
+ p.set(pts.begin(), pts.end());
+ std::cout << std::endl; std::cout << (area(p90));
+ std::cout << std::endl; std::cout << (area(p45));
+ std::cout << std::endl; std::cout << (area(p));
+ std::cout << std::endl; std::cout << (area(p90wh));
+ std::cout << std::endl; std::cout << (area(p45wh));
+ std::cout << std::endl; std::cout << (area(pwh));
+ std::cout << std::endl;
+ point_data<int> pt(1, 1);
+ std::cout << contains(p, pt) << std::endl;
+ std::cout << contains(p90, pt) << std::endl;
+
+ interval_data<int> ivl = construct<interval_data<int> >(0, 10);
+ std::cout << get(ivl, LOW) << std::endl;
+ set(ivl, HIGH, 20);
+
+ std::cout << perimeter(p) << std::endl;
+ if(winding(p) == LOW) std::cout << "LOW" << std::endl;
+ if(winding(p) == HIGH) std::cout << "HIGH" << std::endl;
+ rectangle_data<long long> rd;
+ std::cout << extents(rd, p) << std::endl;
+ std::cout << rd << std::endl;
+
+ boolean_op::testBooleanOr<int>();
+
+ std::vector<rectangle_data<int> > rects1, rects2;
+ rects2.push_back(rectangle_data<int>(0, 0, 10, 10));
+ print_is_polygon_90_set_concept((polygon_90_set_data<int>()));
+ print_is_mutable_polygon_90_set_concept((polygon_90_set_data<int>()));
+ print_is_polygon_90_set_concept((polygon_90_data<int>()));
+ print_is_polygon_90_set_concept((std::vector<polygon_90_data<int> >()));
+ assign(rects1, rects2);
+ polygon_90_set_data<int> ps90;
+ assign(ps90, rects2);
+ assign(rects2, ps90);
+ assign(ps90, p90);
+ assign(rects2, p90);
+ std::cout << p90 << std::endl;
+ for(unsigned int i = 0; i < rects2.size(); ++i) {
+ std::cout << rects2[i] << std::endl;
+ }
+ bloat(rects2, 10);
+ shrink(rects2[0], 10);
+ for(unsigned int i = 0; i < rects2.size(); ++i) {
+ std::cout << rects2[i] << std::endl;
+ }
+ move(rects2[0], HORIZONTAL, 30);
+ assign(rects1, rects2 + p90);
+ std::cout << "result of boolean or\n";
+ for(unsigned int i = 0; i < rects1.size(); ++i) {
+ std::cout << rects1[i] << std::endl;
+ }
+ rects1 -= p90;
+ std::cout << "result of boolean not\n";
+ for(unsigned int i = 0; i < rects1.size(); ++i) {
+ std::cout << rects1[i] << std::endl;
+ }
+ rects1 += p90;
+ std::cout << "result of boolean OR\n";
+ for(unsigned int i = 0; i < rects1.size(); ++i) {
+ std::cout << rects1[i] << std::endl;
+ }
+ rects1 *= p90;
+ std::cout << "result of boolean AND\n";
+ for(unsigned int i = 0; i < rects1.size(); ++i) {
+ std::cout << rects1[i] << std::endl;
+ }
+ rects1 ^= rects2;
+ std::cout << "result of boolean XOR\n";
+ for(unsigned int i = 0; i < rects1.size(); ++i) {
+ std::cout << rects1[i] << std::endl;
+ }
+ rects2.clear();
+ get_max_rectangles(rects2, p90);
+ std::cout << "result of max rectangles\n";
+ for(unsigned int i = 0; i < rects2.size(); ++i) {
+ std::cout << rects2[i] << std::endl;
+ }
+ rects2.clear();
+ //operator += and -= don't support polygons, so + and - should not exist
+// rects2 += p90 + 6;
+// std::cout << "result of resize\n";
+// for(unsigned int i = 0; i < rects2.size(); ++i) {
+// std::cout << rects2[i] << std::endl;
+// }
+// std::cout << "result of resize\n";
+ std::vector<polygon_90_with_holes_data<int> > polyswh1, polyswh2;
+// polyswh1 += p90 -2;
+// for(unsigned int i = 0; i < polyswh1.size(); ++i) {
+// std::cout << polyswh1[i] << std::endl;
+// }
+// std::cout << "result of resize\n";
+ std::vector<polygon_90_data<int> > polys1, polys2;
+ polys1 += p90;
+ polys1 -= 2;
+// polys1 += p90 -2;
+ for(unsigned int i = 0; i < polys1.size(); ++i) {
+ std::cout << polys1[i] << std::endl;
+ }
+
+ boolean_op_45<int>::testScan45();
+ polygon_45_formation<int>::testPolygon45Formation();
+ polygon_45_formation<int>::testPolygon45Tiling();
+
+ axis_transformation atr;
+ transform(p, atr);
+ transform(p45, atr);
+ transform(p90, atr);
+ transform(pwh, atr);
+ transform(p45wh, atr);
+ transform(p90wh, atr);
+ scale_up(p, 2);
+ scale_up(p45, 2);
+ scale_up(p90, 2);
+ scale_up(pwh, 2);
+ scale_up(p45wh, 2);
+ scale_up(p90wh, 2);
+ scale_down(p, 2);
+ scale_down(p45, 2);
+ scale_down(p90, 2);
+ scale_down(pwh, 2);
+ scale_down(p45wh, 2);
+ scale_down(p90wh, 2);
+ std::vector<polygon_45_data<int> > p45s1, p45s2;
+ std::cout << equivalence(p45s1, p45s2) << std::endl;
+ std::cout << equivalence(p45, p45wh) << std::endl;
+ std::cout << equivalence(p90, p45wh) << std::endl;
+ gtl::assign(p45s1, p90);
+ p90 = polys1[0];
+ move(p90, orientation_2d(HORIZONTAL), 8);
+ std::cout << p90 << std::endl << p45wh << std::endl;
+ polygon_45_set_data<int> ps45 = p90 + p45wh;
+ assign(p45s1, ps45);
+ std::cout << "result\n";
+ for(unsigned int i = 0; i < p45s1.size(); ++i) {
+ std::cout << p45s1[i] << std::endl;
+ }
+ std::cout << equivalence(p, pwh) << std::endl;
+ std::cout << equivalence(p90, pwh) << std::endl;
+ std::cout << equivalence(p45, pwh) << std::endl;
+ std::cout << equivalence(pwh, pwh) << std::endl;
+ p + pwh;
+ p90 + pwh;
+ p45 + pwh;
+ std::cout << testInterval() << std::endl;
+ std::cout << testRectangle() << std::endl;
+ std::cout << testPolygon() << std::endl;
+ std::cout << testPropertyMerge() << std::endl;
+ std::cout << testPolygonAssign() << std::endl;
+ std::cout << testPolygonWithHoles() << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationRect()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationP1()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationP2()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationPolys()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationSelfTouch1()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationSelfTouch2()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationSelfTouch3()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testSegmentIntersection()) << std::endl;
+ std::cout << (property_merge<int, int>::test_insertion()) << std::endl;
+ std::cout << (line_intersection<int>::test_verify_scan()) << std::endl;
+ std::cout << (line_intersection<int>::test_validate_scan()) << std::endl;
+ std::cout << (scanline<int, int>::test_scanline()) << std::endl;
+ std::cout << (property_merge<int, int>::test_merge()) << std::endl;
+ std::cout << (property_merge<int, int>::test_intersection()) << std::endl;
+ std::cout << (polygon_arbitrary_formation<int>::testPolygonArbitraryFormationColinear()) << std::endl;
+ std::cout << (property_merge<int, int>::test_manhattan_intersection()) << std::endl;
+ std::cout << (test_arbitrary_boolean_op<int>()) << std::endl;
+ }
+ {
+ polygon_set_data<int> psd;
+ rectangle_data<int> rect;
+ set_points(rect, point_data<int>(0, 0), point_data<int>(10, 10));
+ psd.insert(rect);
+ polygon_set_data<int> psd2;
+ set_points(rect, point_data<int>(5, 5), point_data<int>(15, 15));
+ psd2.insert(rect);
+ std::vector<polygon_data<int> > pv;
+ polygon_set_data<int> psd3;
+ psd3 = psd + psd2;
+ psd3.get(pv);
+ for(unsigned int i = 0; i < pv.size(); ++i) {
+ std::cout << pv[i] << std::endl;
+ }
+ psd += psd2;
+ pv.clear();
+ psd3.get(pv);
+ for(unsigned int i = 0; i < pv.size(); ++i) {
+ std::cout << pv[i] << std::endl;
+ }
+ }
+ {
+ polygon_90_set_data<int> psd;
+ rectangle_data<int> rect;
+ set_points(rect, point_data<int>(0, 0), point_data<int>(10, 10));
+ psd.insert(rect);
+ polygon_90_set_data<int> psd2;
+ set_points(rect, point_data<int>(5, 5), point_data<int>(15, 15));
+ psd2.insert(rect);
+ std::vector<polygon_90_data<int> > pv;
+ interact(psd, psd2);
+ assign(pv, psd);
+ for(unsigned int i = 0; i < pv.size(); ++i) {
+ std::cout << pv[i] << std::endl;
+ }
+
+ connectivity_extraction_90<int> ce;
+ ce.insert(pv[0]);
+ ce.insert(psd2);
+ std::vector<std::set<int> > graph(2);
+ ce.extract(graph);
+ if(graph[0].size() == 1) std::cout << "connectivity extraction is alive\n";
+
+ std::vector<rectangle_data<long long> > lobs;
+ get_max_rectangles(lobs, psd);
+ if(lobs.size() == 1) std::cout << "max rectangles is alive\n";
+
+ std::vector<rectangle_data<int> > rv;
+ rv.push_back(rect);
+ set_points(rect, point_data<int>(0, 0), point_data<int>(10, 10));
+ rv.push_back(rect);
+ self_intersect(rv);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+
+ assign(rv, rv + 1);
+ std::cout << rv.size() << std::endl;
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ assign(rv, rv - 1);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ rv += 1;
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ rv -= 1;
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ rv.clear();
+ set_points(rect, point_data<int>(0, 0), point_data<int>(10, 10));
+ rv.push_back(rect);
+ set_points(rect, point_data<int>(12, 12), point_data<int>(20, 20));
+ rv.push_back(rect);
+ grow_and(rv, 7);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ std::cout << area(rv) << std::endl;
+ std::cout << area(rv) << std::endl;
+
+ scale_up(rv, 10);
+ std::cout << area(rv) << std::endl;
+ scale_down(rv, 7);
+ std::cout << area(rv) << std::endl;
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ keep(rv, 290, 300, 7, 24, 7, 24);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ keep(rv, 300, 310, 7, 24, 7, 24);
+ if(rv.empty()) std::cout << "keep is alive\n";
+ }
+ {
+// typedef int Unit;
+// typedef point_data<int> Point;
+// typedef interval_data<int> Interval;
+// typedef rectangle_data<int> Rectangle;
+// typedef polygon_90_data<int> Polygon;
+// typedef polygon_90_with_holes_data<int> PolygonWithHoles;
+// typedef polygon_45_data<int> Polygon45;
+// typedef polygon_45_with_holes_data<int> Polygon45WithHoles;
+// typedef polygon_90_set_data<int> PolygonSet;
+// //typedef polygon_45_set_data<int> Polygon45Set;
+// typedef axis_transformation AxisTransform;
+// typedef transformation<int> Transform;
+ //test polygon45 area, polygon45 with holes area
+ std::vector<Point> pts;
+ pts.clear();
+ pts.push_back(Point(10, 10));
+ pts.push_back(Point(15, 10));
+ pts.push_back(Point(10, 15));
+ Polygon45 polyHole;
+ polyHole.set(pts.begin(), pts.end());
+ pts.clear();
+ pts.push_back(Point(10, 0));
+ pts.push_back(Point(20, 10));
+ pts.push_back(Point(20, 30));
+ pts.push_back(Point(0, 50));
+ pts.push_back(Point(0, 10));
+ Polygon45WithHoles polyWHoles;
+ polyWHoles.set(pts.begin(), pts.end());
+ polyWHoles.set_holes(&polyHole, (&polyHole)+1);
+ std::cout << polyWHoles << std::endl;
+ std::cout << area(polyWHoles) << std::endl;
+ std::cout << area(polyWHoles) << std::endl;
+ //test polygon45, polygon45with holes transform
+ AxisTransform atr(AxisTransform::EAST_SOUTH);
+ Polygon45WithHoles p45wh(polyWHoles);
+ transform(polyWHoles, atr);
+ std::cout << polyWHoles << std::endl;
+ Transform tr(atr);
+ tr.invert();
+ transform(polyWHoles, tr);
+ std::cout << polyWHoles << std::endl;
+ if(area(polyWHoles) != 687.5) return 1;
+ //test polygon, polygon with holes transform
+ Polygon ph;
+ assign(ph, Rectangle(10, 10, 20, 20));
+ PolygonWithHoles pwh;
+ assign(pwh, Rectangle(0, 0, 100, 100));
+ pwh.set_holes(&ph, (&ph)+1);
+ std::cout << area(pwh) << std::endl;
+ transform(pwh, atr);
+ std::cout << pwh << std::endl;
+ std::cout << area(pwh) << std::endl;
+ transform(pwh, tr);
+ std::cout << pwh << std::endl;
+ std::cout << area(pwh) << std::endl;
+ if(area(pwh) != 9900) return 1;
+
+ //test point scale up / down
+ Point pt(10, 10);
+ scale_up(pt, 25);
+ if(pt != Point(250, 250)) return 1;
+ std::cout << pt << std::endl;
+ scale_down(pt, 25);
+ if(pt != Point(10, 10)) return 1;
+ std::cout << pt << std::endl;
+ scale_down(pt, 25);
+ if(pt != Point(0, 0)) return 1;
+ std::cout << pt << std::endl;
+
+ //test polygon, polygon with holes scale up down
+ PolygonWithHoles tmpPwh(pwh);
+ scale_up(pwh, 25);
+ std::cout << pwh << std::endl;
+ scale_down(pwh, 25);
+ if(area(pwh) != area(tmpPwh)) return 1;
+ std::cout << pwh << std::endl;
+ scale_down(pwh, 25);
+ std::cout << pwh << std::endl;
+ //test polygon45, polygon45 with holes is45
+ std::cout << is_45(polyHole) << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ pts.clear();
+ pts.push_back(Point(10, 10));
+ pts.push_back(Point(15, 10));
+ pts.push_back(Point(10, 16));
+ polyHole.set(pts.begin(), pts.end());
+ std::cout << is_45(polyHole) << std::endl;
+ if(is_45(polyHole) != false) return 1;
+ //test polygon45, polygon45 with holes snap 45
+ snap_to_45(polyHole);
+ std::cout << is_45(polyHole) << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ std::cout << polyHole << std::endl;
+ //test polygon45, polygon45 with holes scalue up down
+ scale_up(polyHole, 10000);
+ std::cout << polyHole << std::endl;
+ scale_down(polyHole, 3);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 5);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 7);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 13);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_up(polyHole, 3);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ pts.clear();
+ pts.push_back(Point(11, 1));
+ pts.push_back(Point(21, 11));
+ pts.push_back(Point(11, 21));
+ pts.push_back(Point(1, 11));
+ polyHole.set(pts.begin(), pts.end());
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 3);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_up(polyHole, 10000);
+ std::cout << polyHole << std::endl;
+ scale_down(polyHole, 3);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 5);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 7);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 13);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_up(polyHole, 3);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+ scale_down(polyHole, 2);
+ std::cout << is_45(polyHole) << " " << polyHole << std::endl;
+ if(is_45(polyHole) != true) return 1;
+
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_up(polyWHoles, 100013);
+ std::cout << polyWHoles << std::endl;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 3);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+ scale_down(polyWHoles, 2);
+ std::cout << is_45(polyWHoles) << " " << polyWHoles << std::endl;
+ if(is_45(polyWHoles) != true) return 1;
+
+ std::cout << (boolean_op_45<Unit>::testScan45()) << std::endl;
+ std::cout << (polygon_45_formation<Unit>::testPolygon45Formation()) << std::endl;
+ std::cout << (polygon_45_formation<Unit>::testPolygon45Tiling()) << std::endl;
+
+
+ {
+ PolygonSet ps;
+ Rectangle rect;
+ ps.insert(Rectangle(0, 0, 10, 10));
+ std::cout << area(ps) << std::endl;
+ if(area(ps) != 100) return 1;
+ scale_up(ps, 3);
+ std::cout << area(ps) << std::endl;
+ if(area(ps) != 900) return 1;
+ scale_down(ps, 2);
+ std::cout << area(ps) << std::endl;
+ if(area(ps) != 225) return 1;
+ transform(ps, atr);
+ std::vector<Rectangle> rv;
+ rv.clear();
+ ps.get(rv);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ transform(ps, tr);
+ rv.clear();
+ ps.get(rv);
+ if(rv.size() == 1) {
+ assign(rect, rv.back());
+ std::cout << rect << std::endl;
+ }
+ }
+// //test polygon45set transform
+// pts.clear();
+// pts.push_back(Point(10, 10));
+// pts.push_back(Point(15, 10));
+// pts.push_back(Point(10, 15));
+// polyHole.set(pts.begin(), pts.end());
+// Polygon45Set ps451, ps452;
+// ps451.insert(polyHole);
+// ps452 = ps451;
+// std::cout << (ps451 == ps452) << std::endl;
+// if(ps451 != ps452) return 1;
+// ps451.transform(atr);
+// std::cout << (ps451 == ps452) << std::endl;
+// if(ps451 == ps452) return 1;
+// ps451.transform(tr);
+// std::cout << (ps451 == ps452) << std::endl;
+// if(ps451 != ps452) return 1;
+
+// //test polygon45set area
+// std::cout << ps451.area() << std::endl;
+// if(ps451.area() != 12.5) return 1;
+// //test polygon45set scale up down
+// ps451.scaleUp(3);
+// std::cout << ps451.area() << std::endl;
+// if(ps451.area() != 112.5) return 1;
+// ps451.scaleDown(2);
+// std::cout << ps451.area() << std::endl;
+// if(ps451.area() != 32) return 1;
+// //test polygonset scalue up down
+ }
+ {
+ std::cout << (testPolygon45SetRect()) << std::endl;
+ //testPolygon45SetPerterbation(); //re-enable after non-intersection fix
+ testPolygon45Set();
+ //testPolygon45SetDORA(); //re-enable after non-intersection fix
+ polygon_45_set_data<int> ps45_1, ps45_2, ps45_3;
+ ps45_1.insert(rectangle_data<int>(0, 0, 10, 10));
+ ps45_2.insert(rectangle_data<int>(5, 5, 15, 15));
+ std::vector<polygon_45_data<int> > p45s;
+ ps45_3 = ps45_1 | ps45_2;
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ p45s.clear();
+ ps45_3 = ps45_1 + ps45_2;
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ p45s.clear();
+ ps45_3 = ps45_1 * ps45_2;
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ p45s.clear();
+ ps45_3 = ps45_1 - ps45_2;
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ p45s.clear();
+ ps45_3 = ps45_1 ^ ps45_2;
+ ps45_3.get(p45s);
+ if(p45s.size() == 2) std::cout << p45s[0] << " " << p45s[1] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ std::vector<point_data<int> > pts;
+ pts.clear();
+ pts.push_back(point_data<int>(7, 0));
+ pts.push_back(point_data<int>(20, 13));
+ pts.push_back(point_data<int>(0, 13));
+ pts.push_back(point_data<int>(0, 0));
+ polygon_45_data<int> p45_1(pts.begin(), pts.end());
+ ps45_3.clear();
+ ps45_3.insert(p45_1);
+ p45s.clear();
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ ps45_3 += 1;
+ p45s.clear();
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ ps45_3 -= 1;
+ p45s.clear();
+ ps45_3.get(p45s);
+ if(p45s.size()) std::cout << p45s[0] << std::endl;
+ else {
+ std::cout << "test failed\n";
+ return 1;
+ }
+ }
+ {
+ polygon_90_set_data<int> p90sd;
+ p90sd.insert(rectangle_data<int>(0, 0, 10, 10));
+ std::vector<rectangle_data<int> > rects;
+ std::vector<polygon_90_data<int> > polys90;
+ std::vector<polygon_90_with_holes_data<int> > pwhs90;
+ assign(rects, p90sd);
+ assign(polys90, p90sd);
+ assign(pwhs90, p90sd);
+ std::cout << equivalence(rects, polys90) << std::endl;
+ std::cout << equivalence(pwhs90, polys90) << std::endl;
+ pwhs90.clear();
+ assign(pwhs90, polys90);
+ std::cout << equivalence(pwhs90, polys90) << std::endl;
+ }
+ {
+ polygon_45_set_data<int> p45sd;
+ p45sd.insert(rectangle_data<int>(0, 0, 10, 10));
+ std::vector<rectangle_data<int> > rects;
+ std::vector<polygon_45_data<int> > polys45;
+ std::vector<polygon_45_with_holes_data<int> > pwhs45;
+ get_trapezoids(polys45, p45sd);
+ assign(polys45, p45sd);
+ assign(pwhs45, p45sd);
+ std::cout << equivalence(pwhs45, polys45) << std::endl;
+ pwhs45.clear();
+ assign(pwhs45, polys45);
+ std::cout << equivalence(pwhs45, polys45) << std::endl;
+ }
+ {
+ polygon_set_data<int> psd;
+ psd.insert(rectangle_data<int>(0, 0, 10, 10));
+ std::vector<polygon_data<int> > polys;
+ std::vector<polygon_with_holes_data<int> > pwhs;
+ assign(polys, psd);
+ assign(pwhs, psd);
+ std::cout << equivalence(pwhs, polys) << std::endl;
+ pwhs.clear();
+ assign(pwhs, polys);
+ std::cout << equivalence(pwhs, polys) << std::endl;
+ }
+ {
+ typedef point_3d_data<int> Point3D;
+ Point3D p3d1(0, 1, 3), p3d2(0, 1, 2);
+ if(equivalence(p3d1, p3d2)) return 1;
+ if(euclidean_distance(p3d1, p3d2) != 1) return 1;
+ if(euclidean_distance(p3d1, p3d2, PROXIMAL) != 1) return 1;
+ if(manhattan_distance(p3d1, p3d2) != 1) return 1;
+ assign(p3d1, p3d2);
+ if(!equivalence(p3d1, p3d2)) return 1;
+ p3d1 = construct<Point3D>(x(p3d1), y(p3d1), z(p3d1));
+ if(!equivalence(p3d1, p3d2)) return 1;
+ convolve(p3d1, p3d2);
+ if(equivalence(p3d1, p3d2)) return 1;
+ deconvolve(p3d1, p3d2);
+ if(!equivalence(p3d1, p3d2)) return 1;
+ if(get(p3d1, PROXIMAL) != 2) return 1;
+ scale(p3d1, anisotropic_scale_factor<double>(2, 2, 2));
+ if(equivalence(p3d1, p3d2)) return 1;
+ scale_down(p3d1, 2);
+ if(!equivalence(p3d1, p3d2)) return 1;
+ scale_up(p3d1, 2);
+ if(equivalence(p3d1, p3d2)) return 1;
+ scale_down(p3d1, 2);
+ set(p3d1, PROXIMAL, 3);
+ if(equivalence(p3d1, p3d2)) return 1;
+ axis_transformation atr = axis_transformation::END;
+ transform(p3d1, atr);
+ if(z(p3d1) != -3) return 1;
+ z(p3d1, 2);
+ if(!equivalence(p3d1, p3d2)) return 1;
+ }
+ {
+ polygon_90_set_data<int> ps1(HORIZONTAL), ps2(VERTICAL);
+ ps1 += rectangle_data<int>(0, 0, 10, 120);
+ assign(ps1, ps2);
+ std::cout << equivalence(ps1, ps2) << std::endl;
+ }
+ {
+ std::vector<rectangle_data<long long> > lobs, input;
+ input.push_back(rectangle_data<long long>(0, 0, 10, 10));
+ input.push_back(rectangle_data<long long>(10, 5, 15, 15));
+ get_max_rectangles(lobs, input);
+ if(lobs.size() == 3) std::cout << "max rectangles is correct\n";
+ }
+ {
+ polygon_set_data<int> ps1, ps2, ps3;
+ ps1.insert(rectangle_data<int>(0, 0, 10, 10));
+ ps2.insert(rectangle_data<int>(0, 0, 15, 5));
+ ps3.insert(rectangle_data<int>(0, 0, 20, 2));
+ std::cout << area(ps1 + ps2) << std::endl;
+ keep(ps1, 0, 100, 0, 100, 0, 100);
+ if(empty(ps1)) return 1;
+ rectangle_data<int> bbox;
+ extents(bbox, ps1);
+ std::cout << bbox << std::endl;
+ //resize(ps1, 1);
+ //shrink(ps1, 1);
+ //bloat(ps1, 1);
+ scale_up(ps1, 2);
+ scale_down(ps1, 2);
+ axis_transformation atr;
+ transform(ps1, atr);
+ std::cout << area(ps1) << std::endl;
+ if(area(ps1) != 100) return 1;
+ clear(ps1);
+ if(!empty(ps1)) return 1;
+ ps1 = ps2 * ps3;
+ ps1 *= ps2;
+ ps1 - ps2;
+ ps1 -= ps2;
+ ps1 ^ ps2;
+ ps1 ^= ps2;
+ ps1 | ps2;
+ ps1 |= ps2;
+ }
+ {
+ polygon_45_set_data<int> ps45_1, ps45_2;
+ ps45_1.insert(rectangle_data<int>(0, 0, 10, 10));
+ keep(ps45_1, 0, 1000, 0, 1000, 0, 1000);
+ std::cout << area(ps45_1) << std::endl;
+ std::cout << empty(ps45_1) << std::endl;
+ rectangle_data<int> bbox;
+ extents(bbox, ps45_1);
+ std::cout << bbox << std::endl;
+ resize(ps45_1, 1);
+ shrink(ps45_1, 1);
+ bloat(ps45_1, 1);
+ scale_up(ps45_1, 2);
+ scale_down(ps45_1, 2);
+ axis_transformation atr;
+ transform(ps45_1, atr);
+ std::cout << area(ps45_1) << std::endl;
+ if(area(ps45_1) != 144) return 1;
+ clear(ps45_1);
+ if(!empty(ps45_1)) return 1;
+ }
+ {
+ std::vector<polygon_45_data<int> > p45v;
+ p45v + p45v;
+ p45v *= p45v;
+ p45v += p45v;
+ p45v - p45v;
+ p45v -= p45v;
+ p45v ^ p45v;
+ p45v ^= p45v;
+ p45v | p45v;
+ p45v |= p45v;
+ p45v + 1;
+ p45v += 1;
+ p45v - 1;
+ p45v -= 1;
+ p45v + (p45v + p45v);
+ }
+ {
+ polygon_45_set_data<int> ps45;
+ polygon_90_set_data<int> ps90;
+ std::vector<polygon_90_with_holes_data<int> > p90whv;
+ ps45.insert(ps90);
+ ps45.insert(p90whv);
+ ps45.insert(p90whv + p90whv);
+
+ ps45.insert(polygon_90_with_holes_data<int>());
+ polygon_with_holes_data<int> pwh;
+ snap_to_45(pwh);
+ }
+ {
+ point_data<int> pt(1,2);
+ point_3d_data<int> pt3d(1,2,3);
+ equivalence(pt, pt3d);
+ deconvolve(pt, pt3d);
+ manhattan_distance(pt, pt3d);
+ move(pt, HORIZONTAL, 1);
+ scale(pt, anisotropic_scale_factor<double>(2, 2, 2));
+ pt = pt3d;
+ }
+ {
+ polygon_90_set_data<int> ps90_1, ps90_2;
+ ps90_1.insert(rectangle_data<int>(0, 0, 10, 10));
+ keep(ps90_1, 0, 1000, 0, 1000, 0, 1000);
+ std::cout << area(ps90_1) << std::endl;
+ std::cout << empty(ps90_1) << std::endl;
+ rectangle_data<int> bbox;
+ extents(bbox, ps90_1);
+ std::cout << bbox << std::endl;
+ resize(ps90_1, 1);
+ shrink(ps90_1, 1);
+ bloat(ps90_1, 1);
+ scale_up(ps90_1, 2);
+ scale_down(ps90_1, 2);
+ scale(ps90_1, anisotropic_scale_factor<double>(2, 2, 2));
+ scale(ps90_1, anisotropic_scale_factor<double>(0.5, 0.5, 0.5));
+ axis_transformation atr;
+ transform(ps90_1, atr);
+ std::cout << area(ps90_1) << std::endl;
+ if(area(ps90_1) != 144) return 1;
+ clear(ps90_1);
+ if(!empty(ps90_1)) return 1;
+ }
+ if(!nonInteger45StessTest()) return 1;
+ std::cout << "ALL TESTS COMPLETE\n";
+ return 0;
+}
Modified: sandbox/gtl/gtl/interval_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/interval_concept.hpp (original)
+++ sandbox/gtl/gtl/interval_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -15,17 +15,18 @@
struct interval_concept {};
template <typename T>
- struct is_interval_concept {};
+ struct is_interval_concept { typedef gtl_no type; };
template <>
- struct is_interval_concept<interval_concept> { typedef void type; };
+ struct is_interval_concept<interval_concept> { typedef gtl_yes type; };
template <typename T>
- struct is_mutable_interval_concept {};
+ struct is_mutable_interval_concept { typedef gtl_no type; };
template <>
- struct is_mutable_interval_concept<interval_concept> { typedef void type; };
+ struct is_mutable_interval_concept<interval_concept> { typedef gtl_yes type; };
template <typename T>
- static inline typename interval_traits<T>::coordinate_type
+ typename requires_1<typename gtl_if<typename is_interval_concept<typename geometry_concept<T>::type>::type>::type,
+ typename interval_traits<T>::coordinate_type>::type
get(const T& interval, direction_1d dir) {
return interval_traits<T>::get(interval, dir);
}
@@ -49,8 +50,8 @@
}
template <typename T, typename T2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
+ typename requires_1< typename gtl_and<typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
T>::type
copy_construct(const T2& interval) {
return construct<T>
@@ -59,8 +60,8 @@
}
template <typename T1, typename T2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<T1>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<T1>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
T1>::type &
assign(T1& lvalue, const T2& rvalue) {
lvalue = copy_construct<T1>(rvalue);
@@ -68,8 +69,8 @@
}
template <typename T, typename T2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_interval_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
bool>::type
equivalence(const T& interval1, const T2& interval2) {
return get(interval1, LOW) ==
@@ -92,8 +93,8 @@
}
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
bool>::type
contains(const interval_type& interval,
const interval_type_2& value, bool consider_touch = true) {
@@ -101,46 +102,47 @@
contains(interval, get(value, HIGH), consider_touch);
}
- /// get the low coordinate
+ // get the low coordinate
template <typename interval_type>
typename requires_1< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
typename interval_traits<interval_type>::coordinate_type >::type
low(const interval_type& interval) { return get(interval, LOW); }
- /// get the high coordinate
+ // get the high coordinate
template <typename interval_type>
typename requires_1< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
typename interval_traits<interval_type>::coordinate_type >::type
high(const interval_type& interval) { return get(interval, HIGH); }
- /// get the center coordinate
+ // get the center coordinate
template <typename interval_type>
typename requires_1< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
typename interval_traits<interval_type>::coordinate_type >::type
center(const interval_type& interval) { return (high(interval) + low(interval))/2; }
- /// set the low coordinate to v
+ // set the low coordinate to v
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, void>::type
low(interval_type& interval,
typename interval_traits<interval_type>::coordinate_type v) {
set(interval, LOW, v); }
- /// set the high coordinate to v
+ // set the high coordinate to v
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, void>::type
high(interval_type& interval,
typename interval_traits<interval_type>::coordinate_type v) {
set(interval, HIGH, v); }
- /// get the magnitude of the interval
+ // get the magnitude of the interval
template <typename interval_type>
- typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference
+ typename requires_1< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference>::type
delta(const interval_type& interval) {
typedef typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference diffT;
return (diffT)high(interval) - (diffT)low(interval); }
-
- /// flip this about coordinate
+
+ // flip this about coordinate
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type &
flip(interval_type& interval,
@@ -153,7 +155,7 @@
return interval;
}
- /// scale interval by factor
+ // scale interval by factor
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type &
scale_up(interval_type& interval,
@@ -187,7 +189,7 @@
return interval;
}
- /// move interval by delta
+ // move interval by delta
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type &
move(interval_type& interval,
@@ -199,7 +201,7 @@
return interval;
}
- /// convolve this with b
+ // convolve this with b
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type &
convolve(interval_type& interval,
@@ -212,7 +214,7 @@
return interval;
}
- /// deconvolve this with b
+ // deconvolve this with b
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type &
deconvolve(interval_type& interval,
@@ -225,25 +227,28 @@
return interval;
}
- /// convolve this with b
+ // convolve this with b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type, interval_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
convolve(interval_type& interval,
const interval_type_2& b) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
Unit newLow = low(interval) + low(b);
Unit newHigh = high(interval) + high(b);
low(interval, newLow);
- high(interval, newHigh);
- return interval;
+ high(interval, newHigh);
+ return interval;
}
- /// deconvolve this with b
+ // deconvolve this with b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- interval_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
deconvolve(interval_type& interval,
const interval_type_2& b) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
@@ -254,11 +259,12 @@
return interval;
}
- /// reflected convolve this with b
+ // reflected convolve this with b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- interval_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
reflected_convolve(interval_type& interval,
const interval_type_2& b) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
@@ -269,10 +275,12 @@
return interval;
}
- /// reflected deconvolve this with b
+ // reflected deconvolve this with b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type, interval_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
reflected_deconvolve(interval_type& interval,
const interval_type_2& b) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
@@ -283,7 +291,7 @@
return interval;
}
- /// distance from a coordinate to an interval
+ // distance from a coordinate to an interval
template <typename interval_type>
typename requires_1< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference>::type
@@ -295,11 +303,12 @@
}
- /// distance between two intervals
+ // distance between two intervals
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference>::type
euclidean_distance(const interval_type& interval,
const interval_type_2& b) {
typedef typename coordinate_traits<typename interval_traits<interval_type>::coordinate_type>::coordinate_difference Unit;
@@ -307,23 +316,25 @@
return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
}
- /// check if Interval b intersects `this` Interval
+ // check if Interval b intersects `this` Interval
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- bool>::type
- intersects(const interval_type& interval, const interval_type_2& b,
- bool consider_touch = true) {
- return consider_touch ?
- (low(interval) <= high(b)) & (high(interval) >= low(b)) :
- (low(interval) < high(b)) & (high(interval) > low(b));
- }
-
- /// check if Interval b partially overlaps `this` Interval
- template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+ intersects(const interval_type& interval, const interval_type_2& b,
+ bool consider_touch = true) {
+ return consider_touch ?
+ (low(interval) <= high(b)) & (high(interval) >= low(b)) :
+ (low(interval) < high(b)) & (high(interval) > low(b));
+ }
+
+ // check if Interval b partially overlaps `this` Interval
+ template <typename interval_type, typename interval_type_2>
+ typename requires_1<
+ typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
boundaries_intersect(const interval_type& interval, const interval_type_2& b,
bool consider_touch = true) {
return (contains(interval, low(b), consider_touch) ||
@@ -332,29 +343,30 @@
contains(b, high(interval), consider_touch));
}
- /// check if they are end to end
+ // check if they are end to end
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
bool>::type
abuts(const interval_type& interval, const interval_type_2& b, direction_1d dir) {
return dir.to_int() ? low(b) == high(interval) : low(interval) == high(b);
}
- /// check if they are end to end
+ // check if they are end to end
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
abuts(const interval_type& interval, const interval_type_2& b) {
return abuts(interval, b, HIGH) || abuts(interval, b, LOW);
}
- /// set 'this' interval to the intersection of 'this' and b
+ // set 'this' interval to the intersection of 'this' and b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
bool>::type
intersect(interval_type& interval, const interval_type_2& b, bool consider_touch = true) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
@@ -370,11 +382,12 @@
return valid;
}
- /// set 'this' interval to the generalized intersection of 'this' and b
+ // set 'this' interval to the generalized intersection of 'this' and b
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- interval_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
generalized_intersect(interval_type& interval, const interval_type_2& b) {
typedef typename interval_traits<interval_type>::coordinate_type Unit;
Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
@@ -385,7 +398,7 @@
return interval;
}
- /// bloat the Interval
+ // bloat the Interval
template <typename interval_type>
typename requires_1< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
interval_type>::type &
@@ -395,7 +408,7 @@
return interval;
}
- /// bloat the specified side of `this` Interval
+ // bloat the specified side of `this` Interval
template <typename interval_type>
typename requires_1< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
interval_type>::type &
@@ -405,7 +418,7 @@
}
- /// shrink the Interval
+ // shrink the Interval
template <typename interval_type>
typename requires_1< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
interval_type>::type &
@@ -413,7 +426,7 @@
return bloat(interval, -shrinking);
}
- /// shrink the specified side of `this` Interval
+ // shrink the specified side of `this` Interval
template <typename interval_type>
typename requires_1< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
interval_type>::type &
@@ -421,11 +434,12 @@
return bloat(interval, dir, -shrinking);
}
- /// Enlarge `this` Interval to encompass the specified Interval
+ // Enlarge `this` Interval to encompass the specified Interval
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
encompass(interval_type& interval, const interval_type_2& b) {
bool retval = !contains(interval, b, true);
low(interval, std::min(low(interval), low(b)));
@@ -433,7 +447,7 @@
return retval;
}
- /// Enlarge `this` Interval to encompass the specified Interval
+ // Enlarge `this` Interval to encompass the specified Interval
template <typename interval_type>
typename requires_1< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
bool>::type
@@ -444,7 +458,7 @@
return retval;
}
- /// gets the half of the interval as an interval
+ // gets the half of the interval as an interval
template <typename interval_type>
typename requires_1<typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type, interval_type>::type
get_half(const interval_type& interval, direction_1d d1d) {
@@ -454,12 +468,13 @@
(d1d == LOW) ? c : get(interval, HIGH));
}
- /// returns true if the 2 intervals exactly touch at one value, like in l1 <= h1 == l2 <= h2
- /// sets the argument to the joined interval
+ // returns true if the 2 intervals exactly touch at one value, like in l1 <= h1 == l2 <= h2
+ // sets the argument to the joined interval
template <typename interval_type, typename interval_type_2>
- typename requires_2< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
join_with(interval_type& interval, const interval_type_2& b) {
if(abuts(interval, b)) {
encompass(interval, b);
Modified: sandbox/gtl/gtl/isotropy.hpp
==============================================================================
--- sandbox/gtl/gtl/isotropy.hpp (original)
+++ sandbox/gtl/gtl/isotropy.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -111,8 +111,9 @@
typedef T3 type;
};
- struct gtl_no {};
- struct gtl_yes { typedef void type; };
+ struct gtl_no { static const bool value = false; };
+ struct gtl_yes { typedef gtl_yes type;
+ static const bool value = true; };
template <typename T, typename T2>
struct gtl_and { typedef gtl_no type; };
@@ -125,39 +126,36 @@
struct gtl_or<T, T> { typedef T type; };
template <typename T, typename T2, typename T3>
- struct gtl_and_3 { typedef gtl_no type; };
- template <typename T>
- struct gtl_and_3<T, T, T> { typedef T type; };
-
+ struct gtl_and_3 { typedef typename gtl_and<
+ T, typename gtl_and<T2, T3>::type>::type type; };
template <typename T, typename T2, typename T3>
- struct gtl_or_3 { typedef gtl_yes type; };
- template <typename T>
- struct gtl_or_3<T, T, T> { typedef T type; };
-
- template <typename T, typename T2, typename T3, typename T4>
- struct gtl_and_4 { typedef gtl_no type; };
- template <typename T>
- struct gtl_and_4<T, T, T, T> { typedef T type; };
-
- template <typename T, typename T2, typename T3, typename T4>
- struct gtl_or_4 { typedef gtl_yes type; };
- template <typename T>
- struct gtl_or_4<T, T, T, T> { typedef T type; };
+ struct gtl_or_3 { typedef typename gtl_or<
+ T, typename gtl_or<T2, T3>::type>::type type; };
+ template <typename T, typename T2, typename T3, typename T4>
+ struct gtl_or_4 { typedef typename gtl_or<
+ T, typename gtl_or_3<T2, T3, T4>::type>::type type; };
+
template <typename T>
struct gtl_not { typedef gtl_no type; };
template <>
struct gtl_not<gtl_no> { typedef gtl_yes type; };
template <typename T>
- struct gtl_if { typedef T type; };
+ struct gtl_if {
+#ifdef WIN32
+ typedef gtl_no type;
+#endif
+ };
template <>
- struct gtl_if<gtl_no> {};
+ struct gtl_if<gtl_yes> { typedef gtl_yes type; };
template <typename T, typename T2>
struct gtl_same_type { typedef gtl_no type; };
template <typename T>
struct gtl_same_type<T, T> { typedef gtl_yes type; };
+ template <typename T, typename T2>
+ struct gtl_different_type { typedef typename gtl_not<typename gtl_same_type<T, T2>::type>::type type; };
template <typename T1, typename T2>
struct requires_type { typedef T2 type; };
@@ -172,20 +170,57 @@
template <typename T>
struct is_different_type_SFINAE<T, T> {};
- template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
- struct requires_5 { typedef T6 type; };
+ namespace boost_copy {
+ template <bool B, class T = void>
+ struct enable_if_c {
+ typedef T type;
+ };
+
+ template <class T>
+ struct enable_if_c<false, T> {};
- template <typename T1, typename T2, typename T3, typename T4, typename T5>
- struct requires_4 { typedef T5 type; };
+ template <class Cond, class T = void>
+ struct enable_if : public enable_if_c<Cond::value, T> {};
- template <typename T1, typename T2, typename T3, typename T4>
- struct requires_3 { typedef T4 type; };
+ template <bool B, class T>
+ struct lazy_enable_if_c {
+ typedef typename T::type type;
+ };
- template <typename T1, typename T2, typename T3>
- struct requires_2 { typedef T3 type; };
+ template <class T>
+ struct lazy_enable_if_c<false, T> {};
- template <typename T1, typename T2>
- struct requires_1 { typedef T2 type; };
+ template <class Cond, class T>
+ struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
+
+
+ template <bool B, class T = void>
+ struct disable_if_c {
+ typedef T type;
+ };
+
+ template <class T>
+ struct disable_if_c<true, T> {};
+
+ template <class Cond, class T = void>
+ struct disable_if : public disable_if_c<Cond::value, T> {};
+
+ template <bool B, class T>
+ struct lazy_disable_if_c {
+ typedef typename T::type type;
+ };
+
+ template <class T>
+ struct lazy_disable_if_c<true, T> {};
+
+ template <class Cond, class T>
+ struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
+}
+// template <typename T1, typename T2>
+// struct requires_1 {};
+// template <typename T2>
+// struct requires_1<gtl_yes, T2> { typedef T2 type; };
+#define requires_1 boost_copy::enable_if
struct manhattan_domain {};
struct forty_five_domain {};
@@ -201,9 +236,10 @@
typedef typename coordinate_traits<coordinate_type>::manhattan_area_type type; };
template <typename coordinate_type_1, typename coordinate_type_2>
- typename requires_2< typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- typename coordinate_traits<coordinate_type_1>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_and<typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
+ typename coordinate_traits<coordinate_type_1>::coordinate_difference>::type
euclidean_distance(const coordinate_type_1& lvalue, const coordinate_type_2& rvalue) {
typedef typename coordinate_traits<coordinate_type_1>::coordinate_difference Unit;
return (lvalue < rvalue) ? (Unit)rvalue - (Unit)lvalue : (Unit)lvalue - (Unit)rvalue;
@@ -211,18 +247,18 @@
-/// predicated_swap swaps a and b if pred is true
+// predicated_swap swaps a and b if pred is true
-/// predicated_swap is garenteed to behave the same as
-/// if(pred){
-/// T tmp = a;
-/// a = b;
-/// b = tmp;
-/// }
-/// but will not generate a branch instruction.
-/// predicated_swap always creates a temp copy of a, but does not
-/// create more than one temp copy of an input.
-/// predicated_swap can be used to optimize away branch instructions in C++
+// predicated_swap is garenteed to behave the same as
+// if(pred){
+// T tmp = a;
+// a = b;
+// b = tmp;
+// }
+// but will not generate a branch instruction.
+// predicated_swap always creates a temp copy of a, but does not
+// create more than one temp copy of an input.
+// predicated_swap can be used to optimize away branch instructions in C++
template <class T>
inline bool predicated_swap(const bool& pred,
T& a,
@@ -323,7 +359,7 @@
inline bool operator> (direction_2d d) const { return (val_ > d.val_); }
inline bool operator>=(direction_2d d) const { return (val_ >= d.val_); }
- /// Casting to int
+ // Casting to int
inline unsigned int to_int(void) const { return val_; }
inline direction_2d backward() const {
@@ -331,18 +367,18 @@
return direction_2d(direction_2d_enum(val_ ^ 1));
}
- /// Returns a direction 90 degree left (LOW) or right(HIGH) to this one
+ // Returns a direction 90 degree left (LOW) or right(HIGH) to this one
inline direction_2d turn(direction_1d t) const {
return direction_2d(direction_2d_enum(val_ ^ 3 ^ (val_ >> 1) ^ t.to_int()));
}
- /// Returns a direction 90 degree left to this one
+ // Returns a direction 90 degree left to this one
inline direction_2d left() const {return turn(HIGH);}
- /// Returns a direction 90 degree right to this one
+ // Returns a direction 90 degree right to this one
inline direction_2d right() const {return turn(LOW);}
- /// N, E are positive, S, W are negative
+ // N, E are positive, S, W are negative
inline bool is_positive() const {return (val_ & 1);}
inline bool is_negative() const {return !is_positive();}
inline int get_sign() const {return ((is_positive()) << 1) -1;}
@@ -408,7 +444,7 @@
inline bool operator> (direction_3d d) const { return (val_ > d.val_); }
inline bool operator>=(direction_3d d) const { return (val_ >= d.val_); }
- /// Casting to int
+ // Casting to int
inline unsigned int to_int(void) const { return val_; }
inline direction_3d backward() const {
@@ -416,7 +452,7 @@
return direction_2d(direction_2d_enum(val_ ^ 1));
}
- /// N, E are positive, S, W are negative
+ // N, E are positive, S, W are negative
inline bool is_positive() const {return (val_ & 1);}
inline bool is_negative() const {return !is_positive();}
inline int get_sign() const {return ((is_positive()) << 1) -1;}
Modified: sandbox/gtl/gtl/iterator_geometry_to_set.hpp
==============================================================================
--- sandbox/gtl/gtl/iterator_geometry_to_set.hpp (original)
+++ sandbox/gtl/gtl/iterator_geometry_to_set.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -108,8 +108,8 @@
second_pt = pts[1] = *itrb;
++itrb;
pts[2] = *itrb;
+ evaluate_();
}
- evaluate_();
}
inline iterator_geometry_to_set& operator++() {
Modified: sandbox/gtl/gtl/iterator_points_to_compact.hpp
==============================================================================
--- sandbox/gtl/gtl/iterator_points_to_compact.hpp (original)
+++ sandbox/gtl/gtl/iterator_points_to_compact.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -11,7 +11,7 @@
template <typename iT, typename point_type>
class iterator_points_to_compact {
private:
- iT iter_;
+ iT iter_, iterEnd_;
orientation_2d orient_;
mutable typename point_traits<point_type>::coordinate_type coord_;
public:
@@ -23,14 +23,19 @@
typedef const coordinate_type& reference; //immutable
inline iterator_points_to_compact() {}
- explicit inline iterator_points_to_compact(iT iter) : iter_(iter), orient_(HORIZONTAL) {}
+ explicit inline iterator_points_to_compact(iT iter, iT iterEnd) : iter_(iter), iterEnd_(iterEnd), orient_(HORIZONTAL) {}
inline iterator_points_to_compact(const iterator_points_to_compact& that) :
iter_(that.iter_), orient_(that.orient_) {}
//use bitwise copy and assign provided by the compiler
inline iterator_points_to_compact& operator++() {
- //consider adding assert/excpetion for non-manhattan case
+ //iT tmp = iter_;
++iter_;
+ //iT tmp2 = iter_;
orient_.turn_90();
+ //while(tmp2 != iterEnd_ && get(*tmp2, orient_) == get(*tmp, orient_)) {
+ // iter_ = tmp2;
+ // ++tmp2;
+ //}
return *this;
}
inline const iterator_points_to_compact operator++(int) {
@@ -44,7 +49,9 @@
inline bool operator!=(const iterator_points_to_compact& that) const {
return (iter_ != that.iter_);
}
- inline reference operator*() const { return coord_ = get(*iter_, orient_); }
+ inline reference operator*() const { coord_ = get(*iter_, orient_);
+ return coord_;
+ }
};
}
Modified: sandbox/gtl/gtl/point_3d_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/point_3d_concept.hpp (original)
+++ sandbox/gtl/gtl/point_3d_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -11,19 +11,19 @@
struct point_3d_concept {};
template <typename T>
- struct is_point_3d_concept {};
+ struct is_point_3d_concept { typedef gtl_no type; };
template <>
- struct is_point_3d_concept<point_3d_concept> { typedef void type; };
+ struct is_point_3d_concept<point_3d_concept> { typedef gtl_yes type; };
//template <>
//struct is_point_concept<point_3d_concept> { typedef void type; };
template <typename T>
- struct is_mutable_point_3d_concept {};
+ struct is_mutable_point_3d_concept { typedef gtl_no type; };
template <>
- struct is_mutable_point_3d_concept<point_3d_concept> { typedef void type; };
+ struct is_mutable_point_3d_concept<point_3d_concept> { typedef gtl_yes type; };
template <typename T>
- typename requires_1< typename is_point_3d_concept<typename geometry_concept<T>::type>::type,
+ typename requires_1< typename gtl_if<typename is_point_3d_concept<typename geometry_concept<T>::type>::type>::type,
typename point_3d_traits<T>::coordinate_type >::type
get(const T& point, orientation_3d orient) { return point_3d_traits<T>::get(point, orient); }
@@ -40,9 +40,10 @@
return point_3d_mutable_traits<T>::construct(x_value, y_value, z_value); }
template <typename point_3d_type_1, typename point_3d_type_2>
- typename requires_2< typename is_mutable_point_3d_concept<typename geometry_concept<point_3d_type_1>::type>::type,
- typename is_point_3d_concept<typename geometry_concept<point_3d_type_2>::type>::type,
- point_3d_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_point_3d_concept<typename geometry_concept<point_3d_type_1>::type>::type,
+ typename is_point_3d_concept<typename geometry_concept<point_3d_type_2>::type>::type>::type,
+ point_3d_type_1>::type &
assign(point_3d_type_1& lvalue, const point_3d_type_2& rvalue) {
set(lvalue, HORIZONTAL, get(rvalue, HORIZONTAL));
set(lvalue, VERTICAL, get(rvalue, VERTICAL));
@@ -66,16 +67,17 @@
z(point_type& point, coordinate_type value) { set(point, PROXIMAL, value); }
template <typename T, typename T2>
- typename requires_2< typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<T>::type>::type,
- typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<T2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename gtl_same_type<point_3d_concept, typename geometry_concept<T>::type>::type,
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<T2>::type>::type>::type,
+ bool>::type
equivalence(const T& point1, const T2& point2) {
return x(point1) == x(point2) && y(point1) == y(point2) && z(point1) == z(point2);
}
template <typename point_type_1, typename point_type_2>
- typename requires_2< typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_1>::type>::type,
- typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_1>::type>::type,
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_2>::type>::type>::type,
typename coordinate_traits<typename point_3d_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
manhattan_distance(const point_type_1& point1, const point_type_2& point2) {
return euclidean_distance(point1, point2, HORIZONTAL) + euclidean_distance(point1, point2, VERTICAL)
@@ -83,8 +85,8 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2< typename is_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_3d_concept<typename geometry_concept<point_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_3d_concept<typename geometry_concept<point_type_2>::type>::type>::type,
typename coordinate_traits<typename point_3d_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
euclidean_distance(const point_type_1& point1, const point_type_2& point2, orientation_3d orient) {
typedef typename coordinate_traits<typename point_3d_traits<point_type_1>::coordinate_type>::coordinate_difference return_type;
@@ -94,8 +96,9 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2< typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_1>::type>::type,
- typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_1>::type>::type,
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_2>::type>::type>::type,
typename coordinate_traits<typename point_3d_traits<point_type_1>::coordinate_type>::coordinate_distance>::type
euclidean_distance(const point_type_1& point1, const point_type_2& point2) {
typedef typename coordinate_traits<typename point_3d_traits<point_type_1>::coordinate_type>::coordinate_distance return_value;
@@ -105,8 +108,9 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2< typename is_mutable_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_2>::type>::type>::type,
point_type_1>::type &
convolve(point_type_1& lvalue, const point_type_2& rvalue) {
x(lvalue, x(lvalue) + x(rvalue));
@@ -116,9 +120,10 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2< typename is_mutable_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_same_type_SFINAE<point_3d_concept, typename geometry_concept<point_type_2>::type>::type,
- point_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_point_3d_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename gtl_same_type<point_3d_concept, typename geometry_concept<point_type_2>::type>::type>::type,
+ point_type_1>::type &
deconvolve(point_type_1& lvalue, const point_type_2& rvalue) {
x(lvalue, x(lvalue) - x(rvalue));
y(lvalue, y(lvalue) - y(rvalue));
Modified: sandbox/gtl/gtl/point_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/point_concept.hpp (original)
+++ sandbox/gtl/gtl/point_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -15,22 +15,22 @@
struct point_concept {};
template <typename T>
- struct is_point_concept {};
+ struct is_point_concept { typedef gtl_no type; };
template <>
- struct is_point_concept<point_concept> { typedef void type; };
+ struct is_point_concept<point_concept> { typedef gtl_yes type; };
struct point_3d_concept;
template <>
- struct is_point_concept<point_3d_concept> { typedef void type; };
+ struct is_point_concept<point_3d_concept> { typedef gtl_yes type; };
template <typename T>
- struct is_mutable_point_concept {};
+ struct is_mutable_point_concept { typedef gtl_no type; };
template <>
- struct is_mutable_point_concept<point_concept> { typedef void type; };
+ struct is_mutable_point_concept<point_concept> { typedef gtl_yes type; };
template <typename T>
- typename requires_1< typename is_point_concept<typename geometry_concept<T>::type>::type,
+ typename requires_1< typename gtl_if<typename is_point_concept<typename geometry_concept<T>::type>::type>::type,
typename point_traits<T>::coordinate_type >::type
get(const T& point, orientation_2d orient) {
return point_traits<T>::get(point, orient);
@@ -50,10 +50,9 @@
}
template <typename T1, typename T2>
- typename requires_2<
- typename is_mutable_point_concept<typename geometry_concept<T1>::type>::type,
- typename is_point_concept<typename geometry_concept<T2>::type>::type,
- T1>::type &
+ typename requires_1< typename gtl_and< typename is_mutable_point_concept<typename geometry_concept<T1>::type>::type,
+ typename is_point_concept<typename geometry_concept<T2>::type>::type>::type,
+ T1>::type &
assign(T1& lvalue, const T2& rvalue) {
set(lvalue, HORIZONTAL, get(rvalue, HORIZONTAL));
set(lvalue, VERTICAL, get(rvalue, VERTICAL));
@@ -89,9 +88,9 @@
}
template <typename T, typename T2>
- typename requires_2<typename is_same_type_SFINAE<point_concept, typename geometry_concept<T>::type>::type,
- typename is_point_concept<typename geometry_concept<T2>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and<typename gtl_same_type<point_concept, typename geometry_concept<T>::type>::type,
+ typename is_point_concept<typename geometry_concept<T2>::type>::type>::type,
+ bool>::type
equivalence(const T& point1, const T2& point2) {
typename point_traits<T>::coordinate_type x1 = x(point1);
typename point_traits<T2>::coordinate_type x2 = get(point2, HORIZONTAL);
@@ -101,17 +100,17 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_same_type_SFINAE<point_concept, typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type,
- typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
+ typename requires_1< typename gtl_and<typename gtl_same_type<point_concept, typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type,
+ typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
manhattan_distance(const point_type_1& point1, const point_type_2& point2) {
return euclidean_distance(point1, point2, HORIZONTAL) + euclidean_distance(point1, point2, VERTICAL);
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type,
- typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
+ typename requires_1< typename gtl_and<typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type,
+ typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
euclidean_distance(const point_type_1& point1, const point_type_2& point2, orientation_2d orient) {
typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference return_value =
get(point1, orient) - get(point2, orient);
@@ -119,18 +118,18 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_same_type_SFINAE<point_concept, typename geometry_concept<point_type_1>::type>::type,
- typename is_same_type_SFINAE<point_concept, typename geometry_concept<point_type_2>::type>::type,
- typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_distance>::type
+ typename requires_1< typename gtl_and<typename gtl_same_type<point_concept, typename geometry_concept<point_type_1>::type>::type,
+ typename gtl_same_type<point_concept, typename geometry_concept<point_type_2>::type>::type>::type,
+ typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_distance>::type
euclidean_distance(const point_type_1& point1, const point_type_2& point2) {
typedef typename point_traits<point_type_1>::coordinate_type Unit;
return sqrt((typename coordinate_traits<Unit>::coordinate_distance)(distance_squared(point1, point2)));
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type,
- typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
+ typename requires_1< typename gtl_and<typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type,
+ typename coordinate_traits<typename point_traits<point_type_1>::coordinate_type>::coordinate_difference>::type
distance_squared(const point_type_1& point1, const point_type_2& point2) {
typedef typename point_traits<point_type_1>::coordinate_type Unit;
typename coordinate_traits<Unit>::coordinate_difference dx = euclidean_distance(point1, point2, HORIZONTAL);
@@ -141,8 +140,8 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_mutable_point_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type, point_type_1>::type &
+ typename requires_1< typename gtl_and<typename is_mutable_point_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type, point_type_1>::type &
convolve(point_type_1& lvalue, const point_type_2& rvalue) {
x(lvalue, x(lvalue) + x(rvalue));
y(lvalue, y(lvalue) + y(rvalue));
@@ -150,8 +149,8 @@
}
template <typename point_type_1, typename point_type_2>
- typename requires_2<typename is_mutable_point_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type, point_type_1>::type &
+ typename requires_1< typename gtl_and<typename is_mutable_point_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type, point_type_1>::type &
deconvolve(point_type_1& lvalue, const point_type_2& rvalue) {
x(lvalue, x(lvalue) - x(rvalue));
y(lvalue, y(lvalue) - y(rvalue));
Modified: sandbox/gtl/gtl/polygon_45_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -30,10 +30,10 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline polygon_45_data(const polygon_45_data& that) : coords_(that.coords_) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline polygon_45_data& operator=(const polygon_45_data& that) {
coords_ = that.coords_;
return *this;
@@ -52,10 +52,10 @@
inline bool operator!=(const polygon_45_data& that) const { return !((*this) == that); }
- /// get begin iterator, returns a pointer to a const Unit
+ // get begin iterator, returns a pointer to a const Unit
inline iterator_type begin() const { return coords_.begin(); }
- /// get end iterator, returns a pointer to a const Unit
+ // get end iterator, returns a pointer to a const Unit
inline iterator_type end() const { return coords_.end(); }
inline std::size_t size() const { return coords_.size(); }
Modified: sandbox/gtl/gtl/polygon_45_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_formation.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_formation.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -20,25 +20,26 @@
//polygon45formation algorithm
template <typename Unit>
struct polygon_45_formation : public boolean_op_45<Unit> {
- typedef point_data<int> Point;
- typedef polygon_45_data<int> Polygon45;
- typedef polygon_45_with_holes_data<int> Polygon45WithHoles;
+ typedef point_data<Unit> Point;
+ typedef polygon_45_data<Unit> Polygon45;
+ typedef polygon_45_with_holes_data<Unit> Polygon45WithHoles;
typedef typename boolean_op_45<Unit>::Vertex45 Vertex45;
typedef typename boolean_op_45<Unit>::lessVertex45 lessVertex45;
+ typedef typename boolean_op_45<Unit>::Count2 Count2;
typedef typename boolean_op_45<Unit>::Scan45Count Scan45Count;
typedef std::pair<Point, Scan45Count> Scan45Vertex;
- typedef typename boolean_op_45<Unit>::Count2 Count2;
- typedef typename boolean_op_45<Unit>::Scan45 Scan45;
+ typedef typename boolean_op_45<Unit>::template
+ Scan45<Count2, typename boolean_op_45<Unit>::template boolean_op_45_output_functor<0> > Scan45;
class PolyLine45 {
public:
- typedef std::list<Point>::const_iterator iterator;
+ typedef typename std::list<Point>::const_iterator iterator;
- /// default constructor of point does not initialize x and y
+ // default constructor of point does not initialize x and y
inline PolyLine45(){;} //do nothing default constructor
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline PolyLine45& set(iT inputBegin, iT inputEnd) {
points.clear(); //just in case there was some old data there
@@ -49,19 +50,19 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline PolyLine45(const PolyLine45& that) : points(that.points) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline PolyLine45& operator=(const PolyLine45& that) {
points = that.points;
return *this;
}
- /// get begin iterator, returns a pointer to a const Unit
+ // get begin iterator, returns a pointer to a const Unit
inline iterator begin() const { return points.begin(); }
- /// get end iterator, returns a pointer to a const Unit
+ // get end iterator, returns a pointer to a const Unit
inline iterator end() const { return points.end(); }
inline std::size_t size() const { return points.size(); }
@@ -363,8 +364,8 @@
static inline std::pair<ActiveTail45*, ActiveTail45*> createActiveTail45sAsPair(Point point, bool solid,
ActiveTail45* phole, bool fractureHoles) {
- ActiveTail45* at1;
- ActiveTail45* at2;
+ ActiveTail45* at1 = 0;
+ ActiveTail45* at2 = 0;
if(phole && fractureHoles) {
//std::cout << "adding hole\n";
at1 = phole;
@@ -385,115 +386,122 @@
};
-
-
- class Vertex45Count {
+ template <typename ct>
+ class Vertex45CountT {
public:
- inline Vertex45Count() { counts[0] = counts[1] = counts[2] = counts[3] = 0; }
- inline Vertex45Count(int count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
- inline Vertex45Count(const int& count1, const int& count2, const int& count3,
- const int& count4) {
+ typedef ct count_type;
+ inline Vertex45CountT() { counts[0] = counts[1] = counts[2] = counts[3] = 0; }
+ //inline Vertex45CountT(ct count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
+ inline Vertex45CountT(const ct& count1, const ct& count2, const ct& count3,
+ const ct& count4) {
counts[0] = count1;
counts[1] = count2;
counts[2] = count3;
counts[3] = count4;
}
- inline Vertex45Count(const Vertex45& vertex) {
+ inline Vertex45CountT(const Vertex45& vertex) {
counts[0] = counts[1] = counts[2] = counts[3] = 0;
(*this) += vertex;
}
- inline Vertex45Count(const Vertex45Count& count) {
+ inline Vertex45CountT(const Vertex45CountT& count) {
(*this) = count;
}
- inline bool operator==(const Vertex45Count& count) const {
+ inline bool operator==(const Vertex45CountT& count) const {
for(unsigned int i = 0; i < 4; ++i) {
if(counts[i] != count.counts[i]) return false;
}
return true;
}
- inline bool operator!=(const Vertex45Count& count) const { return !((*this) == count); }
- inline Vertex45Count& operator=(int count) {
+ inline bool operator!=(const Vertex45CountT& count) const { return !((*this) == count); }
+ inline Vertex45CountT& operator=(ct count) {
counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
- inline Vertex45Count& operator=(const Vertex45Count& count) {
+ inline Vertex45CountT& operator=(const Vertex45CountT& count) {
for(unsigned int i = 0; i < 4; ++i) {
counts[i] = count.counts[i];
}
return *this;
}
- inline int& operator[](int index) { return counts[index]; }
- inline int operator[](int index) const {return counts[index]; }
- inline Vertex45Count& operator+=(const Vertex45Count& count){
+ inline ct& operator[](int index) { return counts[index]; }
+ inline ct operator[](int index) const {return counts[index]; }
+ inline Vertex45CountT& operator+=(const Vertex45CountT& count){
for(unsigned int i = 0; i < 4; ++i) {
counts[i] += count.counts[i];
}
return *this;
}
- inline Vertex45Count& operator-=(const Vertex45Count& count){
+ inline Vertex45CountT& operator-=(const Vertex45CountT& count){
for(unsigned int i = 0; i < 4; ++i) {
counts[i] -= count.counts[i];
}
return *this;
}
- inline Vertex45Count operator+(const Vertex45Count& count) const {
- return Vertex45Count(*this)+=count;
+ inline Vertex45CountT operator+(const Vertex45CountT& count) const {
+ return Vertex45CountT(*this)+=count;
}
- inline Vertex45Count operator-(const Vertex45Count& count) const {
- return Vertex45Count(*this)-=count;
+ inline Vertex45CountT operator-(const Vertex45CountT& count) const {
+ return Vertex45CountT(*this)-=count;
}
- inline Vertex45Count invert() const {
- return Vertex45Count(0)-=(*this);
+ inline Vertex45CountT invert() const {
+ return Vertex45CountT()-=(*this);
}
- inline Vertex45Count& operator+=(const Vertex45& element){
+ inline Vertex45CountT& operator+=(const Vertex45& element){
counts[element.rise+1] += element.count; return *this;
}
inline bool is_45() const {
return counts[0] != 0 || counts[2] != 0;
}
private:
- int counts[4];
+ ct counts[4];
};
+ typedef Vertex45CountT<int> Vertex45Count;
+
// inline std::ostream& operator<< (std::ostream& o, const Vertex45Count& c) {
// o << c[0] << ", " << c[1] << ", ";
// o << c[2] << ", " << c[3];
// return o;
// }
- class Vertex45Compact {
+ template <typename ct>
+ class Vertex45CompactT {
public:
Point pt;
- Vertex45Count count;
- inline Vertex45Compact() {}
- inline Vertex45Compact(const Point& point, int riseIn, int countIn) : pt(point) {
+ ct count;
+ typedef typename boolean_op_45<Unit>::template Vertex45T<typename ct::count_type> Vertex45T;
+ inline Vertex45CompactT() {}
+ inline Vertex45CompactT(const Point& point, int riseIn, int countIn) : pt(point) {
count[riseIn+1] = countIn;
}
- inline Vertex45Compact(const Vertex45& vertex) : pt(vertex.pt) {
+ inline Vertex45CompactT(const Vertex45T& vertex) : pt(vertex.pt) {
count[vertex.rise+1] = vertex.count;
}
- inline Vertex45Compact(const Vertex45Compact& vertex) : pt(vertex.pt), count(vertex.count) {}
- inline Vertex45Compact& operator=(const Vertex45Compact& vertex){
+ inline Vertex45CompactT(const Vertex45CompactT& vertex) : pt(vertex.pt), count(vertex.count) {}
+ inline Vertex45CompactT& operator=(const Vertex45CompactT& vertex){
pt = vertex.pt; count = vertex.count; return *this; }
- inline Vertex45Compact(const std::pair<Point, Point>& vertex) {}
- inline Vertex45Compact& operator=(const std::pair<Point, Point>& vertex){ return *this; }
- inline bool operator==(const Vertex45Compact& vertex) const {
+ inline Vertex45CompactT(const std::pair<Point, Point>& vertex) {}
+ inline Vertex45CompactT& operator=(const std::pair<Point, Point>& vertex){ return *this; }
+ inline bool operator==(const Vertex45CompactT& vertex) const {
return pt == vertex.pt && count == vertex.count; }
- inline bool operator!=(const Vertex45Compact& vertex) const { return !((*this) == vertex); }
+ inline bool operator!=(const Vertex45CompactT& vertex) const { return !((*this) == vertex); }
inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
- inline bool operator<(const Vertex45Compact& vertex) const {
+ inline bool operator<(const Vertex45CompactT& vertex) const {
if(pt.x() < vertex.pt.x()) return true;
if(pt.x() == vertex.pt.x()) {
return pt.y() < vertex.pt.y();
}
return false;
}
- inline bool operator>(const Vertex45Compact& vertex) const { return vertex < (*this); }
- inline bool operator<=(const Vertex45Compact& vertex) const { return !((*this) > vertex); }
- inline bool operator>=(const Vertex45Compact& vertex) const { return !((*this) < vertex); }
+ inline bool operator>(const Vertex45CompactT& vertex) const { return vertex < (*this); }
+ inline bool operator<=(const Vertex45CompactT& vertex) const { return !((*this) > vertex); }
+ inline bool operator>=(const Vertex45CompactT& vertex) const { return !((*this) < vertex); }
inline bool haveVertex45(int index) const { return count[index]; }
- inline Vertex45 operator[](int index) const { return Vertex45(pt, index-1, count[index]); }
+ inline Vertex45T operator[](int index) const {
+ return Vertex45T(pt, index-1, count[index]); }
};
+ typedef Vertex45CompactT<Vertex45Count> Vertex45Compact;
+
// inline std::ostream& operator<< (std::ostream& o, const Vertex45Compact& c) {
// o << c.pt << ", " << c.count;
// return o;
@@ -996,7 +1004,7 @@
std::cout << "testing polygon formation\n";
Polygon45Formation pf(true);
std::vector<Polygon45> polys;
- Scan45 scan45(0);
+ Scan45 scan45;
std::vector<Vertex45 > result;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
@@ -1865,7 +1873,7 @@
Polygon45Tiling pf;
std::vector<Polygon45> polys;
- Scan45 scan45(0);
+ Scan45 scan45;
std::vector<Vertex45 > result;
std::vector<Scan45Vertex> vertices;
//is a Rectnagle(0, 0, 10, 10);
@@ -2089,7 +2097,7 @@
typedef Unit coordinate_type;
typedef point_data<Unit> Point;
typedef Point point_type;
- typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
+ // typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
typedef iterator iterator_type;
typedef typename coordinate_traits<Unit>::area_type area_type;
@@ -2118,7 +2126,7 @@
typedef Unit coordinate_type;
typedef point_data<Unit> Point;
typedef Point point_type;
- typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
+ // typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
typedef iterator iterator_type;
typedef holeType hole_type;
typedef typename coordinate_traits<Unit>::area_type area_type;
@@ -2173,8 +2181,8 @@
return *this;
}
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline PolyLine45PolygonData& set_holes(iT inputBegin, iT inputEnd) {
return *this;
Modified: sandbox/gtl/gtl/polygon_45_set_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_set_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_set_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -42,18 +42,11 @@
//assign
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type_1>::type>::type,
+ typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type>::type,
polygon_set_type_1>::type &
assign(polygon_set_type_1& lvalue, const polygon_set_type_2& rvalue) {
- if(clean(rvalue))
- polygon_45_set_mutable_traits<polygon_set_type_1>::set(lvalue, begin_45_set_data(rvalue), end_45_set_data(rvalue));
- else {
- polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type_2>::coordinate_type> ps;
- ps.insert(begin_45_set_data(rvalue), end_45_set_data(rvalue));
- ps.clean();
- polygon_45_set_mutable_traits<polygon_set_type_1>::set(lvalue, ps.begin(), ps.end());
- }
+ polygon_45_set_mutable_traits<polygon_set_type_1>::set(lvalue, begin_45_set_data(rvalue), end_45_set_data(rvalue));
return lvalue;
}
@@ -68,11 +61,23 @@
ps.get_trapezoids(output);
}
+ //get trapezoids
+ template <typename output_container_type, typename polygon_set_type>
+ typename requires_1< typename gtl_if<typename is_polygon_45_set_type<polygon_set_type>::type>::type,
+ void>::type
+ get_trapezoids(output_container_type& output, const polygon_set_type& polygon_set, orientation_2d slicing_orientation) {
+ clean(polygon_set);
+ polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
+ assign(ps, polygon_set);
+ ps.get_trapezoids(output, slicing_orientation);
+ }
+
//equivalence
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<polygon_set_type_1, polygon_set_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3<typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_1>::type>::type,
+ typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type,
+ typename gtl_if<typename is_either_polygon_45_set_type<polygon_set_type_1,
+ polygon_set_type_2>::type>::type>::type,
bool>::type
equivalence(const polygon_set_type_1& lvalue,
const polygon_set_type_2& rvalue) {
@@ -106,9 +111,10 @@
//extents
template <typename polygon_set_type, typename rectangle_type>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
- typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
+ bool>::type
extents(rectangle_type& extents_rectangle,
const polygon_set_type& polygon_set) {
clean(polygon_set);
@@ -119,7 +125,7 @@
//area
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::area_type>::type
area(const polygon_set_type& polygon_set) {
typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
@@ -134,6 +140,32 @@
return retval;
}
+ //interact
+ template <typename polygon_set_type_1, typename polygon_set_type_2>
+ typename requires_1 <
+ typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type_1>::type>::type,
+ typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type >::type,
+ polygon_set_type_1>::type
+ interact(polygon_set_type_1& polygon_set_1, const polygon_set_type_2& polygon_set_2) {
+ typedef typename polygon_45_set_traits<polygon_set_type_1>::coordinate_type Unit;
+ std::vector<polygon_45_data<Unit> > polys;
+ assign(polys, polygon_set_1);
+ std::vector<std::set<int> > graph(polys.size()+1, std::set<int>());
+ connectivity_extraction_45<Unit> ce;
+ ce.insert(polygon_set_2);
+ for(unsigned int i = 0; i < polys.size(); ++i){
+ ce.insert(polys[i]);
+ }
+ ce.extract(graph);
+ clear(polygon_set_1);
+ polygon_45_set_data<Unit> ps;
+ for(std::set<int>::iterator itr = graph[0].begin(); itr != graph[0].end(); ++itr){
+ ps.insert(polys[(*itr)-1]);
+ }
+ assign(polygon_set_1, ps);
+ return polygon_set_1;
+ }
+
// //self_intersect
// template <typename polygon_set_type>
// typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
@@ -144,7 +176,7 @@
// }
template <typename polygon_set_type, typename coord_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
resize(polygon_set_type& polygon_set, coord_type resizing,
RoundingOption rounding = CLOSEST, CornerOption corner = INTERSECTION) {
@@ -158,7 +190,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
@@ -166,37 +198,37 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type shrinking) {
return resize(polygon_set, -(typename polygon_45_set_traits<polygon_set_type>::coordinate_type)shrinking);
}
-// template <typename polygon_set_type>
-// typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
-// polygon_set_type>::type &
-// grow_and(polygon_set_type& polygon_set,
-// typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
-// typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
-// std::vector<polygon_45_data<Unit> > polys;
-// assign(polys, polygon_set);
-// clear(polygon_set);
-// polygon_45_set_data<Unit> ps;
-// for(unsigned int i = 0; i < polys.size(); ++i) {
-// polygon_45_set_data<Unit> tmpPs;
-// tmpPs.insert(polys[i]);
-// bloat(tmpPs, bloating);
-// tmpPs.clean(); //apply implicit OR on tmp polygon set
-// ps.insert(tmpPs);
-// }
-// self_intersect(ps);
-// assign(polygon_set, ps);
-// return polygon_set;
-// }
+ template <typename polygon_set_type>
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ grow_and(polygon_set_type& polygon_set,
+ typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
+ typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
+ std::vector<polygon_45_data<Unit> > polys;
+ assign(polys, polygon_set);
+ clear(polygon_set);
+ polygon_45_set_data<Unit> ps;
+ for(unsigned int i = 0; i < polys.size(); ++i) {
+ polygon_45_set_data<Unit> tmpPs;
+ tmpPs.insert(polys[i]);
+ bloat(tmpPs, bloating);
+ tmpPs.clean(); //apply implicit OR on tmp polygon set
+ ps.insert(tmpPs);
+ }
+ ps.self_intersect();
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_up(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
@@ -210,7 +242,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_down(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
@@ -223,9 +255,48 @@
return polygon_set;
}
+ template <typename polygon_set_type>
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ scale(polygon_set_type& polygon_set, double factor) {
+ typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
+ clean(polygon_set);
+ polygon_45_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.scale(factor);
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
+ //self_intersect
+ template <typename polygon_set_type>
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ self_intersect(polygon_set_type& polygon_set) {
+ typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_45_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.self_intersect();
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
+ //self_xor
+ template <typename polygon_set_type>
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ self_xor(polygon_set_type& polygon_set) {
+ typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_45_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.self_xor();
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
//transform
template <typename polygon_set_type, typename transformation_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
transform(polygon_set_type& polygon_set,
const transformation_type& transformation) {
@@ -240,7 +311,7 @@
//keep
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
polygon_set_type>::type &
keep(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::area_type min_area,
Modified: sandbox/gtl/gtl/polygon_45_set_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_set_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_set_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -9,11 +9,11 @@
#define GTL_POLYGON_45_SET_DATA_HPP
namespace gtl {
- enum RoundingOption { CLOSEST = 0, OVERSIZE = 1, UNDERSIZE = 2, SQRT2 = 3 };
- enum CornerOption { INTERSECTION = 0, ORTHOGINAL = 1 };
+ enum RoundingOption { CLOSEST = 0, OVERSIZE = 1, UNDERSIZE = 2, SQRT2 = 3, SQRT1OVER2 = 4 };
+ enum CornerOption { INTERSECTION = 0, ORTHOGONAL = 1, UNFILLED = 2 };
template <typename ltype, typename rtype, int op_type>
- class polygon_45_set_view;
+ struct polygon_45_set_view;
struct polygon_45_set_concept {};
@@ -28,25 +28,31 @@
typedef typename value_type::const_iterator iterator_type;
typedef polygon_45_set_data operator_arg_type;
- /// default constructor
+ // default constructor
inline polygon_45_set_data() : dirty_(false), unsorted_(false), is_manhattan_(true) {}
- /// constructor from a geometry object
+ // constructor from a geometry object
template <typename geometry_type>
inline polygon_45_set_data(const geometry_type& that) : dirty_(false), unsorted_(false), is_manhattan_(true) {
insert(that);
}
- /// copy constructor
+ // copy constructor
inline polygon_45_set_data(const polygon_45_set_data& that) :
data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_), is_manhattan_(that.is_manhattan_) {}
- /// destructor
+ template <typename ltype, typename rtype, int op_type>
+ inline polygon_45_set_data(const polygon_45_set_view<ltype, rtype, op_type>& that) {
+ (*this) = that.value();
+ }
+
+ // destructor
inline ~polygon_45_set_data() {}
- /// assignement operator
+ // assignement operator
inline polygon_45_set_data& operator=(const polygon_45_set_data& that) {
if(this == &that) return *this;
+ error_data_ = that.error_data_;
data_ = that.data_;
dirty_ = that.dirty_;
unsorted_ = that.unsorted_;
@@ -56,9 +62,7 @@
template <typename ltype, typename rtype, int op_type>
inline polygon_45_set_data& operator=(const polygon_45_set_view<ltype, rtype, op_type>& that) {
- set(that.begin(), that.end());
- dirty_ = that.dirty();
- unsorted_ = !that.sorted();
+ (*this) = that.value();
return *this;
}
@@ -69,7 +73,7 @@
return *this;
}
- /// insert iterator range
+ // insert iterator range
template <typename iT>
inline void insert(iT input_begin, iT input_end, bool is_hole = false) {
if(input_begin == input_end) return;
@@ -124,24 +128,30 @@
get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type());
}
- /// equivalence operator
+ inline void has_error_data() const { return !error_data_.empty(); }
+ inline unsigned int error_count() const { return error_data_.size() / 4; }
+ inline void get_error_data(polygon_45_set_data& p) const {
+ p.data_.insert(p.data_.end(), error_data_.begin(), error_data_.end());
+ }
+
+ // equivalence operator
inline bool operator==(const polygon_45_set_data& p) const {
clean();
p.clean();
return data_ == p.data_;
}
- /// inequivalence operator
+ // inequivalence operator
inline bool operator!=(const polygon_45_set_data& p) const {
return !((*this) == p);
}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
inline iterator_type begin() const {
return data_.begin();
}
- /// get iterator to end vertex data
+ // get iterator to end vertex data
inline iterator_type end() const {
return data_.end();
}
@@ -150,19 +160,19 @@
return data_;
}
- /// clear the contents of the polygon_45_set_data
- inline void clear() { data_.clear(); dirty_ = unsorted_ = false; is_manhattan_ = true; }
+ // clear the contents of the polygon_45_set_data
+ inline void clear() { data_.clear(); error_data_.clear(); dirty_ = unsorted_ = false; is_manhattan_ = true; }
- /// find out if Polygon set is empty
+ // find out if Polygon set is empty
inline bool empty() const { return data_.empty(); }
- /// find out if Polygon set is sorted
+ // find out if Polygon set is sorted
inline bool sorted() const { return !unsorted_; }
- /// find out if Polygon set is clean
+ // find out if Polygon set is clean
inline bool dirty() const { return dirty_; }
- /// find out if Polygon set is clean
+ // find out if Polygon set is clean
inline bool is_manhattan() const { return is_manhattan_; }
bool clean() const;
@@ -194,35 +204,59 @@
unsorted_ = true;
}
- /// append to the container cT with polygons (holes will be fractured vertically)
+ // append to the container cT with polygons (holes will be fractured vertically)
template <class cT>
void get_polygons(cT& container) const {
get_dispatch(container, polygon_45_concept());
}
- /// append to the container cT with PolygonWithHoles objects
+ // append to the container cT with PolygonWithHoles objects
template <class cT>
void get_polygons_with_holes(cT& container) const {
get_dispatch(container, polygon_45_with_holes_concept());
}
- /// append to the container cT with polygons of three or four verticies
+ // append to the container cT with polygons of three or four verticies
+ // slicing orientation is vertical
+ template <class cT>
+ void get_trapezoids(cT& container) const {
+ clean();
+ typename polygon_45_formation<Unit>::Polygon45Tiling pf;
+ //std::cout << "FORMING POLYGONS\n";
+ pf.scan(container, data_.begin(), data_.end());
+ //std::cout << "DONE FORMING POLYGONS\n";
+ }
+
+ // append to the container cT with polygons of three or four verticies
template <class cT>
- void get_trapezoids(cT& container) const;
+ void get_trapezoids(cT& container, orientation_2d slicing_orientation) const {
+ if(slicing_orientation == VERTICAL) {
+ get_trapezoids(container);
+ } else {
+ polygon_45_set_data<Unit> ps(*this);
+ ps.transform(axis_transformation(axis_transformation::SWAP_XY));
+ cT result;
+ ps.get_trapezoids(result);
+ for(typename cT::iterator itr = result.begin(); itr != result.end(); ++itr) {
+ ::gtl::transform(*itr, axis_transformation(axis_transformation::SWAP_XY));
+ }
+ container.insert(container.end(), result.begin(), result.end());
+ }
+ }
- /// insert vertex sequence
+ // insert vertex sequence
template <class iT>
void insert_vertex_sequence(iT begin_vertex, iT end_vertex,
direction_1d winding, bool is_hole = false);
- /// get the external boundary rectangle
+ // get the external boundary rectangle
template <typename rectangle_type>
bool extents(rectangle_type& rect) const;
- /// snap verticies of set to even,even or odd,odd coordinates
+ // snap verticies of set to even,even or odd,odd coordinates
void snap() const;
- /// |= &= += *= -= ^= binary operators
+ // |= &= += *= -= ^= binary operators
polygon_45_set_data& operator|=(const polygon_45_set_data& b);
polygon_45_set_data& operator&=(const polygon_45_set_data& b);
polygon_45_set_data& operator+=(const polygon_45_set_data& b);
@@ -230,23 +264,40 @@
polygon_45_set_data& operator-=(const polygon_45_set_data& b);
polygon_45_set_data& operator^=(const polygon_45_set_data& b);
- /// resizing operations
+ // resizing operations
polygon_45_set_data& operator+=(Unit delta);
polygon_45_set_data& operator-=(Unit delta);
- /// shrink the Polygon45Set by shrinking
+ // shrink the Polygon45Set by shrinking
polygon_45_set_data& resize(coordinate_type resizing, RoundingOption rounding = CLOSEST,
CornerOption corner = INTERSECTION);
- /// transform set
+ // transform set
template <typename transformation_type>
polygon_45_set_data& transform(const transformation_type& tr);
- /// scale set
+ // scale set
polygon_45_set_data& scale_up(typename coordinate_traits<Unit>::unsigned_area_type factor);
polygon_45_set_data& scale_down(typename coordinate_traits<Unit>::unsigned_area_type factor);
+ polygon_45_set_data& scale(double scaling);
+
+ // self_intersect
+ polygon_45_set_data& self_intersect() {
+ sort();
+ applyAdaptiveUnary_<1>(); //1 = AND
+ dirty_ = false;
+ return *this;
+ }
+
+ // self_xor
+ polygon_45_set_data& self_xor() {
+ sort();
+ applyAdaptiveUnary_<3>(); //3 = XOR
+ dirty_ = false;
+ return *this;
+ }
- /// accumulate the bloated polygon
+ // accumulate the bloated polygon
template <typename geometry_type>
polygon_45_set_data& insert_with_resize(const geometry_type& poly,
coordinate_type resizing, RoundingOption rounding = CLOSEST,
@@ -256,6 +307,7 @@
}
private:
+ mutable value_type error_data_;
mutable value_type data_;
mutable bool dirty_;
mutable bool unsorted_;
@@ -292,11 +344,7 @@
insert(geometry_object.begin(), geometry_object.end(), is_hole);
}
template <typename geometry_type>
- void insert_dispatch(const geometry_type& geometry_object, bool is_hole, rectangle_concept tag) {
- polygon_45_data<Unit> poly;
- assign(poly, geometry_object);
- insert_dispatch(poly, is_hole, polygon_45_concept());
- }
+ void insert_dispatch(const geometry_type& geometry_object, bool is_hole, rectangle_concept tag);
template <typename geometry_type>
void insert_dispatch(const geometry_type& geometry_object, bool is_hole, polygon_90_concept tag) {
insert_vertex_sequence(begin_points(geometry_object), end_points(geometry_object), winding(geometry_object), is_hole);
@@ -344,7 +392,7 @@
coordinate_type resizing, RoundingOption rounding,
CornerOption corner, bool hole, polygon_45_concept tag);
- /// accumulate the bloated polygon with holes
+ // accumulate the bloated polygon with holes
template <typename geometry_type>
polygon_45_set_data& insert_with_resize_dispatch(const geometry_type& poly,
coordinate_type resizing, RoundingOption rounding,
@@ -353,12 +401,12 @@
static void snap_vertex_45(Vertex45Compact& vertex);
public:
- void applyAdaptiveBoolean_(int op, const polygon_45_set_data& rvalue) const;
- void applyAdaptiveBoolean_(polygon_45_set_data& result, int op, const polygon_45_set_data& rvalue) const;
- //void applyBoolean_(int op, value_type& rvalue) const;
- //void applyBoolean_(value_type& result, int op,
- // value_type& rvalue) const;
- //void applyBooleanException_(value_type& result, int op, value_type& rvalue) const;
+ template <int op>
+ void applyAdaptiveBoolean_(const polygon_45_set_data& rvalue) const;
+ template <int op>
+ void applyAdaptiveBoolean_(polygon_45_set_data& result, const polygon_45_set_data& rvalue) const;
+ template <int op>
+ void applyAdaptiveUnary_() const;
};
template <typename T>
@@ -366,15 +414,17 @@
typedef polygon_45_set_concept type;
};
-
- template <typename Unit>
- template <class cT>
- inline void polygon_45_set_data<Unit>::get_trapezoids(cT& container) const {
- clean();
- typename polygon_45_formation<Unit>::Polygon45Tiling pf;
- //std::cout << "FORMING POLYGONS\n";
- pf.scan(container, data_.begin(), data_.end());
- //std::cout << "DONE FORMING POLYGONS\n";
+ template <typename iT>
+ void scale_up_vertex_45_compact_range(iT beginr, iT endr, unsigned int factor) {
+ for( ; beginr != endr; ++beginr) {
+ scale_up((*beginr).pt, factor);
+ }
+ }
+ template <typename iT>
+ void scale_down_vertex_45_compact_range_blindly(iT beginr, iT endr, unsigned int factor) {
+ for( ; beginr != endr; ++beginr) {
+ scale_down((*beginr).pt, factor);
+ }
}
template <typename Unit>
@@ -405,12 +455,13 @@
return retval;
}
- template <typename Unit>
- inline void polygon_45_set_data<Unit>::insert_vertex_half_edge_45_pair(const point_data<Unit>& pt1, point_data<Unit>& pt2,
- const point_data<Unit>& pt3,
- direction_1d wdir) {
+ template <typename cT, typename pT>
+ bool insert_vertex_half_edge_45_pair_into_vector(cT& output,
+ const pT& pt1, pT& pt2,
+ const pT& pt3,
+ direction_1d wdir) {
int multiplier = wdir == LOW ? -1 : 1;
- Vertex45Compact vertex(pt2, 0, 0);
+ typename cT::value_type vertex(pt2, 0, 0);
//std::cout << pt1 << " " << pt2 << " " << pt3 << std::endl;
std::pair<int, int> check;
check = characterizeEdge45(pt1, pt2);
@@ -419,8 +470,15 @@
check = characterizeEdge45(pt2, pt3);
//std::cout << "index " << check.first << " " << check.second * multiplier << std::endl;
vertex.count[check.first] += check.second * multiplier;
- data_.push_back(vertex);
- if(vertex.count.is_45()) is_manhattan_ = false;
+ output.push_back(vertex);
+ return vertex.count.is_45();
+ }
+
+ template <typename Unit>
+ inline void polygon_45_set_data<Unit>::insert_vertex_half_edge_45_pair(const point_data<Unit>& pt1, point_data<Unit>& pt2,
+ const point_data<Unit>& pt3,
+ direction_1d wdir) {
+ if(insert_vertex_half_edge_45_pair_into_vector(data_, pt1, pt2, pt3, wdir)) is_manhattan_ = false;
}
template <typename Unit>
@@ -465,7 +523,7 @@
unsorted_ = true;
}
- /// insert polygon set
+ // insert polygon set
template <typename Unit>
inline void polygon_45_set_data<Unit>::insert(const polygon_45_set_data<Unit>& polygon_set, bool is_hole) {
if(is_hole) {
@@ -477,13 +535,36 @@
return;
}
data_.insert(data_.end(), polygon_set.data_.begin(), polygon_set.data_.end());
+ error_data_.insert(error_data_.end(), polygon_set.error_data_.begin(),
+ polygon_set.error_data_.end());
dirty_ = true;
unsorted_ = true;
if(polygon_set.is_manhattan_ == false) is_manhattan_ = false;
return;
}
- /// get the external boundary rectangle
+ template <typename cT, typename rT>
+ void insert_rectangle_into_vector_45(cT& output, const rT& rect, bool is_hole) {
+ point_data<typename rectangle_traits<rT>::coordinate_type>
+ llpt = ll(rect), lrpt = lr(rect), ulpt = ul(rect), urpt = ur(rect);
+ direction_1d dir = COUNTERCLOCKWISE;
+ if(is_hole) dir = CLOCKWISE;
+ insert_vertex_half_edge_45_pair_into_vector(output, llpt, lrpt, urpt, dir);
+ insert_vertex_half_edge_45_pair_into_vector(output, lrpt, urpt, ulpt, dir);
+ insert_vertex_half_edge_45_pair_into_vector(output, urpt, ulpt, llpt, dir);
+ insert_vertex_half_edge_45_pair_into_vector(output, ulpt, llpt, lrpt, dir);
+ }
+
+ template <typename Unit>
+ template <typename geometry_type>
+ inline void polygon_45_set_data<Unit>::insert_dispatch(const geometry_type& geometry_object,
+ bool is_hole, rectangle_concept tag) {
+ dirty_ = true;
+ unsorted_ = true;
+ insert_rectangle_into_vector_45(data_, geometry_object, is_hole);
+ }
+
+ // get the external boundary rectangle
template <typename Unit>
template <typename rectangle_type>
inline bool polygon_45_set_data<Unit>::extents(rectangle_type& rect) const{
@@ -539,7 +620,7 @@
}
}
- /// |= &= += *= -= ^= binary operators
+ // |= &= += *= -= ^= binary operators
template <typename Unit>
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::operator|=(const polygon_45_set_data<Unit>& b) {
insert(b);
@@ -549,7 +630,7 @@
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::operator&=(const polygon_45_set_data<Unit>& b) {
//b.sort();
//sort();
- applyAdaptiveBoolean_(1, b);
+ applyAdaptiveBoolean_<1>(b);
dirty_ = false;
unsorted_ = false;
return *this;
@@ -566,7 +647,7 @@
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::operator-=(const polygon_45_set_data<Unit>& b) {
//b.sort();
//sort();
- applyAdaptiveBoolean_(2, b);
+ applyAdaptiveBoolean_<2>(b);
dirty_ = false;
unsorted_ = false;
return *this;
@@ -575,7 +656,7 @@
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::operator^=(const polygon_45_set_data<Unit>& b) {
//b.sort();
//sort();
- applyAdaptiveBoolean_(3, b);
+ applyAdaptiveBoolean_<3>(b);
dirty_ = false;
unsorted_ = false;
return *this;
@@ -733,14 +814,64 @@
template <typename Unit>
inline
+ void handleResizingEdge45_SQRT1OVER2(polygon_45_set_data<Unit>& sizingSet, point_data<Unit> first,
+ point_data<Unit> second, Unit resizing, CornerOption corner) {
+ if(first.x() == second.x()) {
+ sizingSet.insert(rectangle_data<int>(first.x() - resizing, first.y(), first.x() + resizing, second.y()));
+ return;
+ }
+ if(first.y() == second.y()) {
+ sizingSet.insert(rectangle_data<int>(first.x(), first.y() - resizing, second.x(), first.y() + resizing));
+ return;
+ }
+ std::vector<point_data<Unit> > pts;
+ Unit bloating = resizing < 0 ? -resizing : resizing;
+ if(corner == UNFILLED) {
+ //we have to round up
+ bloating = bloating / 2 + bloating % 2 ; //round up
+ if(second.x() < first.x()) std::swap(first, second);
+ if(first.y() < second.y()) { //upward sloping
+ pts.push_back(point_data<Unit>(first.x() + bloating, first.y() - bloating));
+ pts.push_back(point_data<Unit>(first.x() - bloating, first.y() + bloating));
+ pts.push_back(point_data<Unit>(second.x() - bloating, second.y() + bloating));
+ pts.push_back(point_data<Unit>(second.x() + bloating, second.y() - bloating));
+ sizingSet.insert_vertex_sequence(pts.begin(), pts.end(), CLOCKWISE, false);
+ } else { //downward sloping
+ pts.push_back(point_data<Unit>(first.x() + bloating, first.y() + bloating));
+ pts.push_back(point_data<Unit>(first.x() - bloating, first.y() - bloating));
+ pts.push_back(point_data<Unit>(second.x() - bloating, second.y() - bloating));
+ pts.push_back(point_data<Unit>(second.x() + bloating, second.y() + bloating));
+ sizingSet.insert_vertex_sequence(pts.begin(), pts.end(), COUNTERCLOCKWISE, false);
+ }
+ return;
+ }
+ if(second.x() < first.x()) std::swap(first, second);
+ if(first.y() < second.y()) { //upward sloping
+ pts.push_back(point_data<Unit>(first.x(), first.y() - bloating));
+ pts.push_back(point_data<Unit>(first.x() - bloating, first.y()));
+ pts.push_back(point_data<Unit>(second.x(), second.y() + bloating));
+ pts.push_back(point_data<Unit>(second.x() + bloating, second.y()));
+ sizingSet.insert_vertex_sequence(pts.begin(), pts.end(), CLOCKWISE, false);
+ } else { //downward sloping
+ pts.push_back(point_data<Unit>(first.x() - bloating, first.y()));
+ pts.push_back(point_data<Unit>(first.x(), first.y() + bloating));
+ pts.push_back(point_data<Unit>(second.x() + bloating, second.y()));
+ pts.push_back(point_data<Unit>(second.x(), second.y() - bloating));
+ sizingSet.insert_vertex_sequence(pts.begin(), pts.end(), CLOCKWISE, false);
+ }
+ }
+
+
+ template <typename Unit>
+ inline
void handleResizingEdge45(polygon_45_set_data<Unit>& sizingSet, point_data<Unit> first,
point_data<Unit> second, Unit resizing, RoundingOption rounding) {
if(first.x() == second.x()) {
- sizingSet += rectangle_data<int>(first.x() - resizing, first.y(), first.x() + resizing, second.y());
+ sizingSet.insert(rectangle_data<int>(first.x() - resizing, first.y(), first.x() + resizing, second.y()));
return;
}
if(first.y() == second.y()) {
- sizingSet += rectangle_data<int>(first.x(), first.y() - resizing, second.x(), first.y() + resizing);
+ sizingSet.insert(rectangle_data<int>(first.x(), first.y() - resizing, second.x(), first.y() + resizing));
return;
}
//edge is 45
@@ -763,6 +894,41 @@
}
template <typename Unit>
+ inline point_data<Unit> bloatVertexInDirWithSQRT1OVER2(int edge1, int normal1, const point_data<Unit>& second, Unit bloating,
+ bool first) {
+ orientation_2d orient = first ? HORIZONTAL : VERTICAL;
+ orientation_2d orientp = orient.get_perpendicular();
+ int multiplier = first ? 1 : -1;
+ point_data<Unit> pt1(second);
+ if(edge1 == 1) {
+ if(normal1 == 3) {
+ move(pt1, orient, -multiplier * bloating);
+ } else {
+ move(pt1, orientp, -multiplier * bloating);
+ }
+ } else if(edge1 == 3) {
+ if(normal1 == 1) {
+ move(pt1, orient, multiplier * bloating);
+ } else {
+ move(pt1, orientp, -multiplier * bloating);
+ }
+ } else if(edge1 == 5) {
+ if(normal1 == 3) {
+ move(pt1, orientp, multiplier * bloating);
+ } else {
+ move(pt1, orient, multiplier * bloating);
+ }
+ } else {
+ if(normal1 == 5) {
+ move(pt1, orient, -multiplier * bloating);
+ } else {
+ move(pt1, orientp, multiplier * bloating);
+ }
+ }
+ return pt1;
+ }
+
+ template <typename Unit>
inline
void handleResizingVertex45(polygon_45_set_data<Unit>& sizingSet, const point_data<Unit>& first,
const point_data<Unit>& second, const point_data<Unit>& third, Unit resizing,
@@ -779,15 +945,63 @@
if(resizing > 0) return; //accute interior corner
else multiplier *= -1; //make it appear to be an accute exterior angle
}
+ Unit bloating = abs(resizing);
+ if(rounding == SQRT1OVER2) {
+ if(edge1 % 2 && edge2 % 2) return;
+ if(corner == ORTHOGONAL && edge1 % 2 == 0 && edge2 % 2 == 0) {
+ rectangle_data<Unit> insertion_rect;
+ set_points(insertion_rect, second, second);
+ bloat(insertion_rect, bloating);
+ sizingSet.insert(insertion_rect);
+ } else if(corner != ORTHOGONAL) {
+ point_data<Unit> pt1(0, 0);
+ point_data<Unit> pt2(0, 0);
+ unsigned int normal1 = getEdge45NormalDirection(edge1, multiplier);
+ unsigned int normal2 = getEdge45NormalDirection(edge2, multiplier);
+ if(edge1 % 2) {
+ pt1 = bloatVertexInDirWithSQRT1OVER2(edge1, normal1, second, bloating, true);
+ } else {
+ pt1 = bloatVertexInDirWithOptions(second, normal1, bloating, UNDERSIZE);
+ }
+ if(edge2 % 2) {
+ pt2 = bloatVertexInDirWithSQRT1OVER2(edge2, normal2, second, bloating, false);
+ } else {
+ pt2 = bloatVertexInDirWithOptions(second, normal2, bloating, UNDERSIZE);
+ }
+ std::vector<point_data<Unit> > pts;
+ pts.push_back(pt1);
+ pts.push_back(second);
+ pts.push_back(pt2);
+ pts.push_back(getIntersectionPoint(pt1, edge1, pt2, edge2));
+ polygon_45_data<Unit> poly(pts.begin(), pts.end());
+ sizingSet.insert(poly);
+ } else {
+ //ORTHOGONAL of a 45 degree corner
+ int normal = 0;
+ if(edge1 % 2) {
+ normal = getEdge45NormalDirection(edge2, multiplier);
+ } else {
+ normal = getEdge45NormalDirection(edge1, multiplier);
+ }
+ rectangle_data<Unit> insertion_rect;
+ point_data<Unit> edgePoint = bloatVertexInDirWithOptions(second, normal, bloating, UNDERSIZE);
+ set_points(insertion_rect, second, edgePoint);
+ if(normal == 0 || normal == 4)
+ bloat(insertion_rect, VERTICAL, bloating);
+ else
+ bloat(insertion_rect, HORIZONTAL, bloating);
+ sizingSet.insert(insertion_rect);
+ }
+ return;
+ }
unsigned int normal1 = getEdge45NormalDirection(edge1, multiplier);
unsigned int normal2 = getEdge45NormalDirection(edge2, multiplier);
- Unit bloating = abs(resizing);
point_data<Unit> edgePoint1 = bloatVertexInDirWithOptions(second, normal1, bloating, rounding);
point_data<Unit> edgePoint2 = bloatVertexInDirWithOptions(second, normal2, bloating, rounding);
//if the change in angle is 135 degrees it is an accute exterior corner
if((edge1+ multiplier * 3) % 8 == edge2) {
- if(corner == ORTHOGINAL) {
- rectangle_data<int> insertion_rect;
+ if(corner == ORTHOGONAL) {
+ rectangle_data<Unit> insertion_rect;
set_points(insertion_rect, edgePoint1, edgePoint2);
sizingSet.insert(insertion_rect);
return;
@@ -799,7 +1013,7 @@
pts.push_back(edgePoint2);
pts.push_back(getIntersectionPoint(edgePoint1, edge1, edgePoint2, edge2));
polygon_45_data<Unit> poly(pts.begin(), pts.end());
- sizingSet += poly;
+ sizingSet.insert(poly);
}
template <typename Unit>
@@ -831,8 +1045,13 @@
polygon_45_set_data<Unit> sizingSet;
//insert minkofski shapes on edges and corners
do {
- handleResizingEdge45(sizingSet, *first, *second, resizing, rounding);
- handleResizingVertex45(sizingSet, *first, *second, *third, resizing, rounding, corner, multiplier);
+ if(rounding != SQRT1OVER2) {
+ handleResizingEdge45(sizingSet, *first, *second, resizing, rounding);
+ } else {
+ handleResizingEdge45_SQRT1OVER2(sizingSet, *first, *second, resizing, corner);
+ }
+ if(corner != UNFILLED)
+ handleResizingVertex45(sizingSet, *first, *second, *third, resizing, rounding, corner, multiplier);
first = second;
second = third;
++third;
@@ -846,23 +1065,15 @@
//sizingSet.snap();
polygon_45_set_data<Unit> tmp;
//insert original shape
- tmp.insert(poly, hole);
+ tmp.insert_dispatch(poly, hole, polygon_45_concept());
if(hole) {
- std::vector<point_data<Unit> > pts;
- pts.reserve(4);
Unit UnitMax = std::numeric_limits<Unit>::max();
Unit UnitMin = std::numeric_limits<Unit>::min();
- pts.push_back(point_data<Unit> (UnitMin, UnitMin));
- pts.push_back(point_data<Unit> (UnitMin, UnitMax));
- pts.push_back(point_data<Unit> (UnitMax, UnitMax));
- pts.push_back(point_data<Unit> (UnitMax, UnitMin));
- tmp.insert_vertex_sequence(pts.begin(), pts.end(), LOW, false);
- //tmp.snap();
+ tmp.insert(rectangle_data<Unit>(UnitMin, UnitMin, UnitMax, UnitMax));
if(resizing < 0) tmp -= sizingSet;
else tmp += sizingSet;
tmp.clean();
- tmp.insert_vertex_sequence(pts.begin(), pts.end(), LOW, true);
- //tmp.snap();
+ tmp.insert(rectangle_data<Unit>(UnitMin, UnitMin, UnitMax, UnitMax), true); //insert as hole to cancel out
} else {
if(resizing < 0) tmp -= sizingSet;
else tmp += sizingSet;
@@ -871,7 +1082,7 @@
return (*this) += tmp;
}
- /// accumulate the bloated polygon with holes
+ // accumulate the bloated polygon with holes
template <typename Unit>
template <typename geometry_type>
inline polygon_45_set_data<Unit>&
@@ -889,7 +1100,7 @@
return *this;
}
- /// transform set
+ // transform set
template <typename Unit>
template <typename transformation_type>
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::transform(const transformation_type& tr){
@@ -909,12 +1120,18 @@
template <typename Unit>
inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::scale_up(typename coordinate_traits<Unit>::unsigned_area_type factor) {
+ scale_up_vertex_45_compact_range(data_.begin(), data_.end(), factor);
+ return *this;
+ }
+
+ template <typename Unit>
+ inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::scale_down(typename coordinate_traits<Unit>::unsigned_area_type factor) {
clean();
std::vector<polygon_45_with_holes_data<Unit> > polys;
get_polygons_with_holes(polys);
for(typename std::vector<polygon_45_with_holes_data<Unit> >::iterator itr = polys.begin();
itr != polys.end(); ++itr) {
- gtl::scale_up(*itr, factor);
+ gtl::scale_down(*itr, factor);
}
clear();
insert(polys.begin(), polys.end());
@@ -924,13 +1141,13 @@
}
template <typename Unit>
- inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::scale_down(typename coordinate_traits<Unit>::unsigned_area_type factor) {
+ inline polygon_45_set_data<Unit>& polygon_45_set_data<Unit>::scale(double factor) {
clean();
std::vector<polygon_45_with_holes_data<Unit> > polys;
get_polygons_with_holes(polys);
for(typename std::vector<polygon_45_with_holes_data<Unit> >::iterator itr = polys.begin();
itr != polys.end(); ++itr) {
- gtl::scale_down(*itr, factor);
+ gtl::scale(*itr, factor);
}
clear();
insert(polys.begin(), polys.end());
@@ -943,26 +1160,323 @@
inline bool polygon_45_set_data<Unit>::clean() const {
if(unsorted_) sort();
if(dirty_) {
- polygon_45_set_data<Unit> empty;
- applyAdaptiveBoolean_(0, empty);
+ applyAdaptiveUnary_<0>();
dirty_ = false;
}
return true;
}
template <typename Unit>
- inline void polygon_45_set_data<Unit>::applyAdaptiveBoolean_(int op, const polygon_45_set_data<Unit>& rvalue) const {
+ template <int op>
+ inline void polygon_45_set_data<Unit>::applyAdaptiveBoolean_(const polygon_45_set_data<Unit>& rvalue) const {
polygon_45_set_data<Unit> tmp;
- applyAdaptiveBoolean_(tmp, op, rvalue);
+ applyAdaptiveBoolean_<op>(tmp, rvalue);
data_.swap(tmp.data_); //swapping vectors should be constant time operation
+ error_data_.swap(tmp.error_data_);
is_manhattan_ = tmp.is_manhattan_;
unsorted_ = false;
dirty_ = false;
}
+ template <typename Unit2, int op>
+ bool applyBoolean45OpOnVectors(std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact>& result_data,
+ std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact>& lvalue_data,
+ std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact>& rvalue_data
+ ) {
+ bool result_is_manhattan_ = true;
+ typename boolean_op_45<Unit2>::template Scan45<typename boolean_op_45<Unit2>::Count2,
+ typename boolean_op_45<Unit2>::template boolean_op_45_output_functor<op> > scan45;
+ std::vector<typename boolean_op_45<Unit2>::Vertex45> eventOut;
+ typedef std::pair<typename boolean_op_45<Unit2>::Point,
+ typename boolean_op_45<Unit2>::template Scan45CountT<typename boolean_op_45<Unit2>::Count2> > Scan45Vertex;
+ std::vector<Scan45Vertex> eventIn;
+ typedef std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact> value_type;
+ typename value_type::const_iterator iter1 = lvalue_data.begin();
+ typename value_type::const_iterator iter2 = rvalue_data.begin();
+ typename value_type::const_iterator end1 = lvalue_data.end();
+ typename value_type::const_iterator end2 = rvalue_data.end();
+ const Unit2 UnitMax = std::numeric_limits<Unit2>::max();
+ Unit2 x = UnitMax;
+ while(iter1 != end1 || iter2 != end2) {
+ Unit2 currentX = UnitMax;
+ if(iter1 != end1) currentX = iter1->pt.x();
+ if(iter2 != end2) currentX = std::min(currentX, iter2->pt.x());
+ if(currentX != x) {
+ //std::cout << "SCAN " << currentX << "\n";
+ //scan event
+ scan45.scan(eventOut, eventIn.begin(), eventIn.end());
+ std::sort(eventOut.begin(), eventOut.end());
+ unsigned int ptCount = 0;
+ for(unsigned int i = 0; i < eventOut.size(); ++i) {
+ if(!result_data.empty() &&
+ result_data.back().pt == eventOut[i].pt) {
+ result_data.back().count += eventOut[i];
+ ++ptCount;
+ } else {
+ if(!result_data.empty()) {
+ if(result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ }
+ result_data.push_back(eventOut[i]);
+ ptCount = 1;
+ }
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ eventOut.clear();
+ eventIn.clear();
+ x = currentX;
+ }
+ //std::cout << "get next\n";
+ if(iter2 != end2 && (iter1 == end1 || iter2->pt.x() < iter1->pt.x() ||
+ (iter2->pt.x() == iter1->pt.x() &&
+ iter2->pt.y() < iter1->pt.y()) )) {
+ //std::cout << "case1 next\n";
+ eventIn.push_back(Scan45Vertex
+ (iter2->pt,
+ typename polygon_45_formation<Unit2>::
+ Scan45Count(typename polygon_45_formation<Unit2>::Count2(0, iter2->count[0]),
+ typename polygon_45_formation<Unit2>::Count2(0, iter2->count[1]),
+ typename polygon_45_formation<Unit2>::Count2(0, iter2->count[2]),
+ typename polygon_45_formation<Unit2>::Count2(0, iter2->count[3]))));
+ ++iter2;
+ } else if(iter1 != end1 && (iter2 == end2 || iter1->pt.x() < iter2->pt.x() ||
+ (iter1->pt.x() == iter2->pt.x() &&
+ iter1->pt.y() < iter2->pt.y()) )) {
+ //std::cout << "case2 next\n";
+ eventIn.push_back(Scan45Vertex
+ (iter1->pt,
+ typename polygon_45_formation<Unit2>::
+ Scan45Count(
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[0], 0),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[1], 0),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[2], 0),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[3], 0))));
+ ++iter1;
+ } else {
+ //std::cout << "case3 next\n";
+ eventIn.push_back(Scan45Vertex
+ (iter2->pt,
+ typename polygon_45_formation<Unit2>::
+ Scan45Count(typename polygon_45_formation<Unit2>::Count2(iter1->count[0],
+ iter2->count[0]),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[1],
+ iter2->count[1]),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[2],
+ iter2->count[2]),
+ typename polygon_45_formation<Unit2>::Count2(iter1->count[3],
+ iter2->count[3]))));
+ ++iter1;
+ ++iter2;
+ }
+ }
+ scan45.scan(eventOut, eventIn.begin(), eventIn.end());
+ std::sort(eventOut.begin(), eventOut.end());
+
+ unsigned int ptCount = 0;
+ for(unsigned int i = 0; i < eventOut.size(); ++i) {
+ if(!result_data.empty() &&
+ result_data.back().pt == eventOut[i].pt) {
+ result_data.back().count += eventOut[i];
+ ++ptCount;
+ } else {
+ if(!result_data.empty()) {
+ if(result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ }
+ result_data.push_back(eventOut[i]);
+ ptCount = 1;
+ }
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ if(!result_data.empty() &&
+ result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ return result_is_manhattan_;
+ }
+
+ template <typename Unit2, int op>
+ bool applyUnary45OpOnVectors(std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact>& result_data,
+ std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact>& lvalue_data ) {
+ bool result_is_manhattan_ = true;
+ typename boolean_op_45<Unit2>::template Scan45<typename boolean_op_45<Unit2>::Count1,
+ typename boolean_op_45<Unit2>::template unary_op_45_output_functor<op> > scan45;
+ std::vector<typename boolean_op_45<Unit2>::Vertex45> eventOut;
+ typedef typename boolean_op_45<Unit2>::template Scan45CountT<typename boolean_op_45<Unit2>::Count1> Scan45Count;
+ typedef std::pair<typename boolean_op_45<Unit2>::Point, Scan45Count> Scan45Vertex;
+ std::vector<Scan45Vertex> eventIn;
+ typedef std::vector<typename polygon_45_formation<Unit2>::Vertex45Compact> value_type;
+ typename value_type::const_iterator iter1 = lvalue_data.begin();
+ typename value_type::const_iterator end1 = lvalue_data.end();
+ const Unit2 UnitMax = std::numeric_limits<Unit2>::max();
+ Unit2 x = UnitMax;
+ while(iter1 != end1) {
+ Unit2 currentX = iter1->pt.x();
+ if(currentX != x) {
+ //std::cout << "SCAN " << currentX << "\n";
+ //scan event
+ scan45.scan(eventOut, eventIn.begin(), eventIn.end());
+ std::sort(eventOut.begin(), eventOut.end());
+ unsigned int ptCount = 0;
+ for(unsigned int i = 0; i < eventOut.size(); ++i) {
+ if(!result_data.empty() &&
+ result_data.back().pt == eventOut[i].pt) {
+ result_data.back().count += eventOut[i];
+ ++ptCount;
+ } else {
+ if(!result_data.empty()) {
+ if(result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ }
+ result_data.push_back(eventOut[i]);
+ ptCount = 1;
+ }
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ eventOut.clear();
+ eventIn.clear();
+ x = currentX;
+ }
+ //std::cout << "get next\n";
+ eventIn.push_back(Scan45Vertex
+ (iter1->pt,
+ Scan45Count( typename boolean_op_45<Unit2>::Count1(iter1->count[0]),
+ typename boolean_op_45<Unit2>::Count1(iter1->count[1]),
+ typename boolean_op_45<Unit2>::Count1(iter1->count[2]),
+ typename boolean_op_45<Unit2>::Count1(iter1->count[3]))));
+ ++iter1;
+ }
+ scan45.scan(eventOut, eventIn.begin(), eventIn.end());
+ std::sort(eventOut.begin(), eventOut.end());
+
+ unsigned int ptCount = 0;
+ for(unsigned int i = 0; i < eventOut.size(); ++i) {
+ if(!result_data.empty() &&
+ result_data.back().pt == eventOut[i].pt) {
+ result_data.back().count += eventOut[i];
+ ++ptCount;
+ } else {
+ if(!result_data.empty()) {
+ if(result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ }
+ result_data.push_back(eventOut[i]);
+ ptCount = 1;
+ }
+ }
+ if(ptCount == 2 && result_data.back().count == (typename polygon_45_formation<Unit2>::Vertex45Count(0, 0, 0, 0))) {
+ result_data.pop_back();
+ }
+ if(!result_data.empty() &&
+ result_data.back().count.is_45()) {
+ result_is_manhattan_ = false;
+ }
+ return result_is_manhattan_;
+ }
+
+ template <typename cT, typename iT>
+ void get_error_rects_shell(cT& posE, cT& negE, iT beginr, iT endr) {
+ typedef typename iT::value_type Point;
+ Point pt1, pt2, pt3;
+ bool i1 = true;
+ bool i2 = true;
+ bool not_done = beginr != endr;
+ bool next_to_last = false;
+ bool last = false;
+ Point first, second;
+ while(not_done) {
+ if(last) {
+ last = false;
+ not_done = false;
+ pt3 = second;
+ } else if(next_to_last) {
+ next_to_last = false;
+ last = true;
+ pt3 = first;
+ } else if(i1) {
+ const Point& pt = *beginr;
+ first = pt1 = pt;
+ i1 = false;
+ i2 = true;
+ ++beginr;
+ if(beginr == endr) return; //too few points
+ continue;
+ } else if (i2) {
+ const Point& pt = *beginr;
+ second = pt2 = pt;
+ i2 = false;
+ ++beginr;
+ if(beginr == endr) return; //too few points
+ continue;
+ } else {
+ const Point& pt = *beginr;
+ pt3 = pt;
+ ++beginr;
+ if(beginr == endr) {
+ next_to_last = true;
+ //skip last point equal to first
+ continue;
+ }
+ }
+ if(abs(x(pt2)) % 2) { //y % 2 should also be odd
+ //is corner concave or convex?
+ Point pts[] = {pt1, pt2, pt3};
+ double ar = point_sequence_area<Point*, double>(pts, pts+3);
+ direction_1d dir = ar < 0 ? COUNTERCLOCKWISE : CLOCKWISE;
+ //std::cout << pt1 << " " << pt2 << " " << pt3 << " " << ar << std::endl;
+ if(dir == CLOCKWISE) {
+ posE.push_back(rectangle_data<typename Point::coordinate_type>
+ (x(pt2) - 1, y(pt2) - 1, x(pt2) + 1, y(pt2) + 1));
+
+ } else {
+ negE.push_back(rectangle_data<typename Point::coordinate_type>
+ (x(pt2) - 1, y(pt2) - 1, x(pt2) + 1, y(pt2) + 1));
+ }
+ }
+ pt1 = pt2;
+ pt2 = pt3;
+ }
+ }
+
+ template <typename cT, typename pT>
+ void get_error_rects(cT& posE, cT& negE, const pT& p) {
+ get_error_rects_shell(posE, negE, p.begin(), p.end());
+ for(typename pT::iterator_holes_type iHb = p.begin_holes();
+ iHb != p.end_holes(); ++iHb) {
+ get_error_rects_shell(posE, negE, iHb->begin(), iHb->end());
+ }
+ }
+
template <typename Unit>
+ template <int op>
inline void polygon_45_set_data<Unit>::applyAdaptiveBoolean_(polygon_45_set_data<Unit>& result,
- int op, const polygon_45_set_data<Unit>& rvalue) const {
+ const polygon_45_set_data<Unit>& rvalue) const {
+ result.clear();
+ result.error_data_ = error_data_;
+ result.error_data_.insert(result.error_data_.end(), rvalue.error_data_.begin(),
+ rvalue.error_data_.end());
if(is_manhattan() && rvalue.is_manhattan()) {
//convert each into polygon_90_set data and call boolean operations
polygon_90_set_data<Unit> l90sd(VERTICAL), r90sd(VERTICAL), output(VERTICAL);
@@ -970,8 +1484,8 @@
if((*itr).count[3] == 0) continue; //skip all non vertical edges
l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
}
- for(typename value_type::const_iterator itr = rvalue.data_.begin(); itr != rvalue.data_.end(); ++itr) {
- if((*itr).count[3] == 0) continue; //skip all non vertical edges
+ for(typename value_type::const_iterator itr = rvalue.data_.begin(); itr != rvalue.data_.end(); ++itr) {
+ if((*itr).count[3] == 0) continue; //skip all non vertical edges
r90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
}
l90sd.sort();
@@ -989,236 +1503,204 @@
output.applyBooleanBinaryOp(l90sd.begin(), l90sd.end(),
r90sd.begin(), r90sd.end(), boolean_op::BinaryCount<boolean_op::BinaryXor>());
}
- result.clear();
+ result.data_.clear();
result.insert(output);
+ result.is_manhattan_ = true;
+ result.dirty_ = false;
+ result.unsorted_ = false;
} else {
sort();
rvalue.sort();
- typename boolean_op_45<Unit>::Scan45 scan45(op);
- std::vector<typename boolean_op_45<Unit>::Vertex45> eventOut;
- std::vector<typename boolean_op_45<Unit>::Scan45Vertex> eventIn;
- typename value_type::const_iterator iter1 = data_.begin();
- typename value_type::const_iterator iter2 = rvalue.data_.begin();
- typename value_type::const_iterator end1 = data_.end();
- typename value_type::const_iterator end2 = rvalue.data_.end();
- const Unit UnitMax = std::numeric_limits<Unit>::max();
- Unit x = UnitMax;
- while(iter1 != end1 || iter2 != end2) {
- Unit currentX = UnitMax;
- if(iter1 != end1) currentX = iter1->pt.x();
- if(iter2 != end2) currentX = std::min(currentX, iter2->pt.x());
- if(currentX != x) {
- //std::cout << "SCAN " << currentX << "\n";
- //scan event
- scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
- for(unsigned int i = 0; i < eventOut.size(); ++i) {
- if(!result.data_.empty() &&
- result.data_.back().pt == eventOut[i].pt) {
- result.data_.back().count += eventOut[i];
- } else {
- if(!result.data_.empty() &&
- result.data_.back().count.is_45()) {
- result.is_manhattan_ = false;
- }
- result.data_.push_back(eventOut[i]);
+ try {
+ result.is_manhattan_ = applyBoolean45OpOnVectors<Unit, op>(result.data_, data_, rvalue.data_);
+ } catch (std::string str) {
+ std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
+ if(str == msg) {
+ result.clear();
+ typedef typename coordinate_traits<Unit>::manhattan_area_type Unit2;
+ typedef typename polygon_45_formation<Unit2>::Vertex45Compact Vertex45Compact2;
+ typedef std::vector<Vertex45Compact2> Data2;
+ Data2 rvalue_data, lvalue_data, result_data;
+ rvalue_data.reserve(rvalue.data_.size());
+ lvalue_data.reserve(data_.size());
+ for(unsigned int i = 0 ; i < data_.size(); ++i) {
+ const Vertex45Compact& vi = data_[i];
+ Vertex45Compact2 ci;
+ ci.pt = point_data<Unit2>(x(vi.pt), y(vi.pt));
+ ci.count = typename polygon_45_formation<Unit2>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ lvalue_data.push_back(ci);
+ }
+ for(unsigned int i = 0 ; i < rvalue.data_.size(); ++i) {
+ const Vertex45Compact& vi = rvalue.data_[i];
+ Vertex45Compact2 ci;
+ ci.pt = (point_data<Unit2>(x(vi.pt), y(vi.pt)));
+ ci.count = typename polygon_45_formation<Unit2>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ rvalue_data.push_back(ci);
+ }
+ scale_up_vertex_45_compact_range(lvalue_data.begin(), lvalue_data.end(), 2);
+ scale_up_vertex_45_compact_range(rvalue_data.begin(), rvalue_data.end(), 2);
+ bool result_is_manhattan = applyBoolean45OpOnVectors<Unit2, op>(result_data,
+ lvalue_data,
+ rvalue_data );
+ if(!result_is_manhattan) {
+ typename polygon_45_formation<Unit2>::Polygon45Formation pf(false);
+ //std::cout << "FORMING POLYGONS\n";
+ std::vector<polygon_45_with_holes_data<Unit2> > container;
+ pf.scan(container, result_data.begin(), result_data.end());
+ Data2 error_data_out;
+ std::vector<rectangle_data<Unit2> > pos_error_rects;
+ std::vector<rectangle_data<Unit2> > neg_error_rects;
+ for(unsigned int i = 0; i < container.size(); ++i) {
+ get_error_rects(pos_error_rects, neg_error_rects, container[i]);
+ }
+ for(unsigned int i = 0; i < pos_error_rects.size(); ++i) {
+ insert_rectangle_into_vector_45(result_data, pos_error_rects[i], false);
+ insert_rectangle_into_vector_45(error_data_out, pos_error_rects[i], false);
}
- if(result.data_.back().count == (typename polygon_45_formation<Unit>::Vertex45Count(0, 0, 0, 0))) {
- result.data_.pop_back();
+ for(unsigned int i = 0; i < neg_error_rects.size(); ++i) {
+ insert_rectangle_into_vector_45(result_data, neg_error_rects[i], true);
+ insert_rectangle_into_vector_45(error_data_out, neg_error_rects[i], false);
}
+ scale_down_vertex_45_compact_range_blindly(error_data_out.begin(), error_data_out.end(), 2);
+ for(unsigned int i = 0 ; i < error_data_out.size(); ++i) {
+ const Vertex45Compact2& vi = error_data_out[i];
+ Vertex45Compact ci;
+ ci.pt = (point_data<Unit2>(x(vi.pt), y(vi.pt)));
+ ci.count = typename polygon_45_formation<Unit>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ result.error_data_.push_back(ci);
+ }
+ Data2 new_result_data;
+ std::sort(result_data.begin(), result_data.end());
+ applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
+ result_data.swap(new_result_data);
}
- eventOut.clear();
- eventIn.clear();
- x = currentX;
- }
- //std::cout << "get next\n";
- if(iter2 != end2 && (iter1 == end1 || iter2->pt.x() < iter1->pt.x() ||
- (iter2->pt.x() == iter1->pt.x() &&
- iter2->pt.y() < iter1->pt.y()) )) {
- //std::cout << "case1 next\n";
- eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter2->pt,
- typename polygon_45_formation<Unit>::
- Scan45Count(typename polygon_45_formation<Unit>::Count2(0, iter2->count[0]),
- typename polygon_45_formation<Unit>::Count2(0, iter2->count[1]),
- typename polygon_45_formation<Unit>::Count2(0, iter2->count[2]),
- typename polygon_45_formation<Unit>::Count2(0, iter2->count[3]))));
- ++iter2;
- } else if(iter1 != end1 && (iter2 == end2 || iter1->pt.x() < iter2->pt.x() ||
- (iter1->pt.x() == iter2->pt.x() &&
- iter1->pt.y() < iter2->pt.y()) )) {
- //std::cout << "case2 next\n";
- eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter1->pt,
- typename polygon_45_formation<Unit>::
- Scan45Count(
- typename polygon_45_formation<Unit>::Count2(iter1->count[0], 0),
- typename polygon_45_formation<Unit>::Count2(iter1->count[1], 0),
- typename polygon_45_formation<Unit>::Count2(iter1->count[2], 0),
- typename polygon_45_formation<Unit>::Count2(iter1->count[3], 0))));
- ++iter1;
- } else {
- //std::cout << "case3 next\n";
- eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter2->pt,
- typename polygon_45_formation<Unit>::
- Scan45Count(typename polygon_45_formation<Unit>::Count2(iter1->count[0],
- iter2->count[0]),
- typename polygon_45_formation<Unit>::Count2(iter1->count[1],
- iter2->count[1]),
- typename polygon_45_formation<Unit>::Count2(iter1->count[2],
- iter2->count[2]),
- typename polygon_45_formation<Unit>::Count2(iter1->count[3],
- iter2->count[3]))));
- ++iter1;
- ++iter2;
- }
- }
- scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
- for(unsigned int i = 0; i < eventOut.size(); ++i) {
- if(!result.data_.empty() &&
- result.data_.back().pt == eventOut[i].pt) {
- result.data_.back().count += eventOut[i];
- } else {
- if(!result.data_.empty() &&
- result.data_.back().count.is_45()) {
- result.is_manhattan_ = false;
+ scale_down_vertex_45_compact_range_blindly(result_data.begin(), result_data.end(), 2);
+ //result.data_.reserve(result_data.size());
+ for(unsigned int i = 0 ; i < result_data.size(); ++i) {
+ const Vertex45Compact2& vi = result_data[i];
+ Vertex45Compact ci;
+ ci.pt = (point_data<Unit2>(x(vi.pt), y(vi.pt)));
+ ci.count = typename polygon_45_formation<Unit>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ result.data_.push_back(ci);
}
- result.data_.push_back(eventOut[i]);
- }
- if(result.data_.back().count == typename polygon_45_formation<Unit>::Vertex45Count(0, 0, 0, 0)) {
- result.data_.pop_back();
- }
- }
- if(!result.data_.empty() &&
- result.data_.back().count.is_45()) {
- result.is_manhattan_ = false;
+ result.is_manhattan_ = result_is_manhattan;
+ result.dirty_ = false;
+ result.unsorted_ = false;
+ } else { throw str; }
}
//std::cout << "DONE SCANNING\n";
}
}
-// template <typename Unit>
-// inline void polygon_45_set_data<Unit>::applyBoolean_(int op, value_type& rvalue) const {
-// value_type tmp;
-// applyBoolean_(tmp, op, rvalue);
-// data_.swap(tmp); //swapping vectors should be constant time operation
-// unsorted_ = false;
-// dirty_ = false;
-// }
-
-// template <typename Unit>
-// inline void polygon_45_set_data<Unit>::applyBoolean_(value_type& result, int op,
-// value_type& rvalue) const {
-// unsigned int originalSize = result.size();
-// try {
-// applyBooleanException_(result, op, rvalue);
-// } catch (std::string str) {
-// std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
-// if(str == msg) {
-// result.resize(originalSize);
-// snap();
-// std::sort(data_.begin(), data_.end());
-// for(typename value_type::iterator itr = rvalue.begin();
-// itr != rvalue.end(); ++itr) {
-// snap_vertex_45(*itr);
-// }
-// std::sort(rvalue.begin(), rvalue.end());
-// applyBooleanException_(result, op, rvalue);
-// } else { throw str; }
-// }
-// }
-
-// template <typename Unit>
-// inline void polygon_45_set_data<Unit>::applyBooleanException_(value_type& result, int op,
-// value_type& rvalue) const {
-// typename boolean_op_45<Unit>::Scan45 scan45(op);
-// std::vector<typename boolean_op_45<Unit>::Vertex45> eventOut;
-// std::vector<typename boolean_op_45<Unit>::Scan45Vertex> eventIn;
-// typename value_type::const_iterator iter1 = data_.begin();
-// typename value_type::const_iterator iter2 = rvalue.begin();
-// typename value_type::const_iterator end1 = data_.end();
-// typename value_type::const_iterator end2 = rvalue.end();
-// const Unit UnitMax = std::numeric_limits<Unit>::max();
-// Unit x = UnitMax;
-// while(iter1 != end1 || iter2 != end2) {
-// Unit currentX = UnitMax;
-// if(iter1 != end1) currentX = iter1->pt.x();
-// if(iter2 != end2) currentX = std::min(currentX, iter2->pt.x());
-// if(currentX != x) {
-// //std::cout << "SCAN " << currentX << "\n";
-// //scan event
-// scan45.scan(eventOut, eventIn.begin(), eventIn.end());
-// std::sort(eventOut.begin(), eventOut.end());
-// for(unsigned int i = 0; i < eventOut.size(); ++i) {
-// if(!result.empty() &&
-// result.back().pt == eventOut[i].pt) {
-// result.back().count += eventOut[i];
-// } else {
-// result.push_back(eventOut[i]);
-// }
-// if(result.back().count == (typename polygon_45_formation<Unit>::Vertex45Count(0, 0, 0, 0))) {
-// result.pop_back();
-// }
-// }
-// eventOut.clear();
-// eventIn.clear();
-// x = currentX;
-// }
-// //std::cout << "get next\n";
-// if(iter2 != end2 && (iter1 == end1 || iter2->pt.x() < iter1->pt.x() ||
-// (iter2->pt.x() == iter1->pt.x() &&
-// iter2->pt.y() < iter1->pt.y()) )) {
-// //std::cout << "case1 next\n";
-// eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter2->pt,
-// typename polygon_45_formation<Unit>::
-// Scan45Count(typename polygon_45_formation<Unit>::Count2(0, iter2->count[0]),
-// typename polygon_45_formation<Unit>::Count2(0, iter2->count[1]),
-// typename polygon_45_formation<Unit>::Count2(0, iter2->count[2]),
-// typename polygon_45_formation<Unit>::Count2(0, iter2->count[3]))));
-// ++iter2;
-// } else if(iter1 != end1 && (iter2 == end2 || iter1->pt.x() < iter2->pt.x() ||
-// (iter1->pt.x() == iter2->pt.x() &&
-// iter1->pt.y() < iter2->pt.y()) )) {
-// //std::cout << "case2 next\n";
-// eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter1->pt,
-// typename polygon_45_formation<Unit>::
-// Scan45Count(
-// typename polygon_45_formation<Unit>::Count2(iter1->count[0], 0),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[1], 0),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[2], 0),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[3], 0))));
-// ++iter1;
-// } else {
-// //std::cout << "case3 next\n";
-// eventIn.push_back(typename boolean_op_45<Unit>::Scan45Vertex(iter2->pt,
-// typename polygon_45_formation<Unit>::
-// Scan45Count(typename polygon_45_formation<Unit>::Count2(iter1->count[0],
-// iter2->count[0]),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[1],
-// iter2->count[1]),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[2],
-// iter2->count[2]),
-// typename polygon_45_formation<Unit>::Count2(iter1->count[3],
-// iter2->count[3]))));
-// ++iter1;
-// ++iter2;
-// }
-// }
-// scan45.scan(eventOut, eventIn.begin(), eventIn.end());
-// std::sort(eventOut.begin(), eventOut.end());
-// for(unsigned int i = 0; i < eventOut.size(); ++i) {
-// if(!result.empty() &&
-// result.back().pt == eventOut[i].pt) {
-// result.back().count += eventOut[i];
-// } else {
-// result.push_back(eventOut[i]);
-// }
-// if(result.back().count == typename polygon_45_formation<Unit>::Vertex45Count(0, 0, 0, 0)) {
-// result.pop_back();
-// }
-// }
-// //std::cout << "DONE SCANNING\n";
-// }
-
+ template <typename Unit>
+ template <int op>
+ inline void polygon_45_set_data<Unit>::applyAdaptiveUnary_() const {
+ polygon_45_set_data<Unit> result;
+ result.error_data_ = error_data_;
+ if(is_manhattan()) {
+ //convert each into polygon_90_set data and call boolean operations
+ polygon_90_set_data<Unit> l90sd(VERTICAL);
+ for(typename value_type::const_iterator itr = data_.begin(); itr != data_.end(); ++itr) {
+ if((*itr).count[3] == 0) continue; //skip all non vertical edges
+ l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
+ }
+ l90sd.sort();
+ if(op == 0) {
+ l90sd.clean();
+ } else if (op == 1) {
+ l90sd.self_intersect();
+ } else if (op == 3) {
+ l90sd.self_xor();
+ }
+ result.data_.clear();
+ result.insert(l90sd);
+ result.is_manhattan_ = true;
+ result.dirty_ = false;
+ result.unsorted_ = false;
+ } else {
+ sort();
+ try {
+ result.is_manhattan_ = applyUnary45OpOnVectors<Unit, op>(result.data_, data_);
+ } catch (std::string str) {
+ std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
+ if(str == msg) {
+ result.clear();
+ typedef typename coordinate_traits<Unit>::manhattan_area_type Unit2;
+ typedef typename polygon_45_formation<Unit2>::Vertex45Compact Vertex45Compact2;
+ typedef std::vector<Vertex45Compact2> Data2;
+ Data2 lvalue_data, result_data;
+ lvalue_data.reserve(data_.size());
+ for(unsigned int i = 0 ; i < data_.size(); ++i) {
+ const Vertex45Compact& vi = data_[i];
+ Vertex45Compact2 ci;
+ ci.pt = point_data<Unit2>(x(vi.pt), y(vi.pt));
+ ci.count = typename polygon_45_formation<Unit2>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ lvalue_data.push_back(ci);
+ }
+ scale_up_vertex_45_compact_range(lvalue_data.begin(), lvalue_data.end(), 2);
+ bool result_is_manhattan = applyUnary45OpOnVectors<Unit2, op>(result_data,
+ lvalue_data );
+ if(!result_is_manhattan) {
+ typename polygon_45_formation<Unit2>::Polygon45Formation pf(false);
+ //std::cout << "FORMING POLYGONS\n";
+ std::vector<polygon_45_with_holes_data<Unit2> > container;
+ pf.scan(container, result_data.begin(), result_data.end());
+ Data2 error_data_out;
+ std::vector<rectangle_data<Unit2> > pos_error_rects;
+ std::vector<rectangle_data<Unit2> > neg_error_rects;
+ for(unsigned int i = 0; i < container.size(); ++i) {
+ get_error_rects(pos_error_rects, neg_error_rects, container[i]);
+ }
+ for(unsigned int i = 0; i < pos_error_rects.size(); ++i) {
+ insert_rectangle_into_vector_45(result_data, pos_error_rects[i], false);
+ insert_rectangle_into_vector_45(error_data_out, pos_error_rects[i], false);
+ }
+ for(unsigned int i = 0; i < neg_error_rects.size(); ++i) {
+ insert_rectangle_into_vector_45(result_data, neg_error_rects[i], true);
+ insert_rectangle_into_vector_45(error_data_out, neg_error_rects[i], false);
+ }
+ scale_down_vertex_45_compact_range_blindly(error_data_out.begin(), error_data_out.end(), 2);
+ for(unsigned int i = 0 ; i < error_data_out.size(); ++i) {
+ const Vertex45Compact2& vi = error_data_out[i];
+ Vertex45Compact ci;
+ ci.pt = (point_data<Unit2>(x(vi.pt), y(vi.pt)));
+ ci.count = typename polygon_45_formation<Unit>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ result.error_data_.push_back(ci);
+ }
+ Data2 new_result_data;
+ std::sort(result_data.begin(), result_data.end());
+ applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
+ result_data.swap(new_result_data);
+ }
+ scale_down_vertex_45_compact_range_blindly(result_data.begin(), result_data.end(), 2);
+ //result.data_.reserve(result_data.size());
+ for(unsigned int i = 0 ; i < result_data.size(); ++i) {
+ const Vertex45Compact2& vi = result_data[i];
+ Vertex45Compact ci;
+ ci.pt = (point_data<Unit2>(x(vi.pt), y(vi.pt)));
+ ci.count = typename polygon_45_formation<Unit>::Vertex45Count
+ ( vi.count[0], vi.count[1], vi.count[2], vi.count[3]);
+ result.data_.push_back(ci);
+ }
+ result.is_manhattan_ = result_is_manhattan;
+ result.dirty_ = false;
+ result.unsorted_ = false;
+ } else { throw str; }
+ }
+ //std::cout << "DONE SCANNING\n";
+ }
+ data_.swap(result.data_);
+ error_data_.swap(result.error_data_);
+ dirty_ = result.dirty_;
+ unsorted_ = result.unsorted_;
+ is_manhattan_ = result.is_manhattan_;
+ }
template <typename Unit>
inline std::ostream& operator<< (std::ostream& o, const polygon_45_set_data<Unit>& p) {
@@ -1242,7 +1724,6 @@
return i;
}
-
}
#endif
Modified: sandbox/gtl/gtl/polygon_45_set_view.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_set_view.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_set_view.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -29,6 +29,43 @@
};
+ template <typename value_type, typename ltype, typename rtype, int op_type>
+ struct compute_45_set_value {
+ static
+ void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_) {
+ output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
+ polygon_45_set_traits<ltype>::end(lvalue_));
+ value_type rinput_;
+ rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
+ polygon_45_set_traits<rtype>::end(rvalue_));
+ if(op_type == 0)
+ output_ |= rinput_;
+ else if(op_type == 1)
+ output_ &= rinput_;
+ else if(op_type == 2)
+ output_ ^= rinput_;
+ else
+ output_ -= rinput_;
+ }
+ };
+
+ template <typename value_type, typename ltype, typename rcoord, int op_type>
+ struct compute_45_set_value<value_type, ltype, polygon_45_set_data<rcoord>, op_type> {
+ static
+ void value(value_type& output_, const ltype& lvalue_, const polygon_45_set_data<rcoord>& rvalue_) {
+ output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
+ polygon_45_set_traits<ltype>::end(lvalue_));
+ if(op_type == 0)
+ output_ |= rvalue_;
+ else if(op_type == 1)
+ output_ &= rvalue_;
+ else if(op_type == 2)
+ output_ ^= rvalue_;
+ else
+ output_ -= rvalue_;
+ }
+ };
+
template <typename ltype, typename rtype, int op_type>
class polygon_45_set_view {
public:
@@ -43,28 +80,15 @@
mutable bool evaluated_;
public:
polygon_45_set_view(const ltype& lvalue,
- const rtype& rvalue ) :
+ const rtype& rvalue ) :
lvalue_(lvalue), rvalue_(rvalue), evaluated_(false) {}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
public:
const value_type& value() const {
if(!evaluated_) {
evaluated_ = true;
- value_type rinput_;
- output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
- polygon_45_set_traits<ltype>::end(lvalue_));
- //polygon_45_set_traits<rtype>::clean(rvalue_);
- rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
- polygon_45_set_traits<rtype>::end(rvalue_));
- if(op_type == 0)
- output_ |= rinput_;
- else if(op_type == 1)
- output_ &= rinput_;
- else if(op_type == 2)
- output_ ^= rinput_;
- else
- output_ -= rinput_;
+ compute_45_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_);
}
return output_;
}
@@ -75,14 +99,14 @@
bool dirty() const { return value().dirty(); } //result of a boolean is clean
bool sorted() const { return value().sorted(); } //result of a boolean is sorted
-// template <typename input_iterator_type>
-// void set(input_iterator_type input_begin, input_iterator_type input_end,
-// orientation_2d orient) const {
-// orient_ = orient;
-// output_.clear();
-// output_.insert(output_.end(), input_begin, input_end);
-// std::sort(output_.begin(), output_.end());
-// }
+ // template <typename input_iterator_type>
+ // void set(input_iterator_type input_begin, input_iterator_type input_end,
+ // orientation_2d orient) const {
+ // orient_ = orient;
+ // output_.clear();
+ // output_.insert(output_.end(), input_begin, input_end);
+ // std::sort(output_.begin(), output_.end());
+ // }
};
template <typename ltype, typename rtype, int op_type>
@@ -143,9 +167,10 @@
struct geometry_concept<polygon_45_set_view<ltype, rtype, op_type> > { typedef polygon_45_set_concept type; };
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3<
+ typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+ typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type
operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
@@ -153,19 +178,28 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
- polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type
+ typename requires_1< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type
operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+ typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_45_set_view<geometry_type_1, geometry_type_2, 1> >::type
operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_45_set_view<geometry_type_1, geometry_type_2, 1>
@@ -173,9 +207,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+ typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_45_set_view<geometry_type_1, geometry_type_2, 2> >::type
operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_45_set_view<geometry_type_1, geometry_type_2, 2>
@@ -183,100 +217,125 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
- polygon_45_set_view<geometry_type_1, geometry_type_2, 3> >::type
+ typename requires_1< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 3> >::type
operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_45_set_view<geometry_type_1, geometry_type_2, 3>
(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
- geometry_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ geometry_type_1>::type &
operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 2>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 3>(lvalue, rvalue);
}
template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_polygon_45_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- polygon_45_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> >::type
- operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
- polygon_45_set_data<typename polygon_45_set_traits<geometry_type_1>::coordinate_type> ps;
- assign(ps, lvalue);
- resize(ps, rvalue);
- return ps;
- }
-
- template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_polygon_45_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- polygon_45_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> >::type
- operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
- polygon_45_set_data<typename polygon_45_set_traits<geometry_type_1>::coordinate_type> ps;
- assign(ps, lvalue);
- resize(ps, -rvalue);
- return ps;
- }
-
- template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type,
+ coordinate_concept>::type>::type,
geometry_type_1>::type &
operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
return resize(lvalue, rvalue);
}
template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
+ typename requires_1< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type,
+ coordinate_concept>::type>::type,
geometry_type_1>::type &
operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
return resize(lvalue, -rvalue);
}
+
+ template <typename geometry_type_1, typename coordinate_type_1>
+ typename requires_1< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type,
+ coordinate_concept>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, geometry_type_1>::type
+ operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+ geometry_type_1 retval(lvalue);
+ retval += rvalue;
+ return retval;
+ }
+
+ template <typename geometry_type_1, typename coordinate_type_1>
+ typename requires_1< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type,
+ coordinate_concept>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, geometry_type_1>::type
+ operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+ geometry_type_1 retval(lvalue);
+ retval -= rvalue;
+ return retval;
+ }
}
#endif
Added: sandbox/gtl/gtl/polygon_45_touch.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/gtl/polygon_45_touch.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -0,0 +1,275 @@
+/*
+ Copyright 2008 Intel Corporation
+
+ Use, modification and distribution are subject to the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt).
+*/
+#ifndef GTL_POLYGON_45_TOUCH_HPP
+#define GTL_POLYGON_45_TOUCH_HPP
+namespace gtl {
+
+ template <typename Unit>
+ struct polygon_45_touch {
+
+ typedef point_data<Unit> Point;
+ typedef typename coordinate_traits<Unit>::manhattan_area_type LongUnit;
+
+ template <typename property_map>
+ static inline void merge_property_maps(property_map& mp, const property_map& mp2, bool subtract = false) {
+ property_map newmp;
+ newmp.reserve(mp.size() + mp2.size());
+ unsigned int i = 0;
+ unsigned int j = 0;
+ while(i != mp.size() && j != mp2.size()) {
+ if(mp[i].first < mp2[j].first) {
+ newmp.push_back(mp[i]);
+ ++i;
+ } else if(mp[i].first > mp2[j].first) {
+ newmp.push_back(mp2[j]);
+ if(subtract) newmp.back().second *= -1;
+ ++j;
+ } else {
+ int count = mp[i].second;
+ if(subtract) count -= mp2[j].second;
+ else count += mp2[j].second;
+ if(count) {
+ newmp.push_back(mp[i]);
+ newmp.back().second = count;
+ }
+ ++i;
+ ++j;
+ }
+ }
+ while(i != mp.size()) {
+ newmp.push_back(mp[i]);
+ ++i;
+ }
+ while(j != mp2.size()) {
+ newmp.push_back(mp2[j]);
+ if(subtract) newmp.back().second *= -1;
+ ++j;
+ }
+ mp.swap(newmp);
+ }
+
+ class CountTouch {
+ public:
+ inline CountTouch() {}
+ //inline CountTouch(int count) { counts[0] = counts[1] = count; }
+ //inline CountTouch(int count1, int count2) { counts[0] = count1; counts[1] = count2; }
+ inline CountTouch(const CountTouch& count) : counts(count.counts) {}
+ inline bool operator==(const CountTouch& count) const { return counts == count.counts; }
+ inline bool operator!=(const CountTouch& count) const { return !((*this) == count); }
+ //inline CountTouch& operator=(int count) { counts[0] = counts[1] = count; return *this; }
+ inline CountTouch& operator=(const CountTouch& count) { counts = count.counts; return *this; }
+ inline int& operator[](int index) {
+ std::vector<std::pair<int, int> >::iterator itr = lower_bound(counts.begin(), counts.end(), std::make_pair(index, int(0)));
+ if(itr != counts.end() && itr->first == index) {
+ return itr->second;
+ }
+ itr = counts.insert(itr, std::make_pair(index, int(0)));
+ return itr->second;
+ }
+// inline int operator[](int index) const {
+// std::vector<std::pair<int, int> >::const_iterator itr = counts.begin();
+// for( ; itr != counts.end() && itr->first <= index; ++itr) {
+// if(itr->first == index) {
+// return itr->second;
+// }
+// }
+// return 0;
+// }
+ inline CountTouch& operator+=(const CountTouch& count){
+ merge_property_maps(counts, count.counts, false);
+ return *this;
+ }
+ inline CountTouch& operator-=(const CountTouch& count){
+ merge_property_maps(counts, count.counts, true);
+ return *this;
+ }
+ inline CountTouch operator+(const CountTouch& count) const {
+ return CountTouch(*this)+=count;
+ }
+ inline CountTouch operator-(const CountTouch& count) const {
+ return CountTouch(*this)-=count;
+ }
+ inline CountTouch invert() const {
+ CountTouch retval;
+ retval -= *this;
+ return retval;
+ }
+ std::vector<std::pair<int, int> > counts;
+ };
+
+ typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::map<int, std::set<int> > > map_graph_o;
+ typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::vector<std::set<int> > > vector_graph_o;
+
+ template <typename cT>
+ static void process_previous_x(cT& output) {
+ std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
+ for(typename std::map<Unit, std::set<int> >::iterator itr = y_prop_map.begin();
+ itr != y_prop_map.end(); ++itr) {
+ for(std::set<int>::iterator inner_itr = itr->second.begin();
+ inner_itr != itr->second.end(); ++inner_itr) {
+ std::set<int>& output_edges = (*(output.second))[*inner_itr];
+ std::set<int>::iterator inner_inner_itr = inner_itr;
+ ++inner_inner_itr;
+ for( ; inner_inner_itr != itr->second.end(); ++inner_inner_itr) {
+ output_edges.insert(output_edges.end(), *inner_inner_itr);
+ std::set<int>& output_edges_2 = (*(output.second))[*inner_inner_itr];
+ output_edges_2.insert(output_edges_2.end(), *inner_itr);
+ }
+ }
+ }
+ y_prop_map.clear();
+ }
+
+ struct touch_45_output_functor {
+ template <typename cT>
+ void operator()(cT& output, const CountTouch& count1, const CountTouch& count2,
+ const Point& pt, int rise, direction_1d end) {
+ Unit& x = output.first.first;
+ std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
+ if(pt.x() != x) process_previous_x(output);
+ x = pt.x();
+ std::set<int>& output_set = y_prop_map[pt.y()];
+ for(std::vector<std::pair<int, int> >::const_iterator itr1 = count1.counts.begin();
+ itr1 != count1.counts.end(); ++itr1) {
+ if(itr1->second > 0) {
+ output_set.insert(output_set.end(), itr1->first);
+ }
+ }
+ for(std::vector<std::pair<int, int> >::const_iterator itr2 = count2.counts.begin();
+ itr2 != count2.counts.end(); ++itr2) {
+ if(itr2->second > 0) {
+ output_set.insert(output_set.end(), itr2->first);
+ }
+ }
+ }
+ };
+ typedef typename std::pair<Point,
+ typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > Vertex45Compact;
+ typedef std::vector<Vertex45Compact> TouchSetData;
+
+ struct lessVertex45Compact {
+ bool operator()(const Vertex45Compact& l, const Vertex45Compact& r) {
+ return l.first < r.first;
+ }
+ };
+
+ template <typename TSD>
+ static void print_tsd(TSD& tsd) {
+ for(unsigned int i = 0; i < tsd.size(); ++i) {
+ std::cout << tsd[i].first << ": ";
+ for(unsigned int r = 0; r < 4; ++r) {
+ std::cout << r << " { ";
+ for(std::vector<std::pair<int, int> >::iterator itr = tsd[i].second[r].counts.begin();
+ itr != tsd[i].second[r].counts.end(); ++itr) {
+ std::cout << itr->first << "," << itr->second << " ";
+ } std::cout << "} ";
+ }
+ } std::cout << std::endl;
+ }
+
+ template <typename T>
+ static void print_scanline(T& t) {
+ for(typename T::iterator itr = t.begin(); itr != t.end(); ++itr) {
+ std::cout << itr->x << "," << itr->y << " " << itr->rise << " ";
+ for(std::vector<std::pair<int, int> >::iterator itr2 = itr->count.counts.begin();
+ itr2 != itr->count.counts.end(); ++itr2) {
+ std::cout << itr2->first << ":" << itr2->second << " ";
+ } std::cout << std::endl;
+ }
+ }
+
+ template <typename graph_type>
+ static void performTouch(graph_type& graph, TouchSetData& tsd) {
+
+ std::sort(tsd.begin(), tsd.end(), lessVertex45Compact());
+ typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > > TSD;
+ TSD tsd_;
+ tsd_.reserve(tsd.size());
+ for(typename TouchSetData::iterator itr = tsd.begin(); itr != tsd.end(); ) {
+ typename TouchSetData::iterator itr2 = itr;
+ ++itr2;
+ for(; itr2 != tsd.end() && itr2->first == itr->first; ++itr2) {
+ (itr->second) += (itr2->second); //accumulate
+ }
+ tsd_.push_back(std::make_pair(itr->first, itr->second));
+ itr = itr2;
+ }
+ std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, graph_type*> output
+ (std::make_pair(std::make_pair(std::numeric_limits<Unit>::max(), std::map<Unit, std::set<int> >()), &graph));
+ typename boolean_op_45<Unit>::template Scan45<CountTouch, touch_45_output_functor> scanline;
+ for(typename TSD::iterator itr = tsd_.begin(); itr != tsd_.end(); ) {
+ typename TSD::iterator itr2 = itr;
+ ++itr2;
+ while(itr2 != tsd_.end() && itr2->first.x() == itr->first.x()) {
+ ++itr2;
+ }
+ scanline.scan(output, itr, itr2);
+ itr = itr2;
+ }
+ process_previous_x(output);
+ }
+
+ template <typename iT>
+ static void populateTouchSetData(TouchSetData& tsd, iT begin, iT end, int nodeCount) {
+ for( ; begin != end; ++begin) {
+ Vertex45Compact vertex;
+ vertex.first = typename Vertex45Compact::first_type(begin->pt.x() * 2, begin->pt.y() * 2);
+ tsd.push_back(vertex);
+ for(unsigned int i = 0; i < 4; ++i) {
+ if(begin->count[i]) {
+ tsd.back().second[i][nodeCount] += begin->count[i];
+ }
+ }
+ }
+ }
+
+ };
+
+ //ConnectivityExtraction computes the graph of connectivity between rectangle, polygon and
+ //polygon set graph nodes where an edge is created whenever the geometry in two nodes overlap
+ template <typename coordinate_type>
+ class connectivity_extraction_45 {
+ private:
+ typedef typename coordinate_traits<coordinate_type>::manhattan_area_type big_coord;
+ typedef typename polygon_45_touch<big_coord>::TouchSetData tsd;
+ tsd tsd_;
+ unsigned int nodeCount_;
+ public:
+ inline connectivity_extraction_45() : nodeCount_(0) {}
+ inline connectivity_extraction_45(const connectivity_extraction_45& that) : tsd_(that.tsd_),
+ nodeCount_(that.nodeCount_) {}
+ inline connectivity_extraction_45& operator=(const connectivity_extraction_45& that) {
+ tsd_ = that.tsd_;
+ nodeCount_ = that.nodeCount_; {}
+ return *this;
+ }
+
+ //insert a polygon set graph node, the value returned is the id of the graph node
+ inline unsigned int insert(const polygon_45_set_data<coordinate_type>& ps) {
+ ps.clean();
+ polygon_45_touch<big_coord>::populateTouchSetData(tsd_, ps.begin(), ps.end(), nodeCount_);
+ return nodeCount_++;
+ }
+ template <class GeoObjT>
+ inline unsigned int insert(const GeoObjT& geoObj) {
+ polygon_45_set_data<coordinate_type> ps;
+ ps.insert(geoObj);
+ return insert(ps);
+ }
+
+ //extract connectivity and store the edges in the graph
+ //graph must be indexable by graph node id and the indexed value must be a std::set of
+ //graph node id
+ template <class GraphT>
+ inline void extract(GraphT& graph) {
+ polygon_45_touch<big_coord>::performTouch(graph, tsd_);
+ }
+ };
+
+}
+#endif
Modified: sandbox/gtl/gtl/polygon_45_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_with_holes_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_with_holes_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -20,7 +20,7 @@
typedef typename coordinate_traits<T>::coordinate_distance area_type;
typedef point_data<T> point_type;
- /// default constructor of point does not initialize x and y
+ // default constructor of point does not initialize x and y
inline polygon_45_with_holes_data(){;} //do nothing default constructor
template<class iT>
@@ -40,8 +40,8 @@
return *this;
}
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline polygon_45_with_holes_data& set_holes(iT input_begin, iT input_end) {
holes_.clear(); //just in case there was some old data there
@@ -52,23 +52,23 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline polygon_45_with_holes_data(const polygon_45_with_holes_data& that) : self_(that.self_),
holes_(that.holes_) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline polygon_45_with_holes_data& operator=(const polygon_45_with_holes_data& that) {
self_ = that.self_;
holes_ = that.holes_;
return *this;
}
- /// get begin iterator, returns a pointer to a const coordinate_type
+ // get begin iterator, returns a pointer to a const coordinate_type
inline const iterator_type begin() const {
return self_.begin();
}
- /// get end iterator, returns a pointer to a const coordinate_type
+ // get end iterator, returns a pointer to a const coordinate_type
inline const iterator_type end() const {
return self_.end();
}
@@ -77,12 +77,12 @@
return self_.size();
}
- /// get begin iterator, returns a pointer to a const polygon
+ // get begin iterator, returns a pointer to a const polygon
inline const iterator_holes_type begin_holes() const {
return holes_.begin();
}
- /// get end iterator, returns a pointer to a const polygon
+ // get end iterator, returns a pointer to a const polygon
inline const iterator_holes_type end_holes() const {
return holes_.end();
}
Modified: sandbox/gtl/gtl/polygon_90_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -20,12 +20,12 @@
inline polygon_90_data(){;} //do nothing default constructor
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline polygon_90_data& set(iT begin_point, iT end_point) {
- return set_compact(iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(begin_point),
- iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(end_point));
+ return set_compact(iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(begin_point, end_point),
+ iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(end_point, end_point));
}
template<class iT>
@@ -38,10 +38,10 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline polygon_90_data(const polygon_90_data& that) : coords_(that.coords_) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline polygon_90_data& operator=(const polygon_90_data& that) {
coords_ = that.coords_;
return *this;
@@ -50,21 +50,21 @@
template <typename T2>
inline polygon_90_data& operator=(const T2& rvalue);
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline bool operator==(const polygon_90_data& that) const {
return coords_ == that.coords_;
}
- /// get begin iterator, returns a pointer to a const Unit
+ // get begin iterator, returns a pointer to a const Unit
inline iterator_type begin() const { return iterator_type(coords_.begin(), coords_.end()); }
- /// get end iterator, returns a pointer to a const Unit
+ // get end iterator, returns a pointer to a const Unit
inline iterator_type end() const { return iterator_type(coords_.end(), coords_.end()); }
- /// get begin iterator, returns a pointer to a const Unit
+ // get begin iterator, returns a pointer to a const Unit
inline compact_iterator_type begin_compact() const { return coords_.begin(); }
- /// get end iterator, returns a pointer to a const Unit
+ // get end iterator, returns a pointer to a const Unit
inline compact_iterator_type end_compact() const { return coords_.end(); }
inline std::size_t size() const { return coords_.size(); }
@@ -128,12 +128,5 @@
}
-namespace std {
-template <typename T>
-void swap(gtl::polygon_90_data<T>& l, gtl::polygon_90_data<T>& r) {
- l.swap(r);
-}
-
-}
#endif
Modified: sandbox/gtl/gtl/polygon_90_set_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_set_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_set_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -10,28 +10,28 @@
namespace gtl {
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<polygon_set_type>::type,
typename polygon_90_set_traits<polygon_set_type>::iterator_type>::type
begin_90_set_data(const polygon_set_type& polygon_set) {
return polygon_90_set_traits<polygon_set_type>::begin(polygon_set);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<polygon_set_type>::type,
typename polygon_90_set_traits<polygon_set_type>::iterator_type>::type
end_90_set_data(const polygon_set_type& polygon_set) {
return polygon_90_set_traits<polygon_set_type>::end(polygon_set);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<polygon_set_type>::type,
orientation_2d>::type
scanline_orientation(const polygon_set_type& polygon_set) {
return polygon_90_set_traits<polygon_set_type>::orient(polygon_set);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<polygon_set_type>::type,
bool>::type
clean(const polygon_set_type& polygon_set) {
return polygon_90_set_traits<polygon_set_type>::clean(polygon_set);
@@ -39,28 +39,32 @@
//assign
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<polygon_set_type_2>::type>::type,
- polygon_set_type_1>::type &
+ typename requires_1 <
+ typename gtl_and<
+ typename is_mutable_polygon_90_set_type<polygon_set_type_1>::type,
+ typename is_polygon_90_set_type<polygon_set_type_2>::type>::type,
+ polygon_set_type_1>::type &
assign(polygon_set_type_1& lvalue, const polygon_set_type_2& rvalue) {
- polygon_90_set_mutable_traits<polygon_set_type_1>::set(lvalue, begin_90_set_data(rvalue), end_90_set_data(rvalue), scanline_orientation(rvalue));
+ polygon_90_set_mutable_traits<polygon_set_type_1>::set(lvalue, begin_90_set_data(rvalue), end_90_set_data(rvalue),
+ scanline_orientation(rvalue));
return lvalue;
}
template <typename T1, typename T2>
- struct are_not_both_rectangle_concept { typedef void type; };
+ struct are_not_both_rectangle_concept { typedef gtl_yes type; };
template <>
- struct are_not_both_rectangle_concept<rectangle_concept, rectangle_concept> {};
+ struct are_not_both_rectangle_concept<rectangle_concept, rectangle_concept> { typedef gtl_no type; };
//equivalence
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_3< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<polygon_set_type_2>::type>::type,
- typename are_not_both_rectangle_concept<typename geometry_concept<polygon_set_type_1>::type,
- typename geometry_concept<polygon_set_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3<
+ typename is_polygon_90_set_type<polygon_set_type_1>::type,
+ typename is_polygon_90_set_type<polygon_set_type_2>::type,
+ typename are_not_both_rectangle_concept<typename geometry_concept<polygon_set_type_1>::type,
+ typename geometry_concept<polygon_set_type_2>::type>::type>::type,
bool>::type
equivalence(const polygon_set_type_1& lvalue,
- const polygon_set_type_2& rvalue) {
+ const polygon_set_type_2& rvalue) {
polygon_90_set_data<typename polygon_90_set_traits<polygon_set_type_1>::coordinate_type> ps1;
assign(ps1, lvalue);
polygon_90_set_data<typename polygon_90_set_traits<polygon_set_type_2>::coordinate_type> ps2;
@@ -68,32 +72,56 @@
return ps1 == ps2;
}
+
+ //get rectangle tiles (slicing orientation is vertical)
+ template <typename output_container_type, typename polygon_set_type>
+ typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ void>::type
+ get_rectangles(output_container_type& output, const polygon_set_type& polygon_set) {
+ clean(polygon_set);
+ polygon_90_set_data<typename polygon_90_set_traits<polygon_set_type>::coordinate_type> ps(VERTICAL);
+ assign(ps, polygon_set);
+ ps.get_rectangles(output);
+ }
+
+ //get rectangle tiles
+ template <typename output_container_type, typename polygon_set_type>
+ typename requires_1< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
+ void>::type
+ get_rectangles(output_container_type& output, const polygon_set_type& polygon_set, orientation_2d slicing_orientation) {
+ clean(polygon_set);
+ polygon_90_set_data<typename polygon_90_set_traits<polygon_set_type>::coordinate_type> ps;
+ assign(ps, polygon_set);
+ ps.get_rectangles(output, slicing_orientation);
+ }
+
//get: min_rectangles max_rectangles
template <typename output_container_type, typename polygon_set_type>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<polygon_set_type>::type>::type,
- typename is_same_type_SFINAE<rectangle_concept,
- typename geometry_concept
- <typename std::iterator_traits
- <typename output_container_type::iterator>::value_type>::type>::type,
+ typename requires_1 <typename gtl_and<
+ typename is_polygon_90_set_type<polygon_set_type>::type,
+ typename gtl_same_type<rectangle_concept,
+ typename geometry_concept
+ <typename std::iterator_traits
+ <typename output_container_type::iterator>::value_type>::type>::type>::type,
void>::type
get_max_rectangles(output_container_type& output, const polygon_set_type& polygon_set) {
std::vector<rectangle_data<typename polygon_90_set_traits<polygon_set_type>::coordinate_type> > rects;
assign(rects, polygon_set);
MaxCover<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::getMaxCover(output, rects, scanline_orientation(polygon_set));
}
-
+
//clear
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
void>::type
clear(polygon_set_type& polygon_set) {
polygon_90_set_data<typename polygon_90_set_traits<polygon_set_type>::coordinate_type> ps(scanline_orientation(polygon_set));
assign(polygon_set, ps);
}
-
+
//empty
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
bool>::type
empty(const polygon_set_type& polygon_set) {
if(clean(polygon_set)) return begin_90_set_data(polygon_set) == end_90_set_data(polygon_set);
@@ -105,24 +133,20 @@
//extents
template <typename polygon_set_type, typename rectangle_type>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
- typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1 <typename gtl_and< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
bool>::type
extents(rectangle_type& extents_rectangle,
const polygon_set_type& polygon_set) {
- std::vector<rectangle_type> rects;
- assign(rects, polygon_set);
- if(rects.empty()) return false;
- extents_rectangle = rects[0];
- for(unsigned int i = 1; i < rects.size(); ++i) {
- encompass(extents_rectangle, rects[i]);
- }
- return true;
+ typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ return ps.extents(extents_rectangle);
}
//area
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::manhattan_area_type>::type
area(const polygon_set_type& polygon_set) {
typedef rectangle_data<typename polygon_90_set_traits<polygon_set_type>::coordinate_type> rectangle_type;
@@ -138,52 +162,48 @@
//interact
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type_2>::type>::type,
+ typename requires_1 <typename gtl_and< typename is_mutable_polygon_90_set_type<polygon_set_type_1>::type,
+ typename is_mutable_polygon_90_set_type<polygon_set_type_2>::type>::type,
polygon_set_type_1>::type
interact(polygon_set_type_1& polygon_set_1, const polygon_set_type_2& polygon_set_2) {
typedef typename polygon_90_set_traits<polygon_set_type_1>::coordinate_type Unit;
- typename touch_90_operation<Unit>::TouchSetData tsd;
polygon_90_set_data<Unit> ps(scanline_orientation(polygon_set_2));
- assign(ps, polygon_set_1);
- touch_90_operation<Unit>::populateTouchSetData(tsd, begin_90_set_data(ps), end_90_set_data(ps), 0);
- std::vector<polygon_90_data<Unit> > polys;
- assign(polys, polygon_set_1);
- std::vector<std::set<int> > graph(polys.size()+1, std::set<int>());
- for(unsigned int i = 0; i < polys.size(); ++i){
- polygon_90_set_data<Unit> psTmp(scanline_orientation(polygon_set_2));
- psTmp.insert(polys[i]);
- psTmp.clean();
- touch_90_operation<Unit>::populateTouchSetData(tsd, psTmp.begin(), psTmp.end(), i+1);
- }
- touch_90_operation<Unit>::performTouch(graph, tsd);
- clear(polygon_set_1);
- ps.clear();
- for(std::set<int>::iterator itr = graph[0].begin(); itr != graph[0].end(); ++itr){
- ps.insert(polys[(*itr)-1]);
- }
+ polygon_90_set_data<Unit> ps2(ps);
+ ps.insert(polygon_set_1);
+ ps2.insert(polygon_set_2);
+ ps.interact(ps2);
assign(polygon_set_1, ps);
return polygon_set_1;
}
//self_intersect
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
self_intersect(polygon_set_type& polygon_set) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
polygon_90_set_data<Unit> ps;
assign(ps, polygon_set);
- interval_data<Unit> ivl(std::numeric_limits<Unit>::min(), std::numeric_limits<Unit>::max());
- rectangle_data<Unit> rect(ivl, ivl);
- ps.insert(rect, true);
- ps.clean();
+ ps.self_intersect();
assign(polygon_set, ps);
return polygon_set;
}
+ //self_xor
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ self_xor(polygon_set_type& polygon_set) {
+ typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.self_xor();
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
+ template <typename polygon_set_type>
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
@@ -191,7 +211,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set, orientation_2d orient,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
@@ -201,7 +221,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set, orientation_2d orient,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type low_bloating,
@@ -212,7 +232,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set, direction_2d dir,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
@@ -226,7 +246,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
bloat(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type west_bloating,
@@ -234,28 +254,16 @@
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type south_bloating,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type north_bloating) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
- std::vector<rectangle_data<Unit> > rects;
- if(!clean(polygon_set)) {
- polygon_90_set_data<Unit> ps;
- assign(ps, polygon_set);
- clean(ps);
- assign(rects, ps);
- } else {
- assign(rects, polygon_set);
- }
- rectangle_data<Unit> convolutionRectangle(interval_data<Unit>(-((Unit)west_bloating), (Unit)east_bloating),
- interval_data<Unit>(-((Unit)south_bloating), (Unit)north_bloating));
- for(typename std::vector<rectangle_data<Unit> >::iterator itr = rects.begin();
- itr != rects.end(); ++itr) {
- convolve(*itr, convolutionRectangle);
- }
- clear(polygon_set);
- assign(polygon_set, rects);
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.bloat(west_bloating, east_bloating, south_bloating, north_bloating);
+ ps.clean();
+ assign(polygon_set, ps);
return polygon_set;
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type shrinking) {
@@ -263,7 +271,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set, orientation_2d orient,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type shrinking) {
@@ -273,7 +281,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set, orientation_2d orient,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type low_shrinking,
@@ -284,7 +292,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set, direction_2d dir,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type shrinking) {
@@ -298,7 +306,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
shrink(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type west_shrinking,
@@ -308,36 +316,14 @@
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
polygon_90_set_data<Unit> ps;
assign(ps, polygon_set);
+ ps.shrink(west_shrinking, east_shrinking, south_shrinking, north_shrinking);
ps.clean();
- rectangle_data<Unit> externalBoundary;
- if(!extents(externalBoundary, ps)) return polygon_set;
- bloat(externalBoundary, 10); //bloat by diferential ammount
- //insert a hole that encompasses the data
- ps.insert(externalBoundary, true); //note that the set is in a dirty state now
- ps.sort(); //does not apply implicit or operation
- std::vector<rectangle_data<Unit> > rects;
- //begin does not apply implicit or operation, this is a dirty range
- get_rectangles(rects, ps.begin(), ps.end(), scanline_orientation(ps), rectangle_concept());
- ps.clear();
- rectangle_data<Unit> convolutionRectangle(interval_data<Unit>(-((Unit)east_shrinking), (Unit)west_shrinking),
- interval_data<Unit>(-((Unit)north_shrinking), (Unit)south_shrinking));
- for(typename std::vector<rectangle_data<Unit> >::iterator itr = rects.begin();
- itr != rects.end(); ++itr) {
- rectangle_data<Unit>& rect = *itr;
- convolve(rect, convolutionRectangle);
- //insert rectangle as a hole
- ps.insert(rect, true);
- }
- convolve(externalBoundary, convolutionRectangle);
- //insert duplicate of external boundary as solid to cancel out the external hole boundaries
- ps.insert(externalBoundary);
- ps.clean(); //we have negative values in the set, so we need to apply an OR operation to make it valid input to a boolean
assign(polygon_set, ps);
return polygon_set;
}
template <typename polygon_set_type, typename coord_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
resize(polygon_set_type& polygon_set, coord_type resizing) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
@@ -350,40 +336,53 @@
return polygon_set;
}
+ //positive or negative values allow for any and all directions of sizing
+ template <typename polygon_set_type, typename coord_type>
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ resize(polygon_set_type& polygon_set, coord_type west, coord_type east, coord_type south, coord_type north) {
+ typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.resize(west, east, south, north);
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
grow_and(polygon_set_type& polygon_set,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
return grow_and(polygon_set, bloating, bloating, bloating, bloating);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
grow_and(polygon_set_type& polygon_set, orientation_2d orient,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
if(orient == orientation_2d(HORIZONTAL))
return grow_and(polygon_set, bloating, bloating, 0, 0);
return grow_and(polygon_set, 0, 0, bloating, bloating);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
grow_and(polygon_set_type& polygon_set, orientation_2d orient,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type low_bloating,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type high_bloating) {
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type low_bloating,
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type high_bloating) {
if(orient == orientation_2d(HORIZONTAL))
return grow_and(polygon_set, low_bloating, high_bloating, 0, 0);
return grow_and(polygon_set, 0, 0, low_bloating, high_bloating);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
grow_and(polygon_set_type& polygon_set, direction_2d dir,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
if(dir == direction_2d(EAST))
return grow_and(polygon_set, 0, bloating, 0, 0);
if(dir == direction_2d(WEST))
@@ -397,10 +396,10 @@
typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
polygon_set_type>::type &
grow_and(polygon_set_type& polygon_set,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type west_bloating,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type east_bloating,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type south_bloating,
- typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type north_bloating) {
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type west_bloating,
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type east_bloating,
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type south_bloating,
+ typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type north_bloating) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
std::vector<polygon_90_data<Unit> > polys;
assign(polys, polygon_set);
@@ -419,106 +418,90 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_up(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>
::unsigned_area_type factor) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
- std::vector<std::pair<Unit, std::pair<Unit, int> > > tmpVec;
polygon_90_set_data<Unit> ps;
assign(ps, polygon_set);
- tmpVec.insert(tmpVec.begin(), ps.begin(), ps.end());
- for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = tmpVec.begin();
- itr != tmpVec.end(); ++itr) {
- (*itr).first *= (Unit)factor;
- (*itr).second.first *= (Unit)factor;
- }
- polygon_90_set_mutable_traits<polygon_set_type>::set(polygon_set, tmpVec.begin(), tmpVec.end(),
- scanline_orientation(polygon_set));
+ ps.scale_up(factor);
+ assign(polygon_set, ps);
return polygon_set;
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_down(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>
::unsigned_area_type factor) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- std::vector<std::pair<Unit, std::pair<Unit, int> > > tmpVec;
- polygon_90_set_data<Unit> ps(scanline_orientation(polygon_set));
+ polygon_90_set_data<Unit> ps;
assign(ps, polygon_set);
- tmpVec.insert(tmpVec.begin(), ps.begin(), ps.end());
- for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = tmpVec.begin();
- itr != tmpVec.end(); ++itr) {
- (*itr).first = scaling_policy<Unit>::round((dt)((*itr).first) / (dt)factor);
- (*itr).second.first = scaling_policy<Unit>::round((dt)((*itr).second.first) / (dt)factor);
- }
- ps.clear();
- ps.insert(tmpVec.begin(), tmpVec.end(), scanline_orientation(polygon_set));
- clean(ps);
+ ps.scale_down(factor);
assign(polygon_set, ps);
return polygon_set;
}
template <typename polygon_set_type, typename scaling_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale(polygon_set_type& polygon_set,
const scaling_type& scaling) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- std::vector<std::pair<Unit, std::pair<Unit, int> > > tmpVec;
- tmpVec.insert(tmpVec.begin(), begin_90_set_data(polygon_set), end_90_set_data(polygon_set));
- for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = tmpVec.begin();
- itr != tmpVec.end(); ++itr) {
- if(scanline_orientation(polygon_set) == orientation_2d(VERTICAL)) {
- scaling.scale((*itr).first, (*itr).second.first);
- } else {
- scaling.scale((*itr).second.first, (*itr).first);
- }
- }
- polygon_90_set_data<Unit> ps(scanline_orientation(polygon_set));
- ps.insert(tmpVec.begin(), tmpVec.end(), scanline_orientation(polygon_set));
- clean(ps);
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.scale(scaling);
+ assign(polygon_set, ps);
+ return polygon_set;
+ }
+
+ //move
+ template <typename polygon_set_type, typename coord_type>
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ move(polygon_set_type& polygon_set,
+ orientation_2d orient, coord_type displacement) {
+ if(orient == HORIZONTAL)
+ return move(polygon_set, displacement, 0);
+ else
+ return move(polygon_set, 0, displacement);
+ }
+
+ template <typename polygon_set_type, typename coord_type>
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
+ polygon_set_type>::type &
+ move(polygon_set_type& polygon_set, coord_type x_displacement, coord_type y_displacement) {
+ typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.move(x_displacement, y_displacement);
+ ps.clean();
assign(polygon_set, ps);
return polygon_set;
}
//transform
template <typename polygon_set_type, typename transformation_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
transform(polygon_set_type& polygon_set,
const transformation_type& transformation) {
typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- std::vector<std::pair<Unit, std::pair<Unit, int> > > tmpVec;
- tmpVec.insert(tmpVec.begin(), begin_90_set_data(polygon_set), end_90_set_data(polygon_set));
- direction_2d dir1, dir2;
- transformation.get_directions(dir1, dir2);
- int sign = dir1.get_sign() * dir2.get_sign();
- for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = tmpVec.begin();
- itr != tmpVec.end(); ++itr) {
- if(scanline_orientation(polygon_set) == orientation_2d(VERTICAL)) {
- transformation.transform((*itr).first, (*itr).second.first);
- } else {
- transformation.transform((*itr).second.first, (*itr).first);
- }
- (*itr).second.second *= sign;
- }
- polygon_90_set_data<Unit> ps(scanline_orientation(polygon_set));
- ps.insert(tmpVec.begin(), tmpVec.end(), scanline_orientation(polygon_set));
- clean(ps);
+ polygon_90_set_data<Unit> ps;
+ assign(ps, polygon_set);
+ ps.transform(transformation);
+ ps.clean();
assign(polygon_set, ps);
return polygon_set;
+ typedef typename polygon_90_set_traits<polygon_set_type>::coordinate_type Unit;
}
//keep
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_90_set_type<polygon_set_type>::type,
polygon_set_type>::type &
keep(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_90_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type min_area,
Modified: sandbox/gtl/gtl/polygon_90_set_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_set_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_set_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -19,13 +19,13 @@
typedef typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::const_iterator iterator_type;
typedef polygon_90_set_data operator_arg_type;
- /// default constructor
+ // default constructor
inline polygon_90_set_data() : orient_(HORIZONTAL), dirty_(false), unsorted_(false) {}
- /// constructor
+ // constructor
inline polygon_90_set_data(orientation_2d orient) : orient_(orient), dirty_(false), unsorted_(false) {}
- /// constructor from an iterator pair over vertex data
+ // constructor from an iterator pair over vertex data
template <typename iT>
inline polygon_90_set_data(orientation_2d orient, iT input_begin, iT input_end) {
dirty_ = true;
@@ -33,20 +33,23 @@
for( ; input_begin != input_end; ++input_begin) { insert(*input_begin); }
}
- /// copy constructor
+ // copy constructor
inline polygon_90_set_data(const polygon_90_set_data& that) :
orient_(that.orient_), data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_) {}
- /// copy with orientation change constructor
+ template <typename ltype, typename rtype, typename op_type>
+ inline polygon_90_set_data(const polygon_90_set_view<ltype, rtype, op_type>& that);
+
+ // copy with orientation change constructor
inline polygon_90_set_data(orientation_2d orient, const polygon_90_set_data& that) :
orient_(orient), dirty_(false), unsorted_(false) {
insert(that, false, that.orient_);
}
- /// destructor
+ // destructor
inline ~polygon_90_set_data() {}
- /// assignement operator
+ // assignement operator
inline polygon_90_set_data& operator=(const polygon_90_set_data& that) {
if(this == &that) return *this;
orient_ = that.orient_;
@@ -73,9 +76,9 @@
// return *this;
// }
- /// insert iterator range
+ // insert iterator range
template <typename iT>
- inline void insert(iT input_begin, iT input_end, orientation_2d orient) {
+ inline void insert(iT input_begin, iT input_end, orientation_2d orient = HORIZONTAL) {
if(input_begin == input_end) return;
dirty_ = true;
unsorted_ = true;
@@ -88,6 +91,19 @@
insert(polygon_set.begin(), polygon_set.end(), polygon_set.orient());
}
+ inline void insert(const std::pair<std::pair<point_data<coordinate_type>, point_data<coordinate_type> >, int>& edge, bool is_hole = false,
+ orientation_2d orient = HORIZONTAL) {
+ std::pair<coordinate_type, std::pair<coordinate_type, int> > vertex;
+ vertex.first = edge.first.first.x();
+ vertex.second.first = edge.first.first.y();
+ vertex.second.second = edge.second * (is_hole ? -1 : 1);
+ insert(vertex, false, VERTICAL);
+ vertex.first = edge.first.second.x();
+ vertex.second.first = edge.first.second.y();
+ vertex.second.second *= -1;
+ insert(vertex, false, VERTICAL);
+ }
+
template <typename geometry_type>
inline void insert(const geometry_type& geometry_object, bool is_hole = false, orientation_2d orient = HORIZONTAL) {
iterator_geometry_to_set<typename geometry_concept<geometry_type>::type, geometry_type>
@@ -120,7 +136,34 @@
get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type());
}
- /// equivalence operator
+ template <typename output_container>
+ inline void get_polygons(output_container& output) const {
+ get_dispatch(output, polygon_90_concept());
+ }
+
+ template <typename output_container>
+ inline void get_rectangles(output_container& output) const {
+ clean();
+ form_rectangles(output, data_.begin(), data_.end(), orient_, rectangle_concept());
+ }
+
+ template <typename output_container>
+ inline void get_rectangles(output_container& output, orientation_2d slicing_orientation) const {
+ if(slicing_orientation == orient_) {
+ get_rectangles(output);
+ } else {
+ polygon_90_set_data<coordinate_type> ps(*this);
+ ps.transform(axis_transformation(axis_transformation::SWAP_XY));
+ output_container result;
+ ps.get_rectangles(result);
+ for(typename output_container::iterator itr = result.begin(); itr != result.end(); ++itr) {
+ ::gtl::transform(*itr, axis_transformation(axis_transformation::SWAP_XY));
+ }
+ output.insert(output.end(), result.begin(), result.end());
+ }
+ }
+
+ // equivalence operator
inline bool operator==(const polygon_90_set_data& p) const {
if(orient_ == p.orient()) {
clean();
@@ -131,17 +174,17 @@
}
}
- /// inequivalence operator
+ // inequivalence operator
inline bool operator!=(const polygon_90_set_data& p) const {
return !((*this) == p);
}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
inline iterator_type begin() const {
return data_.begin();
}
- /// get iterator to end vertex data
+ // get iterator to end vertex data
inline iterator_type end() const {
return data_.end();
}
@@ -150,25 +193,25 @@
return data_;
}
- /// clear the contents of the polygon_90_set_data
+ // clear the contents of the polygon_90_set_data
inline void clear() { data_.clear(); dirty_ = unsorted_ = false; }
- /// find out if Polygon set is empty
+ // find out if Polygon set is empty
inline bool empty() const { clean(); return data_.empty(); }
- /// find out if Polygon set is sorted
+ // find out if Polygon set is sorted
inline bool sorted() const { return !unsorted_; }
- /// find out if Polygon set is clean
+ // find out if Polygon set is clean
inline bool dirty() const { return dirty_; }
- /// get the scanline orientation of the polygon set
+ // get the scanline orientation of the polygon set
inline orientation_2d orient() const { return orient_; }
void clean() const {
sort();
if(dirty_) {
- boolean_op::applyBooleanOr(data_);
+ boolean_op::default_arg_workaround<int>::applyBooleanOr(data_);
dirty_ = false;
}
}
@@ -196,6 +239,204 @@
unsorted_ = true;
}
+ //extents
+ template <typename rectangle_type>
+ bool
+ extents(rectangle_type& extents_rectangle) const {
+ clean();
+ if(data_.empty()) return false;
+ if(orient_ == HORIZONTAL)
+ set_points(extents_rectangle, point_data<coordinate_type>(data_[0].second.first, data_[0].first),
+ point_data<coordinate_type>(data_[data_.size() - 1].second.first, data_[data_.size() - 1].first));
+ else
+ set_points(extents_rectangle, point_data<coordinate_type>(data_[0].first, data_[0].second.first),
+ point_data<coordinate_type>(data_[data_.size() - 1].first, data_[data_.size() - 1].second.first));
+ for(unsigned int i = 1; i < data_.size() - 1; ++i) {
+ if(orient_ == HORIZONTAL)
+ encompass(extents_rectangle, point_data<coordinate_type>(data_[i].second.first, data_[i].first));
+ else
+ encompass(extents_rectangle, point_data<coordinate_type>(data_[i].first, data_[i].second.first));
+ }
+ return true;
+ }
+
+ polygon_90_set_data&
+ bloat(typename coordinate_traits<coordinate_type>::unsigned_area_type west_bloating,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type east_bloating,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type south_bloating,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type north_bloating) {
+ std::vector<rectangle_data<coordinate_type> > rects;
+ get(rects);
+ rectangle_data<coordinate_type> convolutionRectangle(interval_data<coordinate_type>(-((coordinate_type)west_bloating),
+ (coordinate_type)east_bloating),
+ interval_data<coordinate_type>(-((coordinate_type)south_bloating),
+ (coordinate_type)north_bloating));
+ for(typename std::vector<rectangle_data<coordinate_type> >::iterator itr = rects.begin();
+ itr != rects.end(); ++itr) {
+ convolve(*itr, convolutionRectangle);
+ }
+ clear();
+ insert(rects.begin(), rects.end());
+ return *this;
+ }
+
+ polygon_90_set_data&
+ shrink(typename coordinate_traits<coordinate_type>::unsigned_area_type west_shrinking,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type east_shrinking,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type south_shrinking,
+ typename coordinate_traits<coordinate_type>::unsigned_area_type north_shrinking) {
+ rectangle_data<coordinate_type> externalBoundary;
+ if(!extents(externalBoundary)) return *this;
+ ::gtl::bloat(externalBoundary, 10); //bloat by diferential ammount
+ //insert a hole that encompasses the data
+ insert(externalBoundary, true); //note that the set is in a dirty state now
+ sort(); //does not apply implicit OR operation
+ std::vector<rectangle_data<coordinate_type> > rects;
+ //begin does not apply implicit or operation, this is a dirty range
+ form_rectangles(rects, data_.begin(), data_.end(), orient_, rectangle_concept());
+ clear();
+ rectangle_data<coordinate_type> convolutionRectangle(interval_data<coordinate_type>(-((coordinate_type)east_shrinking),
+ (coordinate_type)west_shrinking),
+ interval_data<coordinate_type>(-((coordinate_type)north_shrinking),
+ (coordinate_type)south_shrinking));
+ for(typename std::vector<rectangle_data<coordinate_type> >::iterator itr = rects.begin();
+ itr != rects.end(); ++itr) {
+ rectangle_data<coordinate_type>& rect = *itr;
+ convolve(rect, convolutionRectangle);
+ //insert rectangle as a hole
+ insert(rect, true);
+ }
+ convolve(externalBoundary, convolutionRectangle);
+ //insert duplicate of external boundary as solid to cancel out the external hole boundaries
+ insert(externalBoundary);
+ clean(); //we have negative values in the set, so we need to apply an OR operation to make it valid input to a boolean
+ return *this;
+ }
+
+ polygon_90_set_data&
+ resize(coordinate_type west, coordinate_type east, coordinate_type south, coordinate_type north);
+
+ polygon_90_set_data& move(coordinate_type x_delta, coordinate_type y_delta) {
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ if(orient_ == orientation_2d(VERTICAL)) {
+ (*itr).first += x_delta;
+ (*itr).second.first += y_delta;
+ } else {
+ (*itr).second.first += x_delta;
+ (*itr).first += y_delta;
+ }
+ }
+ return *this;
+ }
+
+ // transform set
+ template <typename transformation_type>
+ polygon_90_set_data& transform(const transformation_type& transformation) {
+ direction_2d dir1, dir2;
+ transformation.get_directions(dir1, dir2);
+ int sign = dir1.get_sign() * dir2.get_sign();
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ if(orient_ == orientation_2d(VERTICAL)) {
+ transformation.transform((*itr).first, (*itr).second.first);
+ } else {
+ transformation.transform((*itr).second.first, (*itr).first);
+ }
+ (*itr).second.second *= sign;
+ }
+ if(dir1 != EAST || dir2 != NORTH)
+ unsorted_ = true; //some mirroring or rotation must have happened
+ return *this;
+ }
+
+ // scale set
+ polygon_90_set_data& scale_up(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ (*itr).first *= (coordinate_type)factor;
+ (*itr).second.first *= (coordinate_type)factor;
+ }
+ return *this;
+ }
+ polygon_90_set_data& scale_down(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
+ typedef typename coordinate_traits<coordinate_type>::coordinate_distance dt;
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ (*itr).first = scaling_policy<coordinate_type>::round((dt)((*itr).first) / (dt)factor);
+ (*itr).second.first = scaling_policy<coordinate_type>::round((dt)((*itr).second.first) / (dt)factor);
+ }
+ unsorted_ = true; //scaling down can make coordinates equal that were not previously equal
+ return *this;
+ }
+ template <typename scaling_type>
+ polygon_90_set_data& scale(const anisotropic_scale_factor<scaling_type>& scaling) {
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ if(orient_ == orientation_2d(VERTICAL)) {
+ scaling.scale((*itr).first, (*itr).second.first);
+ } else {
+ scaling.scale((*itr).second.first, (*itr).first);
+ }
+ }
+ unsorted_ = true;
+ return *this;
+ }
+ polygon_90_set_data& scale(double factor) {
+ typedef typename coordinate_traits<coordinate_type>::coordinate_distance dt;
+ for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
+ itr = data_.begin(); itr != data_.end(); ++itr) {
+ (*itr).first = scaling_policy<coordinate_type>::round((dt)((*itr).first) * (dt)factor);
+ (*itr).second.first = scaling_policy<coordinate_type>::round((dt)((*itr).second.first) * (dt)factor);
+ }
+ unsorted_ = true; //scaling make coordinates equal that were not previously equal
+ return *this;
+ }
+
+ polygon_90_set_data& self_xor() {
+ sort();
+ if(dirty_) { //if it is clean it is a no-op
+ boolean_op::default_arg_workaround<boolean_op::UnaryCount>::applyBooleanOr(data_);
+ dirty_ = false;
+ }
+ return *this;
+ }
+
+ polygon_90_set_data& self_intersect() {
+ sort();
+ if(dirty_) { //if it is clean it is a no-op
+ interval_data<coordinate_type> ivl(std::numeric_limits<coordinate_type>::min(), std::numeric_limits<coordinate_type>::max());
+ rectangle_data<coordinate_type> rect(ivl, ivl);
+ insert(rect, true);
+ clean();
+ }
+ return *this;
+ }
+
+ inline polygon_90_set_data& interact(const polygon_90_set_data& that) {
+ typedef coordinate_type Unit;
+ if(that.dirty_) that.clean();
+ typename touch_90_operation<Unit>::TouchSetData tsd;
+ touch_90_operation<Unit>::populateTouchSetData(tsd, that.data_, 0);
+ std::vector<polygon_90_data<Unit> > polys;
+ get(polys);
+ std::vector<std::set<int> > graph(polys.size()+1, std::set<int>());
+ for(unsigned int i = 0; i < polys.size(); ++i){
+ polygon_90_set_data<Unit> psTmp(that.orient_);
+ psTmp.insert(polys[i]);
+ psTmp.clean();
+ touch_90_operation<Unit>::populateTouchSetData(tsd, psTmp.data_, i+1);
+ }
+ touch_90_operation<Unit>::performTouch(graph, tsd);
+ clear();
+ for(std::set<int>::iterator itr = graph[0].begin(); itr != graph[0].end(); ++itr){
+ insert(polys[(*itr)-1]);
+ }
+ dirty_ = false;
+ return *this;
+ }
+
+
template <class T2, typename iterator_type_1, typename iterator_type_2>
void applyBooleanBinaryOp(iterator_type_1 itr1, iterator_type_1 itr1_end,
iterator_type_2 itr2, iterator_type_2 itr2_end,
@@ -215,7 +456,7 @@
template <typename output_container>
void get_dispatch(output_container& output, rectangle_concept tag) const {
clean();
- get_rectangles(output, data_.begin(), data_.end(), orient_, tag);
+ form_rectangles(output, data_.begin(), data_.end(), orient_, rectangle_concept());
}
template <typename output_container>
void get_dispatch(output_container& output, polygon_90_concept tag) const {
@@ -244,10 +485,36 @@
template <typename output_container, typename concept_type>
void get_fracture(output_container& container, bool fracture_holes, concept_type tag) const {
clean();
- get_polygons(container, data_.begin(), data_.end(), orient_, fracture_holes, tag);
+ ::gtl::get_polygons(container, data_.begin(), data_.end(), orient_, fracture_holes, tag);
}
};
+ template <typename coordinate_type>
+ polygon_90_set_data<coordinate_type>&
+ polygon_90_set_data<coordinate_type>::resize(coordinate_type west,
+ coordinate_type east,
+ coordinate_type south,
+ coordinate_type north) {
+ move(-west, -south);
+ coordinate_type e_total = west + east;
+ coordinate_type n_total = south + north;
+ if((e_total < 0) ^ (n_total < 0)) {
+ //different signs
+ if(e_total < 0) {
+ shrink(0, e_total, 0, 0);
+ return bloat(0, 0, 0, n_total);
+ } else {
+ shrink(0, 0, 0, n_total); //shrink first
+ return bloat(0, e_total, 0, 0);
+ }
+ } else {
+ if(e_total < 0) {
+ return shrink(0, e_total, 0, n_total);
+ }
+ return bloat(0, e_total, 0, n_total);
+ }
+ }
+
template <typename coordinate_type, typename property_type>
class property_merge_90 {
private:
@@ -280,16 +547,16 @@
//ConnectivityExtraction computes the graph of connectivity between rectangle, polygon and
//polygon set graph nodes where an edge is created whenever the geometry in two nodes overlap
template <typename coordinate_type>
- class connectivity_extraction {
+ class connectivity_extraction_90 {
private:
typedef typename touch_90_operation<coordinate_type>::TouchSetData tsd;
tsd tsd_;
unsigned int nodeCount_;
public:
- inline connectivity_extraction() : nodeCount_(0) {}
- inline connectivity_extraction(const connectivity_extraction& that) : tsd_(that.tsd_),
+ inline connectivity_extraction_90() : nodeCount_(0) {}
+ inline connectivity_extraction_90(const connectivity_extraction_90& that) : tsd_(that.tsd_),
nodeCount_(that.nodeCount_) {}
- inline connectivity_extraction& operator=(const connectivity_extraction& that) {
+ inline connectivity_extraction_90& operator=(const connectivity_extraction_90& that) {
tsd_ = that.tsd_;
nodeCount_ = that.nodeCount_; {}
return *this;
Modified: sandbox/gtl/gtl/polygon_90_set_traits.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_set_traits.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_set_traits.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -244,7 +244,7 @@
template <typename output_container_type, typename pst>
void get_90_dispatch(output_container_type& output, const pst& ps,
orientation_2d orient, rectangle_concept tag) {
- get_rectangles(output, ps.begin(), ps.end(), orient, tag);
+ form_rectangles(output, ps.begin(), ps.end(), orient, rectangle_concept());
}
template <typename output_container_type, typename pst>
@@ -326,18 +326,18 @@
template <typename T>
struct is_polygon_90_set_concept { };
template <>
- struct is_polygon_90_set_concept<polygon_90_set_concept> { typedef void type; };
+ struct is_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
template <>
- struct is_polygon_90_set_concept<rectangle_concept> { typedef void type; };
+ struct is_polygon_90_set_concept<rectangle_concept> { typedef gtl_yes type; };
template <>
- struct is_polygon_90_set_concept<polygon_90_concept> { typedef void type; };
+ struct is_polygon_90_set_concept<polygon_90_concept> { typedef gtl_yes type; };
template <>
- struct is_polygon_90_set_concept<polygon_90_with_holes_concept> { typedef void type; };
+ struct is_polygon_90_set_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
template <typename T>
- struct is_mutable_polygon_90_set_concept {};
+ struct is_mutable_polygon_90_set_concept { typedef gtl_no type; };
template <>
- struct is_mutable_polygon_90_set_concept<polygon_90_set_concept> { typedef void type; };
+ struct is_mutable_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
template <typename T>
struct geometry_concept<polygon_90_set_data<T> > { typedef polygon_90_set_concept type; };
Modified: sandbox/gtl/gtl/polygon_90_set_view.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_set_view.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_set_view.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -33,6 +33,57 @@
static inline bool sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
};
+ template <typename value_type, typename ltype, typename rtype, typename op_type>
+ struct compute_90_set_value {
+ static
+ void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_, orientation_2d orient_) {
+ value_type linput_(orient_);
+ value_type rinput_(orient_);
+ insert_into_view_arg(linput_, lvalue_, orient_);
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+ rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
+ }
+ };
+
+ template <typename value_type, typename lcoord, typename rcoord, typename op_type>
+ struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, polygon_90_set_data<rcoord>, op_type> {
+ static
+ void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
+ const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
+ lvalue_.sort();
+ rvalue_.sort();
+ output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+ rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
+ }
+ };
+
+ template <typename value_type, typename lcoord, typename rtype, typename op_type>
+ struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, rtype, op_type> {
+ static
+ void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
+ const rtype& rvalue_, orientation_2d orient_) {
+ value_type rinput_(orient_);
+ lvalue_.sort();
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+ rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
+ }
+ };
+
+ template <typename value_type, typename ltype, typename rcoord, typename op_type>
+ struct compute_90_set_value<value_type, ltype, polygon_90_set_data<rcoord>, op_type> {
+ static
+ void value(value_type& output_, const ltype& lvalue_,
+ const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
+ value_type linput_(orient_);
+ insert_into_view_arg(linput_, lvalue_, orient_);
+ rvalue_.sort();
+ output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+ rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
+ }
+ };
+
template <typename ltype, typename rtype, typename op_type>
class polygon_90_set_view {
public:
@@ -54,17 +105,12 @@
op_type op) :
lvalue_(lvalue), rvalue_(rvalue), orient_(orient), op_(op), output_(orient), evaluated_(false) {}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
private:
const value_type& value() const {
if(!evaluated_) {
evaluated_ = true;
- value_type linput_(orient_);
- value_type rinput_(orient_);
- insert_into_view_arg(linput_, lvalue_, orient_);
- insert_into_view_arg(rinput_, rvalue_, orient_);
- output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
- rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
+ compute_90_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_, orient_);
}
return output_;
}
@@ -144,6 +190,11 @@
return *this;
}
+ template <typename T>
+ template <typename ltype, typename rtype, typename op_type>
+ inline polygon_90_set_data<T>::polygon_90_set_data(const polygon_90_set_view<ltype, rtype, op_type>& that) :
+ orient_(that.orient()), data_(that.begin(), that.end()), dirty_(false), unsorted_(false) {}
+
template <typename geometry_type_1, typename geometry_type_2>
struct self_assign_operator_lvalue {
typedef geometry_type_1& type;
@@ -173,8 +224,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>
@@ -184,9 +236,19 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
- polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
+ typename requires_1<
+ typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+ ::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type,
+ polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>
(lvalue, rvalue,
@@ -195,8 +257,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>
@@ -206,8 +269,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_if<typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type>::type,
polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>
@@ -217,8 +281,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor> >::type
operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor>
@@ -228,8 +293,17 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_polygon_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+::type,
polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot> >::type
operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot>
@@ -239,7 +313,7 @@
}
template <typename coordinate_type_1, typename geometry_type_2>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<geometry_type_2>::type,
polygon_90_set_data<coordinate_type_1> >::type &
operator+=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
lvalue.insert(polygon_90_set_traits<geometry_type_2>::begin(rvalue), polygon_90_set_traits<geometry_type_2>::end(rvalue),
@@ -249,7 +323,7 @@
//
template <typename coordinate_type_1, typename geometry_type_2>
- typename requires_1< typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename is_polygon_90_set_type<geometry_type_2>::type,
polygon_90_set_data<coordinate_type_1> >::type &
operator|=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
return lvalue += rvalue;
@@ -257,89 +331,108 @@
//normal self assignment boolean operations
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryXor>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename is_polygon_90_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryNot>(lvalue, rvalue);
}
template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- polygon_90_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> >::type
- operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
- polygon_90_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> ps;
- assign(ps, lvalue);
- resize(ps, rvalue);
- return ps;
- }
-
- template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
- polygon_90_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> >::type
- operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
- polygon_90_set_data<typename polygon_90_set_traits<geometry_type_1>::coordinate_type> ps;
- assign(ps, lvalue);
- resize(ps, -rvalue);
- return ps;
- }
-
- template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_polygon_90_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
geometry_type_1>::type &
operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
return resize(lvalue, rvalue);
}
template <typename geometry_type_1, typename coordinate_type_1>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_set_type<geometry_type_1>::type>::type,
- typename is_same_type_SFINAE<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_90_set_type<geometry_type_1>::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
geometry_type_1>::type &
operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
return resize(lvalue, -rvalue);
}
+
+ template <typename geometry_type_1, typename coordinate_type_1>
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type,
+ geometry_type_1>::type
+ operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+ geometry_type_1 retval(lvalue);
+ retval += rvalue;
+ return retval;
+ }
+
+ template <typename geometry_type_1, typename coordinate_type_1>
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_90_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+::type,
+ typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type,
+ geometry_type_1>::type
+ operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+ geometry_type_1 retval(lvalue);
+ retval -= rvalue;
+ return retval;
+ }
+
}
#endif
Modified: sandbox/gtl/gtl/polygon_90_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_with_holes_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_with_holes_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -21,27 +21,27 @@
typedef typename coordinate_traits<T>::area_type area_type;
typedef point_data<T> point_type;
- /// default constructor of point does not initialize x and y
+ // default constructor of point does not initialize x and y
inline polygon_90_with_holes_data(){;} //do nothing default constructor
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline polygon_90_with_holes_data& set(iT input_begin, iT input_end) {
self_.set(input_begin, input_end);
return *this;
}
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline polygon_90_with_holes_data& set_compact(iT input_begin, iT input_end) {
self_.set_compact(input_begin, input_end);
return *this;
}
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline polygon_90_with_holes_data& set_holes(iT input_begin, iT input_end) {
holes_.clear(); //just in case there was some old data there
@@ -52,33 +52,33 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline polygon_90_with_holes_data(const polygon_90_with_holes_data& that) : self_(that.self_),
holes_(that.holes_) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline polygon_90_with_holes_data& operator=(const polygon_90_with_holes_data& that) {
self_ = that.self_;
holes_ = that.holes_;
return *this;
}
- /// get begin iterator, returns a pointer to a const coordinate_type
+ // get begin iterator, returns a pointer to a const coordinate_type
inline const iterator_type begin() const {
return self_.begin();
}
- /// get end iterator, returns a pointer to a const coordinate_type
+ // get end iterator, returns a pointer to a const coordinate_type
inline const iterator_type end() const {
return self_.end();
}
- /// get begin iterator, returns a pointer to a const coordinate_type
+ // get begin iterator, returns a pointer to a const coordinate_type
inline const compact_iterator_type begin_compact() const {
return self_.begin_compact();
}
- /// get end iterator, returns a pointer to a const coordinate_type
+ // get end iterator, returns a pointer to a const coordinate_type
inline const compact_iterator_type end_compact() const {
return self_.end_compact();
}
@@ -87,12 +87,12 @@
return self_.size();
}
- /// get begin iterator, returns a pointer to a const polygon
+ // get begin iterator, returns a pointer to a const polygon
inline const iterator_holes_type begin_holes() const {
return holes_.begin();
}
- /// get end iterator, returns a pointer to a const polygon
+ // get end iterator, returns a pointer to a const polygon
inline const iterator_holes_type end_holes() const {
return holes_.end();
}
Modified: sandbox/gtl/gtl/polygon_arbitrary_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_arbitrary_formation.hpp (original)
+++ sandbox/gtl/gtl/polygon_arbitrary_formation.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -553,11 +553,11 @@
public:
typedef typename std::list<Point>::const_iterator iterator;
- /// default constructor of point does not initialize x and y
+ // default constructor of point does not initialize x and y
inline poly_line_arbitrary(){;} //do nothing default constructor
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline poly_line_arbitrary& set(iT inputBegin, iT inputEnd) {
points.clear(); //just in case there was some old data there
@@ -568,19 +568,19 @@
return *this;
}
- /// copy constructor (since we have dynamic memory)
+ // copy constructor (since we have dynamic memory)
inline poly_line_arbitrary(const poly_line_arbitrary& that) : points(that.points) {}
- /// assignment operator (since we have dynamic memory do a deep copy)
+ // assignment operator (since we have dynamic memory do a deep copy)
inline poly_line_arbitrary& operator=(const poly_line_arbitrary& that) {
points = that.points;
return *this;
}
- /// get begin iterator, returns a pointer to a const Unit
+ // get begin iterator, returns a pointer to a const Unit
inline iterator begin() const { return points.begin(); }
- /// get end iterator, returns a pointer to a const Unit
+ // get end iterator, returns a pointer to a const Unit
inline iterator end() const { return points.end(); }
inline std::size_t size() const { return points.size(); }
@@ -1813,7 +1813,7 @@
typedef Point point_type;
typedef Unit coordinate_type;
typedef typename active_tail_arbitrary::iterator iterator_type;
- typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
+ //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
typedef iterator_type iterator;
inline poly_line_arbitrary_hole_data() : p_(0) {}
@@ -1821,8 +1821,8 @@
//use default copy and assign
inline iterator begin() const { return p_->getTail()->begin(); }
inline iterator end() const { return p_->getTail()->end(); }
- inline compact_iterator_type begin_compact() const { return compact_iterator_type(begin()); }
- inline compact_iterator_type end_compact() const { return compact_iterator_type(end()); }
+ //inline compact_iterator_type begin_compact() const { return compact_iterator_type(begin()); }
+ //inline compact_iterator_type end_compact() const { return compact_iterator_type(end()); }
inline unsigned int size() const { return 0; }
template<class iT>
inline poly_line_arbitrary_hole_data& set(iT inputBegin, iT inputEnd) {
@@ -1846,7 +1846,7 @@
typedef Point point_type;
typedef Unit coordinate_type;
typedef typename active_tail_arbitrary::iterator iterator_type;
- typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
+ //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
typedef typename coordinate_traits<Unit>::coordinate_distance area_type;
class iterator_holes_type {
@@ -1892,8 +1892,8 @@
//use default copy and assign
inline iterator_type begin() const { return p_->getTail()->begin(); }
inline iterator_type end() const { return p_->getTail()->end(); }
- inline compact_iterator_type begin_compact() const { return p_->getTail()->begin(); }
- inline compact_iterator_type end_compact() const { return p_->getTail()->end(); }
+ //inline compact_iterator_type begin_compact() const { return p_->getTail()->begin(); }
+ //inline compact_iterator_type end_compact() const { return p_->getTail()->end(); }
inline iterator_holes_type begin_holes() const { return iterator_holes_type(p_->getHoles().begin()); }
inline iterator_holes_type end_holes() const { return iterator_holes_type(p_->getHoles().end()); }
inline active_tail_arbitrary* yield() { return p_; }
Modified: sandbox/gtl/gtl/polygon_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_formation.hpp (original)
+++ sandbox/gtl/gtl/polygon_formation.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -11,38 +11,38 @@
namespace polygon_formation {
- /**
- * @brief End has two states, HEAD and TAIL as is represented by a bool
+ /*
+ * End has two states, HEAD and TAIL as is represented by a bool
*/
typedef bool End;
- /**
- * @brief HEAD End is represented as false because it is the lesser state
+ /*
+ * HEAD End is represented as false because it is the lesser state
*/
const End HEAD = false;
- /**
- * @brief TAIL End is represented by true because TAIL comes after head and 1 after 0
+ /*
+ * TAIL End is represented by true because TAIL comes after head and 1 after 0
*/
const End TAIL = true;
- /**
- * @brief 2D turning direction, left and right sides (is a boolean value since it has two states.)
+ /*
+ * 2D turning direction, left and right sides (is a boolean value since it has two states.)
*/
typedef bool Side;
- /**
- * @brief LEFT Side is 0 because we inuitively think left to right; left < right
+ /*
+ * LEFT Side is 0 because we inuitively think left to right; left < right
*/
const Side LEFT = false;
- /**
- * @brief RIGHT Side is 1 so that right > left
+ /*
+ * RIGHT Side is 1 so that right > left
*/
const Side RIGHT = true;
- /**
- * @brief The PolyLine class is data storage and services for building and representing partial polygons.
+ /*
+ * The PolyLine class is data storage and services for building and representing partial polygons.
* As the polyline is added to it extends its storage to accomodate the data.
* PolyLines can be joined head-to-head/head-to-tail when it is determined that two polylines are
* part of the same polygon.
@@ -60,21 +60,21 @@
private:
//data
- /**
- * @brief ptdata_ a vector of coordiantes
+ /*
+ * ptdata_ a vector of coordiantes
* if VERTICAL_HEAD, first coordiante is an X
* else first coordinate is a Y
*/
std::vector<Unit> ptdata_;
- /**
- * @brief head and tail points to other polylines before and after this in a chain
+ /*
+ * head and tail points to other polylines before and after this in a chain
*/
PolyLine* headp_;
PolyLine* tailp_;
- /**
- * @brief state bitmask
+ /*
+ * state bitmask
* bit zero is orientation, 0 H, 1 V
* bit 1 is head connectivity, 0 for head, 1 for tail
* bit 2 is tail connectivity, 0 for head, 1 for tail
@@ -83,13 +83,13 @@
int state_;
public:
- /**
- * @brief default constructor (for preallocation)
+ /*
+ * default constructor (for preallocation)
*/
PolyLine();
- /**
- * @brief constructor that takes the orientation, coordiante and side to which there is solid
+ /*
+ * constructor that takes the orientation, coordiante and side to which there is solid
*/
PolyLine(orientation_2d orient, Unit coord, Side side);
@@ -105,172 +105,172 @@
//equivalence operator
bool operator==(const PolyLine& b) const;
- /**
- * @brief valid PolyLine (only default constructed polylines are invalid.)
+ /*
+ * valid PolyLine (only default constructed polylines are invalid.)
*/
bool isValid() const;
- /**
- * @brief Orientation of Head
+ /*
+ * Orientation of Head
*/
orientation_2d headOrient() const;
- /**
- * @brief returns true if first coordinate is an X value (first segment is vertical)
+ /*
+ * returns true if first coordinate is an X value (first segment is vertical)
*/
bool verticalHead() const;
- /**
- * @brief returns the orientation_2d fo the tail
+ /*
+ * returns the orientation_2d fo the tail
*/
orientation_2d tailOrient() const;
- /**
- * @brief returns true if last coordinate is an X value (last segment is vertical)
+ /*
+ * returns true if last coordinate is an X value (last segment is vertical)
*/
bool verticalTail() const;
- /**
- * @brief retrun true if PolyLine has odd number of coordiantes
+ /*
+ * retrun true if PolyLine has odd number of coordiantes
*/
bool oddLength() const;
- /**
- * @brief retrun the End of the other polyline that the specified end of this polyline is connected to
+ /*
+ * retrun the End of the other polyline that the specified end of this polyline is connected to
*/
End endConnectivity(End end) const;
- /**
- * @brief retrun true if the head of this polyline is connect to the tail of a polyline
+ /*
+ * retrun true if the head of this polyline is connect to the tail of a polyline
*/
bool headToTail() const;
- /**
- * @brief retrun true if the head of this polyline is connect to the head of a polyline
+ /*
+ * retrun true if the head of this polyline is connect to the head of a polyline
*/
bool headToHead() const;
- /**
- * @brief retrun true if the tail of this polyline is connect to the tail of a polyline
+ /*
+ * retrun true if the tail of this polyline is connect to the tail of a polyline
*/
bool tailToTail() const;
- /**
- * @brief retrun true if the tail of this polyline is connect to the head of a polyline
+ /*
+ * retrun true if the tail of this polyline is connect to the head of a polyline
*/
bool tailToHead() const;
- /**
- * @brief retrun the side on which there is solid for this polyline
+ /*
+ * retrun the side on which there is solid for this polyline
*/
Side solidSide() const;
- /**
- * @brief retrun true if there is solid to the right of this polyline
+ /*
+ * retrun true if there is solid to the right of this polyline
*/
bool solidToRight() const;
- /**
- * @brief returns true if the polyline tail is not connected
+ /*
+ * returns true if the polyline tail is not connected
*/
bool active() const;
- /**
- * @brief adds a coordinate value to the end of the polyline changing the tail orientation
+ /*
+ * adds a coordinate value to the end of the polyline changing the tail orientation
*/
PolyLine& pushCoordinate(Unit coord);
- /**
- * @brief removes a coordinate value at the end of the polyline changing the tail orientation
+ /*
+ * removes a coordinate value at the end of the polyline changing the tail orientation
*/
PolyLine& popCoordinate();
- /**
- * @brief extends the tail of the polyline to include the point, changing orientation if needed
+ /*
+ * extends the tail of the polyline to include the point, changing orientation if needed
*/
PolyLine& pushPoint(const point_data<Unit>& point);
- /**
- * @brief changes the last coordinate of the tail of the polyline by the amount of the delta
+ /*
+ * changes the last coordinate of the tail of the polyline by the amount of the delta
*/
PolyLine& extendTail(Unit delta);
- /**
- * @brief join thisEnd of this polyline to that polyline's end
+ /*
+ * join thisEnd of this polyline to that polyline's end
*/
PolyLine& joinTo(End thisEnd, PolyLine& that, End end);
- /**
- * @brief join an end of this polyline to the tail of that polyline
+ /*
+ * join an end of this polyline to the tail of that polyline
*/
PolyLine& joinToTail(PolyLine& that, End end);
- /**
- * @brief join an end of this polyline to the head of that polyline
+ /*
+ * join an end of this polyline to the head of that polyline
*/
PolyLine& joinToHead(PolyLine& that, End end);
- /**
- * @brief join the head of this polyline to the head of that polyline
+ /*
+ * join the head of this polyline to the head of that polyline
*/
//join this to that in the given way
PolyLine& joinHeadToHead(PolyLine& that);
- /**
- * @brief join the head of this polyline to the tail of that polyline
+ /*
+ * join the head of this polyline to the tail of that polyline
*/
PolyLine& joinHeadToTail(PolyLine& that);
- /**
- * @brief join the tail of this polyline to the head of that polyline
+ /*
+ * join the tail of this polyline to the head of that polyline
*/
PolyLine& joinTailToHead(PolyLine& that);
- /**
- * @brief join the tail of this polyline to the tail of that polyline
+ /*
+ * join the tail of this polyline to the tail of that polyline
*/
PolyLine& joinTailToTail(PolyLine& that);
- /**
- * @brief dissconnect the tail at the end of the polygon
+ /*
+ * dissconnect the tail at the end of the polygon
*/
PolyLine& disconnectTails();
- /**
- * @brief get the coordinate at one end of this polyline, by default the tail end
+ /*
+ * get the coordinate at one end of this polyline, by default the tail end
*/
Unit getEndCoord(End end = TAIL) const;
- /**
- * @brief get the point on the polyline at the given index (polylines have the same number of coordinates as points
+ /*
+ * get the point on the polyline at the given index (polylines have the same number of coordinates as points
*/
point_data<Unit> getPoint(unsigned int index) const;
- /**
- * @brief get the point on one end of the polyline, by default the tail
+ /*
+ * get the point on one end of the polyline, by default the tail
*/
point_data<Unit> getEndPoint(End end = TAIL) const;
- /**
- * @brief get the orientation of a segment by index
+ /*
+ * get the orientation of a segment by index
*/
orientation_2d segmentOrient(unsigned int index = 0) const;
- /**
- * @brief get a coordinate by index using the square bracket operator
+ /*
+ * get a coordinate by index using the square bracket operator
*/
Unit operator[] (unsigned int index) const;
- /**
- * @brief get the number of segments/points/coordinates in the polyline
+ /*
+ * get the number of segments/points/coordinates in the polyline
*/
unsigned int numSegments() const;
- /**
- * @brief get the pointer to the next polyline at one end of this
+ /*
+ * get the pointer to the next polyline at one end of this
*/
PolyLine* next(End end) const;
- /**
- * @brief write out coordinates of this and all attached polylines to a single vector
+ /*
+ * write out coordinates of this and all attached polylines to a single vector
*/
PolyLine* writeOut(std::vector<Unit>& outVec, End startEnd = TAIL) const;
@@ -287,8 +287,8 @@
template<bool orientT, typename Unit>
class PolyLinePolygonWithHolesData;
- /**
- * @brief ActiveTail represents an edge of an incomplete polygon.
+ /*
+ * ActiveTail represents an edge of an incomplete polygon.
*
* An ActiveTail object is the active tail end of a polyline object, which may (should) be the attached to
* a chain of polyline objects through a pointer. The ActiveTail class provides an abstraction between
@@ -319,8 +319,8 @@
std::list<ActiveTail*> holesList_;
public:
- /**
- * @brief iterator over coordinates of the figure
+ /*
+ * iterator over coordinates of the figure
*/
class iterator {
private:
@@ -410,8 +410,8 @@
inline Unit operator*() { return (*pLine_)[index_]; }
};
- /**
- * @brief iterator over holes contained within the figure
+ /*
+ * iterator over holes contained within the figure
*/
typedef typename std::list<ActiveTail*>::const_iterator iteratorHoles;
@@ -436,96 +436,96 @@
//equivalence operator
bool operator==(const ActiveTail& b) const;
- /**
- * @brief comparison operators, ActiveTail objects are sortable by geometry
+ /*
+ * comparison operators, ActiveTail objects are sortable by geometry
*/
bool operator<(const ActiveTail& b) const;
bool operator<=(const ActiveTail& b) const;
bool operator>(const ActiveTail& b) const;
bool operator>=(const ActiveTail& b) const;
- /**
- * @brief get the pointer to the polyline that this is an active tail of
+ /*
+ * get the pointer to the polyline that this is an active tail of
*/
PolyLine<Unit>* getTail() const;
- /**
- * @brief get the pointer to the polyline at the other end of the chain
+ /*
+ * get the pointer to the polyline at the other end of the chain
*/
PolyLine<Unit>* getOtherTail() const;
- /**
- * @brief get the pointer to the activetail at the other end of the chain
+ /*
+ * get the pointer to the activetail at the other end of the chain
*/
ActiveTail* getOtherActiveTail() const;
- /**
- * @brief test if another active tail is the other end of the chain
+ /*
+ * test if another active tail is the other end of the chain
*/
bool isOtherTail(const ActiveTail& b);
- /**
- * @brief update this end of chain pointer to new polyline
+ /*
+ * update this end of chain pointer to new polyline
*/
ActiveTail& updateTail(PolyLine<Unit>* newTail);
- /**
- * @brief associate a hole to this active tail by the specified policy
+ /*
+ * associate a hole to this active tail by the specified policy
*/
ActiveTail* addHole(ActiveTail* hole, bool fractureHoles);
- /**
- * @brief get the list of holes
+ /*
+ * get the list of holes
*/
const std::list<ActiveTail*>& getHoles() const;
- /**
- * @brief copy holes from that to this
+ /*
+ * copy holes from that to this
*/
void copyHoles(ActiveTail& that);
- /**
- * @brief find out if solid to right
+ /*
+ * find out if solid to right
*/
bool solidToRight() const;
- /**
- * @brief get coordinate (getCoord and getCoordinate are aliases for eachother)
+ /*
+ * get coordinate (getCoord and getCoordinate are aliases for eachother)
*/
Unit getCoord() const;
Unit getCoordinate() const;
- /**
- * @brief get the tail orientation
+ /*
+ * get the tail orientation
*/
orientation_2d getOrient() const;
- /**
- * @brief add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
+ /*
+ * add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
*/
void pushCoordinate(Unit coord);
- /**
- * @brief write the figure that this active tail points to out to the temp buffer
+ /*
+ * write the figure that this active tail points to out to the temp buffer
*/
void writeOutFigure(std::vector<Unit>& outVec, bool isHole = false) const;
- /**
- * @brief write the figure that this active tail points to out through iterators
+ /*
+ * write the figure that this active tail points to out through iterators
*/
void writeOutFigureItrs(iterator& beginOut, iterator& endOut, bool isHole = false, orientation_2d orient = VERTICAL) const;
iterator begin(bool isHole, orientation_2d orient) const;
iterator end() const;
- /**
- * @brief write the holes that this active tail points to out through iterators
+ /*
+ * write the holes that this active tail points to out through iterators
*/
void writeOutFigureHoleItrs(iteratorHoles& beginOut, iteratorHoles& endOut) const;
iteratorHoles beginHoles() const;
iteratorHoles endHoles() const;
- /**
- * @brief joins the two chains that the two active tail tails are ends of
+ /*
+ * joins the two chains that the two active tail tails are ends of
* checks for closure of figure and writes out polygons appropriately
* returns a handle to a hole if one is closed
*/
@@ -533,30 +533,30 @@
template <typename PolygonT>
static ActiveTail* joinChains(ActiveTail* at1, ActiveTail* at2, bool solid, typename std::vector<PolygonT>& outBufferTmp);
- /**
- * @brief deallocate temp buffer
+ /*
+ * deallocate temp buffer
*/
static void destroyOutBuffer();
- /**
- * @brief deallocate all polygon data this active tail points to (deep delete, call only from one of a pair of active tails)
+ /*
+ * deallocate all polygon data this active tail points to (deep delete, call only from one of a pair of active tails)
*/
void destroyContents();
};
- /** @brief allocate a polyline object */
+ /* allocate a polyline object */
template <typename Unit>
PolyLine<Unit>* createPolyLine(orientation_2d orient, Unit coord, Side side);
- /** @brief deallocate a polyline object */
+ /* deallocate a polyline object */
template <typename Unit>
void destroyPolyLine(PolyLine<Unit>* pLine);
- /** @brief allocate an activetail object */
+ /* allocate an activetail object */
template <typename Unit>
ActiveTail<Unit>* createActiveTail();
- /** @brief deallocate an activetail object */
+ /* deallocate an activetail object */
template <typename Unit>
void destroyActiveTail(ActiveTail<Unit>* aTail);
@@ -646,8 +646,8 @@
return *this;
}
- /// initialize a polygon from x,y values, it is assumed that the first is an x
- /// and that the input is a well behaved polygon
+ // initialize a polygon from x,y values, it is assumed that the first is an x
+ // and that the input is a well behaved polygon
template<class iT>
inline PolyLinePolygonWithHolesData& set_holes(iT inputBegin, iT inputEnd) {
return *this;
@@ -655,10 +655,6 @@
};
- /**
- * @brief ScanLine does all the work of stitching together polygons from incoming vertical edges
- */
- struct ERROR {};
template <bool orientT, typename Unit, typename polygon_concept_type>
struct PolyLineType { };
template <bool orientT, typename Unit>
@@ -677,7 +673,6 @@
template <bool orientT, typename Unit, typename polygon_concept_type>
class ScanLineToPolygonItrs {
private:
- /** @brief a map of horizontal edges of incomplete polygons by their y value coordinate */
std::map<Unit, ActiveTail<Unit>*> tailMap_;
typedef typename PolyLineType<orientT, Unit, polygon_concept_type>::type PolyLinePolygonData;
std::vector<PolyLinePolygonData> outputPolygons_;
@@ -685,12 +680,12 @@
public:
typedef typename std::vector<PolyLinePolygonData>::iterator iterator;
inline ScanLineToPolygonItrs() {}
- /** @brief construct a scanline with the proper offsets, protocol and options */
+ /* construct a scanline with the proper offsets, protocol and options */
inline ScanLineToPolygonItrs(bool fractureHoles) : fractureHoles_(fractureHoles) {}
~ScanLineToPolygonItrs() { clearOutput_(); }
- /** @brief process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
+ /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
void processEdges(iterator& beginOutput, iterator& endOutput,
Unit currentX, std::vector<interval_data<Unit> >& leftEdges,
std::vector<interval_data<Unit> >& rightEdges);
@@ -699,8 +694,8 @@
void clearOutput_();
};
- /**
- * @brief ScanLine does all the work of stitching together polygons from incoming vertical edges
+ /*
+ * ScanLine does all the work of stitching together polygons from incoming vertical edges
*/
// template <typename Unit, typename polygon_concept_type>
// class ScanLineToPolygons {
@@ -708,10 +703,10 @@
// ScanLineToPolygonItrs<true, Unit> scanline_;
// public:
// inline ScanLineToPolygons() : scanline_() {}
-// /** @brief construct a scanline with the proper offsets, protocol and options */
+// /* construct a scanline with the proper offsets, protocol and options */
// inline ScanLineToPolygons(bool fractureHoles) : scanline_(fractureHoles) {}
-// /** @brief process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
+// /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
// inline void processEdges(std::vector<Unit>& outBufferTmp, Unit currentX, std::vector<interval_data<Unit> >& leftEdges,
// std::vector<interval_data<Unit> >& rightEdges) {
// typename ScanLineToPolygonItrs<true, Unit>::iterator itr, endItr;
@@ -1402,8 +1397,8 @@
// with add hole
template <typename Unit>
inline std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> createActiveTailsAsPair(Unit x, Unit y, bool solid, ActiveTail<Unit>* phole, bool fractureHoles) {
- ActiveTail<Unit>* at1;
- ActiveTail<Unit>* at2;
+ ActiveTail<Unit>* at1 = 0;
+ ActiveTail<Unit>* at2 = 0;
if(!phole || !fractureHoles){
at1 = createActiveTail<Unit>();
at2 = createActiveTail<Unit>();
Modified: sandbox/gtl/gtl/polygon_set_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -20,21 +20,21 @@
};
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_any_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_any_polygon_set_type<polygon_set_type>::type,
typename polygon_set_traits<polygon_set_type>::iterator_type>::type
begin_polygon_set_data(const polygon_set_type& polygon_set) {
return polygon_set_traits<polygon_set_type>::begin(polygon_set);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_any_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_any_polygon_set_type<polygon_set_type>::type,
typename polygon_set_traits<polygon_set_type>::iterator_type>::type
end_polygon_set_data(const polygon_set_type& polygon_set) {
return polygon_set_traits<polygon_set_type>::end(polygon_set);
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_polygon_set_type<polygon_set_type>::type,
bool>::type
clean(const polygon_set_type& polygon_set) {
return polygon_set_traits<polygon_set_type>::clean(polygon_set);
@@ -42,8 +42,9 @@
//assign
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<polygon_set_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_set_type<polygon_set_type_1>::type,
+ typename is_any_polygon_set_type<polygon_set_type_2>::type>::type,
polygon_set_type_1>::type &
assign(polygon_set_type_1& lvalue, const polygon_set_type_2& rvalue) {
if(clean(rvalue))
@@ -57,23 +58,24 @@
return lvalue;
}
-// //get trapezoids
-// template <typename output_container_type, typename polygon_set_type>
-// typename requires_1< typename gtl_if<typename is_polygon_set_type<polygon_set_type>::type>::type,
-// void>::type
-// get_trapezoids(output_container_type& output, const polygon_set_type& polygon_set) {
-// //TODO
-// // clean(polygon_set);
-// // polygon_set_data<typename polygon_set_traits<polygon_set_type>::coordinate_type> ps;
-// // assign(ps, polygon_set);
-// // ps.get_trapezoids(output);
-// }
+ // //get trapezoids
+ // template <typename output_container_type, typename polygon_set_type>
+ // typename requires_1< typename gtl_if<typename is_polygon_set_type<polygon_set_type>::type>::type,
+ // void>::type
+ // get_trapezoids(output_container_type& output, const polygon_set_type& polygon_set) {
+ // //TODO
+ // // clean(polygon_set);
+ // // polygon_set_data<typename polygon_set_traits<polygon_set_type>::coordinate_type> ps;
+ // // assign(ps, polygon_set);
+ // // ps.get_trapezoids(output);
+ // }
//equivalence
template <typename polygon_set_type_1, typename polygon_set_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<polygon_set_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<polygon_set_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<polygon_set_type_1, polygon_set_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3 <
+ typename is_any_polygon_set_type<polygon_set_type_1>::type,
+ typename is_any_polygon_set_type<polygon_set_type_2>::type,
+ typename is_either_polygon_set_type<polygon_set_type_1, polygon_set_type_2>::type>::type,
bool>::type
equivalence(const polygon_set_type_1& lvalue,
const polygon_set_type_2& rvalue) {
@@ -86,7 +88,7 @@
//clear
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
void>::type
clear(polygon_set_type& polygon_set) {
polygon_set_data<typename polygon_set_traits<polygon_set_type>::coordinate_type> ps;
@@ -95,7 +97,7 @@
//empty
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
bool>::type
empty(const polygon_set_type& polygon_set) {
if(clean(polygon_set)) return begin_polygon_set_data(polygon_set) == end_polygon_set_data(polygon_set);
@@ -107,8 +109,9 @@
//extents
template <typename polygon_set_type, typename rectangle_type>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
- typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_polygon_set_type<polygon_set_type>::type,
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
bool>::type
extents(rectangle_type& extents_rectangle,
const polygon_set_type& polygon_set) {
@@ -120,7 +123,7 @@
//area
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
typename coordinate_traits<typename polygon_set_traits<polygon_set_type>::coordinate_type>::area_type>::type
area(const polygon_set_type& polygon_set) {
typedef typename polygon_set_traits<polygon_set_type>::coordinate_type Unit;
@@ -136,7 +139,7 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_up(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
@@ -150,10 +153,10 @@
}
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
polygon_set_type>::type &
scale_down(polygon_set_type& polygon_set,
- typename coordinate_traits<typename polygon_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
+ typename coordinate_traits<typename polygon_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
typedef typename polygon_set_traits<polygon_set_type>::coordinate_type Unit;
clean(polygon_set);
polygon_set_data<Unit> ps;
@@ -165,7 +168,7 @@
//transform
template <typename polygon_set_type, typename transformation_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
polygon_set_type>::type &
transform(polygon_set_type& polygon_set,
const transformation_type& transformation) {
@@ -180,7 +183,7 @@
//keep
template <typename polygon_set_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_set_type<polygon_set_type>::type>::type,
+ typename requires_1< typename is_mutable_polygon_set_type<polygon_set_type>::type,
polygon_set_type>::type &
keep(polygon_set_type& polygon_set,
typename coordinate_traits<typename polygon_set_traits<polygon_set_type>::coordinate_type>::area_type min_area,
@@ -216,9 +219,9 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3 < typename is_any_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type,
+ typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_set_view<geometry_type_1, geometry_type_2, 0> >::type
operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_set_view<geometry_type_1, geometry_type_2, 0>
@@ -226,19 +229,29 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
- polygon_set_view<geometry_type_1, geometry_type_2, 0> >::type
+ typename requires_1< typename gtl_and_3 < typename is_any_polygon_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_any_polygon_set_type<geometry_type_2>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, polygon_set_view<geometry_type_1, geometry_type_2, 0> >::type
operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_set_view<geometry_type_1, geometry_type_2, 0>
(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3 <
+ typename is_any_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type,
+ typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_set_view<geometry_type_1, geometry_type_2, 1> >::type
operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_set_view<geometry_type_1, geometry_type_2, 1>
@@ -246,9 +259,10 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3 <
+ typename is_any_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type,
+ typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
polygon_set_view<geometry_type_1, geometry_type_2, 2> >::type
operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_set_view<geometry_type_1, geometry_type_2, 2>
@@ -256,59 +270,70 @@
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_3< typename gtl_if<typename is_any_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- typename gtl_if<typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>::type,
- polygon_set_view<geometry_type_1, geometry_type_2, 3> >::type
+ typename requires_1< typename gtl_and_3 < typename is_any_polygon_set_type<geometry_type_1>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_any_polygon_set_type<geometry_type_2>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef __ICC
+ ::type
+#endif
+ ::type, polygon_set_view<geometry_type_1, geometry_type_2, 3> >::type
operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return polygon_set_view<geometry_type_1, geometry_type_2, 3>
(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- geometry_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ geometry_type_1>::type &
operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
geometry_type_1>::type &
operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 2>(lvalue, rvalue);
}
template <typename geometry_type_1, typename geometry_type_2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_set_type<geometry_type_1>::type>::type,
- typename gtl_if<typename is_any_polygon_set_type<geometry_type_2>::type>::type,
- geometry_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_set_type<geometry_type_1>::type,
+ typename is_any_polygon_set_type<geometry_type_2>::type>::type,
+ geometry_type_1>::type &
operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 3>(lvalue, rvalue);
}
Modified: sandbox/gtl/gtl/polygon_set_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -23,23 +23,27 @@
typedef typename value_type::const_iterator iterator_type;
typedef polygon_set_data operator_arg_type;
- /// default constructor
+ // default constructor
inline polygon_set_data() : dirty_(false), unsorted_(false), is_45_(true) {}
- /// constructor from an iterator pair over edge data
+ // constructor from an iterator pair over edge data
template <typename iT>
inline polygon_set_data(iT input_begin, iT input_end) {
for( ; input_begin != input_end; ++input_begin) { insert(*input_begin); }
}
- /// copy constructor
+ // copy constructor
inline polygon_set_data(const polygon_set_data& that) :
data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_), is_45_(that.is_45_) {}
- /// destructor
+ // copy constructor
+ template <typename ltype, typename rtype, int op_type>
+ inline polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that);
+
+ // destructor
inline ~polygon_set_data() {}
- /// assignement operator
+ // assignement operator
inline polygon_set_data& operator=(const polygon_set_data& that) {
if(this == &that) return *this;
data_ = that.data_;
@@ -64,7 +68,7 @@
return *this;
}
- /// insert iterator range
+ // insert iterator range
template <typename iT>
inline void insert(iT input_begin, iT input_end) {
if(input_begin == input_end) return;
@@ -176,24 +180,24 @@
get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type());
}
- /// equivalence operator
+ // equivalence operator
inline bool operator==(const polygon_set_data& p) const {
clean();
p.clean();
return data_ == p.data_;
}
- /// inequivalence operator
+ // inequivalence operator
inline bool operator!=(const polygon_set_data& p) const {
return !((*this) == p);
}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
inline iterator_type begin() const {
return data_.begin();
}
- /// get iterator to end vertex data
+ // get iterator to end vertex data
inline iterator_type end() const {
return data_.end();
}
@@ -202,16 +206,16 @@
return data_;
}
- /// clear the contents of the polygon_set_data
+ // clear the contents of the polygon_set_data
inline void clear() { data_.clear(); dirty_ = unsorted_ = false; }
- /// find out if Polygon set is empty
+ // find out if Polygon set is empty
inline bool empty() const { return data_.empty(); }
- /// find out if Polygon set is sorted
+ // find out if Polygon set is sorted
inline bool sorted() const { return !unsorted_; }
- /// find out if Polygon set is clean
+ // find out if Polygon set is clean
inline bool dirty() const { return dirty_; }
void clean() const;
Modified: sandbox/gtl/gtl/polygon_set_view.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_view.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_view.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -25,10 +25,10 @@
} else {
sort();
arbitrary_boolean_op<coordinate_type> abo;
- polygon_set_data<coordinate_type> tmp;
- abo.execute(tmp, begin(), end(), end(), end(), 0);
- data_.swap(tmp.data_);
- is_45_ = tmp.is_45_;
+ polygon_set_data<coordinate_type> tmp2;
+ abo.execute(tmp2, begin(), end(), end(), end(), 0);
+ data_.swap(tmp2.data_);
+ is_45_ = tmp2.is_45_;
dirty_ = false;
}
}
@@ -54,8 +54,8 @@
static inline bool sort(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
};
- template <typename value_type, typename geometry_type_1, typename geometry_type_2>
- void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_, int op_type) {
+ template <typename value_type, typename geometry_type_1, typename geometry_type_2, int op_type>
+ void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
typedef geometry_type_1 ltype;
typedef geometry_type_2 rtype;
typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
@@ -65,7 +65,7 @@
insert_into_view_arg(rinput_, rvalue_);
polygon_45_set_data<coordinate_type> l45, r45, o45;
if(linput_.downcast(l45) && rinput_.downcast(r45)) {
- l45.applyAdaptiveBoolean_(o45, op_type, r45);
+ l45.template applyAdaptiveBoolean_<op_type>(o45, r45);
output_.insert(o45);
} else {
arbitrary_boolean_op<coordinate_type> abo;
@@ -91,12 +91,12 @@
const rtype& rvalue ) :
lvalue_(lvalue), rvalue_(rvalue), evaluated_(false) {}
- /// get iterator to begin vertex data
+ // get iterator to begin vertex data
public:
const value_type& value() const {
if(!evaluated_) {
evaluated_ = true;
- execute_boolean_op(output_, lvalue_, rvalue_, op_type);
+ execute_boolean_op<value_type, ltype, rtype, op_type>(output_, lvalue_, rvalue_);
}
return output_;
}
@@ -146,11 +146,17 @@
typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
typedef polygon_set_data<coordinate_type> value_type;
value_type output_;
- execute_boolean_op(output_, lvalue_, rvalue_, op_type);
+ execute_boolean_op<value_type, geometry_type_1, geometry_type_2, op_type>(output_, lvalue_, rvalue_);
polygon_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end());
return lvalue_;
}
+ // copy constructor
+ template <typename coordinate_type>
+ template <typename ltype, typename rtype, int op_type>
+ polygon_set_data<coordinate_type>::polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that) :
+ data_(that.value().data_), dirty_(that.value().dirty_), unsorted_(that.value().unsorted_), is_45_(that.value().is_45_) {}
+
template <typename ltype, typename rtype, int op_type>
struct geometry_concept<polygon_set_view<ltype, rtype, op_type> > { typedef polygon_set_concept type; };
Modified: sandbox/gtl/gtl/polygon_traits.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_traits.hpp (original)
+++ sandbox/gtl/gtl/polygon_traits.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -9,82 +9,95 @@
#define GTL_POLYGON_TRAITS_HPP
namespace gtl {
- template <typename T, typename enable = void>
+ template <typename T, typename enable = gtl_yes>
struct polygon_90_traits {
typedef typename T::coordinate_type coordinate_type;
typedef typename T::compact_iterator_type compact_iterator_type;
- /// Get the begin iterator
+ // Get the begin iterator
static inline compact_iterator_type begin_compact(const T& t) {
return t.begin_compact();
}
- /// Get the end iterator
+ // Get the end iterator
static inline compact_iterator_type end_compact(const T& t) {
return t.end_compact();
}
- /// Get the number of sides of the polygon
+ // Get the number of sides of the polygon
static inline unsigned int size(const T& t) {
return t.size();
}
- /// Get the winding direction of the polygon
+ // Get the winding direction of the polygon
static inline winding_direction winding(const T& t) {
return unknown_winding;
}
};
- template <typename T, typename enable = void>
- struct polygon_traits {
+ template <typename T, typename enable = gtl_yes>
+ struct polygon_traits {};
+
+ template <typename T>
+ struct polygon_traits<T,
+ typename gtl_or_4<
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_concept>::type,
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_45_concept>::type,
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_with_holes_concept>::type,
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_45_with_holes_concept>::type
+ >::type> {
typedef typename T::coordinate_type coordinate_type;
typedef typename T::iterator_type iterator_type;
typedef typename T::point_type point_type;
- /// Get the begin iterator
+ // Get the begin iterator
static inline iterator_type begin_points(const T& t) {
return t.begin();
}
- /// Get the end iterator
+ // Get the end iterator
static inline iterator_type end_points(const T& t) {
return t.end();
}
- /// Get the number of sides of the polygon
+ // Get the number of sides of the polygon
static inline unsigned int size(const T& t) {
return t.size();
}
- /// Get the winding direction of the polygon
+ // Get the winding direction of the polygon
static inline winding_direction winding(const T& t) {
return unknown_winding;
}
};
template <typename T>
- struct polygon_traits<T, typename is_same_type_SFINAE<polygon_90_concept, typename geometry_concept<T>::type>::type> {
+ struct polygon_traits< T,
+ typename gtl_or<
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_90_concept>::type,
+ typename gtl_same_type<typename geometry_concept<T>::type, polygon_90_with_holes_concept>::type
+ >::type > {
typedef typename polygon_90_traits<T>::coordinate_type coordinate_type;
typedef iterator_compact_to_points<typename polygon_90_traits<T>::compact_iterator_type, point_data<coordinate_type> > iterator_type;
- /// Get the begin iterator
+ // Get the begin iterator
static inline iterator_type begin_points(const T& t) {
return iterator_type(polygon_90_traits<T>::begin_compact(t),
polygon_90_traits<T>::end_compact(t));
}
- /// Get the end iterator
+ // Get the end iterator
static inline iterator_type end_points(const T& t) {
return iterator_type(polygon_90_traits<T>::end_compact(t),
polygon_90_traits<T>::end_compact(t));
}
- /// Get the number of sides of the polygon
+ // Get the number of sides of the polygon
static inline unsigned int size(const T& t) {
return polygon_90_traits<T>::size(t);
}
- /// Get the winding direction of the polygon
+ // Get the winding direction of the polygon
static inline winding_direction winding(const T& t) {
return polygon_90_traits<T>::winding(t);
}
@@ -95,17 +108,17 @@
typedef typename T::iterator_holes_type iterator_holes_type;
typedef typename T::hole_type hole_type;
- /// Get the begin iterator
+ // Get the begin iterator
static inline iterator_holes_type begin_holes(const T& t) {
return t.begin_holes();
}
- /// Get the end iterator
+ // Get the end iterator
static inline iterator_holes_type end_holes(const T& t) {
return t.end_holes();
}
- /// Get the number of holes
+ // Get the number of holes
static inline unsigned int size_holes(const T& t) {
return t.size_holes();
}
@@ -114,7 +127,7 @@
template <typename T, typename enable = void>
struct polygon_90_mutable_traits {
- /// Set the data of a polygon with the unique coordinates in an iterator, starting with an x
+ // Set the data of a polygon with the unique coordinates in an iterator, starting with an x
template <typename iT>
static inline T& set_compact(T& t, iT input_begin, iT input_end) {
t.set_compact(input_begin, input_end);
@@ -124,8 +137,8 @@
};
template <typename T>
- struct polygon_90_mutable_traits<T, typename is_same_type_SFINAE<polygon_concept, typename geometry_concept<T>::type>::type> {
- /// Set the data of a polygon with the unique coordinates in an iterator, starting with an x
+ struct polygon_90_mutable_traits<T, typename gtl_same_type<polygon_concept, typename geometry_concept<T>::type>::type> {
+ // Set the data of a polygon with the unique coordinates in an iterator, starting with an x
template <typename iT>
static inline T& set_compact(T& t, iT input_begin, iT input_end) {
typedef iterator_points_to_compact<iT, typename polygon_traits<T>::point_type> iTp;
@@ -137,7 +150,7 @@
template <typename T, typename enable = void>
struct polygon_mutable_traits {
- /// Set the data of a polygon with the unique coordinates in an iterator, starting with an x
+ // Set the data of a polygon with the unique coordinates in an iterator, starting with an x
template <typename iT>
static inline T& set_points(T& t, iT input_begin, iT input_end) {
t.set(input_begin, input_end);
@@ -149,7 +162,7 @@
template <typename T, typename enable = void>
struct polygon_with_holes_mutable_traits {
- /// Set the data of a polygon with the unique coordinates in an iterator, starting with an x
+ // Set the data of a polygon with the unique coordinates in an iterator, starting with an x
template <typename iT>
static inline T& set_holes(T& t, iT inputBegin, iT inputEnd) {
t.set_holes(inputBegin, inputEnd);
@@ -275,9 +288,10 @@
};
template <typename T>
struct is_any_mutable_polygon_without_holes_type {
- typedef typename gtl_or_3<typename is_mutable_polygon_90_type<T>::type,
- typename is_mutable_polygon_45_type<T>::type,
- typename is_mutable_polygon_type<T>::type>::type type; };
+ typedef typename gtl_or_3<
+ typename is_mutable_polygon_90_type<T>::type,
+ typename is_mutable_polygon_45_type<T>::type,
+ typename is_mutable_polygon_type<T>::type>::type type; };
template <typename T>
struct is_any_mutable_polygon_type {
@@ -300,24 +314,44 @@
struct distance_type_by_domain<manhattan_domain, coordinate_type> {
typedef typename coordinate_traits<coordinate_type>::coordinate_difference type; };
+ // \brief Sets the boundary of the polygon to the points in the iterator range
+ // \tparam T A type that models polygon_concept
+ // \tparam iT Iterator type over objects that model point_concept
+ // \param t The polygon to set
+ // \param begin_points The start of the range of points
+ // \param end_points The end of the range of points
+
+ /// \relatesalso polygon_concept
template <typename T, typename iT>
- typename requires_1 <typename gtl_if<typename is_any_mutable_polygon_type<T>::type>::type, T>::type &
+ typename requires_1 <typename is_any_mutable_polygon_type<T>::type, T>::type &
set_points(T& t, iT begin_points, iT end_points) {
polygon_mutable_traits<T>::set_points(t, begin_points, end_points);
return t;
}
+ // \brief Sets the boundary of the polygon to the non-redundant coordinates in the iterator range
+ // \tparam T A type that models polygon_90_concept
+ // \tparam iT Iterator type over objects that model coordinate_concept
+ // \param t The polygon to set
+ // \param begin_compact_coordinates The start of the range of coordinates
+ // \param end_compact_coordinates The end of the range of coordinates
+
+/// \relatesalso polygon_90_concept
template <typename T, typename iT>
- typename requires_1 <typename gtl_if<typename gtl_or< typename is_mutable_polygon_90_type<T>::type,
- typename is_mutable_polygon_90_with_holes_type<T>::type>::type>::type, T>::type &
+ typename requires_1 <typename gtl_or<
+ typename is_mutable_polygon_90_type<T>::type,
+ typename is_mutable_polygon_90_with_holes_type<T>::type>::type, T>::type &
set_compact(T& t, iT begin_compact_coordinates, iT end_compact_coordinates) {
polygon_90_mutable_traits<T>::set_compact(t, begin_compact_coordinates, end_compact_coordinates);
return t;
}
+/// \relatesalso polygon_with_holes_concept
template <typename T, typename iT>
- typename requires_2 <typename gtl_if<typename is_any_mutable_polygon_with_holes_type<T>::type>::type,
- typename is_different_type_SFINAE<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
+ typename requires_1< typename gtl_and <
+ typename is_any_mutable_polygon_with_holes_type<T>::type,
+ typename gtl_different_type<typename geometry_domain<typename geometry_concept<T>::type>::type,
+ manhattan_domain>::type>::type,
T>::type &
set_compact(T& t, iT begin_compact_coordinates, iT end_compact_coordinates) {
iterator_compact_to_points<iT, point_data<typename polygon_traits<T>::coordinate_type> >
@@ -326,83 +360,105 @@
return set_points(t, itrb, itre);
}
+/// \relatesalso polygon_with_holes_concept
template <typename T, typename iT>
- typename requires_1 <typename gtl_if<typename is_any_mutable_polygon_with_holes_type<T>::type>::type, T>::type &
+ typename requires_1 <typename is_any_mutable_polygon_with_holes_type<T>::type, T>::type &
set_holes(T& t, iT begin_holes, iT end_holes) {
polygon_with_holes_mutable_traits<T>::set_holes(t, begin_holes, end_holes);
return t;
}
+/// \relatesalso polygon_90_concept
template <typename T>
- typename requires_2 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename is_same_type_SFINAE<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
- typename polygon_90_traits<T>::compact_iterator_type>::type
+ typename requires_1<
+ typename gtl_if<
+ typename gtl_and <typename is_polygon_with_holes_type<T>::type,
+ typename gtl_same_type<typename geometry_domain<typename geometry_concept<T>::type>::type,
+ manhattan_domain>::type>::type>::type,
+ typename polygon_90_traits<T>::compact_iterator_type>::type
begin_compact(const T& polygon) {
return polygon_90_traits<T>::begin_compact(polygon);
}
+/// \relatesalso polygon_90_concept
template <typename T>
- typename requires_2 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename is_same_type_SFINAE<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
+ typename requires_1< typename gtl_if<
+ typename gtl_and <typename is_polygon_with_holes_type<T>::type,
+ typename gtl_same_type<typename geometry_domain<typename geometry_concept<T>::type>::type,
+ manhattan_domain>::type>::type>::type,
typename polygon_90_traits<T>::compact_iterator_type>::type
end_compact(const T& polygon) {
return polygon_90_traits<T>::end_compact(polygon);
}
+ /// \relatesalso polygon_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename polygon_traits<T>::iterator_type>::type
+ typename requires_1 < typename gtl_if<
+ typename is_polygon_with_holes_type<T>::type>::type,
+ typename polygon_traits<T>::iterator_type>::type
begin_points(const T& polygon) {
return polygon_traits<T>::begin_points(polygon);
}
+ /// \relatesalso polygon_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename polygon_traits<T>::iterator_type>::type
+ typename requires_1 < typename gtl_if<
+ typename is_polygon_with_holes_type<T>::type>::type,
+ typename polygon_traits<T>::iterator_type>::type
end_points(const T& polygon) {
return polygon_traits<T>::end_points(polygon);
}
+ /// \relatesalso polygon_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
+ typename requires_1 <typename is_polygon_with_holes_type<T>::type,
unsigned int>::type
size(const T& polygon) {
return polygon_traits<T>::size(polygon);
}
+/// \relatesalso polygon_with_holes_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename polygon_with_holes_traits<T>::iterator_holes_type>::type
+ typename requires_1 < typename gtl_if<
+ typename is_polygon_with_holes_type<T>::type>::type,
+ typename polygon_with_holes_traits<T>::iterator_holes_type>::type
begin_holes(const T& polygon) {
return polygon_with_holes_traits<T>::begin_holes(polygon);
}
+/// \relatesalso polygon_with_holes_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename polygon_with_holes_traits<T>::iterator_holes_type>::type
+ typename requires_1 < typename gtl_if<
+ typename is_polygon_with_holes_type<T>::type>::type,
+ typename polygon_with_holes_traits<T>::iterator_holes_type>::type
end_holes(const T& polygon) {
return polygon_with_holes_traits<T>::end_holes(polygon);
}
+/// \relatesalso polygon_with_holes_concept
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
+ typename requires_1 <typename is_polygon_with_holes_type<T>::type,
unsigned int>::type
size_holes(const T& polygon) {
return polygon_with_holes_traits<T>::size_holes(polygon);
}
+ // \relatesalso polygon_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_type<T1>::type>::type,
- typename gtl_if<typename is_polygon_type<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_type<T1>::type,
+ typename is_polygon_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_mutable_traits<T1>::set_points(lvalue, polygon_traits<T2>::begin_points(rvalue),
polygon_traits<T2>::end_points(rvalue));
return lvalue;
}
+// \relatesalso polygon_with_holes_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_with_holes_type<T1>::type>::type,
- typename gtl_if<typename is_polygon_with_holes_type<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_with_holes_type<T1>::type,
+ typename is_polygon_with_holes_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_mutable_traits<T1>::set_points(lvalue, polygon_traits<T2>::begin_points(rvalue),
polygon_traits<T2>::end_points(rvalue));
@@ -411,19 +467,20 @@
return lvalue;
}
+ // \relatesalso polygon_45_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_type<T1>::type>::type,
- typename gtl_if<typename is_polygon_45_type<T2>::type>::type,
- T1>::type &
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_45_type<T1>::type, typename is_polygon_45_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_mutable_traits<T1>::set_points(lvalue, polygon_traits<T2>::begin_points(rvalue),
polygon_traits<T2>::end_points(rvalue));
return lvalue;
}
+// \relatesalso polygon_45_with_holes_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_45_with_holes_type<T1>::type>::type,
- typename gtl_if<typename is_polygon_45_with_holes_type<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_45_with_holes_type<T1>::type,
+ typename is_polygon_45_with_holes_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_mutable_traits<T1>::set_points(lvalue, polygon_traits<T2>::begin_points(rvalue),
polygon_traits<T2>::end_points(rvalue));
@@ -432,18 +489,22 @@
return lvalue;
}
+ // \relatesalso polygon_90_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_type<T1>::type>::type,
- typename gtl_if<typename is_polygon_90_type<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_90_type<T1>::type,
+ typename is_polygon_90_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_90_mutable_traits<T1>::set_compact(lvalue, polygon_90_traits<T2>::begin_compact(rvalue),
polygon_90_traits<T2>::end_compact(rvalue));
return lvalue;
}
+// \relatesalso polygon_90_with_holes_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_with_holes_type<T1>::type>::type,
- typename gtl_if< typename is_polygon_90_with_holes_type<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_polygon_90_with_holes_type<T1>::type,
+ typename is_polygon_90_with_holes_type<T2>::type>::type, T1>::type &
assign(T1& lvalue, const T2& rvalue) {
polygon_90_mutable_traits<T1>::set_compact(lvalue, polygon_90_traits<T2>::begin_compact(rvalue),
polygon_90_traits<T2>::end_compact(rvalue));
@@ -452,9 +513,11 @@
return lvalue;
}
+ // \relatesalso polygon_90_concept
template <typename T1, typename T2>
- typename requires_2< typename gtl_if<typename is_any_mutable_polygon_type<T1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<T2>::type>::type, T1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_type<T1>::type,
+ typename is_rectangle_concept<typename geometry_concept<T2>::type>::type>::type, T1>::type &
assign(T1& polygon, const T2& rect) {
typedef point_data<typename polygon_traits<T1>::coordinate_type> PT;
PT points[4] = {PT(xl(rect), yl(rect)), PT(xh(rect), yl(rect)), PT(xh(rect), yh(rect)), PT(xl(rect), yh(rect))};
@@ -462,9 +525,10 @@
return polygon;
}
+/// \relatesalso polygon_90_concept
template <typename polygon_type, typename point_type>
- typename requires_2< typename gtl_if<typename is_mutable_polygon_90_type<polygon_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_polygon_90_type<polygon_type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
polygon_type>::type &
convolve(polygon_type& polygon, const point_type& point) {
std::vector<typename polygon_90_traits<polygon_type>::coordinate_type> coords;
@@ -478,10 +542,13 @@
polygon_90_mutable_traits<polygon_type>::set_compact(polygon, coords.begin(), coords.end());
return polygon;
}
+
+/// \relatesalso polygon_concept
template <typename polygon_type, typename point_type>
- typename requires_2< typename gtl_if<typename gtl_or<typename is_mutable_polygon_45_type<polygon_type>::type,
- typename is_mutable_polygon_type<polygon_type>::type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_and< typename gtl_or<
+ typename is_mutable_polygon_45_type<polygon_type>::type,
+ typename is_mutable_polygon_type<polygon_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
polygon_type>::type &
convolve(polygon_type& polygon, const point_type& point) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
@@ -495,10 +562,12 @@
return polygon;
}
+/// \relatesalso polygon_with_holes_concept
template <typename polygon_type, typename point_type>
- typename requires_2< typename gtl_if<typename is_any_mutable_polygon_with_holes_type<polygon_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
- polygon_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_with_holes_type<polygon_type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
+ polygon_type>::type &
convolve(polygon_type& polygon, const point_type& point) {
typedef typename polygon_with_holes_traits<polygon_type>::hole_type hole_type;
hole_type h;
@@ -516,36 +585,23 @@
return polygon;
}
+/// \relatesalso polygon_concept
template <typename T>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_type<T>::type>::type, T>::type &
+ typename requires_1< typename is_any_mutable_polygon_type<T>::type, T>::type &
move(T& polygon, orientation_2d orient, typename polygon_traits<T>::coordinate_type displacement) {
typedef typename polygon_traits<T>::coordinate_type Unit;
if(orient == HORIZONTAL) return convolve(polygon, point_data<Unit>(displacement, Unit(0)));
return convolve(polygon, point_data<Unit>(Unit(0), displacement));
}
+/// \relatesalso polygon_concept
+/// \brief Applies a transformation to the polygon.
+/// \tparam polygon_type A type that models polygon_concept
+/// \tparam transform_type A type that may be either axis_transformation or transformation or that overloads point_concept::transform
+/// \param polygon The polygon to transform
+/// \param tr The transformation to apply
template <typename polygon_type, typename transform_type>
- typename requires_1< typename gtl_if<typename is_mutable_polygon_90_type<polygon_type>::type>::type, polygon_type>::type &
- transform(polygon_type& polygon, const transform_type& tr) {
- std::vector<typename polygon_90_traits<polygon_type>::coordinate_type> coords;
- coords.reserve(size(polygon));
- bool pingpong = true;
- for(typename polygon_90_traits<polygon_type>::compact_iterator_type iter = begin_compact(polygon);
- iter != end_compact(polygon); ++iter) {
- typename polygon_90_traits<polygon_type>::coordinate_type dummy(0);
- coords.push_back(*iter);
- if(pingpong)
- tr.transform(coords.back(), dummy);
- else
- tr.transform(dummy, coords.back());
- pingpong = !pingpong;
- }
- polygon_90_mutable_traits<polygon_type>::set_compact(polygon, coords.begin(), coords.end());
- return polygon;
- }
- template <typename polygon_type, typename transform_type>
- typename requires_1< typename gtl_if<typename gtl_or<typename is_mutable_polygon_45_type<polygon_type>::type,
- typename is_mutable_polygon_type<polygon_type>::type>::type>::type, polygon_type>::type &
+ typename requires_1< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type, polygon_type>::type &
transform(polygon_type& polygon, const transform_type& tr) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
points.reserve(size(polygon));
@@ -558,8 +614,9 @@
return polygon;
}
+/// \relatesalso polygon_with_holes_concept
template <typename T, typename transform_type>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_with_holes_type<T>::type>::type, T>::type &
+ typename requires_1< typename is_any_mutable_polygon_with_holes_type<T>::type, T>::type &
transform(T& polygon, const transform_type& tr) {
typedef typename polygon_with_holes_traits<T>::hole_type hole_type;
hole_type h;
@@ -578,7 +635,7 @@
}
template <typename polygon_type>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_without_holes_type<polygon_type>::type>::type, polygon_type>::type &
+ typename requires_1< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type, polygon_type>::type &
scale_up(polygon_type& polygon, typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::unsigned_area_type factor) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
points.reserve(size(polygon));
@@ -592,7 +649,7 @@
}
template <typename T>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_with_holes_type<T>::type>::type, T>::type &
+ typename requires_1< typename is_any_mutable_polygon_with_holes_type<T>::type, T>::type &
scale_up(T& polygon, typename coordinate_traits<typename polygon_traits<T>::coordinate_type>::unsigned_area_type factor) {
typedef typename polygon_with_holes_traits<T>::hole_type hole_type;
hole_type h;
@@ -612,11 +669,12 @@
//scale non-45 down
template <typename polygon_type>
- typename requires_2< typename gtl_if<typename is_any_mutable_polygon_without_holes_type<polygon_type>::type>::type,
- typename gtl_if<typename gtl_not<typename gtl_same_type
- < forty_five_domain,
- typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type>::type,
- polygon_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type,
+ typename gtl_not<typename gtl_same_type
+ < forty_five_domain,
+ typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type>::type,
+ polygon_type>::type &
scale_down(polygon_type& polygon, typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::unsigned_area_type factor) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
points.reserve(size(polygon));
@@ -711,7 +769,7 @@
}
template <typename polygon_type>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_without_holes_type<polygon_type>::type>::type, polygon_type>::type &
+ typename requires_1< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type, polygon_type>::type &
snap_to_45(polygon_type& polygon) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
points.reserve(size(polygon));
@@ -725,7 +783,7 @@
}
template <typename polygon_type>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_with_holes_type<polygon_type>::type>::type, polygon_type>::type &
+ typename requires_1< typename is_any_mutable_polygon_with_holes_type<polygon_type>::type, polygon_type>::type &
snap_to_45(polygon_type& polygon) {
typedef typename polygon_with_holes_traits<polygon_type>::hole_type hole_type;
hole_type h;
@@ -745,11 +803,12 @@
//scale specifically 45 down
template <typename polygon_type>
- typename requires_2< typename gtl_if<typename is_any_mutable_polygon_without_holes_type<polygon_type>::type>::type,
- typename gtl_if<typename gtl_same_type
- < forty_five_domain,
- typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type,
- polygon_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type,
+ typename gtl_same_type
+ < forty_five_domain,
+ typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type,
+ polygon_type>::type &
scale_down(polygon_type& polygon, typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::unsigned_area_type factor) {
std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
points.reserve(size(polygon));
@@ -764,7 +823,7 @@
}
template <typename T>
- typename requires_1< typename gtl_if<typename is_any_mutable_polygon_with_holes_type<T>::type>::type, T>::type &
+ typename requires_1< typename is_any_mutable_polygon_with_holes_type<T>::type, T>::type &
scale_down(T& polygon, typename coordinate_traits<typename polygon_traits<T>::coordinate_type>::unsigned_area_type factor) {
typedef typename polygon_with_holes_traits<T>::hole_type hole_type;
hole_type h;
@@ -782,6 +841,66 @@
return polygon;
}
+ //scale non-45
+ template <typename polygon_type>
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type,
+ typename gtl_not<typename gtl_same_type
+ < forty_five_domain,
+ typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type>::type,
+ polygon_type>::type &
+ scale(polygon_type& polygon, double factor) {
+ std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
+ points.reserve(size(polygon));
+ for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
+ iter != end_points(polygon); ++iter) {
+ points.push_back(*iter);
+ scale(points.back(), anisotropic_scale_factor<double>(factor, factor));
+ }
+ polygon_mutable_traits<polygon_type>::set_points(polygon, points.begin(), points.end());
+ return polygon;
+ }
+
+ //scale specifically 45
+ template <typename polygon_type>
+ typename requires_1<
+ typename gtl_and< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type,
+ typename gtl_same_type
+ < forty_five_domain,
+ typename geometry_domain<typename geometry_concept<polygon_type>::type>::type>::type>::type,
+ polygon_type>::type &
+ scale(polygon_type& polygon, double factor) {
+ std::vector<point_data<typename polygon_traits<polygon_type>::coordinate_type> > points;
+ points.reserve(size(polygon));
+ for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
+ iter != end_points(polygon); ++iter) {
+ points.push_back(*iter);
+ scale(points.back(), anisotropic_scale_factor<double>(factor, factor));
+ }
+ snap_point_vector_to_45(points);
+ polygon_mutable_traits<polygon_type>::set_points(polygon, points.begin(), points.end());
+ return polygon;
+ }
+
+ template <typename T>
+ typename requires_1< typename is_any_mutable_polygon_with_holes_type<T>::type, T>::type &
+ scale(T& polygon, double factor) {
+ typedef typename polygon_with_holes_traits<T>::hole_type hole_type;
+ hole_type h;
+ set_points(h, begin_points(polygon), end_points(polygon));
+ scale(h, factor);
+ std::vector<hole_type> holes;
+ holes.reserve(size_holes(polygon));
+ for(typename polygon_with_holes_traits<T>::iterator_holes_type itr = begin_holes(polygon);
+ itr != end_holes(polygon); ++itr) {
+ holes.push_back(*itr);
+ scale(holes.back(), factor);
+ }
+ assign(polygon, h);
+ set_holes(polygon, holes.begin(), holes.end());
+ return polygon;
+ }
+
template <typename iterator_type, typename area_type>
static area_type
point_sequence_area(iterator_type begin_range, iterator_type end_range) {
@@ -825,9 +944,10 @@
}
template <typename T>
- typename requires_1< typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename area_type_by_domain< typename geometry_domain<typename geometry_concept<T>::type>::type,
- typename polygon_traits<T>::coordinate_type>::type>::type
+ typename requires_1<
+ typename is_polygon_with_holes_type<T>::type,
+ typename area_type_by_domain< typename geometry_domain<typename geometry_concept<T>::type>::type,
+ typename polygon_traits<T>::coordinate_type>::type>::type
area(const T& polygon) {
typedef typename area_type_by_domain< typename geometry_domain<typename geometry_concept<T>::type>::type,
typename polygon_traits<T>::coordinate_type>::type area_type;
@@ -873,7 +993,7 @@
}
template <typename polygon_type>
- typename requires_1< typename gtl_if<typename is_polygon_with_holes_type<polygon_type>::type>::type, bool>::type
+ typename requires_1< typename is_polygon_with_holes_type<polygon_type>::type, bool>::type
is_45(const polygon_type& polygon) {
typename polygon_traits<polygon_type>::iterator_type itr = begin_points(polygon), itr_end = end_points(polygon);
if(!point_sequence_is_45(itr, itr_end)) return false;
@@ -906,9 +1026,11 @@
}
template <typename T>
- typename requires_1< typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename distance_type_by_domain<typename geometry_domain<typename geometry_concept<T>::type>::type,
- typename polygon_traits<T>::coordinate_type>::type>::type
+ typename requires_1<
+ typename gtl_if<
+ typename is_polygon_with_holes_type<T>::type>::type,
+ typename distance_type_by_domain<typename geometry_domain<typename geometry_concept<T>::type>::type,
+ typename polygon_traits<T>::coordinate_type>::type>::type
perimeter(const T& polygon) {
typedef typename distance_type_by_domain
<typename geometry_domain<typename geometry_concept<T>::type>::type, typename polygon_traits<T>::coordinate_type>::type Unit;
@@ -925,7 +1047,7 @@
}
template <typename T>
- typename requires_1 <typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
+ typename requires_1 <typename is_polygon_with_holes_type<T>::type,
direction_1d>::type
winding(const T& polygon) {
winding_direction wd = polygon_traits<T>::winding(polygon);
@@ -939,10 +1061,11 @@
}
template <typename T, typename input_point_type>
- typename requires_3< typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename is_same_type_SFINAE<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
- typename is_same_type_SFINAE<typename geometry_concept<input_point_type>::type, point_concept>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and_3< typename is_polygon_with_holes_type<T>::type,
+ typename gtl_same_type<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
+ typename gtl_same_type<typename geometry_concept<input_point_type>::type, point_concept>::type>::type,
+ bool>::type
contains(const T& polygon, const input_point_type& point, bool consider_touch = true) {
typedef T polygon_type;
typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
@@ -970,9 +1093,9 @@
x(point)) return consider_touch;
++increment;
if(y(current_pt) !=
- y(point) &&
- y(prev_pt) !=
- y(point)) {
+ y(point) &&
+ y(prev_pt) !=
+ y(point)) {
++increment;
}
counts[index] += increment;
@@ -987,18 +1110,22 @@
}
template <typename T, typename input_point_type>
- typename requires_3< typename gtl_if<typename is_polygon_with_holes_type<T>::type>::type,
- typename is_different_type_SFINAE<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
- typename is_same_type_SFINAE<typename geometry_concept<input_point_type>::type, point_concept>::type, bool>::type
+ typename requires_1<
+ typename gtl_and_3<
+ typename is_polygon_with_holes_type<T>::type,
+ typename gtl_different_type<typename geometry_domain<typename geometry_concept<T>::type>::type, manhattan_domain>::type,
+ typename gtl_same_type<typename geometry_concept<input_point_type>::type, point_concept>::type>::type,
+ bool>::type
contains(const T& polygon, const input_point_type& point, bool consider_touch = true) {
std::cout << "not implemented\n"; //awaiting arrival of general edge concept
return false;
}
template <typename T1, typename T2>
- typename requires_2< typename is_mutable_point_concept<typename geometry_concept<T1>::type>::type,
- typename gtl_if<typename is_polygon_with_holes_type<T2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_point_concept<typename geometry_concept<T1>::type>::type,
+ typename is_polygon_with_holes_type<T2>::type>::type,
+ bool>::type
center(T1& center_point, const T2& polygon) {
typedef typename polygon_traits<T2>::coordinate_type coordinate_type;
rectangle_data<coordinate_type> bbox;
@@ -1007,9 +1134,10 @@
}
template <typename T1, typename T2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<T1>::type>::type,
- typename gtl_if<typename is_polygon_with_holes_type<T2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<T1>::type>::type,
+ typename is_polygon_with_holes_type<T2>::type>::type,
+ bool>::type
extents(T1& bounding_box, const T2& polygon) {
typedef typename polygon_traits<T2>::iterator_type iterator;
bool first_iteration = true;
Modified: sandbox/gtl/gtl/rectangle_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_concept.hpp (original)
+++ sandbox/gtl/gtl/rectangle_concept.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -27,132 +27,126 @@
struct rectangle_concept {};
template <typename T>
- struct is_rectangle_concept {};
+ struct is_rectangle_concept { typedef gtl_no type; };
template <>
- struct is_rectangle_concept<rectangle_concept> { typedef void type; };
+ struct is_rectangle_concept<rectangle_concept> { typedef gtl_yes type; };
template <typename T>
- struct is_mutable_rectangle_concept {};
+ struct is_mutable_rectangle_concept { typedef gtl_no type; };
template <>
- struct is_mutable_rectangle_concept<rectangle_concept> { typedef void type; };
+ struct is_mutable_rectangle_concept<rectangle_concept> { typedef gtl_yes type; };
template <>
struct geometry_domain<rectangle_concept> { typedef manhattan_domain type; };
- template <typename T, orientation_2d_enum orient>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename rectangle_traits<T>::interval_type>::type
- get(const T& rectangle) {
- return rectangle_traits<T>::get(rectangle, orient);
- }
-
template <typename T>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<T>::type>::type>::type,
typename rectangle_traits<T>::interval_type>::type
get(const T& rectangle, orientation_2d orient) {
return rectangle_traits<T>::get(rectangle, orient);
}
template <typename T>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<T>::type>::type>::type,
typename rectangle_traits<T>::interval_type>::type
horizontal(const T& rectangle) {
return rectangle_traits<T>::get(rectangle, HORIZONTAL);
}
template <typename T>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<T>::type>::type>::type,
typename rectangle_traits<T>::interval_type>::type
vertical(const T& rectangle) {
return rectangle_traits<T>::get(rectangle, VERTICAL);
}
template <orientation_2d_enum orient, typename T, typename T2>
- typename requires_2<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
- void>::type
+ typename requires_1< typename gtl_and<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
+ void>::type
set(T& rectangle, const T2& interval) {
rectangle_mutable_traits<T>::set(rectangle, orient, interval);
}
template <typename T, typename T2>
- typename requires_2<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
- void>::type
+ typename requires_1< typename gtl_and<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
+ void>::type
set(T& rectangle, orientation_2d orient, const T2& interval) {
rectangle_mutable_traits<T>::set(rectangle, orient, interval);
}
template <typename T, typename T2>
- typename requires_2<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
- void>::type
+ typename requires_1< typename gtl_and<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
+ void>::type
horizontal(T& rectangle, const T2& interval) {
rectangle_mutable_traits<T>::set(rectangle, HORIZONTAL, interval);
}
template <typename T, typename T2>
- typename requires_2<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type,
- void>::type
+ typename requires_1<
+ typename gtl_and<typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type, void>::type
vertical(T& rectangle, const T2& interval) {
rectangle_mutable_traits<T>::set(rectangle, VERTICAL, interval);
}
template <typename T, typename T2, typename T3>
- typename requires_1<
- typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- T>::type
+ typename requires_1< typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ T>::type
construct(const T2& interval_horizontal,
const T3& interval_vertical) {
return rectangle_mutable_traits<T>::construct(interval_horizontal, interval_vertical); }
-
+
template <typename T, typename coord_type>
- typename requires_1<
- typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- T>::type
+ typename requires_1< typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ T>::type
construct(coord_type xl, coord_type yl, coord_type xh, coord_type yh) {
return rectangle_mutable_traits<T>::construct(interval_data<coord_type>(xl, xh),
- interval_data<coord_type>(yl, yh));
+ interval_data<coord_type>(yl, yh));
}
-
+
template <typename T, typename T2>
- typename requires_2<
- typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<T2>::type>::type,
+ typename requires_1<
+ typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<T2>::type>::type>::type,
T>::type
copy_construct(const T2& rectangle) {
return construct<T> (get(rectangle, HORIZONTAL), get(rectangle, VERTICAL));
}
-
+
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1<
+ typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
rectangle_type_1>::type &
assign(rectangle_type_1& lvalue, const rectangle_type_2& rvalue) {
set(lvalue, HORIZONTAL, get(rvalue, HORIZONTAL));
set(lvalue, VERTICAL, get(rvalue, VERTICAL));
return lvalue;
}
-
+
template <typename T, typename T2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<T2>::type>::type,
+ typename requires_1<
+ typename gtl_and<
+ typename is_rectangle_concept<typename geometry_concept<T>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<T2>::type>::type>::type,
bool>::type
equivalence(const T& rect1, const T2& rect2) {
return equivalence(get(rect1, HORIZONTAL), get(rect2, HORIZONTAL)) &&
equivalence(get(rect1, VERTICAL), get(rect2, VERTICAL));
}
-
+
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename rectangle_traits<rectangle_type>::coordinate_type>::type
get(const rectangle_type& rectangle, orientation_2d orient, direction_1d dir) {
return get(rectangle_traits<rectangle_type>::get(rectangle, orient), dir);
}
-
+
template <typename rectangle_type>
typename requires_1<typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type, void>::type
set(rectangle_type& rectangle, orientation_2d orient, direction_1d dir,
@@ -163,7 +157,7 @@
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename rectangle_traits<rectangle_type>::coordinate_type>::type
xl(const rectangle_type& rectangle) {
return get(rectangle, HORIZONTAL, LOW);
@@ -176,7 +170,7 @@
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename rectangle_traits<rectangle_type>::coordinate_type>::type
xh(const rectangle_type& rectangle) {
return get(rectangle, HORIZONTAL, HIGH);
@@ -189,7 +183,7 @@
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename rectangle_traits<rectangle_type>::coordinate_type>::type
yl(const rectangle_type& rectangle) {
return get(rectangle, VERTICAL, LOW);
@@ -202,7 +196,7 @@
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename rectangle_traits<rectangle_type>::coordinate_type>::type
yh(const rectangle_type& rectangle) {
return get(rectangle, VERTICAL, HIGH);
@@ -215,59 +209,58 @@
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
point_data<typename rectangle_traits<rectangle_type>::coordinate_type> >::type
ll(const rectangle_type& rectangle) {
return point_data<typename rectangle_traits<rectangle_type>::coordinate_type> (xl(rectangle), yl(rectangle));
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
point_data<typename rectangle_traits<rectangle_type>::coordinate_type> >::type
lr(const rectangle_type& rectangle) {
return point_data<typename rectangle_traits<rectangle_type>::coordinate_type> (xh(rectangle), yl(rectangle));
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
point_data<typename rectangle_traits<rectangle_type>::coordinate_type> >::type
ul(const rectangle_type& rectangle) {
return point_data<typename rectangle_traits<rectangle_type>::coordinate_type> (xl(rectangle), yh(rectangle));
}
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
point_data<typename rectangle_traits<rectangle_type>::coordinate_type> >::type
ur(const rectangle_type& rectangle) {
return point_data<typename rectangle_traits<rectangle_type>::coordinate_type> (xh(rectangle), yh(rectangle));
}
template <typename rectangle_type, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ bool>::type
contains(const rectangle_type& rectangle, const rectangle_type_2 rectangle_contained,
- bool consider_touch = true) {
+ bool consider_touch = true) {
return contains(horizontal(rectangle), horizontal(rectangle_contained), consider_touch) &&
contains(vertical(rectangle), vertical(rectangle_contained), consider_touch);
}
+
template <typename rectangle_type, typename point_type>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type, bool>::type
contains(const rectangle_type& rectangle, const point_type point_contained,
- bool consider_touch = true) {
+ bool consider_touch = true) {
return contains(horizontal(rectangle), x(point_contained), consider_touch) &&
contains(vertical(rectangle), y(point_contained), consider_touch);
}
- /// set all four coordinates based upon two points
+ // set all four coordinates based upon two points
template <typename rectangle_type, typename point_type_1, typename point_type_2>
- typename requires_3< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type_2>::type>::type,
+ typename requires_1< typename gtl_and_3<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type_2>::type>::type>::type,
rectangle_type>::type &
set_points(rectangle_type& rectangle, const point_type_1& p1,
const point_type_2& p2) {
@@ -281,7 +274,7 @@
return rectangle;
}
- /// move rectangle by delta in orient
+ // move rectangle by delta in orient
template <typename rectangle_type>
typename requires_1<typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type, rectangle_type>::type &
move(rectangle_type& rectangle, orientation_2d orient,
@@ -292,11 +285,13 @@
return rectangle;
}
- /// convolve this with b
+ // convolve this with b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- rectangle_type_1>::type &
+ typename requires_1<
+ typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ rectangle_type_1>::type &
convolve(rectangle_type_1& rectangle,
const rectangle_type_2& convolution_rectangle) {
typename rectangle_traits<rectangle_type_1>::interval_type ivl = horizontal(rectangle);
@@ -306,10 +301,11 @@
return rectangle;
}
- /// deconvolve this with b
+ // deconvolve this with b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
rectangle_type_1>::type &
deconvolve(rectangle_type_1& rectangle, const rectangle_type_2& convolution_rectangle) {
typename rectangle_traits<rectangle_type_1>::interval_type ivl = horizontal(rectangle);
@@ -319,11 +315,12 @@
return rectangle;
}
- /// reflectedConvolve this with b
+ // reflectedConvolve this with b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- rectangle_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ rectangle_type_1>::type &
reflected_convolve(rectangle_type_1& rectangle, const rectangle_type_2& convolution_rectangle) {
typename rectangle_traits<rectangle_type_1>::interval_type ivl = horizontal(rectangle);
horizontal(rectangle, reflected_convolve(ivl, horizontal(convolution_rectangle)));
@@ -332,12 +329,13 @@
return rectangle;
}
- /// reflectedDeconvolve this with b
- /// deconvolve this with b
+ // reflectedDeconvolve this with b
+ // deconvolve this with b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- rectangle_type_1>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ rectangle_type_1>::type &
reflected_deconvolve(rectangle_type_1& rectangle, const rectangle_type_2& convolution_rectangle) {
typename rectangle_traits<rectangle_type_1>::interval_type ivl = horizontal(rectangle);
horizontal(rectangle, reflected_deconvolve(ivl, horizontal(convolution_rectangle)));
@@ -346,10 +344,10 @@
return rectangle;
}
- /// convolve with point
+ // convolve with point
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
rectangle_type>::type &
convolve(rectangle_type& rectangle, const point_type& convolution_point) {
typename rectangle_traits<rectangle_type>::interval_type ivl = horizontal(rectangle);
@@ -359,11 +357,11 @@
return rectangle;
}
- /// deconvolve with point
+ // deconvolve with point
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
- rectangle_type>::type &
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type, rectangle_type>::type &
deconvolve(rectangle_type& rectangle, const point_type& convolution_point) {
typename rectangle_traits<rectangle_type>::interval_type ivl = horizontal(rectangle);
horizontal(rectangle, deconvolve(ivl, x(convolution_point)));
@@ -372,14 +370,15 @@
return rectangle;
}
- /// get the magnitude of the interval range depending on orient
+ // get the magnitude of the interval range depending on orient
template <typename rectangle_type>
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
delta(const rectangle_type& rectangle, orientation_2d orient) {
return delta(get(rectangle, orient));
}
- /// get the area of the rectangle
+ // get the area of the rectangle
template <typename rectangle_type>
typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::manhattan_area_type>::type
@@ -388,7 +387,7 @@
return (area_type)delta(rectangle, HORIZONTAL) * (area_type)delta(rectangle, VERTICAL);
}
- /// returns the orientation of the longest side
+ // returns the orientation of the longest side
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
orientation_2d>::type
@@ -397,44 +396,44 @@
HORIZONTAL : VERTICAL;
}
- /// get the half perimeter of the rectangle
+ // get the half perimeter of the rectangle
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
half_perimeter(const rectangle_type& rectangle) {
return delta(rectangle, HORIZONTAL) + delta(rectangle, VERTICAL);
}
- /// get the perimeter of the rectangle
+ // get the perimeter of the rectangle
template <typename rectangle_type>
- typename requires_1< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename requires_1< typename gtl_if<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
perimeter(const rectangle_type& rectangle) {
return 2 * half_perimeter(rectangle);
}
- /// check if Rectangle b intersects `this` Rectangle
+ // check if Rectangle b intersects `this` Rectangle
// [in] b Rectangle that will be checked
// [in] considerTouch If true, return true even if b touches the boundary
// [ret] . true if `t` intersects b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1<
+ typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
bool>::type
intersects(const rectangle_type_1& rectangle, const rectangle_type_2& b, bool consider_touch = true) {
return intersects(horizontal(rectangle), horizontal(b), consider_touch) &&
intersects(vertical(rectangle), vertical(b), consider_touch);
}
- /// Check if boundaries of Rectangle b and `this` Rectangle intersect
+ // Check if boundaries of Rectangle b and `this` Rectangle intersect
// [in] b Rectangle that will be checked
// [in] considerTouch If true, return true even if p is on the foundary
// [ret] . true if `t` contains p
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1<
+ typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
bool>::type
boundaries_intersect(const rectangle_type_1& rectangle, const rectangle_type_2& b,
bool consider_touch = true) {
@@ -443,14 +442,13 @@
!(contains(b, rectangle, !consider_touch)));
}
- /// check if b is touching 'this' on the end specified by dir
+ // check if b is touching 'this' on the end specified by dir
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ bool>::type
abuts(const rectangle_type_1& rectangle, const rectangle_type_2& b,
- direction_2d dir) {
+ direction_2d dir) {
return
abuts(get(rectangle, orientation_2d(dir)),
get(b, orientation_2d(dir)),
@@ -459,35 +457,34 @@
get(b, orientation_2d(dir).get_perpendicular()), true);
}
- /// check if they are touching in the given orientation
+ // check if they are touching in the given orientation
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ bool>::type
abuts(const rectangle_type_1& rectangle, const rectangle_type_2& b,
- orientation_2d orient) {
+ orientation_2d orient) {
return
abuts(get(rectangle, orient), get(b, orient)) &&
intersects(get(rectangle, orient.get_perpendicular()),
get(b, orient.get_perpendicular()), true);
}
- /// check if they are touching but not overlapping
+ // check if they are touching but not overlapping
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2<
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- bool>::type
+ typename requires_1< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ bool>::type
abuts(const rectangle_type_1& rectangle, const rectangle_type_2& b) {
return abuts(rectangle, b, HORIZONTAL) || abuts(rectangle, b, VERTICAL);
}
- /// intersect rectangle with interval on orient
+ // intersect rectangle with interval on orient
template <typename rectangle_type, typename interval_type>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ bool>::type
intersect(rectangle_type& rectangle, const interval_type& b,
orientation_2d orient, bool consider_touch = true) {
typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
@@ -498,10 +495,10 @@
return false;
}
- /// clip rectangle to b
+ // clip rectangle to b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
bool>::type
intersect(rectangle_type_1& rectangle, const rectangle_type_2& b, bool consider_touch = true) {
if(intersects(rectangle, b)) {
@@ -512,10 +509,11 @@
return false;
}
- /// Sets this to the generalized intersection of this and the given rectangle
+ // Sets this to the generalized intersection of this and the given rectangle
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
rectangle_type_1>::type &
generalized_intersect(rectangle_type_1& rectangle, const rectangle_type_2& b) {
typename rectangle_traits<rectangle_type_1>::interval_type ivl = get(rectangle, HORIZONTAL);
@@ -527,72 +525,73 @@
return rectangle;
}
- /// bloat the interval specified by orient by bloating
+ // bloat the interval specified by orient by bloating
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
bloat(rectangle_type& rectangle, orientation_2d orient,
- typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
+ typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
bloat(ivl, bloating);
set(rectangle, orient, ivl);
return rectangle;
}
- /// bloat the Rectangle by bloating
+ // bloat the Rectangle by bloating
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
bloat(rectangle_type& rectangle,
- typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
+ typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
bloat(rectangle, HORIZONTAL, bloating);
return bloat(rectangle, VERTICAL, bloating);
}
- /// bloat the interval cooresponding to orient by bloating in dir direction
+ // bloat the interval cooresponding to orient by bloating in dir direction
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
bloat(rectangle_type& rectangle, direction_2d dir,
- typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
+ typename rectangle_traits<rectangle_type>::coordinate_type bloating) {
typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orientation_2d(dir));
bloat(ivl, direction_1d(dir), bloating);
set(rectangle, orientation_2d(dir), ivl);
return rectangle;
}
- /// shrink the interval specified by orient by bloating
+ // shrink the interval specified by orient by bloating
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
shrink(rectangle_type& rectangle, orientation_2d orient,
- typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
+ typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
return bloat(rectangle, orient, -shrinking);
}
- /// shrink the Rectangle by bloating
+ // shrink the Rectangle by bloating
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
shrink(rectangle_type& rectangle,
- typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
+ typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
return bloat(rectangle, -shrinking);
}
- /// shrink the interval cooresponding to orient by bloating in dir direction
+ // shrink the interval cooresponding to orient by bloating in dir direction
template <typename rectangle_type>
typename requires_1<typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
rectangle_type>::type &
shrink(rectangle_type& rectangle, direction_2d dir,
- typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
+ typename rectangle_traits<rectangle_type>::coordinate_type shrinking) {
return bloat(rectangle, dir, -shrinking);
}
- /// encompass interval on orient
+ // encompass interval on orient
template <typename rectangle_type, typename interval_type>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ bool>::type
encompass(rectangle_type& rectangle, const interval_type& b,
orientation_2d orient) {
typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
@@ -603,10 +602,11 @@
return false;
}
- /// enlarge rectangle to encompass the Rectangle b
+ // enlarge rectangle to encompass the Rectangle b
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_and<
+ typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
bool>::type
encompass(rectangle_type_1& rectangle, const rectangle_type_2& b) {
//note that operator | is intentional because both should be called regardless
@@ -614,11 +614,12 @@
encompass(rectangle, vertical(b), VERTICAL);
}
- /// enlarge rectangle to encompass the point b
+ // enlarge rectangle to encompass the point b
template <typename rectangle_type_1, typename point_type>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
+ bool>::type
encompass(rectangle_type_1& rectangle, const point_type& b) {
typename rectangle_traits<rectangle_type_1>::interval_type hivl, vivl;
hivl = horizontal(rectangle);
@@ -632,11 +633,12 @@
return retval;
}
- /// returns the center of the rectangle
+ // returns the center of the rectangle
template <typename point_type, typename rectangle_type>
- typename requires_2< typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
+ bool>::type
center(point_type& center_point, const rectangle_type& rectangle) {
center_point = construct<point_type>(center(horizontal(rectangle)),
center(vertical(rectangle)));
@@ -644,9 +646,10 @@
}
template <typename point_type, typename rectangle_type>
- typename requires_2< typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
+ bool>::type
get_corner(point_type& corner_point, const rectangle_type& rectangle, direction_2d direction_facing, direction_1d direction_turning) {
typedef typename rectangle_traits<rectangle_type>::coordinate_type Unit;
Unit u1 = get(rectangle, direction_facing);
@@ -665,8 +668,8 @@
}
template <typename rectangle_type_1, typename rectangle_type_2>
- typename requires_2< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_and< typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
bool>::type
join_with(rectangle_type_1& rectangle, const rectangle_type_2& b) {
typedef typename rectangle_traits<rectangle_type_1>::interval_type Interval1;
@@ -687,24 +690,28 @@
}
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_if< typename gtl_and<
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
euclidean_distance(const rectangle_type& lvalue, const point_type& rvalue, orientation_2d orient) {
return euclidean_distance(get(lvalue, orient), get(rvalue, orient));
}
template <typename rectangle_type, typename rectangle_type_2>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_if< typename gtl_and<
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type>::type,
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
euclidean_distance(const rectangle_type& lvalue, const rectangle_type_2& rvalue, orientation_2d orient) {
return euclidean_distance(get(lvalue, orient), get(rvalue, orient));
}
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_if< typename gtl_and<
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
square_euclidean_distance(rectangle_type& lvalue, const point_type& rvalue) {
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference xdist, ydist;
@@ -714,9 +721,10 @@
}
template <typename rectangle_type, typename rectangle_type_2>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_if< typename gtl_and< typename is_rectangle_concept< typename geometry_concept<rectangle_type>::type>::type,
+ typename is_rectangle_concept< typename geometry_concept<rectangle_type_2>::type>::type>::type>::type,
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
square_euclidean_distance(const rectangle_type& lvalue, const rectangle_type_2& rvalue) {
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference xdist, ydist;
xdist = euclidean_distance(lvalue, rvalue, HORIZONTAL);
@@ -725,8 +733,8 @@
}
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
+ typename requires_1< typename gtl_if< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_distance>::type
euclidean_distance(rectangle_type& lvalue, const point_type& rvalue) {
return sqrt((typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_distance)
@@ -734,8 +742,8 @@
}
template <typename rectangle_type, typename rectangle_type_2>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
+ typename requires_1< typename gtl_if< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type>::type,
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_distance>::type
euclidean_distance(const rectangle_type& lvalue, const rectangle_type_2& rvalue) {
return sqrt((typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_distance)
@@ -743,9 +751,10 @@
}
template <typename rectangle_type, typename point_type>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_point_concept<typename geometry_concept<point_type>::type>::type,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_if< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type>::type,
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
manhattan_distance(rectangle_type& lvalue, const point_type& rvalue) {
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference xdist, ydist;
xdist = euclidean_distance(lvalue, rvalue, HORIZONTAL);
@@ -754,9 +763,10 @@
}
template <typename rectangle_type, typename rectangle_type_2>
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
+ typename requires_1<
+ typename gtl_if< typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type>::type,
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference>::type
manhattan_distance(const rectangle_type& lvalue, const rectangle_type_2& rvalue) {
typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::coordinate_difference xdist, ydist;
xdist = euclidean_distance(lvalue, rvalue, HORIZONTAL);
@@ -767,7 +777,7 @@
template <typename rectangle_type>
typename requires_1<typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type, rectangle_type>::type &
scale_up(rectangle_type& rectangle,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::unsigned_area_type factor) {
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::unsigned_area_type factor) {
horizontal(rectangle, scale_up(horizontal(rectangle), factor));
vertical(rectangle, scale_up(vertical(rectangle), factor));
return rectangle;
@@ -776,7 +786,7 @@
template <typename rectangle_type>
typename requires_1<typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type, rectangle_type>::type &
scale_down(rectangle_type& rectangle,
- typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::unsigned_area_type factor) {
+ typename coordinate_traits<typename rectangle_traits<rectangle_type>::coordinate_type>::unsigned_area_type factor) {
horizontal(rectangle, scale_down(horizontal(rectangle), factor));
vertical(rectangle, scale_down(vertical(rectangle), factor));
return rectangle;
@@ -797,7 +807,7 @@
typename requires_1<typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type, rectangle_type>::type &
transform(rectangle_type& rectangle, const transformation_type& transformation) {
point_data<typename rectangle_traits<rectangle_type>::coordinate_type> llp(xl(rectangle), yl(rectangle));
- point_data<typename rectangle_traits<rectangle_type>::coordinate_type> urp(xl(rectangle), yl(rectangle));
+ point_data<typename rectangle_traits<rectangle_type>::coordinate_type> urp(xh(rectangle), yh(rectangle));
transform(llp, transformation);
transform(urp, transformation);
set_points(rectangle, llp, urp);
@@ -810,9 +820,10 @@
orientation_2d orient_;
public:
inline less_rectangle_concept(orientation_2d orient = VERTICAL) : orient_(orient) {}
- typename requires_2< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
- typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type,
- bool>::type
+ typename requires_1<
+ typename gtl_and< typename is_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
+ typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
+ bool>::type
operator () (const rectangle_type_1& a,
const rectangle_type_2& b) const {
typedef typename rectangle_traits<rectangle_type_1>::coordinate_type Unit;
Modified: sandbox/gtl/gtl/rectangle_data.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_data.hpp (original)
+++ sandbox/gtl/gtl/rectangle_data.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -7,12 +7,13 @@
*/
#ifndef GTL_RECTANGLE_DATA_HPP
#define GTL_RECTANGLE_DATA_HPP
-namespace gtl {
#include "isotropy.hpp"
//interval
#include "interval_data.hpp"
+namespace gtl {
+
template <typename T>
class rectangle_data {
public:
Modified: sandbox/gtl/gtl/rectangle_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_formation.hpp (original)
+++ sandbox/gtl/gtl/rectangle_formation.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -228,15 +228,24 @@
} //namespace rectangle_formation
-
+
+ template <typename T, typename T2>
+ struct get_coordinate_type_for_rectangles {
+ typedef typename polygon_traits<T>::coordinate_type type;
+ };
+ template <typename T>
+ struct get_coordinate_type_for_rectangles<T, rectangle_concept> {
+ typedef typename rectangle_traits<T>::coordinate_type type;
+ };
+
template <typename output_container, typename iterator_type, typename rectangle_concept>
- void get_rectangles(output_container& output, iterator_type begin, iterator_type end,
- orientation_2d orient, rectangle_concept tag) {
+ void form_rectangles(output_container& output, iterator_type begin, iterator_type end,
+ orientation_2d orient, rectangle_concept tag) {
typedef typename output_container::value_type rectangle_type;
- typedef typename rectangle_traits<rectangle_type>::coordinate_type Unit;
+ typedef typename get_coordinate_type_for_rectangles<rectangle_type, typename geometry_concept<rectangle_type>::type>::type Unit;
rectangle_data<Unit> model;
Unit prevPos = std::numeric_limits<Unit>::max();
- rectangle_formation::ScanLineToRects<rectangle_type> scanlineToRects(orient, model);
+ rectangle_formation::ScanLineToRects<rectangle_data<Unit> > scanlineToRects(orient, model);
for(iterator_type itr = begin;
itr != end; ++ itr) {
Unit pos = (*itr).first;
Modified: sandbox/gtl/gtl/rectangle_traits.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_traits.hpp (original)
+++ sandbox/gtl/gtl/rectangle_traits.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -9,8 +9,13 @@
#define GTL_RECTANGLE_TRAITS_HPP
namespace gtl {
+ template <typename T, typename enable = gtl_yes>
+ struct rectangle_traits {};
template <typename T>
- struct rectangle_traits {
+ struct rectangle_traits<T, gtl_no> {};
+
+ template <typename T>
+ struct rectangle_traits<T, typename gtl_same_type<typename T::interval_type, typename T::interval_type>::type> {
typedef typename T::coordinate_type coordinate_type;
typedef typename T::interval_type interval_type;
static inline interval_type get(const T& rectangle, orientation_2d orient) {
Modified: sandbox/gtl/gtl/scan_arbitrary.hpp
==============================================================================
--- sandbox/gtl/gtl/scan_arbitrary.hpp (original)
+++ sandbox/gtl/gtl/scan_arbitrary.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -1095,7 +1095,7 @@
} std::cout << std::endl;
}
- static inline void merge_property_maps(property_map& mp, const property_map& mp2, bool subtract = false) {
+ static inline void merge_property_maps(property_map& mp, const property_map& mp2) {
property_map newmp;
newmp.reserve(mp.size() + mp2.size());
unsigned int i = 0;
@@ -1109,8 +1109,7 @@
++j;
} else {
int count = mp[i].second;
- if(subtract) count -= mp2[j].second;
- else count += mp2[j].second;
+ count += mp2[j].second;
if(count) {
newmp.push_back(mp[i]);
newmp.back().second = count;
@@ -1917,7 +1916,90 @@
//pts.push_back(Point(5624841,9125000));
//pts.push_back(Point(17616200,9125000));
//pts.push_back(Point(17616200,75000));
-pts.push_back(Point(12262940, 6652520 )); pts.push_back(Point(12125750, 6652520 )); pts.push_back(Point(12121272, 6652961 )); pts.push_back(Point(12112981, 6656396 )); pts.push_back(Point(12106636, 6662741 )); pts.push_back(Point(12103201, 6671032 )); pts.push_back(Point(12103201, 6680007 )); pts.push_back(Point(12106636, 6688298 )); pts.push_back(Point(12109500, 6691780 )); pts.push_back(Point(12748600, 7330890 )); pts.push_back(Point(15762600, 7330890 )); pts.push_back(Point(15904620, 7472900 )); pts.push_back(Point(15909200, 7473030 )); pts.push_back(Point(15935830, 7476006 )); pts.push_back(Point(15992796, 7499602 )); pts.push_back(Point(16036397, 7543203 )); pts.push_back(Point(16059993, 7600169 )); pts.push_back(Point(16059993, 7661830 )); pts.push_back(Point(16036397, 7718796 )); pts.push_back(Point(15992796, 7762397 )); pts.push_back(Point(15935830, 7785993 )); pts.push_back(Point(15874169, 7785993 )); pts.push_back(Point(15817203, 7762397 )); pts.push_back(Point(15773602, 7718796 )); pts.push_back(
Point(15750006, 7661830 )); pts.push_back(Point(15747030, 7635200 )); pts.push_back(Point(15746900, 7630620 )); pts.push_back(Point(15670220, 7553930 )); pts.push_back(Point(14872950, 7553930 )); pts.push_back(Point(14872950, 7626170 )); pts.push_back(Point(14869973, 7661280 )); pts.push_back(Point(14846377, 7718246 )); pts.push_back(Point(14802776, 7761847 )); pts.push_back(Point(14745810, 7785443 )); pts.push_back(Point(14684149, 7785443 )); pts.push_back(Point(14627183, 7761847 )); pts.push_back(Point(14583582, 7718246 )); pts.push_back(Point(14559986, 7661280 )); pts.push_back(Point(14557070, 7636660 )); pts.push_back(Point(14556670, 7625570 )); pts.push_back(Point(13703330, 7625570 )); pts.push_back(Point(13702930, 7636660 )); pts.push_back(Point(13699993, 7661830 )); pts.push_back(Point(13676397, 7718796 )); pts.push_back(Point(13632796, 7762397 )); pts.push_back(Point(13575830, 7785993 )); pts.push_back(Point(13514169, 7785993 )); pts.push_back(Point(13457203, 7762397 )); pts.push_back(Point(13436270,
7745670 )); pts.push_back(Point(13432940, 7742520 )); pts.push_back(Point(12963760, 7742520 )); pts.push_back(Point(12959272, 7742961 )); pts.push_back(Point(12950981, 7746396 )); pts.push_back(Point(12944636, 7752741 )); pts.push_back(Point(12941201, 7761032 )); pts.push_back(Point(12941201, 7770007 )); pts.push_back(Point(12944636, 7778298 )); pts.push_back(Point(12947490, 7781780 )); pts.push_back(Point(13425330, 8259620 )); pts.push_back(Point(15601330, 8259620 )); pts.push_back(Point(15904620, 8562900 )); pts.push_back(Point(15909200, 8563030 )); pts.push_back(Point(15935830, 8566006 )); pts.push_back(Point(15992796, 8589602 )); pts.push_back(Point(16036397, 8633203 )); pts.push_back(Point(16059993, 8690169 )); pts.push_back(Point(16059993, 8751830 )); pts.push_back(Point(16036397, 8808796 )); pts.push_back(Point(15992796, 8852397 )); pts.push_back(Point(15935830, 8875993 )); pts.push_back(Point(15874169, 8875993 )); pts.push_back(Point(15817203, 8852397 )); pts.push_back(Point(15773602, 8808796 )); pt
s.push_back(Point(15750006, 8751830 )); pts.push_back(Point(15747030, 8725200 )); pts.push_back(Point(15746900, 8720620 )); pts.push_back(Point(15508950, 8482660 )); pts.push_back(Point(14689890, 8482660 )); pts.push_back(Point(14685412, 8483101 )); pts.push_back(Point(14677121, 8486536 )); pts.push_back(Point(14670776, 8492881 )); pts.push_back(Point(14667341, 8501172 )); pts.push_back(Point(14667341, 8510147 )); pts.push_back(Point(14670776, 8518438 )); pts.push_back(Point(14673630, 8521920 )); pts.push_back(Point(14714620, 8562900 )); pts.push_back(Point(14719200, 8563030 )); pts.push_back(Point(14745830, 8566006 )); pts.push_back(Point(14802796, 8589602 )); pts.push_back(Point(14846397, 8633203 )); pts.push_back(Point(14869993, 8690169 )); pts.push_back(Point(14869993, 8751830 )); pts.push_back(Point(14846397, 8808796 )); pts.push_back(Point(14802796, 8852397 )); pts.push_back(Point(14745830, 8875993 )); pts.push_back(Point(14684169, 8875993 )); pts.push_back(Point(14627203, 8852397 )); pts.push_back(Poi
nt(14583602, 8808796 )); pts.push_back(Point(14560006, 8751830 )); pts.push_back(Point(14557030, 8725200 )); pts.push_back(Point(14556900, 8720620 )); pts.push_back(Point(14408270, 8571980 )); pts.push_back(Point(13696320, 8571980 )); pts.push_back(Point(13696320, 8675520 )); pts.push_back(Point(13699963, 8690161 )); pts.push_back(Point(13699963, 8751818 )); pts.push_back(Point(13676368, 8808781 )); pts.push_back(Point(13632771, 8852378 )); pts.push_back(Point(13575808, 8875973 )); pts.push_back(Point(13514151, 8875973 )); pts.push_back(Point(13457188, 8852378 )); pts.push_back(Point(13436270, 8835670 )); pts.push_back(Point(13432940, 8832520 )); pts.push_back(Point(13281760, 8832520 )); pts.push_back(Point(13277272, 8832961 )); pts.push_back(Point(13268981, 8836396 )); pts.push_back(Point(13262636, 8842741 )); pts.push_back(Point(13259201, 8851032 )); pts.push_back(Point(13259201, 8860007 )); pts.push_back(Point(13262636, 8868298 )); pts.push_back(Point(13265500, 8871780 )); pts.push_back(Point(13518710, 91
25000 )); pts.push_back(Point(16270720, 9125000 )); pts.push_back(Point(16270720, 8939590 )); pts.push_back(Point(17120780, 8939590 )); pts.push_back(Point(17120780, 9125000 )); pts.push_back(Point(17616200, 9125000 )); pts.push_back(Point(17616200, 75000 )); pts.push_back(Point(16024790, 75000 )); pts.push_back(Point(16021460, 80700 )); pts.push_back(Point(16016397, 88796 )); pts.push_back(Point(15972796, 132397 )); pts.push_back(Point(15915830, 155993 )); pts.push_back(Point(15908730, 157240 )); pts.push_back(Point(15905000, 157800 )); pts.push_back(Point(15516800, 546000 )); pts.push_back(Point(15905000, 934200 )); pts.push_back(Point(15908730, 934760 )); pts.push_back(Point(15915830, 936006 )); pts.push_back(Point(15972796, 959602 )); pts.push_back(Point(16016397, 1003203 )); pts.push_back(Point(16039993, 1060169 )); pts.push_back(Point(16039993, 1121830 )); pts.push_back(Point(16016397, 1178796 )); pts.push_back(Point(15972796, 1222397 )); pts.push_back(Point(15915830, 1245993 )); pts.p
ush_back(Point(15854169, 1245993 )); pts.push_back(Point(15797203, 1222397 )); pts.push_back(Point(15753602, 1178796 )); pts.push_back(Point(15730006, 1121830 )); pts.push_back(Point(15728760, 1114730 )); pts.push_back(Point(15728200, 1111000 )); pts.push_back(Point(15363500, 746300 )); pts.push_back(Point(14602620, 746300 )); pts.push_back(Point(14598142, 746741 )); pts.push_back(Point(14589851, 750176 )); pts.push_back(Point(14583506, 756521 )); pts.push_back(Point(14580071, 764812 )); pts.push_back(Point(14580071, 773787 )); pts.push_back(Point(14583506, 782078 )); pts.push_back(Point(14586360, 785560 )); pts.push_back(Point(14586370, 785560 )); pts.push_back(Point(14735000, 934200 )); pts.push_back(Point(14738730, 934760 )); pts.push_back(Point(14745830, 936006 )); pts.push_back(Point(14802796, 959602 )); pts.push_back(Point(14846397, 1003203 )); pts.push_back(Point(14869993, 1060169 )); pts.push_back(Point(14870450, 1062550 )); pts.push_back(Point(14872170, 1071980 )); pts.push_back(Point(
14972780, 1071980 )); pts.push_back(Point(15925000, 2024200 )); pts.push_back(Point(15928730, 2024760 )); pts.push_back(Point(15935830, 2026006 )); pts.push_back(Point(15992796, 2049602 )); pts.push_back(Point(16036397, 2093203 )); pts.push_back(Point(16059993, 2150169 )); pts.push_back(Point(16059993, 2211830 )); pts.push_back(Point(16036397, 2268796 )); pts.push_back(Point(15992796, 2312397 )); pts.push_back(Point(15935830, 2335993 )); pts.push_back(Point(15874169, 2335993 )); pts.push_back(Point(15817203, 2312397 )); pts.push_back(Point(15773602, 2268796 )); pts.push_back(Point(15750006, 2211830 )); pts.push_back(Point(15748760, 2204730 )); pts.push_back(Point(15748200, 2201000 )); pts.push_back(Point(14869220, 1322020 )); pts.push_back(Point(14088350, 1322020 )); pts.push_back(Point(14083862, 1322461 )); pts.push_back(Point(14075571, 1325896 )); pts.push_back(Point(14069226, 1332241 )); pts.push_back(Point(14065791, 1340532 )); pts.push_back(Point(14065791, 1349507 )); pts.push_back(Point(14069226, 13577
98 )); pts.push_back(Point(14072080, 1361280 )); pts.push_back(Point(14072090, 1361280 )); pts.push_back(Point(14735000, 2024200 )); pts.push_back(Point(14738730, 2024760 )); pts.push_back(Point(14745830, 2026006 )); pts.push_back(Point(14802796, 2049602 )); pts.push_back(Point(14846397, 2093203 )); pts.push_back(Point(14869993, 2150169 )); pts.push_back(Point(14869993, 2211830 )); pts.push_back(Point(14846397, 2268796 )); pts.push_back(Point(14802796, 2312397 )); pts.push_back(Point(14745830, 2335993 )); pts.push_back(Point(14684169, 2335993 )); pts.push_back(Point(14627203, 2312397 )); pts.push_back(Point(14583602, 2268796 )); pts.push_back(Point(14560006, 2211830 )); pts.push_back(Point(14558760, 2204730 )); pts.push_back(Point(14558200, 2201000 )); pts.push_back(Point(13752220, 1395020 )); pts.push_back(Point(12991340, 1395020 )); pts.push_back(Point(12986862, 1395461 )); pts.push_back(Point(12978571, 1398896 )); pts.push_back(Point(12972226, 1405241 )); pts.push_back(Point(12968791, 1413532 )); pts.push
_back(Point(12968791, 1422507 )); pts.push_back(Point(12972226, 1430798 )); pts.push_back(Point(12975080, 1434280 )); pts.push_back(Point(12975090, 1434280 )); pts.push_back(Point(13565000, 2024200 )); pts.push_back(Point(13568730, 2024760 )); pts.push_back(Point(13575830, 2026006 )); pts.push_back(Point(13632796, 2049602 )); pts.push_back(Point(13676397, 2093203 )); pts.push_back(Point(13699993, 2150169 )); pts.push_back(Point(13699993, 2211830 )); pts.push_back(Point(13676397, 2268796 )); pts.push_back(Point(13632796, 2312397 )); pts.push_back(Point(13575830, 2335993 )); pts.push_back(Point(13514169, 2335993 )); pts.push_back(Point(13457203, 2312397 )); pts.push_back(Point(13413602, 2268796 )); pts.push_back(Point(13390006, 2211830 )); pts.push_back(Point(13388760, 2204730 )); pts.push_back(Point(13388200, 2201000 )); pts.push_back(Point(12655220, 1468020 )); pts.push_back(Point(11894340, 1468020 )); pts.push_back(Point(11889862, 1468461 )); pts.push_back(Point(11881571, 1471896 )); pts.push_back(Point(118
75226, 1478241 )); pts.push_back(Point(11871791, 1486532 )); pts.push_back(Point(11871791, 1495507 )); pts.push_back(Point(11875226, 1503798 )); pts.push_back(Point(11878090, 1507280 )); pts.push_back(Point(12395000, 2024200 )); pts.push_back(Point(12398730, 2024760 )); pts.push_back(Point(12405830, 2026006 )); pts.push_back(Point(12462796, 2049602 )); pts.push_back(Point(12506397, 2093203 )); pts.push_back(Point(12529993, 2150169 )); pts.push_back(Point(12529993, 2211830 )); pts.push_back(Point(12506397, 2268796 )); pts.push_back(Point(12462796, 2312397 )); pts.push_back(Point(12405830, 2335993 )); pts.push_back(Point(12344169, 2335993 )); pts.push_back(Point(12287203, 2312397 )); pts.push_back(Point(12243602, 2268796 )); pts.push_back(Point(12220006, 2211830 )); pts.push_back(Point(12218760, 2204730 )); pts.push_back(Point(12218200, 2201000 )); pts.push_back(Point(11558220, 1541020 )); pts.push_back(Point(10797340, 1541020 )); pts.push_back(Point(10792862, 1541461 )); pts.push_back(Point(10784571, 1544896
)); pts.push_back(Point(10778226, 1551241 )); pts.push_back(Point(10774791, 1559532 )); pts.push_back(Point(10774791, 1568507 )); pts.push_back(Point(10778226, 1576798 )); pts.push_back(Point(10781080, 1580280 )); pts.push_back(Point(10781090, 1580280 )); pts.push_back(Point(11225000, 2024200 )); pts.push_back(Point(11228730, 2024760 )); pts.push_back(Point(11235830, 2026006 )); pts.push_back(Point(11292796, 2049602 )); pts.push_back(Point(11336397, 2093203 )); pts.push_back(Point(11359993, 2150169 )); pts.push_back(Point(11359993, 2211830 )); pts.push_back(Point(11336397, 2268796 )); pts.push_back(Point(11292796, 2312397 )); pts.push_back(Point(11235830, 2335993 )); pts.push_back(Point(11174169, 2335993 )); pts.push_back(Point(11117203, 2312397 )); pts.push_back(Point(11073602, 2268796 )); pts.push_back(Point(11050006, 2211830 )); pts.push_back(Point(11048760, 2204730 )); pts.push_back(Point(11048200, 2201000 )); pts.push_back(Point(10461220, 1614020 )); pts.push_back(Point( 5647400, 1614020 )); pts.push_ba
ck(Point( 5642912, 1614461 )); pts.push_back(Point( 5634621, 1617896 )); pts.push_back(Point( 5628276, 1624241 )); pts.push_back(Point( 5624841, 1632532 )); pts.push_back(Point( 5624841, 1641507 )); pts.push_back(Point( 5628276, 1649798 )); pts.push_back(Point( 5631130, 1653280 )); pts.push_back(Point( 5688490, 1710640 )); pts.push_back(Point( 9722350, 1710640 )); pts.push_back(Point(10034620, 2022900 )); pts.push_back(Point(10039200, 2023030 )); pts.push_back(Point(10065830, 2026006 )); pts.push_back(Point(10122796, 2049602 )); pts.push_back(Point(10166397, 2093203 )); pts.push_back(Point(10189993, 2150169 )); pts.push_back(Point(10189993, 2211830 )); pts.push_back(Point(10166397, 2268796 )); pts.push_back(Point(10158620, 2279450 )); pts.push_back(Point(10158620, 2404900 )); pts.push_back(Point(10548950, 2795240 )); pts.push_back(Point(15586950, 2795240 )); pts.push_back(Point(15904620, 3112900 )); pts.push_back(Point(15909200, 3113030 )); pts.push_back(Point(15935830, 3116006 )); pts.push_back(Point(159927
96, 3139602 )); pts.push_back(Point(16036397, 3183203 )); pts.push_back(Point(16059993, 3240169 )); pts.push_back(Point(16059993, 3301830 )); pts.push_back(Point(16036397, 3358796 )); pts.push_back(Point(15992796, 3402397 )); pts.push_back(Point(15935830, 3425993 )); pts.push_back(Point(15874169, 3425993 )); pts.push_back(Point(15817203, 3402397 )); pts.push_back(Point(15773602, 3358796 )); pts.push_back(Point(15750006, 3301830 )); pts.push_back(Point(15747030, 3275200 )); pts.push_back(Point(15746900, 3270620 )); pts.push_back(Point(15494570, 3018280 )); pts.push_back(Point(14675510, 3018280 )); pts.push_back(Point(14671032, 3018721 )); pts.push_back(Point(14662741, 3022156 )); pts.push_back(Point(14656396, 3028501 )); pts.push_back(Point(14652961, 3036792 )); pts.push_back(Point(14652961, 3045767 )); pts.push_back(Point(14656396, 3054058 )); pts.push_back(Point(14659260, 3057540 )); pts.push_back(Point(14714620, 3112900 )); pts.push_back(Point(14719200, 3113030 )); pts.push_back(Point(14745830, 3116006 ));
pts.push_back(Point(14802796, 3139602 )); pts.push_back(Point(14846397, 3183203 )); pts.push_back(Point(14869993, 3240169 )); pts.push_back(Point(14869993, 3301830 )); pts.push_back(Point(14846397, 3358796 )); pts.push_back(Point(14802796, 3402397 )); pts.push_back(Point(14745830, 3425993 )); pts.push_back(Point(14684169, 3425993 )); pts.push_back(Point(14627203, 3402397 )); pts.push_back(Point(14583602, 3358796 )); pts.push_back(Point(14560006, 3301830 )); pts.push_back(Point(14557030, 3275200 )); pts.push_back(Point(14556900, 3270620 )); pts.push_back(Point(14370700, 3084410 )); pts.push_back(Point(13702830, 3084410 )); pts.push_back(Point(13702830, 3263160 )); pts.push_back(Point(13700003, 3302210 )); pts.push_back(Point(13676407, 3359176 )); pts.push_back(Point(13632806, 3402777 )); pts.push_back(Point(13575840, 3426373 )); pts.push_back(Point(13514179, 3426373 )); pts.push_back(Point(13457213, 3402777 )); pts.push_back(Point(13413612, 3359176 )); pts.push_back(Point(13390016, 3302210 )); pts.push_back(
Point(13387030, 3275200 )); pts.push_back(Point(13386900, 3270620 )); pts.push_back(Point(13266840, 3150550 )); pts.push_back(Point(12532920, 3150550 )); pts.push_back(Point(12532920, 3264990 )); pts.push_back(Point(12529993, 3301820 )); pts.push_back(Point(12506397, 3358786 )); pts.push_back(Point(12462796, 3402387 )); pts.push_back(Point(12405830, 3425983 )); pts.push_back(Point(12344169, 3425983 )); pts.push_back(Point(12287203, 3402387 )); pts.push_back(Point(12243602, 3358786 )); pts.push_back(Point(12220006, 3301820 )); pts.push_back(Point(12217030, 3275200 )); pts.push_back(Point(12216900, 3270620 )); pts.push_back(Point(12157460, 3211170 )); pts.push_back(Point(11362030, 3211170 )); pts.push_back(Point(11360250, 3220520 )); pts.push_back(Point(11359993, 3221830 )); pts.push_back(Point(11336397, 3278796 )); pts.push_back(Point(11292796, 3322397 )); pts.push_back(Point(11235830, 3345993 )); pts.push_back(Point(11174169, 3345993 )); pts.push_back(Point(11117203, 3322397 )); pts.push_back(Point(11096270,
3305670 )); pts.push_back(Point(11092940, 3302520 )); pts.push_back(Point(10680760, 3302520 )); pts.push_back(Point(10676272, 3302961 )); pts.push_back(Point(10667981, 3306396 )); pts.push_back(Point(10661636, 3312741 )); pts.push_back(Point(10658201, 3321032 )); pts.push_back(Point(10658201, 3330007 )); pts.push_back(Point(10661636, 3338298 )); pts.push_back(Point(10664500, 3341780 )); pts.push_back(Point(11264260, 3941550 )); pts.push_back(Point(15643260, 3941550 )); pts.push_back(Point(15904620, 4202900 )); pts.push_back(Point(15909200, 4203030 )); pts.push_back(Point(15935830, 4206006 )); pts.push_back(Point(15992796, 4229602 )); pts.push_back(Point(16036397, 4273203 )); pts.push_back(Point(16059993, 4330169 )); pts.push_back(Point(16059993, 4391830 )); pts.push_back(Point(16036397, 4448796 )); pts.push_back(Point(15992796, 4492397 )); pts.push_back(Point(15935830, 4515993 )); pts.push_back(Point(15874169, 4515993 )); pts.push_back(Point(15817203, 4492397 )); pts.push_back(Point(15773602, 4448796 )); pt
s.push_back(Point(15750006, 4391830 )); pts.push_back(Point(15747030, 4365200 )); pts.push_back(Point(15746900, 4360620 )); pts.push_back(Point(15550880, 4164590 )); pts.push_back(Point(14825070, 4164590 )); pts.push_back(Point(14825070, 4247610 )); pts.push_back(Point(14846397, 4273213 )); pts.push_back(Point(14869993, 4330179 )); pts.push_back(Point(14869993, 4391840 )); pts.push_back(Point(14846397, 4448806 )); pts.push_back(Point(14802796, 4492407 )); pts.push_back(Point(14745830, 4516003 )); pts.push_back(Point(14684169, 4516003 )); pts.push_back(Point(14627203, 4492407 )); pts.push_back(Point(14583602, 4448806 )); pts.push_back(Point(14560006, 4391840 )); pts.push_back(Point(14557030, 4365200 )); pts.push_back(Point(14556900, 4360620 )); pts.push_back(Point(14432520, 4236230 )); pts.push_back(Point(13702830, 4236230 )); pts.push_back(Point(13702830, 4352930 )); pts.push_back(Point(13699993, 4391750 )); pts.push_back(Point(13676397, 4448716 )); pts.push_back(Point(13632796, 4492317 )); pts.push_back(Poi
nt(13575830, 4515913 )); pts.push_back(Point(13514169, 4515913 )); pts.push_back(Point(13457203, 4492317 )); pts.push_back(Point(13413602, 4448716 )); pts.push_back(Point(13390006, 4391750 )); pts.push_back(Point(13387030, 4365200 )); pts.push_back(Point(13386900, 4360620 )); pts.push_back(Point(13334170, 4307880 )); pts.push_back(Point(12532990, 4307880 )); pts.push_back(Point(12532990, 4357550 )); pts.push_back(Point(12529993, 4391760 )); pts.push_back(Point(12506397, 4448726 )); pts.push_back(Point(12462796, 4492327 )); pts.push_back(Point(12405830, 4515923 )); pts.push_back(Point(12344169, 4515923 )); pts.push_back(Point(12287203, 4492327 )); pts.push_back(Point(12243602, 4448726 )); pts.push_back(Point(12220006, 4391760 )); pts.push_back(Point(12217970, 4378710 )); pts.push_back(Point(12216810, 4368500 )); pts.push_back(Point(11363190, 4368500 )); pts.push_back(Point(11362030, 4378710 )); pts.push_back(Point(11359983, 4391828 )); pts.push_back(Point(11336388, 4448791 )); pts.push_back(Point(11292791, 44
92388 )); pts.push_back(Point(11235828, 4515983 )); pts.push_back(Point(11174171, 4515983 )); pts.push_back(Point(11117208, 4492388 )); pts.push_back(Point(11096270, 4475670 )); pts.push_back(Point(11092940, 4472520 )); pts.push_back(Point(11057750, 4472520 )); pts.push_back(Point(11053272, 4472961 )); pts.push_back(Point(11044981, 4476396 )); pts.push_back(Point(11038636, 4482741 )); pts.push_back(Point(11035201, 4491032 )); pts.push_back(Point(11035201, 4500007 )); pts.push_back(Point(11038636, 4508298 )); pts.push_back(Point(11041490, 4511780 )); pts.push_back(Point(11573490, 5043780 )); pts.push_back(Point(15655490, 5043780 )); pts.push_back(Point(15904620, 5292900 )); pts.push_back(Point(15909200, 5293030 )); pts.push_back(Point(15935830, 5296006 )); pts.push_back(Point(15992796, 5319602 )); pts.push_back(Point(16036397, 5363203 )); pts.push_back(Point(16059993, 5420169 )); pts.push_back(Point(16059993, 5481830 )); pts.push_back(Point(16036397, 5538796 )); pts.push_back(Point(15992796, 5582397 )); pts.p
ush_back(Point(15935830, 5605993 )); pts.push_back(Point(15874169, 5605993 )); pts.push_back(Point(15817203, 5582397 )); pts.push_back(Point(15773602, 5538796 )); pts.push_back(Point(15750006, 5481830 )); pts.push_back(Point(15747030, 5455200 )); pts.push_back(Point(15746900, 5450620 )); pts.push_back(Point(15563110, 5266820 )); pts.push_back(Point(14857380, 5266820 )); pts.push_back(Point(14857380, 5382430 )); pts.push_back(Point(14869993, 5420179 )); pts.push_back(Point(14869993, 5481840 )); pts.push_back(Point(14846397, 5538806 )); pts.push_back(Point(14802796, 5582407 )); pts.push_back(Point(14745830, 5606003 )); pts.push_back(Point(14684169, 5606003 )); pts.push_back(Point(14627203, 5582407 )); pts.push_back(Point(14583602, 5538806 )); pts.push_back(Point(14560006, 5481840 )); pts.push_back(Point(14557030, 5455200 )); pts.push_back(Point(14556900, 5450620 )); pts.push_back(Point(14444750, 5338460 )); pts.push_back(Point(13702890, 5338460 )); pts.push_back(Point(13702890, 5364400 )); pts.push_back(Point(
13699993, 5401800 )); pts.push_back(Point(13676397, 5458766 )); pts.push_back(Point(13632796, 5502367 )); pts.push_back(Point(13575830, 5525963 )); pts.push_back(Point(13514169, 5525963 )); pts.push_back(Point(13457203, 5502367 )); pts.push_back(Point(13413602, 5458766 )); pts.push_back(Point(13390006, 5401800 )); pts.push_back(Point(13389230, 5397620 )); pts.push_back(Point(13387590, 5388060 )); pts.push_back(Point(12532960, 5388060 )); pts.push_back(Point(12532960, 5446220 )); pts.push_back(Point(12529993, 5481820 )); pts.push_back(Point(12506397, 5538786 )); pts.push_back(Point(12462796, 5582387 )); pts.push_back(Point(12405830, 5605983 )); pts.push_back(Point(12344169, 5605983 )); pts.push_back(Point(12287203, 5582387 )); pts.push_back(Point(12266270, 5565670 )); pts.push_back(Point(12262940, 5562520 )); pts.push_back(Point(11737750, 5562520 )); pts.push_back(Point(11733272, 5562961 )); pts.push_back(Point(11724981, 5566396 )); pts.push_back(Point(11718636, 5572741 )); pts.push_back(Point(11715201, 55810
32 )); pts.push_back(Point(11715201, 5590007 )); pts.push_back(Point(11718636, 5598298 )); pts.push_back(Point(11721500, 5601780 )); pts.push_back(Point(12287760, 6168050 )); pts.push_back(Point(15689760, 6168050 )); pts.push_back(Point(15904620, 6382900 )); pts.push_back(Point(15909200, 6383030 )); pts.push_back(Point(15935830, 6386006 )); pts.push_back(Point(15992796, 6409602 )); pts.push_back(Point(16036397, 6453203 )); pts.push_back(Point(16059993, 6510169 )); pts.push_back(Point(16059993, 6571830 )); pts.push_back(Point(16036397, 6628796 )); pts.push_back(Point(15992796, 6672397 )); pts.push_back(Point(15935830, 6695993 )); pts.push_back(Point(15874169, 6695993 )); pts.push_back(Point(15817203, 6672397 )); pts.push_back(Point(15773602, 6628796 )); pts.push_back(Point(15750006, 6571830 )); pts.push_back(Point(15747030, 6545200 )); pts.push_back(Point(15746900, 6540620 )); pts.push_back(Point(15597380, 6391090 )); pts.push_back(Point(14858060, 6391090 )); pts.push_back(Point(14858060, 6473860 )); pts.push
_back(Point(14869993, 6510179 )); pts.push_back(Point(14869993, 6571840 )); pts.push_back(Point(14846397, 6628806 )); pts.push_back(Point(14802796, 6672407 )); pts.push_back(Point(14745830, 6696003 )); pts.push_back(Point(14684169, 6696003 )); pts.push_back(Point(14627203, 6672407 )); pts.push_back(Point(14583602, 6628806 )); pts.push_back(Point(14560006, 6571840 )); pts.push_back(Point(14557030, 6545200 )); pts.push_back(Point(14556900, 6540620 )); pts.push_back(Point(14479020, 6462730 )); pts.push_back(Point(13702990, 6462730 )); pts.push_back(Point(13702990, 6537170 )); pts.push_back(Point(13700003, 6571840 )); pts.push_back(Point(13676407, 6628806 )); pts.push_back(Point(13632806, 6672407 )); pts.push_back(Point(13575840, 6696003 )); pts.push_back(Point(13514179, 6696003 )); pts.push_back(Point(13457213, 6672407 )); pts.push_back(Point(13413612, 6628806 )); pts.push_back(Point(13390016, 6571840 )); pts.push_back(Point(13387040, 6545550 )); pts.push_back(Point(13386710, 6534380 )); pts.push_back(Point(125
33290, 6534380 )); pts.push_back(Point(12532960, 6545550 )); pts.push_back(Point(12529983, 6571828 )); pts.push_back(Point(12506388, 6628791 )); pts.push_back(Point(12462791, 6672388 )); pts.push_back(Point(12405828, 6695983 )); pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 )); pts.push_back(Point(12266270, 6655670 ));
+pts.push_back(Point(12262940, 6652520 )); pts.push_back(Point(12125750, 6652520 )); pts.push_back(Point(12121272, 6652961 )); pts.push_back(Point(12112981, 6656396 )); pts.push_back(Point(12106636, 6662741 )); pts.push_back(Point(12103201, 6671032 )); pts.push_back(Point(12103201, 6680007 )); pts.push_back(Point(12106636, 6688298 ));
+pts.push_back(Point(12109500, 6691780 )); pts.push_back(Point(12748600, 7330890 )); pts.push_back(Point(15762600, 7330890 )); pts.push_back(Point(15904620, 7472900 )); pts.push_back(Point(15909200, 7473030 )); pts.push_back(Point(15935830, 7476006 )); pts.push_back(Point(15992796, 7499602 )); pts.push_back(Point(16036397, 7543203 ));
+pts.push_back(Point(16059993, 7600169 )); pts.push_back(Point(16059993, 7661830 )); pts.push_back(Point(16036397, 7718796 )); pts.push_back(Point(15992796, 7762397 )); pts.push_back(Point(15935830, 7785993 )); pts.push_back(Point(15874169, 7785993 )); pts.push_back(Point(15817203, 7762397 )); pts.push_back(Point(15773602, 7718796 ));
+pts.push_back(Point(15750006, 7661830 )); pts.push_back(Point(15747030, 7635200 )); pts.push_back(Point(15746900, 7630620 )); pts.push_back(Point(15670220, 7553930 )); pts.push_back(Point(14872950, 7553930 )); pts.push_back(Point(14872950, 7626170 ));
+pts.push_back(Point(14869973, 7661280 )); pts.push_back(Point(14846377, 7718246 )); pts.push_back(Point(14802776, 7761847 )); pts.push_back(Point(14745810, 7785443 )); pts.push_back(Point(14684149, 7785443 )); pts.push_back(Point(14627183, 7761847 )); pts.push_back(Point(14583582, 7718246 ));
+pts.push_back(Point(14559986, 7661280 )); pts.push_back(Point(14557070, 7636660 )); pts.push_back(Point(14556670, 7625570 )); pts.push_back(Point(13703330, 7625570 )); pts.push_back(Point(13702930, 7636660 )); pts.push_back(Point(13699993, 7661830 )); pts.push_back(Point(13676397, 7718796 ));
+pts.push_back(Point(13632796, 7762397 )); pts.push_back(Point(13575830, 7785993 )); pts.push_back(Point(13514169, 7785993 )); pts.push_back(Point(13457203, 7762397 )); pts.push_back(Point(13436270, 7745670 )); pts.push_back(Point(13432940, 7742520 )); pts.push_back(Point(12963760, 7742520 ));
+pts.push_back(Point(12959272, 7742961 )); pts.push_back(Point(12950981, 7746396 )); pts.push_back(Point(12944636, 7752741 )); pts.push_back(Point(12941201, 7761032 )); pts.push_back(Point(12941201, 7770007 )); pts.push_back(Point(12944636, 7778298 )); pts.push_back(Point(12947490, 7781780 ));
+pts.push_back(Point(13425330, 8259620 )); pts.push_back(Point(15601330, 8259620 )); pts.push_back(Point(15904620, 8562900 )); pts.push_back(Point(15909200, 8563030 )); pts.push_back(Point(15935830, 8566006 )); pts.push_back(Point(15992796, 8589602 )); pts.push_back(Point(16036397, 8633203 ));
+pts.push_back(Point(16059993, 8690169 )); pts.push_back(Point(16059993, 8751830 )); pts.push_back(Point(16036397, 8808796 )); pts.push_back(Point(15992796, 8852397 )); pts.push_back(Point(15935830, 8875993 )); pts.push_back(Point(15874169, 8875993 )); pts.push_back(Point(15817203, 8852397 )); pts.push_back(Point(15773602, 8808796 ));
+pts.push_back(Point(15750006, 8751830 )); pts.push_back(Point(15747030, 8725200 )); pts.push_back(Point(15746900, 8720620 )); pts.push_back(Point(15508950, 8482660 )); pts.push_back(Point(14689890, 8482660 )); pts.push_back(Point(14685412, 8483101 )); pts.push_back(Point(14677121, 8486536 ));
+pts.push_back(Point(14670776, 8492881 )); pts.push_back(Point(14667341, 8501172 )); pts.push_back(Point(14667341, 8510147 )); pts.push_back(Point(14670776, 8518438 )); pts.push_back(Point(14673630, 8521920 )); pts.push_back(Point(14714620, 8562900 )); pts.push_back(Point(14719200, 8563030 )); pts.push_back(Point(14745830, 8566006 ));
+pts.push_back(Point(14802796, 8589602 )); pts.push_back(Point(14846397, 8633203 )); pts.push_back(Point(14869993, 8690169 )); pts.push_back(Point(14869993, 8751830 )); pts.push_back(Point(14846397, 8808796 )); pts.push_back(Point(14802796, 8852397 )); pts.push_back(Point(14745830, 8875993 )); pts.push_back(Point(14684169, 8875993 ));
+pts.push_back(Point(14627203, 8852397 )); pts.push_back(Point(14583602, 8808796 )); pts.push_back(Point(14560006, 8751830 )); pts.push_back(Point(14557030, 8725200 )); pts.push_back(Point(14556900, 8720620 )); pts.push_back(Point(14408270, 8571980 )); pts.push_back(Point(13696320, 8571980 )); pts.push_back(Point(13696320, 8675520 ));
+pts.push_back(Point(13699963, 8690161 )); pts.push_back(Point(13699963, 8751818 )); pts.push_back(Point(13676368, 8808781 )); pts.push_back(Point(13632771, 8852378 )); pts.push_back(Point(13575808, 8875973 )); pts.push_back(Point(13514151, 8875973 )); pts.push_back(Point(13457188, 8852378 )); pts.push_back(Point(13436270, 8835670 )); pts.push_back(Point(13432940, 8832520 ));
+pts.push_back(Point(13281760, 8832520 )); pts.push_back(Point(13277272, 8832961 )); pts.push_back(Point(13268981, 8836396 )); pts.push_back(Point(13262636, 8842741 )); pts.push_back(Point(13259201, 8851032 )); pts.push_back(Point(13259201, 8860007 )); pts.push_back(Point(13262636, 8868298 )); pts.push_back(Point(13265500, 8871780 ));
+pts.push_back(Point(13518710, 9125000 )); pts.push_back(Point(16270720, 9125000 )); pts.push_back(Point(16270720, 8939590 )); pts.push_back(Point(17120780, 8939590 )); pts.push_back(Point(17120780, 9125000 )); pts.push_back(Point(17616200, 9125000 )); pts.push_back(Point(17616200, 75000 )); pts.push_back(Point(16024790, 75000 ));
+pts.push_back(Point(16021460, 80700 )); pts.push_back(Point(16016397, 88796 )); pts.push_back(Point(15972796, 132397 )); pts.push_back(Point(15915830, 155993 )); pts.push_back(Point(15908730, 157240 )); pts.push_back(Point(15905000, 157800 )); pts.push_back(Point(15516800, 546000 )); pts.push_back(Point(15905000, 934200 ));
+pts.push_back(Point(15908730, 934760 )); pts.push_back(Point(15915830, 936006 )); pts.push_back(Point(15972796, 959602 )); pts.push_back(Point(16016397, 1003203 )); pts.push_back(Point(16039993, 1060169 )); pts.push_back(Point(16039993, 1121830 )); pts.push_back(Point(16016397, 1178796 )); pts.push_back(Point(15972796, 1222397 ));
+pts.push_back(Point(15915830, 1245993 )); pts.push_back(Point(15854169, 1245993 )); pts.push_back(Point(15797203, 1222397 )); pts.push_back(Point(15753602, 1178796 )); pts.push_back(Point(15730006, 1121830 )); pts.push_back(Point(15728760, 1114730 )); pts.push_back(Point(15728200, 1111000 )); pts.push_back(Point(15363500, 746300 ));
+pts.push_back(Point(14602620, 746300 )); pts.push_back(Point(14598142, 746741 )); pts.push_back(Point(14589851, 750176 )); pts.push_back(Point(14583506, 756521 )); pts.push_back(Point(14580071, 764812 )); pts.push_back(Point(14580071, 773787 )); pts.push_back(Point(14583506, 782078 )); pts.push_back(Point(14586360, 785560 ));
+pts.push_back(Point(14586370, 785560 )); pts.push_back(Point(14735000, 934200 )); pts.push_back(Point(14738730, 934760 )); pts.push_back(Point(14745830, 936006 )); pts.push_back(Point(14802796, 959602 )); pts.push_back(Point(14846397, 1003203 )); pts.push_back(Point(14869993, 1060169 ));
+pts.push_back(Point(14870450, 1062550 )); pts.push_back(Point(14872170, 1071980 )); pts.push_back(Point(14972780, 1071980 )); pts.push_back(Point(15925000, 2024200 )); pts.push_back(Point(15928730, 2024760 )); pts.push_back(Point(15935830, 2026006 )); pts.push_back(Point(15992796, 2049602 ));
+pts.push_back(Point(16036397, 2093203 )); pts.push_back(Point(16059993, 2150169 )); pts.push_back(Point(16059993, 2211830 )); pts.push_back(Point(16036397, 2268796 )); pts.push_back(Point(15992796, 2312397 )); pts.push_back(Point(15935830, 2335993 )); pts.push_back(Point(15874169, 2335993 ));
+pts.push_back(Point(15817203, 2312397 )); pts.push_back(Point(15773602, 2268796 )); pts.push_back(Point(15750006, 2211830 )); pts.push_back(Point(15748760, 2204730 )); pts.push_back(Point(15748200, 2201000 )); pts.push_back(Point(14869220, 1322020 )); pts.push_back(Point(14088350, 1322020 ));
+pts.push_back(Point(14083862, 1322461 )); pts.push_back(Point(14075571, 1325896 )); pts.push_back(Point(14069226, 1332241 )); pts.push_back(Point(14065791, 1340532 )); pts.push_back(Point(14065791, 1349507 )); pts.push_back(Point(14069226, 1357798 )); pts.push_back(Point(14072080, 1361280 ));
+pts.push_back(Point(14072090, 1361280 )); pts.push_back(Point(14735000, 2024200 )); pts.push_back(Point(14738730, 2024760 )); pts.push_back(Point(14745830, 2026006 )); pts.push_back(Point(14802796, 2049602 )); pts.push_back(Point(14846397, 2093203 )); pts.push_back(Point(14869993, 2150169 ));
+pts.push_back(Point(14869993, 2211830 )); pts.push_back(Point(14846397, 2268796 )); pts.push_back(Point(14802796, 2312397 )); pts.push_back(Point(14745830, 2335993 )); pts.push_back(Point(14684169, 2335993 )); pts.push_back(Point(14627203, 2312397 )); pts.push_back(Point(14583602, 2268796 )); pts.push_back(Point(14560006, 2211830 ));
+pts.push_back(Point(14558760, 2204730 )); pts.push_back(Point(14558200, 2201000 )); pts.push_back(Point(13752220, 1395020 )); pts.push_back(Point(12991340, 1395020 )); pts.push_back(Point(12986862, 1395461 )); pts.push_back(Point(12978571, 1398896 )); pts.push_back(Point(12972226, 1405241 ));
+pts.push_back(Point(12968791, 1413532 )); pts.push_back(Point(12968791, 1422507 )); pts.push_back(Point(12972226, 1430798 )); pts.push_back(Point(12975080, 1434280 )); pts.push_back(Point(12975090, 1434280 )); pts.push_back(Point(13565000, 2024200 )); pts.push_back(Point(13568730, 2024760 )); pts.push_back(Point(13575830, 2026006 ));
+pts.push_back(Point(13632796, 2049602 )); pts.push_back(Point(13676397, 2093203 )); pts.push_back(Point(13699993, 2150169 )); pts.push_back(Point(13699993, 2211830 )); pts.push_back(Point(13676397, 2268796 )); pts.push_back(Point(13632796, 2312397 )); pts.push_back(Point(13575830, 2335993 ));
+pts.push_back(Point(13514169, 2335993 )); pts.push_back(Point(13457203, 2312397 )); pts.push_back(Point(13413602, 2268796 )); pts.push_back(Point(13390006, 2211830 )); pts.push_back(Point(13388760, 2204730 )); pts.push_back(Point(13388200, 2201000 )); pts.push_back(Point(12655220, 1468020 ));
+pts.push_back(Point(11894340, 1468020 )); pts.push_back(Point(11889862, 1468461 )); pts.push_back(Point(11881571, 1471896 )); pts.push_back(Point(11875226, 1478241 )); pts.push_back(Point(11871791, 1486532 )); pts.push_back(Point(11871791, 1495507 ));
+pts.push_back(Point(11875226, 1503798 )); pts.push_back(Point(11878090, 1507280 )); pts.push_back(Point(12395000, 2024200 )); pts.push_back(Point(12398730, 2024760 )); pts.push_back(Point(12405830, 2026006 )); pts.push_back(Point(12462796, 2049602 )); pts.push_back(Point(12506397, 2093203 ));
+pts.push_back(Point(12529993, 2150169 )); pts.push_back(Point(12529993, 2211830 )); pts.push_back(Point(12506397, 2268796 )); pts.push_back(Point(12462796, 2312397 )); pts.push_back(Point(12405830, 2335993 )); pts.push_back(Point(12344169, 2335993 ));
+pts.push_back(Point(12287203, 2312397 )); pts.push_back(Point(12243602, 2268796 )); pts.push_back(Point(12220006, 2211830 )); pts.push_back(Point(12218760, 2204730 )); pts.push_back(Point(12218200, 2201000 )); pts.push_back(Point(11558220, 1541020 ));
+pts.push_back(Point(10797340, 1541020 )); pts.push_back(Point(10792862, 1541461 )); pts.push_back(Point(10784571, 1544896 )); pts.push_back(Point(10778226, 1551241 )); pts.push_back(Point(10774791, 1559532 )); pts.push_back(Point(10774791, 1568507 )); pts.push_back(Point(10778226, 1576798 )); pts.push_back(Point(10781080, 1580280 ));
+pts.push_back(Point(10781090, 1580280 )); pts.push_back(Point(11225000, 2024200 )); pts.push_back(Point(11228730, 2024760 )); pts.push_back(Point(11235830, 2026006 )); pts.push_back(Point(11292796, 2049602 )); pts.push_back(Point(11336397, 2093203 )); pts.push_back(Point(11359993, 2150169 ));
+pts.push_back(Point(11359993, 2211830 )); pts.push_back(Point(11336397, 2268796 )); pts.push_back(Point(11292796, 2312397 )); pts.push_back(Point(11235830, 2335993 )); pts.push_back(Point(11174169, 2335993 )); pts.push_back(Point(11117203, 2312397 )); pts.push_back(Point(11073602, 2268796 )); pts.push_back(Point(11050006, 2211830 ));
+pts.push_back(Point(11048760, 2204730 )); pts.push_back(Point(11048200, 2201000 )); pts.push_back(Point(10461220, 1614020 )); pts.push_back(Point( 5647400, 1614020 )); pts.push_back(Point( 5642912, 1614461 ));
+pts.push_back(Point( 5634621, 1617896 )); pts.push_back(Point( 5628276, 1624241 )); pts.push_back(Point( 5624841, 1632532 )); pts.push_back(Point( 5624841, 1641507 )); pts.push_back(Point( 5628276, 1649798 )); pts.push_back(Point( 5631130, 1653280 ));
+pts.push_back(Point( 5688490, 1710640 )); pts.push_back(Point( 9722350, 1710640 )); pts.push_back(Point(10034620, 2022900 )); pts.push_back(Point(10039200, 2023030 )); pts.push_back(Point(10065830, 2026006 )); pts.push_back(Point(10122796, 2049602 ));
+pts.push_back(Point(10166397, 2093203 )); pts.push_back(Point(10189993, 2150169 )); pts.push_back(Point(10189993, 2211830 )); pts.push_back(Point(10166397, 2268796 )); pts.push_back(Point(10158620, 2279450 )); pts.push_back(Point(10158620, 2404900 )); pts.push_back(Point(10548950, 2795240 ));
+pts.push_back(Point(15586950, 2795240 )); pts.push_back(Point(15904620, 3112900 )); pts.push_back(Point(15909200, 3113030 )); pts.push_back(Point(15935830, 3116006 )); pts.push_back(Point(15992796, 3139602 )); pts.push_back(Point(16036397, 3183203 )); pts.push_back(Point(16059993, 3240169 )); pts.push_back(Point(16059993, 3301830 ));
+pts.push_back(Point(16036397, 3358796 )); pts.push_back(Point(15992796, 3402397 )); pts.push_back(Point(15935830, 3425993 )); pts.push_back(Point(15874169, 3425993 )); pts.push_back(Point(15817203, 3402397 )); pts.push_back(Point(15773602, 3358796 )); pts.push_back(Point(15750006, 3301830 )); pts.push_back(Point(15747030, 3275200 ));
+pts.push_back(Point(15746900, 3270620 )); pts.push_back(Point(15494570, 3018280 )); pts.push_back(Point(14675510, 3018280 )); pts.push_back(Point(14671032, 3018721 )); pts.push_back(Point(14662741, 3022156 )); pts.push_back(Point(14656396, 3028501 )); pts.push_back(Point(14652961, 3036792 ));
+pts.push_back(Point(14652961, 3045767 )); pts.push_back(Point(14656396, 3054058 )); pts.push_back(Point(14659260, 3057540 )); pts.push_back(Point(14714620, 3112900 )); pts.push_back(Point(14719200, 3113030 )); pts.push_back(Point(14745830, 3116006 )); pts.push_back(Point(14802796, 3139602 ));
+pts.push_back(Point(14846397, 3183203 )); pts.push_back(Point(14869993, 3240169 )); pts.push_back(Point(14869993, 3301830 )); pts.push_back(Point(14846397, 3358796 )); pts.push_back(Point(14802796, 3402397 )); pts.push_back(Point(14745830, 3425993 )); pts.push_back(Point(14684169, 3425993 )); pts.push_back(Point(14627203, 3402397 ));
+pts.push_back(Point(14583602, 3358796 )); pts.push_back(Point(14560006, 3301830 )); pts.push_back(Point(14557030, 3275200 )); pts.push_back(Point(14556900, 3270620 )); pts.push_back(Point(14370700, 3084410 )); pts.push_back(Point(13702830, 3084410 )); pts.push_back(Point(13702830, 3263160 ));
+pts.push_back(Point(13700003, 3302210 )); pts.push_back(Point(13676407, 3359176 )); pts.push_back(Point(13632806, 3402777 )); pts.push_back(Point(13575840, 3426373 )); pts.push_back(Point(13514179, 3426373 )); pts.push_back(Point(13457213, 3402777 )); pts.push_back(Point(13413612, 3359176 ));
+pts.push_back(Point(13390016, 3302210 )); pts.push_back(Point(13387030, 3275200 )); pts.push_back(Point(13386900, 3270620 )); pts.push_back(Point(13266840, 3150550 )); pts.push_back(Point(12532920, 3150550 )); pts.push_back(Point(12532920, 3264990 )); pts.push_back(Point(12529993, 3301820 ));
+pts.push_back(Point(12506397, 3358786 )); pts.push_back(Point(12462796, 3402387 )); pts.push_back(Point(12405830, 3425983 )); pts.push_back(Point(12344169, 3425983 )); pts.push_back(Point(12287203, 3402387 )); pts.push_back(Point(12243602, 3358786 )); pts.push_back(Point(12220006, 3301820 )); pts.push_back(Point(12217030, 3275200 ));
+pts.push_back(Point(12216900, 3270620 )); pts.push_back(Point(12157460, 3211170 )); pts.push_back(Point(11362030, 3211170 )); pts.push_back(Point(11360250, 3220520 )); pts.push_back(Point(11359993, 3221830 )); pts.push_back(Point(11336397, 3278796 ));
+pts.push_back(Point(11292796, 3322397 )); pts.push_back(Point(11235830, 3345993 )); pts.push_back(Point(11174169, 3345993 )); pts.push_back(Point(11117203, 3322397 )); pts.push_back(Point(11096270, 3305670 )); pts.push_back(Point(11092940, 3302520 )); pts.push_back(Point(10680760, 3302520 ));
+pts.push_back(Point(10676272, 3302961 )); pts.push_back(Point(10667981, 3306396 )); pts.push_back(Point(10661636, 3312741 )); pts.push_back(Point(10658201, 3321032 )); pts.push_back(Point(10658201, 3330007 )); pts.push_back(Point(10661636, 3338298 )); pts.push_back(Point(10664500, 3341780 ));
+pts.push_back(Point(11264260, 3941550 )); pts.push_back(Point(15643260, 3941550 )); pts.push_back(Point(15904620, 4202900 )); pts.push_back(Point(15909200, 4203030 )); pts.push_back(Point(15935830, 4206006 )); pts.push_back(Point(15992796, 4229602 ));
+pts.push_back(Point(16036397, 4273203 )); pts.push_back(Point(16059993, 4330169 )); pts.push_back(Point(16059993, 4391830 )); pts.push_back(Point(16036397, 4448796 )); pts.push_back(Point(15992796, 4492397 ));
+pts.push_back(Point(15935830, 4515993 )); pts.push_back(Point(15874169, 4515993 )); pts.push_back(Point(15817203, 4492397 )); pts.push_back(Point(15773602, 4448796 )); pts.push_back(Point(15750006, 4391830 )); pts.push_back(Point(15747030, 4365200 )); pts.push_back(Point(15746900, 4360620 ));
+pts.push_back(Point(15550880, 4164590 )); pts.push_back(Point(14825070, 4164590 )); pts.push_back(Point(14825070, 4247610 )); pts.push_back(Point(14846397, 4273213 )); pts.push_back(Point(14869993, 4330179 )); pts.push_back(Point(14869993, 4391840 )); pts.push_back(Point(14846397, 4448806 ));
+pts.push_back(Point(14802796, 4492407 )); pts.push_back(Point(14745830, 4516003 )); pts.push_back(Point(14684169, 4516003 )); pts.push_back(Point(14627203, 4492407 )); pts.push_back(Point(14583602, 4448806 )); pts.push_back(Point(14560006, 4391840 )); pts.push_back(Point(14557030, 4365200 ));
+pts.push_back(Point(14556900, 4360620 )); pts.push_back(Point(14432520, 4236230 )); pts.push_back(Point(13702830, 4236230 )); pts.push_back(Point(13702830, 4352930 )); pts.push_back(Point(13699993, 4391750 )); pts.push_back(Point(13676397, 4448716 ));
+pts.push_back(Point(13632796, 4492317 )); pts.push_back(Point(13575830, 4515913 )); pts.push_back(Point(13514169, 4515913 )); pts.push_back(Point(13457203, 4492317 )); pts.push_back(Point(13413602, 4448716 )); pts.push_back(Point(13390006, 4391750 )); pts.push_back(Point(13387030, 4365200 ));
+pts.push_back(Point(13386900, 4360620 )); pts.push_back(Point(13334170, 4307880 )); pts.push_back(Point(12532990, 4307880 )); pts.push_back(Point(12532990, 4357550 )); pts.push_back(Point(12529993, 4391760 )); pts.push_back(Point(12506397, 4448726 )); pts.push_back(Point(12462796, 4492327 ));
+pts.push_back(Point(12405830, 4515923 )); pts.push_back(Point(12344169, 4515923 )); pts.push_back(Point(12287203, 4492327 )); pts.push_back(Point(12243602, 4448726 )); pts.push_back(Point(12220006, 4391760 )); pts.push_back(Point(12217970, 4378710 )); pts.push_back(Point(12216810, 4368500 ));
+pts.push_back(Point(11363190, 4368500 )); pts.push_back(Point(11362030, 4378710 )); pts.push_back(Point(11359983, 4391828 )); pts.push_back(Point(11336388, 4448791 )); pts.push_back(Point(11292791, 4492388 )); pts.push_back(Point(11235828, 4515983 )); pts.push_back(Point(11174171, 4515983 )); pts.push_back(Point(11117208, 4492388 ));
+pts.push_back(Point(11096270, 4475670 )); pts.push_back(Point(11092940, 4472520 )); pts.push_back(Point(11057750, 4472520 )); pts.push_back(Point(11053272, 4472961 )); pts.push_back(Point(11044981, 4476396 )); pts.push_back(Point(11038636, 4482741 )); pts.push_back(Point(11035201, 4491032 ));
+pts.push_back(Point(11035201, 4500007 )); pts.push_back(Point(11038636, 4508298 )); pts.push_back(Point(11041490, 4511780 )); pts.push_back(Point(11573490, 5043780 )); pts.push_back(Point(15655490, 5043780 )); pts.push_back(Point(15904620, 5292900 ));
+pts.push_back(Point(15909200, 5293030 )); pts.push_back(Point(15935830, 5296006 )); pts.push_back(Point(15992796, 5319602 )); pts.push_back(Point(16036397, 5363203 )); pts.push_back(Point(16059993, 5420169 )); pts.push_back(Point(16059993, 5481830 )); pts.push_back(Point(16036397, 5538796 ));
+pts.push_back(Point(15992796, 5582397 )); pts.push_back(Point(15935830, 5605993 )); pts.push_back(Point(15874169, 5605993 )); pts.push_back(Point(15817203, 5582397 )); pts.push_back(Point(15773602, 5538796 )); pts.push_back(Point(15750006, 5481830 )); pts.push_back(Point(15747030, 5455200 ));
+pts.push_back(Point(15746900, 5450620 )); pts.push_back(Point(15563110, 5266820 )); pts.push_back(Point(14857380, 5266820 )); pts.push_back(Point(14857380, 5382430 )); pts.push_back(Point(14869993, 5420179 )); pts.push_back(Point(14869993, 5481840 )); pts.push_back(Point(14846397, 5538806 )); pts.push_back(Point(14802796, 5582407 ));
+pts.push_back(Point(14745830, 5606003 )); pts.push_back(Point(14684169, 5606003 )); pts.push_back(Point(14627203, 5582407 )); pts.push_back(Point(14583602, 5538806 )); pts.push_back(Point(14560006, 5481840 )); pts.push_back(Point(14557030, 5455200 )); pts.push_back(Point(14556900, 5450620 )); pts.push_back(Point(14444750, 5338460 ));
+pts.push_back(Point(13702890, 5338460 )); pts.push_back(Point(13702890, 5364400 )); pts.push_back(Point(13699993, 5401800 )); pts.push_back(Point(13676397, 5458766 )); pts.push_back(Point(13632796, 5502367 )); pts.push_back(Point(13575830, 5525963 )); pts.push_back(Point(13514169, 5525963 )); pts.push_back(Point(13457203, 5502367 ));
+pts.push_back(Point(13413602, 5458766 )); pts.push_back(Point(13390006, 5401800 )); pts.push_back(Point(13389230, 5397620 )); pts.push_back(Point(13387590, 5388060 )); pts.push_back(Point(12532960, 5388060 )); pts.push_back(Point(12532960, 5446220 )); pts.push_back(Point(12529993, 5481820 ));
+pts.push_back(Point(12506397, 5538786 )); pts.push_back(Point(12462796, 5582387 )); pts.push_back(Point(12405830, 5605983 )); pts.push_back(Point(12344169, 5605983 )); pts.push_back(Point(12287203, 5582387 )); pts.push_back(Point(12266270, 5565670 )); pts.push_back(Point(12262940, 5562520 )); pts.push_back(Point(11737750, 5562520 ));
+pts.push_back(Point(11733272, 5562961 )); pts.push_back(Point(11724981, 5566396 )); pts.push_back(Point(11718636, 5572741 )); pts.push_back(Point(11715201, 5581032 )); pts.push_back(Point(11715201, 5590007 )); pts.push_back(Point(11718636, 5598298 )); pts.push_back(Point(11721500, 5601780 ));
+pts.push_back(Point(12287760, 6168050 )); pts.push_back(Point(15689760, 6168050 )); pts.push_back(Point(15904620, 6382900 )); pts.push_back(Point(15909200, 6383030 )); pts.push_back(Point(15935830, 6386006 )); pts.push_back(Point(15992796, 6409602 ));
+pts.push_back(Point(16036397, 6453203 )); pts.push_back(Point(16059993, 6510169 )); pts.push_back(Point(16059993, 6571830 )); pts.push_back(Point(16036397, 6628796 )); pts.push_back(Point(15992796, 6672397 )); pts.push_back(Point(15935830, 6695993 )); pts.push_back(Point(15874169, 6695993 ));
+pts.push_back(Point(15817203, 6672397 )); pts.push_back(Point(15773602, 6628796 )); pts.push_back(Point(15750006, 6571830 )); pts.push_back(Point(15747030, 6545200 )); pts.push_back(Point(15746900, 6540620 )); pts.push_back(Point(15597380, 6391090 )); pts.push_back(Point(14858060, 6391090 ));
+pts.push_back(Point(14858060, 6473860 )); pts.push_back(Point(14869993, 6510179 )); pts.push_back(Point(14869993, 6571840 )); pts.push_back(Point(14846397, 6628806 )); pts.push_back(Point(14802796, 6672407 )); pts.push_back(Point(14745830, 6696003 )); pts.push_back(Point(14684169, 6696003 ));
+pts.push_back(Point(14627203, 6672407 )); pts.push_back(Point(14583602, 6628806 )); pts.push_back(Point(14560006, 6571840 )); pts.push_back(Point(14557030, 6545200 )); pts.push_back(Point(14556900, 6540620 )); pts.push_back(Point(14479020, 6462730 ));
+pts.push_back(Point(13702990, 6462730 )); pts.push_back(Point(13702990, 6537170 )); pts.push_back(Point(13700003, 6571840 )); pts.push_back(Point(13676407, 6628806 )); pts.push_back(Point(13632806, 6672407 )); pts.push_back(Point(13575840, 6696003 ));
+pts.push_back(Point(13514179, 6696003 )); pts.push_back(Point(13457213, 6672407 )); pts.push_back(Point(13413612, 6628806 )); pts.push_back(Point(13390016, 6571840 )); pts.push_back(Point(13387040, 6545550 )); pts.push_back(Point(13386710, 6534380 ));
+pts.push_back(Point(12533290, 6534380 )); pts.push_back(Point(12532960, 6545550 )); pts.push_back(Point(12529983, 6571828 )); pts.push_back(Point(12506388, 6628791 )); pts.push_back(Point(12462791, 6672388 )); pts.push_back(Point(12405828, 6695983 ));
+pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 )); pts.push_back(Point(12266270, 6655670 ));
poly.set(pts.begin(), pts.end());
si.insert(poly, 444);
result.clear();
Modified: sandbox/gtl/gtl/transform.hpp
==============================================================================
--- sandbox/gtl/gtl/transform.hpp (original)
+++ sandbox/gtl/gtl/transform.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -9,136 +9,136 @@
#define GTL_TRANSFORM_HPP
namespace gtl {
-/// Transformation of Coordinate Systems
-/// Enum meaning:
-/// Select which direction_3d to change the positive direction of each
-/// axis in the old coordinate system to map it to the new coordiante system.
-/// The first direction_3d listed for each enum is the direction to map the
-/// positive horizontal direction to.
-/// The second direction_3d listed for each enum is the direction to map the
-/// positive vertical direction to.
-/// The third direction_3d listed for each enum is the direction to map the
-/// positive proximal direction to.
-/// The zero position bit (LSB) indicates whether the horizontal axis flips
-/// when transformed.
-/// The 1st postion bit indicates whether the vertical axis flips when
-/// transformed.
-/// The 2nd position bit indicates whether the horizontal and vertical axis
-/// swap positions when transformed.
-/// Note that the first eight values are the complete set of 2D transforms.
-/// The 3rd position bit indicates whether the proximal axis flips when
-/// transformed.
-/// The 4th position bit indicates whether the proximal and horizontal axis are
-/// swapped when transformed. It changes the meaning of the 2nd position bit
-/// to mean that the horizontal and vertical axis are swapped in their new
-/// positions, naturally.
-/// The 5th position bit (MSB) indicates whether the proximal and vertical axis
-/// are swapped when transformed. It is mutually exclusive with the 4th postion
-/// bit, making the maximum legal value 48 (decimal). It similarly changes the
-/// meaning of the 2nd position bit to mean that the horizontal and vertical are
-/// swapped in their new positions.
-/// Enum Values:
-/// 000000 EAST NORTH UP
-/// 000001 WEST NORTH UP
-/// 000010 EAST SOUTH UP
-/// 000011 WEST SOUTH UP
-/// 000100 NORTH EAST UP
-/// 000101 SOUTH EAST UP
-/// 000110 NORTH WEST UP
-/// 000111 SOUTH WEST UP
-/// 001000 EAST NORTH DOWN
-/// 001001 WEST NORTH DOWN
-/// 001010 EAST SOUTH DOWN
-/// 001011 WEST SOUTH DOWN
-/// 001100 NORTH EAST DOWN
-/// 001101 SOUTH EAST DOWN
-/// 001110 NORTH WEST DOWN
-/// 001111 SOUTH WEST DOWN
-/// 010000 UP NORTH EAST
-/// 010001 DOWN NORTH EAST
-/// 010010 UP SOUTH EAST
-/// 010011 DOWN SOUTH EAST
-/// 010100 NORTH UP EAST
-/// 010101 SOUTH UP EAST
-/// 010110 NORTH DOWN EAST
-/// 010111 SOUTH DOWN EAST
-/// 011000 UP NORTH WEST
-/// 011001 DOWN NORTH WEST
-/// 011010 UP SOUTH WEST
-/// 011011 DOWN SOUTH WEST
-/// 011100 NORTH UP WEST
-/// 011101 SOUTH UP WEST
-/// 011110 NORTH DOWN WEST
-/// 011111 SOUTH DOWN WEST
-/// 100000 EAST UP NORTH
-/// 100001 WEST UP NORTH
-/// 100010 EAST DOWN NORTH
-/// 100011 WEST DOWN NORTH
-/// 100100 UP EAST NORTH
-/// 100101 DOWN EAST NORTH
-/// 100110 UP WEST NORTH
-/// 100111 DOWN WEST NORTH
-/// 101000 EAST UP SOUTH
-/// 101001 WEST UP SOUTH
-/// 101010 EAST DOWN SOUTH
-/// 101011 WEST DOWN SOUTH
-/// 101100 UP EAST SOUTH
-/// 101101 DOWN EAST SOUTH
-/// 101110 UP WEST SOUTH
-/// 101111 DOWN WEST SOUTH
+// Transformation of Coordinate Systems
+// Enum meaning:
+// Select which direction_3d to change the positive direction of each
+// axis in the old coordinate system to map it to the new coordiante system.
+// The first direction_3d listed for each enum is the direction to map the
+// positive horizontal direction to.
+// The second direction_3d listed for each enum is the direction to map the
+// positive vertical direction to.
+// The third direction_3d listed for each enum is the direction to map the
+// positive proximal direction to.
+// The zero position bit (LSB) indicates whether the horizontal axis flips
+// when transformed.
+// The 1st postion bit indicates whether the vertical axis flips when
+// transformed.
+// The 2nd position bit indicates whether the horizontal and vertical axis
+// swap positions when transformed.
+// Note that the first eight values are the complete set of 2D transforms.
+// The 3rd position bit indicates whether the proximal axis flips when
+// transformed.
+// The 4th position bit indicates whether the proximal and horizontal axis are
+// swapped when transformed. It changes the meaning of the 2nd position bit
+// to mean that the horizontal and vertical axis are swapped in their new
+// positions, naturally.
+// The 5th position bit (MSB) indicates whether the proximal and vertical axis
+// are swapped when transformed. It is mutually exclusive with the 4th postion
+// bit, making the maximum legal value 48 (decimal). It similarly changes the
+// meaning of the 2nd position bit to mean that the horizontal and vertical are
+// swapped in their new positions.
+// Enum Values:
+// 000000 EAST NORTH UP
+// 000001 WEST NORTH UP
+// 000010 EAST SOUTH UP
+// 000011 WEST SOUTH UP
+// 000100 NORTH EAST UP
+// 000101 SOUTH EAST UP
+// 000110 NORTH WEST UP
+// 000111 SOUTH WEST UP
+// 001000 EAST NORTH DOWN
+// 001001 WEST NORTH DOWN
+// 001010 EAST SOUTH DOWN
+// 001011 WEST SOUTH DOWN
+// 001100 NORTH EAST DOWN
+// 001101 SOUTH EAST DOWN
+// 001110 NORTH WEST DOWN
+// 001111 SOUTH WEST DOWN
+// 010000 UP NORTH EAST
+// 010001 DOWN NORTH EAST
+// 010010 UP SOUTH EAST
+// 010011 DOWN SOUTH EAST
+// 010100 NORTH UP EAST
+// 010101 SOUTH UP EAST
+// 010110 NORTH DOWN EAST
+// 010111 SOUTH DOWN EAST
+// 011000 UP NORTH WEST
+// 011001 DOWN NORTH WEST
+// 011010 UP SOUTH WEST
+// 011011 DOWN SOUTH WEST
+// 011100 NORTH UP WEST
+// 011101 SOUTH UP WEST
+// 011110 NORTH DOWN WEST
+// 011111 SOUTH DOWN WEST
+// 100000 EAST UP NORTH
+// 100001 WEST UP NORTH
+// 100010 EAST DOWN NORTH
+// 100011 WEST DOWN NORTH
+// 100100 UP EAST NORTH
+// 100101 DOWN EAST NORTH
+// 100110 UP WEST NORTH
+// 100111 DOWN WEST NORTH
+// 101000 EAST UP SOUTH
+// 101001 WEST UP SOUTH
+// 101010 EAST DOWN SOUTH
+// 101011 WEST DOWN SOUTH
+// 101100 UP EAST SOUTH
+// 101101 DOWN EAST SOUTH
+// 101110 UP WEST SOUTH
+// 101111 DOWN WEST SOUTH
class axis_transformation {
public:
- /// Enum Names and values
- /// NULL_TRANSFORM = 0, BEGIN_TRANSFORM = 0,
- /// ENU = 0, EAST_NORTH_UP = 0, EN = 0, EAST_NORTH = 0,
- /// WNU = 1, WEST_NORTH_UP = 1, WN = 1, WEST_NORTH = 1, FLIP_X = 1,
- /// ESU = 2, EAST_SOUTH_UP = 2, ES = 2, EAST_SOUTH = 2, FLIP_Y = 2,
- /// WSU = 3, WEST_SOUTH_UP = 3, WS = 3, WEST_SOUTH = 3,
- /// NEU = 4, NORTH_EAST_UP = 4, NE = 4, NORTH_EAST = 4, SWAP_XY = 4,
- /// SEU = 5, SOUTH_EAST_UP = 5, SE = 5, SOUTH_EAST = 5,
- /// NWU = 6, NORTH_WEST_UP = 6, NW = 6, NORTH_WEST = 6,
- /// SWU = 7, SOUTH_WEST_UP = 7, SW = 7, SOUTH_WEST = 7,
- /// END_2D_TRANSFORM = 7,
- /// END = 8, EAST_NORTH_DOWN = 8,
- /// WND = 9, WEST_NORTH_DOWN = 9,
- /// ESD = 10, EAST_SOUTH_DOWN = 10,
- /// WSD = 11, WEST_SOUTH_DOWN = 11,
- /// NED = 12, NORTH_EAST_DOWN = 12,
- /// SED = 13, SOUTH_EAST_DOWN = 13,
- /// NWD = 14, NORTH_WEST_DOWN = 14,
- /// SWD = 15, SOUTH_WEST_DOWN = 15,
- /// UNE = 16, UP_NORTH_EAST = 16,
- /// DNE = 17, DOWN_NORTH_EAST = 17,
- /// USE = 18, UP_SOUTH_EAST = 18,
- /// DSE = 19, DOWN_SOUTH_EAST = 19,
- /// NUE = 20, NORTH_UP_EAST = 20,
- /// SUE = 21, SOUTH_UP_EAST = 21,
- /// NDE = 22, NORTH_DOWN_EAST = 22,
- /// SDE = 23, SOUTH_DOWN_EAST = 23,
- /// UNW = 24, UP_NORTH_WEST = 24,
- /// DNW = 25, DOWN_NORTH_WEST = 25,
- /// USW = 26, UP_SOUTH_WEST = 26,
- /// DSW = 27, DOWN_SOUTH_WEST = 27,
- /// NUW = 28, NORTH_UP_WEST = 28,
- /// SUW = 29, SOUTH_UP_WEST = 29,
- /// NDW = 30, NORTH_DOWN_WEST = 30,
- /// SDW = 31, SOUTH_DOWN_WEST = 31,
- /// EUN = 32, EAST_UP_NORTH = 32,
- /// WUN = 33, WEST_UP_NORTH = 33,
- /// EDN = 34, EAST_DOWN_NORTH = 34,
- /// WDN = 35, WEST_DOWN_NORTH = 35,
- /// UEN = 36, UP_EAST_NORTH = 36,
- /// DEN = 37, DOWN_EAST_NORTH = 37,
- /// UWN = 38, UP_WEST_NORTH = 38,
- /// DWN = 39, DOWN_WEST_NORTH = 39,
- /// EUS = 40, EAST_UP_SOUTH = 40,
- /// WUS = 41, WEST_UP_SOUTH = 41,
- /// EDS = 42, EAST_DOWN_SOUTH = 42,
- /// WDS = 43, WEST_DOWN_SOUTH = 43,
- /// UES = 44, UP_EAST_SOUTH = 44,
- /// DES = 45, DOWN_EAST_SOUTH = 45,
- /// UWS = 46, UP_WEST_SOUTH = 46,
- /// DWS = 47, DOWN_WEST_SOUTH = 47, END_TRANSFORM = 47
+ // Enum Names and values
+ // NULL_TRANSFORM = 0, BEGIN_TRANSFORM = 0,
+ // ENU = 0, EAST_NORTH_UP = 0, EN = 0, EAST_NORTH = 0,
+ // WNU = 1, WEST_NORTH_UP = 1, WN = 1, WEST_NORTH = 1, FLIP_X = 1,
+ // ESU = 2, EAST_SOUTH_UP = 2, ES = 2, EAST_SOUTH = 2, FLIP_Y = 2,
+ // WSU = 3, WEST_SOUTH_UP = 3, WS = 3, WEST_SOUTH = 3,
+ // NEU = 4, NORTH_EAST_UP = 4, NE = 4, NORTH_EAST = 4, SWAP_XY = 4,
+ // SEU = 5, SOUTH_EAST_UP = 5, SE = 5, SOUTH_EAST = 5,
+ // NWU = 6, NORTH_WEST_UP = 6, NW = 6, NORTH_WEST = 6,
+ // SWU = 7, SOUTH_WEST_UP = 7, SW = 7, SOUTH_WEST = 7,
+ // END_2D_TRANSFORM = 7,
+ // END = 8, EAST_NORTH_DOWN = 8,
+ // WND = 9, WEST_NORTH_DOWN = 9,
+ // ESD = 10, EAST_SOUTH_DOWN = 10,
+ // WSD = 11, WEST_SOUTH_DOWN = 11,
+ // NED = 12, NORTH_EAST_DOWN = 12,
+ // SED = 13, SOUTH_EAST_DOWN = 13,
+ // NWD = 14, NORTH_WEST_DOWN = 14,
+ // SWD = 15, SOUTH_WEST_DOWN = 15,
+ // UNE = 16, UP_NORTH_EAST = 16,
+ // DNE = 17, DOWN_NORTH_EAST = 17,
+ // USE = 18, UP_SOUTH_EAST = 18,
+ // DSE = 19, DOWN_SOUTH_EAST = 19,
+ // NUE = 20, NORTH_UP_EAST = 20,
+ // SUE = 21, SOUTH_UP_EAST = 21,
+ // NDE = 22, NORTH_DOWN_EAST = 22,
+ // SDE = 23, SOUTH_DOWN_EAST = 23,
+ // UNW = 24, UP_NORTH_WEST = 24,
+ // DNW = 25, DOWN_NORTH_WEST = 25,
+ // USW = 26, UP_SOUTH_WEST = 26,
+ // DSW = 27, DOWN_SOUTH_WEST = 27,
+ // NUW = 28, NORTH_UP_WEST = 28,
+ // SUW = 29, SOUTH_UP_WEST = 29,
+ // NDW = 30, NORTH_DOWN_WEST = 30,
+ // SDW = 31, SOUTH_DOWN_WEST = 31,
+ // EUN = 32, EAST_UP_NORTH = 32,
+ // WUN = 33, WEST_UP_NORTH = 33,
+ // EDN = 34, EAST_DOWN_NORTH = 34,
+ // WDN = 35, WEST_DOWN_NORTH = 35,
+ // UEN = 36, UP_EAST_NORTH = 36,
+ // DEN = 37, DOWN_EAST_NORTH = 37,
+ // UWN = 38, UP_WEST_NORTH = 38,
+ // DWN = 39, DOWN_WEST_NORTH = 39,
+ // EUS = 40, EAST_UP_SOUTH = 40,
+ // WUS = 41, WEST_UP_SOUTH = 41,
+ // EDS = 42, EAST_DOWN_SOUTH = 42,
+ // WDS = 43, WEST_DOWN_SOUTH = 43,
+ // UES = 44, UP_EAST_SOUTH = 44,
+ // DES = 45, DOWN_EAST_SOUTH = 45,
+ // UWS = 46, UP_WEST_SOUTH = 46,
+ // DWS = 47, DOWN_WEST_SOUTH = 47, END_TRANSFORM = 47
enum ATR {
NULL_TRANSFORM = 0, BEGIN_TRANSFORM = 0,
ENU = 0, EAST_NORTH_UP = 0, EN = 0, EAST_NORTH = 0,
@@ -223,33 +223,33 @@
explicit axis_transformation(const orientation_2d& orient);
explicit axis_transformation(const direction_2d& dir);
- /// assignment operator
+ // assignment operator
axis_transformation& operator=(const axis_transformation& a);
- /// assignment operator
+ // assignment operator
axis_transformation& operator=(const ATR& atr);
- /// equivalence operator
+ // equivalence operator
bool operator==(const axis_transformation& a) const;
- /// inequivalence operator
+ // inequivalence operator
bool operator!=(const axis_transformation& a) const;
- /// ordering
+ // ordering
bool operator<(const axis_transformation& a) const;
- /// concatenation operator
+ // concatenation operator
axis_transformation operator+(const axis_transformation& a) const;
- /// concatenate this with that
+ // concatenate this with that
axis_transformation& operator+=(const axis_transformation& a);
- /// populate_axis_array writes the three INDIVIDUAL_AXIS values that the
- /// ATR enum value of 'this' represent into axis_array
+ // populate_axis_array writes the three INDIVIDUAL_AXIS values that the
+ // ATR enum value of 'this' represent into axis_array
void populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const;
- /// it is recommended that the directions stored in an array
- /// in the caller code for easier isotropic access by orientation value
+ // it is recommended that the directions stored in an array
+ // in the caller code for easier isotropic access by orientation value
inline void get_directions(direction_2d& horizontal_dir,
direction_2d& vertical_dir) const {
bool bit2 = atr_ & 4;
@@ -259,8 +259,8 @@
horizontal_dir = direction_2d((direction_2d_enum)(((int)(bit2) << 1) + !bit0));
}
- /// it is recommended that the directions stored in an array
- /// in the caller code for easier isotropic access by orientation value
+ // it is recommended that the directions stored in an array
+ // in the caller code for easier isotropic access by orientation value
inline void get_directions(direction_3d& horizontal_dir,
direction_3d& vertical_dir,
direction_3d& proximal_dir) const {
@@ -282,8 +282,8 @@
!bit0));
}
- /// combine_axis_arrays concatenates this_array and that_array overwriting
- /// the result into this_array
+ // combine_axis_arrays concatenates this_array and that_array overwriting
+ // the result into this_array
static void combine_axis_arrays (INDIVIDUAL_AXIS this_array[],
const INDIVIDUAL_AXIS that_array[]);
@@ -301,24 +301,24 @@
const direction_3d& vertical_dir,
const direction_3d& proximal_dir);
- /// transform the two coordinates by reference using the 2D portion of this
+ // transform the two coordinates by reference using the 2D portion of this
template <typename coordinate_type>
void transform(coordinate_type& x, coordinate_type& y) const;
- /// transform the three coordinates by reference
+ // transform the three coordinates by reference
template <typename coordinate_type>
void transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const;
- /// invert the 2D portion of this
+ // invert the 2D portion of this
axis_transformation& invert_2d();
- /// get the inverse of the 2D portion of this
+ // get the inverse of the 2D portion of this
axis_transformation inverse_2d() const;
- /// invert this axis_transformation
+ // invert this axis_transformation
axis_transformation& invert();
- /// get the inverse axis_transformation of this
+ // get the inverse axis_transformation of this
axis_transformation inverse() const;
friend std::ostream& operator<< (std::ostream& o, const axis_transformation& r);
@@ -329,12 +329,12 @@
};
-/// Scaling object to be used to store the scale factor for each axis
+// Scaling object to be used to store the scale factor for each axis
-/// For use by the transformation object, in that context the scale factor
-/// is the amount that each axis scales by when transformed.
-/// If the horizontal value of the Scale is 10 that means the horizontal
-/// axis of the input is multiplied by 10 when the transformation is applied.
+// For use by the transformation object, in that context the scale factor
+// is the amount that each axis scales by when transformed.
+// If the horizontal value of the Scale is 10 that means the horizontal
+// axis of the input is multiplied by 10 when the transformation is applied.
template <typename scale_factor_type>
class anisotropic_scale_factor {
public:
@@ -354,11 +354,11 @@
scale_[2] = zscale;
}
- /// get a component of the anisotropic_scale_factor by orientation
+ // get a component of the anisotropic_scale_factor by orientation
scale_factor_type get(orientation_3d orient) const;
scale_factor_type get(orientation_2d orient) const { return get(orientation_3d(orient)); }
- /// set a component of the anisotropic_scale_factor by orientation
+ // set a component of the anisotropic_scale_factor by orientation
void set(orientation_3d orient, scale_factor_type value);
void set(orientation_2d orient, scale_factor_type value) { set(orientation_3d(orient), value); }
@@ -369,24 +369,24 @@
void y(scale_factor_type value);
void z(scale_factor_type value);
- /// concatination operator (convolve scale factors)
+ // concatination operator (convolve scale factors)
anisotropic_scale_factor operator+(const anisotropic_scale_factor& s) const;
- /// concatinate this with that
+ // concatinate this with that
const anisotropic_scale_factor& operator+=(const anisotropic_scale_factor& s);
- /// transform this scale with an axis_transform
+ // transform this scale with an axis_transform
anisotropic_scale_factor& transform(axis_transformation atr);
- /// scale the two coordinates
+ // scale the two coordinates
template <typename coordinate_type>
void scale(coordinate_type& x, coordinate_type& y) const;
- /// scale the three coordinates
+ // scale the three coordinates
template <typename coordinate_type>
void scale(coordinate_type& x, coordinate_type& y, coordinate_type& z) const;
- /// invert this scale factor to give the reverse scale factor
+ // invert this scale factor to give the reverse scale factor
anisotropic_scale_factor& invert();
private:
@@ -396,11 +396,11 @@
//friend std::istream& operator>> (std::istream& i, Scale& r);
};
-/// Transformation object, stores and provides services for transformations
+// Transformation object, stores and provides services for transformations
-/// Transformation object stores an axistransformation, a scale factor and a translation.
-/// The tranlation is the position of the origin of the new system of coordinates in the old system.
-/// The scale scales the coordinates before they are transformed.
+// Transformation object stores an axistransformation, a scale factor and a translation.
+// The tranlation is the position of the origin of the new system of coordinates in the old system.
+// The scale scales the coordinates before they are transformed.
template <typename coordinate_type>
class transformation {
public:
@@ -414,45 +414,45 @@
transformation(axis_transformation atr, const point_type& referencePt, const point_type& destinationPt);
transformation(const transformation& tr);
- /// equivalence operator
+ // equivalence operator
bool operator==(const transformation& tr) const;
- /// inequivalence operator
+ // inequivalence operator
bool operator!=(const transformation& tr) const;
- /// ordering
+ // ordering
bool operator<(const transformation& tr) const;
- /// concatenation operator
+ // concatenation operator
transformation operator+(const transformation& tr) const;
- /// concatenate this with that
+ // concatenate this with that
const transformation& operator+=(const transformation& tr);
- /// get the axis_transformation portion of this
+ // get the axis_transformation portion of this
inline axis_transformation get_axis_transformation() const {return atr_;}
- /// set the axis_transformation portion of this
+ // set the axis_transformation portion of this
void set_axis_transformation(const axis_transformation& atr);
- /// get the translation portion of this as a point3d
+ // get the translation portion of this as a point3d
template <typename point_type>
void get_translation(point_type& translation) const;
- /// set the translation portion of this with a point3d
+ // set the translation portion of this with a point3d
template <typename point_type>
void set_translation(const point_type& p);
- /// apply the 2D portion of this transformation to the two coordinates given
+ // apply the 2D portion of this transformation to the two coordinates given
void transform(coordinate_type& x, coordinate_type& y) const;
- /// apply this transformation to the three coordinates given
+ // apply this transformation to the three coordinates given
void transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const;
- /// invert this transformation
+ // invert this transformation
transformation& invert();
- /// get the inverse of this transformation
+ // get the inverse of this transformation
transformation inverse() const;
inline void get_directions(direction_2d& horizontal_dir,
Modified: sandbox/gtl/gtl/transform_detail.hpp
==============================================================================
--- sandbox/gtl/gtl/transform_detail.hpp (original)
+++ sandbox/gtl/gtl/transform_detail.hpp 2009-03-13 14:35:56 EDT (Fri, 13 Mar 2009)
@@ -523,9 +523,9 @@
atr_.transform(x,y,z);
}
-/// sets the axis_transform portion to its inverse
-/// transforms the tranlastion portion by that inverse axis_transform
-/// multiplies the translation portion by -1 to reverse it
+// sets the axis_transform portion to its inverse
+// transforms the tranlastion portion by that inverse axis_transform
+// multiplies the translation portion by -1 to reverse it
template <typename coordinate_type>
inline transformation<coordinate_type>& transformation<coordinate_type>::invert() {
coordinate_type x = p_.get(HORIZONTAL), y = p_.get(VERTICAL), z = p_.get(PROXIMAL);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk