/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Node.cpp14/// @author Jakub Sevcik (RICE)15/// @author Jan Prikryl (RICE)16/// @date 2019-12-1517///18/// @note based on work 2017 Ahmad Khaled, Ahmad Essam, Omnia Zakaria, Mary Nader19///20// Representation of electric circuit nodes, i.e. wire junctions and connection points.21/****************************************************************************/22#include <config.h>2324#include <string>25#include <algorithm>26#include "Node.h"27#include "Element.h"282930// A constructor, same functionality as "init" functions31Node::Node(std::string name, int id) {32isground = false;33this->name = name; // unique property, each object has distinctive and unique name34this->id = id; // a sequential ID number, might be useful when making the equation35this->num_matrixRow = -1;36this->num_matrixCol = -1;37this->voltage = 0;38this->elements = new std::vector<Element*>(0);39isremovable = false;40}4142// connects an element to the node43void Node::addElement(Element* element) {44elements->push_back(element);45}4647void Node::eraseElement(Element* element) {48elements->erase(std::remove(elements->begin(), elements->end(), element), elements->end());49}5051// getters and setters52double Node::getVoltage() {53return this->voltage;54}5556void Node::setVoltage(double volt) {57this->voltage = volt;58}5960int Node::getNumOfElements() {61return (int) elements->size();62}6364std::string& Node::getName() {65return this->name;66}6768bool Node::isGround() {69return this->isground;70}7172void Node::setGround(bool newIsGround) {73this->isground = newIsGround;74}7576int Node::getId() {77return this->id;78}7980void Node::setId(int newId) {81this->id = newId;82}8384void Node::setNumMatrixRow(int num) {85this->num_matrixRow = num;86}8788int Node::getNumMatrixRow() {89return this->num_matrixRow;90}9192void Node::setNumMatrixCol(int num) {93this->num_matrixCol = num;94}9596int Node::getNumMatrixCol() {97return this->num_matrixCol;98}99100std::vector<Element*>* Node::getElements() {101return elements;102}103104void Node::setRemovability(bool newIsRemovable) {105this->isremovable = newIsRemovable;106}107108Element* Node::getAnOtherElement(Element* element) {109for (Element* it : *this->getElements()) {110if (it != element) {111return it;112}113}114return nullptr;115}116117118