53 if ((startPos != -1) || (endPos != -1)) {
55 if ((startPos != -1) && (endPos != -1) && (endPos < startPos)) {
56 std::swap(startPos, endPos);
67 myShape = myShape.
splitAt(endPos).first;
72 }
else if (endPos == -1) {
74 myShape = myShape.
splitAt(startPos).second;
80 myShape = myShape.
splitAt(startPos).second;
83 myShape = myShape.getSubpart(startPos, endPos);
88 myShape.push_front(extraFirstPosition);
92 myShape.push_back(extraLastPosition);
95 calculateShapeRotationsAndLengths();
104 if (posOverLane < 0) {
107 }
else if (posOverLane > laneLength) {
152 const std::vector<double>&
154 return myShapeRotations;
158 const std::vector<double>&
160 return myShapeLengths;
167 myShapeRotations.clear();
168 myShapeLengths.clear();
170 int numberOfSegments = (int)myShape.size() - 1;
172 if (numberOfSegments >= 0) {
174 myShapeRotations.reserve(numberOfSegments);
175 myShapeLengths.reserve(numberOfSegments);
177 for (
int i = 0; i < numberOfSegments; i++) {
190 edge(_lane->getParentEdge()),
194 myUseLaneShape(true),
195 myUseLane2LaneShape(false) {
200 const PositionVector& shape,
const std::vector<double>& shapeRotations,
const std::vector<double>& shapeLengths,
const bool _valid) :
202 edge(_lane->getParentEdge()),
206 myUseLaneShape(false),
207 myUseLane2LaneShape(false),
208 mySegmentShape(shape),
209 mySegmentRotations(shapeRotations),
210 mySegmentLengths(shapeLengths) {
218 junction(currentLane->getParentEdge()->getGNEJunctionDestiny()),
220 myUseLaneShape(false),
221 myUseLane2LaneShape(true),
222 mySegmentShape(currentLane->getLane2laneConnections().connectionsMap.at(nextLane).getShape()),
223 mySegmentRotations(currentLane->getLane2laneConnections().connectionsMap.at(nextLane).getShapeRotations()),
224 mySegmentLengths(currentLane->getLane2laneConnections().connectionsMap.at(nextLane).getShapeLengths()) {
230 mySegmentShape = shape;
231 mySegmentRotations = shapeRotations;
232 mySegmentLengths = shapeLengths;
239 nextLane(_nextLane) {
245 if (myUseLaneShape) {
246 return lane->getLaneShape();
248 return mySegmentShape;
253 const std::vector<double>&
255 if (myUseLaneShape) {
256 return lane->getShapeRotations();
258 return mySegmentRotations;
263 const std::vector<double>&
265 if (myUseLaneShape) {
266 return lane->getShapeLengths();
268 return mySegmentLengths;
288 const PositionVector& laneShape,
const std::vector<double>& laneShapeRotations,
const std::vector<double>& laneShapeLengths,
const bool valid) {
303 myShapeSegments.at(segmentIndex).update(newLaneShape, newLaneShapeRotations, newLaneShapeLengths);
356 b.
add(i.getShape().getBoxBoundary());
362 std::vector<GNEGeometry::SegmentGeometry::Segment>::const_iterator
368 std::vector<GNEGeometry::SegmentGeometry::Segment>::const_iterator
396 myOriginLane(originLane) {
403 connectionsMap.clear();
405 for (
const auto& outgoingEdge : myOriginLane->getParentEdge()->getGNEJunctionDestiny()->getGNEOutgoingEdges()) {
406 for (
const auto& outgoingLane : outgoingEdge->getLanes()) {
408 const NBEdge* NBEdgeFrom = myOriginLane->getParentEdge()->getNBEdge();
409 const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
421 connectionsMap[outgoingLane].updateGeometryShape({
422 NBEdgeFrom->
getLaneShape(myOriginLane->getIndex()).back(),
423 NBEdgeTo->
getLaneShape(outgoingLane->getIndex()).front()});
435 myHierarchicalElement(hierarchicalElement) {}
441 connectionPositions.clear();
442 symbolsPositionAndRotation.clear();
444 for (
const auto& edge : myHierarchicalElement->getParentEdges()) {
445 for (
const auto& lane : edge->getLanes()) {
446 std::pair<Position, double> posRot;
448 if (lane->getLaneShape().length() - 6 > 0) {
449 posRot.first = lane->getLaneShape().positionAtOffset(lane->getLaneShape().length() - 6);
450 posRot.second = lane->getLaneShape().rotationDegreeAtOffset(lane->getLaneShape().length() - 6);
452 posRot.first = lane->getLaneShape().positionAtOffset(lane->getLaneShape().length());
453 posRot.second = lane->getLaneShape().rotationDegreeAtOffset(lane->getLaneShape().length());
455 symbolsPositionAndRotation.push_back(posRot);
459 for (
const auto& lane : myHierarchicalElement->getParentLanes()) {
460 std::pair<Position, double> posRot;
462 if (lane->getLaneShape().length() - 6 > 0) {
463 posRot.first = lane->getLaneShape().positionAtOffset(lane->getLaneShape().length() - 6);
464 posRot.second = lane->getLaneShape().rotationDegreeAtOffset(lane->getLaneShape().length() - 6);
466 posRot.first = lane->getLaneShape().positionAtOffset(lane->getLaneShape().length());
467 posRot.second = lane->getLaneShape().rotationDegreeAtOffset(lane->getLaneShape().length());
469 symbolsPositionAndRotation.push_back(posRot);
472 for (
const auto& additional : myHierarchicalElement->getParentAdditionals()) {
474 if (additional->getPositionInView() != myHierarchicalElement->getPositionInView()) {
475 std::vector<Position> posConnection;
476 double A = std::abs(additional->getPositionInView().x() - myHierarchicalElement->getPositionInView().x());
477 double B = std::abs(additional->getPositionInView().y() - myHierarchicalElement->getPositionInView().y());
479 posConnection.push_back(additional->getPositionInView());
480 if (myHierarchicalElement->getPositionInView().x() > additional->getPositionInView().x()) {
481 if (myHierarchicalElement->getPositionInView().y() > additional->getPositionInView().y()) {
482 posConnection.push_back(
Position(additional->getPositionInView().x() + A, additional->getPositionInView().y()));
484 posConnection.push_back(
Position(additional->getPositionInView().x(), additional->getPositionInView().y() - B));
487 if (myHierarchicalElement->getPositionInView().y() > additional->getPositionInView().y()) {
488 posConnection.push_back(
Position(additional->getPositionInView().x(), additional->getPositionInView().y() + B));
490 posConnection.push_back(
Position(additional->getPositionInView().x() - A, additional->getPositionInView().y()));
493 posConnection.push_back(myHierarchicalElement->getPositionInView());
494 connectionPositions.push_back(posConnection);
498 for (
const auto& symbol : symbolsPositionAndRotation) {
499 std::vector<Position> posConnection;
500 double A = std::abs(symbol.first.x() - myHierarchicalElement->getPositionInView().x());
501 double B = std::abs(symbol.first.y() - myHierarchicalElement->getPositionInView().y());
503 posConnection.push_back(symbol.first);
504 if (myHierarchicalElement->getPositionInView().x() > symbol.first.x()) {
505 if (myHierarchicalElement->getPositionInView().y() > symbol.first.y()) {
506 posConnection.push_back(
Position(symbol.first.x() + A, symbol.first.y()));
508 posConnection.push_back(
Position(symbol.first.x(), symbol.first.y() - B));
511 if (myHierarchicalElement->getPositionInView().y() > symbol.first.y()) {
512 posConnection.push_back(
Position(symbol.first.x(), symbol.first.y() + B));
514 posConnection.push_back(
Position(symbol.first.x() - A, symbol.first.y()));
517 posConnection.push_back(myHierarchicalElement->getPositionInView());
518 connectionPositions.push_back(posConnection);
526 for (
const PositionVector& connectionPosition : connectionPositions) {
530 glTranslated(0, 0, parentType - 0.01);
534 for (PositionVector::const_iterator j = connectionPosition.begin(); (j + 1) != connectionPosition.end(); ++j) {
550 return ((
double)atan2((second.
x() - first.
x()), (first.
y() - second.
y())) * (double) 180.0 / (
double)
M_PI);
564 if (startLane && endLane && (startLane == endLane) && (startPos != -1) && (endPos != -1)) {
565 if (startPos >= endPos) {
570 if ((startPos != -1) && startLane) {
579 if ((endPos != -1) && endLane) {
597 if (edges.size() > 0) {
599 if (fromLane == toLane) {
601 if (fromLane ==
nullptr) {
608 std::vector<GNELane*> lanes;
610 lanes.reserve(edges.size());
612 for (
auto edgeParent = edges.begin(); edgeParent != edges.end(); edgeParent++) {
613 GNELane* allowedLane =
nullptr;
614 if (edgeParent == edges.begin()) {
615 allowedLane = fromLane;
616 }
else if (edgeParent == (edges.end() - 1)) {
617 allowedLane = toLane;
620 allowedLane = (*edgeParent)->getLaneByDisallowedVClass(vClass);
623 allowedLane = (*edgeParent)->getLaneByAllowedVClass(vClass);
626 if (allowedLane ==
nullptr) {
627 allowedLane = (*edgeParent)->getLanes().front();
630 lanes.push_back(allowedLane);
641 double startPos,
double endPos,
const Position& extraFirstPosition,
const Position& extraLastPosition) {
645 if (lanes.size() > 0) {
647 if (lanes.size() == 1) {
655 trimmedLane.
updateGeometryShape(lanes.front()->getLaneShape(), startPos, endPos, extraFirstPosition, extraLastPosition);
667 for (
int i = 0; i < (int)lanes.size(); i++) {
669 const GNELane* lane = lanes.at(i);
673 if ((lanes.at(i) == lanes.front()) && (startPos != -1)) {
682 frontTrimmedLane.getShape(),
684 frontTrimmedLane.getShapeLengths(),
true);
685 }
else if ((lane == lanes.back()) && (endPos != -1)) {
703 if ((i + 1) < (int)lanes.size()) {
705 const GNELane* nextLane = lanes.at(i + 1);
722 if ((segmentGeometry.
size() == 1) && (segmentGeometry.
front().
edge == edge)) {
739 std::vector<GNEGeometry::SegmentGeometry::SegmentToUpdate> segmentsToUpdate;
741 for (
auto segment = segmentGeometry.
begin(); segment != segmentGeometry.
end(); segment++) {
742 if (segment->edge == edge) {
744 const int index = (int)(segment - segmentGeometry.
begin());
748 if (((segment + 1) != segmentGeometry.
end()) && (segment + 1)->junction) {
754 for (
const auto& segmentToUpdate : segmentsToUpdate) {
756 if (segmentToUpdate.lane->getLaneShape().size() > 0) {
758 if ((segmentToUpdate.index == 0) && (startPos != -1)) {
770 }
else if ((segmentToUpdate.index == (segmentGeometry.
size() - 1)) && (endPos != -1)) {
785 if (segmentToUpdate.lane->getLane2laneConnections().connectionsMap.count(segmentToUpdate.nextLane) > 0) {
787 segmentGeometry.
updateLane2LaneSegment(segmentToUpdate.index, segmentToUpdate.lane, segmentToUpdate.nextLane);
807 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
821 const std::vector<double>& lengths,
const std::vector<RGBColor>& colors,
double width) {
833 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
839 }
else if (colors.size() > 0) {
862 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);