RDG-Networks 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {RDG_Networks-0.1.2.dist-info → RDG_Networks-0.1.4.dist-info}/METADATA +1 -1
- RDG_Networks-0.1.4.dist-info/RECORD +13 -0
- RDG_networks/draw_segments.py +1 -1
- RDG_networks/generate_line_segments.py +13 -11
- RDG_networks/get_intersection_segments.py +12 -2
- RDG_Networks-0.1.2.dist-info/RECORD +0 -13
- {RDG_Networks-0.1.2.dist-info → RDG_Networks-0.1.4.dist-info}/LICENSE.txt +0 -0
- {RDG_Networks-0.1.2.dist-info → RDG_Networks-0.1.4.dist-info}/WHEEL +0 -0
- {RDG_Networks-0.1.2.dist-info → RDG_Networks-0.1.4.dist-info}/entry_points.txt +0 -0
- {RDG_Networks-0.1.2.dist-info → RDG_Networks-0.1.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
RDG_networks/Classes.py,sha256=_9X3JPHFAYYlaC8IZ_H9__sfz99G5l9UfPl65lL60_4,7977
|
2
|
+
RDG_networks/__init__.py,sha256=lbEZ5NwKERxQ4oLXTxWoe8q8f6c_iSx4ZQXDwgx_OP4,759
|
3
|
+
RDG_networks/draw_segments.py,sha256=0jc1H_8YUUH7YSCtIfzgZdeIZRTX--FZUUGo2m45Lxo,983
|
4
|
+
RDG_networks/generate_line_network.py,sha256=F8p7AFS0vYQEfTdTtTMhP0yK92VFq3FakaSte6K5AOw,1139
|
5
|
+
RDG_networks/generate_line_segments.py,sha256=j5IuC49ms_0GBiCx8bBK8KeO4XM8CYIylztrLf5RgjU,9002
|
6
|
+
RDG_networks/get_intersection_segments.py,sha256=T9a8UGxcSSglJNt7k5BzAHmDCTvo-D5E75sqOyZNstE,2751
|
7
|
+
RDG_networks/sample_in_polygon.py,sha256=qpPpW-Da1vK8ZkVWMJ0zBsE8IgyMB619gCdybSkzKSQ,1605
|
8
|
+
RDG_Networks-0.1.4.dist-info/LICENSE.txt,sha256=Zlv8517YKFuHaaqksoTKeIiQBl9DGxhUdb_0kJg0NOE,1066
|
9
|
+
RDG_Networks-0.1.4.dist-info/METADATA,sha256=Zj-Za9uEKTgbUPX0xVvLMHsCR6vGWMasZreiqc3Knv8,1756
|
10
|
+
RDG_Networks-0.1.4.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
11
|
+
RDG_Networks-0.1.4.dist-info/entry_points.txt,sha256=4LC5qJH7VKpjuuhDR3HpJulO4qy9K5UlAUOGBg6ctxA,268
|
12
|
+
RDG_Networks-0.1.4.dist-info/top_level.txt,sha256=4gUUYafD5Al9V8ZSiViVGYHpRMMCsCBcGgCNodk9Syg,13
|
13
|
+
RDG_Networks-0.1.4.dist-info/RECORD,,
|
RDG_networks/draw_segments.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import matplotlib.pyplot as plt
|
2
2
|
from typing import List, Optional
|
3
3
|
|
4
|
-
from
|
4
|
+
from Classes import LineSegment
|
5
5
|
|
6
6
|
def draw_segments(segments: List[LineSegment], fig: Optional[plt.Figure] = None, ax: Optional[plt.Axes] = None) -> None:
|
7
7
|
"""
|
@@ -4,8 +4,8 @@ import numpy as np
|
|
4
4
|
import random
|
5
5
|
from typing import List, Tuple, Union
|
6
6
|
|
7
|
-
from
|
8
|
-
from
|
7
|
+
from Classes import Line, LineSegment, Polygon
|
8
|
+
from sample_in_polygon import sample_in_polygon
|
9
9
|
|
10
10
|
def doLinesIntersect(line1: Line, line2: Line) -> Tuple[bool, Union[Tuple[float, float], None]]:
|
11
11
|
"""
|
@@ -62,20 +62,20 @@ def get_vertices(vertices, index_begin, index_end, vertex_begin, vertex_end):
|
|
62
62
|
|
63
63
|
return vertices1, vertices2
|
64
64
|
|
65
|
-
def update_polygon_arr(polygon_id, polygon_arr, neighbor1, neighbor2, vertex_begin, vertex_end
|
65
|
+
def update_polygon_arr(polygon_id, polygon_arr, neighbor1, neighbor2, vertex_begin, vertex_end):
|
66
66
|
|
67
67
|
vertices=polygon_arr[polygon_id]['vertices']
|
68
68
|
cycle = polygon_arr[polygon_id]['faces']
|
69
69
|
index_begin, index_end = (cycle.index(neighbor1), cycle.index(neighbor2))
|
70
70
|
|
71
|
-
cycle1, cycle2 = get_cyles(cycle=cycle, segment_new_id=
|
71
|
+
cycle1, cycle2 = get_cyles(cycle=cycle, segment_new_id=str(len(polygon_arr)), neighbor1=neighbor1, neighbor2=neighbor2, index_begin=index_begin, index_end=index_end)
|
72
72
|
vertices1, vertices2 = get_vertices(vertices, index_begin, index_end, vertex_begin, vertex_end)
|
73
73
|
|
74
74
|
polygon1 = Polygon(vertices=vertices1)
|
75
75
|
area1 = polygon1.area()
|
76
76
|
area2 = polygon_arr[polygon_id]['area'] - area1
|
77
77
|
|
78
|
-
polygon_new_1 = {
|
78
|
+
polygon_new_1 = { f'p{len(polygon_arr)+1}': { 'vertices': vertices1, 'area': area1, 'faces': cycle1[:-1] } }
|
79
79
|
polygon_new_2 = { polygon_id: { 'vertices': vertices2, 'area': area2, 'faces': cycle2[:-1] } }
|
80
80
|
|
81
81
|
polygon_arr.update(polygon_new_1)
|
@@ -103,8 +103,9 @@ def add_line_segment(segments_dict, polygon_arr, angles='uniform') -> Tuple[List
|
|
103
103
|
|
104
104
|
Returns:
|
105
105
|
- Updated line_segments list.
|
106
|
-
"""
|
106
|
+
"""
|
107
107
|
polygon_id, polygon = pick_item_with_probability(polygon_arr)
|
108
|
+
|
108
109
|
line_segments_to_check = [segments_dict[segment] for segment in polygon['faces']]
|
109
110
|
|
110
111
|
location_new = sample_in_polygon(polygon['vertices'])
|
@@ -160,12 +161,13 @@ def add_line_segment(segments_dict, polygon_arr, angles='uniform') -> Tuple[List
|
|
160
161
|
intersections_f = [intersection for intersection in intersection_points if intersection["point"][1] > line_new.location[1]]
|
161
162
|
|
162
163
|
# Determine correct segment length
|
163
|
-
id = str(len(
|
164
|
+
id = str(len(segments_dict)-3)
|
165
|
+
|
164
166
|
start = min(intersections_b, key=lambda x: x["segment_length"])
|
165
167
|
end = min(intersections_f, key=lambda x: x["segment_length"])
|
166
168
|
|
167
169
|
# Add new segment object with corresponding neighbors
|
168
|
-
neighbors_initial = {}
|
170
|
+
neighbors_initial = {}
|
169
171
|
neighbors_initial[start["id"]] = start["point"]
|
170
172
|
neighbors_initial[end["id"]] = end["point"]
|
171
173
|
segment_new = LineSegment(start=start["point"], end=end["point"], id=id, neighbors_initial=neighbors_initial, neighbors=neighbors_initial)
|
@@ -177,8 +179,8 @@ def add_line_segment(segments_dict, polygon_arr, angles='uniform') -> Tuple[List
|
|
177
179
|
|
178
180
|
vertex_begin = start["point"]
|
179
181
|
vertex_end = end["point"]
|
180
|
-
polygon_arr = update_polygon_arr(polygon_id=polygon_id, polygon_arr=polygon_arr, neighbor1=start["id"], neighbor2=end["id"], vertex_begin=vertex_begin, vertex_end=vertex_end
|
181
|
-
|
182
|
+
polygon_arr = update_polygon_arr(polygon_id=polygon_id, polygon_arr=polygon_arr, neighbor1=start["id"], neighbor2=end["id"], vertex_begin=vertex_begin, vertex_end=vertex_end)
|
183
|
+
|
182
184
|
return segments_dict, polygon_arr
|
183
185
|
|
184
186
|
def generate_line_segments(size: int, angles='uniform') -> Tuple[nx.Graph, List[LineSegment]]:
|
@@ -198,7 +200,7 @@ def generate_line_segments(size: int, angles='uniform') -> Tuple[nx.Graph, List[
|
|
198
200
|
LineSegment((1, 1), (1, 0), id='b4', neighbors_initial={'b1': (1, 0), 'b3': (1, 1)}, neighbors={'b1': (1, 0), 'b3': (1, 1)})
|
199
201
|
]
|
200
202
|
|
201
|
-
polygon_arr = { '
|
203
|
+
polygon_arr = { 'p1': { 'vertices': [(0,0), (0,1), (1,1), (1,0)], 'area': 1, 'faces': [ 'b1', 'b2', 'b3', 'b4' ] } }
|
202
204
|
|
203
205
|
segments = borders
|
204
206
|
segments_dict = {segment.id: segment for segment in segments}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import numpy as np
|
2
2
|
from typing import List, Tuple
|
3
3
|
|
4
|
-
from
|
4
|
+
from Classes import LineSegment
|
5
5
|
|
6
6
|
def order_points(points: List[Tuple[float, float]], segment_start: Tuple[float, float]) -> List[Tuple[float, float]]:
|
7
7
|
"""
|
@@ -31,8 +31,16 @@ def get_intersection_segments(line_segments: List[LineSegment]) -> List[LineSegm
|
|
31
31
|
"""
|
32
32
|
intersection_points = {segment.id: [] for segment in line_segments}
|
33
33
|
|
34
|
+
intersection_points['b1'] = [(1, 0), (0, 0)]
|
35
|
+
intersection_points['b2'] = [(0, 1), (0, 0)]
|
36
|
+
intersection_points['b3'] = [(0, 1), (1, 1)]
|
37
|
+
intersection_points['b4'] = [(1, 1), (1, 0)]
|
38
|
+
|
34
39
|
# Add all segments minus the borders
|
35
40
|
for index, segment in enumerate(line_segments):
|
41
|
+
if segment.id in ['b1', 'b2', 'b3', 'b4']:
|
42
|
+
continue
|
43
|
+
|
36
44
|
neighbors_initial = segment.neighbors_initial
|
37
45
|
|
38
46
|
# Add segment start and end points to intersection points
|
@@ -46,7 +54,9 @@ def get_intersection_segments(line_segments: List[LineSegment]) -> List[LineSegm
|
|
46
54
|
# Order intersection points
|
47
55
|
ordered_intersection_points = {}
|
48
56
|
for segment_id, points in intersection_points.items():
|
57
|
+
|
49
58
|
ordered_points = order_points(points, points[0])
|
59
|
+
|
50
60
|
ordered_intersection_points[segment_id] = ordered_points
|
51
61
|
|
52
62
|
# Generate intersection segments
|
@@ -62,4 +72,4 @@ def get_intersection_segments(line_segments: List[LineSegment]) -> List[LineSegm
|
|
62
72
|
intersection_segments.append(segment_new)
|
63
73
|
i += 1
|
64
74
|
|
65
|
-
return intersection_segments
|
75
|
+
return intersection_segments
|
@@ -1,13 +0,0 @@
|
|
1
|
-
RDG_networks/Classes.py,sha256=_9X3JPHFAYYlaC8IZ_H9__sfz99G5l9UfPl65lL60_4,7977
|
2
|
-
RDG_networks/__init__.py,sha256=lbEZ5NwKERxQ4oLXTxWoe8q8f6c_iSx4ZQXDwgx_OP4,759
|
3
|
-
RDG_networks/draw_segments.py,sha256=ZHTQtu7szm4M3PWDRJa5WCetDN1yNQem9C0l8xfaTr8,996
|
4
|
-
RDG_networks/generate_line_network.py,sha256=F8p7AFS0vYQEfTdTtTMhP0yK92VFq3FakaSte6K5AOw,1139
|
5
|
-
RDG_networks/generate_line_segments.py,sha256=ocC5vRRzB8LNsFnKL_2n1imUH1xD2cewoDXy4N-Mp7w,8983
|
6
|
-
RDG_networks/get_intersection_segments.py,sha256=hYul5dS5eHglRVfb47FQF3k2UWHG5nnTkbnO_1aJ1eI,2480
|
7
|
-
RDG_networks/sample_in_polygon.py,sha256=qpPpW-Da1vK8ZkVWMJ0zBsE8IgyMB619gCdybSkzKSQ,1605
|
8
|
-
RDG_Networks-0.1.2.dist-info/LICENSE.txt,sha256=Zlv8517YKFuHaaqksoTKeIiQBl9DGxhUdb_0kJg0NOE,1066
|
9
|
-
RDG_Networks-0.1.2.dist-info/METADATA,sha256=g_GmYl15EImvDNk_Khf3aBkoiStZJFm6L8AmQvU67l4,1756
|
10
|
-
RDG_Networks-0.1.2.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
11
|
-
RDG_Networks-0.1.2.dist-info/entry_points.txt,sha256=4LC5qJH7VKpjuuhDR3HpJulO4qy9K5UlAUOGBg6ctxA,268
|
12
|
-
RDG_Networks-0.1.2.dist-info/top_level.txt,sha256=4gUUYafD5Al9V8ZSiViVGYHpRMMCsCBcGgCNodk9Syg,13
|
13
|
-
RDG_Networks-0.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|