|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82040 - in branches/release: boost/polygon boost/polygon/detail libs/polygon/doc libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-12-16 18:16:09
Author: asydorchuk
Date: 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
New Revision: 82040
URL: http://svn.boost.org/trac/boost/changeset/82040
Log:
Polygon: Merging trunk and release branches.
Added tests and refactored data/traits/concept classes for point/interval/segment.
Removed point_3d point/interval/segment.
Simplified transform (3D->2D).
Fixed bugs: #6366, #7678.
Added:
branches/release/libs/polygon/test/polygon_interval_test.cpp (contents, props changed)
branches/release/libs/polygon/test/polygon_point_test.cpp (contents, props changed)
Removed:
branches/release/boost/polygon/detail/transform_detail.hpp
branches/release/boost/polygon/point_3d_concept.hpp
branches/release/boost/polygon/point_3d_data.hpp
branches/release/boost/polygon/point_3d_traits.hpp
Text files modified:
branches/release/boost/polygon/detail/boolean_op_45.hpp | 110 +-
branches/release/boost/polygon/detail/polygon_45_formation.hpp | 178 ++--
branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp | 258 +++---
branches/release/boost/polygon/detail/scan_arbitrary.hpp | 170 ++--
branches/release/boost/polygon/interval_concept.hpp | 1397 ++++++++++++++++++++++++---------------
branches/release/boost/polygon/interval_data.hpp | 157 +++-
branches/release/boost/polygon/interval_traits.hpp | 73 +
branches/release/boost/polygon/point_concept.hpp | 761 +++++++++++++--------
branches/release/boost/polygon/point_data.hpp | 220 +++--
branches/release/boost/polygon/point_traits.hpp | 70 +
branches/release/boost/polygon/polygon.hpp | 6
branches/release/boost/polygon/polygon_90_set_data.hpp | 1
branches/release/boost/polygon/polygon_90_set_traits.hpp | 2
branches/release/boost/polygon/polygon_traits.hpp | 58
branches/release/boost/polygon/segment_concept.hpp | 212 ++---
branches/release/boost/polygon/segment_data.hpp | 99 +-
branches/release/boost/polygon/segment_traits.hpp | 78 +
branches/release/boost/polygon/transform.hpp | 672 +++++++++----------
branches/release/boost/polygon/voronoi_geometry_type.hpp | 2
branches/release/libs/polygon/doc/gtl_interval_concept.htm | 58 +
branches/release/libs/polygon/doc/gtl_point_concept.htm | 206 ++---
branches/release/libs/polygon/doc/gtl_segment_concept.htm | 9
branches/release/libs/polygon/test/Jamfile.v2 | 2
branches/release/libs/polygon/test/gtl_boost_unit_test.cpp | 105 --
branches/release/libs/polygon/test/polygon_segment_test.cpp | 98 +-
25 files changed, 2704 insertions(+), 2298 deletions(-)
Modified: branches/release/boost/polygon/detail/boolean_op_45.hpp
==============================================================================
--- branches/release/boost/polygon/detail/boolean_op_45.hpp (original)
+++ branches/release/boost/polygon/detail/boolean_op_45.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -395,9 +395,9 @@
int edgeType = applyLogic<op>(count1, count2);
if(edgeType) {
int multiplier = end == LOW ? -1 : 1;
- //std::cout << "cross logic: " << edgeType << std::endl;
+ //std::cout << "cross logic: " << edgeType << "\n";
output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
- //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+ //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << "\n";
}
}
};
@@ -428,9 +428,9 @@
int edgeType = applyLogic<op>(count1, count2);
if(edgeType) {
int multiplier = end == LOW ? -1 : 1;
- //std::cout << "cross logic: " << edgeType << std::endl;
+ //std::cout << "cross logic: " << edgeType << "\n";
output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
- //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+ //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << "\n";
}
}
};
@@ -510,18 +510,18 @@
//std::cout << "1\n";
while(inputBegin != inputEnd) {
//std::cout << "2\n";
- //std::cout << "x_ = " << x_ << std::endl;
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "x_ = " << x_ << "\n";
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
//for(iterator iter = scanData_.begin();
// iter != scanData_.end(); ++iter) {
// std::cout << "scan element\n";
- // std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
+ // std::cout << *iter << " " << iter->evalAtX(x_) << "\n";
// }
- // std::cout << "cross queue size: " << crossQueue_.size() << std::endl;
- // std::cout << "cross vector size: " << crossVector_.size() << std::endl;
+ // std::cout << "cross queue size: " << crossQueue_.size() << "\n";
+ // std::cout << "cross vector size: " << crossVector_.size() << "\n";
//for(CrossQueue::iterator cqitr = crossQueue_.begin(); cqitr != crossQueue_.end(); ++cqitr) {
// std::cout << *cqitr << " ";
- //} std::cout << std::endl;
+ //} std::cout << "\n";
Unit nextX = (*inputBegin).first.x();
if(!crossVector_.empty() && crossVector_[0].first.x() < nextX) nextX = crossVector_[0].first.x();
if(nextX != x_) {
@@ -567,18 +567,18 @@
//std::cout << "loop\n";
//pop point off the cross queue
Point crossPoint = *(crossQueue_.begin());
- //std::cout << crossPoint << std::endl;
+ //std::cout << crossPoint << "\n";
//for(iterator iter = scanData_.begin();
// iter != scanData_.end(); ++iter) {
// std::cout << "scan element\n";
- // std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
+ // std::cout << *iter << " " << iter->evalAtX(x_) << "\n";
//}
crossQueue_.erase(crossQueue_.begin());
Scan45Vertex vertex(crossPoint, Scan45Count());
iterator lowIter = lookUp_(vertex.first.y());
- //std::cout << "searching at: " << vertex.first.y() << std::endl;
+ //std::cout << "searching at: " << vertex.first.y() << "\n";
//if(lowIter == scanData_.end()) std::cout << "could not find\n";
- //else std::cout << "found: " << *lowIter << std::endl;
+ //else std::cout << "found: " << *lowIter << "\n";
if(lowIter == scanData_.end() ||
lowIter->evalAtX(x_) != vertex.first.y()) {
// std::cout << "skipping\n";
@@ -593,7 +593,7 @@
--searchDownItr;
countBelow = searchDownItr->count;
}
- //std::cout << "Below Count: " << countBelow << std::endl;
+ //std::cout << "Below Count: " << countBelow << "\n";
Scan45Count count(countBelow);
std::size_t numEdges = 0;
iterator eraseItrs[3];
@@ -601,7 +601,7 @@
lowIter->evalAtX(x_) == vertex.first.y()) {
for(int index = lowIter->rise +1; index >= 0; --index)
count[index] = lowIter->count;
- //std::cout << count << std::endl;
+ //std::cout << count << "\n";
eraseItrs[numEdges] = lowIter;
++numEdges;
++lowIter;
@@ -630,8 +630,8 @@
vertex.second[0] = count[0] - count[1];
//add the point, deriviative pair into the cross vector
//std::cout << "LOOK HERE!\n";
- //std::cout << count << std::endl;
- //std::cout << vertex << std::endl;
+ //std::cout << count << "\n";
+ //std::cout << vertex << "\n";
crossVector_.push_back(vertex);
}
//erase crossing elements
@@ -686,10 +686,10 @@
iterator prevIter = scanData_.end();
while(inputBegin != inputEnd &&
(*inputBegin).first.x() == x_) {
- //std::cout << (*inputBegin) << std::endl;
+ //std::cout << (*inputBegin) << "\n";
//std::cout << "loop\n";
Scan45Vertex vertex = *inputBegin;
- //std::cout << vertex.first << std::endl;
+ //std::cout << vertex.first << "\n";
//if vertical count propigating up fake a null event at the next element
if(verticalCount != CountType() && (prevIter != scanData_.end() &&
prevIter->evalAtX(x_) < vertex.first.y())) {
@@ -707,13 +707,13 @@
++inputBegin;
}
}
- //std::cout << vertex.second << std::endl;
+ //std::cout << vertex.second << "\n";
//integrate vertex
CountType currentCount = verticalCount;// + vertex.second[0];
for(unsigned int i = 0; i < 3; ++i) {
vertex.second[i] = currentCount += vertex.second[i];
}
- //std::cout << vertex.second << std::endl;
+ //std::cout << vertex.second << "\n";
//vertex represents the change in state at this point
//get counts at current vertex
@@ -725,8 +725,8 @@
countBelow = lowIter->count;
++lowIter;
}
- //std::cout << "Count Below: " << countBelow[0] << " " << countBelow[1] << std::endl;
- //std::cout << "vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
+ //std::cout << "Count Below: " << countBelow[0] << " " << countBelow[1] << "\n";
+ //std::cout << "vertical count: " << verticalCount[0] << " " << verticalCount[1] << "\n";
Scan45Count countAt(countBelow - verticalCount);
//check if the vertical edge should be written out
if(verticalCount != CountType()) {
@@ -756,20 +756,20 @@
}
verticalCount += vertex.second[3];
prevPoint = vertex.first;
- //std::cout << "new vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
+ //std::cout << "new vertical count: " << verticalCount[0] << " " << verticalCount[1] << "\n";
prevIter = lowIter;
//count represents the current state at this point
- //std::cout << vertex.second << std::endl;
- //std::cout << countAt << std::endl;
+ //std::cout << vertex.second << "\n";
+ //std::cout << countAt << "\n";
//std::cout << "ADD\n";
vertex.second += countAt;
- //std::cout << vertex.second << std::endl;
+ //std::cout << vertex.second << "\n";
//add elements to the scanline
for(int i = 0; i < 3; ++i) {
if(vertex.second[i] != countBelow) {
//std::cout << "insert: " << vertex.first.x() << " " << vertex.first.y() << " " << i-1 <<
- // " " << vertex.second[i][0] << " " << vertex.second[i][1] << std::endl;
+ // " " << vertex.second[i][0] << " " << vertex.second[i][1] << "\n";
iterator insertIter = scanData_.insert(scanData_.end(),
Scan45ElementT<CountType>(vertex.first.x(),
vertex.first.y(),
@@ -864,7 +864,7 @@
}
}
}
- //std::cout << std::endl;
+ //std::cout << "\n";
}
inline iterator lookUp_(Unit y){
@@ -878,7 +878,7 @@
// 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;
+ // std::cout << iter->x << " " << iter->y << " " << iter->rise << "\n";
// }
//}
@@ -957,13 +957,13 @@
reference.push_back(Vertex45(Point(10, 10), 2, 1));
reference.push_back(Vertex45(Point(10, 10), 0, 1));
if(result != reference) {
- stdcout << "result size == " << result.size() << std::endl;
+ stdcout << "result size == " << result.size() << "\n";
for(std::size_t i = 0; i < result.size(); ++i) {
- //std::cout << "result == " << result[i]<< std::endl;
+ //std::cout << "result == " << result[i]<< "\n";
}
- stdcout << "reference size == " << reference.size() << std::endl;
+ stdcout << "reference size == " << reference.size() << "\n";
for(std::size_t i = 0; i < reference.size(); ++i) {
- //std::cout << "reference == " << reference[i]<< std::endl;
+ //std::cout << "reference == " << reference[i]<< "\n";
}
return false;
}
@@ -1007,13 +1007,13 @@
reference.push_back(Vertex45(Point(10, 20), 2, 1));
reference.push_back(Vertex45(Point(10, 20), 1, 1));
if(result != reference) {
- stdcout << "result size == " << result.size() << std::endl;
+ stdcout << "result size == " << result.size() << "\n";
for(std::size_t i = 0; i < result.size(); ++i) {
- //std::cout << "result == " << result[i]<< std::endl;
+ //std::cout << "result == " << result[i]<< "\n";
}
- stdcout << "reference size == " << reference.size() << std::endl;
+ stdcout << "reference size == " << reference.size() << "\n";
for(std::size_t i = 0; i < reference.size(); ++i) {
- //std::cout << "reference == " << reference[i]<< std::endl;
+ //std::cout << "reference == " << reference[i]<< "\n";
}
return false;
}
@@ -1057,13 +1057,13 @@
reference.push_back(Vertex45(Point(20, 10), 1, -1));
reference.push_back(Vertex45(Point(20, 10), 0, 1));
if(result != reference) {
- stdcout << "result size == " << result.size() << std::endl;
+ stdcout << "result size == " << result.size() << "\n";
for(std::size_t i = 0; i < result.size(); ++i) {
- //stdcout << "result == " << result[i]<< std::endl;
+ //stdcout << "result == " << result[i]<< "\n";
}
- stdcout << "reference size == " << reference.size() << std::endl;
+ stdcout << "reference size == " << reference.size() << "\n";
for(std::size_t i = 0; i < reference.size(); ++i) {
- //stdcout << "reference == " << reference[i]<< std::endl;
+ //stdcout << "reference == " << reference[i]<< "\n";
}
return false;
}
@@ -1114,13 +1114,13 @@
reference.push_back(Vertex45(Point(10, 10), 2, 1));
reference.push_back(Vertex45(Point(10, 10), 0, 1));
if(result != reference) {
- stdcout << "result size == " << result.size() << std::endl;
+ stdcout << "result size == " << result.size() << "\n";
for(std::size_t i = 0; i < result.size(); ++i) {
- //stdcout << "result == " << result[i]<< std::endl;
+ //stdcout << "result == " << result[i]<< "\n";
}
- stdcout << "reference size == " << reference.size() << std::endl;
+ stdcout << "reference size == " << reference.size() << "\n";
for(std::size_t i = 0; i < reference.size(); ++i) {
- //stdcout << "reference == " << reference[i]<< std::endl;
+ //stdcout << "reference == " << reference[i]<< "\n";
}
return false;
}
@@ -1176,8 +1176,8 @@
// result == 12 8 1 -1
// result == 12 8 -1 1
if(result.size() != 24) {
- //stdcout << "result size == " << result.size() << std::endl;
- //stdcout << "reference size == " << 24 << std::endl;
+ //stdcout << "result size == " << result.size() << "\n";
+ //stdcout << "reference size == " << 24 << "\n";
return false;
}
stdcout << "done testing Scan45Star1\n";
@@ -1232,8 +1232,8 @@
// result == 16 8 1 -1
// result == 16 8 0 1
if(result.size() != 24) {
- //std::cout << "result size == " << result.size() << std::endl;
- //std::cout << "reference size == " << 24 << std::endl;
+ //std::cout << "result size == " << result.size() << "\n";
+ //std::cout << "reference size == " << 24 << "\n";
return false;
}
stdcout << "done testing Scan45Star2\n";
@@ -1297,8 +1297,8 @@
// result == 12 14 2 1
// result == 12 14 0 1
if(result.size() != 28) {
- //std::cout << "result size == " << result.size() << std::endl;
- //std::cout << "reference size == " << 28 << std::endl;
+ //std::cout << "result size == " << result.size() << "\n";
+ //std::cout << "reference size == " << 28 << "\n";
return false;
}
@@ -1364,8 +1364,8 @@
// result == 16 12 2 1
// result == 16 12 0 1
if(result.size() != 28) {
- //stdcout << "result size == " << result.size() << std::endl;
- //stdcout << "reference size == " << 28 << std::endl;
+ //stdcout << "result size == " << result.size() << "\n";
+ //stdcout << "reference size == " << 28 << "\n";
return false;
}
Modified: branches/release/boost/polygon/detail/polygon_45_formation.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_45_formation.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_45_formation.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -311,7 +311,7 @@
at1->copyHoles(*(at1->otherTailp_));
//std::cout << "test2\n";
//Polygon45WithHolesImpl<PolyLine45PolygonData> poly(polyData);
- //std::cout << poly << std::endl;
+ //std::cout << poly << "\n";
//std::cout << "test3\n";
typedef typename cT::value_type pType;
output.push_back(pType());
@@ -319,14 +319,14 @@
typename PolyLineByConcept<Unit, cType>::type polyData(at1);
assign(output.back(), polyData);
//std::cout << "test4\n";
- //std::cout << "delete " << at1->otherTailp_ << std::endl;
+ //std::cout << "delete " << at1->otherTailp_ << "\n";
//at1->print();
//at1->otherTailp_->print();
delete at1->otherTailp_;
//at1->print();
//at1->otherTailp_->print();
//std::cout << "test5\n";
- //std::cout << "delete " << at1 << std::endl;
+ //std::cout << "delete " << at1 << "\n";
delete at1;
//std::cout << "test6\n";
return 0;
@@ -345,7 +345,7 @@
inline void destroyContents() {
if(otherTailp_) {
- //std::cout << "delete p " << tailp_ << std::endl;
+ //std::cout << "delete p " << tailp_ << "\n";
if(tailp_) delete tailp_;
tailp_ = 0;
otherTailp_->otherTailp_ = 0;
@@ -353,7 +353,7 @@
otherTailp_ = 0;
}
for(typename std::list<ActiveTail45*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
- //std::cout << "delete p " << (*itr) << std::endl;
+ //std::cout << "delete p " << (*itr) << "\n";
if(*itr) {
if((*itr)->otherTailp_) {
delete (*itr)->otherTailp_;
@@ -367,7 +367,7 @@
}
// inline void print() {
-// std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
+// std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << "\n";
// }
static inline std::pair<ActiveTail45*, ActiveTail45*> createActiveTail45sAsPair(Point point, bool solid,
@@ -575,9 +575,9 @@
while(inputBegin != inputEnd) {
//std::cout << "2\n";
x_ = (*inputBegin).pt.x();
- //std::cout << "SCAN FORMATION " << x_ << std::endl;
- //std::cout << "x_ = " << x_ << std::endl;
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "SCAN FORMATION " << x_ << "\n";
+ //std::cout << "x_ = " << x_ << "\n";
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
inputBegin = processEvent_(output, inputBegin, inputEnd);
}
}
@@ -587,7 +587,7 @@
template <class cT, class cT2>
inline std::pair<int, ActiveTail45*> processPoint_(cT& output, cT2& elements, Point point,
Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) {
- //std::cout << point << std::endl;
+ //std::cout << point << "\n";
//std::cout << counts[0] << " ";
//std::cout << counts[1] << " ";
//std::cout << counts[2] << " ";
@@ -600,14 +600,14 @@
ActiveTail45* returnValue = 0;
int returnCount = 0;
for(int i = 0; i < 3; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] == -1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < 4; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(counts[j]) {
if(counts[j] == 1) {
- //std::cout << "case1: " << i << " " << j << std::endl;
+ //std::cout << "case1: " << i << " " << j << "\n";
//if a figure is closed it will be written out by this function to output
ActiveTail45::joinChains(point, tails[i], tails[j], true, output);
counts[i] = 0;
@@ -623,14 +623,14 @@
//find any pairs of incoming edges that need to create pair for leading solid
//std::cout << "checking case2\n";
for(int i = 0; i < 3; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(incoming[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < 4; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(incoming[j]) {
if(incoming[j] == -1) {
- //std::cout << "case2: " << i << " " << j << std::endl;
+ //std::cout << "case2: " << i << " " << j << "\n";
//std::cout << "creating active tail pair\n";
std::pair<ActiveTail45*, ActiveTail45*> tailPair =
ActiveTail45::createActiveTail45sAsPair(point, true, 0, fractureHoles_ != 0);
@@ -642,10 +642,10 @@
returnCount = 1;
} else {
Vertex45 vertex(point, i -1, incoming[i]);
- //std::cout << "new element " << j-1 << " " << -1 << std::endl;
+ //std::cout << "new element " << j-1 << " " << -1 << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << 1 << std::endl;
+ //std::cout << "new element " << i-1 << " " << 1 << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
incoming[i] = 0;
incoming[j] = 0;
@@ -662,14 +662,14 @@
//find pass through with solid on top
//std::cout << "checking case 3\n";
for(int i = 0; i < 4; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] != 0) {
if(counts[i] == 1) {
//std::cout << "fixed i\n";
for(int j = 3; j >= 0; --j) {
if(incoming[j] != 0) {
if(incoming[j] == 1) {
- //std::cout << "case3: " << i << " " << j << std::endl;
+ //std::cout << "case3: " << i << " " << j << "\n";
//tails[i]->print();
//pass through solid on top
tails[i]->pushPoint(point);
@@ -699,14 +699,14 @@
for(int j = 0; j < 4; ++j) {
if(incoming[j] != 0) {
if(incoming[j] == -1) {
- //std::cout << "case4: " << i << " " << j << std::endl;
+ //std::cout << "case4: " << i << " " << j << "\n";
//pass through solid on bottom
tails[i]->pushPoint(point);
if(j == 3) {
returnValue = tails[i];
returnCount = 1;
} else {
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
}
tails[i] = 0;
@@ -728,7 +728,7 @@
if(counts[i] != 0) {
for(int j = i+1; j < 4; ++j) {
if(counts[j] != 0) {
- //std::cout << "case5: " << i << " " << j << std::endl;
+ //std::cout << "case5: " << i << " " << j << "\n";
//we are ending a hole and may potentially close a figure and have to handle the hole
returnValue = ActiveTail45::joinChains(point, tails[i], tails[j], false, output);
tails[i] = 0;
@@ -746,7 +746,7 @@
if(incoming[i] != 0) {
for(int j = i+1; j < 4; ++j) {
if(incoming[j] != 0) {
- //std::cout << "case6: " << i << " " << j << std::endl;
+ //std::cout << "case6: " << i << " " << j << "\n";
//we are beginning a empty space
ActiveTail45* holep = 0;
if(counts[3] == 0) holep = tails[3];
@@ -756,10 +756,10 @@
returnValue = tailPair.first;
returnCount = -1;
} else {
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
+ //std::cout << "new element " << i-1 << " " << incoming[i] << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), tailPair.second));
incoming[i] = 0;
incoming[j] = 0;
@@ -798,7 +798,7 @@
//std::cout << "loop2\n";
elementIters.push_back(iter);
int index = iter->first.rise + 1;
- //std::cout << index << " " << iter->first.count << std::endl;
+ //std::cout << index << " " << iter->first.count << "\n";
counts[index] = iter->first.count;
tails[index] = iter->second;
++iter;
@@ -834,7 +834,7 @@
verticalCount = result.first;
verticalTail = result.second;
//if(verticalTail) std::cout << "have vertical tail\n";
- //std::cout << "verticalCount: " << verticalCount << std::endl;
+ //std::cout << "verticalCount: " << verticalCount << "\n";
if(verticalTail && !verticalCount) {
//we got a hole out of the point we just processed
//iter is still at the next y element above the current y value in the tree
@@ -906,9 +906,9 @@
data.push_back(Vertex45(Point(10, 10), 0, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -930,9 +930,9 @@
data.push_back(Vertex45(Point(10, 20), 1, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -955,9 +955,9 @@
data.push_back(Vertex45(Point(20, 10), 0, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1020,9 +1020,9 @@
data.push_back(Vertex45(Point(12, 8), -1, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1053,9 +1053,9 @@
polygon_sort(result.begin(), result.end());
pf.scan(polys, result.begin(), result.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1125,9 +1125,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1197,9 +1197,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1241,9 +1241,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1289,9 +1289,9 @@
while(inputBegin != inputEnd) {
//std::cout << "2\n";
x_ = (*inputBegin).pt.x();
- //std::cout << "SCAN FORMATION " << x_ << std::endl;
- //std::cout << "x_ = " << x_ << std::endl;
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "SCAN FORMATION " << x_ << "\n";
+ //std::cout << "x_ = " << x_ << "\n";
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
inputBegin = processEvent_(output, inputBegin, inputEnd);
}
}
@@ -1316,7 +1316,7 @@
std::pair<ActiveTail45*, ActiveTail45*>& verticalPair,
iterator previter, Point point,
Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) {
- //std::cout << point << std::endl;
+ //std::cout << point << "\n";
//std::cout << counts[0] << " ";
//std::cout << counts[1] << " ";
//std::cout << counts[2] << " ";
@@ -1332,14 +1332,14 @@
verticalPairOut.second = 0;
int returnCount = 0;
for(int i = 0; i < 3; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] == -1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < 4; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(counts[j]) {
if(counts[j] == 1) {
- //std::cout << "case1: " << i << " " << j << std::endl;
+ //std::cout << "case1: " << i << " " << j << "\n";
//if a figure is closed it will be written out by this function to output
ActiveTail45::joinChains(point, tails[i], tails[j], true, output);
counts[i] = 0;
@@ -1355,14 +1355,14 @@
//find any pairs of incoming edges that need to create pair for leading solid
//std::cout << "checking case2\n";
for(int i = 0; i < 3; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(incoming[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < 4; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(incoming[j]) {
if(incoming[j] == -1) {
- //std::cout << "case2: " << i << " " << j << std::endl;
+ //std::cout << "case2: " << i << " " << j << "\n";
//std::cout << "creating active tail pair\n";
std::pair<ActiveTail45*, ActiveTail45*> tailPair =
ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
@@ -1374,10 +1374,10 @@
returnCount = 1;
} else {
Vertex45 vertex(point, i -1, incoming[i]);
- //std::cout << "new element " << j-1 << " " << -1 << std::endl;
+ //std::cout << "new element " << j-1 << " " << -1 << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << 1 << std::endl;
+ //std::cout << "new element " << i-1 << " " << 1 << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
incoming[i] = 0;
incoming[j] = 0;
@@ -1394,14 +1394,14 @@
//find pass through with solid on top
//std::cout << "checking case 3\n";
for(int i = 0; i < 4; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] != 0) {
if(counts[i] == 1) {
//std::cout << "fixed i\n";
for(int j = 3; j >= 0; --j) {
if(incoming[j] != 0) {
if(incoming[j] == 1) {
- //std::cout << "case3: " << i << " " << j << std::endl;
+ //std::cout << "case3: " << i << " " << j << "\n";
//tails[i]->print();
//pass through solid on top
if(i != 3)
@@ -1437,10 +1437,10 @@
for(int j = 0; j < 4; ++j) {
if(incoming[j] != 0) {
if(incoming[j] == -1) {
- //std::cout << "case4: " << i << " " << j << std::endl;
+ //std::cout << "case4: " << i << " " << j << "\n";
//pass through solid on bottom
if(i == 3) {
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
if(j == 3) {
returnValue = tails[i];
returnCount = 1;
@@ -1483,7 +1483,7 @@
if(counts[i] != 0) {
for(int j = i+1; j < 4; ++j) {
if(counts[j] != 0) {
- //std::cout << "case5: " << i << " " << j << std::endl;
+ //std::cout << "case5: " << i << " " << j << "\n";
//we are ending a hole and may potentially close a figure and have to handle the hole
tails[i]->pushPoint(point);
verticalPairOut.first = tails[i];
@@ -1511,7 +1511,7 @@
if(incoming[i] != 0) {
for(int j = i+1; j < 4; ++j) {
if(incoming[j] != 0) {
- //std::cout << "case6: " << i << " " << j << std::endl;
+ //std::cout << "case6: " << i << " " << j << "\n";
//we are beginning a empty space
if(verticalPair.first == 0) {
getVerticalPair_(verticalPair, previter);
@@ -1523,12 +1523,12 @@
} else {
std::pair<ActiveTail45*, ActiveTail45*> tailPair =
ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.second));
verticalPairOut.second = tailPair.first;
verticalPairOut.first = verticalPair.first;
}
- //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
+ //std::cout << "new element " << i-1 << " " << incoming[i] << "\n";
elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), verticalPair.second));
incoming[i] = 0;
incoming[j] = 0;
@@ -1578,7 +1578,7 @@
//std::cout << "loop2\n";
elementIters.push_back(iter);
int index = iter->first.rise + 1;
- //std::cout << index << " " << iter->first.count << std::endl;
+ //std::cout << index << " " << iter->first.count << "\n";
counts[index] = iter->first.count;
tails[index] = iter->second;
++iter;
@@ -1670,9 +1670,9 @@
data.push_back(Vertex45(Point(10, 10), 0, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1694,9 +1694,9 @@
data.push_back(Vertex45(Point(10, 20), 1, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1718,9 +1718,9 @@
data.push_back(Vertex45(Point(20, 10), 0, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1744,9 +1744,9 @@
data.push_back(Vertex45(Point(20, 20), 2, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1770,9 +1770,9 @@
data.push_back(Vertex45(Point(20, -10), 2, -1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1803,9 +1803,9 @@
data.push_back(Vertex45(Point(3, 2), 0, -1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1837,9 +1837,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1901,9 +1901,9 @@
data.push_back(Vertex45(Point(12, 8), -1, 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -1935,9 +1935,9 @@
polygon_sort(result.begin(), result.end());
pf.scan(polys, result.begin(), result.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -2007,9 +2007,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -2079,9 +2079,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
@@ -2123,9 +2123,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon tiling\n";
return true;
Modified: branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -442,8 +442,8 @@
y_den = (dx1 * dy2 - dx2 * dy1);
x = x_num / x_den;
y = y_num / y_den;
- //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << std::endl;
- //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << std::endl;
+ //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << "\n";
+ //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << "\n";
//Unit exp_x = compute_x_intercept<at>(x11, x21, y11, y21, dy1, dy2, dx1, dx2);
//Unit exp_y = compute_x_intercept<at>(y11, y21, x11, x21, dx1, dx2, dy1, dy2);
if(round_closest) {
@@ -460,10 +460,10 @@
if(is_horizontal(he2))
y_unit = he2.first.y();
//if(x != exp_x || y != exp_y)
- // std::cout << exp_x << " " << exp_y << " " << x << " " << y << std::endl;
+ // std::cout << exp_x << " " << exp_y << " " << x << " " << y << "\n";
//Unit y1 = evalAtXforY(exp_x, he1.first, he1.second);
//Unit y2 = evalAtXforY(exp_x, he2.first, he2.second);
- //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << std::endl;
+ //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << "\n";
Point result(x_unit, y_unit);
if(!projected && !contains(rect1, result, true)) return false;
if(!projected && !contains(rect2, result, true)) return false;
@@ -554,9 +554,9 @@
y_den = (dx1 * dy2 - dx2 * dy1);
x = x_num / x_den;
y = y_num / y_den;
- //std::cout << x << " " << y << std::endl;
- //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << std::endl;
- //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << std::endl;
+ //std::cout << x << " " << y << "\n";
+ //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << "\n";
+ //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << "\n";
//Unit exp_x = compute_x_intercept<at>(x11, x21, y11, y21, dy1, dy2, dx1, dx2);
//Unit exp_y = compute_x_intercept<at>(y11, y21, x11, x21, dx1, dx2, dy1, dy2);
if(round_closest) {
@@ -573,10 +573,10 @@
if(is_horizontal(he2))
y_unit = he2.first.y();
//if(x != exp_x || y != exp_y)
- // std::cout << exp_x << " " << exp_y << " " << x << " " << y << std::endl;
+ // std::cout << exp_x << " " << exp_y << " " << x << " " << y << "\n";
//Unit y1 = evalAtXforY(exp_x, he1.first, he1.second);
//Unit y2 = evalAtXforY(exp_x, he2.first, he2.second);
- //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << std::endl;
+ //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << "\n";
Point result(x_unit, y_unit);
if(!contains(rect1, result, true)) return false;
if(!contains(rect2, result, true)) return false;
@@ -644,8 +644,8 @@
high_precision y_den = (dx1 * dy2 - dx2 * dy1);
high_precision x = x_num / x_den;
high_precision y = y_num / y_den;
- //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << std::endl;
- //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << std::endl;
+ //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << "\n";
+ //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << "\n";
//Unit exp_x = compute_x_intercept<at>(x11, x21, y11, y21, dy1, dy2, dx1, dx2);
//Unit exp_y = compute_x_intercept<at>(y11, y21, x11, x21, dx1, dx2, dy1, dy2);
Unit x_unit = convert_high_precision_type<Unit>(x);
@@ -658,10 +658,10 @@
if(is_horizontal(he2))
y_unit = he2.first.y();
//if(x != exp_x || y != exp_y)
- // std::cout << exp_x << " " << exp_y << " " << x << " " << y << std::endl;
+ // std::cout << exp_x << " " << exp_y << " " << x << " " << y << "\n";
//Unit y1 = evalAtXforY(exp_x, he1.first, he1.second);
//Unit y2 = evalAtXforY(exp_x, he2.first, he2.second);
- //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << std::endl;
+ //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << "\n";
Point result(x_unit, y_unit);
if(!contains(rect1, result, true)) return false;
if(!contains(rect2, result, true)) return false;
@@ -1121,21 +1121,21 @@
typename PolyLineArbitraryByConcept<Unit, typename geometry_concept<typename cT::value_type>::type>::type polyData(at1);
//poly_line_arbitrary_polygon_data polyData(at1);
//std::cout << "test2\n";
- //std::cout << poly << std::endl;
+ //std::cout << poly << "\n";
//std::cout << "test3\n";
typedef typename cT::value_type result_type;
typedef typename geometry_concept<result_type>::type result_concept;
output.push_back(result_type());
assign(output.back(), polyData);
//std::cout << "test4\n";
- //std::cout << "delete " << at1->otherTailp_ << std::endl;
+ //std::cout << "delete " << at1->otherTailp_ << "\n";
//at1->print();
//at1->otherTailp_->print();
delete at1->otherTailp_;
//at1->print();
//at1->otherTailp_->print();
//std::cout << "test5\n";
- //std::cout << "delete " << at1 << std::endl;
+ //std::cout << "delete " << at1 << "\n";
delete at1;
//std::cout << "test6\n";
return 0;
@@ -1154,7 +1154,7 @@
inline void destroyContents() {
if(otherTailp_) {
- //std::cout << "delete p " << tailp_ << std::endl;
+ //std::cout << "delete p " << tailp_ << "\n";
if(tailp_) delete tailp_;
tailp_ = 0;
otherTailp_->otherTailp_ = 0;
@@ -1162,7 +1162,7 @@
otherTailp_ = 0;
}
for(typename std::list<active_tail_arbitrary*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
- //std::cout << "delete p " << (*itr) << std::endl;
+ //std::cout << "delete p " << (*itr) << "\n";
if(*itr) {
if((*itr)->otherTailp_) {
delete (*itr)->otherTailp_;
@@ -1176,7 +1176,7 @@
}
inline void print() {
- //std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
+ //std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << "\n";
}
static inline std::pair<active_tail_arbitrary*, active_tail_arbitrary*> createActiveTailsAsPair(Point point, bool solid,
@@ -1356,12 +1356,12 @@
while(inputBegin != inputEnd) {
//std::cout << "2\n";
x_ = (*inputBegin).pt.get(HORIZONTAL);
- //std::cout << "SCAN FORMATION " << x_ << std::endl;
- //std::cout << "x_ = " << x_ << std::endl;
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "SCAN FORMATION " << x_ << "\n";
+ //std::cout << "x_ = " << x_ << "\n";
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
inputBegin = processEvent_(output, inputBegin, inputEnd);
}
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
}
protected:
@@ -1369,7 +1369,7 @@
template <class cT, class cT2>
inline std::pair<std::pair<Point, int>, active_tail_arbitrary*> processPoint_(cT& output, cT2& elements, Point point,
incoming_count& counts_from_scanline, vertex_arbitrary_count& incoming_count) {
- //std::cout << "\nAT POINT: " << point << std::endl;
+ //std::cout << "\nAT POINT: " << point << "\n";
//join any closing solid corners
std::vector<int> counts;
std::vector<int> incoming;
@@ -1401,25 +1401,25 @@
have_vertical_tail_from_below = true;
}
//assert size = size_less_1 + 1
- //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << std::endl;
+ //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << "\n";
// for(std::size_t i = 0; i < counts.size(); ++i) {
// std::cout << counts_from_scanline[i].first.first.first.get(HORIZONTAL) << ",";
// std::cout << counts_from_scanline[i].first.first.first.get(VERTICAL) << " ";
// std::cout << counts_from_scanline[i].first.first.second.get(HORIZONTAL) << ",";
// std::cout << counts_from_scanline[i].first.first.second.get(VERTICAL) << ":";
// std::cout << counts_from_scanline[i].first.second << " ";
- // } std::cout << std::endl;
+ // } std::cout << "\n";
// print(incoming_count);
{
for(int i = 0; i < c_size_less_1; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] == -1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < c_size; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(counts[j]) {
if(counts[j] == 1) {
- //std::cout << "case1: " << i << " " << j << std::endl;
+ //std::cout << "case1: " << i << " " << j << "\n";
//if a figure is closed it will be written out by this function to output
active_tail_arbitrary::joinChains(point, tails[i], tails[j], true, output);
counts[i] = 0;
@@ -1437,15 +1437,15 @@
//std::cout << "checking case2\n";
{
for(int i = 0; i < i_size_less_1; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(incoming[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < i_size; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(incoming[j]) {
- //std::cout << incoming[j] << std::endl;
+ //std::cout << incoming[j] << "\n";
if(incoming[j] == -1) {
- //std::cout << "case2: " << i << " " << j << std::endl;
+ //std::cout << "case2: " << i << " " << j << "\n";
//std::cout << "creating active tail pair\n";
std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair =
active_tail_arbitrary::createActiveTailsAsPair(point, true, 0, fractureHoles_ != 0);
@@ -1457,14 +1457,14 @@
returnCount.first = point;
returnCount.second = 1;
} else {
- //std::cout << "new element " << j-1 << " " << -1 << std::endl;
- //std::cout << point << " " << incoming_count[j].first << std::endl;
+ //std::cout << "new element " << j-1 << " " << -1 << "\n";
+ //std::cout << point << " " << incoming_count[j].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[j].first, -1), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << 1 << std::endl;
- //std::cout << point << " " << incoming_count[i].first << std::endl;
+ //std::cout << "new element " << i-1 << " " << 1 << "\n";
+ //std::cout << point << " " << incoming_count[i].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[i].first, 1), tailPair.second));
@@ -1484,14 +1484,14 @@
{
//std::cout << "checking case 3\n";
for(int i = 0; i < c_size; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] != 0) {
if(counts[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i_size_less_1; j >= 0; --j) {
if(incoming[j] != 0) {
if(incoming[j] == 1) {
- //std::cout << "case3: " << i << " " << j << std::endl;
+ //std::cout << "case3: " << i << " " << j << "\n";
//tails[i]->print();
//pass through solid on top
tails[i]->pushPoint(point);
@@ -1521,13 +1521,13 @@
//find pass through with solid on bottom
{
for(int i = c_size_less_1; i >= 0; --i) {
- //std::cout << "i = " << i << " with count " << counts[i] << std::endl;
+ //std::cout << "i = " << i << " with count " << counts[i] << "\n";
if(counts[i] != 0) {
if(counts[i] == -1) {
for(int j = 0; j < i_size; ++j) {
if(incoming[j] != 0) {
if(incoming[j] == -1) {
- //std::cout << "case4: " << i << " " << j << std::endl;
+ //std::cout << "case4: " << i << " " << j << "\n";
//pass through solid on bottom
tails[i]->pushPoint(point);
if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
@@ -1535,8 +1535,8 @@
returnCount.first = point;
returnCount.second = 1;
} else {
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
- //std::cout << point << " " << incoming_count[j].first << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
+ //std::cout << point << " " << incoming_count[j].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[j].first, incoming[j]), tails[i]));
@@ -1561,11 +1561,11 @@
if(counts[i] != 0) {
for(int j = i+1; j < c_size; ++j) {
if(counts[j] != 0) {
- //std::cout << "case5: " << i << " " << j << std::endl;
+ //std::cout << "case5: " << i << " " << j << "\n";
//we are ending a hole and may potentially close a figure and have to handle the hole
returnValue = active_tail_arbitrary::joinChains(point, tails[i], tails[j], false, output);
if(returnValue) returnCount.first = point;
- //std::cout << returnValue << std::endl;
+ //std::cout << returnValue << "\n";
tails[i] = 0;
tails[j] = 0;
counts[i] = 0;
@@ -1583,7 +1583,7 @@
if(incoming[i] != 0) {
for(int j = i+1; j < i_size; ++j) {
if(incoming[j] != 0) {
- //std::cout << "case6: " << i << " " << j << std::endl;
+ //std::cout << "case6: " << i << " " << j << "\n";
//we are beginning a empty space
active_tail_arbitrary* holep = 0;
//if(c_size && counts[c_size_less_1] == 0 &&
@@ -1596,20 +1596,20 @@
std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair =
active_tail_arbitrary::createActiveTailsAsPair(point, false, holep, fractureHoles_ != 0);
if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
- //std::cout << "vertical element " << point << std::endl;
+ //std::cout << "vertical element " << point << "\n";
returnValue = tailPair.first;
returnCount.first = point;
//returnCount = incoming_count[j];
returnCount.second = -1;
} else {
- //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
- //std::cout << point << " " << incoming_count[j].first << std::endl;
+ //std::cout << "new element " << j-1 << " " << incoming[j] << "\n";
+ //std::cout << point << " " << incoming_count[j].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[j].first, incoming[j]), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
- //std::cout << point << " " << incoming_count[i].first << std::endl;
+ //std::cout << "new element " << i-1 << " " << incoming[i] << "\n";
+ //std::cout << point << " " << incoming_count[i].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[i].first, incoming[i]), tailPair.second));
@@ -1639,13 +1639,13 @@
//std::cout << count[i].first.get(HORIZONTAL) << ",";
//std::cout << count[i].first.get(VERTICAL) << ":";
//std::cout << count[i].second << " ";
- } //std::cout << std::endl;
+ } //std::cout << "\n";
}
static inline void print(const scanline_data& data) {
for(typename scanline_data::const_iterator itr = data.begin(); itr != data.end(); ++itr){
//std::cout << itr->first.pt << ", " << itr->first.other_pt << "; ";
- } //std::cout << std::endl;
+ } //std::cout << "\n";
}
template <class cT, class iT>
@@ -1664,16 +1664,16 @@
while(currentIter != inputEnd && currentIter->pt.get(HORIZONTAL) == x_) {
//std::cout << "loop\n";
Unit currentY = (*currentIter).pt.get(VERTICAL);
- //std::cout << "current Y " << currentY << std::endl;
- //std::cout << "scanline size " << scanData_.size() << std::endl;
+ //std::cout << "current Y " << currentY << "\n";
+ //std::cout << "scanline size " << scanData_.size() << "\n";
//print(scanData_);
iterator iter = lookUp_(currentY);
- //std::cout << "found element in scanline " << (iter != scanData_.end()) << std::endl;
+ //std::cout << "found element in scanline " << (iter != scanData_.end()) << "\n";
//int counts[4] = {0, 0, 0, 0};
incoming_count counts_from_scanline;
//std::cout << "finding elements in tree\n";
//if(iter != scanData_.end())
- // std::cout << "first iter y is " << iter->first.evalAtX(x_) << std::endl;
+ // std::cout << "first iter y is " << iter->first.evalAtX(x_) << "\n";
while(iter != scanData_.end() &&
((iter->first.pt.x() == x_ && iter->first.pt.y() == currentY) ||
(iter->first.other_pt.x() == x_ && iter->first.other_pt.y() == currentY))) {
@@ -1688,7 +1688,7 @@
++iter;
}
Point currentPoint(x_, currentY);
- //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << std::endl;
+ //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << "\n";
sort_incoming_count(counts_from_scanline, currentPoint);
vertex_arbitrary_count incoming;
@@ -1702,9 +1702,9 @@
currentIter->pt.get(HORIZONTAL) == x_);
//print(incoming);
sort_vertex_arbitrary_count(incoming, currentPoint);
- //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << std::endl;
+ //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << "\n";
//print(incoming);
- //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+ //std::cout << "incoming counts from input size " << incoming.size() << "\n";
//compact_vertex_arbitrary_count(currentPoint, incoming);
vertex_arbitrary_count tmp;
tmp.reserve(incoming.size());
@@ -1714,13 +1714,13 @@
}
}
incoming.swap(tmp);
- //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+ //std::cout << "incoming counts from input size " << incoming.size() << "\n";
//now counts_from_scanline has the data from the left and
//incoming has the data from the right at this point
//cancel out any end points
if(verticalTail) {
//std::cout << "adding vertical tail to counts from scanline\n";
- //std::cout << -verticalCount.second << std::endl;
+ //std::cout << -verticalCount.second << "\n";
counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
(std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(verticalCount.first,
currentPoint),
@@ -1737,7 +1737,7 @@
verticalTail = result.second;
//if(verticalTail) {
// std::cout << "have vertical tail\n";
- // std::cout << verticalCount.second << std::endl;
+ // std::cout << verticalCount.second << "\n";
//}
if(verticalTail && !(verticalCount.second)) {
//we got a hole out of the point we just processed
@@ -1794,7 +1794,7 @@
inline iterator lookUp_(Unit y){
//if just before then we need to look from 1 not -1
- //std::cout << "just before " << justBefore_ << std::endl;
+ //std::cout << "just before " << justBefore_ << "\n";
return scanData_.lower_bound(vertex_half_edge(Point(x_, y), Point(x_, y+1), 0));
}
@@ -1816,9 +1816,9 @@
data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1840,9 +1840,9 @@
data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1864,9 +1864,9 @@
data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1910,14 +1910,14 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
pf2.scan(polys2, data.begin(), data.end());
- stdcout << "result size: " << polys2.size() << std::endl;
+ stdcout << "result size: " << polys2.size() << "\n";
for(std::size_t i = 0; i < polys2.size(); ++i) {
- stdcout << polys2[i] << std::endl;
+ stdcout << polys2[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1957,9 +1957,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -1997,9 +1997,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -2037,9 +2037,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -2065,9 +2065,9 @@
data.push_back(vertex_half_edge(Point(0, 2), Point(-1, 4), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing polygon formation\n";
return true;
@@ -2281,12 +2281,12 @@
while(inputBegin != inputEnd) {
//std::cout << "2\n";
polygon_arbitrary_formation<Unit>::x_ = (*inputBegin).pt.get(HORIZONTAL);
- //std::cout << "SCAN FORMATION " << x_ << std::endl;
- //std::cout << "x_ = " << x_ << std::endl;
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "SCAN FORMATION " << x_ << "\n";
+ //std::cout << "x_ = " << x_ << "\n";
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
inputBegin = processEvent_(output, inputBegin, inputEnd);
}
- //std::cout << "scan line size: " << scanData_.size() << std::endl;
+ //std::cout << "scan line size: " << scanData_.size() << "\n";
}
private:
@@ -2311,7 +2311,7 @@
std::pair<active_tail_arbitrary*, active_tail_arbitrary*>& verticalPair,
iterator previter, Point point, incoming_count& counts_from_scanline,
vertex_arbitrary_count& incoming_count) {
- //std::cout << "\nAT POINT: " << point << std::endl;
+ //std::cout << "\nAT POINT: " << point << "\n";
//join any closing solid corners
std::vector<int> counts;
std::vector<int> incoming;
@@ -2346,25 +2346,25 @@
have_vertical_tail_from_below = true;
}
//assert size = size_less_1 + 1
- //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << std::endl;
+ //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << "\n";
// for(std::size_t i = 0; i < counts.size(); ++i) {
// std::cout << counts_from_scanline[i].first.first.first.get(HORIZONTAL) << ",";
// std::cout << counts_from_scanline[i].first.first.first.get(VERTICAL) << " ";
// std::cout << counts_from_scanline[i].first.first.second.get(HORIZONTAL) << ",";
// std::cout << counts_from_scanline[i].first.first.second.get(VERTICAL) << ":";
// std::cout << counts_from_scanline[i].first.second << " ";
- // } std::cout << std::endl;
+ // } std::cout << "\n";
// print(incoming_count);
{
for(int i = 0; i < c_size_less_1; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] == -1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < c_size; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(counts[j]) {
if(counts[j] == 1) {
- //std::cout << "case1: " << i << " " << j << std::endl;
+ //std::cout << "case1: " << i << " " << j << "\n";
//if a figure is closed it will be written out by this function to output
active_tail_arbitrary::joinChains(point, tails[i], tails[j], true, output);
counts[i] = 0;
@@ -2382,15 +2382,15 @@
//std::cout << "checking case2\n";
{
for(int i = 0; i < i_size_less_1; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(incoming[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i + 1; j < i_size; ++j) {
- //std::cout << j << std::endl;
+ //std::cout << j << "\n";
if(incoming[j]) {
- //std::cout << incoming[j] << std::endl;
+ //std::cout << incoming[j] << "\n";
if(incoming[j] == -1) {
- //std::cout << "case2: " << i << " " << j << std::endl;
+ //std::cout << "case2: " << i << " " << j << "\n";
//std::cout << "creating active tail pair\n";
std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair =
active_tail_arbitrary::createActiveTailsAsPair(point, true, 0, polygon_arbitrary_formation<Unit>::fractureHoles_ != 0);
@@ -2402,14 +2402,14 @@
returnCount.first = point;
returnCount.second = 1;
} else {
- //std::cout << "new element " << j-1 << " " << -1 << std::endl;
- //std::cout << point << " " << incoming_count[j].first << std::endl;
+ //std::cout << "new element " << j-1 << " " << -1 << "\n";
+ //std::cout << point << " " << incoming_count[j].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[j].first, -1), tailPair.first));
}
- //std::cout << "new element " << i-1 << " " << 1 << std::endl;
- //std::cout << point << " " << incoming_count[i].first << std::endl;
+ //std::cout << "new element " << i-1 << " " << 1 << "\n";
+ //std::cout << point << " " << incoming_count[i].first << "\n";
elements.push_back(std::pair<vertex_half_edge,
active_tail_arbitrary*>(vertex_half_edge(point,
incoming_count[i].first, 1), tailPair.second));
@@ -2429,14 +2429,14 @@
{
//std::cout << "checking case 3\n";
for(int i = 0; i < c_size; ++i) {
- //std::cout << i << std::endl;
+ //std::cout << i << "\n";
if(counts[i] != 0) {
if(counts[i] == 1) {
//std::cout << "fixed i\n";
for(int j = i_size_less_1; j >= 0; --j) {
if(incoming[j] != 0) {
if(incoming[j] == 1) {
- //std::cout << "case3: " << i << " " << j << std::endl;
+ //std::cout << "case3: " << i << " " << j << "\n";
//tails[i]->print();
//pass through solid on top
tails[i]->pushPoint(point);
@@ -2470,13 +2470,13 @@
//find pass through with solid on bottom
{
for(int i = c_size_less_1; i >= 0; --i) {
- //std::cout << "i = " << i << " with count " << counts[i] << std::endl;
+ //std::cout << "i = " << i << " with count " << counts[i] << "\n";
if(counts[i] != 0) {
if(counts[i] == -1) {
for(int j = 0; j < i_size; ++j) {
if(incoming[j] != 0) {
if(incoming[j] == -1) {
- //std::cout << "case4: " << i << " " << j << std::endl;
+ //std::cout << "case4: " << i << " " << j << "\n";
//pass through solid on bottom
//if count from scanline is vertical
@@ -2536,7 +2536,7 @@
if(counts[i] != 0) {
for(int j = i+1; j < c_size; ++j) {
if(counts[j] != 0) {
- //std::cout << "case5: " << i << " " << j << std::endl;
+ //std::cout << "case5: " << i << " " << j << "\n";
//we are ending a hole and may potentially close a figure and have to handle the hole
tails[i]->pushPoint(point);
verticalPairOut.first = tails[i];
@@ -2569,7 +2569,7 @@
if(incoming[i] != 0) {
for(int j = i+1; j < i_size; ++j) {
if(incoming[j] != 0) {
- //std::cout << "case6: " << i << " " << j << std::endl;
+ //std::cout << "case6: " << i << " " << j << "\n";
//we are beginning a empty space
if(verticalPair.first == 0) {
getVerticalPair_(verticalPair, previter);
@@ -2619,13 +2619,13 @@
//std::cout << count[i].first.get(HORIZONTAL) << ",";
//std::cout << count[i].first.get(VERTICAL) << ":";
//std::cout << count[i].second << " ";
- } //std::cout << std::endl;
+ } //std::cout << "\n";
}
static inline void print(const scanline_data& data) {
for(typename scanline_data::const_iterator itr = data.begin(); itr != data.end(); ++itr){
//std::cout << itr->first.pt << ", " << itr->first.other_pt << "; ";
- } //std::cout << std::endl;
+ } //std::cout << "\n";
}
template <class cT, class iT>
@@ -2645,16 +2645,16 @@
while(currentIter != inputEnd && currentIter->pt.get(HORIZONTAL) == polygon_arbitrary_formation<Unit>::x_) {
//std::cout << "loop\n";
Unit currentY = (*currentIter).pt.get(VERTICAL);
- //std::cout << "current Y " << currentY << std::endl;
- //std::cout << "scanline size " << scanData_.size() << std::endl;
+ //std::cout << "current Y " << currentY << "\n";
+ //std::cout << "scanline size " << scanData_.size() << "\n";
//print(scanData_);
iterator iter = this->lookUp_(currentY);
- //std::cout << "found element in scanline " << (iter != scanData_.end()) << std::endl;
+ //std::cout << "found element in scanline " << (iter != scanData_.end()) << "\n";
//int counts[4] = {0, 0, 0, 0};
incoming_count counts_from_scanline;
//std::cout << "finding elements in tree\n";
//if(iter != scanData_.end())
- // std::cout << "first iter y is " << iter->first.evalAtX(x_) << std::endl;
+ // std::cout << "first iter y is " << iter->first.evalAtX(x_) << "\n";
iterator previter = iter;
if(previter != polygon_arbitrary_formation<Unit>::scanData_.end() &&
previter->first.evalAtX(polygon_arbitrary_formation<Unit>::x_) >= currentY &&
@@ -2674,7 +2674,7 @@
++iter;
}
Point currentPoint(polygon_arbitrary_formation<Unit>::x_, currentY);
- //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << std::endl;
+ //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << "\n";
this->sort_incoming_count(counts_from_scanline, currentPoint);
vertex_arbitrary_count incoming;
@@ -2688,9 +2688,9 @@
currentIter->pt.get(HORIZONTAL) == polygon_arbitrary_formation<Unit>::x_);
//print(incoming);
this->sort_vertex_arbitrary_count(incoming, currentPoint);
- //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << std::endl;
+ //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << "\n";
//print(incoming);
- //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+ //std::cout << "incoming counts from input size " << incoming.size() << "\n";
//compact_vertex_arbitrary_count(currentPoint, incoming);
vertex_arbitrary_count tmp;
tmp.reserve(incoming.size());
@@ -2700,13 +2700,13 @@
}
}
incoming.swap(tmp);
- //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+ //std::cout << "incoming counts from input size " << incoming.size() << "\n";
//now counts_from_scanline has the data from the left and
//incoming has the data from the right at this point
//cancel out any end points
if(verticalTail) {
//std::cout << "adding vertical tail to counts from scanline\n";
- //std::cout << -verticalCount.second << std::endl;
+ //std::cout << -verticalCount.second << "\n";
counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
(std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(verticalCount.first,
currentPoint),
@@ -2771,9 +2771,9 @@
data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing trapezoid formation\n";
return true;
@@ -2794,9 +2794,9 @@
data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing trapezoid formation\n";
return true;
@@ -2817,9 +2817,9 @@
data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing trapezoid formation\n";
return true;
@@ -2862,14 +2862,14 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
//pf2.scan(polys2, data.begin(), data.end());
- //stdcout << "result size: " << polys2.size() << std::endl;
+ //stdcout << "result size: " << polys2.size() << "\n";
//for(std::size_t i = 0; i < polys2.size(); ++i) {
- // stdcout << polys2[i] << std::endl;
+ // stdcout << polys2[i] << "\n";
//}
stdcout << "done testing trapezoid formation\n";
return true;
@@ -2909,9 +2909,9 @@
polygon_sort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end());
- stdcout << "result size: " << polys.size() << std::endl;
+ stdcout << "result size: " << polys.size() << "\n";
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
stdcout << "done testing trapezoid formation\n";
return true;
Modified: branches/release/boost/polygon/detail/scan_arbitrary.hpp
==============================================================================
--- branches/release/boost/polygon/detail/scan_arbitrary.hpp (original)
+++ branches/release/boost/polygon/detail/scan_arbitrary.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -269,11 +269,11 @@
// for(typename std::set<Point>::iterator itr = intersection_points[offenders.first].begin();
// itr != intersection_points[offenders.first].end(); ++itr) {
// std::cout << (*itr).x() << " " << (*itr).y() << " ";
-// } std::cout << std::endl;
+// } std::cout << "\n";
// for(typename std::set<Point>::iterator itr = intersection_points[offenders.second].begin();
// itr != intersection_points[offenders.second].end(); ++itr) {
// std::cout << (*itr).x() << " " << (*itr).y() << " ";
-// } std::cout << std::endl;
+// } std::cout << "\n";
// exit(1);
// }
}
@@ -307,7 +307,7 @@
if(scanline_base<Unit>::intersects(he1, he2)) {
offenders.first = id1;
offenders.second = id2;
- //std::cout << he1.first.x() << " " << he1.first.y() << " " << he1.second.x() << " " << he1.second.y() << " " << he2.first.x() << " " << he2.first.y() << " " << he2.second.x() << " " << he2.second.y() << std::endl;
+ //std::cout << he1.first.x() << " " << he1.first.y() << " " << he1.second.x() << " " << he1.second.y() << " " << he2.first.x() << " " << he2.first.y() << " " << he2.second.x() << " " << he2.second.y() << "\n";
return false;
}
}
@@ -693,7 +693,7 @@
}
edges.clear();
validate_scan(edges, input.begin(), input.end());
- stdcout << edges.size() << std::endl;
+ stdcout << edges.size() << "\n";
if(!verify_scan(result, edges.begin(), edges.end())) {
stdcout << "s fail5 3 " << result.first << " " << result.second << "\n";
return false;
@@ -876,7 +876,7 @@
for(std::size_t i = 0; i < vec.size(); ++ i) {
// print(vec[i]);
}
- //std::cout << std::endl;
+ //std::cout << "\n";
}
template <typename stream_type>
@@ -1012,7 +1012,7 @@
void write_out(result_type& result, result_functor rf, const half_edge& he,
const property_map& pm_left, const property_map& pm_right) {
//std::cout << "write out ";
- //std::cout << he.first << ", " << he.second << std::endl;
+ //std::cout << he.first << ", " << he.second << "\n";
property_set ps_left, ps_right;
set_unique_property(ps_left, pm_left);
set_unique_property(ps_right, pm_right);
@@ -1230,7 +1230,7 @@
// for(std::size_t i = 0; i < mp.size(); ++i) {
// std::cout << mp[i].first << ":" << mp[i].second << " ";
// } std::cout << ") ";
- // } std::cout << std::endl;
+ // } std::cout << "\n";
//}
static inline void merge_property_maps(property_map& mp, const property_map& mp2) {
@@ -1338,7 +1338,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1)));
@@ -1350,7 +1350,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
@@ -1366,7 +1366,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
@@ -1382,7 +1382,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
@@ -1398,7 +1398,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
@@ -1414,7 +1414,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
@@ -1438,7 +1438,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
input.clear();
result.clear();
input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1))); //a
@@ -1458,7 +1458,7 @@
stdcout << "scanned\n";
for(std::size_t i = 0; i < result.size(); ++i) {
stdcout << result[i].first.first << ", " << result[i].first.second << "; ";
- } stdcout << std::endl;
+ } stdcout << "\n";
return true;
}
@@ -1568,7 +1568,7 @@
}
if(!line_intersection<Unit>::verify_scan(offenders, lines.begin(), lines.end())) {
//stdcout << "Intersection failed!\n";
- //stdcout << offenders.first << " " << offenders.second << std::endl;
+ //stdcout << offenders.first << " " << offenders.second << "\n";
return false;
}
std::vector<Point> pts;
@@ -1790,7 +1790,7 @@
yh(rect, 11);
si.insert(rect, 333);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
Point pts[4] = {Point(0, 0), Point(10,-3), Point(13, 8), Point(0, 0) };
polygon_data<Unit> poly;
@@ -1798,25 +1798,25 @@
poly.set(pts, pts+3);
si2.insert(poly, 444);
si2.sort_property_merge_data();
- print(stdcout, si2.pmd) << std::endl;
+ print(stdcout, si2.pmd) << "\n";
property_merge si3;
poly.set(pts, pts+4);
si3.insert(poly, 444);
si3.sort_property_merge_data();
- stdcout << (si2.pmd == si3.pmd) << std::endl;
+ stdcout << (si2.pmd == si3.pmd) << "\n";
std::reverse(pts, pts+4);
property_merge si4;
poly.set(pts, pts+4);
si4.insert(poly, 444);
si4.sort_property_merge_data();
- print(stdcout, si4.pmd) << std::endl;
- stdcout << (si2.pmd == si4.pmd) << std::endl;
+ print(stdcout, si4.pmd) << "\n";
+ stdcout << (si2.pmd == si4.pmd) << "\n";
std::reverse(pts, pts+3);
property_merge si5;
poly.set(pts, pts+4);
si5.insert(poly, 444);
si5.sort_property_merge_data();
- stdcout << (si2.pmd == si5.pmd) << std::endl;
+ stdcout << (si2.pmd == si5.pmd) << "\n";
return true;
}
@@ -1833,7 +1833,7 @@
si.insert(rect, 333);
std::map<std::set<property_type>, polygon_set_data<Unit> > result;
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
polygon_set_data<Unit> psd = (*(result.begin())).second;
std::vector<polygon_data<Unit> > polys;
psd.get(polys);
@@ -1841,7 +1841,7 @@
stdcout << "fail merge 1\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
si.clear();
std::vector<Point> pts;
pts.push_back(Point(0, 0));
@@ -1858,9 +1858,9 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() != 1) {
@@ -1884,9 +1884,9 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() != 1) {
@@ -1910,16 +1910,16 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() != 1) {
stdcout << "fail merge 4\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
stdcout << "Polygon { -4 0, -2 -3, 3 -4 } \n";
stdcout << "Polygon { -1 1, 1 -2, -4 -3 } \n";
si.clear();
@@ -1937,9 +1937,9 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() != 1) {
@@ -1963,17 +1963,17 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() != 1) {
stdcout << "fail merge 6\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
}
stdcout << "Polygon { 0 2, 3 -1, 4 1 } \n";
stdcout << "Polygon { -4 3, 3 3, 4 2 } \n";
@@ -1992,17 +1992,17 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() == 0) {
stdcout << "fail merge 7\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
}
stdcout << "Polygon { 1 -2, -1 4, 3 -2 } \n";
stdcout << "Polygon { 0 -3, 3 1, -3 -4 } \n";
@@ -2021,17 +2021,17 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() == 0) {
stdcout << "fail merge 8\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
}
stdcout << "Polygon { 2 2, 3 0, -3 4 } \n";
stdcout << "Polygon { -2 -2, 0 0, -1 -1 } \n";
@@ -2050,17 +2050,17 @@
si.insert(poly, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() == 0) {
stdcout << "fail merge 9\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
}
si.clear();
pts.clear();
@@ -2158,10 +2158,10 @@
result.clear();
si.merge(result);
si.verify1();
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
std::vector<Point> outpts;
for(typename polygon_set_data<Unit>::iterator_type itr = psd.begin();
itr != psd.end(); ++itr) {
@@ -2172,8 +2172,8 @@
for(std::size_t i = 0; i < outpts.size(); i+=2) {
if(outpts[i] != outpts[i+1]) {
stdcout << "Polygon set not a closed figure\n";
- stdcout << i << std::endl;
- stdcout << outpts[i] << " " << outpts[i+1] << std::endl;
+ stdcout << i << "\n";
+ stdcout << outpts[i] << " " << outpts[i+1] << "\n";
return 0;
}
}
@@ -2183,10 +2183,10 @@
stdcout << "fail merge 10\n";
return false;
}
- stdcout << (polys[0]) << std::endl;
+ stdcout << (polys[0]) << "\n";
}
for(unsigned int i = 0; i < 10; ++i) {
- stdcout << "random case # " << i << std::endl;
+ stdcout << "random case # " << i << "\n";
si.clear();
pts.clear();
pts.push_back(Point(rand()%9-4, rand()%9-4));
@@ -2194,7 +2194,7 @@
pts.push_back(Point(rand()%9-4, rand()%9-4));
polygon_data<Unit> poly1;
poly1.set(pts.begin(), pts.end());
- stdcout << poly1 << std::endl;
+ stdcout << poly1 << "\n";
si.insert(poly1, 444);
pts.clear();
pts.push_back(Point(rand()%9-4, rand()%9-4));
@@ -2202,14 +2202,14 @@
pts.push_back(Point(rand()%9-4, rand()%9-4));
polygon_data<Unit> poly2;
poly2.set(pts.begin(), pts.end());
- stdcout << poly2 << std::endl;
+ stdcout << poly2 << "\n";
si.insert(poly2, 444);
result.clear();
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
if(!result.empty()) {
psd = (*(result.begin())).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
polys.clear();
psd.get(polys);
if(polys.size() == 0) {
@@ -2228,13 +2228,13 @@
std::vector<polygon_data<Unit> > polys2;
psd.get(polys2);
if(!polys1.empty() || !polys2.empty()) {
- stdcout << "fail random merge " << i << std::endl;
+ stdcout << "fail random merge " << i << "\n";
return false;
}
}
}
if(!polys.empty())
- stdcout << polys.size() << ": " << (polys[0]) << std::endl;
+ stdcout << polys.size() << ": " << (polys[0]) << "\n";
}
return true;
}
@@ -2249,13 +2249,13 @@
std::vector<polygon_data<Unit> > polys90;
si.insert(rect1, 111);
si90.insert(rect1, 111);
- stdcout << rect1 << std::endl;
+ stdcout << rect1 << "\n";
si.insert(rect2, 222);
si90.insert(rect2, 222);
- stdcout << rect2 << std::endl;
+ stdcout << rect2 << "\n";
si.insert(rect3, 333);
si90.insert(rect3, 333);
- stdcout << rect3 << std::endl;
+ stdcout << rect3 << "\n";
si.merge(result);
si90.merge(result90);
if(result.size() != result90.size()) {
@@ -2277,20 +2277,20 @@
psd90.get(polys90);
if(polys.size() != polys90.size()) {
stdcout << "merge failed with polygon count mismatch\n";
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
for(std::size_t j = 0; j < polys.size(); ++j) {
- stdcout << polys[j] << std::endl;
+ stdcout << polys[j] << "\n";
}
stdcout << "reference\n";
for(std::size_t j = 0; j < polys90.size(); ++j) {
- stdcout << polys90[j] << std::endl;
+ stdcout << polys90[j] << "\n";
}
return 0;
}
bool failed = false;
for(std::size_t j = 0; j < polys.size(); ++j) {
- stdcout << polys[j] << std::endl;
- stdcout << polys90[j] << std::endl;
+ stdcout << polys[j] << "\n";
+ stdcout << polys90[j] << "\n";
#ifdef BOOST_POLYGON_ICC
#pragma warning (disable:1572)
#endif
@@ -2324,7 +2324,7 @@
property_merge_90<property_type, Unit> si90;
std::map<std::set<property_type>, polygon_90_set_data<Unit> > result90;
std::vector<polygon_data<Unit> > polys90;
- stdcout << "random case # " << i << std::endl;
+ stdcout << "random case # " << i << "\n";
set_points(rect1, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
set_points(rect2, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
set_points(rect3, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
@@ -2356,7 +2356,7 @@
si.insert(rect, 555);
std::map<std::set<property_type>, polygon_set_data<Unit> > result;
si.merge(result);
- print(stdcout, si.pmd) << std::endl;
+ print(stdcout, si.pmd) << "\n";
for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
itr != result.end(); ++itr) {
stdcout << "( ";
@@ -2365,18 +2365,18 @@
stdcout << (*set_itr) << " ";
} stdcout << ") \n";
polygon_set_data<Unit> psd = (*itr).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
std::vector<polygon_data<Unit> > polys;
psd.get(polys);
for(std::size_t i = 0; i < polys.size(); ++i) {
- stdcout << polys[i] << std::endl;
+ stdcout << polys[i] << "\n";
}
}
std::vector<Point> pts;
std::vector<polygon_data<Unit> > polys;
for(unsigned int i = 0; i < 10; ++i) {
property_merge si2;
- stdcout << "random case # " << i << std::endl;
+ stdcout << "random case # " << i << "\n";
si.clear();
pts.clear();
pts.push_back(Point(rand()%9-4, rand()%9-4));
@@ -2384,7 +2384,7 @@
pts.push_back(Point(rand()%9-4, rand()%9-4));
polygon_data<Unit> poly1;
poly1.set(pts.begin(), pts.end());
- stdcout << poly1 << std::endl;
+ stdcout << poly1 << "\n";
si.insert(poly1, 444);
si2.insert(poly1, 333);
pts.clear();
@@ -2393,7 +2393,7 @@
pts.push_back(Point(rand()%9-4, rand()%9-4));
polygon_data<Unit> poly2;
poly2.set(pts.begin(), pts.end());
- stdcout << poly2 << std::endl;
+ stdcout << poly2 << "\n";
si.insert(poly2, 444);
si2.insert(poly2, 444);
pts.clear();
@@ -2402,7 +2402,7 @@
pts.push_back(Point(rand()%9-4, rand()%9-4));
polygon_data<Unit> poly3;
poly3.set(pts.begin(), pts.end());
- stdcout << poly3 << std::endl;
+ stdcout << poly3 << "\n";
si.insert(poly3, 444);
si2.insert(poly3, 555);
result.clear();
@@ -2418,15 +2418,15 @@
stdcout << (*set_itr) << " ";
} stdcout << ") \n";
polygon_set_data<Unit> psd = (*itr).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
std::vector<polygon_data<Unit> > polys2;
psd.get(polys2);
for(std::size_t ii = 0; ii < polys2.size(); ++ii) {
- stdcout << polys2[ii] << std::endl;
+ stdcout << polys2[ii] << "\n";
}
}
stdcout << "intersected pmd\n";
- print(stdcout, si2.pmd) << std::endl;
+ print(stdcout, si2.pmd) << "\n";
stdcout << "intersected result\n";
for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
itr != result2.end(); ++itr) {
@@ -2436,11 +2436,11 @@
stdcout << (*set_itr) << " ";
} stdcout << ") \n";
polygon_set_data<Unit> psd = (*itr).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
std::vector<polygon_data<Unit> > polys2;
psd.get(polys2);
for(std::size_t ii = 0; ii < polys2.size(); ++ii) {
- stdcout << polys2[ii] << std::endl;
+ stdcout << polys2[ii] << "\n";
}
}
si.clear();
@@ -2463,11 +2463,11 @@
stdcout << (*set_itr) << " ";
} stdcout << ") \n";
polygon_set_data<Unit> psd = (*itr).second;
- stdcout << psd << std::endl;
+ stdcout << psd << "\n";
std::vector<polygon_data<Unit> > polys2;
psd.get(polys2);
for(std::size_t ii = 0; ii < polys2.size(); ++ii) {
- stdcout << polys2[ii] << std::endl;
+ stdcout << polys2[ii] << "\n";
}
}
std::vector<polygon_data<Unit> > polys2;
@@ -2475,7 +2475,7 @@
(*(result.begin())).second.get(polys);
(*(result2.begin())).second.get(polys2);
if(!(polys == polys2)) {
- stdcout << "failed intersection check # " << i << std::endl;
+ stdcout << "failed intersection check # " << i << "\n";
return false;
}
}
@@ -2660,7 +2660,7 @@
abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_OR);
psd3.get(pv);
for(std::size_t i = 0; i < pv.size(); ++i) {
- stdcout << pv[i] << std::endl;
+ stdcout << pv[i] << "\n";
}
pv.clear();
abo.clear();
@@ -2668,7 +2668,7 @@
abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_AND);
psd3.get(pv);
for(std::size_t i = 0; i < pv.size(); ++i) {
- stdcout << pv[i] << std::endl;
+ stdcout << pv[i] << "\n";
}
pv.clear();
abo.clear();
@@ -2676,7 +2676,7 @@
abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_XOR);
psd3.get(pv);
for(std::size_t i = 0; i < pv.size(); ++i) {
- stdcout << pv[i] << std::endl;
+ stdcout << pv[i] << "\n";
}
pv.clear();
abo.clear();
@@ -2684,7 +2684,7 @@
abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_NOT);
psd3.get(pv);
for(std::size_t i = 0; i < pv.size(); ++i) {
- stdcout << pv[i] << std::endl;
+ stdcout << pv[i] << "\n";
}
return true;
}
Deleted: branches/release/boost/polygon/detail/transform_detail.hpp
==============================================================================
--- branches/release/boost/polygon/detail/transform_detail.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
+++ (empty file)
@@ -1,548 +0,0 @@
-/*
- 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 BOOST_POLYGON_TRANSFORM_DETAIL_HPP
-#define BOOST_POLYGON_TRANSFORM_DETAIL_HPP
-
-namespace boost { namespace polygon{
- // inline std::ostream& operator<< (std::ostream& o, const axis_transformation& r) {
- // o << r.atr_;
- // return o;
- // }
-
- // inline std::istream& operator>> (std::istream& i, axis_transformation& r) {
- // int tmp;
- // i >> tmp;
- // r = axis_transformation((axis_transformation::ATR)tmp);
- // return i;
- // }
-
- // template <typename scale_factor_type>
- // inline std::ostream& operator<< (std::ostream& o, const anisotropic_scale_factor<scale_factor_type>& sc) {
- // o << sc.scale_[0] << BOOST_POLYGON_SEP << sc.scale_[1] << GTL_SEP << sc.scale_[2];
- // return o;
- // }
-
- // template <typename scale_factor_type>
- // inline std::istream& operator>> (std::istream& i, anisotropic_scale_factor<scale_factor_type>& sc) {
- // i >> sc.scale_[0] >> sc.scale_[1] >> sc.scale_[2];
- // return i;
- // }
-
- // template <typename coordinate_type>
- // inline std::ostream& operator<< (std::ostream& o, const transformation& tr) {
- // o << tr.atr_ << BOOST_POLYGON_SEP << tr.p_;
- // return o;
- // }
-
- // template <typename coordinate_type>
- // inline std::istream& operator>> (std::istream& i, transformation& tr) {
- // i >> tr.atr_ >> tr.p_;
- // return i;
- // }
-
-
- inline axis_transformation::axis_transformation(const orientation_3d& orient) : atr_(NULL_TRANSFORM) {
- const ATR tmp[3] = {
- UP_EAST_NORTH, //sort by x, then z, then y
- EAST_UP_NORTH, //sort by y, then z, then x
- EAST_NORTH_UP //sort by z, then y, then x
- };
- atr_ = tmp[orient.to_int()];
- }
-
- inline axis_transformation::axis_transformation(const orientation_2d& orient) : atr_(NULL_TRANSFORM) {
- const ATR tmp[3] = {
- NORTH_EAST_UP, //sort by z, then x, then y
- EAST_NORTH_UP //sort by z, then y, then x
- };
- atr_ = tmp[orient.to_int()];
- }
-
- inline axis_transformation::axis_transformation(const direction_3d& dir) : atr_(NULL_TRANSFORM) {
- const ATR tmp[6] = {
- DOWN_EAST_NORTH, //sort by -x, then z, then y
- UP_EAST_NORTH, //sort by x, then z, then y
- EAST_DOWN_NORTH, //sort by -y, then z, then x
- EAST_UP_NORTH, //sort by y, then z, then x
- EAST_NORTH_DOWN, //sort by -z, then y, then x
- EAST_NORTH_UP //sort by z, then y, then x
- };
- atr_ = tmp[dir.to_int()];
- }
-
- inline axis_transformation::axis_transformation(const direction_2d& dir) : atr_(NULL_TRANSFORM) {
- const ATR tmp[4] = {
- SOUTH_EAST_UP, //sort by z, then x, then y
- NORTH_EAST_UP, //sort by z, then x, then y
- EAST_SOUTH_UP, //sort by z, then y, then x
- EAST_NORTH_UP //sort by z, then y, then x
- };
- atr_ = tmp[dir.to_int()];
- }
-
- inline axis_transformation& axis_transformation::operator=(const axis_transformation& a) {
- atr_ = a.atr_;
- return *this;
- }
-
- inline axis_transformation& axis_transformation::operator=(const ATR& atr) {
- atr_ = atr;
- return *this;
- }
-
- inline bool axis_transformation::operator==(const axis_transformation& a) const {
- return atr_ == a.atr_;
- }
-
- inline bool axis_transformation::operator!=(const axis_transformation& a) const {
- return !(*this == a);
- }
-
- inline bool axis_transformation::operator<(const axis_transformation& a) const {
- return atr_ < a.atr_;
- }
-
- inline axis_transformation& axis_transformation::operator+=(const axis_transformation& a){
- bool abit5 = (a.atr_ & 32) != 0;
- bool abit4 = (a.atr_ & 16) != 0;
- bool abit3 = (a.atr_ & 8) != 0;
- bool abit2 = (a.atr_ & 4) != 0;
- bool abit1 = (a.atr_ & 2) != 0;
- bool abit0 = (a.atr_ & 1) != 0;
- bool bit5 = (atr_ & 32) != 0;
- bool bit4 = (atr_ & 16) != 0;
- bool bit3 = (atr_ & 8) != 0;
- bool bit2 = (atr_ & 4) != 0;
- bool bit1 = (atr_ & 2) != 0;
- bool bit0 = (atr_ & 1) != 0;
- int indexes[2][3] = {
- {
- ((int)((bit5 & bit2) | (bit4 & !bit2)) << 1) +
- (int)(bit2 & !bit5),
- ((int)((bit4 & bit2) | (bit5 & !bit2)) << 1) +
- (int)(!bit5 & !bit2),
- ((int)(!bit4 & !bit5) << 1) +
- (int)(bit5)
- },
- {
- ((int)((abit5 & abit2) | (abit4 & !abit2)) << 1) +
- (int)(abit2 & !abit5),
- ((int)((abit4 & abit2) | (abit5 & !abit2)) << 1) +
- (int)(!abit5 & !abit2),
- ((int)(!abit4 & !abit5) << 1) +
- (int)(abit5)
- }
- };
- int zero_bits[2][3] = {
- {bit0, bit1, bit3},
- {abit0, abit1, abit3}
- };
- int nbit3 = zero_bits[0][2] ^ zero_bits[1][indexes[0][2]];
- int nbit1 = zero_bits[0][1] ^ zero_bits[1][indexes[0][1]];
- int nbit0 = zero_bits[0][0] ^ zero_bits[1][indexes[0][0]];
- indexes[0][0] = indexes[1][indexes[0][0]];
- indexes[0][1] = indexes[1][indexes[0][1]];
- indexes[0][2] = indexes[1][indexes[0][2]];
- int nbit5 = (indexes[0][2] == 1);
- int nbit4 = (indexes[0][2] == 0);
- int nbit2 = (!(nbit5 | nbit4) & (bool)(indexes[0][0] & 1)) | //swap xy
- (nbit5 & ((indexes[0][0] & 2) >> 1)) | //z->y x->z
- (nbit4 & ((indexes[0][1] & 2) >> 1)); //z->x y->z
- atr_ = (ATR)((nbit5 << 5) +
- (nbit4 << 4) +
- (nbit3 << 3) +
- (nbit2 << 2) +
- (nbit1 << 1) + nbit0);
- return *this;
- }
-
- inline axis_transformation axis_transformation::operator+(const axis_transformation& a) const {
- axis_transformation retval(*this);
- return retval+=a;
- }
-
- // populate_axis_array writes the three INDIVIDUAL_AXIS values that the
- // ATR enum value of 'this' represent into axis_array
- inline void axis_transformation::populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const {
- bool bit5 = (atr_ & 32) != 0;
- bool bit4 = (atr_ & 16) != 0;
- bool bit3 = (atr_ & 8) != 0;
- bool bit2 = (atr_ & 4) != 0;
- bool bit1 = (atr_ & 2) != 0;
- bool bit0 = (atr_ & 1) != 0;
- axis_array[2] =
- (INDIVIDUAL_AXIS)((((int)(!bit4 & !bit5)) << 2) +
- ((int)(bit5) << 1) +
- bit3);
- axis_array[1] =
- (INDIVIDUAL_AXIS)((((int)((bit4 & bit2) | (bit5 & !bit2))) << 2)+
- ((int)(!bit5 & !bit2) << 1) +
- bit1);
- axis_array[0] =
- (INDIVIDUAL_AXIS)((((int)((bit5 & bit2) | (bit4 & !bit2))) << 2) +
- ((int)(bit2 & !bit5) << 1) +
- bit0);
- }
-
- // combine_axis_arrays concatenates this_array and that_array overwriting
- // the result into this_array
- inline void
- axis_transformation::combine_axis_arrays (INDIVIDUAL_AXIS this_array[],
- const INDIVIDUAL_AXIS that_array[]){
- int indexes[3] = {this_array[0] >> 1,
- this_array[1] >> 1,
- this_array[2] >> 1};
- int zero_bits[2][3] = {
- {this_array[0] & 1, this_array[1] & 1, this_array[2] & 1},
- {that_array[0] & 1, that_array[1] & 1, that_array[2] & 1}
- };
- this_array[0] = that_array[indexes[0]];
- this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] & (int)((int)PZ+(int)PY));
- this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] |
- ((int)zero_bits[0][0] ^
- (int)zero_bits[1][indexes[0]]));
- this_array[1] = that_array[indexes[1]];
- this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] & (int)((int)PZ+(int)PY));
- this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] |
- ((int)zero_bits[0][1] ^
- (int)zero_bits[1][indexes[1]]));
- this_array[2] = that_array[indexes[2]];
- this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] & (int)((int)PZ+(int)PY));
- this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] |
- ((int)zero_bits[0][2] ^
- (int)zero_bits[1][indexes[2]]));
- }
-
- // write_back_axis_array converts an array of three INDIVIDUAL_AXIS values
- // to the ATR enum value and sets 'this' to that value
- inline void axis_transformation::write_back_axis_array(const INDIVIDUAL_AXIS this_array[]) {
- int bit5 = ((int)this_array[2] & 2) != 0;
- int bit4 = !((((int)this_array[2] & 4) != 0) | (((int)this_array[2] & 2) != 0));
- int bit3 = ((int)this_array[2] & 1) != 0;
- //bit 2 is the tricky bit
- int bit2 = ((!(bit5 | bit4)) & (((int)this_array[0] & 2) != 0)) | //swap xy
- (bit5 & (((int)this_array[0] & 4) >> 2)) | //z->y x->z
- (bit4 & (((int)this_array[1] & 4) >> 2)); //z->x y->z
- int bit1 = ((int)this_array[1] & 1);
- int bit0 = ((int)this_array[0] & 1);
- atr_ = ATR((bit5 << 5) +
- (bit4 << 4) +
- (bit3 << 3) +
- (bit2 << 2) +
- (bit1 << 1) + bit0);
- }
-
- // behavior is deterministic but undefined in the case where illegal
- // combinations of directions are passed in.
- inline axis_transformation&
- axis_transformation::set_directions(const direction_2d& horizontalDir,
- const direction_2d& verticalDir){
- int bit2 = (static_cast<orientation_2d>(horizontalDir).to_int()) != 0;
- int bit1 = !(verticalDir.to_int() & 1);
- int bit0 = !(horizontalDir.to_int() & 1);
- atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
- return *this;
- }
-
- // behavior is deterministic but undefined in the case where illegal
- // combinations of directions are passed in.
- inline axis_transformation& axis_transformation::set_directions(
- const direction_3d& horizontalDir,
- const direction_3d& verticalDir,
- const direction_3d& proximalDir){
- unsigned int this_array[3] = {horizontalDir.to_int(),
- verticalDir.to_int(),
- proximalDir.to_int()};
- unsigned int bit5 = (this_array[2] & 2) != 0;
- unsigned int bit4 = !(((this_array[2] & 4) != 0) | ((this_array[2] & 2) != 0));
- unsigned int bit3 = !((this_array[2] & 1) != 0);
- //bit 2 is the tricky bit
- unsigned int bit2 = (!(bit5 | bit4) & ((this_array[0] & 2) != 0 )) | //swap xy
- (bit5 & ((this_array[0] & 4) >> 2)) | //z->y x->z
- (bit4 & ((this_array[1] & 4) >> 2)); //z->x y->z
- unsigned int bit1 = !(this_array[1] & 1);
- unsigned int bit0 = !(this_array[0] & 1);
- atr_ = ATR((bit5 << 5) | (bit4 << 4) | (bit3 << 3) | (bit2 << 2) | (bit1 << 1) | bit0);
- return *this;
- }
-
- template <typename coordinate_type_2>
- inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y) const {
- int bit2 = (atr_ & 4) != 0;
- int bit1 = (atr_ & 2) != 0;
- int bit0 = (atr_ & 1) != 0;
- x *= -((bit0 << 1) - 1);
- y *= -((bit1 << 1) - 1);
- predicated_swap(bit2 != 0,x,y);
- }
-
- template <typename coordinate_type_2>
- inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
- int bit5 = (atr_ & 32) != 0;
- int bit4 = (atr_ & 16) != 0;
- int bit3 = (atr_ & 8) != 0;
- int bit2 = (atr_ & 4) != 0;
- int bit1 = (atr_ & 2) != 0;
- int bit0 = (atr_ & 1) != 0;
- x *= -((bit0 << 1) - 1);
- y *= -((bit1 << 1) - 1);
- z *= -((bit3 << 1) - 1);
- predicated_swap(bit2 != 0, x, y);
- predicated_swap(bit5 != 0, y, z);
- predicated_swap(bit4 != 0, x, z);
- }
-
- inline axis_transformation& axis_transformation::invert_2d() {
- int bit2 = ((atr_ & 4) != 0);
- int bit1 = ((atr_ & 2) != 0);
- int bit0 = ((atr_ & 1) != 0);
- //swap bit 0 and bit 1 if bit2 is 1
- predicated_swap(bit2 != 0, bit0, bit1);
- bit1 = bit1 << 1;
- atr_ = (ATR)(atr_ & (32+16+8+4)); //mask away bit0 and bit1
- atr_ = (ATR)(atr_ | bit0 | bit1);
- return *this;
- }
-
- inline axis_transformation axis_transformation::inverse_2d() const {
- axis_transformation retval(*this);
- return retval.invert_2d();
- }
-
- inline axis_transformation& axis_transformation::invert() {
- int bit5 = ((atr_ & 32) != 0);
- int bit4 = ((atr_ & 16) != 0);
- int bit3 = ((atr_ & 8) != 0);
- int bit2 = ((atr_ & 4) != 0);
- int bit1 = ((atr_ & 2) != 0);
- int bit0 = ((atr_ & 1) != 0);
- predicated_swap(bit2 != 0, bit4, bit5);
- predicated_swap(bit4 != 0, bit0, bit3);
- predicated_swap(bit5 != 0, bit1, bit3);
- predicated_swap(bit2 != 0, bit0, bit1);
- atr_ = (ATR)((bit5 << 5) +
- (bit4 << 4) +
- (bit3 << 3) +
- (bit2 << 2) +
- (bit1 << 1) + bit0);
- return *this;
- }
-
- inline axis_transformation axis_transformation::inverse() const {
- axis_transformation retval(*this);
- return retval.invert();
- }
-
- template <typename scale_factor_type>
- inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::get(orientation_3d orient) const {
- return scale_[orient.to_int()];
- }
-
- template <typename scale_factor_type>
- inline void anisotropic_scale_factor<scale_factor_type>::set(orientation_3d orient, scale_factor_type value) {
- scale_[orient.to_int()] = value;
- }
-
- template <typename scale_factor_type>
- inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::x() const { return scale_[HORIZONTAL]; }
- template <typename scale_factor_type>
- inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::y() const { return scale_[VERTICAL]; }
- template <typename scale_factor_type>
- inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::z() const { return scale_[PROXIMAL]; }
- template <typename scale_factor_type>
- inline void anisotropic_scale_factor<scale_factor_type>::x(scale_factor_type value) { scale_[HORIZONTAL] = value; }
- template <typename scale_factor_type>
- inline void anisotropic_scale_factor<scale_factor_type>::y(scale_factor_type value) { scale_[VERTICAL] = value; }
- template <typename scale_factor_type>
- inline void anisotropic_scale_factor<scale_factor_type>::z(scale_factor_type value) { scale_[PROXIMAL] = value; }
-
- //concatenation operator (convolve scale factors)
- template <typename scale_factor_type>
- inline anisotropic_scale_factor<scale_factor_type> anisotropic_scale_factor<scale_factor_type>::operator+(const anisotropic_scale_factor<scale_factor_type>& s) const {
- anisotropic_scale_factor<scale_factor_type> retval(*this);
- return retval+=s;
- }
-
- //concatenate this with that
- template <typename scale_factor_type>
- inline const anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::operator+=(const anisotropic_scale_factor<scale_factor_type>& s){
- scale_[0] *= s.scale_[0];
- scale_[1] *= s.scale_[1];
- scale_[2] *= s.scale_[2];
- return *this;
- }
-
- //transform
- template <typename scale_factor_type>
- inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::transform(axis_transformation atr){
- direction_3d dirs[3];
- atr.get_directions(dirs[0],dirs[1],dirs[2]);
- scale_factor_type tmp[3] = {scale_[0], scale_[1], scale_[2]};
- for(int i = 0; i < 3; ++i){
- scale_[orientation_3d(dirs[i]).to_int()] = tmp[i];
- }
- return *this;
- }
-
- template <typename scale_factor_type>
- template <typename coordinate_type_2>
- inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y) const {
- x = scaling_policy<coordinate_type_2>::round((scale_factor_type)x * get(HORIZONTAL));
- y = scaling_policy<coordinate_type_2>::round((scale_factor_type)y * get(HORIZONTAL));
- }
-
- template <typename scale_factor_type>
- template <typename coordinate_type_2>
- inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
- scale(x, y);
- z = scaling_policy<coordinate_type_2>::round((scale_factor_type)z * get(HORIZONTAL));
- }
-
- template <typename scale_factor_type>
- inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::invert() {
- x(1/x());
- y(1/y());
- z(1/z());
- return *this;
- }
-
-
- template <typename coordinate_type>
- inline transformation<coordinate_type>::transformation() : atr_(), p_(0, 0, 0) {;}
-
- template <typename coordinate_type>
- inline transformation<coordinate_type>::transformation(axis_transformation atr) : atr_(atr), p_(0, 0, 0){;}
-
- template <typename coordinate_type>
- inline transformation<coordinate_type>::transformation(axis_transformation::ATR atr) : atr_(atr), p_(0, 0, 0){;}
-
- template <typename coordinate_type>
- template <typename point_type>
- inline transformation<coordinate_type>::transformation(const point_type& p) : atr_(), p_(0, 0, 0) {
- set_translation(p);
- }
-
- template <typename coordinate_type>
- template <typename point_type>
- inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& p) :
- atr_(atr), p_(0, 0, 0) {
- set_translation(p);
- }
-
- template <typename coordinate_type>
- template <typename point_type>
- inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& referencePt, const point_type& destinationPt) : atr_(), p_(0, 0, 0) {
- transformation<coordinate_type> tmp(referencePt);
- transformation<coordinate_type> rotRef(atr);
- transformation<coordinate_type> tmpInverse = tmp.inverse();
- point_type decon(referencePt);
- deconvolve(decon, destinationPt);
- transformation<coordinate_type> displacement(decon);
- tmp += rotRef;
- tmp += tmpInverse;
- tmp += displacement;
- (*this) = tmp;
- }
-
- template <typename coordinate_type>
- inline transformation<coordinate_type>::transformation(const transformation<coordinate_type>& tr) :
- atr_(tr.atr_), p_(tr.p_) {;}
-
- template <typename coordinate_type>
- inline bool transformation<coordinate_type>::operator==(const transformation<coordinate_type>& tr) const {
- return atr_ == tr.atr_ && p_ == tr.p_;
- }
-
- template <typename coordinate_type>
- inline bool transformation<coordinate_type>::operator!=(const transformation<coordinate_type>& tr) const {
- return !(*this == tr);
- }
-
- template <typename coordinate_type>
- inline bool transformation<coordinate_type>::operator<(const transformation<coordinate_type>& tr) const {
- return atr_ < tr.atr_ || (atr_ == tr.atr_ && p_ < tr.p_);
- }
-
- template <typename coordinate_type>
- inline transformation<coordinate_type> transformation<coordinate_type>::operator+(const transformation<coordinate_type>& tr) const {
- transformation<coordinate_type> retval(*this);
- return retval+=tr;
- }
-
- template <typename coordinate_type>
- inline const transformation<coordinate_type>& transformation<coordinate_type>::operator+=(const transformation<coordinate_type>& tr){
- //apply the inverse transformation of this to the translation point of that
- //and convolve it with this translation point
- coordinate_type x, y, z;
- transformation<coordinate_type> inv = inverse();
- inv.transform(x, y, z);
- p_.set(HORIZONTAL, p_.get(HORIZONTAL) + x);
- p_.set(VERTICAL, p_.get(VERTICAL) + y);
- p_.set(PROXIMAL, p_.get(PROXIMAL) + z);
- //concatenate axis transforms
- atr_ += tr.atr_;
- return *this;
- }
-
- template <typename coordinate_type>
- inline void transformation<coordinate_type>::set_axis_transformation(const axis_transformation& atr) {
- atr_ = atr;
- }
-
- template <typename coordinate_type>
- template <typename point_type>
- inline void transformation<coordinate_type>::get_translation(point_type& p) const {
- assign(p, p_);
- }
-
- template <typename coordinate_type>
- template <typename point_type>
- inline void transformation<coordinate_type>::set_translation(const point_type& p) {
- assign(p_, p);
- }
-
- template <typename coordinate_type>
- inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y) const {
- //subtract each component of new origin point
- y -= p_.get(VERTICAL);
- x -= p_.get(HORIZONTAL);
- atr_.transform(x, y);
- }
-
- template <typename coordinate_type>
- inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const {
- //subtract each component of new origin point
- z -= p_.get(PROXIMAL);
- y -= p_.get(VERTICAL);
- x -= p_.get(HORIZONTAL);
- 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
- 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);
- atr_.transform(x, y, z);
- x *= -1;
- y *= -1;
- z *= -1;
- p_ = point_3d_data<coordinate_type>(x, y, z);
- atr_.invert();
- return *this;
- }
-
- template <typename coordinate_type>
- inline transformation<coordinate_type> transformation<coordinate_type>::inverse() const {
- transformation<coordinate_type> retval(*this);
- return retval.invert();
- }
-}
-}
-#endif
Modified: branches/release/boost/polygon/interval_concept.hpp
==============================================================================
--- branches/release/boost/polygon/interval_concept.hpp (original)
+++ branches/release/boost/polygon/interval_concept.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,632 +1,935 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_concept.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_INTERVAL_CONCEPT_HPP
#define BOOST_POLYGON_INTERVAL_CONCEPT_HPP
+
#include "isotropy.hpp"
-#include "interval_data.hpp"
#include "interval_traits.hpp"
-namespace boost { namespace polygon{
- struct interval_concept {};
+namespace boost {
+namespace polygon {
- template <typename T>
- struct is_interval_concept { typedef gtl_no type; };
- template <>
- struct is_interval_concept<interval_concept> { typedef gtl_yes type; };
-
- template <typename T>
- struct is_mutable_interval_concept { typedef gtl_no type; };
- template <>
- struct is_mutable_interval_concept<interval_concept> { typedef gtl_yes type; };
-
- template <typename T, typename CT>
- struct interval_coordinate_type_by_concept { typedef void type; };
- template <typename T>
- struct interval_coordinate_type_by_concept<T, gtl_yes> { typedef typename interval_traits<T>::coordinate_type type; };
-
- template <typename T>
- struct interval_coordinate_type {
- typedef typename interval_coordinate_type_by_concept<
- T, typename is_interval_concept<typename geometry_concept<T>::type>::type>::type type;
- };
+struct interval_concept {};
- template <typename T, typename CT>
- struct interval_difference_type_by_concept { typedef void type; };
- template <typename T>
- struct interval_difference_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename interval_traits<T>::coordinate_type>::coordinate_difference type; };
-
- template <typename T>
- struct interval_difference_type {
- typedef typename interval_difference_type_by_concept<
- T, typename is_interval_concept<typename geometry_concept<T>::type>::type>::type type;
- };
+template <typename ConceptType>
+struct is_interval_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_interval_concept<interval_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename ConceptType>
+struct is_mutable_interval_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_mutable_interval_concept<interval_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct interval_coordinate_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct interval_coordinate_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename interval_traits<GeometryType>::coordinate_type type;
+};
+
+template <typename GeometryType>
+struct interval_coordinate_type {
+ typedef typename interval_coordinate_type_by_concept<
+ GeometryType,
+ typename is_interval_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct interval_difference_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct interval_difference_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename coordinate_traits<
+ typename interval_traits<GeometryType>::coordinate_type
+ >::coordinate_difference type;
+};
+
+template <typename GeometryType>
+struct interval_difference_type {
+ typedef typename interval_difference_type_by_concept<
+ GeometryType,
+ typename is_interval_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+struct y_i_get : gtl_yes {};
+
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_get,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type get(const IntervalType& interval, direction_1d dir) {
+ return interval_traits<IntervalType>::get(interval, dir);
+}
- struct y_i_get : gtl_yes {};
+struct y_i_set : gtl_yes {};
- template <typename T>
- typename enable_if< typename gtl_and<
- y_i_get,
- typename is_interval_concept<typename geometry_concept<T>::type>::type>::type,
- typename interval_coordinate_type<T>::type>::type
- get(const T& interval, direction_1d dir) {
- return interval_traits<T>::get(interval, dir);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_set,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ void
+>::type set(IntervalType& interval, direction_1d dir,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ interval_mutable_traits<IntervalType>::set(interval, dir, value);
+}
- struct y_i_set : gtl_yes {};
+struct y_i_construct : gtl_yes {};
- template <typename T, typename coordinate_type>
- typename enable_if< typename gtl_and<
- y_i_set,
- typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type>::type,
- void>::type
- set(T& interval, direction_1d dir, coordinate_type value) {
- //this may need to be refined
- interval_mutable_traits<T>::set(interval, dir, value);
- if(high(interval) < low(interval))
- interval_mutable_traits<T>::set(interval, dir.backward(), value);
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_construct,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type construct(
+ typename interval_mutable_traits<IntervalType>::coordinate_type low,
+ typename interval_mutable_traits<IntervalType>::coordinate_type high) {
+ if (low > high) {
+ (std::swap)(low, high);
}
+ return interval_mutable_traits<IntervalType>::construct(low, high);
+}
- struct y_i_construct : gtl_yes {};
+struct y_i_copy_construct : gtl_yes {};
- template <typename T, typename T2, typename T3>
- typename enable_if< typename gtl_and<
- y_i_construct,
- typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type>::type,
- T>::type
- construct(T2 low_value, T3 high_value) {
- if(low_value > high_value) std::swap(low_value, high_value);
- return interval_mutable_traits<T>::construct(low_value, high_value);
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_copy_construct,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type copy_construct(const IntervalType2& interval) {
+ return construct<IntervalType1>(get(interval, LOW), get(interval, HIGH));
+}
- struct y_i_copy_construct : gtl_yes {};
+struct y_i_assign : gtl_yes {};
- template <typename T, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_copy_construct,
- 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>(get(interval, LOW ), get(interval, HIGH));
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_assign,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& assign(IntervalType1& lvalue, const IntervalType2& rvalue) {
+ set(lvalue, LOW, get(rvalue, LOW));
+ set(lvalue, HIGH, get(rvalue, HIGH));
+ return lvalue;
+}
- struct y_i_assign : gtl_yes {};
+struct y_i_low : gtl_yes {};
- template <typename T1, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_assign,
- 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);
- return lvalue;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_low,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type low(const IntervalType& interval) {
+ return get(interval, LOW);
+}
- struct y_i_equivalence : gtl_yes {};
+struct y_i_high : gtl_yes {};
- template <typename T, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_equivalence,
- 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) == get(interval2, LOW) &&
- get(interval1, HIGH) == get(interval2, HIGH);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_high,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type high(const IntervalType& interval) {
+ return get(interval, HIGH);
+}
- struct y_i_contains : gtl_yes {};
+struct y_i_low2 : gtl_yes {};
- template <typename interval_type>
- typename enable_if< typename gtl_and< y_i_contains, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type >::type, bool>::type
- contains(const interval_type& interval,
- typename interval_coordinate_type<interval_type>::type value,
- bool consider_touch = true ) {
- if(consider_touch) {
- return value <= high(interval) && value >= low(interval);
- } else {
- return value < high(interval) && value > low(interval);
- }
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_low2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ void
+>::type low(IntervalType& interval,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ set(interval, LOW, value);
+}
- struct y_i_contains2 : gtl_yes {};
+struct y_i_high2 : gtl_yes {};
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<
- y_i_contains2,
- 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) {
- return contains(interval, get(value, LOW), consider_touch) &&
- contains(interval, get(value, HIGH), consider_touch);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_high2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ void
+>::type high(IntervalType& interval,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ set(interval, HIGH, value);
+}
- struct y_i_low : gtl_yes {};
+struct y_i_equivalence : gtl_yes {};
- // get the low coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_low,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- low(const interval_type& interval) { return get(interval, LOW); }
-
- struct y_i_high : gtl_yes {};
-
- // get the high coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_high,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- high(const interval_type& interval) { return get(interval, HIGH); }
-
- struct y_i_center : gtl_yes {};
-
- // get the center coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_center,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- center(const interval_type& interval) { return (high(interval) + low(interval))/2; }
-
-
- struct y_i_low2 : gtl_yes {};
-
- // set the low coordinate to v
- template <typename interval_type>
- typename enable_if<typename gtl_and<
- y_i_low2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- void>::type
- low(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type v) { set(interval, LOW, v); }
-
- struct y_i_high2 : gtl_yes {};
-
- // set the high coordinate to v
- template <typename interval_type>
- typename enable_if<typename gtl_and<
- y_i_high2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- void>::type
- high(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type v) { set(interval, HIGH, v); }
-
- struct y_i_delta : gtl_yes {};
-
- // get the magnitude of the interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_delta,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_difference_type<interval_type>::type >::type
- delta(const interval_type& interval) {
- typedef typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::coordinate_difference diffT;
- return (diffT)high(interval) - (diffT)low(interval); }
-
- struct y_i_flip : gtl_yes {};
-
- // flip this about coordinate
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_flip, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- flip(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type axis = 0) {
- typename interval_coordinate_type<interval_type>::type newLow, newHigh;
- newLow = 2 * axis - high(interval);
- newHigh = 2 * axis - low(interval);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_equivalence,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type equivalence(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2) {
+ return (get(interval1, LOW) == get(interval2, LOW)) &&
+ (get(interval1, HIGH) == get(interval2, HIGH));
+}
- struct y_i_scale_up : gtl_yes {};
+struct y_i_contains : gtl_yes {};
- // scale interval by factor
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale_up, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale_up(interval_type& interval,
- typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::unsigned_area_type factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newHigh = high(interval) * (Unit)factor;
- low(interval, low(interval) * (Unit)factor);
- high(interval, (newHigh));
- return interval;
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_contains,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ bool
+>::type contains(
+ const IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type value,
+ bool consider_touch = true ) {
+ if (consider_touch) {
+ return value <= high(interval) && value >= low(interval);
+ } else {
+ return value < high(interval) && value > low(interval);
}
+}
- struct y_i_scale_down : gtl_yes {};
+struct y_i_contains2 : gtl_yes {};
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale_down, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale_down(interval_type& interval,
- typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::unsigned_area_type factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- Unit newHigh = scaling_policy<Unit>::round((dt)(high(interval)) / (dt)factor);
- low(interval, scaling_policy<Unit>::round((dt)(low(interval)) / (dt)factor));
- high(interval, (newHigh));
- return interval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_contains2,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type contains(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2,
+ bool consider_touch = true) {
+ return contains(interval1, get(interval2, LOW), consider_touch) &&
+ contains(interval1, get(interval2, HIGH), consider_touch);
+}
- struct y_i_scale : gtl_yes {};
+struct y_i_center : gtl_yes {};
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale(interval_type& interval, double factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newHigh = scaling_policy<Unit>::round((double)(high(interval)) * factor);
- low(interval, scaling_policy<Unit>::round((double)low(interval)* factor));
- high(interval, (newHigh));
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_center,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type center(const IntervalType& interval) {
+ return (high(interval) + low(interval)) / 2;
+}
- struct y_i_move : gtl_yes {};
+struct y_i_delta : gtl_yes {};
- // move interval by delta
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_move,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- move(interval_type& interval, typename interval_difference_type<interval_type>::type displacement) {
- typedef typename interval_coordinate_type<interval_type>::type ctype;
- typedef typename coordinate_traits<ctype>::coordinate_difference Unit;
- Unit len = delta(interval);
- low(interval, static_cast<ctype>(static_cast<Unit>(low(interval)) + displacement));
- high(interval, static_cast<ctype>(static_cast<Unit>(low(interval)) + len));
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_delta,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_difference_type<IntervalType>::type
+>::type delta(const IntervalType& interval) {
+ typedef typename interval_difference_type<IntervalType>::type diff_type;
+ return static_cast<diff_type>(high(interval)) -
+ static_cast<diff_type>(low(interval));
+}
- struct y_i_convolve : gtl_yes {};
+struct y_i_flip : gtl_yes {};
- // convolve this with b
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_convolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- convolve(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + b;
- Unit newHigh = high(interval) + b;
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_flip,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type& flip(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type axis = 0) {
+ typename interval_coordinate_type<IntervalType>::type newLow, newHigh;
+ newLow = 2 * axis - high(interval);
+ newHigh = 2 * axis - low(interval);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
- struct y_i_deconvolve : gtl_yes {};
+struct y_i_scale_up : gtl_yes {};
- // deconvolve this with b
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_deconvolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- deconvolve(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - b;
- Unit newHigh = high(interval) - b;
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_scale_up,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& scale_up(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type factor) {
+ typename interval_coordinate_type<IntervalType>::type newHigh =
+ high(interval) * factor;
+ low(interval, low(interval) * factor);
+ high(interval, (newHigh));
+ return interval;
+}
- struct y_i_convolve2 : gtl_yes {};
+struct y_i_scale_down : gtl_yes {};
- // convolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_convolve2,
- 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_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + low(b);
- Unit newHigh = high(interval) + high(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_scale_down,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& scale_down(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type factor) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ typename interval_coordinate_type<IntervalType>::type newHigh =
+ high(interval) / factor;
+ low(interval, low(interval) / factor);
+ high(interval, (newHigh));
+ return interval;
+}
- struct y_i_deconvolve2 : gtl_yes {};
+// TODO(asydorchuk): Deprecated.
+struct y_i_scale : gtl_yes {};
- // deconvolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3< y_i_deconvolve2,
- 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_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - low(b);
- Unit newHigh = high(interval) - high(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_scale,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& scale(IntervalType& interval, double factor) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ Unit newHigh = scaling_policy<Unit>::round(
+ static_cast<double>(high(interval)) * factor);
+ low(interval, scaling_policy<Unit>::round(
+ static_cast<double>(low(interval)) * factor));
+ high(interval, (newHigh));
+ return interval;
+}
- struct y_i_reconvolve : gtl_yes {};
+struct y_i_move : gtl_yes {};
- // reflected convolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_reconvolve,
- 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_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - high(b);
- Unit newHigh = high(interval) - low(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_move,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& move(
+ IntervalType& interval,
+ typename interval_difference_type<IntervalType>::type displacement) {
+ typedef typename interval_coordinate_type<IntervalType>::type ctype;
+ typedef typename coordinate_traits<ctype>::coordinate_difference Unit;
+ low(interval, static_cast<ctype>(
+ static_cast<Unit>(low(interval)) + displacement));
+ high(interval, static_cast<ctype>(
+ static_cast<Unit>(high(interval)) + displacement));
+ return interval;
+}
- struct y_i_redeconvolve : gtl_yes {};
+struct y_i_convolve : gtl_yes {};
- // reflected deconvolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3< y_i_redeconvolve,
- 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_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + high(b);
- Unit newHigh = high(interval) + low(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_convolve,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& convolve(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type value) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ Unit newLow = low(interval) + value;
+ Unit newHigh = high(interval) + value;
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
- struct y_i_e_dist1 : gtl_yes {};
+struct y_i_deconvolve : gtl_yes {};
- // distance from a coordinate to an interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_e_dist1, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_difference_type<interval_type>::type>::type
- euclidean_distance(const interval_type& interval,
- typename interval_coordinate_type<interval_type>::type position) {
- typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
- Unit dist[3] = {0, (Unit)low(interval) - (Unit)position, (Unit)position - (Unit)high(interval)};
- return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_deconvolve,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& deconvolve(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type value) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ Unit newLow = low(interval) - value;
+ Unit newHigh = high(interval) - value;
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
- struct y_i_e_dist2 : gtl_yes {};
+struct y_i_convolve2 : gtl_yes {};
- // distance between two intervals
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_dist2, 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 interval_difference_type<interval_type>::type>::type
- euclidean_distance(const interval_type& interval,
- const interval_type_2& b) {
- typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
- Unit dist[3] = {0, (Unit)low(interval) - (Unit)high(b), (Unit)low(b) - (Unit)high(interval)};
- return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_convolve2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& convolve(IntervalType1& lvalue, const IntervalType2& rvalue) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit newLow = low(lvalue) + low(rvalue);
+ Unit newHigh = high(lvalue) + high(rvalue);
+ low(lvalue, newLow);
+ high(lvalue, newHigh);
+ return lvalue;
+}
- struct y_i_e_intersects : gtl_yes {};
+struct y_i_deconvolve2 : gtl_yes {};
- // check if Interval b intersects `this` Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_intersects, 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));
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_deconvolve2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& deconvolve(IntervalType1& lvalue, const IntervalType2& rvalue) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit newLow = low(lvalue) - low(rvalue);
+ Unit newHigh = high(lvalue) - high(rvalue);
+ low(lvalue, newLow);
+ high(lvalue, newHigh);
+ return lvalue;
+}
- struct y_i_e_bintersect : gtl_yes {};
+struct y_i_reconvolve : gtl_yes {};
- // check if Interval b partially overlaps `this` Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_bintersect, 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) ||
- contains(interval, high(b), consider_touch)) &&
- (contains(b, low(interval), consider_touch) ||
- contains(b, high(interval), consider_touch));
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_reconvolve,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& reflected_convolve(
+ IntervalType1& lvalue,
+ const IntervalType2& rvalue) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit newLow = low(lvalue) - high(rvalue);
+ Unit newHigh = high(lvalue) - low(rvalue);
+ low(lvalue, newLow);
+ high(lvalue, newHigh);
+ return lvalue;
+}
- struct y_i_abuts1 : gtl_yes {};
+struct y_i_redeconvolve : gtl_yes {};
- // check if they are end to end
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<y_i_abuts1, 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);
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_redeconvolve,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& reflected_deconvolve(
+ IntervalType1& lvalue,
+ const IntervalType2& rvalue) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit newLow = low(lvalue) + high(rvalue);
+ Unit newHigh = high(lvalue) + low(rvalue);
+ low(lvalue, newLow);
+ high(lvalue, newHigh);
+ return lvalue;
+}
- struct y_i_abuts2 : gtl_yes {};
+struct y_i_e_dist1 : gtl_yes {};
- // check if they are end to end
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_abuts2, 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);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<y_i_e_dist1,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_difference_type<IntervalType>::type
+>::type euclidean_distance(
+ const IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type position) {
+ typedef typename interval_difference_type<IntervalType>::type Unit;
+ Unit dist[3] = {
+ 0,
+ (Unit)low(interval) - (Unit)position,
+ (Unit)position - (Unit)high(interval)
+ };
+ return dist[(dist[1] > 0) + ((dist[2] > 0) << 1)];
+}
- struct y_i_intersect : gtl_yes {};
+struct y_i_e_dist2 : gtl_yes {};
- // set 'this' interval to the intersection of 'this' and b
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<y_i_intersect, 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_coordinate_type<interval_type>::type Unit;
- Unit lowVal = (std::max)(low(interval), low(b));
- Unit highVal = (std::min)(high(interval), high(b));
- bool valid = consider_touch ?
- lowVal <= highVal :
- lowVal < highVal;
- if(valid) {
- low(interval, lowVal);
- high(interval, highVal);
- }
- return valid;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_e_dist2,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ typename interval_difference_type<IntervalType1>::type
+>::type euclidean_distance(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2) {
+ typedef typename interval_difference_type<IntervalType1>::type Unit;
+ Unit dist[3] = {
+ 0,
+ (Unit)low(interval1) - (Unit)high(interval2),
+ (Unit)low(interval2) - (Unit)high(interval1)
+ };
+ return dist[(dist[1] > 0) + ((dist[2] > 0) << 1)];
+}
- struct y_i_g_intersect : gtl_yes {};
+struct y_i_e_intersects : gtl_yes {};
- // set 'this' interval to the generalized intersection of 'this' and b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_g_intersect, 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_coordinate_type<interval_type>::type Unit;
- Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
- //consider implementing faster sorting of small fixed length range
- polygon_sort(coords, coords+4);
- low(interval, coords[1]);
- high(interval, coords[2]);
- return interval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_e_intersects,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type intersects(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2,
+ bool consider_touch = true) {
+ return consider_touch ?
+ (low(interval1) <= high(interval2)) &&
+ (high(interval1) >= low(interval2)) :
+ (low(interval1) < high(interval2)) &&
+ (high(interval1) > low(interval2));
+}
- struct y_i_bloat : gtl_yes {};
+struct y_i_e_bintersect : gtl_yes {};
- // bloat the Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_bloat, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- bloat(interval_type& interval, typename interval_coordinate_type<interval_type>::type bloating) {
- low(interval, low(interval)-bloating);
- high(interval, high(interval)+bloating);
- return interval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_e_bintersect,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type boundaries_intersect(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2,
+ bool consider_touch = true) {
+ return (contains(interval1, low(interval2), consider_touch) ||
+ contains(interval1, high(interval2), consider_touch)) &&
+ (contains(interval2, low(interval1), consider_touch) ||
+ contains(interval2, high(interval1), consider_touch));
+}
- struct y_i_bloat2 : gtl_yes {};
+struct y_i_intersect : gtl_yes {};
- // bloat the specified side of `this` Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_bloat2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- bloat(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type bloating) {
- set(interval, dir, get(interval, dir) + dir.get_sign() * bloating);
- return interval;
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_intersect,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type intersect(
+ IntervalType1& lvalue,
+ const IntervalType2& rvalue,
+ bool consider_touch = true) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit lowVal = (std::max)(low(lvalue), low(rvalue));
+ Unit highVal = (std::min)(high(lvalue), high(rvalue));
+ bool valid = consider_touch ? lowVal <= highVal : lowVal < highVal;
+ if (valid) {
+ low(lvalue, lowVal);
+ high(lvalue, highVal);
}
+ return valid;
+}
- struct y_i_shrink : gtl_yes {};
+struct y_i_g_intersect : gtl_yes {};
- // shrink the Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_shrink, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- shrink(interval_type& interval, typename interval_coordinate_type<interval_type>::type shrinking) {
- return bloat(interval, -shrinking);
- }
+// TODO(asydorchuk): Deprecated.
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_g_intersect,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ IntervalType1
+>::type& generalized_intersect(
+ IntervalType1& lvalue,
+ const IntervalType2& rvalue) {
+ typedef typename interval_coordinate_type<IntervalType1>::type Unit;
+ Unit coords[4] = {low(lvalue), high(lvalue), low(rvalue), high(rvalue)};
+ // TODO(asydorchuk): consider implementing faster sorting of small
+ // fixed length range.
+ polygon_sort(coords, coords+4);
+ low(lvalue, coords[1]);
+ high(lvalue, coords[2]);
+ return lvalue;
+}
- struct y_i_shrink2 : gtl_yes {};
+struct y_i_abuts1 : gtl_yes {};
- // shrink the specified side of `this` Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_shrink2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- shrink(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type shrinking) {
- return bloat(interval, dir, -shrinking);
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_abuts1,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type abuts(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2,
+ direction_1d dir) {
+ return dir.to_int() ? low(interval2) == high(interval1) :
+ low(interval1) == high(interval2);
+}
- struct y_i_encompass : gtl_yes {};
+struct y_i_abuts2 : gtl_yes {};
- // Enlarge `this` Interval to encompass the specified Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<
- y_i_encompass,
- 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)));
- high(interval, (std::max)(high(interval), high(b)));
- return retval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_abuts2,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type abuts(
+ const IntervalType1& interval1,
+ const IntervalType2& interval2) {
+ return abuts(interval1, interval2, HIGH) ||
+ abuts(interval1, interval2, LOW);
+}
- struct y_i_encompass2 : gtl_yes {};
+struct y_i_bloat : gtl_yes {};
- // Enlarge `this` Interval to encompass the specified Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_encompass2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- bool>::type
- encompass(interval_type& interval, typename interval_coordinate_type<interval_type>::type b) {
- bool retval = !contains(interval, b, true);
- low(interval, (std::min)(low(interval), b));
- high(interval, (std::max)(high(interval), b));
- return retval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_bloat,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& bloat(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type bloating) {
+ low(interval, low(interval) - bloating);
+ high(interval, high(interval) + bloating);
+ return interval;
+}
- struct y_i_get_half : gtl_yes {};
+struct y_i_bloat2 : gtl_yes {};
- // gets the half of the interval as an interval
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_get_half, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type
- get_half(const interval_type& interval, direction_1d d1d) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit c = (get(interval, LOW) + get(interval, HIGH)) / 2;
- return construct<interval_type>((d1d == LOW) ? get(interval, LOW) : c,
- (d1d == LOW) ? c : get(interval, HIGH));
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_bloat2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& bloat(
+ IntervalType& interval,
+ direction_1d dir,
+ typename interval_coordinate_type<IntervalType>::type bloating) {
+ set(interval, dir, get(interval, dir) + dir.get_sign() * bloating);
+ return interval;
+}
- struct y_i_join_with : gtl_yes {};
+struct y_i_shrink : gtl_yes {};
- // 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 enable_if<
- typename gtl_and_3<y_i_join_with, 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);
- return true;
- }
- return false;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_shrink,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& shrink(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type shrinking) {
+ return bloat(interval, -shrinking);
+}
- template <class T>
- template <class T2>
- interval_data<T>& interval_data<T>::operator=(const T2& rvalue) {
- assign(*this, rvalue);
- return *this;
- }
+struct y_i_shrink2 : gtl_yes {};
- template <typename T>
- struct geometry_concept<interval_data<T> > {
- typedef interval_concept type;
- };
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_shrink2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type& shrink(
+ IntervalType& interval,
+ direction_1d dir,
+ typename interval_coordinate_type<IntervalType>::type shrinking) {
+ return bloat(interval, dir, -shrinking);
+}
+
+struct y_i_encompass : gtl_yes {};
+
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_encompass,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+ bool
+>::type encompass(IntervalType1& interval1, const IntervalType2& interval2) {
+ bool retval = !contains(interval1, interval2, true);
+ low(interval1, (std::min)(low(interval1), low(interval2)));
+ high(interval1, (std::max)(high(interval1), high(interval2)));
+ return retval;
+}
+
+struct y_i_encompass2 : gtl_yes {};
+
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_encompass2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ bool
+>::type encompass(
+ IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type value) {
+ bool retval = !contains(interval, value, true);
+ low(interval, (std::min)(low(interval), value));
+ high(interval, (std::max)(high(interval), value));
+ return retval;
}
+
+struct y_i_get_half : gtl_yes {};
+
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_get_half,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ IntervalType
+>::type get_half(const IntervalType& interval, direction_1d dir) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ Unit c = (get(interval, LOW) + get(interval, HIGH)) / 2;
+ return construct<IntervalType>(
+ (dir == LOW) ? get(interval, LOW) : c,
+ (dir == LOW) ? c : get(interval, HIGH));
}
-#endif
+
+struct y_i_join_with : gtl_yes {};
+
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_join_with,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type>::type,
+ bool
+>::type join_with(IntervalType1& interval1, const IntervalType2& interval2) {
+ if (abuts(interval1, interval2)) {
+ encompass(interval1, interval2);
+ return true;
+ }
+ return false;
+}
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_INTERVAL_CONCEPT_HPP
Modified: branches/release/boost/polygon/interval_data.hpp
==============================================================================
--- branches/release/boost/polygon/interval_data.hpp (original)
+++ branches/release/boost/polygon/interval_data.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,67 +1,120 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_data.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_INTERVAL_DATA_HPP
#define BOOST_POLYGON_INTERVAL_DATA_HPP
+
#include "isotropy.hpp"
-namespace boost { namespace polygon{
- template <typename T>
- class interval_data {
- public:
- typedef T coordinate_type;
- inline interval_data()
+#include "interval_concept.hpp"
+
+namespace boost {
+namespace polygon {
+
+template <typename T>
+class interval_data {
+ public:
+ typedef T coordinate_type;
+
+ interval_data()
#ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
#endif
- {}
- inline interval_data(coordinate_type low, coordinate_type high)
+ {}
+
+ interval_data(coordinate_type low, coordinate_type high)
#ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
#endif
- {
- coords_[LOW] = low; coords_[HIGH] = high;
- }
- inline interval_data(const interval_data& that)
+ {
+ coords_[LOW] = low;
+ coords_[HIGH] = high;
+ }
+
+ interval_data(const interval_data& that)
#ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
#endif
- {
- (*this) = that;
- }
- inline interval_data& operator=(const interval_data& that) {
- coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; return *this;
- }
- template <typename T2>
- inline interval_data& operator=(const T2& rvalue);
- inline coordinate_type get(direction_1d dir) const {
- return coords_[dir.to_int()];
- }
- inline coordinate_type low() const { return coords_[0]; }
- inline coordinate_type high() const { return coords_[1]; }
- inline bool operator==(const interval_data& that) const {
- return low() == that.low() && high() == that.high(); }
- inline bool operator!=(const interval_data& that) const {
- return low() != that.low() || high() != that.high(); }
- inline bool operator<(const interval_data& that) const {
- if(coords_[0] < that.coords_[0]) return true;
- if(coords_[0] > that.coords_[0]) return false;
- if(coords_[1] < that.coords_[1]) return true;
- return false;
- }
- inline bool operator<=(const interval_data& that) const { return !(that < *this); }
- inline bool operator>(const interval_data& that) const { return that < *this; }
- inline bool operator>=(const interval_data& that) const { return !((*this) < that); }
- inline void set(direction_1d dir, coordinate_type value) {
+ {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ }
+
+ interval_data& operator=(const interval_data& that) {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ return *this;
+ }
+
+ coordinate_type get(direction_1d dir) const {
+ return coords_[dir.to_int()];
+ }
+
+ void set(direction_1d dir, coordinate_type value) {
coords_[dir.to_int()] = value;
}
-private:
+
+ coordinate_type low() const {
+ return coords_[0];
+ }
+
+ interval_data& low(coordinate_type value) {
+ coords_[LOW] = value;
+ return *this;
+ }
+
+ coordinate_type high() const {
+ return coords_[1];
+ }
+
+ interval_data& high(coordinate_type value) {
+ coords_[HIGH] = value;
+ return *this;
+ }
+
+ bool operator==(const interval_data& that) const {
+ return low() == that.low() && high() == that.high();
+ }
+
+ bool operator!=(const interval_data& that) const {
+ return low() != that.low() || high() != that.high();
+ }
+
+ bool operator<(const interval_data& that) const {
+ if (coords_[0] != that.coords_[0]) {
+ return coords_[0] < that.coords_[0];
+ }
+ return coords_[1] < that.coords_[1];
+ }
+
+ bool operator<=(const interval_data& that) const {
+ return !(that < *this);
+ }
+
+ bool operator>(const interval_data& that) const {
+ return that < *this;
+ }
+
+ bool operator>=(const interval_data& that) const {
+ return !((*this) < that);
+ }
+
+ private:
coordinate_type coords_[2];
};
-}
-}
-#endif
+template <typename CType>
+struct geometry_concept< interval_data<CType> > {
+ typedef interval_concept type;
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_INTERVAL_DATA_HPP
Modified: branches/release/boost/polygon/interval_traits.hpp
==============================================================================
--- branches/release/boost/polygon/interval_traits.hpp (original)
+++ branches/release/boost/polygon/interval_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,32 +1,47 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_traits.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_INTERVAL_TRAITS_HPP
#define BOOST_POLYGON_INTERVAL_TRAITS_HPP
-namespace boost { namespace polygon{
- template <typename T>
- struct interval_traits {
- typedef typename T::coordinate_type coordinate_type;
-
- static inline coordinate_type get(const T& interval, direction_1d dir) {
- return interval.get(dir);
- }
- };
-
- template <typename T>
- struct interval_mutable_traits {
- static inline void set(T& interval, direction_1d dir, typename interval_traits<T>::coordinate_type value) {
- interval.set(dir, value);
- }
- static inline T construct(typename interval_traits<T>::coordinate_type low_value,
- typename interval_traits<T>::coordinate_type high_value) {
- return T(low_value, high_value);
- }
- };
-}
-}
-#endif
+
+#include "isotropy.hpp"
+
+namespace boost {
+namespace polygon {
+
+template <typename Interval>
+struct interval_traits {
+ typedef Interval interval_type;
+ typedef typename interval_type::coordinate_type coordinate_type;
+
+ static coordinate_type get(const interval_type& interval, direction_1d dir) {
+ return interval.get(dir);
+ }
+};
+
+template <typename Interval>
+struct interval_mutable_traits {
+ typedef Interval interval_type;
+ typedef typename interval_type::coordinate_type coordinate_type;
+
+ static void set(
+ interval_type& interval, direction_1d dir, coordinate_type value) {
+ interval.set(dir, value);
+ }
+
+ static interval_type construct(coordinate_type low, coordinate_type high) {
+ return interval_type(low, high);
+ }
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLICY_INTERVAL_TRAITS_HPP
Deleted: branches/release/boost/polygon/point_3d_concept.hpp
==============================================================================
--- branches/release/boost/polygon/point_3d_concept.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
+++ (empty file)
@@ -1,270 +0,0 @@
-/*
- 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 GLT_POINT_3D_CONCEPT_HPP
-#define GLT_POINT_3D_CONCEPT_HPP
-#include "point_concept.hpp"
-#include "point_3d_data.hpp"
-#include "point_3d_traits.hpp"
-namespace boost { namespace polygon{
- struct point_3d_concept {};
-
- template <typename T>
- struct is_point_3d_concept { typedef gtl_no type; };
- template <>
- 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 { typedef gtl_no type; };
- template <>
- struct is_mutable_point_3d_concept<point_3d_concept> { typedef gtl_yes type; };
-
- template <typename T, typename CT>
- struct point_3d_coordinate_type_by_concept { typedef void type; };
- template <typename T>
- struct point_3d_coordinate_type_by_concept<T, gtl_yes> { typedef typename point_3d_traits<T>::coordinate_type type; };
-
- template <typename T>
- struct point_3d_coordinate_type {
- typedef typename point_3d_coordinate_type_by_concept<T, typename is_point_3d_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- template <typename T, typename CT>
- struct point_3d_difference_type_by_concept { typedef void type; };
- template <typename T>
- struct point_3d_difference_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename point_3d_coordinate_type<T>::type>::coordinate_difference type; };
-
- template <typename T>
- struct point_3d_difference_type {
- typedef typename point_3d_difference_type_by_concept<
- T, typename is_point_3d_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- template <typename T, typename CT>
- struct point_3d_distance_type_by_concept { typedef void type; };
- template <typename T>
- struct point_3d_distance_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename point_3d_coordinate_type<T>::type>::coordinate_distance type; };
-
- template <typename T>
- struct point_3d_distance_type {
- typedef typename point_3d_distance_type_by_concept<
- T, typename is_point_3d_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- struct y_p3d_get : gtl_yes {};
-
- template <typename T>
- typename enable_if< typename gtl_and<y_p3d_get, typename is_point_3d_concept<typename geometry_concept<T>::type>::type>::type,
- typename point_3d_coordinate_type<T>::type >::type
- get(const T& point, orientation_3d orient) { return point_3d_traits<T>::get(point, orient); }
-
- struct y_p3d_set : gtl_yes {};
-
- template <typename T, typename coordinate_type>
- typename enable_if< typename gtl_and<y_p3d_set, typename is_mutable_point_3d_concept<typename geometry_concept<T>::type>::type>::type, void>::type
- set(T& point, orientation_3d orient, coordinate_type value) { point_3d_mutable_traits<T>::set(point, orient, value); }
-
- struct y_p3d_set2 : gtl_yes {};
-
- template <typename T, typename coordinate_type>
- typename enable_if< typename gtl_and<y_p3d_set2, typename is_mutable_point_3d_concept<typename geometry_concept<T>::type>::type>::type, void>::type
- set(T& point, orientation_2d orient, coordinate_type value) { point_3d_mutable_traits<T>::set(point, orient, value); }
-
- struct y_p3d_construct : gtl_yes {};
-
- template <typename T, typename coordinate_type1, typename coordinate_type2, typename coordinate_type3>
- typename enable_if< typename gtl_and<y_p3d_construct, typename is_mutable_point_3d_concept<typename geometry_concept<T>::type>::type>::type, T>::type
- construct(coordinate_type1 x_value, coordinate_type2 y_value, coordinate_type3 z_value) {
- return point_3d_mutable_traits<T>::construct(x_value, y_value, z_value); }
-
- struct y_p3d_assign : gtl_yes {};
-
- template <typename point_3d_type_1, typename point_3d_type_2>
- typename enable_if<
- typename gtl_and_3<y_p3d_assign, 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));
- set(lvalue, PROXIMAL, get(rvalue, PROXIMAL));
- return lvalue;
- }
-
- struct y_p3d_z : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_p3d_z, typename is_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type,
- typename point_3d_coordinate_type<point_type>::type >::type
- z(const point_type& point) { return get(point, PROXIMAL); }
-
- struct y_p3d_x : gtl_yes {};
-
- template <typename point_type, typename coordinate_type>
- typename enable_if< typename gtl_and<y_p3d_x, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type, void>::type
- x(point_type& point, coordinate_type value) { set(point, HORIZONTAL, value); }
-
- struct y_p3d_y : gtl_yes {};
-
- template <typename point_type, typename coordinate_type>
- typename enable_if< typename gtl_and<y_p3d_y, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type, void>::type
- y(point_type& point, coordinate_type value) { set(point, VERTICAL, value); }
-
- struct y_p3d_z2 : gtl_yes {};
-
- template <typename point_type, typename coordinate_type>
- typename enable_if< typename gtl_and<y_p3d_z2, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type, void>::type
- z(point_type& point, coordinate_type value) { set(point, PROXIMAL, value); }
-
- struct y_p3d_equiv : gtl_yes {};
-
- template <typename T, typename T2>
- typename enable_if<
- typename gtl_and_3<y_p3d_equiv, 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);
- }
-
- struct y_p3d_dist : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<y_p3d_dist, 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 point_3d_difference_type<point_type_1>::type>::type
- euclidean_distance(const point_type_1& point1, const point_type_2& point2, orientation_3d orient) {
- typedef typename coordinate_traits<typename point_3d_coordinate_type<point_type_1>::type>::coordinate_difference return_type;
- return_type return_value =
- (return_type)get(point1, orient) - (return_type)get(point2, orient);
- return return_value < 0 ? -return_value : return_value;
- }
-
- struct y_p3d_man_dist : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<y_p3d_man_dist, 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 point_3d_difference_type<point_type_1>::type>::type
- manhattan_distance(const point_type_1& point1, const point_type_2& point2) {
- return euclidean_distance(point1, point2, HORIZONTAL) + euclidean_distance(point1, point2, VERTICAL)
- + euclidean_distance(point1, point2, PROXIMAL);
- }
-
- struct y_p3d_dist2 : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3< y_p3d_dist2,
- 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 point_3d_distance_type<point_type_1>::type>::type
- euclidean_distance(const point_type_1& point1, const point_type_2& point2) {
- typedef typename coordinate_traits<typename point_3d_coordinate_type<point_type_1>::type>::coordinate_distance return_value;
- return_value pdist = (return_value)euclidean_distance(point1, point2, PROXIMAL);
- pdist *= pdist;
- return std::sqrt((double)(distance_squared(point1, point2) + pdist));
- }
-
- struct y_p3d_convolve : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3< y_p3d_convolve,
- 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));
- y(lvalue, y(lvalue) + y(rvalue));
- z(lvalue, z(lvalue) + z(rvalue));
- return lvalue;
- }
-
- struct y_p3d_deconvolve : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if<
- typename gtl_and_3<y_p3d_deconvolve, 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));
- z(lvalue, z(lvalue) - z(rvalue));
- return lvalue;
- }
-
- struct y_p3d_scale_up : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_p3d_scale_up, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale_up(point_type& point,
- typename coordinate_traits<typename point_3d_coordinate_type<point_type>::type>::unsigned_area_type factor) {
- x(point, x(point) * (typename point_3d_coordinate_type<point_type>::type)factor);
- y(point, y(point) * (typename point_3d_coordinate_type<point_type>::type)factor);
- z(point, z(point) * (typename point_3d_coordinate_type<point_type>::type)factor);
- return point;
- }
-
- struct y_p3d_scale_down : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_p3d_scale_down, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale_down(point_type& point,
- typename coordinate_traits<typename point_3d_coordinate_type<point_type>::type>::unsigned_area_type factor) {
- typedef typename point_3d_coordinate_type<point_type>::type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- x(point, scaling_policy<Unit>::round((dt)(x(point)) / (dt)factor));
- y(point, scaling_policy<Unit>::round((dt)(y(point)) / (dt)factor));
- z(point, scaling_policy<Unit>::round((dt)(z(point)) / (dt)factor));
- return point;
- }
-
- struct y_p3d_scale : gtl_yes {};
-
- template <typename point_type, typename scaling_type>
- typename enable_if< typename gtl_and<y_p3d_scale, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale(point_type& point,
- const scaling_type& scaling) {
- typedef typename point_3d_coordinate_type<point_type>::type Unit;
- Unit x_(x(point)), y_(y(point)), z_(z(point));
- scaling.scale(x_, y_, z_);
- x(point, x_);
- y(point, y_);
- z(point, z_);
- return point;
- }
-
- struct y_p3d_transform : gtl_yes {};
-
- template <typename point_type, typename transformation_type>
- typename enable_if< typename gtl_and<y_p3d_transform, typename is_mutable_point_3d_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- transform(point_type& point, const transformation_type& transformation) {
- typedef typename point_3d_coordinate_type<point_type>::type Unit;
- Unit x_(x(point)), y_(y(point)), z_(z(point));
- transformation.transform(x_, y_, z_);
- x(point, x_);
- y(point, y_);
- z(point, z_);
- return point;
- }
-
- template <typename T>
- struct geometry_concept<point_3d_data<T> > {
- typedef point_3d_concept type;
- };
-}
-}
-#endif
-
Deleted: branches/release/boost/polygon/point_3d_data.hpp
==============================================================================
--- branches/release/boost/polygon/point_3d_data.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
+++ (empty file)
@@ -1,49 +0,0 @@
-/*
- 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 BOOST_POLYGON_POINT_3D_DATA_HPP
-#define BOOST_POLYGON_POINT_3D_DATA_HPP
-namespace boost { namespace polygon{
- template <typename T>
- class point_3d_data {
- public:
- typedef T coordinate_type;
- inline point_3d_data():coords_(){}
- inline point_3d_data(coordinate_type x, coordinate_type y):coords_() {
- coords_[HORIZONTAL] = x; coords_[VERTICAL] = y; coords_[PROXIMAL] = 0; }
- inline point_3d_data(coordinate_type x, coordinate_type y, coordinate_type z)
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- {
- coords_[HORIZONTAL] = x; coords_[VERTICAL] = y; coords_[PROXIMAL] = z; }
- inline point_3d_data(const point_3d_data& that):coords_() { (*this) = that; }
- inline point_3d_data& operator=(const point_3d_data& that) {
- coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1];
- coords_[2] = that.coords_[2]; return *this; }
- template <typename T2>
- inline point_3d_data& operator=(const T2& rvalue);
- inline bool operator==(const point_3d_data& that) const {
- return coords_[0] == that.coords_[0] && coords_[1] == that.coords_[1] && coords_[2] == that.coords_[2];
- }
- inline bool operator!=(const point_3d_data& that) const {
- return !((*this) == that);
- }
- inline coordinate_type get(orientation_2d orient) const {
- return coords_[orient.to_int()]; }
- inline coordinate_type get(orientation_3d orient) const {
- return coords_[orient.to_int()]; }
- inline void set(orientation_2d orient, coordinate_type value) {
- coords_[orient.to_int()] = value; }
- inline void set(orientation_3d orient, coordinate_type value) {
- coords_[orient.to_int()] = value; }
- private:
- coordinate_type coords_[3];
- };
-}
-}
-#endif
Deleted: branches/release/boost/polygon/point_3d_traits.hpp
==============================================================================
--- branches/release/boost/polygon/point_3d_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
+++ (empty file)
@@ -1,34 +0,0 @@
-/*
- 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 BOOST_POLYGON_POINT_3D_TRAITS_HPP
-#define BOOST_POLYGON_POINT_3D_TRAITS_HPP
-
-#include "isotropy.hpp"
-
-namespace boost { namespace polygon{
- template <typename T>
- struct point_3d_traits {
- typedef typename T::coordinate_type coordinate_type;
-
- static inline coordinate_type get(const T& point, orientation_3d orient) {
- return point.get(orient); }
- };
-
- template <typename T>
- struct point_3d_mutable_traits {
- static inline void set(T& point, orientation_3d orient, typename point_3d_traits<T>::coordinate_type value) {
- point.set(orient, value); }
-
- static inline T construct(typename point_3d_traits<T>::coordinate_type x_value,
- typename point_3d_traits<T>::coordinate_type y_value,
- typename point_3d_traits<T>::coordinate_type z_value) {
- return T(x_value, y_value, z_value); }
- };
-}
-}
-#endif
Modified: branches/release/boost/polygon/point_concept.hpp
==============================================================================
--- branches/release/boost/polygon/point_concept.hpp (original)
+++ branches/release/boost/polygon/point_concept.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,316 +1,469 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library point_concept.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_POINT_CONCEPT_HPP
#define BOOST_POLYGON_POINT_CONCEPT_HPP
+
#include "isotropy.hpp"
-#include "point_data.hpp"
#include "point_traits.hpp"
-namespace boost { namespace polygon{
- struct point_concept {};
+namespace boost {
+namespace polygon {
+
+struct point_concept {};
+
+template <typename ConceptType>
+struct is_point_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_point_concept<point_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename ConceptType>
+struct is_mutable_point_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_mutable_point_concept<point_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct point_coordinate_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct point_coordinate_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename point_traits<GeometryType>::coordinate_type type;
+};
+
+template <typename GeometryType>
+struct point_coordinate_type {
+ typedef typename point_coordinate_type_by_concept<
+ GeometryType,
+ typename is_point_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct point_difference_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct point_difference_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename coordinate_traits<
+ typename point_traits<GeometryType>::coordinate_type
+ >::coordinate_difference type;
+};
+
+template <typename GeometryType>
+struct point_difference_type {
+ typedef typename point_difference_type_by_concept<
+ GeometryType,
+ typename is_point_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct point_distance_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct point_distance_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename coordinate_traits<
+ typename point_coordinate_type<GeometryType>::type
+ >::coordinate_distance type;
+};
+
+template <typename GeometryType>
+struct point_distance_type {
+ typedef typename point_distance_type_by_concept<
+ GeometryType,
+ typename is_point_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+struct y_pt_get : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_get,
+ typename is_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+ typename point_coordinate_type<PointType>::type
+>::type get(const PointType& point, orientation_2d orient) {
+ return point_traits<PointType>::get(point, orient);
+}
+
+struct y_pt_set : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_set,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+ void
+>::type set(PointType& point, orientation_2d orient,
+ typename point_mutable_traits<PointType>::coordinate_type value) {
+ point_mutable_traits<PointType>::set(point, orient, value);
+}
+
+struct y_pt_construct : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_construct,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type construct(
+ typename point_mutable_traits<PointType>::coordinate_type x,
+ typename point_mutable_traits<PointType>::coordinate_type y) {
+ return point_mutable_traits<PointType>::construct(x, y);
+}
+
+struct y_pt_assign : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_assign,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+>::type,
+PointType1>::type& assign(PointType1& lvalue, const PointType2& rvalue) {
+ set(lvalue, HORIZONTAL, get(rvalue, HORIZONTAL));
+ set(lvalue, VERTICAL, get(rvalue, VERTICAL));
+ return lvalue;
+}
+
+struct y_p_x : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_p_x,
+ typename is_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+ typename point_coordinate_type<PointType>::type
+>::type x(const PointType& point) {
+ return get(point, HORIZONTAL);
+}
+
+struct y_p_y : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_p_y,
+ typename is_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+ typename point_coordinate_type<PointType>::type
+>::type y(const PointType& point) {
+ return get(point, VERTICAL);
+}
+
+struct y_p_sx : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_p_sx,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+void>::type x(PointType& point,
+ typename point_mutable_traits<PointType>::coordinate_type value) {
+ set(point, HORIZONTAL, value);
+}
+
+struct y_p_sy : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_p_sy,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+void>::type y(PointType& point,
+ typename point_mutable_traits<PointType>::coordinate_type value) {
+ set(point, VERTICAL, value);
+}
+
+struct y_pt_equiv : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_equiv,
+ typename is_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+bool>::type equivalence(
+ const PointType1& point1, const PointType2& point2) {
+ return (x(point1) == x(point2)) && (y(point1) == y(point2));
+}
+
+struct y_pt_man_dist : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_man_dist,
+ typename is_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+typename point_difference_type<PointType1>::type>::type
+manhattan_distance(const PointType1& point1, const PointType2& point2) {
+ return euclidean_distance(point1, point2, HORIZONTAL) +
+ euclidean_distance(point1, point2, VERTICAL);
+}
+
+struct y_pt_ed1 : gtl_yes {};
- template <typename T>
- struct is_point_concept { typedef gtl_no type; };
- template <>
- struct is_point_concept<point_concept> { typedef gtl_yes type; };
-
- struct point_3d_concept;
- template <>
- struct is_point_concept<point_3d_concept> { typedef gtl_yes type; };
-
- template <typename T>
- struct is_mutable_point_concept { typedef gtl_no type; };
- template <>
- struct is_mutable_point_concept<point_concept> { typedef gtl_yes type; };
-
- template <typename T, typename CT>
- struct point_coordinate_type_by_concept { typedef void type; };
- template <typename T>
- struct point_coordinate_type_by_concept<T, gtl_yes> { typedef typename point_traits<T>::coordinate_type type; };
-
- template <typename T>
- struct point_coordinate_type {
- typedef typename point_coordinate_type_by_concept<T, typename is_point_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- template <typename T, typename CT>
- struct point_difference_type_by_concept { typedef void type; };
- template <typename T>
- struct point_difference_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename point_coordinate_type<T>::type>::coordinate_difference type; };
-
- template <typename T>
- struct point_difference_type {
- typedef typename point_difference_type_by_concept<
- T, typename is_point_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- template <typename T, typename CT>
- struct point_distance_type_by_concept { typedef void type; };
- template <typename T>
- struct point_distance_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename point_coordinate_type<T>::type>::coordinate_distance type; };
-
- template <typename T>
- struct point_distance_type {
- typedef typename point_distance_type_by_concept<
- T, typename is_point_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- struct y_pt_get : gtl_yes {};
-
- template <typename T>
- typename enable_if< typename gtl_and<y_pt_get, typename is_point_concept<typename geometry_concept<T>::type>::type>::type,
- typename point_coordinate_type<T>::type >::type
- get(const T& point, orientation_2d orient) {
- return point_traits<T>::get(point, orient);
- }
-
- struct y_pt_set : gtl_yes {};
-
- template <typename T, typename coordinate_type>
- typename enable_if< typename gtl_and<y_pt_set, typename is_mutable_point_concept<typename geometry_concept<T>::type>::type>::type,
- void>::type
- set(T& point, orientation_2d orient, coordinate_type value) {
- point_mutable_traits<T>::set(point, orient, value);
- }
-
- struct y_pt_construct : gtl_yes {};
-
- template <typename T, typename coordinate_type1, typename coordinate_type2>
- typename enable_if< typename gtl_and<y_pt_construct, typename is_mutable_point_concept<typename geometry_concept<T>::type>::type>::type,
- T>::type
- construct(coordinate_type1 x_value, coordinate_type2 y_value) {
- return point_mutable_traits<T>::construct(x_value, y_value);
- }
-
- struct y_pt_assign : gtl_yes {};
-
- template <typename T1, typename T2>
- typename enable_if<typename gtl_and_3<
- y_pt_assign,
- 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));
- return lvalue;
- }
-
- struct y_p_x : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_p_x, typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- typename point_coordinate_type<point_type>::type >::type
- x(const point_type& point) {
- return get(point, HORIZONTAL);
- }
-
- struct y_p_y : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_p_y, typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- typename point_coordinate_type<point_type>::type >::type
- y(const point_type& point) {
- return get(point, VERTICAL);
- }
-
- struct y_p_sx : gtl_yes {};
-
- template <typename point_type, typename coordinate_type>
- typename enable_if<typename gtl_and<y_p_sx, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- void>::type
- x(point_type& point, coordinate_type value) {
- set(point, HORIZONTAL, value);
- }
-
- struct y_p_sy : gtl_yes {};
-
- template <typename point_type, typename coordinate_type>
- typename enable_if<typename gtl_and<y_p_sy, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- void>::type
- y(point_type& point, coordinate_type value) {
- set(point, VERTICAL, value);
- }
-
- struct y_pt_equiv : gtl_yes {};
-
- template <typename T, typename T2>
- typename enable_if<typename gtl_and_3<y_pt_equiv,
- 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_coordinate_type<T>::type x1 = x(point1);
- typename point_coordinate_type<T2>::type x2 = get(point2, HORIZONTAL);
- typename point_coordinate_type<T>::type y1 = get(point1, VERTICAL);
- typename point_coordinate_type<T2>::type y2 = y(point2);
- return x1 == x2 && y1 == y2;
- }
-
- struct y_pt_man_dist : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<
- y_pt_man_dist,
- 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 point_difference_type<point_type_1>::type>::type
- manhattan_distance(const point_type_1& point1, const point_type_2& point2) {
- return euclidean_distance(point1, point2, HORIZONTAL) + euclidean_distance(point1, point2, VERTICAL);
- }
-
- struct y_pt_ed1 : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<y_pt_ed1, 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 point_difference_type<point_type_1>::type>::type
- euclidean_distance(const point_type_1& point1, const point_type_2& point2, orientation_2d orient) {
- typename coordinate_traits<typename point_coordinate_type<point_type_1>::type>::coordinate_difference return_value =
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_ed1,
+ typename is_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+typename point_difference_type<PointType1>::type>::type
+euclidean_distance(
+ const PointType1& point1,
+ const PointType2& point2,
+ orientation_2d orient) {
+ typename point_difference_type<PointType1>::type dif =
get(point1, orient) - get(point2, orient);
- return return_value < 0 ? (typename coordinate_traits<typename point_coordinate_type<point_type_1>::type>::coordinate_difference)-return_value : return_value;
- }
+ return (dif < 0) ? -dif : dif;
+}
- struct y_pt_ed2 : gtl_yes {};
+struct y_pt_eds : gtl_yes {};
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<y_pt_ed2, 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 point_distance_type<point_type_1>::type>::type
- euclidean_distance(const point_type_1& point1, const point_type_2& point2) {
- typedef typename point_coordinate_type<point_type_1>::type Unit;
- return std::sqrt((double)(distance_squared(point1, point2)));
- }
-
- struct y_pt_eds : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<
- y_pt_eds,
- 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 point_difference_type<point_type_1>::type>::type
- distance_squared(const point_type_1& point1, const point_type_2& point2) {
- typedef typename point_coordinate_type<point_type_1>::type Unit;
- typename coordinate_traits<Unit>::coordinate_difference dx = euclidean_distance(point1, point2, HORIZONTAL);
- typename coordinate_traits<Unit>::coordinate_difference dy = euclidean_distance(point1, point2, VERTICAL);
- dx *= dx;
- dy *= dy;
- return dx + dy;
- }
-
- struct y_pt_convolve : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<
- y_pt_convolve,
- 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));
- return lvalue;
- }
-
- struct y_pt_deconvolve : gtl_yes {};
-
- template <typename point_type_1, typename point_type_2>
- typename enable_if< typename gtl_and_3<
- y_pt_deconvolve,
- 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));
- return lvalue;
- }
-
- struct y_pt_scale_up : gtl_yes {};
-
- template <typename point_type, typename coord_type>
- typename enable_if< typename gtl_and<y_pt_scale_up, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale_up(point_type& point, coord_type factor) {
- typedef typename point_coordinate_type<point_type>::type Unit;
- x(point, x(point) * (Unit)factor);
- y(point, y(point) * (Unit)factor);
- return point;
- }
-
- struct y_pt_scale_down : gtl_yes {};
-
- template <typename point_type, typename coord_type>
- typename enable_if< typename gtl_and<y_pt_scale_down, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale_down(point_type& point, coord_type factor) {
- typedef typename point_coordinate_type<point_type>::type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- x(point, scaling_policy<Unit>::round((dt)((dt)(x(point)) / (dt)factor)));
- y(point, scaling_policy<Unit>::round((dt)((dt)(y(point)) / (dt)factor)));
- return point;
- }
-
- struct y_pt_scale : gtl_yes {};
-
- template <typename point_type, typename scaling_type>
- typename enable_if< typename gtl_and<y_pt_scale, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- scale(point_type& point, const scaling_type& scaling) {
- typedef typename point_coordinate_type<point_type>::type Unit;
- Unit x_(x(point)), y_(y(point));
- scaling.scale(x_, y_);
- x(point, x_);
- y(point, y_);
- return point;
- }
-
- struct y_pt_transform : gtl_yes {};
-
- template <typename point_type, typename transformation_type>
- typename enable_if< typename gtl_and<y_pt_transform, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- transform(point_type& point, const transformation_type& transformation) {
- typedef typename point_coordinate_type<point_type>::type Unit;
- Unit x_(x(point)), y_(y(point));
- transformation.transform(x_, y_);
- x(point, x_);
- y(point, y_);
- return point;
- }
-
- struct y_pt_move : gtl_yes {};
-
- template <typename point_type>
- typename enable_if< typename gtl_and<y_pt_move, typename is_mutable_point_concept<typename geometry_concept<point_type>::type>::type>::type,
- point_type>::type &
- move(point_type& point, orientation_2d orient,
- typename point_coordinate_type<point_type>::type displacement) {
- typedef typename point_coordinate_type<point_type>::type Unit;
- Unit v(get(point, orient));
- set(point, orient, v + displacement);
- return point;
- }
-
- template <class T>
- template <class T2>
- point_data<T>& point_data<T>::operator=(const T2& rvalue) {
- assign(*this, rvalue);
- return *this;
- }
-
- template <typename T>
- struct geometry_concept<point_data<T> > {
- typedef point_concept type;
- };
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_eds,
+ typename is_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+typename point_difference_type<PointType1>::type>::type
+distance_squared(const PointType1& point1, const PointType2& point2) {
+ typename point_difference_type<PointType1>::type dx =
+ euclidean_distance(point1, point2, HORIZONTAL);
+ typename point_difference_type<PointType1>::type dy =
+ euclidean_distance(point1, point2, VERTICAL);
+ dx *= dx;
+ dy *= dy;
+ return dx + dy;
}
+
+struct y_pt_ed2 : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_ed2,
+ typename is_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+typename point_distance_type<PointType1>::type>::type
+euclidean_distance(const PointType1& point1, const PointType2& point2) {
+ return (std::sqrt)(
+ static_cast<double>(distance_squared(point1, point2)));
}
-#endif
+
+struct y_pt_convolve : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_convolve,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+PointType1>::type& convolve(PointType1& lvalue, const PointType2& rvalue) {
+ x(lvalue, x(lvalue) + x(rvalue));
+ y(lvalue, y(lvalue) + y(rvalue));
+ return lvalue;
+}
+
+struct y_pt_deconvolve : gtl_yes {};
+
+template <typename PointType1, typename PointType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_pt_deconvolve,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType1>::type
+ >::type,
+ typename is_point_concept<
+ typename geometry_concept<PointType2>::type
+ >::type
+ >::type,
+PointType1>::type& deconvolve(PointType1& lvalue, const PointType2& rvalue) {
+ x(lvalue, x(lvalue) - x(rvalue));
+ y(lvalue, y(lvalue) - y(rvalue));
+ return lvalue;
+}
+
+struct y_pt_scale_up : gtl_yes {};
+
+template <typename PointType, typename CType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_scale_up,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type& scale_up(PointType& point, CType factor) {
+ typedef typename point_coordinate_type<PointType>::type Unit;
+ x(point, x(point) * (Unit)factor);
+ y(point, y(point) * (Unit)factor);
+ return point;
+}
+
+struct y_pt_scale_down : gtl_yes {};
+
+template <typename PointType, typename CType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_scale_down,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type& scale_down(PointType& point, CType factor) {
+ typedef typename point_coordinate_type<PointType>::type Unit;
+ typedef typename coordinate_traits<Unit>::coordinate_distance dt;
+ x(point, scaling_policy<Unit>::round((dt)(x(point)) / (dt)factor));
+ y(point, scaling_policy<Unit>::round((dt)(y(point)) / (dt)factor));
+ return point;
+}
+
+struct y_pt_scale : gtl_yes {};
+
+template <typename PointType, typename ScaleType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_scale,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type& scale(PointType& point, const ScaleType& scaling) {
+ typedef typename point_coordinate_type<PointType>::type Unit;
+ Unit x_coord(x(point));
+ Unit y_coord(y(point));
+ scaling.scale(x_coord, y_coord);
+ x(point, x_coord);
+ y(point, y_coord);
+ return point;
+}
+
+struct y_pt_transform : gtl_yes {};
+
+template <typename PointType, typename TransformType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_transform,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type& transform(PointType& point, const TransformType& transform) {
+ typedef typename point_coordinate_type<PointType>::type Unit;
+ Unit x_coord(x(point));
+ Unit y_coord(y(point));
+ transform.transform(x_coord, y_coord);
+ x(point, x_coord);
+ y(point, y_coord);
+ return point;
+}
+
+struct y_pt_move : gtl_yes {};
+
+template <typename PointType>
+typename enable_if<
+ typename gtl_and<
+ y_pt_move,
+ typename is_mutable_point_concept<
+ typename geometry_concept<PointType>::type
+ >::type
+ >::type,
+PointType>::type& move(PointType& point, orientation_2d orient,
+ typename point_coordinate_type<PointType>::type displacement) {
+ typedef typename point_coordinate_type<PointType>::type Unit;
+ Unit coord = get(point, orient);
+ set(point, orient, coord + displacement);
+ return point;
+}
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_POINT_CONCEPT_HPP
Modified: branches/release/boost/polygon/point_data.hpp
==============================================================================
--- branches/release/boost/polygon/point_data.hpp (original)
+++ branches/release/boost/polygon/point_data.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,104 +1,132 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library point_data.hpp header file
- 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 GTLPOINT_DATA_HPP
-#define GTLPOINT_DATA_HPP
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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 BOOST_POLYGON_POINT_DATA_HPP
+#define BOOST_POLYGON_POINT_DATA_HPP
#include "isotropy.hpp"
+#include "point_concept.hpp"
-namespace boost { namespace polygon{
+namespace boost {
+namespace polygon {
- template <typename T>
- class point_data {
- public:
- typedef T coordinate_type;
- inline point_data()
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- {}
- inline point_data(coordinate_type x, coordinate_type y)
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- {
- coords_[HORIZONTAL] = x; coords_[VERTICAL] = y;
- }
- inline point_data(const point_data& that)
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- { (*this) = that; }
- template <typename other>
- point_data(const other& that)
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- { (*this) = that; }
- inline point_data& operator=(const point_data& that) {
- coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; return *this;
- }
- template<typename T1, typename T2>
- inline point_data(const T1& x, const T2& y)
-#ifndef BOOST_POLYGON_MSVC
- :coords_()
-#endif
- {
- coords_[HORIZONTAL] = (coordinate_type)x;
- coords_[VERTICAL] = (coordinate_type)y;
- }
- template <typename T2>
- inline point_data(const point_data<T2>& rvalue)
+template <typename T>
+class point_data {
+ public:
+ typedef T coordinate_type;
+
+ point_data()
#ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
#endif
- {
- coords_[HORIZONTAL] = (coordinate_type)(rvalue.x());
- coords_[VERTICAL] = (coordinate_type)(rvalue.y());
- }
- template <typename T2>
- inline point_data& operator=(const T2& rvalue);
- inline bool operator==(const point_data& that) const {
- return coords_[0] == that.coords_[0] && coords_[1] == that.coords_[1];
- }
- inline bool operator!=(const point_data& that) const {
- return !((*this) == that);
- }
- inline bool operator<(const point_data& that) const {
- return coords_[0] < that.coords_[0] ||
- (coords_[0] == that.coords_[0] && coords_[1] < that.coords_[1]);
- }
- inline bool operator<=(const point_data& that) const { return !(that < *this); }
- inline bool operator>(const point_data& that) const { return that < *this; }
- inline bool operator>=(const point_data& that) const { return !((*this) < that); }
- inline coordinate_type get(orientation_2d orient) const {
- return coords_[orient.to_int()];
- }
- inline void set(orientation_2d orient, coordinate_type value) {
- coords_[orient.to_int()] = value;
- }
- inline coordinate_type x() const {
- return coords_[HORIZONTAL];
- }
- inline coordinate_type y() const {
- return coords_[VERTICAL];
- }
- inline point_data& x(coordinate_type value) {
- coords_[HORIZONTAL] = value;
- return *this;
- }
- inline point_data& y(coordinate_type value) {
- coords_[VERTICAL] = value;
- return *this;
- }
- private:
- coordinate_type coords_[2];
- };
+ {}
-}
-}
-#endif
+ point_data(coordinate_type x, coordinate_type y) {
+ coords_[HORIZONTAL] = x;
+ coords_[VERTICAL] = y;
+ }
+
+ explicit point_data(const point_data& that) {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ }
+
+ point_data& operator=(const point_data& that) {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ return *this;
+ }
+
+ // TODO(asydorchuk): Deprecated.
+ template <typename PointType>
+ explicit point_data(const PointType& that) {
+ *this = that;
+ }
+
+ // TODO(asydorchuk): Deprecated.
+ template <typename PointType>
+ point_data& operator=(const PointType& that) {
+ assign(*this, that);
+ return *this;
+ }
+
+ // TODO(asydorchuk): Deprecated.
+ template <typename CT>
+ point_data(const point_data<CT>& that) {
+ coords_[HORIZONTAL] = (coordinate_type)that.x();
+ coords_[VERTICAL] = (coordinate_type)that.y();
+ }
+
+ coordinate_type get(orientation_2d orient) const {
+ return coords_[orient.to_int()];
+ }
+
+ void set(orientation_2d orient, coordinate_type value) {
+ coords_[orient.to_int()] = value;
+ }
+
+ coordinate_type x() const {
+ return coords_[HORIZONTAL];
+ }
+
+ point_data& x(coordinate_type value) {
+ coords_[HORIZONTAL] = value;
+ return *this;
+ }
+
+ coordinate_type y() const {
+ return coords_[VERTICAL];
+ }
+
+ point_data& y(coordinate_type value) {
+ coords_[VERTICAL] = value;
+ return *this;
+ }
+
+ bool operator==(const point_data& that) const {
+ return (coords_[0] == that.coords_[0]) &&
+ (coords_[1] == that.coords_[1]);
+ }
+
+ bool operator!=(const point_data& that) const {
+ return !(*this == that);
+ }
+
+ bool operator<(const point_data& that) const {
+ return (coords_[0] < that.coords_[0]) ||
+ ((coords_[0] == that.coords_[0]) &&
+ (coords_[1] < that.coords_[1]));
+ }
+
+ bool operator<=(const point_data& that) const {
+ return !(that < *this);
+ }
+
+ bool operator>(const point_data& that) const {
+ return that < *this;
+ }
+
+ bool operator>=(const point_data& that) const {
+ return !(*this < that);
+ }
+
+ private:
+ coordinate_type coords_[2];
+};
+
+template <typename CType>
+struct geometry_concept< point_data<CType> > {
+ typedef point_concept type;
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_POINT_DATA_HPP
Modified: branches/release/boost/polygon/point_traits.hpp
==============================================================================
--- branches/release/boost/polygon/point_traits.hpp (original)
+++ branches/release/boost/polygon/point_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,34 +1,48 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library point_traits.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_POINT_TRAITS_HPP
#define BOOST_POLYGON_POINT_TRAITS_HPP
#include "isotropy.hpp"
-namespace boost { namespace polygon{
- template <typename T>
- struct point_traits {
- typedef typename T::coordinate_type coordinate_type;
-
- static inline coordinate_type get(const T& point, orientation_2d orient) {
- return point.get(orient);
- }
- };
-
- template <typename T>
- struct point_mutable_traits {
- static inline void set(T& point, orientation_2d orient, typename point_traits<T>::coordinate_type value) {
- point.set(orient, value);
- }
- static inline T construct(typename point_traits<T>::coordinate_type x_value, typename point_traits<T>::coordinate_type y_value) {
- return T(x_value, y_value);
- }
- };
-}
-}
-#endif
+namespace boost {
+namespace polygon {
+
+template <typename PointType>
+struct point_traits {
+ typedef PointType point_type;
+ typedef typename point_type::coordinate_type coordinate_type;
+
+ static coordinate_type get(
+ const point_type& point, orientation_2d orient) {
+ return point.get(orient);
+ }
+};
+
+template <typename PointType>
+struct point_mutable_traits {
+ typedef PointType point_type;
+ typedef typename point_type::coordinate_type coordinate_type;
+
+ static void set(
+ point_type& point, orientation_2d orient, coordinate_type value) {
+ point.set(orient, value);
+ }
+
+ static point_type construct(coordinate_type x, coordinate_type y) {
+ return point_type(x, y);
+ }
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_POINT_TRAITS_HPP
Modified: branches/release/boost/polygon/polygon.hpp
==============================================================================
--- branches/release/boost/polygon/polygon.hpp (original)
+++ branches/release/boost/polygon/polygon.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -16,13 +16,7 @@
#include "point_traits.hpp"
#include "point_concept.hpp"
-//point 3d
-#include "point_3d_data.hpp"
-#include "point_3d_traits.hpp"
-#include "point_3d_concept.hpp"
-
#include "transform.hpp"
-#include "detail/transform_detail.hpp"
//interval
#include "interval_data.hpp"
Modified: branches/release/boost/polygon/polygon_90_set_data.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_90_set_data.hpp (original)
+++ branches/release/boost/polygon/polygon_90_set_data.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -9,7 +9,6 @@
#define BOOST_POLYGON_POLYGON_90_SET_DATA_HPP
#include "isotropy.hpp"
#include "point_concept.hpp"
-#include "point_3d_concept.hpp"
#include "transform.hpp"
#include "interval_concept.hpp"
#include "rectangle_concept.hpp"
Modified: branches/release/boost/polygon/polygon_90_set_traits.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_90_set_traits.hpp (original)
+++ branches/release/boost/polygon/polygon_90_set_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -20,8 +20,6 @@
template <typename T>
struct traits_by_concept<T, point_concept> { typedef point_traits<T> type; };
template <typename T>
- struct traits_by_concept<T, point_3d_concept> { typedef point_3d_traits<T> type; };
- template <typename T>
struct traits_by_concept<T, rectangle_concept> { typedef rectangle_traits<T> type; };
template <typename T>
struct traits_by_concept<T, segment_concept> { typedef segment_traits<T> type; };
Modified: branches/release/boost/polygon/polygon_traits.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_traits.hpp (original)
+++ branches/release/boost/polygon/polygon_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1136,42 +1136,36 @@
typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
typedef typename polygon_traits<polygon_type>::iterator_type iterator;
typedef typename std::iterator_traits<iterator>::value_type point_type;
- iterator iter, iter_end;
- iter_end = end_points(polygon);
- iter = begin_points(polygon);
- point_type prev_pt = *iter;
- std::size_t num = size(polygon);
- std::size_t counts[2] = {0, 0};
- for(std::size_t i = 0; i < num; ++i) {
- if(i == num-1) iter = begin_points(polygon);
- else ++iter;
- point_type current_pt = *iter;
- if(x(current_pt) ==
- x(prev_pt)) {
- unsigned int index = x(current_pt) >
- x(point);
- std::size_t increment = 0;
- interval_data<coordinate_type> ivl(y(current_pt),
- y(prev_pt));
- if(contains(ivl, y(point), true)) {
- if(x(current_pt) ==
- x(point)) return consider_touch;
- ++increment;
- if(y(current_pt) !=
- y(point) &&
- y(prev_pt) !=
- y(point)) {
- ++increment;
+ coordinate_type point_x = x(point);
+ coordinate_type point_y = y(point);
+ bool inside = false;
+ for (iterator iter = begin_points(polygon); iter != end_points(polygon);) {
+ point_type curr_point = *iter;
+ ++iter;
+ point_type next_point = (iter == end_points(polygon)) ? *begin_points(polygon) : *iter;
+ if (x(curr_point) == x(next_point)) {
+ if (x(curr_point) > point_x) {
+ continue;
+ }
+ coordinate_type min_y = (std::min)(y(curr_point), y(next_point));
+ coordinate_type max_y = (std::max)(y(curr_point), y(next_point));
+ if (point_y > min_y && point_y < max_y) {
+ if (x(curr_point) == point_x) {
+ return consider_touch;
+ }
+ inside ^= true;
+ }
+ } else {
+ coordinate_type min_x = (std::min)(x(curr_point), x(next_point));
+ coordinate_type max_x = (std::max)(x(curr_point), x(next_point));
+ if (point_x >= min_x && point_x <= max_x) {
+ if (y(curr_point) == point_y) {
+ return consider_touch;
}
- counts[index] += increment;
}
}
- prev_pt = current_pt;
}
- //odd count implies boundary condition
- if(counts[0] % 2 || counts[1] % 2) return consider_touch;
- //an odd number of edges to the left implies interior pt
- return counts[winding(polygon) == COUNTERCLOCKWISE ? 0 : 1] % 4 != 0;
+ return inside;
}
//TODO: refactor to expose as user APIs
Modified: branches/release/boost/polygon/segment_concept.hpp
==============================================================================
--- branches/release/boost/polygon/segment_concept.hpp (original)
+++ branches/release/boost/polygon/segment_concept.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,23 +1,27 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library segment_concept.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_SEGMENT_CONCEPT_HPP
#define BOOST_POLYGON_SEGMENT_CONCEPT_HPP
#include "isotropy.hpp"
-#include "segment_data.hpp"
#include "segment_traits.hpp"
#include "rectangle_concept.hpp"
namespace boost {
namespace polygon {
+
struct segment_concept {};
-template <typename Segment>
+template <typename ConceptType>
struct is_segment_concept {
typedef gtl_no type;
};
@@ -27,7 +31,7 @@
typedef gtl_yes type;
};
-template <typename Segment>
+template <typename ConceptType>
struct is_mutable_segment_concept {
typedef gtl_no type;
};
@@ -37,64 +41,64 @@
typedef gtl_yes type;
};
-template <typename Segment, typename CT>
+template <typename GeometryType, typename BoolType>
struct segment_distance_type_by_concept {
typedef void type;
};
-template <typename Segment>
-struct segment_distance_type_by_concept<Segment, gtl_yes> {
+template <typename GeometryType>
+struct segment_distance_type_by_concept<GeometryType, gtl_yes> {
typedef typename coordinate_traits<
- typename segment_traits<Segment>::coordinate_type
+ typename segment_traits<GeometryType>::coordinate_type
>::coordinate_distance type;
};
-template <typename Segment>
+template <typename GeometryType>
struct segment_distance_type {
typedef typename segment_distance_type_by_concept<
- Segment,
+ GeometryType,
typename is_segment_concept<
- typename geometry_concept<Segment>::type
+ typename geometry_concept<GeometryType>::type
>::type
>::type type;
};
-template <typename Segment, typename CT>
+template <typename GeometryType, typename BoolType>
struct segment_point_type_by_concept {
typedef void type;
};
-template <typename Segment>
-struct segment_point_type_by_concept<Segment, gtl_yes> {
- typedef typename segment_traits<Segment>::point_type type;
+template <typename GeometryType>
+struct segment_point_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename segment_traits<GeometryType>::point_type type;
};
-template <typename Segment>
+template <typename GeometryType>
struct segment_point_type {
typedef typename segment_point_type_by_concept<
- Segment,
+ GeometryType,
typename is_segment_concept<
- typename geometry_concept<Segment>::type
+ typename geometry_concept<GeometryType>::type
>::type
>::type type;
};
-template <typename Segment, typename CT>
+template <typename GeometryType, typename BoolType>
struct segment_coordinate_type_by_concept {
typedef void type;
};
-template <typename Segment>
-struct segment_coordinate_type_by_concept<Segment, gtl_yes> {
- typedef typename segment_traits<Segment>::coordinate_type type;
+template <typename GeometryType>
+struct segment_coordinate_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename segment_traits<GeometryType>::coordinate_type type;
};
-template <typename Segment>
+template <typename GeometryType>
struct segment_coordinate_type {
typedef typename segment_coordinate_type_by_concept<
- Segment,
+ GeometryType,
typename is_segment_concept<
- typename geometry_concept<Segment>::type
+ typename geometry_concept<GeometryType>::type
>::type
>::type type;
};
@@ -109,8 +113,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- typename segment_point_type<Segment>::type
->::type
+typename segment_point_type<Segment>::type>::type
get(const Segment& segment, direction_1d dir) {
return segment_traits<Segment>::get(segment, dir);
}
@@ -128,9 +131,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- void
->::type
-set(Segment& segment, direction_1d dir, const Point& point) {
+void>::type set(Segment& segment, direction_1d dir, const Point& point) {
segment_mutable_traits<Segment>::set(segment, dir, point);
}
@@ -150,9 +151,7 @@
typename geometry_concept<Point2>::type
>::type
>::type,
- Segment
->::type
-construct(const Point1& low, const Point2& high) {
+Segment>::type construct(const Point1& low, const Point2& high) {
return segment_mutable_traits<Segment>::construct(low, high);
}
@@ -169,9 +168,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- Segment1
->::type
-copy_construct(const Segment2& segment) {
+Segment1>::type copy_construct(const Segment2& segment) {
return construct<Segment1>(get(segment, LOW), get(segment, HIGH));
}
@@ -188,9 +185,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- Segment1
->::type &
-assign(Segment1& segment1, const Segment2& segment2) {
+Segment1>::type& assign(Segment1& segment1, const Segment2& segment2) {
return segment1 = copy_construct<Segment1>(segment2);
}
@@ -207,9 +202,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- bool
->::type
-equivalence(const Segment1& segment1, const Segment2& segment2) {
+bool>::type equivalence(const Segment1& segment1, const Segment2& segment2) {
return get(segment1, LOW) == get(segment2, LOW) &&
get(segment1, HIGH) == get(segment2, HIGH);
}
@@ -224,9 +217,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- typename segment_point_type<Segment>::type
->::type
-low(const Segment& segment) {
+typename segment_point_type<Segment>::type>::type low(const Segment& segment) {
return get(segment, LOW);
}
@@ -240,9 +231,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- typename segment_point_type<Segment>::type
->::type
-high(const Segment& segment) {
+typename segment_point_type<Segment>::type>::type high(const Segment& segment) {
return get(segment, HIGH);
}
@@ -256,8 +245,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- typename segment_point_type<Segment>::type
->::type
+typename segment_point_type<Segment>::type>::type
center(const Segment& segment) {
return construct<typename segment_point_type<Segment>::type>(
(x(high(segment)) + x(low(segment)))/2,
@@ -277,9 +265,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- void
->::type
-low(Segment& segment, const Point& point) {
+void>::type low(Segment& segment, const Point& point) {
set(segment, LOW, point);
}
@@ -296,9 +282,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- void
->::type
-high(Segment& segment, const Point& point) {
+void>::type high(Segment& segment, const Point& point) {
set(segment, HIGH, point);
}
@@ -316,9 +300,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- int
->::type
-orientation(const Segment1& segment1, const Segment2& segment2) {
+int>::type orientation(const Segment1& segment1, const Segment2& segment2) {
typedef typename coordinate_traits<
typename segment_traits<Segment1>::coordinate_type
>::manhattan_area_type int_x2;
@@ -360,9 +342,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- int
->::type
-orientation(const Segment& segment, const Point& point) {
+int>::type orientation(const Segment& segment, const Point& point) {
Segment segment2 = construct<Segment>(high(segment), point);
return orientation(segment, segment2);
}
@@ -380,11 +360,8 @@
typename geometry_concept<Point>::type
>::type
>::type,
- bool
->::type
-contains(const Segment& segment,
- const Point& point,
- bool consider_touch = true ) {
+bool>::type contains(const Segment& segment,
+ const Point& point, bool consider_touch = true ) {
if (orientation(segment, point))
return false;
rectangle_data<typename segment_coordinate_type<Segment>::type> rect;
@@ -411,11 +388,8 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- bool
->::type
-contains(const Segment1& segment1,
- const Segment2& segment2,
- bool consider_touch = true) {
+bool>::type contains(const Segment1& segment1,
+ const Segment2& segment2, bool consider_touch = true) {
return contains(segment1, get(segment2, LOW), consider_touch) &&
contains(segment1, get(segment2, HIGH), consider_touch);
}
@@ -430,8 +404,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- typename segment_distance_type<Segment>::type
->::type
+typename segment_distance_type<Segment>::type>::type
length(const Segment& segment) {
return euclidean_distance(low(segment), high(segment));
}
@@ -446,12 +419,10 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- Segment
->::type &
-scale_up(Segment& segment,
- typename coordinate_traits<
- typename segment_coordinate_type<Segment>::type
- >::unsigned_area_type factor) {
+Segment>::type& scale_up(Segment& segment,
+ typename coordinate_traits<
+ typename segment_coordinate_type<Segment>::type
+ >::unsigned_area_type factor) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, scale_up(l, factor));
@@ -469,12 +440,10 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- Segment
->::type &
-scale_down(Segment& segment,
- typename coordinate_traits<
- typename segment_coordinate_type<Segment>::type
- >::unsigned_area_type factor) {
+Segment>::type& scale_down(Segment& segment,
+ typename coordinate_traits<
+ typename segment_coordinate_type<Segment>::type
+ >::unsigned_area_type factor) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, scale_down(l, factor));
@@ -492,9 +461,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- Segment
->::type &
-scale(Segment& segment, const Scale& sc) {
+Segment>::type& scale(Segment& segment, const Scale& sc) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, scale(l, sc));
@@ -512,9 +479,7 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- Segment
->::type &
-transform(Segment& segment, const Transform& tr) {
+Segment>::type& transform(Segment& segment, const Transform& tr) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, transform(l, tr));
@@ -532,10 +497,8 @@
typename geometry_concept<Segment>::type
>::type
>::type,
- Segment
->::type &
-move(Segment& segment, orientation_2d orient,
- typename segment_coordinate_type<Segment>::type displacement) {
+Segment>::type& move(Segment& segment, orientation_2d orient,
+ typename segment_coordinate_type<Segment>::type displacement) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, move(l, orient, displacement));
@@ -556,9 +519,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- Segment
->::type &
-convolve(Segment& segment, const Point& point) {
+Segment>::type& convolve(Segment& segment, const Point& point) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, convolve(l, point));
@@ -579,9 +540,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- Segment
->::type &
-deconvolve(Segment& segment, const Point& point) {
+Segment>::type& deconvolve(Segment& segment, const Point& point) {
typename segment_point_type<Segment>::type l = low(segment);
typename segment_point_type<Segment>::type h = high(segment);
low(segment, deconvolve(l, point));
@@ -602,9 +561,8 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- bool
->::type
-abuts(const Segment1& segment1, const Segment2& segment2, direction_1d dir) {
+bool>::type abuts(const Segment1& segment1,
+ const Segment2& segment2, direction_1d dir) {
return dir.to_int() ? equivalence(low(segment2) , high(segment1)) :
equivalence(low(segment1) , high(segment2));
}
@@ -622,9 +580,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- bool
->::type
-abuts(const Segment1& segment1, const Segment2& segment2) {
+bool>::type abuts(const Segment1& segment1, const Segment2& segment2) {
return abuts(segment1, segment2, HIGH) || abuts(segment1, segment2, LOW);
}
@@ -641,10 +597,9 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- bool
->::type
-intersects(const Segment1& segment1, const Segment2& segment2,
- bool consider_touch = true) {
+bool
+>::type intersects(const Segment1& segment1, const Segment2& segment2,
+ bool consider_touch = true) {
rectangle_data<typename segment_coordinate_type<Segment1>::type> rect1, rect2;
set_points(rect1, low(segment1), high(segment1));
set_points(rect2, low(segment2), high(segment2));
@@ -680,8 +635,7 @@
typename geometry_concept<Point>::type
>::type
>::type,
- typename segment_distance_type<Segment>::type
->::type
+typename segment_distance_type<Segment>::type>::type
euclidean_distance(const Segment& segment, const Point& point) {
typedef typename segment_distance_type<Segment>::type Unit;
Unit x1 = x(low(segment));
@@ -721,8 +675,7 @@
typename geometry_concept<Segment2>::type
>::type
>::type,
- typename segment_distance_type<Segment1>::type
->::type
+typename segment_distance_type<Segment1>::type>::type
euclidean_distance(const Segment1& segment1, const Segment2& segment2) {
if (intersects(segment1, segment2))
return 0.0;
@@ -737,18 +690,7 @@
result3 = result4;
return (result1 < result3) ? result1 : result3;
}
+} // polygon
+} // boost
-template <class T>
-template <class Segment>
-segment_data<T>& segment_data<T>::operator=(const Segment& rvalue) {
- assign(*this, rvalue);
- return *this;
-}
-
-template <typename T>
-struct geometry_concept<segment_data<T> > {
- typedef segment_concept type;
-};
-}
-}
-#endif
+#endif // BOOST_POLYGON_SEGMENT_CONCEPT_HPP
Modified: branches/release/boost/polygon/segment_data.hpp
==============================================================================
--- branches/release/boost/polygon/segment_data.hpp (original)
+++ branches/release/boost/polygon/segment_data.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,108 +1,115 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library segment_data.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_SEGMENT_DATA_HPP
#define BOOST_POLYGON_SEGMENT_DATA_HPP
#include "isotropy.hpp"
+#include "segment_concept.hpp"
namespace boost {
namespace polygon {
+
template <typename T>
class segment_data {
public:
typedef T coordinate_type;
typedef point_data<T> point_type;
- inline segment_data()
+ segment_data()
#ifndef BOOST_POLYGON_MSVC
- :points_()
+ : points_()
#endif
{}
- inline segment_data(const point_type& low, const point_type& high)
-#ifndef BOOST_POLYGON_MSVC
- :points_()
-#endif
- {
+ segment_data(const point_type& low, const point_type& high) {
points_[LOW] = low;
points_[HIGH] = high;
}
- inline segment_data(const segment_data& that)
-#ifndef BOOST_POLYGON_MSVC
- :points_()
-#endif
- {
- (*this) = that;
+ segment_data(const segment_data& that) {
+ points_[0] = that.points_[0];
+ points_[1] = that.points_[1];
}
- inline segment_data& operator=(const segment_data& that) {
+ segment_data& operator=(const segment_data& that) {
points_[0] = that.points_[0];
points_[1] = that.points_[1];
return *this;
}
- template <typename Segment>
- inline segment_data& operator=(const Segment& that);
-
- inline point_type get(direction_1d dir) const {
+ point_type get(direction_1d dir) const {
return points_[dir.to_int()];
}
- inline void set(direction_1d dir, const point_type& point) {
+ void set(direction_1d dir, const point_type& point) {
points_[dir.to_int()] = point;
}
- inline point_type low() const { return points_[0]; }
+ point_type low() const {
+ return points_[LOW];
+ }
- inline segment_data& low(const point_type& point) {
- points_[0] = point;
+ segment_data& low(const point_type& point) {
+ points_[LOW] = point;
return *this;
}
- inline point_type high() const {return points_[1]; }
+ point_type high() const {
+ return points_[HIGH];
+ }
- inline segment_data& high(const point_type& point) {
- points_[1] = point;
+ segment_data& high(const point_type& point) {
+ points_[HIGH] = point;
return *this;
}
- inline bool operator==(const segment_data& that) const {
- return low() == that.low() && high() == that.high();
+ bool operator==(const segment_data& that) const {
+ return (points_[0] == that.points_[0]) &&
+ (points_[1] == that.points_[1]);
}
- inline bool operator!=(const segment_data& that) const {
- return low() != that.low() || high() != that.high();
+ bool operator!=(const segment_data& that) const {
+ return (points_[0] != that.points_[0]) ||
+ (points_[1] != that.points_[1]);
}
- inline bool operator<(const segment_data& that) const {
- if (points_[0] < that.points_[0])
- return true;
- if (points_[0] > that.points_[0])
- return false;
+ bool operator<(const segment_data& that) const {
+ if (points_[0] != that.points_[0]) {
+ points_[0] < that.points_[0];
+ }
return points_[1] < that.points_[1];
}
- inline bool operator<=(const segment_data& that) const {
+ bool operator<=(const segment_data& that) const {
return !(that < *this);
}
- inline bool operator>(const segment_data& that) const {
+ bool operator>(const segment_data& that) const {
return that < *this;
}
- inline bool operator>=(const segment_data& that) const {
+ bool operator>=(const segment_data& that) const {
return !((*this) < that);
}
private:
point_type points_[2];
};
-}
-}
-#endif
+
+template <typename CType>
+struct geometry_concept<segment_data<CType> > {
+ typedef segment_concept type;
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_SEGMENT_DATA_HPP
Modified: branches/release/boost/polygon/segment_traits.hpp
==============================================================================
--- branches/release/boost/polygon/segment_traits.hpp (original)
+++ branches/release/boost/polygon/segment_traits.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,38 +1,50 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library segment_traits.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_SEGMENT_TRAITS_HPP
#define BOOST_POLYGON_SEGMENT_TRAITS_HPP
+
+#include "isotropy.hpp"
+
namespace boost {
namespace polygon {
- template <typename Segment>
- struct segment_traits {
- typedef typename Segment::coordinate_type coordinate_type;
- typedef typename Segment::point_type point_type;
-
- static inline point_type get(const Segment& segment, direction_1d dir) {
- return segment.get(dir);
- }
- };
-
- template <typename Segment>
- struct segment_mutable_traits {
- typedef typename segment_traits<Segment>::point_type point_type;
-
- static inline void set(
- Segment& segment, direction_1d dir, const point_type& point) {
- segment.set(dir, point);
- }
-
- static inline Segment construct(
- const point_type& low, const point_type& high) {
- return Segment(low, high);
- }
- };
-}
-}
-#endif
+
+template <typename Segment>
+struct segment_traits {
+ typedef Segment segment_type;
+ typedef typename segment_type::point_type point_type;
+ typedef typename segment_type::coordinate_type coordinate_type;
+
+ static point_type get(
+ const segment_type& segment, direction_1d dir) {
+ return segment.get(dir);
+ }
+};
+
+template <typename Segment>
+struct segment_mutable_traits {
+ typedef Segment segment_type;
+ typedef typename segment_type::point_type point_type;
+ typedef typename segment_type::coordinate_type coordinate_type;
+
+ static void set(
+ segment_type& segment, direction_1d dir, const point_type& point) {
+ segment.set(dir, point);
+ }
+
+ static segment_type construct(const point_type& low, const point_type& high) {
+ return segment_type(low, high);
+ }
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_SEGMENT_TRAITS_HPP
Modified: branches/release/boost/polygon/transform.hpp
==============================================================================
--- branches/release/boost/polygon/transform.hpp (original)
+++ branches/release/boost/polygon/transform.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,195 +1,58 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library point_data.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
- 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 BOOST_POLYGON_TRANSFORM_HPP
#define BOOST_POLYGON_TRANSFORM_HPP
+
#include "isotropy.hpp"
-#include "point_3d_concept.hpp"
-namespace boost { namespace polygon{
-// Transformation of Coordinate Systems
+
+namespace boost {
+namespace polygon {
+// Transformation of Coordinate System.
// Enum meaning:
-// Select which direction_3d to change the positive direction of each
+// Select which direction_2d 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
+// The first direction_2d 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
+// The second direction_2d 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
+// 000 EAST NORTH
+// 001 WEST NORTH
+// 010 EAST SOUTH
+// 011 WEST SOUTH
+// 100 NORTH EAST
+// 101 SOUTH EAST
+// 110 NORTH WEST
+// 111 SOUTH WEST
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
+ public:
enum ATR {
- 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, FLIP_XY = 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, ROTATE_LEFT = 5,
- NWU = 6, NORTH_WEST_UP = 6, NW = 6, NORTH_WEST = 6, ROTATE_RIGHT = 6,
- SWU = 7, SOUTH_WEST_UP = 7, SW = 7, SOUTH_WEST = 7, FLIP_SWAP_XY = 7, END_2D_TRANSFORM = 7,
- END = 8, EAST_NORTH_DOWN = 8, FLIP_Z = 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
+ NULL_TRANSFORM = 0,
+ BEGIN_TRANSFORM = 0,
+ EN = 0, EAST_NORTH = 0,
+ WN = 1, WEST_NORTH = 1, FLIP_X = 1,
+ ES = 2, EAST_SOUTH = 2, FLIP_Y = 2,
+ WS = 3, WEST_SOUTH = 3, FLIP_XY = 3,
+ NE = 4, NORTH_EAST = 4, SWAP_XY = 4,
+ SE = 5, SOUTH_EAST = 5, ROTATE_LEFT = 5,
+ NW = 6, NORTH_WEST = 6, ROTATE_RIGHT = 6,
+ SW = 7, SOUTH_WEST = 7, FLIP_SWAP_XY = 7,
+ END_TRANSFORM = 7
};
// Individual axis enum values indicate which axis an implicit individual
@@ -205,296 +68,399 @@
// NX: map to negative x axis
// PY: map to positive y axis
// NY: map to negative y axis
- // PZ: map to positive z axis
- // NZ: map to negative z axis
enum INDIVIDUAL_AXIS {
PX = 0,
NX = 1,
PY = 2,
- NY = 3,
- PZ = 4,
- NZ = 5
+ NY = 3
};
- inline axis_transformation() : atr_(NULL_TRANSFORM) {}
- inline axis_transformation(ATR atr) : atr_(atr) {}
- inline axis_transformation(const axis_transformation& atr) : atr_(atr.atr_) {}
- explicit axis_transformation(const orientation_3d& orient);
- explicit axis_transformation(const direction_3d& dir);
- explicit axis_transformation(const orientation_2d& orient);
- explicit axis_transformation(const direction_2d& dir);
+ axis_transformation() : atr_(NULL_TRANSFORM) {}
+ explicit axis_transformation(ATR atr) : atr_(atr) {}
+ axis_transformation(const axis_transformation& atr) : atr_(atr.atr_) {}
+
+ explicit axis_transformation(const orientation_2d& orient) {
+ const ATR tmp[2] = {
+ NORTH_EAST, // sort x, then y
+ EAST_NORTH // sort y, then x
+ };
+ atr_ = tmp[orient.to_int()];
+ }
+
+ explicit axis_transformation(const direction_2d& dir) {
+ const ATR tmp[4] = {
+ SOUTH_EAST, // sort x, then y
+ NORTH_EAST, // sort x, then y
+ EAST_SOUTH, // sort y, then x
+ EAST_NORTH // sort y, then x
+ };
+ atr_ = tmp[dir.to_int()];
+ }
// assignment operator
- axis_transformation& operator=(const axis_transformation& a);
+ axis_transformation& operator=(const axis_transformation& a) {
+ atr_ = a.atr_;
+ return *this;
+ }
// assignment operator
- axis_transformation& operator=(const ATR& atr);
+ axis_transformation& operator=(const ATR& atr) {
+ atr_ = atr;
+ return *this;
+ }
// equivalence operator
- bool operator==(const axis_transformation& a) const;
+ bool operator==(const axis_transformation& a) const {
+ return atr_ == a.atr_;
+ }
// inequivalence operator
- bool operator!=(const axis_transformation& a) const;
+ bool operator!=(const axis_transformation& a) const {
+ return !(*this == a);
+ }
// ordering
- bool operator<(const axis_transformation& a) const;
-
- // concatenation operator
- axis_transformation operator+(const axis_transformation& a) const;
+ bool operator<(const axis_transformation& a) const {
+ return atr_ < a.atr_;
+ }
// concatenate this with that
- axis_transformation& operator+=(const axis_transformation& a);
+ axis_transformation& operator+=(const axis_transformation& a) {
+ bool abit2 = (a.atr_ & 4) != 0;
+ bool abit1 = (a.atr_ & 2) != 0;
+ bool abit0 = (a.atr_ & 1) != 0;
+ bool bit2 = (atr_ & 4) != 0;
+ bool bit1 = (atr_ & 2) != 0;
+ bool bit0 = (atr_ & 1) != 0;
+ int indexes[2][2] = {
+ { (int)bit2, (int)(!bit2) },
+ { (int)abit2, (int)(!abit2) }
+ };
+ int zero_bits[2][2] = {
+ {bit0, bit1}, {abit0, abit1}
+ };
+ int nbit1 = zero_bits[0][1] ^ zero_bits[1][indexes[0][1]];
+ int nbit0 = zero_bits[0][0] ^ zero_bits[1][indexes[0][0]];
+ indexes[0][0] = indexes[1][indexes[0][0]];
+ indexes[0][1] = indexes[1][indexes[0][1]];
+ int nbit2 = indexes[0][0] & 1; // swap xy
+ atr_ = (ATR)((nbit2 << 2) + (nbit1 << 1) + nbit0);
+ return *this;
+ }
+
+ // concatenation operator
+ axis_transformation operator+(const axis_transformation& a) const {
+ axis_transformation retval(*this);
+ return retval+=a;
+ }
// 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
- inline void get_directions(direction_2d& horizontal_dir,
- direction_2d& vertical_dir) const {
+ void populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const {
bool bit2 = (atr_ & 4) != 0;
bool bit1 = (atr_ & 2) != 0;
bool bit0 = (atr_ & 1) != 0;
- vertical_dir = direction_2d((direction_2d_enum)(((int)(!bit2) << 1) + !bit1));
- horizontal_dir = direction_2d((direction_2d_enum)(((int)(bit2) << 1) + !bit0));
+ axis_array[1] = (INDIVIDUAL_AXIS)(((int)(!bit2) << 1) + bit1);
+ axis_array[0] = (INDIVIDUAL_AXIS)(((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
- inline void get_directions(direction_3d& horizontal_dir,
- direction_3d& vertical_dir,
- direction_3d& proximal_dir) const {
- bool bit5 = (atr_ & 32) != 0;
- bool bit4 = (atr_ & 16) != 0;
- bool bit3 = (atr_ & 8) != 0;
+ void get_directions(direction_2d& horizontal_dir,
+ direction_2d& vertical_dir) const {
bool bit2 = (atr_ & 4) != 0;
bool bit1 = (atr_ & 2) != 0;
bool bit0 = (atr_ & 1) != 0;
- proximal_dir = direction_3d((direction_2d_enum)((((int)(!bit4 & !bit5)) << 2) +
- ((int)(bit5) << 1) +
- !bit3));
- vertical_dir = direction_3d((direction_2d_enum)((((int)((bit4 & bit2) | (bit5 & !bit2))) << 2)+
- ((int)(!bit5 & !bit2) << 1) +
- !bit1));
- horizontal_dir = direction_3d((direction_2d_enum)((((int)((bit5 & bit2) |
- (bit4 & !bit2))) << 2) +
- ((int)(bit2 & !bit5) << 1) +
- !bit0));
+ vertical_dir = direction_2d((direction_2d_enum)(((int)(!bit2) << 1) + !bit1));
+ horizontal_dir = direction_2d((direction_2d_enum)(((int)(bit2) << 1) + !bit0));
}
// 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[]);
+ static void combine_axis_arrays(INDIVIDUAL_AXIS this_array[],
+ const INDIVIDUAL_AXIS that_array[]) {
+ int indexes[2] = { this_array[0] >> 1, this_array[1] >> 1 };
+ int zero_bits[2][2] = {
+ { this_array[0] & 1, this_array[1] & 1 },
+ { that_array[0] & 1, that_array[1] & 1 }
+ };
+ this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] |
+ ((int)zero_bits[0][0] ^
+ (int)zero_bits[1][indexes[0]]));
+ this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] |
+ ((int)zero_bits[0][1] ^
+ (int)zero_bits[1][indexes[1]]));
+ }
// write_back_axis_array converts an array of three INDIVIDUAL_AXIS values
// to the ATR enum value and sets 'this' to that value
- void write_back_axis_array(const INDIVIDUAL_AXIS this_array[]);
+ void write_back_axis_array(const INDIVIDUAL_AXIS this_array[]) {
+ int bit2 = ((int)this_array[0] & 2) != 0; // swap xy
+ int bit1 = ((int)this_array[1] & 1);
+ int bit0 = ((int)this_array[0] & 1);
+ atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
+ }
// behavior is deterministic but undefined in the case where illegal
// combinations of directions are passed in.
axis_transformation& set_directions(const direction_2d& horizontal_dir,
- const direction_2d& vertical_dir);
- // behavior is deterministic but undefined in the case where illegal
- // combinations of directions are passed in.
- axis_transformation& set_directions(const direction_3d& horizontal_dir,
- const direction_3d& vertical_dir,
- const direction_3d& proximal_dir);
-
- // 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;
+ const direction_2d& vertical_dir) {
+ int bit2 = (static_cast<orientation_2d>(horizontal_dir).to_int()) != 0;
+ int bit1 = !(vertical_dir.to_int() & 1);
+ int bit0 = !(horizontal_dir.to_int() & 1);
+ atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
+ return *this;
+ }
// 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
- axis_transformation& invert_2d();
-
- // get the inverse of the 2D portion of this
- axis_transformation inverse_2d() const;
+ void transform(coordinate_type& x, coordinate_type& y) const {
+ int bit2 = (atr_ & 4) != 0;
+ int bit1 = (atr_ & 2) != 0;
+ int bit0 = (atr_ & 1) != 0;
+ x *= -((bit0 << 1) - 1);
+ y *= -((bit1 << 1) - 1);
+ predicated_swap(bit2 != 0, x, y);
+ }
// invert this axis_transformation
- axis_transformation& invert();
+ axis_transformation& invert() {
+ int bit2 = ((atr_ & 4) != 0);
+ int bit1 = ((atr_ & 2) != 0);
+ int bit0 = ((atr_ & 1) != 0);
+ // swap bit 0 and bit 1 if bit2 is 1
+ predicated_swap(bit2 != 0, bit0, bit1);
+ bit1 = bit1 << 1;
+ atr_ = (ATR)(atr_ & (32+16+8+4)); // mask away bit0 and bit1
+ atr_ = (ATR)(atr_ | bit0 | bit1);
+ return *this;
+ }
// get the inverse axis_transformation of this
- axis_transformation inverse() const;
-
- //friend std::ostream& operator<< (std::ostream& o, const axis_transformation& r);
- //friend std::istream& operator>> (std::istream& i, axis_transformation& r);
+ axis_transformation inverse() const {
+ axis_transformation retval(*this);
+ return retval.invert();
+ }
-private:
+ private:
ATR atr_;
};
-
-// 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.
template <typename scale_factor_type>
class anisotropic_scale_factor {
-public:
- inline anisotropic_scale_factor()
-#ifndef BOOST_POLYGON_MSVC
- : scale_()
-#endif
- {
+ public:
+ anisotropic_scale_factor() {
scale_[0] = 1;
scale_[1] = 1;
- scale_[2] = 1;
- }
- inline anisotropic_scale_factor(scale_factor_type xscale, scale_factor_type yscale)
-#ifndef BOOST_POLYGON_MSVC
- : scale_()
-#endif
- {
- scale_[0] = xscale;
- scale_[1] = yscale;
- scale_[2] = 1;
}
- inline anisotropic_scale_factor(scale_factor_type xscale, scale_factor_type yscale, scale_factor_type zscale)
-#ifndef BOOST_POLYGON_MSVC
- : scale_()
-#endif
- {
+ anisotropic_scale_factor(scale_factor_type xscale,
+ scale_factor_type yscale) {
scale_[0] = xscale;
scale_[1] = yscale;
- scale_[2] = zscale;
}
// 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)); }
+ scale_factor_type get(orientation_2d orient) const {
+ return scale_[orient.to_int()];
+ }
// 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); }
+ void set(orientation_2d orient, scale_factor_type value) {
+ scale_[orient.to_int()] = value;
+ }
+
+ scale_factor_type x() const {
+ return scale_[HORIZONTAL];
+ }
+
+ scale_factor_type y() const {
+ return scale_[VERTICAL];
+ }
- scale_factor_type x() const;
- scale_factor_type y() const;
- scale_factor_type z() const;
- void x(scale_factor_type value);
- void y(scale_factor_type value);
- void z(scale_factor_type value);
+ void x(scale_factor_type value) {
+ scale_[HORIZONTAL] = value;
+ }
+
+ void y(scale_factor_type value) {
+ scale_[VERTICAL] = value;
+ }
// concatination operator (convolve scale factors)
- anisotropic_scale_factor operator+(const anisotropic_scale_factor& s) const;
+ anisotropic_scale_factor operator+(const anisotropic_scale_factor& s) const {
+ anisotropic_scale_factor<scale_factor_type> retval(*this);
+ return retval += s;
+ }
// concatinate this with that
- const anisotropic_scale_factor& operator+=(const anisotropic_scale_factor& s);
+ const anisotropic_scale_factor& operator+=(
+ const anisotropic_scale_factor& s) {
+ scale_[0] *= s.scale_[0];
+ scale_[1] *= s.scale_[1];
+ return *this;
+ }
// transform this scale with an axis_transform
- anisotropic_scale_factor& transform(axis_transformation atr);
+ anisotropic_scale_factor& transform(axis_transformation atr) {
+ direction_2d dirs[2];
+ atr.get_directions(dirs[0], dirs[1]);
+ scale_factor_type tmp[2] = {scale_[0], scale_[1]};
+ for (int i = 0; i < 2; ++i) {
+ scale_[orientation_2d(dirs[i]).to_int()] = tmp[i];
+ }
+ return *this;
+ }
// scale the two coordinates
template <typename coordinate_type>
- void scale(coordinate_type& x, coordinate_type& y) const;
-
- // scale the three coordinates
- template <typename coordinate_type>
- void scale(coordinate_type& x, coordinate_type& y, coordinate_type& z) const;
+ void scale(coordinate_type& x, coordinate_type& y) const {
+ x = scaling_policy<coordinate_type>::round(
+ (scale_factor_type)x * get(HORIZONTAL));
+ y = scaling_policy<coordinate_type>::round(
+ (scale_factor_type)y * get(HORIZONTAL));
+ }
// invert this scale factor to give the reverse scale factor
- anisotropic_scale_factor& invert();
-
-private:
- scale_factor_type scale_[3];
+ anisotropic_scale_factor& invert() {
+ x(1/x());
+ y(1/y());
+ return *this;
+ }
- //friend std::ostream& operator<< (std::ostream& o, const Scale& r);
- //friend std::istream& operator>> (std::istream& i, Scale& r);
+ private:
+ scale_factor_type scale_[2];
};
-// 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 and provides services for transformations.
+// Consits of axis transformation, scale factor and translation.
+// The tranlation is the position of the origin of the new coordinate system of
+// in the old system. Coordinates are scaled before they are transformed.
template <typename coordinate_type>
class transformation {
-public:
- transformation();
- transformation(axis_transformation atr);
- transformation(axis_transformation::ATR atr);
+ public:
+ transformation() : atr_(), p_(0, 0) {}
+ explicit transformation(axis_transformation atr) : atr_(atr), p_(0, 0) {}
+ explicit transformation(axis_transformation::ATR atr) : atr_(atr), p_(0, 0) {}
+ transformation(const transformation& tr) : atr_(tr.atr_), p_(tr.p_) {}
+
template <typename point_type>
- transformation(const point_type& p);
+ explicit transformation(const point_type& p) : atr_(), p_(0, 0) {
+ set_translation(p);
+ }
+
template <typename point_type>
- transformation(axis_transformation atr, const point_type& p);
+ transformation(axis_transformation atr,
+ const point_type& p) : atr_(atr), p_(0, 0) {
+ set_translation(p);
+ }
+
template <typename point_type>
- transformation(axis_transformation atr, const point_type& referencePt, const point_type& destinationPt);
- transformation(const transformation& tr);
+ transformation(axis_transformation atr,
+ const point_type& referencePt,
+ const point_type& destinationPt) : atr_(), p_(0, 0) {
+ transformation<coordinate_type> tmp(referencePt);
+ transformation<coordinate_type> rotRef(atr);
+ transformation<coordinate_type> tmpInverse = tmp.inverse();
+ point_type decon(referencePt);
+ deconvolve(decon, destinationPt);
+ transformation<coordinate_type> displacement(decon);
+ tmp += rotRef;
+ tmp += tmpInverse;
+ tmp += displacement;
+ (*this) = tmp;
+ }
// equivalence operator
- bool operator==(const transformation& tr) const;
+ bool operator==(const transformation& tr) const {
+ return (atr_ == tr.atr_) && (p_ == tr.p_);
+ }
// inequivalence operator
- bool operator!=(const transformation& tr) const;
+ bool operator!=(const transformation& tr) const {
+ return !(*this == tr);
+ }
// ordering
- bool operator<(const transformation& tr) const;
+ bool operator<(const transformation& tr) const {
+ return (atr_ < tr.atr_) || ((atr_ == tr.atr_) && (p_ < tr.p_));
+ }
// concatenation operator
- transformation operator+(const transformation& tr) const;
+ transformation operator+(const transformation& tr) const {
+ transformation<coordinate_type> retval(*this);
+ return retval+=tr;
+ }
// concatenate this with that
- const transformation& operator+=(const transformation& tr);
+ const transformation& operator+=(const transformation& tr) {
+ coordinate_type x, y;
+ transformation<coordinate_type> inv = inverse();
+ inv.transform(x, y);
+ p_.set(HORIZONTAL, p_.get(HORIZONTAL) + x);
+ p_.set(VERTICAL, p_.get(VERTICAL) + y);
+ // concatenate axis transforms
+ atr_ += tr.atr_;
+ return *this;
+ }
// get the axis_transformation portion of this
- inline axis_transformation get_axis_transformation() const {return atr_;}
+ axis_transformation get_axis_transformation() const {
+ return atr_;
+ }
// set the axis_transformation portion of this
- void set_axis_transformation(const axis_transformation& atr);
+ void set_axis_transformation(const axis_transformation& atr) {
+ atr_ = atr;
+ }
- // get the translation portion of this as a point3d
+ // get the translation
template <typename point_type>
- void get_translation(point_type& translation) const;
+ void get_translation(point_type& p) const {
+ assign(p, p_);
+ }
- // set the translation portion of this with a point3d
+ // set the translation
template <typename point_type>
- void set_translation(const point_type& p);
+ void set_translation(const point_type& p) {
+ assign(p_, p);
+ }
// 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
- void transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const;
+ void transform(coordinate_type& x, coordinate_type& y) const {
+ y -= p_.get(VERTICAL);
+ x -= p_.get(HORIZONTAL);
+ atr_.transform(x, y);
+ }
// invert this transformation
- transformation& invert();
+ transformation& invert() {
+ coordinate_type x = p_.get(HORIZONTAL), y = p_.get(VERTICAL);
+ atr_.transform(x, y);
+ x *= -1;
+ y *= -1;
+ p_ = point_data<coordinate_type>(x, y);
+ atr_.invert();
+ return *this;
+ }
// get the inverse of this transformation
- transformation inverse() const;
+ transformation inverse() const {
+ transformation<coordinate_type> ret_val(*this);
+ return ret_val.invert();
+ }
- inline void get_directions(direction_2d& horizontal_dir,
- direction_2d& vertical_dir) const {
- return atr_.get_directions(horizontal_dir, vertical_dir); }
-
- inline void get_directions(direction_3d& horizontal_dir,
- direction_3d& vertical_dir,
- direction_3d& proximal_dir) const {
- return atr_.get_directions(horizontal_dir, vertical_dir, proximal_dir); }
+ void get_directions(direction_2d& horizontal_dir,
+ direction_2d& vertical_dir) const {
+ return atr_.get_directions(horizontal_dir, vertical_dir);
+ }
-private:
+ private:
axis_transformation atr_;
- point_3d_data<coordinate_type> p_;
-
- template <typename point_type>
- void construct_dispatch(axis_transformation atr, point_type p, point_concept tag);
- template <typename point_type>
- void construct_dispatch(axis_transformation atr, point_type p, point_3d_concept tag);
- template <typename point_type>
- void construct_dispatch(axis_transformation atr, point_type rp, point_type dp, point_concept tag);
- template <typename point_type>
- void construct_dispatch(axis_transformation atr, point_type rp, point_type dp, point_3d_concept tag);
-
- //friend std::ostream& operator<< (std::ostream& o, const transformation& tr);
- //friend std::istream& operator>> (std::istream& i, transformation& tr);
+ point_data<coordinate_type> p_;
};
-}
-}
-#include "detail/transform_detail.hpp"
-#endif
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_TRANSFORM_HPP
Modified: branches/release/boost/polygon/voronoi_geometry_type.hpp
==============================================================================
--- branches/release/boost/polygon/voronoi_geometry_type.hpp (original)
+++ branches/release/boost/polygon/voronoi_geometry_type.hpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -33,7 +33,7 @@
SOURCE_CATEGORY_BITMASK = 0x1F
};
-bool belongs(
+inline bool belongs(
SourceCategory source_category,
GeometryCategory geometry_category) {
return (static_cast<std::size_t>(source_category) >>
Modified: branches/release/libs/polygon/doc/gtl_interval_concept.htm
==============================================================================
--- branches/release/libs/polygon/doc/gtl_interval_concept.htm (original)
+++ branches/release/libs/polygon/doc/gtl_interval_concept.htm 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -7,6 +7,8 @@
+
+
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /><!-- <link type="text/css" rel="stylesheet" href="adobe_source.css"> --></head><body><table style="margin: 0pt; padding: 0pt; width: 100%;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
<div style="padding: 5px;" align="center">
@@ -464,44 +466,38 @@
<td>Assignment operator.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>interval_data& <b>operator=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">template <typename IntervalType><b>
+ <br /> </b>interval_data& <b>operator=</b>(</font><font face="Courier New">const IntervalType</font><font face="Courier New">& that) const</font></td>
<td>Assign from an object that is a model of interval.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator==</b>(const T2& that) const</font></td>
- <td>Compare equality to an object that is a model of interval.</td>
+ <td width="586"><font face="Courier New"><b />bool<b>
+ operator==</b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
+ <td>Equality operator overload.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator!=</b>(const T2& that) const</font></td>
- <td>Compare inequality to an object that is a model of interval.</td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator!=</b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
+ <td>Inequality operator overload.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator<</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator<</b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator<=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator<=</b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator></b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator></b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator>=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator>=</b>(const </font><font face="Courier New">interval_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
@@ -510,10 +506,26 @@
<td>Get the coordinate in the given direction.</td>
</tr>
<tr>
+ <td style="vertical-align: top;"><font face="Courier New">T <span style="font-weight: bold;">low</span>() const</font></td>
+ <td style="vertical-align: top;">Retrieves the low value.</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;"><font face="Courier New">T <span style="font-weight: bold;">high</span>() const</font></td>
+ <td style="vertical-align: top;">Retrieves the high endpoint.</td>
+ </tr>
+<tr>
<td width="586"><font face="Courier New">void <b>set</b>(direction_1d
dir, T value)</font></td>
<td>Sets the coordinate in the given direction to the value.</td>
- </tr>
+ </tr><tr>
+ <td style="vertical-align: top;"><font face="Courier New">interval_data& <span style="font-weight: bold;">low</span>(T value)</font></td>
+ <td style="vertical-align: top;">Sets the low value.</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;"><font face="Courier New">interval_data& <span style="font-weight: bold;">high</span>(T value)</font></td>
+ <td style="vertical-align: top;">Sets the high value.</td>
+ </tr>
+
</tbody></table>
</td></tr><tr>
<td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
Modified: branches/release/libs/polygon/doc/gtl_point_concept.htm
==============================================================================
--- branches/release/libs/polygon/doc/gtl_point_concept.htm (original)
+++ branches/release/libs/polygon/doc/gtl_point_concept.htm 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,12 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head>
-<!--
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head><!--
Copyright 2009-2010 Intel Corporation
license banner
--><title>Boost Polygon Library: Point Concept</title>
+
+
+
+
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /><!-- <link type="text/css" rel="stylesheet" href="adobe_source.css"> --></head><body><table style="margin: 0pt; padding: 0pt; width: 100%;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
<div style="padding: 5px;" align="center">
@@ -85,26 +88,27 @@
The point concept tag is <font face="Courier New">
point_concept</font></p><p>
To register a user defined type as a model of point concept, specialize the
-geometry concept meta-function for that type. In the example below CPoint is registered as a model of
+geometry concept meta-function for that type. In the example below <span style="font-family: Courier New,Courier,monospace;">CPoint</span> is registered as a model of
point concept.</p><p>
<font face="Courier New">template <><br />
struct geometry_concept<CPoint> { typedef point_concept type; };</font></p><p>
-<font face="Times New Roman">The semantic of a point is that it has an x and y
+The semantic of a point is that it has an x and y
coordinate. A std::pair<int, int>, boost::tuple<int, int> or boost::array<int, 2>
could all be made models of point by simply providing indirect access to their
elements through traits, however, these objects cannot be made a model of both
point and interval in the same compilation unit, for obvious reason that
duplicate specialization of the geometry_concept struct is illegal, but also
because it would make overloading generic function by concept ambiguous if a
-type modeled more than one concept.</font></p><p>
-<font face="Times New Roman">Below is shown the default point traits.
+type modeled more than one concept.</p><p>
+Below is shown the default point traits.
Specialization of these traits is required for types that don't conform to the
-default behavior.</font></p><p>
+default behavior.</p>
+ <p>
template <typename T><br />
struct point_traits {<br />
typedef typename T::coordinate_type coordinate_type;<br />
<br />
- static inline coordinate_type get(const T& point,
+ static coordinate_type get(const T& point,
orientation_2d orient) {<br />
return point.get(orient);
<br />
@@ -113,107 +117,110 @@
<br />
template <typename T><br />
struct point_mutable_traits {<br />
- static inline void set(T& point, orientation_2d orient,
+ static void set(T& point, orientation_2d orient,
typename point_traits<T>::coordinate_type value) {<br />
point.set(orient, value);
<br />
}<br />
- static inline T construct(typename point_traits<T>::coordinate_type
+ static T construct(typename point_traits<T>::coordinate_type
x_value, typename point_traits<T>::coordinate_type y_value) {<br />
return T(x_value, y_value);
<br />
}<br />
-};</p><p>
+};</p>
+<p>
Example code custom_point.cpp demonstrates
how to map a
user defined point class to the library point_concept</p><h2>Functions</h2>
<table id="table1" border="1" width="100%">
<tbody><tr>
- <td width="586"><font face="Courier New">template <typename T><br />
- coordinate_type <b>get</b>(const T& point, orientation_2d)</font></td>
- <td><font face="Times New Roman">Expects a model of point. Returns
+ <td width="586"><font face="Courier New">template <typename PointType><br />
+ coordinate_type <b>get</b>(const PointType& point,<br />
+orientation_2d)</font></td>
+ <td>Expects a model of point. Returns
the x or y coordinate of the point, depending on the orientation_2d
- value.</font><font face="Courier New"><br />
- </font></td>
+ value.<br />
+
+ </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T, typename
- coordinate_type><br />
- void <b>set</b>(T& point, orientation_2d, coordinate_type)</font></td>
- <td><font face="Times New Roman">Expects a model of point.
- Sets the x or y coordinate of the point to the coordinate, depending on
- the orientation_2d value. </font></td>
+ <td width="586"><font face="Courier New">template <typename PointType><br />
+ void <b>set</b>(PointType& point, orientation_2d,<br />
+ coordinate_type)</font></td>
+ <td>Expects a model of point. Sets the x or y coordinate of the point to the coordinate, depending on
+ the orientation_2d value. </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T><br />
- T <b>construct</b>(coordinate_type x, coordinate_type y)</font></td>
+ <td width="586"><font face="Courier New">template <typename PointType><br />PointType <b>construct</b>(coordinate_type x,<br />
+
+coordinate_type y)</font></td>
<td>Construct an object that is a model of point given x and y
coordinate values.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- T1& <b>assign</b>(T1& left, const T2& right)</font></td>
+ <td width="586"><font face="Courier New">template <typename PointType1, typename PointType2><br />
+ PointType1& <b>assign</b>(PointType1& left,<br />
+
+const PointType2& right)</font></td>
<td>Copies data from right object that models point into left object
that models point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T, typename
- T2><br />
- bool <b>equivalence</b>(const T& point1, const T2& point2)</font></td>
+ <td width="586"><font face="Courier New">template <typename PointType1, typename PointType2><br />
+ bool <b>equivalence</b>(const </font><font face="Courier New">PointType1</font><font face="Courier New">& point1,<br />
+ const </font><font face="Courier New">PointType2</font><font face="Courier New">& point2)</font></td>
<td>Given two objects that model point, compares and returns true if
their x and y values are respectively equal to each other.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- coordinate_type <b>x</b>(const point_type& point)</font></td>
+ <td width="586"><font face="Courier New">template <typename PointType><br />
+ coordinate_type <b>x</b>(const </font><font face="Courier New">PointType</font><font face="Courier New">& point)</font></td>
<td>Returns the x coordinate of an object that models point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- coordinate_type <b>y</b>(const point_type& point)</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ coordinate_type <b>y</b>(const </font><font face="Courier New">PointType</font><font face="Courier New">& point)</font></td>
<td>Returns the y coordinate of an object that models point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- void <b>x</b>(point_type& point, coordinate_type )</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ void <b>x</b>(p</font><font face="Courier New">PointType</font><font face="Courier New">& point, coordinate_type )</font></td>
<td>Sets the x coordinate of the object that models point to the
coordinate value. </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- void <b>y</b>(point_type& point, coordinate_type )</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ void <b>y</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point, coordinate_type )</font></td>
<td>Sets the y coordinate of the object that models point to the
coordinate value. </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- point_type& <b>scale_up</b>(point_type& point, <br />
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ point_type& <b>scale_up</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point, <br />
unsigned_area_type factor)</font></td>
<td>Multiplies x and y coordinate of an object that models point by
unsigned factor.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- point_type& <b>scale_down</b>(point_type& point, <br />
-
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ point_type& <b>scale_down</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point, <br />
unsigned_area_type factor)</font></td>
<td>Divides x and y coordinate of an object that models point by
unsigned factor.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type,
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">,
typename scaling_type><br />
- point_type& <b>scale</b>(point_type& point,<br />
+ point_type& <b>scale</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point,<br />
const scaling_type& factor) </font></td>
<td>Calls the scale member function of scaling type on the x and y value
of an object that models point and sets the point to the scaled values.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type,
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">,
typename transform_type><br />
- point_type& <b>transform</b>(point_type& point,<br />
+ point_type& <b>transform</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point,<br />
const transform_type& transform) </font></td>
<td>Calls the transform member function of transform type on the x and y
@@ -221,59 +228,52 @@
transformed values.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename point_type><br />
- point_type& <b>move</b>(point_type& point, orientation_2d<br />
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">><br />
+ point_type& <b>move</b>(</font><font face="Courier New">PointType</font><font face="Courier New">& point, orientation_2d,<br />
coordinate_difference displacement)</font></td>
<td>Adds displacement value to the coordinate of an object that models
point indicated by the orientation_2d.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- T1& <b>convolve</b>(T1& a, const T2& b)</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">1, typename PointType2><br />
+ </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">& <b>convolve</b>(</font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">& a,<br />
+ const </font><font face="Courier New">PointType2</font><font face="Courier New">& b)</font></td>
<td>Adds x coordinate of b to x coordinate of a and adds y coordinate of
b to y coordinate of a.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- T1& <b>deconvolve</b>(T1& a, const T2& b)</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">, typename </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">><br />
+ </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">,</font><font face="Courier New">& <b>deconvolve</b>(</font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">& a,<br />
+
+const </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">></font><font face="Courier New">& b)</font></td>
<td>Subtracts x coordinate of b from x coordinate of a and subtracts y
coordinate of b from y coordinate of a. </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- coordinate_distance <b>euclidean_distance</b>(const T1&,<br />
-
-const T2&)</font></td>
+ <td width="586"><font face="Courier New">template <typename </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">, typename </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">><br />distance_type <b>euclidean_distance</b>(<br />
+ const </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">&, const </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">&)</font></td>
<td>Returns the distance from an object that models point to a second
object that models point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T><br />
- coordinate_difference <b>euclidean_distance</b>(const T&,<br />
- orientation_2d,
- coordinate_type)</font></td>
+ <td width="586"><font face="Courier New">template <</font><font face="Courier New">typename </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">, typename </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">><br />
+ coordinate_difference <b>euclidean_distance</b>(<br />
+ const </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">&, </font><font face="Courier New">const PointType</font><span style="font-family: Courier New;">2&,</span><font face="Courier New"> orientation_2d)</font></td>
<td>Returns the distance from an object that models point to a
coordinate in the given orientation_2d.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- coordinate_difference <b>manhattan_distance</b>(const T1&,<br />
-
-const T2&)</font></td>
+ <td width="586"><font face="Courier New">template <</font><font face="Courier New">typename </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">, typename </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">><br />
+ coordinate_difference <b>manhattan_distance</b>(<br />
+ </font><font face="Courier New">const </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">&, </font><font face="Courier New">const PointType</font><span style="font-family: Courier New;">2&</span><font face="Courier New">)</font></td>
<td>Returns the distance in x plus the distance in y from an object that
models point to a second object that models point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T1, typename
- T2><br />
- coordinate_difference <b>distance_squared</b>(const T1&,<br />
-
-const T2&)</font></td>
+ <td width="586"><font face="Courier New">template <</font><font face="Courier New">typename </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">, typename </font><font face="Courier New">PointType</font><span style="font-family: Courier New;">2</span><font face="Courier New">><br />
+ coordinate_difference <b>distance_squared</b>(<br />
+ </font><font face="Courier New">const </font><font face="Courier New">PointType</font><font face="Courier New">1</font><font face="Courier New">&, </font><font face="Courier New">const PointType</font><span style="font-family: Courier New;">2&</span><font face="Courier New">)</font></td>
<td>Returns the square of the distance in x plus the square of the
distance in y from an object that models point to a second object that
models point.</td>
@@ -293,28 +293,25 @@
library provided point data type and functions</p>
<h2>Members</h2>
<table id="table2" border="1" width="100%">
- <tbody><tr>
- <td width="586"><b><font face="Courier New">geometry_type</font></b></td>
- <td><font face="Times New Roman">point_concept</font></td>
- </tr>
+ <tbody>
<tr>
<td width="586"><b><font face="Courier New">coordinate_type</font></b></td>
- <td><font face="Times New Roman">T</font></td>
+ <td>T</td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b>point_data</b>()</font></td>
- <td><font face="Times New Roman">Default constructs the two coordinate
- values of the </font>point<font face="Times New Roman">.</font></td>
+ <td>Default constructs the two coordinate
+ values of the point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b>point_data</b>(T x, T y)</font></td>
- <td><font face="Times New Roman">Constructs an interval with two
- coordinates.</font></td>
+ <td>Constructs an interval with two
+ coordinates.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New"><b>point_data</b>(const point_data*
+ <td width="586"><font face="Courier New"><b>point_data</b>(const point_data&
that)</font></td>
- <td><font face="Times New Roman">Copy construct</font></td>
+ <td>Copy construct</td>
</tr>
<tr>
<td width="586"><font face="Courier New">point_data& <b>operator=</b>(const
@@ -322,44 +319,39 @@
<td>Assignment operator.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>point_data& <b>operator=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">template <typename PointType><br />
+point_data& <b>operator=</b>(const PointType& that) const</font></td>
<td>Assign from an object that is a model of point.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator==</b>(const T2& that) const</font></td>
- <td>Compare equality to an object that is a model of point.</td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator==</b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
+ <td>Equality operator overload.<br />
+</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator!=</b>(const T2& that) const</font></td>
- <td>Compare inequality to an object that is a model of point.</td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator!=</b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
+ <td>Inequality operator overload.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator<</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New"><b> </b>bool<b>
+ operator<</b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
<td>Compares y coordinates then x coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator<=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New"><b> </b>bool<b>
+ operator<=</b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
<td>Compares y coordinates then x coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator></b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New"><b> </b>bool<b>
+ operator></b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template <typename T2><b>
- <br /> </b>bool<b>
- operator>=</b>(const T2& that) const</font></td>
+ <td width="586"><font face="Courier New">bool<b>
+ operator>=</b>(const </font><font face="Courier New">point_data</font><font face="Courier New">& that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
Modified: branches/release/libs/polygon/doc/gtl_segment_concept.htm
==============================================================================
--- branches/release/libs/polygon/doc/gtl_segment_concept.htm (original)
+++ branches/release/libs/polygon/doc/gtl_segment_concept.htm 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -1,6 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head>
-<!--
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head><!--
Copyright 2009-2010 Intel Corporation
license banner
--><title>Boost Polygon Library: Segment Concept</title>
@@ -18,6 +17,8 @@
+
+
@@ -411,8 +412,8 @@
</tr>
<tr>
<td width="586"><font face="Courier New">template
-<typename Segment><b><br />
- </b>segment_data& <b>operator=</b>(const Segment& that)
+<typename SegmentType><b><br />
+ </b>segment_data& <b>operator=</b>(const </font><font face="Courier New">SegmentType</font><font face="Courier New">& that)
const</font></td>
<td>Assign from an object that is a model of segment.</td>
</tr>
Modified: branches/release/libs/polygon/test/Jamfile.v2
==============================================================================
--- branches/release/libs/polygon/test/Jamfile.v2 (original)
+++ branches/release/libs/polygon/test/Jamfile.v2 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -18,7 +18,9 @@
test-suite polygon-unit
:
+ [ run polygon_point_test.cpp ]
[ run polygon_segment_test.cpp ]
+ [ run polygon_interval_test.cpp ]
[ run gtl_boost_unit_test.cpp ]
;
Modified: branches/release/libs/polygon/test/gtl_boost_unit_test.cpp
==============================================================================
--- branches/release/libs/polygon/test/gtl_boost_unit_test.cpp (original)
+++ branches/release/libs/polygon/test/gtl_boost_unit_test.cpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -733,64 +733,6 @@
}
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;
#ifdef BOOST_POLYGON_MSVC
@@ -2544,7 +2486,6 @@
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;
@@ -3113,37 +3054,6 @@
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);
@@ -3238,16 +3148,6 @@
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);
@@ -3261,8 +3161,8 @@
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));
+ scale(ps90_1, anisotropic_scale_factor<double>(2, 2));
+ scale(ps90_1, anisotropic_scale_factor<double>(0.5, 0.5));
axis_transformation atr;
transform(ps90_1, atr);
std::cout << area(ps90_1) << std::endl;
@@ -3710,7 +3610,6 @@
segment_data<int> sarray[2];
sarray[0] = segment_data<int>(point_data<int>(0,0), point_data<int>(10,10));
sarray[1] = segment_data<int>(point_data<int>(10,0), point_data<int>(0,10));
- std::iterator_traits<segment_data<int>*>::value_type s = sarray[0];
intersect_segments(segs, sarray, sarray+2);
std::cout << segs.size() << std::endl;
assert_s(segs.size() == 4, "intersection3");
Added: branches/release/libs/polygon/test/polygon_interval_test.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/polygon/test/polygon_interval_test.cpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -0,0 +1,258 @@
+// Boost.Polygon library polygon_interval_test.cpp file
+
+// Copyright Andrii Sydorchuk 2012.
+// Distributed under 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)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#define BOOST_TEST_MODULE POLYGON_INTERVAL_TEST
+#include <boost/mpl/list.hpp>
+#include <boost/test/test_case_template.hpp>
+
+#include "boost/polygon/interval_concept.hpp"
+#include "boost/polygon/interval_data.hpp"
+#include "boost/polygon/interval_traits.hpp"
+using namespace boost::polygon;
+
+typedef boost::mpl::list<int> test_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_data_test, T, test_types) {
+ typedef interval_data<T> interval_type;
+ interval_type interval1(1, 2);
+ interval_type interval2;
+ interval2 = interval1;
+
+ BOOST_CHECK_EQUAL(interval1.low(), 1);
+ BOOST_CHECK_EQUAL(interval1.high(), 2);
+ BOOST_CHECK_EQUAL(interval1.get(LOW), 1);
+ BOOST_CHECK_EQUAL(interval1.get(HIGH), 2);
+ BOOST_CHECK(interval1 == interval2);
+ BOOST_CHECK(!(interval1 != interval2));
+ BOOST_CHECK(!(interval1 < interval2));
+ BOOST_CHECK(!(interval1 > interval2));
+ BOOST_CHECK(interval1 <= interval2);
+ BOOST_CHECK(interval1 >= interval2);
+
+ interval1.low(2);
+ interval1.high(1);
+ BOOST_CHECK_EQUAL(interval1.low(), 2);
+ BOOST_CHECK_EQUAL(interval1.high(), 1);
+ BOOST_CHECK(!(interval1 == interval2));
+ BOOST_CHECK(interval1 != interval2);
+
+ interval2.set(LOW, 2);
+ interval2.set(HIGH, 1);
+ BOOST_CHECK(interval1 == interval2);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_traits_test, T, test_types) {
+ typedef interval_data<T> interval_type;
+
+ interval_type interval = interval_mutable_traits<interval_type>::construct(1, 2);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, LOW), 1);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, HIGH), 2);
+
+ interval_mutable_traits<interval_type>::set(interval, LOW, 3);
+ interval_mutable_traits<interval_type>::set(interval, HIGH, 4);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, LOW), 3);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, HIGH), 4);
+}
+
+template <typename T>
+struct Interval {
+ T left;
+ T right;
+};
+
+namespace boost {
+namespace polygon {
+ template <typename T>
+ struct geometry_concept< Interval<T> > {
+ typedef interval_concept type;
+ };
+
+ template <typename T>
+ struct interval_traits< Interval<T> > {
+ typedef T coordinate_type;
+
+ static coordinate_type get(const Interval<T>& interval, direction_1d dir) {
+ return (dir == LOW) ? interval.left : interval.right;
+ }
+ };
+
+ template <typename T>
+ struct interval_mutable_traits< Interval<T> > {
+ typedef T coordinate_type;
+
+ static void set(Interval<T>& interval, direction_1d dir, T value) {
+ (dir == LOW) ? interval.left = value : interval.right = value;
+ }
+
+ static Interval<T> construct(coordinate_type left, coordinate_type right) {
+ Interval<T> interval;
+ interval.left = left;
+ interval.right = right;
+ return interval;
+ }
+ };
+} // polygon
+} // boost
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test1, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval1 = construct<interval_type>(2, 1);
+ BOOST_CHECK_EQUAL(interval1.left, 1);
+ BOOST_CHECK_EQUAL(interval1.right, 2);
+
+ set(interval1, LOW, 3);
+ set(interval1, HIGH, 4);
+ BOOST_CHECK_EQUAL(get(interval1, LOW), 3);
+ BOOST_CHECK_EQUAL(get(interval1, HIGH), 4);
+
+ interval_type interval2 = copy_construct<interval_type>(interval1);
+ BOOST_CHECK(equivalence(interval1, interval2));
+
+ low(interval2, 1);
+ high(interval2, 2);
+ BOOST_CHECK_EQUAL(low(interval2), 1);
+ BOOST_CHECK_EQUAL(high(interval2), 2);
+
+ assign(interval1, interval2);
+ BOOST_CHECK(equivalence(interval1, interval2));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test2, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval1 = construct<interval_type>(1, 3);
+ BOOST_CHECK_EQUAL(center(interval1), 2);
+ BOOST_CHECK_EQUAL(delta(interval1), 2);
+
+ flip(interval1, -1);
+ BOOST_CHECK_EQUAL(low(interval1), -5);
+ BOOST_CHECK_EQUAL(high(interval1), -3);
+
+ scale_up(interval1, 2);
+ BOOST_CHECK_EQUAL(low(interval1), -10);
+ BOOST_CHECK_EQUAL(high(interval1), -6);
+
+ scale_down(interval1, 2);
+ BOOST_CHECK_EQUAL(low(interval1), -5);
+ BOOST_CHECK_EQUAL(high(interval1), -3);
+
+ move(interval1, 5);
+ BOOST_CHECK_EQUAL(low(interval1), 0);
+ BOOST_CHECK_EQUAL(high(interval1), 2);
+
+ convolve(interval1, 1);
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 3);
+
+ deconvolve(interval1, 2);
+ BOOST_CHECK_EQUAL(low(interval1), -1);
+ BOOST_CHECK_EQUAL(high(interval1), 1);
+
+ interval_type interval2 = construct<interval_type>(-1, 2);
+ convolve(interval1, interval2);
+ BOOST_CHECK_EQUAL(low(interval1), -2);
+ BOOST_CHECK_EQUAL(high(interval1), 3);
+
+ deconvolve(interval1, interval2);
+ BOOST_CHECK_EQUAL(low(interval1), -1);
+ BOOST_CHECK_EQUAL(high(interval1), 1);
+
+ reflected_convolve(interval1, interval2);
+ BOOST_CHECK_EQUAL(low(interval1), -3);
+ BOOST_CHECK_EQUAL(high(interval1), 2);
+
+ reflected_deconvolve(interval1, interval2);
+ BOOST_CHECK_EQUAL(low(interval1), -1);
+ BOOST_CHECK_EQUAL(high(interval1), 1);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test3, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval1 = construct<interval_type>(1, 3);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, -2), 3);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, 2), 0);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, 4), 1);
+
+ interval_type interval2 = construct<interval_type>(-1, 0);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, interval2), 1);
+ BOOST_CHECK(!intersects(interval1, interval2));
+ BOOST_CHECK(!boundaries_intersect(interval1, interval2));
+ BOOST_CHECK(!intersect(interval2, interval1));
+ BOOST_CHECK_EQUAL(low(interval2), -1);
+ BOOST_CHECK_EQUAL(high(interval2), 0);
+
+ interval_type interval3 = construct<interval_type>(-1, 6);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, interval3), 0);
+ BOOST_CHECK(intersects(interval1, interval3));
+ BOOST_CHECK(!boundaries_intersect(interval1, interval3));
+ BOOST_CHECK(intersect(interval3, interval1));
+ BOOST_CHECK_EQUAL(low(interval3), 1);
+ BOOST_CHECK_EQUAL(high(interval3), 3);
+
+ interval_type interval4 = construct<interval_type>(5, 6);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, interval4), 2);
+ BOOST_CHECK(!intersects(interval1, interval4));
+ BOOST_CHECK(!boundaries_intersect(interval1, interval4));
+ BOOST_CHECK(!intersect(interval4, interval1));
+ BOOST_CHECK_EQUAL(low(interval4), 5);
+ BOOST_CHECK_EQUAL(high(interval4), 6);
+
+ interval_type interval5 = construct<interval_type>(3, 5);
+ BOOST_CHECK_EQUAL(euclidean_distance(interval1, interval5), 0);
+ BOOST_CHECK(!intersects(interval1, interval5, false));
+ BOOST_CHECK(boundaries_intersect(interval1, interval5));
+ BOOST_CHECK(intersect(interval5, interval1));
+ BOOST_CHECK_EQUAL(low(interval5), 3);
+ BOOST_CHECK_EQUAL(high(interval5), 3);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test4, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval1 = construct<interval_type>(1, 3);
+ interval_type interval2 = construct<interval_type>(3, 5);
+ BOOST_CHECK(!abuts(interval1, interval2, LOW));
+ BOOST_CHECK(abuts(interval1, interval2, HIGH));
+ BOOST_CHECK(abuts(interval1, interval2));
+
+ bloat(interval1, 1);
+ BOOST_CHECK_EQUAL(low(interval1), 0);
+ BOOST_CHECK_EQUAL(high(interval1), 4);
+ BOOST_CHECK(!abuts(interval1, interval2));
+
+ bloat(interval1, LOW, 1);
+ BOOST_CHECK_EQUAL(low(interval1), -1);
+ BOOST_CHECK_EQUAL(high(interval1), 4);
+
+ shrink(interval1, LOW, 1);
+ BOOST_CHECK_EQUAL(low(interval1), 0);
+ BOOST_CHECK_EQUAL(high(interval1), 4);
+
+ shrink(interval1, 1);
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 3);
+
+ BOOST_CHECK(encompass(interval1, 4));
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 4);
+
+ BOOST_CHECK(encompass(interval1, interval2));
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 5);
+
+ interval1 = get_half(interval1, LOW);
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 3);
+
+ BOOST_CHECK(join_with(interval1, interval2));
+ BOOST_CHECK_EQUAL(low(interval1), 1);
+ BOOST_CHECK_EQUAL(high(interval1), 5);
+}
Added: branches/release/libs/polygon/test/polygon_point_test.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/polygon/test/polygon_point_test.cpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -0,0 +1,192 @@
+// Boost.Polygon library polygon_point_test.cpp file
+
+// Copyright Andrii Sydorchuk 2012.
+// Distributed under 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)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#define BOOST_TEST_MODULE POLYGON_POINT_TEST
+#include <boost/mpl/list.hpp>
+#include <boost/test/test_case_template.hpp>
+
+#include "boost/polygon/point_concept.hpp"
+#include "boost/polygon/point_data.hpp"
+#include "boost/polygon/point_traits.hpp"
+using namespace boost::polygon;
+
+typedef boost::mpl::list<int> test_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_data_test, T, test_types) {
+ typedef point_data<T> point_type;
+
+ point_type point1(1, 2);
+ point_type point2;
+ point2 = point1;
+ BOOST_CHECK_EQUAL(point1.x(), 1);
+ BOOST_CHECK_EQUAL(point1.y(), 2);
+ BOOST_CHECK_EQUAL(point2.x(), 1);
+ BOOST_CHECK_EQUAL(point2.y(), 2);
+ BOOST_CHECK(point1 == point2);
+ BOOST_CHECK(!(point1 != point2));
+ BOOST_CHECK(!(point1 < point2));
+ BOOST_CHECK(!(point1 > point2));
+ BOOST_CHECK(point1 <= point2);
+ BOOST_CHECK(point1 >= point2);
+
+ point2.x(2);
+ point2.y(1);
+ BOOST_CHECK_EQUAL(point2.x(), 2);
+ BOOST_CHECK_EQUAL(point2.y(), 1);
+ BOOST_CHECK(!(point1 == point2));
+ BOOST_CHECK(point1 != point2);
+ BOOST_CHECK(point1 < point2);
+ BOOST_CHECK(!(point1 > point2));
+ BOOST_CHECK(point1 <= point2);
+ BOOST_CHECK(!(point1 >= point2));
+
+ point2.set(HORIZONTAL, 1);
+ point2.set(VERTICAL, 2);
+ BOOST_CHECK(point1 == point2);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_traits_test, T, test_types) {
+ typedef point_data<T> point_type;
+
+ point_type point = point_mutable_traits<point_type>::construct(1, 2);
+ BOOST_CHECK_EQUAL(point_traits<point_type>::get(point, HORIZONTAL), 1);
+ BOOST_CHECK_EQUAL(point_traits<point_type>::get(point, VERTICAL), 2);
+
+ point_mutable_traits<point_type>::set(point, HORIZONTAL, 3);
+ point_mutable_traits<point_type>::set(point, VERTICAL, 4);
+ BOOST_CHECK_EQUAL(point_traits<point_type>::get(point, HORIZONTAL), 3);
+ BOOST_CHECK_EQUAL(point_traits<point_type>::get(point, VERTICAL), 4);
+}
+
+template <typename T>
+struct Point {
+ T x;
+ T y;
+};
+
+namespace boost {
+namespace polygon {
+ template <typename T>
+ struct geometry_concept< Point<T> > {
+ typedef point_concept type;
+ };
+
+ template <typename T>
+ struct point_traits< Point<T> > {
+ typedef T coordinate_type;
+
+ static coordinate_type get(const Point<T>& point, orientation_2d orient) {
+ return (orient == HORIZONTAL) ? point.x : point.y;
+ }
+ };
+
+ template <typename T>
+ struct point_mutable_traits< Point<T> > {
+ typedef T coordinate_type;
+
+ static void set(Point<T>& point, orientation_2d orient, T value) {
+ (orient == HORIZONTAL) ? point.x = value : point.y = value;
+ }
+
+ static Point<T> construct(coordinate_type x, coordinate_type y) {
+ Point<T> point;
+ point.x = x;
+ point.y = y;
+ return point;
+ }
+ };
+} // polygon
+} // boost
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_concept_test1, T, test_types) {
+ typedef Point<T> point_type;
+
+ point_type point1 = construct<point_type>(1, 2);
+ BOOST_CHECK_EQUAL(point1.x, 1);
+ BOOST_CHECK_EQUAL(point1.y, 2);
+
+ set(point1, HORIZONTAL, 3);
+ set(point1, VERTICAL, 4);
+ BOOST_CHECK_EQUAL(get(point1, HORIZONTAL), 3);
+ BOOST_CHECK_EQUAL(get(point1, VERTICAL), 4);
+
+ point_type point2;
+ assign(point2, point1);
+ BOOST_CHECK(equivalence(point1, point2));
+
+ x(point2, 1);
+ y(point2, 2);
+ BOOST_CHECK_EQUAL(x(point2), 1);
+ BOOST_CHECK_EQUAL(y(point2), 2);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_concept_test2, T, test_types) {
+ typedef Point<T> point_type;
+
+ point_type point1 = construct<point_type>(1, 2);
+ point_type point2 = construct<point_type>(5, 5);
+ BOOST_CHECK_EQUAL(euclidean_distance(point1, point2, HORIZONTAL), 4);
+ BOOST_CHECK_EQUAL(euclidean_distance(point1, point2, VERTICAL), 3);
+ BOOST_CHECK_EQUAL(manhattan_distance(point1, point2), 7);
+ BOOST_CHECK_EQUAL(euclidean_distance(point1, point2), 5.0);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_concept_test3, T, test_types) {
+ typedef Point<T> point_type;
+
+ point_type point = construct<point_type>(1, 2);
+ point_type shift = construct<point_type>(4, 3);
+ convolve(point, shift);
+ BOOST_CHECK_EQUAL(x(point), 5);
+ BOOST_CHECK_EQUAL(y(point), 5);
+
+ deconvolve(point, shift);
+ BOOST_CHECK_EQUAL(x(point), 1);
+ BOOST_CHECK_EQUAL(y(point), 2);
+
+ scale_up(point, 5);
+ BOOST_CHECK_EQUAL(x(point), 5);
+ BOOST_CHECK_EQUAL(y(point), 10);
+
+ scale_down(point, 5);
+ BOOST_CHECK_EQUAL(x(point), 1);
+ BOOST_CHECK_EQUAL(y(point), 2);
+
+ move(point, HORIZONTAL, 2);
+ move(point, VERTICAL, 3);
+ BOOST_CHECK_EQUAL(x(point), 3);
+ BOOST_CHECK_EQUAL(y(point), 5);
+}
+
+template<typename T>
+struct Transformer {
+ void scale(T& x, T& y) const {
+ x *= 2;
+ y *= 2;
+ }
+
+ void transform(T& x, T& y) const {
+ T tmp = x;
+ x = y;
+ y = tmp;
+ }
+};
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(point_concept_test4, T, test_types) {
+ typedef Point<T> point_type;
+
+ point_type point = construct<point_type>(1, 2);
+ scale(point, Transformer<T>());
+ BOOST_CHECK_EQUAL(x(point), 2);
+ BOOST_CHECK_EQUAL(y(point), 4);
+
+ transform(point, Transformer<T>());
+ BOOST_CHECK_EQUAL(x(point), 4);
+ BOOST_CHECK_EQUAL(y(point), 2);
+}
Modified: branches/release/libs/polygon/test/polygon_segment_test.cpp
==============================================================================
--- branches/release/libs/polygon/test/polygon_segment_test.cpp (original)
+++ branches/release/libs/polygon/test/polygon_segment_test.cpp 2012-12-16 18:16:06 EST (Sun, 16 Dec 2012)
@@ -7,14 +7,13 @@
// See http://www.boost.org for updates, documentation, and revision history.
-#include <algorithm>
-#include <list>
-
#define BOOST_TEST_MODULE POLYGON_SEGMENT_TEST
#include <boost/mpl/list.hpp>
#include <boost/test/test_case_template.hpp>
-#include "boost/polygon/polygon.hpp"
+#include "boost/polygon/segment_concept.hpp"
+#include "boost/polygon/segment_data.hpp"
+#include "boost/polygon/segment_traits.hpp"
using namespace boost::polygon;
typedef boost::mpl::list<int> test_types;
@@ -25,7 +24,8 @@
point_type point1(1, 2);
point_type point2(3, 4);
segment_type segment1(point1, point2);
- segment_type segment2 = segment1;
+ segment_type segment2;
+ segment2 = segment1;
BOOST_CHECK(segment1.low() == point1);
BOOST_CHECK(segment1.high() == point2);
@@ -56,14 +56,14 @@
point_type point1(1, 2);
point_type point2(3, 4);
- segment_type segment = segment_mutable_traits<segment_type>::construct(point1, point2);
+ segment_type segment =
+ segment_mutable_traits<segment_type>::construct(point1, point2);
BOOST_CHECK(segment_traits<segment_type>::get(segment, LOW) == point1);
BOOST_CHECK(segment_traits<segment_type>::get(segment, HIGH) == point2);
segment_mutable_traits<segment_type>::set(segment, LOW, point2);
segment_mutable_traits<segment_type>::set(segment, HIGH, point1);
-
BOOST_CHECK(segment_traits<segment_type>::get(segment, LOW) == point2);
BOOST_CHECK(segment_traits<segment_type>::get(segment, HIGH) == point1);
}
@@ -95,15 +95,13 @@
struct segment_mutable_traits< Segment<T> > {
typedef point_data<T> point_type;
- static inline void set(Segment<T>& segment, direction_1d dir, const point_type& point) {
- if (dir.to_int()) {
- segment.p1 = point;
- } else {
- segment.p0 = point;
- }
+ static void set(
+ Segment<T>& segment, direction_1d dir, const point_type& point) {
+ dir.to_int() ? segment.p1 = point : segment.p0 = point;;
}
- static inline Segment<T> construct(const point_type& point1, const point_type& point2) {
+ static Segment<T> construct(
+ const point_type& point1, const point_type& point2) {
Segment<T> segment;
segment.p0 = point1;
segment.p1 = point2;
@@ -190,11 +188,16 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
- segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));
- segment_type segment2 = construct<segment_type>(point_type(0, 0), point_type(2, 4));
- segment_type segment3 = construct<segment_type>(point_type(0, 0), point_type(2, 3));
- segment_type segment4 = construct<segment_type>(point_type(0, 0), point_type(2, 5));
- segment_type segment5 = construct<segment_type>(point_type(0, 2), point_type(2, 0));
+ segment_type segment1 = construct<segment_type>(
+ point_type(0, 0), point_type(1, 2));
+ segment_type segment2 = construct<segment_type>(
+ point_type(0, 0), point_type(2, 4));
+ segment_type segment3 = construct<segment_type>(
+ point_type(0, 0), point_type(2, 3));
+ segment_type segment4 = construct<segment_type>(
+ point_type(0, 0), point_type(2, 5));
+ segment_type segment5 = construct<segment_type>(
+ point_type(0, 2), point_type(2, 0));
BOOST_CHECK(orientation(segment1, segment2) == 0);
BOOST_CHECK(orientation(segment1, segment3) == -1);
@@ -325,10 +328,14 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
- segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));
- segment_type segment2 = construct<segment_type>(point_type(1, 2), point_type(2, 4));
- segment_type segment3 = construct<segment_type>(point_type(2, 4), point_type(0, 4));
- segment_type segment4 = construct<segment_type>(point_type(0, 4), point_type(0, 0));
+ segment_type segment1 = construct<segment_type>(
+ point_type(0, 0), point_type(1, 2));
+ segment_type segment2 = construct<segment_type>(
+ point_type(1, 2), point_type(2, 4));
+ segment_type segment3 = construct<segment_type>(
+ point_type(2, 4), point_type(0, 4));
+ segment_type segment4 = construct<segment_type>(
+ point_type(0, 4), point_type(0, 0));
BOOST_CHECK(abuts(segment1, segment2, HIGH));
BOOST_CHECK(abuts(segment2, segment3, HIGH));
@@ -353,11 +360,16 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
- segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(2, 2));
- segment_type segment2 = construct<segment_type>(point_type(1, 1), point_type(3, 3));
- segment_type segment3 = construct<segment_type>(point_type(2, 2), point_type(-1, -1));
- segment_type segment4 = construct<segment_type>(point_type(1, 3), point_type(3, 1));
- segment_type segment5 = construct<segment_type>(point_type(2, 2), point_type(1, 3));
+ segment_type segment1 = construct<segment_type>(
+ point_type(0, 0), point_type(2, 2));
+ segment_type segment2 = construct<segment_type>(
+ point_type(1, 1), point_type(3, 3));
+ segment_type segment3 = construct<segment_type>(
+ point_type(2, 2), point_type(-1, -1));
+ segment_type segment4 = construct<segment_type>(
+ point_type(1, 3), point_type(3, 1));
+ segment_type segment5 = construct<segment_type>(
+ point_type(2, 2), point_type(1, 3));
BOOST_CHECK(intersects(segment1, segment2, false));
BOOST_CHECK(intersects(segment1, segment2, true));
@@ -377,12 +389,18 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
- segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(0, 2));
- segment_type segment2 = construct<segment_type>(point_type(0, 1), point_type(0, 3));
- segment_type segment3 = construct<segment_type>(point_type(0, 1), point_type(0, 2));
- segment_type segment4 = construct<segment_type>(point_type(0, 2), point_type(0, 3));
- segment_type segment5 = construct<segment_type>(point_type(0, 2), point_type(2, 2));
- segment_type segment6 = construct<segment_type>(point_type(0, 1), point_type(1, 1));
+ segment_type segment1 = construct<segment_type>(
+ point_type(0, 0), point_type(0, 2));
+ segment_type segment2 = construct<segment_type>(
+ point_type(0, 1), point_type(0, 3));
+ segment_type segment3 = construct<segment_type>(
+ point_type(0, 1), point_type(0, 2));
+ segment_type segment4 = construct<segment_type>(
+ point_type(0, 2), point_type(0, 3));
+ segment_type segment5 = construct<segment_type>(
+ point_type(0, 2), point_type(2, 2));
+ segment_type segment6 = construct<segment_type>(
+ point_type(0, 1), point_type(1, 1));
BOOST_CHECK(intersects(segment1, segment1, false));
BOOST_CHECK(intersects(segment1, segment1, true));
@@ -420,10 +438,14 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
- segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(3, 4));
- segment_type segment2 = construct<segment_type>(point_type(2, 0), point_type(0, 2));
- segment_type segment3 = construct<segment_type>(point_type(1, -7), point_type(10, 5));
- segment_type segment4 = construct<segment_type>(point_type(7, 7), point_type(10, 11));
+ segment_type segment1 = construct<segment_type>(
+ point_type(0, 0), point_type(3, 4));
+ segment_type segment2 = construct<segment_type>(
+ point_type(2, 0), point_type(0, 2));
+ segment_type segment3 = construct<segment_type>(
+ point_type(1, -7), point_type(10, 5));
+ segment_type segment4 = construct<segment_type>(
+ point_type(7, 7), point_type(10, 11));
BOOST_CHECK(euclidean_distance(segment1, segment2) == 0.0);
BOOST_CHECK(euclidean_distance(segment1, segment3) == 5.0);
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