40 double maxDistance,
double connectivity,
42 : myNet(net), myMinLinkAngle(minAngle), myMinDistance(minDistance),
43 myMaxDistance(maxDistance), myConnectivity(connectivity), myNumTries(numTries),
44 myNeighbourDistribution(neighborDist) {
68 if (li->getStartNode() == node) {
69 ni = li->getEndNode();
71 ni = li->getStartNode();
79 if (lj->getStartNode() == node) {
80 ni = lj->getEndNode();
82 ni = lj->getStartNode();
100 bool connectable =
true;
121 NGEdgeList::iterator li;
125 const NGNode*
const start = (*li)->getStartNode();
126 const NGNode*
const end = (*li)->getEndNode();
129 if ((baseNode != start) && (baseNode != end) && (newNode != start) && (newNode != end)) {
133 if (connectable && (newNode != start) && (newNode != end)) {
153 NGNodeList::iterator ni;
179 double x = baseNode->
getPosition().
x() + dist * cos(angle);
180 double y = baseNode->
getPosition().
y() + dist * sin(angle);
static double angle2D(const Position &p1, const Position &p2)
Returns the angle between two vectors on a plane The angle is from vector 1 to vector 2,...
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
A netgen-representation of an edge.
The class storing the generated network.
void add(NGNode *node)
Adds the given node to the network.
int nodeNo() const
Returns the number of stored nodes.
std::string getNextFreeID()
Returns the next free id.
A netgen-representation of a node.
bool connected(const NGNode *const node, const bool withDir=false) const
Returns whether the other node is connected.
void setY(double y)
Sets a new value for y-position.
void setX(double x)
Sets a new value for x-position.
const NGEdgeList & getLinks() const
void setMaxNeighbours(int value)
Sets this node's maximum neighbour number.
const Position & getPosition() const
Returns this node's position.
int getMaxNeighbours()
Returns this node's maximum neighbour number.
int myNumTries
Number of tries to create a new node.
double myMaxDistance
Maximum distance allowed between two nodes.
void createNet(int numNodes, bool gridMode)
Builds a NGNet using the set values.
void findPossibleOuterNodes(NGNode *node)
finds possible connections between Node and OuterNodes complying with restrictions
bool createNewNode(NGNode *baseNode, bool gridMode)
Creates new random node.
NGNodeList myOuterNodes
The list of outer nodes.
RandomDistributor< int > myNeighbourDistribution
The distribution of number of neighbours.
bool canConnect(NGNode *baseNode, NGNode *newNode)
Checks whether connecting the given two nodes complies with the set restrictions.
bool checkAngles(const NGNode *const node)
Checks whether the angle of this node's connections are valid.
double myMinLinkAngle
Minimum angle allowed between two links.
void removeOuterNode(NGNode *node)
Removes the given node from the list of outer nodes.
double myConnectivity
Probability of connecting to a existing node if possible.
double myMinDistance
Minimum distance allowed between two nodes.
NGNet & myNet
The network to fill.
NGEdgeList myOuterLinks
The list of outer links.
int myNumNodes
Number of nodes to be created.
NGRandomNetBuilder(NGNet &net, double minAngle, double minDistance, double maxDistance, double connectivity, int numTries, const RandomDistributor< int > &neighborDist)
Constructor.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
double y() const
Returns the y-position.
double length() const
Returns the length.
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
T get(SumoRNG *which=nullptr) const
Draw a sample of the distribution.