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));
385 const int endIndex = (
int)tmp.size() - 1;
387 for (
int i = 0; i < endIndex; i++) {
388 area += tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
399 for (const_iterator i = begin(); i != end() - 1; i++) {
400 if (poly.
around(*i, offset)) {
414 std::pair<PositionVector, PositionVector>
425 const_iterator it = begin() + 1;
426 SUMOReal next = first.back().distanceTo(*it);
432 next = first.back().distanceTo(*it);
434 if (fabs(where - (seen + next)) >
POSITION_EPS || it == end() - 1) {
437 Line tmpL(first.back(), *it);
438 Position p = tmpL.getPositionAtDistance(where - seen);
445 for (; it != end(); it++) {
448 assert(first.size() >= 2);
449 assert(second.size() >= 2);
450 assert(first.back() == second.front());
452 return std::pair<PositionVector, PositionVector>(first, second);
458 for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); i++) {
459 if (i != geom.begin()) {
476 for (
int i = 0; i < static_cast<int>(size()); i++) {
477 (*this)[i].add(xoff, yoff, zoff);
484 for (
int i = 0; i < static_cast<int>(size()); i++) {
485 (*this)[i].reshiftRotate(xoff, yoff, rot);
493 return atan2(p1.
x(), p1.
y()) < atan2(p2.
x(), p2.
y());
512 if (p1.
x() != p2.
x()) {
513 return p1.
x() < p2.
x();
515 return p1.
y() < p2.
y();
523 return (P1.
x() - P0.
x()) * (P2.
y() - P0.
y()) - (P2.
x() - P0.
x()) * (P1.
y() - P0.
y());
538 for (const_iterator i = begin(); i != end() - 1; i++) {
541 *i, *(i + 1), line.
p1(), line.
p2()));
550 if (back().distanceTo(v[0]) < 2) {
551 copy(v.begin() + 1, v.end(), back_inserter(*
this));
555 Line l1((*
this)[static_cast<int>(size()) - 2], back());
561 (*this)[
static_cast<int>(size()) - 1] = p;
562 copy(v.begin() + 1, v.end(), back_inserter(*
this));
565 copy(v.begin(), v.end(), back_inserter(*
this));
573 if (back().distanceTo(v[0]) < 2) {
574 copy(v.begin() + 1, v.end(), back_inserter(*
this));
576 copy(v.begin(), v.end(), back_inserter(*
this));
595 const_iterator i = begin();
597 while ((i + 1) != end()
599 seen + (*i).distanceTo(*(i + 1)) < beginOffset) {
600 seen += (*i).distanceTo(*(i + 1));
604 while ((i + 1) != end()
606 seen + (*i).distanceTo(*(i + 1)) < endOffset) {
614 seen += (*i).distanceTo(*(i + 1));
637 const_iterator i = begin();
639 while ((i + 1) != end()
641 seen + (*i).distanceTo2D(*(i + 1)) < beginOffset) {
642 seen += (*i).distanceTo2D(*(i + 1));
646 while ((i + 1) != end()
648 seen + (*i).distanceTo2D(*(i + 1)) < endOffset) {
656 seen += (*i).distanceTo2D(*(i + 1));
675 if (currDist >= 0 && currDist < dist) {
680 for (iterator i = begin(); i != end() - 1; i++, currPos++) {
682 if (currDist >= 0 && currDist < dist) {
688 for (
size_t j = 0; j < pos; j++) {
693 (*
this)[0], (*
this)[1], p);
698 if (np != *(begin())) {
700 if (np != *(begin())) {
703 assert(*(begin()) != *(end() - 1));
719 if (currDist >= 0 && currDist < dist) {
724 for (reverse_iterator i = rbegin(); i != rend() - 1; i++, currPos++) {
726 if (currDist >= 0 && currDist < dist) {
732 for (
size_t j = 0; j < pos; j++) {
738 (*
this)[static_cast<int>(size()) - 1], (*
this)[static_cast<int>(size()) - 2], p);
744 if (np != *(end() - 1)) {
746 if (np != *(end() - 1)) {
749 assert(*(begin()) != *(end() - 1));
757 Line tmp(front(), back());
777 for (const_iterator i = begin(); i != end() - 1; i++) {
781 if (dist < minDist) {
782 nearestPos = pos + seen;
785 if (perpendicular && i != begin()) {
788 if (cornerDist < minDist) {
790 minDist = cornerDist;
793 seen += (*i).distanceTo2D(*(i + 1));
805 for (
int i = 0; i < (
int)size(); i++) {
807 if (dist < minDist) {
821 int insertionIndex = 1;
822 for (
int i = 0; i < (
int)size() - 1; i++) {
824 if (dist < minDist) {
825 insertionIndex = i + 1;
830 return insertionIndex;
837 return front().distanceTo(p);
841 for (const_iterator i = begin(); i != end() - 1; i++) {
843 p, *i, *(i + 1), outIntersection));
849 std::vector<SUMOReal>
851 std::vector<SUMOReal> ret;
852 for (const_iterator i = other.begin(); i != other.end() - 1; i++) {
854 copy(atSegment.begin(), atSegment.end(), back_inserter(ret));
860 std::vector<SUMOReal>
862 std::vector<SUMOReal> ret;
864 for (const_iterator i = begin(); i != end() - 1; i++) {
865 Line l((*i), *(i + 1));
870 ret.push_back(atLength + pos);
885 (*
this)[static_cast<int>(size()) - 2], (*
this)[static_cast<int>(size()) - 1], val);
896 for (const_reverse_iterator i = rbegin(); i != rend(); i++) {
909 for (
int i = 0; i < static_cast<int>(size()); i++) {
913 std::pair<SUMOReal, SUMOReal> offsets =
916 from.
y() - offsets.second, from.
z()));
917 }
else if (i == static_cast<int>(size()) - 1) {
920 std::pair<SUMOReal, SUMOReal> offsets =
923 to.
y() - offsets.second, to.
z()));
929 me.
x() - to.
x(), me.
y() - to.
y()) / 2);
933 std::pair<SUMOReal, SUMOReal> off =
938 std::pair<SUMOReal, SUMOReal> offsets =
940 std::pair<SUMOReal, SUMOReal> offsets2 =
943 Position(from.
x() - offsets.first, from.
y() - offsets.second),
944 Position(me.
x() - offsets.first, me.
y() - offsets.second));
947 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
948 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
990 assert((
int)size() > pos + 1);
991 return Line((*
this)[pos], (*
this)[pos + 1]);
1003 return lineAt((
int)size() - 2);
1009 if ((*
this)[0] == back()) {
1016 std::vector<SUMOReal>
1018 std::vector<SUMOReal> ret;
1020 for (i = begin(); i != end(); i++) {
1023 for (i = s.begin(); i != s.end(); i++) {
1033 insert(begin() + index, p);
1035 insert(end() + index, p);
1042 assert(index < static_cast<int>(size()));
1043 assert(index + static_cast<int>(size()) >= 0);
1047 (*this)[index +
static_cast<int>(size())] = p;
1070 return size() >= 2 && (*this)[0] == back();
1077 iterator last = begin();
1078 for (iterator i = begin() + 1; i != end() && (!assertLength || size() > 2);) {
1079 if (last->almostSame(*i, minDist)) {
1094 for (iterator i = begin() + 1; i != end() - 1;) {
1108 if (size() == v2.size()) {
1109 for (
int i = 0; i < (
int)size(); i++) {
1110 if ((*
this)[i] != v2[i]) {