topologicpy 0.4.8__py3-none-any.whl → 0.4.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Aperture.py +46 -0
- topologicpy/Cell.py +1780 -0
- topologicpy/CellComplex.py +791 -0
- topologicpy/Cluster.py +591 -0
- topologicpy/Color.py +157 -0
- topologicpy/Context.py +56 -0
- topologicpy/DGL.py +2661 -0
- topologicpy/Dictionary.py +470 -0
- topologicpy/Edge.py +855 -0
- topologicpy/EnergyModel.py +1052 -0
- topologicpy/Face.py +1810 -0
- topologicpy/Graph.py +3526 -0
- topologicpy/Graph_Export.py +858 -0
- topologicpy/Grid.py +338 -0
- topologicpy/Helper.py +182 -0
- topologicpy/Honeybee.py +424 -0
- topologicpy/Matrix.py +255 -0
- topologicpy/Neo4jGraph.py +311 -0
- topologicpy/Plotly.py +1396 -0
- topologicpy/Polyskel.py +524 -0
- topologicpy/Process.py +1368 -0
- topologicpy/SQL.py +48 -0
- topologicpy/Shell.py +1418 -0
- topologicpy/Speckle.py +433 -0
- topologicpy/Topology.py +5854 -0
- topologicpy/UnitTest.py +29 -0
- topologicpy/Vector.py +555 -0
- topologicpy/Vertex.py +714 -0
- topologicpy/Wire.py +2346 -0
- topologicpy/__init__.py +20 -0
- topologicpy/bin/linux/topologic/__init__.py +2 -0
- topologicpy/bin/linux/topologic/topologic.cpython-310-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-311-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-38-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-39-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic.libs/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/windows/topologic/TKBO-f6b191de.dll +0 -0
- topologicpy/bin/windows/topologic/TKBRep-e56a600e.dll +0 -0
- topologicpy/bin/windows/topologic/TKBool-7b8d47ae.dll +0 -0
- topologicpy/bin/windows/topologic/TKFillet-0ddbf0a8.dll +0 -0
- topologicpy/bin/windows/topologic/TKG2d-2e2dee3d.dll +0 -0
- topologicpy/bin/windows/topologic/TKG3d-6674513d.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomAlgo-d240e370.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomBase-df87aba5.dll +0 -0
- topologicpy/bin/windows/topologic/TKMath-45bd625a.dll +0 -0
- topologicpy/bin/windows/topologic/TKMesh-d6e826b1.dll +0 -0
- topologicpy/bin/windows/topologic/TKOffset-79b9cc94.dll +0 -0
- topologicpy/bin/windows/topologic/TKPrim-aa430a86.dll +0 -0
- topologicpy/bin/windows/topologic/TKShHealing-bb48be89.dll +0 -0
- topologicpy/bin/windows/topologic/TKTopAlgo-7d0d1e22.dll +0 -0
- topologicpy/bin/windows/topologic/TKernel-08c8cfbb.dll +0 -0
- topologicpy/bin/windows/topologic/__init__.py +2 -0
- topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/METADATA +1 -1
- topologicpy-0.4.9.dist-info/RECORD +77 -0
- topologicpy-0.4.9.dist-info/top_level.txt +1 -0
- topologicpy-0.4.8.dist-info/RECORD +0 -5
- topologicpy-0.4.8.dist-info/top_level.txt +0 -1
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/LICENSE +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import topologic
|
|
2
|
+
import time
|
|
3
|
+
import random
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
import py2neo
|
|
7
|
+
from py2neo import NodeMatcher,RelationshipMatcher
|
|
8
|
+
from py2neo.data import spatial as sp
|
|
9
|
+
except:
|
|
10
|
+
raise Exception("Error: Could not import py2neo.")
|
|
11
|
+
|
|
12
|
+
class Neo4jGraph:
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def ExportToGraph(neo4jGraph):
|
|
16
|
+
"""
|
|
17
|
+
Description
|
|
18
|
+
-----------
|
|
19
|
+
Creates a vertex at the coordinates specified by the x, y, z inputs.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
neo4jGraph : TYPE
|
|
24
|
+
DESCRIPTION.
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
TYPE
|
|
29
|
+
DESCRIPTION.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
from topologicpy.Vertex import Vertex
|
|
33
|
+
from topologicpy.Edge import Edge
|
|
34
|
+
from topologicpy.Topology import Topology
|
|
35
|
+
from topologicpy.Dictionary import Dictionary
|
|
36
|
+
from topologicpy.Graph import Graph
|
|
37
|
+
|
|
38
|
+
def randomVertex(vertices, minDistance):
|
|
39
|
+
flag = True
|
|
40
|
+
while flag:
|
|
41
|
+
x = random.uniform(0, 1000)
|
|
42
|
+
y = random.uniform(0, 1000)
|
|
43
|
+
z = random.uniform(0, 1000)
|
|
44
|
+
v = Vertex.ByCoordinates(x, y, z)
|
|
45
|
+
test = False
|
|
46
|
+
if len(vertices) < 1:
|
|
47
|
+
return v
|
|
48
|
+
for vertex in vertices:
|
|
49
|
+
d = Vertex.Distance(v, vertex)
|
|
50
|
+
if d < minDistance:
|
|
51
|
+
test = True
|
|
52
|
+
break
|
|
53
|
+
if test == False:
|
|
54
|
+
return v
|
|
55
|
+
else:
|
|
56
|
+
continue
|
|
57
|
+
|
|
58
|
+
node_labels = neo4jGraph.schema.node_labels
|
|
59
|
+
relationship_types = neo4jGraph.schema.relationship_types
|
|
60
|
+
node_matcher = NodeMatcher(neo4jGraph)
|
|
61
|
+
relationship_matcher = RelationshipMatcher(neo4jGraph)
|
|
62
|
+
vertices = []
|
|
63
|
+
edges = []
|
|
64
|
+
nodes = []
|
|
65
|
+
for node_label in node_labels:
|
|
66
|
+
nodes = nodes + (list(node_matcher.match(node_label)))
|
|
67
|
+
for node in nodes:
|
|
68
|
+
#Check if they have X, Y, Z coordinates
|
|
69
|
+
if ('x' in node.keys()) and ('y' in node.keys()) and ('z' in node.keys()) or ('X' in node.keys()) and ('Y' in node.keys()) and ('Z' in node.keys()):
|
|
70
|
+
x = node['x']
|
|
71
|
+
y = node['y']
|
|
72
|
+
z = node['z']
|
|
73
|
+
vertex = Vertex.ByCoordinates(x, y, z)
|
|
74
|
+
else:
|
|
75
|
+
vertex = randomVertex(vertices, 1)
|
|
76
|
+
keys = list(node.keys())
|
|
77
|
+
values = []
|
|
78
|
+
for key in keys:
|
|
79
|
+
values.append(node[key])
|
|
80
|
+
d = Dictionary.ByKeysValues(keys, values)
|
|
81
|
+
_ = Topology.SetDictionary(vertex, d)
|
|
82
|
+
vertices.append(vertex)
|
|
83
|
+
for node in nodes:
|
|
84
|
+
for relationship_type in relationship_types:
|
|
85
|
+
relationships = list(relationship_matcher.match([node], r_type=relationship_type))
|
|
86
|
+
for relationship in relationships:
|
|
87
|
+
sv = vertices[nodes.index(relationship.start_node)]
|
|
88
|
+
ev = vertices[nodes.index(relationship.end_node)]
|
|
89
|
+
edge = Edge.ByVertices([sv, ev])
|
|
90
|
+
if relationship.start_node['name']:
|
|
91
|
+
sv_name = relationship.start_node['name']
|
|
92
|
+
else:
|
|
93
|
+
sv_name = 'None'
|
|
94
|
+
if relationship.end_node['name']:
|
|
95
|
+
ev_name = relationship.end_node['name']
|
|
96
|
+
else:
|
|
97
|
+
ev_name = 'None'
|
|
98
|
+
d = Dictionary.ByKeysValues(["relationship_type", "from", "to"], [relationship_type, sv_name, ev_name])
|
|
99
|
+
if d:
|
|
100
|
+
_ = Topology.SetDictionary(edge, d)
|
|
101
|
+
edges.append(edge)
|
|
102
|
+
return Graph.ByVerticesEdges(vertices,edges)
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def AddTopologicGraph(neo4jGraph, topologicGraph, categoryKey, tolerance):
|
|
106
|
+
"""
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
neo4jGraph : TYPE
|
|
110
|
+
DESCRIPTION.
|
|
111
|
+
topologicGraph : TYPE
|
|
112
|
+
DESCRIPTION.
|
|
113
|
+
categoryKey : TYPE
|
|
114
|
+
DESCRIPTION.
|
|
115
|
+
tolerance : TYPE
|
|
116
|
+
DESCRIPTION.
|
|
117
|
+
|
|
118
|
+
Returns
|
|
119
|
+
-------
|
|
120
|
+
neo4jGraph : TYPE
|
|
121
|
+
DESCRIPTION.
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
from topologicpy.Topology import Topology
|
|
125
|
+
from topologicpy.Graph import Graph
|
|
126
|
+
gmt = time.gmtime()
|
|
127
|
+
timestamp = str(gmt.tm_zone)+"_"+str(gmt.tm_year)+"_"+str(gmt.tm_mon)+"_"+str(gmt.tm_wday)+"_"+str(gmt.tm_hour)+"_"+str(gmt.tm_min)+"_"+str(gmt.tm_sec)
|
|
128
|
+
vertices = Graph.Vertices(topologicGraph)
|
|
129
|
+
edges = Graph.Edges(topologicGraph)
|
|
130
|
+
tx = neo4jGraph.begin()
|
|
131
|
+
nodes = []
|
|
132
|
+
for i in range(len(vertices)):
|
|
133
|
+
vDict = Topology.GetDictionary(vertices[i])
|
|
134
|
+
keys, values = Neo4jGraph.getKeysAndValues(vDict)
|
|
135
|
+
keys.append("x")
|
|
136
|
+
keys.append("y")
|
|
137
|
+
keys.append("z")
|
|
138
|
+
keys.append("timestamp")
|
|
139
|
+
keys.append("location")
|
|
140
|
+
values.append(vertices[i].X())
|
|
141
|
+
values.append(vertices[i].Y())
|
|
142
|
+
values.append(vertices[i].Z())
|
|
143
|
+
values.append(timestamp)
|
|
144
|
+
values.append(sp.CartesianPoint([vertices[i].X(),vertices[i].Y(),vertices[i].Z()]))
|
|
145
|
+
zip_iterator = zip(keys, values)
|
|
146
|
+
pydict = dict(zip_iterator)
|
|
147
|
+
if categoryKey == 'None':
|
|
148
|
+
nodeName = "TopologicGraphVertex"
|
|
149
|
+
else:
|
|
150
|
+
nodeName = str(values[keys.index(categoryKey)])
|
|
151
|
+
n = py2neo.Node(nodeName, **pydict)
|
|
152
|
+
neo4jGraph.cypher.execute("CREATE INDEX FOR (n:%s) on (n.name)" %
|
|
153
|
+
n.nodelabel)
|
|
154
|
+
tx.create(n)
|
|
155
|
+
nodes.append(n)
|
|
156
|
+
for i in range(len(edges)):
|
|
157
|
+
e = edges[i]
|
|
158
|
+
sv = e.StartVertex()
|
|
159
|
+
ev = e.EndVertex()
|
|
160
|
+
sn = nodes[Neo4jGraph.vertexIndex(sv, vertices, tolerance)]
|
|
161
|
+
en = nodes[Neo4jGraph.vertexIndex(ev, vertices, tolerance)]
|
|
162
|
+
snen = py2neo.Relationship(sn, "CONNECTEDTO", en)
|
|
163
|
+
tx.create(snen)
|
|
164
|
+
snen = py2neo.Relationship(en, "CONNECTEDTO", sn)
|
|
165
|
+
tx.create(snen)
|
|
166
|
+
neo4jGraph.commit(tx)
|
|
167
|
+
return neo4jGraph
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@staticmethod
|
|
171
|
+
def ByParameters(url, username, password, run):
|
|
172
|
+
"""
|
|
173
|
+
Parameters
|
|
174
|
+
----------
|
|
175
|
+
url : TYPE
|
|
176
|
+
DESCRIPTION.
|
|
177
|
+
username : TYPE
|
|
178
|
+
DESCRIPTION.
|
|
179
|
+
password : TYPE
|
|
180
|
+
DESCRIPTION.
|
|
181
|
+
run : TYPE
|
|
182
|
+
DESCRIPTION.
|
|
183
|
+
|
|
184
|
+
Returns
|
|
185
|
+
-------
|
|
186
|
+
TYPE
|
|
187
|
+
DESCRIPTION.
|
|
188
|
+
|
|
189
|
+
"""
|
|
190
|
+
if not (run):
|
|
191
|
+
return None
|
|
192
|
+
return py2neo.Graph(url, auth=(username, password))
|
|
193
|
+
|
|
194
|
+
@staticmethod
|
|
195
|
+
def DeleteAll(neo4jGraph):
|
|
196
|
+
"""
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
neo4jGraph : TYPE
|
|
200
|
+
DESCRIPTION.
|
|
201
|
+
|
|
202
|
+
Returns
|
|
203
|
+
-------
|
|
204
|
+
neo4jGraph : TYPE
|
|
205
|
+
DESCRIPTION.
|
|
206
|
+
|
|
207
|
+
"""
|
|
208
|
+
# neo4jGraph = item
|
|
209
|
+
neo4jGraph.delete_all()
|
|
210
|
+
return neo4jGraph
|
|
211
|
+
|
|
212
|
+
@staticmethod
|
|
213
|
+
def NodeLabels(neo4jGraph):
|
|
214
|
+
"""
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
neo4jGraph : TYPE
|
|
218
|
+
DESCRIPTION.
|
|
219
|
+
|
|
220
|
+
Returns
|
|
221
|
+
-------
|
|
222
|
+
TYPE
|
|
223
|
+
DESCRIPTION.
|
|
224
|
+
|
|
225
|
+
"""
|
|
226
|
+
return neo4jGraph.schema.node_labels
|
|
227
|
+
|
|
228
|
+
@staticmethod
|
|
229
|
+
def SetGraph(neo4jGraph, topologicGraph, labelKey, relationshipKey, bidirectional, deleteAll, run, tolerance=0.0001):
|
|
230
|
+
"""
|
|
231
|
+
Parameters
|
|
232
|
+
----------
|
|
233
|
+
neo4jGraph : TYPE
|
|
234
|
+
DESCRIPTION.
|
|
235
|
+
topologicGraph : TYPE
|
|
236
|
+
DESCRIPTION.
|
|
237
|
+
labelKey : TYPE
|
|
238
|
+
DESCRIPTION.
|
|
239
|
+
relationshipKey : TYPE
|
|
240
|
+
DESCRIPTION.
|
|
241
|
+
bidirectional : TYPE
|
|
242
|
+
DESCRIPTION.
|
|
243
|
+
deleteAll : TYPE
|
|
244
|
+
DESCRIPTION.
|
|
245
|
+
run : TYPE
|
|
246
|
+
DESCRIPTION.
|
|
247
|
+
tolerance : TYPE, optional
|
|
248
|
+
DESCRIPTION. The default is 0.0001.
|
|
249
|
+
|
|
250
|
+
Returns
|
|
251
|
+
-------
|
|
252
|
+
neo4jGraph : TYPE
|
|
253
|
+
DESCRIPTION.
|
|
254
|
+
|
|
255
|
+
"""
|
|
256
|
+
# neo4jGraph, topologicGraph, labelKey, relationshipKey, bidirectional, deleteAll, tolerance, run = item
|
|
257
|
+
from topologicpy.Graph import Graph
|
|
258
|
+
from topologicpy.Dictionary import Dictionary
|
|
259
|
+
|
|
260
|
+
if not (run):
|
|
261
|
+
return None
|
|
262
|
+
import time
|
|
263
|
+
gmt = time.gmtime()
|
|
264
|
+
timestamp = str(gmt.tm_zone)+"_"+str(gmt.tm_year)+"_"+str(gmt.tm_mon)+"_"+str(gmt.tm_wday)+"_"+str(gmt.tm_hour)+"_"+str(gmt.tm_min)+"_"+str(gmt.tm_sec)
|
|
265
|
+
|
|
266
|
+
vertices = Graph.Vertices(topologicGraph)
|
|
267
|
+
edges = Graph.Edges(topologicGraph)
|
|
268
|
+
tx = neo4jGraph.begin()
|
|
269
|
+
nodes = []
|
|
270
|
+
for i in range(len(vertices)):
|
|
271
|
+
vDict = vertices[i].GetDictionary()
|
|
272
|
+
keys = Dictionary.Keys(vDict)
|
|
273
|
+
values = Dictionary.Values(vDict)
|
|
274
|
+
keys.append("x")
|
|
275
|
+
keys.append("y")
|
|
276
|
+
keys.append("z")
|
|
277
|
+
keys.append("timestamp")
|
|
278
|
+
keys.append("location")
|
|
279
|
+
values.append(vertices[i].X())
|
|
280
|
+
values.append(vertices[i].Y())
|
|
281
|
+
values.append(vertices[i].Z())
|
|
282
|
+
values.append(timestamp)
|
|
283
|
+
values.append(sp.CartesianPoint([vertices[i].X(),vertices[i].Y(),vertices[i].Z()]))
|
|
284
|
+
zip_iterator = zip(keys, values)
|
|
285
|
+
pydict = dict(zip_iterator)
|
|
286
|
+
if (labelKey == 'None') or (not (labelKey)):
|
|
287
|
+
nodeName = "TopologicGraphVertex"
|
|
288
|
+
else:
|
|
289
|
+
nodeName = str(Dictionary.ValueAtKey(vDict, labelKey))
|
|
290
|
+
n = py2neo.Node(nodeName, **pydict)
|
|
291
|
+
tx.create(n)
|
|
292
|
+
nodes.append(n)
|
|
293
|
+
for i in range(len(edges)):
|
|
294
|
+
e = edges[i]
|
|
295
|
+
sv = e.StartVertex()
|
|
296
|
+
ev = e.EndVertex()
|
|
297
|
+
sn = nodes[Neo4jGraph.vertexIndex(sv, vertices, tolerance)]
|
|
298
|
+
en = nodes[Neo4jGraph.vertexIndex(ev, vertices, tolerance)]
|
|
299
|
+
ed = e.GetDictionary()
|
|
300
|
+
relationshipType = Dictionary.ValueAtKey(ed, relationshipKey)
|
|
301
|
+
if not (relationshipType):
|
|
302
|
+
relationshipType = "Connected To"
|
|
303
|
+
snen = py2neo.Relationship(sn, relationshipType, en)
|
|
304
|
+
tx.create(snen)
|
|
305
|
+
if bidirectional:
|
|
306
|
+
snen = py2neo.Relationship(en, relationshipType, sn)
|
|
307
|
+
tx.create(snen)
|
|
308
|
+
if deleteAll:
|
|
309
|
+
neo4jGraph.delete_all()
|
|
310
|
+
neo4jGraph.commit(tx)
|
|
311
|
+
return neo4jGraph
|