Skip to content

Commit

Permalink
No junctions don't use boundaries. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent e0f6e7f commit bc3999f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 26 deletions.
8 changes: 6 additions & 2 deletions src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,9 @@ GNENet::computeAndUpdate(OptionsCont& neteditOptions, bool volatileOptions) {
// removes all junctions of grid
WRITE_GLDEBUG("Removing junctions during recomputing");
for (const auto& junction : myAttributeCarriers->getJunctions()) {
myGrid.removeAdditionalGLObject(junction.second.second);
if (junction.second.second->isJunctionInGrid()) {
myGrid.removeAdditionalGLObject(junction.second.second);
}
}
// remove all edges from grid
WRITE_GLDEBUG("Removing edges during recomputing");
Expand Down Expand Up @@ -2827,7 +2829,9 @@ GNENet::computeAndUpdate(OptionsCont& neteditOptions, bool volatileOptions) {
// update centering boundary
junction.second.second->updateCenteringBoundary(false);
// add junction in grid again
myGrid.addAdditionalGLObject(junction.second.second);
if (junction.second.second->isJunctionInGrid()) {
myGrid.addAdditionalGLObject(junction.second.second);
}
}
// insert all edges from grid again
WRITE_GLDEBUG("Add edges during recomputing after calling myNetBuilder->compute(...)");
Expand Down
6 changes: 6 additions & 0 deletions src/netedit/GNENetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ GNENetHelper::AttributeCarriers::registerEdge(GNEEdge* edge) {
// Add references into GNEJunctions
edge->getFromJunction()->addOutgoingGNEEdge(edge);
edge->getToJunction()->addIncomingGNEEdge(edge);
// update boundaries of both junctions (to remove it from Grid)
edge->getFromJunction()->updateCenteringBoundary(true);
edge->getToJunction()->updateCenteringBoundary(true);
return edge;
}

Expand Down Expand Up @@ -2304,6 +2307,9 @@ GNENetHelper::AttributeCarriers::deleteSingleEdge(GNEEdge* edge) {
// Remove refrences from GNEJunctions
edge->getFromJunction()->removeOutgoingGNEEdge(edge);
edge->getToJunction()->removeIncomingGNEEdge(edge);
// update boundaries of both junctions (to remove it from Grid)
edge->getFromJunction()->updateCenteringBoundary(true);
edge->getToJunction()->updateCenteringBoundary(true);
// get template editor
GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
// check if we have to remove template
Expand Down
11 changes: 7 additions & 4 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ GNEEdge::updateCenteringBoundary(const bool updateGrid) {
}
}
// add junction positions
myEdgeBoundary.add(getFromJunction()->getPositionInView());
myEdgeBoundary.add(getToJunction()->getPositionInView());
myEdgeBoundary.add(getFromJunction()->getCenteringBoundary());
myEdgeBoundary.add(getToJunction()->getCenteringBoundary());
// grow boundary
myEdgeBoundary.grow(5);
// add object into net
Expand Down Expand Up @@ -559,12 +559,15 @@ GNEEdge::getOppositeEdges() const {

void
GNEEdge::drawGL(const GUIVisualizationSettings& s) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// draw draw lanes
for (const auto& lane : myLanes) {
lane->drawGL(s);
}
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// draw junctions
getFromJunction()->drawGL(s);
getToJunction()->drawGL(s);
// get detail level
const auto detailLevel = s.getDetailLevel(1);
// draw geometry points
Expand Down
50 changes: 32 additions & 18 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@
GNEJunction::GNEJunction(GNENet* net, NBNode* nbn, bool loaded) :
GNENetworkElement(net, nbn->getID(), GLO_JUNCTION, SUMO_TAG_JUNCTION,
GUIIconSubSys::getIcon(GUIIcon::JUNCTION), {}, {}, {}, {}, {}, {}),
myNBNode(nbn),
myMaxDrawingSize(1),
myAmCreateEdgeSource(false),
myLogicStatus(loaded ? FEATURE_LOADED : FEATURE_GUESSED),
myAmResponsible(false),
myHasValidLogic(loaded),
myAmTLSSelected(false),
myColorForMissingConnections(false),
myTesselation(nbn->getID(), "", RGBColor::MAGENTA, nbn->getShape(), false, true, 0),
myExaggeration(1) {
myNBNode(nbn),
myJunctionInGrid(true),
myMaxDrawingSize(1),
myAmCreateEdgeSource(false),
myLogicStatus(loaded ? FEATURE_LOADED : FEATURE_GUESSED),
myAmResponsible(false),
myHasValidLogic(loaded),
myAmTLSSelected(false),
myColorForMissingConnections(false),
myTesselation(nbn->getID(), "", RGBColor::MAGENTA, nbn->getShape(), false, true, 0),
myExaggeration(1) {
// update centering boundary without updating grid
updateCenteringBoundary(false);
}
Expand Down Expand Up @@ -563,8 +564,8 @@ GNEJunction::getCenteringBoundary() const {

void
GNEJunction::updateCenteringBoundary(const bool updateGrid) {
// Remove object from net
if (updateGrid) {
// Remove object from grid
if (myJunctionInGrid && updateGrid) {
myNet->removeGLObjectFromGrid(this);
}
// calculate boundary using a radius bigger than geometry point
Expand Down Expand Up @@ -597,9 +598,16 @@ GNEJunction::updateCenteringBoundary(const bool updateGrid) {
myJunctionBoundary.add(boundary);
}
}
// add object into net

// add object into grid
if (updateGrid) {
myNet->addGLObjectIntoGrid(this);
// if junction has at least one edge, then don't add in grid (because uses the edge's grid)
if (myGNEIncomingEdges.size() + myGNEOutgoingEdges.size() > 0) {
myJunctionInGrid = false;
} else {
myJunctionInGrid = true;
myNet->addGLObjectIntoGrid(this);
}
}
// trigger rebuilding tesselation
myExaggeration = 2;
Expand All @@ -609,7 +617,9 @@ GNEJunction::updateCenteringBoundary(const bool updateGrid) {
void
GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
if (myJunctionInGrid) {
GLHelper::drawBoundary(s, getCenteringBoundary());
}
// get junction exaggeration
const double junctionExaggeration = getExaggeration(s);
// get detail level
Expand Down Expand Up @@ -718,6 +728,12 @@ GNEJunction::getJunctionNeighbours() const {
}


bool
GNEJunction::isJunctionInGrid() const {
return myJunctionInGrid;
}


void
GNEJunction::addIncomingGNEEdge(GNEEdge* edge) {
// Check if incoming edge was already inserted
Expand Down Expand Up @@ -1754,9 +1770,7 @@ GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s, GUIVisualiz
}
// draw child demand elements
for (const auto& demandElement : getChildDemandElements()) {
if (!demandElement->getTagProperty().isPlacedInRTree()) {
demandElement->drawGL(s);
}
demandElement->drawGL(s);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @brief return GNEJunction neighbours
std::vector<GNEJunction*> getJunctionNeighbours() const;

/// @brief check if junction is currently in grid
bool isJunctionInGrid() const;

/// @brief add incoming GNEEdge
void addIncomingGNEEdge(GNEEdge* edge);

Expand Down Expand Up @@ -296,11 +299,14 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
void removeInternalLane(const GNEInternalLane* internalLane);

protected:
/// @brief A reference to the represented junction
NBNode* myNBNode;

/// @brief edge boundary
Boundary myJunctionBoundary;

/// @brief A reference to the represented junction
NBNode* myNBNode;
/// @brief flag for check if junction is currently in grid
bool myJunctionInGrid;

/// @brief vector with the (child) incomings GNEEdges vinculated with this junction
std::vector<GNEEdge*> myGNEIncomingEdges;
Expand Down

0 comments on commit bc3999f

Please sign in to comment.