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));
100 for (const_iterator i = begin(); i != end() - 1; i++) {
105 (*(i + 1)).x() - p.
x(),
106 (*(i + 1)).y() - p.
y());
110 (*(end() - 1)).x() - p.
x(),
111 (*(end() - 1)).y() - p.
y());
113 (*(begin())).x() - p.
x(),
114 (*(begin())).y() - p.
y());
116 return (!(fabs(angle) <
M_PI));
122 for (const_iterator i = begin(); i != end() - 1; i++) {
123 if (poly.
around(*i, offset)) {
136 for (const_iterator i = begin(); i != end() - 1; i++) {
151 for (const_iterator i = begin(); i != end() - 1; i++) {
164 for (const_iterator i = begin(); i != end() - 1; i++) {
175 for (const_iterator i = begin(); i != end() - 1; i++) {
194 return at((
int)size() + index);
204 return at((
int)size() + index);
211 const_iterator i = begin();
214 const SUMOReal nextLength = (*i).distanceTo(*(i + 1));
215 if (seenLength + nextLength > pos) {
218 seenLength += nextLength;
219 }
while (++i != end() - 1);
226 const_iterator i = begin();
229 const SUMOReal nextLength = (*i).distanceTo2D(*(i + 1));
230 if (seenLength + nextLength > pos) {
233 seenLength += nextLength;
234 }
while (++i != end() - 1);
244 const_iterator i = begin();
247 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
248 if (seenLength + nextLength > pos) {
249 Line l(*i, *(i + 1));
252 seenLength += nextLength;
253 }
while (++i != end() - 1);
254 Line l(*(end() - 2), *(end() - 1));
260 const_iterator i = begin();
263 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
264 if (seenLength + nextLength > pos) {
265 Line l(*i, *(i + 1));
268 seenLength += nextLength;
269 }
while (++i != end() - 1);
270 Line l(*(end() - 2), *(end() - 1));
282 if (lateralOffset != 0) {
287 return p1 + (p2 - p1) * (pos / dist);
299 if (lateralOffset != 0) {
304 return p1 + (p2 - p1) * (pos / dist);
311 for (const_iterator i = begin(); i != end(); i++) {
322 for (const_iterator i = begin(); i != end(); i++) {
336 const int endIndex = (
int)tmp.size() - 1;
340 if (tmp.
area() != 0) {
342 for (
int i = 0; i < endIndex; i++) {
343 const SUMOReal z = tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
345 x += (tmp[i].x() + tmp[i + 1].x()) * z;
346 y += (tmp[i].y() + tmp[i + 1].y()) * z;
354 for (
int i = 0; i < endIndex; i++) {
356 x += (tmp[i].x() + tmp[i + 1].x()) * length / 2;
357 y += (tmp[i].y() + tmp[i + 1].y()) * length / 2;
360 if (lengthSum == 0) {
364 return Position(x / lengthSum, y / lengthSum);
372 for (
int i = 0; i < static_cast<int>(size()); i++) {
373 (*this)[i] = centroid + (((*this)[i] - centroid) * factor);
381 for (
int i = 0; i < static_cast<int>(size()); i++) {
382 (*this)[i] = centroid + (((*this)[i] - centroid) + offset);
399 for (const_iterator i = begin(); i != end() - 1; i++) {
400 len += (*i).distanceTo(*(i + 1));
408 for (const_iterator i = begin(); i != end() - 1; i++) {
409 len += (*i).distanceTo2D(*(i + 1));
422 const int endIndex = (
int)tmp.size() - 1;
424 for (
int i = 0; i < endIndex; i++) {
425 area += tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
436 for (const_iterator i = begin(); i != end() - 1; i++) {
437 if (poly.
around(*i, offset)) {
451 std::pair<PositionVector, PositionVector>
462 const_iterator it = begin() + 1;
463 SUMOReal next = first.back().distanceTo(*it);
469 next = first.back().distanceTo(*it);
471 if (fabs(where - (seen + next)) >
POSITION_EPS || it == end() - 1) {
474 Line tmpL(first.back(), *it);
475 Position p = tmpL.getPositionAtDistance(where - seen);
482 for (; it != end(); it++) {
485 assert(first.size() >= 2);
486 assert(second.size() >= 2);
487 assert(first.back() == second.front());
489 return std::pair<PositionVector, PositionVector>(first, second);
495 for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); i++) {
496 if (i != geom.begin()) {
513 for (
int i = 0; i < static_cast<int>(size()); i++) {
514 (*this)[i].add(xoff, yoff, zoff);
521 for (
int i = 0; i < static_cast<int>(size()); i++) {
522 (*this)[i].reshiftRotate(xoff, yoff, rot);
530 return atan2(p1.
x(), p1.
y()) < atan2(p2.
x(), p2.
y());
549 if (p1.
x() != p2.
x()) {
550 return p1.
x() < p2.
x();
552 return p1.
y() < p2.
y();
560 return (P1.
x() - P0.
x()) * (P2.
y() - P0.
y()) - (P2.
x() - P0.
x()) * (P1.
y() - P0.
y());
575 for (const_iterator i = begin(); i != end() - 1; i++) {
578 *i, *(i + 1), line.
p1(), line.
p2()));
587 if (back().distanceTo(v[0]) < 2) {
588 copy(v.begin() + 1, v.end(), back_inserter(*
this));
592 Line l1((*
this)[static_cast<int>(size()) - 2], back());
598 (*this)[
static_cast<int>(size()) - 1] = p;
599 copy(v.begin() + 1, v.end(), back_inserter(*
this));
602 copy(v.begin(), v.end(), back_inserter(*
this));
610 if (back().distanceTo(v[0]) < 2) {
611 copy(v.begin() + 1, v.end(), back_inserter(*
this));
613 copy(v.begin(), v.end(), back_inserter(*
this));
632 const_iterator i = begin();
634 while ((i + 1) != end()
636 seen + (*i).distanceTo(*(i + 1)) < beginOffset) {
637 seen += (*i).distanceTo(*(i + 1));
641 while ((i + 1) != end()
643 seen + (*i).distanceTo(*(i + 1)) < endOffset) {
651 seen += (*i).distanceTo(*(i + 1));
674 const_iterator i = begin();
676 while ((i + 1) != end()
678 seen + (*i).distanceTo2D(*(i + 1)) < beginOffset) {
679 seen += (*i).distanceTo2D(*(i + 1));
683 while ((i + 1) != end()
685 seen + (*i).distanceTo2D(*(i + 1)) < endOffset) {
693 seen += (*i).distanceTo2D(*(i + 1));
712 if (currDist >= 0 && currDist < dist) {
717 for (iterator i = begin(); i != end() - 1; i++, currPos++) {
719 if (currDist >= 0 && currDist < dist) {
725 for (
size_t j = 0; j < pos; j++) {
730 (*
this)[0], (*
this)[1], p);
735 if (np != *(begin())) {
737 if (np != *(begin())) {
740 assert(*(begin()) != *(end() - 1));
748 if (beginIndex < 0) {
749 beginIndex += (
int)size();
752 assert(beginIndex < (
int)size());
753 assert(beginIndex + count <= (
int)size());
755 for (
int i = beginIndex; i < beginIndex + count; ++i) {
772 if (currDist >= 0 && currDist < dist) {
777 for (reverse_iterator i = rbegin(); i != rend() - 1; i++, currPos++) {
779 if (currDist >= 0 && currDist < dist) {
785 for (
size_t j = 0; j < pos; j++) {
791 (*
this)[static_cast<int>(size()) - 1], (*
this)[static_cast<int>(size()) - 2], p);
797 if (np != *(end() - 1)) {
799 if (np != *(end() - 1)) {
802 assert(*(begin()) != *(end() - 1));
810 Line tmp(front(), back());
830 for (const_iterator i = begin(); i != end() - 1; i++) {
834 if (dist < minDist) {
835 nearestPos = pos + seen;
838 if (perpendicular && i != begin()) {
841 if (cornerDist < minDist) {
843 minDist = cornerDist;
846 seen += (*i).distanceTo2D(*(i + 1));
858 for (
int i = 0; i < (
int)size(); i++) {
860 if (dist < minDist) {
874 int insertionIndex = 1;
875 for (
int i = 0; i < (
int)size() - 1; i++) {
877 if (dist < minDist) {
878 insertionIndex = i + 1;
883 return insertionIndex;
890 return front().distanceTo(p);
894 for (const_iterator i = begin(); i != end() - 1; i++) {
896 p, *i, *(i + 1), outIntersection));
902 std::vector<SUMOReal>
904 std::vector<SUMOReal> ret;
905 for (const_iterator i = other.begin(); i != other.end() - 1; i++) {
907 copy(atSegment.begin(), atSegment.end(), back_inserter(ret));
913 std::vector<SUMOReal>
915 std::vector<SUMOReal> ret;
917 for (const_iterator i = begin(); i != end() - 1; i++) {
918 Line l((*i), *(i + 1));
923 ret.push_back(atLength + pos);
938 (*
this)[static_cast<int>(size()) - 2], (*
this)[static_cast<int>(size()) - 1], val);
949 for (const_reverse_iterator i = rbegin(); i != rend(); i++) {
962 for (
int i = 0; i < static_cast<int>(size()); i++) {
966 std::pair<SUMOReal, SUMOReal> offsets =
969 from.
y() - offsets.second, from.
z()));
970 }
else if (i == static_cast<int>(size()) - 1) {
973 std::pair<SUMOReal, SUMOReal> offsets =
976 to.
y() - offsets.second, to.
z()));
982 me.
x() - to.
x(), me.
y() - to.
y()) / 2);
986 std::pair<SUMOReal, SUMOReal> off =
991 std::pair<SUMOReal, SUMOReal> offsets =
993 std::pair<SUMOReal, SUMOReal> offsets2 =
996 Position(from.
x() - offsets.first, from.
y() - offsets.second),
997 Position(me.
x() - offsets.first, me.
y() - offsets.second));
1000 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
1001 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
1043 assert((
int)size() > pos + 1);
1044 return Line((*
this)[pos], (*
this)[pos + 1]);
1056 return lineAt((
int)size() - 2);
1062 if ((*
this)[0] == back()) {
1069 std::vector<SUMOReal>
1071 std::vector<SUMOReal> ret;
1073 for (i = begin(); i != end(); i++) {
1076 for (i = s.begin(); i != s.end(); i++) {
1086 insert(begin() + index, p);
1088 insert(end() + index, p);
1095 assert(index < static_cast<int>(size()));
1096 assert(index + static_cast<int>(size()) >= 0);
1100 (*this)[index +
static_cast<int>(size())] = p;
1123 return size() >= 2 && (*this)[0] == back();
1130 iterator last = begin();
1131 for (iterator i = begin() + 1; i != end() && (!assertLength || size() > 2);) {
1132 if (last->almostSame(*i, minDist)) {
1147 for (iterator i = begin() + 1; i != end() - 1;) {
1161 if (size() == v2.size()) {
1162 for (
int i = 0; i < (
int)size(); i++) {
1163 if ((*
this)[i] != v2[i]) {