47 double maxDistance,
double connectivity,
72 NGEdgeList::iterator li;
76 if ((*li)->getStartNode() == node) {
77 ni = (*li)->getEndNode();
79 ni = (*li)->getStartNode();
85 NGEdgeList::iterator lj;
88 if ((*lj)->getStartNode() == node) {
89 ni = (*lj)->getEndNode();
91 ni = (*lj)->getStartNode();
109 bool connectable =
true;
130 NGEdgeList::iterator li;
134 const NGNode*
const start = (*li)->getStartNode();
135 const NGNode*
const end = (*li)->getEndNode();
138 if ((baseNode != start) && (baseNode != end) && (newNode != start) && (newNode != end)) {
139 connectable = !n.intersects(p1, p2);
142 if (connectable && (newNode != start) && (newNode != end)) {
162 NGNodeList::iterator ni;
182 double x = baseNode->
getPosition().
x() + dist * cos(angle);
183 double y = baseNode->
getPosition().
y() + dist * sin(angle);
A netgen-representation of an edge.
NGNodeList myOuterNodes
The list of outer nodes.
void findPossibleOuterNodes(NGNode *node)
finds possible connections between Node and OuterNodes complying with restrictions ...
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void createNet(int numNodes)
Builds a NGNet using the set values.
double myMinLinkAngle
Minimum angle allowed between two links.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
double y() const
Returns the y-position.
double myMinDistance
Minimum distance allowed between two nodes.
double myConnectivity
Probability of connecting to a existing node if possible.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
double x() const
Returns the x-position.
int nodeNo() const
Returns the number of stored nodes.
bool checkAngles(NGNode *node)
Checks whether the angle of this node's connections are valid.
bool canConnect(NGNode *baseNode, NGNode *newNode)
Checks whether connecting the given two nodes complies with the set restrictions. ...
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
void setX(double x)
Sets a new value for x-position.
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
A point in 2D or 3D with translation and scaling methods.
bool connected(NGNode *node) const
Returns whether the other node is connected.
std::string getNextFreeID()
Returns the next free id.
int getMaxNeighbours()
Returns this node's maximum neighbour number.
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...
int myNumNodes
Number of nodes to be created.
The class storing the generated network.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
void removeOuterNode(NGNode *node)
Removes the given node from the list of outer nodes.
double length() const
Returns the length.
NGEdgeList myOuterLinks
The list of outer links.
NGRandomNetBuilder(NGNet &net, double minAngle, double minDistance, double maxDistance, double connectivity, int numTries, const RandomDistributor< int > &neighborDist)
Constructor.
void setMaxNeighbours(int value)
Sets this node's maximum neighbour number.
const Position & getPosition() const
Returns this node's position.
double myMaxDistance
Maximum distance allowed between two nodes.
A netgen-representation of a node.
void setY(double y)
Sets a new value for y-position.
bool createNewNode(NGNode *baseNode)
Creates new random node.
int myNumTries
Number of tries to create a new node.
RandomDistributor< int > myNeighbourDistribution
The distribution of number of neighbours.
NGEdgeList LinkList
List of connected links.
void add(NGNode *node)
Adds the given node to the network.
NGNet & myNet
The network to fill.