52 #ifdef CHECK_MEMORY_LEAKS
54 #endif // CHECK_MEMORY_LEAKS
64 std::copy(v.begin(), v.end(), std::back_inserter(
myCont));
96 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
101 (*(i + 1)).x() - p.
x(),
102 (*(i + 1)).y() - p.
y());
106 (*(
myCont.end() - 1)).x() - p.
x(),
107 (*(
myCont.end() - 1)).y() - p.
y());
109 (*(
myCont.begin())).x() - p.
x(),
110 (*(
myCont.begin())).y() - p.
y());
112 return (!(fabs(angle) <
PI));
118 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
119 if (poly.
around(*i, offset)) {
132 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
147 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
160 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
171 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
219 ContType::const_iterator i =
myCont.begin();
222 const SUMOReal nextLength = (*i).distanceTo(*(i + 1));
223 if (seenLength + nextLength > pos) {
226 seenLength += nextLength;
227 }
while (++i !=
myCont.end() - 1);
234 ContType::const_iterator i =
myCont.begin();
237 const SUMOReal nextLength = (*i).distanceTo2D(*(i + 1));
238 if (seenLength + nextLength > pos) {
241 seenLength += nextLength;
242 }
while (++i !=
myCont.end() - 1);
249 ContType::const_iterator i =
myCont.begin();
252 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
253 if (seenLength + nextLength > pos) {
254 Line l(*i, *(i + 1));
257 seenLength += nextLength;
258 }
while (++i !=
myCont.end() - 1);
265 ContType::const_iterator i =
myCont.begin();
268 SUMOReal nextLength = (*i).distanceTo(*(i + 1));
269 if (seenLength + nextLength > pos) {
270 Line l(*i, *(i + 1));
273 seenLength += nextLength;
274 }
while (++i !=
myCont.end() - 1);
287 return p1 + (p2 - p1) * (pos / dist);
299 return p1 + (p2 - p1) * (pos / dist);
306 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end(); i++) {
317 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end(); i++) {
331 const int endIndex = (
int)tmp.
size() - 1;
335 if (tmp.
area() != 0) {
337 for (
int i = 0; i < endIndex; i++) {
338 const SUMOReal z = tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
340 x += (tmp[i].x() + tmp[i + 1].x()) * z;
341 y += (tmp[i].y() + tmp[i + 1].y()) * z;
349 for (
int i = 0; i < endIndex; i++) {
351 x += (tmp[i].x() + tmp[i + 1].x()) * length / 2;
352 y += (tmp[i].y() + tmp[i + 1].y()) * length / 2;
355 return Position(x / lengthSum, y / lengthSum);
363 for (
size_t i = 0; i <
size(); i++) {
364 myCont[i] = centroid + ((
myCont[i] - centroid) * factor);
381 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
382 len += (*i).distanceTo(*(i + 1));
395 const int endIndex = (
int)tmp.
size() - 1;
397 for (
int i = 0; i < endIndex; i++) {
398 area += tmp[i].x() * tmp[i + 1].y() - tmp[i + 1].x() * tmp[i].y();
409 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
410 if (poly.
around(*i, offset)) {
424 std::pair<PositionVector, PositionVector>
435 ContType::const_iterator it =
myCont.begin() + 1;
448 Position p = tmpL.getPositionAtDistance(where - seen);
455 for (; it !=
myCont.end(); it++) {
458 assert(first.
size() >= 2);
459 assert(second.
size() >= 2);
462 return std::pair<PositionVector, PositionVector>(first, second);
468 for (PositionVector::ContType::const_iterator i = geom.
myCont.begin(); i != geom.
myCont.end(); i++) {
469 if (i != geom.
myCont.begin()) {
486 for (
size_t i = 0; i <
size(); i++) {
487 myCont[i].add(xoff, yoff, zoff);
494 for (
size_t i = 0; i <
size(); i++) {
495 myCont[i].reshiftRotate(xoff, yoff, rot);
503 return atan2(p1.
x(), p1.
y()) < atan2(p2.
x(), p2.
y());
522 if (p1.
x() != p2.
x()) {
523 return p1.
x() < p2.
x();
525 return p1.
y() < p2.
y();
533 return (P1.
x() - P0.
x()) * (P2.
y() - P0.
y()) - (P2.
x() - P0.
x()) * (P1.
y() - P0.
y());
554 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
557 *i, *(i + 1), line.
p1(), line.
p2()));
575 if (l1.intersects(l2) && l1.intersectsAtLength2D(l2) < l1.length2D() - 100) {
611 ContType::const_iterator i =
myCont.begin();
613 while ((i + 1) !=
myCont.end()
615 seen + (*i).distanceTo(*(i + 1)) <
begin) {
616 seen += (*i).distanceTo(*(i + 1));
620 while ((i + 1) !=
myCont.end()
622 seen + (*i).distanceTo(*(i + 1)) <
end) {
630 seen += (*i).distanceTo(*(i + 1));
653 ContType::const_iterator i =
myCont.begin();
655 while ((i + 1) !=
myCont.end()
657 seen + (*i).distanceTo2D(*(i + 1)) <
begin) {
658 seen += (*i).distanceTo2D(*(i + 1));
662 while ((i + 1) !=
myCont.end()
664 seen + (*i).distanceTo2D(*(i + 1)) <
end) {
672 seen += (*i).distanceTo2D(*(i + 1));
691 if (currDist >= 0 && currDist < dist) {
696 for (ContType::iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++, currPos++) {
698 if (currDist >= 0 && currDist < dist) {
704 for (
size_t j = 0; j < pos; j++) {
714 if (np != *(
myCont.begin())) {
716 if (np != *(
myCont.begin())) {
718 assert(
myCont.size() > 1);
735 if (currDist >= 0 && currDist < dist) {
740 for (ContType::reverse_iterator i =
myCont.rbegin(); i !=
myCont.rend() - 1; i++, currPos++) {
742 if (currDist >= 0 && currDist < dist) {
748 for (
size_t j = 0; j < pos; j++) {
760 if (np != *(myCont.end() - 1)) {
761 myCont.erase(myCont.end() - 1);
762 if (np != *(myCont.end() - 1)) {
763 myCont.push_back(np);
764 assert(myCont.size() > 1);
765 assert(*(myCont.begin()) != *(myCont.end() - 1));
793 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
797 if (dist < minDist) {
798 nearestPos = pos + seen;
801 seen += (*i).distanceTo2D(*(i + 1));
813 for (
int i = 0; i < (
int)
size(); i++) {
815 if (dist < minDist) {
829 int insertionIndex = 1;
830 for (
int i = 0; i < (
int)
size() - 1; i++) {
832 if (dist < minDist) {
833 insertionIndex = i + 1;
838 return insertionIndex;
845 return myCont.front().distanceTo(p);
849 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
851 p, *i, *(i + 1), outIntersection));
857 std::vector<SUMOReal>
859 std::vector<SUMOReal> ret;
860 for (ContType::const_iterator i = other.
myCont.begin(); i != other.
myCont.end() - 1; i++) {
862 copy(atSegment.begin(), atSegment.end(), back_inserter(ret));
868 std::vector<SUMOReal>
870 std::vector<SUMOReal> ret;
872 for (ContType::const_iterator i =
myCont.begin(); i !=
myCont.end() - 1; i++) {
873 Line l((*i), *(i + 1));
878 ret.push_back(atLength + pos);
888 assert(
myCont.size() > 1);
894 myCont.erase(myCont.begin());
896 myCont.erase(myCont.end() - 1);
904 for (ContType::const_reverse_iterator i =
myCont.rbegin(); i !=
myCont.rend(); i++) {
917 for (
size_t i = 0; i <
myCont.size(); i++) {
921 std::pair<SUMOReal, SUMOReal> offsets =
924 from.
y() - offsets.second, from.
z()));
925 }
else if (i ==
myCont.size() - 1) {
928 std::pair<SUMOReal, SUMOReal> offsets =
931 to.
y() - offsets.second, to.
z()));
937 me.
x() - to.
x(), me.
y() - to.
y()) / 2);
941 std::pair<SUMOReal, SUMOReal> off =
946 std::pair<SUMOReal, SUMOReal> offsets =
948 std::pair<SUMOReal, SUMOReal> offsets2 =
951 Position(from.
x() - offsets.first, from.
y() - offsets.second),
952 Position(me.
x() - offsets.first, me.
y() - offsets.second));
955 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
956 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
998 assert(
myCont.size() > pos + 1);
1024 std::vector<SUMOReal>
1026 std::vector<SUMOReal> ret;
1027 ContType::const_iterator i;
1082 assert(
size() > index);
1096 ContType::iterator last =
myCont.begin();
1097 for (ContType::iterator i =
myCont.begin() + 1; i !=
myCont.end() && (!assertLength ||
myCont.size() > 2);) {
1098 if (last->almostSame(*i, minDist)) {
1113 for (ContType::iterator i =
myCont.begin() + 1; i !=
myCont.end() - 1;) {
1128 for (
int i = 0; i < (
int)
size(); i++) {
1129 if ((*
this)[i] != v2[i]) {