52 #ifdef CHECK_MEMORY_LEAKS
54 #endif // CHECK_MEMORY_LEAKS
64 std::copy(v.begin(), v.end(), std::back_inserter(*
this));
74 copy(p.begin(), p.end(), back_inserter(*
this));
98 for (const_iterator i = begin(); i != end() - 1; i++) {
103 (*(i + 1)).x() - p.
x(),
104 (*(i + 1)).y() - p.
y());
108 (*(end() - 1)).x() - p.
x(),
109 (*(end() - 1)).y() - p.
y());
111 (*(begin())).x() - p.
x(),
112 (*(begin())).y() - p.
y());
114 return (!(fabs(angle) <
M_PI));
120 for (const_iterator i = begin(); i != end() - 1; i++) {
121 if (poly.
around(*i, offset)) {
134 for (const_iterator i = begin(); i != end() - 1; i++) {
149 for (const_iterator i = begin(); i != end() - 1; i++) {
162 for (const_iterator i = begin(); i != end() - 1; i++) {
173 for (const_iterator i = begin(); i != end() - 1; i++) {
192 return at(size() + index);
202 return at(size() + index);
209 const_iterator i = begin();
212 const SUMOReal nextLength = (*i).distanceTo(*(i + 1));
213 if (seenLength + nextLength > pos) {
216 seenLength += nextLength;
217 }
while (++i != end() - 1);
224 const_iterator i = begin();
227 const SUMOReal nextLength = (*i).distanceTo2D(*(i + 1));
228 if (seenLength + nextLength > pos) {
231 seenLength += nextLength;
232 }
while (++i != end() - 1);
239 const_iterator i = begin();
242 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
243 if (seenLength + nextLength > pos) {
244 Line l(*i, *(i + 1));
247 seenLength += nextLength;
248 }
while (++i != end() - 1);
249 Line l(*(end() - 2), *(end() - 1));
255 const_iterator i = begin();
258 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
259 if (seenLength + nextLength > pos) {
260 Line l(*i, *(i + 1));
263 seenLength += nextLength;
264 }
while (++i != end() - 1);
265 Line l(*(end() - 2), *(end() - 1));
277 return p1 + (p2 - p1) * (pos / dist);
289 return p1 + (p2 - p1) * (pos / dist);
296 for (const_iterator i = begin(); i != end(); i++) {
307 for (const_iterator i = begin(); i != end(); i++) {
321 const int endIndex = (
int)tmp.size() - 1;
325 if (tmp.
area() != 0) {
327 for (
int i = 0; i < endIndex; i++) {
328 const SUMOReal z = tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
330 x += (tmp[i].x() + tmp[i + 1].x()) * z;
331 y += (tmp[i].y() + tmp[i + 1].y()) * z;
339 for (
int i = 0; i < endIndex; i++) {
341 x += (tmp[i].x() + tmp[i + 1].x()) * length / 2;
342 y += (tmp[i].y() + tmp[i + 1].y()) * length / 2;
345 return Position(x / lengthSum, y / lengthSum);
353 for (
int i = 0; i < static_cast<int>(size()); i++) {
354 (*this)[i] = centroid + (((*this)[i] - centroid) * factor);
371 for (const_iterator i = begin(); i != end() - 1; i++) {
372 len += (*i).distanceTo(*(i + 1));
380 for (const_iterator i = begin(); i != end() - 1; i++) {
381 len += (*i).distanceTo2D(*(i + 1));
394 const int endIndex = (
int)tmp.size() - 1;
396 for (
int i = 0; i < endIndex; i++) {
397 area += tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
408 for (const_iterator i = begin(); i != end() - 1; i++) {
409 if (poly.
around(*i, offset)) {
423 std::pair<PositionVector, PositionVector>
434 const_iterator it = begin() + 1;
435 SUMOReal next = first.back().distanceTo(*it);
441 next = first.back().distanceTo(*it);
443 if (fabs(where - (seen + next)) >
POSITION_EPS || it == end() - 1) {
446 Line tmpL(first.back(), *it);
447 Position p = tmpL.getPositionAtDistance(where - seen);
454 for (; it != end(); it++) {
457 assert(first.size() >= 2);
458 assert(second.size() >= 2);
459 assert(first.back() == second.front());
461 return std::pair<PositionVector, PositionVector>(first, second);
467 for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); i++) {
468 if (i != geom.begin()) {
485 for (
int i = 0; i < static_cast<int>(size()); i++) {
486 (*this)[i].add(xoff, yoff, zoff);
493 for (
int i = 0; i < static_cast<int>(size()); i++) {
494 (*this)[i].reshiftRotate(xoff, yoff, rot);
502 return atan2(p1.
x(), p1.
y()) < atan2(p2.
x(), p2.
y());
521 if (p1.
x() != p2.
x()) {
522 return p1.
x() < p2.
x();
524 return p1.
y() < p2.
y();
532 return (P1.
x() - P0.
x()) * (P2.
y() - P0.
y()) - (P2.
x() - P0.
x()) * (P1.
y() - P0.
y());
547 for (const_iterator i = begin(); i != end() - 1; i++) {
550 *i, *(i + 1), line.
p1(), line.
p2()));
559 if (back().distanceTo(v[0]) < 2) {
560 copy(v.begin() + 1, v.end(), back_inserter(*
this));
564 Line l1((*
this)[static_cast<int>(size()) - 2], back());
570 (*this)[
static_cast<int>(size()) - 1] = p;
571 copy(v.begin() + 1, v.end(), back_inserter(*
this));
574 copy(v.begin(), v.end(), back_inserter(*
this));
582 if (back().distanceTo(v[0]) < 2) {
583 copy(v.begin() + 1, v.end(), back_inserter(*
this));
585 copy(v.begin(), v.end(), back_inserter(*
this));
604 const_iterator i = begin();
606 while ((i + 1) != end()
608 seen + (*i).distanceTo(*(i + 1)) < beginOffset) {
609 seen += (*i).distanceTo(*(i + 1));
613 while ((i + 1) != end()
615 seen + (*i).distanceTo(*(i + 1)) < endOffset) {
623 seen += (*i).distanceTo(*(i + 1));
646 const_iterator i = begin();
648 while ((i + 1) != end()
650 seen + (*i).distanceTo2D(*(i + 1)) < beginOffset) {
651 seen += (*i).distanceTo2D(*(i + 1));
655 while ((i + 1) != end()
657 seen + (*i).distanceTo2D(*(i + 1)) < endOffset) {
665 seen += (*i).distanceTo2D(*(i + 1));
684 if (currDist >= 0 && currDist < dist) {
689 for (iterator i = begin(); i != end() - 1; i++, currPos++) {
691 if (currDist >= 0 && currDist < dist) {
697 for (
size_t j = 0; j < pos; j++) {
702 (*
this)[0], (*
this)[1], p);
707 if (np != *(begin())) {
709 if (np != *(begin())) {
712 assert(*(begin()) != *(end() - 1));
728 if (currDist >= 0 && currDist < dist) {
733 for (reverse_iterator i = rbegin(); i != rend() - 1; i++, currPos++) {
735 if (currDist >= 0 && currDist < dist) {
741 for (
size_t j = 0; j < pos; j++) {
747 (*
this)[static_cast<int>(size()) - 1], (*
this)[static_cast<int>(size()) - 2], p);
753 if (np != *(end() - 1)) {
755 if (np != *(end() - 1)) {
758 assert(*(begin()) != *(end() - 1));
766 Line tmp(front(), back());
786 for (const_iterator i = begin(); i != end() - 1; i++) {
790 if (dist < minDist) {
791 nearestPos = pos + seen;
794 if (perpendicular && i != begin()) {
797 if (cornerDist < minDist) {
799 minDist = cornerDist;
802 seen += (*i).distanceTo2D(*(i + 1));
814 for (
int i = 0; i < (
int)size(); i++) {
816 if (dist < minDist) {
830 int insertionIndex = 1;
831 for (
int i = 0; i < (
int)size() - 1; i++) {
833 if (dist < minDist) {
834 insertionIndex = i + 1;
839 return insertionIndex;
846 return front().distanceTo(p);
850 for (const_iterator i = begin(); i != end() - 1; i++) {
852 p, *i, *(i + 1), outIntersection));
858 std::vector<SUMOReal>
860 std::vector<SUMOReal> ret;
861 for (const_iterator i = other.begin(); i != other.end() - 1; i++) {
863 copy(atSegment.begin(), atSegment.end(), back_inserter(ret));
869 std::vector<SUMOReal>
871 std::vector<SUMOReal> ret;
873 for (const_iterator i = begin(); i != end() - 1; i++) {
874 Line l((*i), *(i + 1));
879 ret.push_back(atLength + pos);
894 (*
this)[static_cast<int>(size()) - 2], (*
this)[static_cast<int>(size()) - 1], val);
905 for (const_reverse_iterator i = rbegin(); i != rend(); i++) {
918 for (
int i = 0; i < static_cast<int>(size()); i++) {
922 std::pair<SUMOReal, SUMOReal> offsets =
925 from.
y() - offsets.second, from.
z()));
926 }
else if (i == static_cast<int>(size()) - 1) {
929 std::pair<SUMOReal, SUMOReal> offsets =
932 to.
y() - offsets.second, to.
z()));
938 me.
x() - to.
x(), me.
y() - to.
y()) / 2);
942 std::pair<SUMOReal, SUMOReal> off =
947 std::pair<SUMOReal, SUMOReal> offsets =
949 std::pair<SUMOReal, SUMOReal> offsets2 =
952 Position(from.
x() - offsets.first, from.
y() - offsets.second),
953 Position(me.
x() - offsets.first, me.
y() - offsets.second));
956 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
957 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
999 assert((
int)size() > pos + 1);
1000 return Line((*
this)[pos], (*
this)[pos + 1]);
1012 return lineAt((
int)size() - 2);
1018 if ((*
this)[0] == back()) {
1025 std::vector<SUMOReal>
1027 std::vector<SUMOReal> ret;
1029 for (i = begin(); i != end(); i++) {
1032 for (i = s.begin(); i != s.end(); i++) {
1042 insert(begin() + index, p);
1044 insert(end() + index, p);
1051 assert(index < static_cast<int>(size()));
1052 assert(index + static_cast<int>(size()) >= 0);
1056 (*this)[index +
static_cast<int>(size())] = p;
1079 return size() >= 2 && (*this)[0] == back();
1086 iterator last = begin();
1087 for (iterator i = begin() + 1; i != end() && (!assertLength || size() > 2);) {
1088 if (last->almostSame(*i, minDist)) {
1103 for (iterator i = begin() + 1; i != end() - 1;) {
1117 if (size() == v2.size()) {
1118 for (
int i = 0; i < (
int)size(); i++) {
1119 if ((*
this)[i] != v2[i]) {