forked from SRaent/FiNTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunited_junction.cpp
65 lines (53 loc) · 1.5 KB
/
united_junction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef UNITED_JUNCTION_CPP
#define UNITED_JUNCTION_CPP UNITED_JUNCTION_CPP
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include "united_junction.h"
#include "analyse.cpp"
united_junction::united_junction(node* n, unsigned long long d){
dist = d;
nodes = n->unite_junctions(dist);
for (auto it = nodes.begin(); it != nodes.end(); ++it){
(*it)->j = this;
}
find_outgoing_connections();
determine_position();
}
void united_junction::find_outgoing_connections(){
for ( auto it = nodes.begin(); it != nodes.end(); ++it){
for ( auto jt = (*it)->connections.begin(); jt != (*it)->connections.end(); ++jt){
if ((*it)->junc_free_path(dist,(*jt), NULL)){
outgoing_connections.push_back(new node*[2]);
(outgoing_connections.back())[0] = *it;
(outgoing_connections.back())[1] = *jt;
}
}
}
}
void united_junction::determine_position(){
x = 0;
y = 0;
// nodes that have multiple outgoing connections are purpously weightet stronger
for (auto it = outgoing_connections.begin(); it != outgoing_connections.end(); ++it){
x += (*it)[0]->x;
y += (*it)[0]->y;
}
x = x/outgoing_connections.size();
y = y/outgoing_connections.size();
}
united_junction::~united_junction(){
for (const auto& n:nodes){
n->j=NULL;
}
for (auto it = outgoing_connections.begin(); it != outgoing_connections.end(); ++it){
delete[] (*it);
}
}
#endif