topologicpy 0.3.6__py3-none-any.whl → 0.3.8__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/EnergyModel.py +376 -341
- topologicpy/Honeybee.py +11 -5
- topologicpy/Plotly.py +111 -24
- topologicpy/Topology.py +291 -4
- topologicpy/__init__.py +1 -1
- {topologicpy-0.3.6.dist-info → topologicpy-0.3.8.dist-info}/METADATA +1 -1
- {topologicpy-0.3.6.dist-info → topologicpy-0.3.8.dist-info}/RECORD +10 -10
- {topologicpy-0.3.6.dist-info → topologicpy-0.3.8.dist-info}/LICENSE +0 -0
- {topologicpy-0.3.6.dist-info → topologicpy-0.3.8.dist-info}/WHEEL +0 -0
- {topologicpy-0.3.6.dist-info → topologicpy-0.3.8.dist-info}/top_level.txt +0 -0
topologicpy/Honeybee.py
CHANGED
|
@@ -98,7 +98,7 @@ class Honeybee:
|
|
|
98
98
|
|
|
99
99
|
@staticmethod
|
|
100
100
|
def ModelByTopology(tpBuilding,
|
|
101
|
-
tpShadingFacesCluster=None,
|
|
101
|
+
tpShadingFacesCluster = None,
|
|
102
102
|
buildingName = "Generic_Building",
|
|
103
103
|
defaultProgramIdentifier = "Generic Office Program",
|
|
104
104
|
defaultConstructionSetIdentifier = "Default Generic Construction Set",
|
|
@@ -106,12 +106,18 @@ class Honeybee:
|
|
|
106
106
|
heatingSetpoint = 20.0,
|
|
107
107
|
humidifyingSetpoint = 30.0,
|
|
108
108
|
dehumidifyingSetpoint = 55.0,
|
|
109
|
-
roomNameKey = "
|
|
110
|
-
roomTypeKey = "
|
|
111
|
-
apertureTypeKey = "
|
|
109
|
+
roomNameKey = "TOPOLOGIC_name",
|
|
110
|
+
roomTypeKey = "TOPOLOGIC_type",
|
|
111
|
+
apertureTypeKey = "TOPOLOGIC_type",
|
|
112
112
|
addSensorGrid = False):
|
|
113
113
|
"""
|
|
114
|
-
Creates an HB Model from the input Topology
|
|
114
|
+
Creates an HB Model from the input Topology.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Returns
|
|
115
121
|
-------
|
|
116
122
|
HBModel
|
|
117
123
|
The created HB Model
|
topologicpy/Plotly.py
CHANGED
|
@@ -13,6 +13,81 @@ from topologicpy.Topology import Topology
|
|
|
13
13
|
import numpy as np
|
|
14
14
|
|
|
15
15
|
class Plotly:
|
|
16
|
+
@staticmethod
|
|
17
|
+
def AddColorBar(figure, values=[], nTicks=5, xPosition=-0.15, width=15, outlineWidth=0, title="", subTitle="", units="", colorScale="viridis", mantissa=4):
|
|
18
|
+
"""
|
|
19
|
+
Adds a color bar to the input figure
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
figure : plotly.graph_objs._figure.Figure
|
|
24
|
+
The input plotly figure.
|
|
25
|
+
values : list , optional
|
|
26
|
+
The input list of values to use for the color bar. The default is [].
|
|
27
|
+
nTicks : int , optional
|
|
28
|
+
The number of ticks to use on the color bar. The default is 5.
|
|
29
|
+
xPosition : float , optional
|
|
30
|
+
The x location of the color bar. The default is -0.15.
|
|
31
|
+
width : int , optional
|
|
32
|
+
The width in pixels of the color bar. The default is 15
|
|
33
|
+
outlineWidth : int , optional
|
|
34
|
+
The width in pixels of the outline of the color bar. The default is 0.
|
|
35
|
+
title : str , optional
|
|
36
|
+
The title of the color bar. The default is "".
|
|
37
|
+
subTitle : str , optional
|
|
38
|
+
The subtitle of the color bar. The default is "".
|
|
39
|
+
units: str , optional
|
|
40
|
+
The units used in the color bar. The default is ""
|
|
41
|
+
colorScale : str , optional
|
|
42
|
+
The desired type of plotly color scales to use (e.g. "viridis", "plasma"). The default is "viridis". For a full list of names, see https://plotly.com/python/builtin-colorscales/.
|
|
43
|
+
mantissa : int , optional
|
|
44
|
+
The desired length of the mantissa for the values listed on the color bar. The default is 4.
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
plotly.graph_objs._figure.Figure
|
|
48
|
+
The input figure with the color bar added.
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
if not isinstance(figure, plotly.graph_objs._figure.Figure):
|
|
52
|
+
return None
|
|
53
|
+
if units:
|
|
54
|
+
units = "Units: "+units
|
|
55
|
+
minValue = min(values)
|
|
56
|
+
maxValue = max(values)
|
|
57
|
+
step = (maxValue - minValue)/float(nTicks-1)
|
|
58
|
+
r = [round(minValue+i*step, mantissa) for i in range(nTicks)]
|
|
59
|
+
r[-1] = round(maxValue, mantissa)
|
|
60
|
+
# Define the minimum and maximum range of the colorbar
|
|
61
|
+
rs = [str(x) for x in r]
|
|
62
|
+
|
|
63
|
+
# Define the colorbar as a trace with no data, x or y coordinates
|
|
64
|
+
colorbar_trace = go.Scatter(
|
|
65
|
+
x=[0],
|
|
66
|
+
y=[0],
|
|
67
|
+
mode="markers",
|
|
68
|
+
showlegend=False,
|
|
69
|
+
marker=dict(
|
|
70
|
+
size=0,
|
|
71
|
+
colorscale=colorScale, # choose the colorscale
|
|
72
|
+
cmin=minValue,
|
|
73
|
+
cmax=maxValue,
|
|
74
|
+
color=['rgba(0,0,0,0)'],
|
|
75
|
+
colorbar=dict(
|
|
76
|
+
x=xPosition,
|
|
77
|
+
title="<b>"+title+"</b><br>"+subTitle+"<br>"+units, # title of the colorbar
|
|
78
|
+
ticks="outside", # position of the ticks
|
|
79
|
+
tickvals=r, # values of the ticks
|
|
80
|
+
ticktext=rs, # text of the ticks
|
|
81
|
+
tickmode="array",
|
|
82
|
+
thickness=width,
|
|
83
|
+
outlinewidth=outlineWidth,
|
|
84
|
+
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
figure.add_trace(colorbar_trace)
|
|
89
|
+
return figure
|
|
90
|
+
|
|
16
91
|
@staticmethod
|
|
17
92
|
def Colors():
|
|
18
93
|
"""
|
|
@@ -283,7 +358,7 @@ class Plotly:
|
|
|
283
358
|
return data
|
|
284
359
|
|
|
285
360
|
@staticmethod
|
|
286
|
-
def DataByTopology(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor="white", faceOpacity=0.5, edgeColor="black", edgeWidth=1, vertexColor="black", vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, vertexLabel="Topology Vertices", edgeLabel="Topology Edges", faceLabel="Topology Faces", vertexLegendGroup=1, edgeLegendGroup=2, faceLegendGroup=3, vertexLegendRank=1, edgeLegendRank=2, faceLegendRank=3, showVertexLegend=
|
|
361
|
+
def DataByTopology(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor="white", faceOpacity=0.5, edgeColor="black", edgeWidth=1, vertexColor="black", vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, vertexLabel="Topology Vertices", edgeLabel="Topology Edges", faceLabel="Topology Faces", vertexLegendGroup=1, edgeLegendGroup=2, faceLegendGroup=3, vertexLegendRank=1, edgeLegendRank=2, faceLegendRank=3, showVertexLegend=False, showEdgeLegend=False, showFaceLegend=False, intensityKey=None, colorScale="Viridis", showScale=True, scaleTitle="Untitled"):
|
|
287
362
|
"""
|
|
288
363
|
Creates plotly face, edge, and vertex data.
|
|
289
364
|
|
|
@@ -316,8 +391,7 @@ class Plotly:
|
|
|
316
391
|
vertexLegendRank : int , optional
|
|
317
392
|
The legend rank order of the vertices of this topology. The default is 1.
|
|
318
393
|
showVertexLegend : bool, optional
|
|
319
|
-
If set to True, the legend for the vertices of this topology is shown. Otherwise, it isn't. The default is
|
|
320
|
-
|
|
394
|
+
If set to True, the legend for the vertices of this topology is shown. Otherwise, it isn't. The default is False.
|
|
321
395
|
edgeGroupKey : str , optional
|
|
322
396
|
The dictionary key to use to display the edge group. The default is None.
|
|
323
397
|
edgeGroups : list , optional
|
|
@@ -332,7 +406,6 @@ class Plotly:
|
|
|
332
406
|
The default is "black".
|
|
333
407
|
edgeWidth : float , optional
|
|
334
408
|
The desired thickness of the output edges. The default is 1.
|
|
335
|
-
|
|
336
409
|
edgeLabel : str , optional
|
|
337
410
|
The legend label string used to identify edges. The default is "Topology Edges".
|
|
338
411
|
edgeLabelKey : str , optional
|
|
@@ -342,7 +415,7 @@ class Plotly:
|
|
|
342
415
|
edgeLegendRank : int , optional
|
|
343
416
|
The legend rank order of the edges of this topology. The default is 2.
|
|
344
417
|
showEdgeLegend : bool, optional
|
|
345
|
-
If set to True, the legend for the edges of this topology is shown. Otherwise, it isn't. The default is
|
|
418
|
+
If set to True, the legend for the edges of this topology is shown. Otherwise, it isn't. The default is False.
|
|
346
419
|
showEdges : bool , optional
|
|
347
420
|
If set to True the edges will be drawn. Otherwise, they will not be drawn. The default is True.
|
|
348
421
|
faceLabelKey : str , optional
|
|
@@ -370,7 +443,7 @@ class Plotly:
|
|
|
370
443
|
faceLegendRank : int , optional
|
|
371
444
|
The legend rank order of the faces of this topology. The default is 3.
|
|
372
445
|
showFaceLegend : bool, optional
|
|
373
|
-
If set to True, the legend for the faces of this topology is shown. Otherwise, it isn't. The default is
|
|
446
|
+
If set to True, the legend for the faces of this topology is shown. Otherwise, it isn't. The default is False.
|
|
374
447
|
intensityKey: str, optional
|
|
375
448
|
If not None, the dictionary of each vertex is searched for the value associated with the intensity key. This value is then used to color-code the vertex based on the colorScale. The default is None.
|
|
376
449
|
colorScale : str , optional
|
|
@@ -504,7 +577,8 @@ class Plotly:
|
|
|
504
577
|
hoverinfo='text')
|
|
505
578
|
|
|
506
579
|
|
|
507
|
-
def faceData(vertices, faces, dictionaries=None, faceColor="white", faceOpacity=0.5, faceLabelKey=None, faceGroupKey=None, faceGroups=[], faceLabel="Topology Faces", legendGroup=3, legendRank=3, showLegend=True, intensities=None, colorScale="Viridis", showScale="False",
|
|
580
|
+
def faceData(vertices, faces, dictionaries=None, faceColor="white", faceOpacity=0.5, faceLabelKey=None, faceGroupKey=None, faceGroups=[], faceLabel="Topology Faces", legendGroup=3, legendRank=3, showLegend=True, intensities=None, colorScale="Viridis", showScale="False", scaleTitle="Untitled"):
|
|
581
|
+
from topologicpy.Color import Color
|
|
508
582
|
x = []
|
|
509
583
|
y = []
|
|
510
584
|
z = []
|
|
@@ -517,7 +591,15 @@ class Plotly:
|
|
|
517
591
|
k = []
|
|
518
592
|
f_labels = []
|
|
519
593
|
f_groupList = []
|
|
594
|
+
minGroup = 0
|
|
595
|
+
maxGroup = 100
|
|
520
596
|
if faceLabelKey or faceGroupKey:
|
|
597
|
+
if faceGroups:
|
|
598
|
+
minGroup = min(faceGroups)
|
|
599
|
+
maxGroup = max(faceGroups)
|
|
600
|
+
else:
|
|
601
|
+
minGroup = 0
|
|
602
|
+
maxGroup = 1
|
|
521
603
|
for m, f in enumerate(faces):
|
|
522
604
|
i.append(f[0])
|
|
523
605
|
j.append(f[1])
|
|
@@ -532,11 +614,13 @@ class Plotly:
|
|
|
532
614
|
except:
|
|
533
615
|
f_label = ""
|
|
534
616
|
try:
|
|
535
|
-
f_group =
|
|
617
|
+
f_group = Dictionary.ValueAtKey(d, key=faceGroupKey) or None
|
|
536
618
|
except:
|
|
537
|
-
f_group =
|
|
619
|
+
f_group = None
|
|
538
620
|
try:
|
|
539
|
-
|
|
621
|
+
f_color = Color.ByValueInRange(f_group, minValue=minGroup, maxValue=maxGroup, colorScale=colorScale)
|
|
622
|
+
colorString = "rgb("+str(f_color[0])+","+str(f_color[1])+","+str(f_color[2])+")"
|
|
623
|
+
f_groupList.append(colorString)
|
|
540
624
|
except:
|
|
541
625
|
f_groupList.append(len(faceGroups))
|
|
542
626
|
if not f_label == "" and not f_group == "":
|
|
@@ -549,12 +633,10 @@ class Plotly:
|
|
|
549
633
|
k.append(f[2])
|
|
550
634
|
|
|
551
635
|
if len(list(set(f_groupList))) < 2:
|
|
552
|
-
|
|
636
|
+
f_groupList = None
|
|
553
637
|
if len(f_labels) < 1:
|
|
554
638
|
f_labels = ""
|
|
555
|
-
|
|
556
|
-
colorBarTitle = " "
|
|
557
|
-
return go.Mesh3d(
|
|
639
|
+
trace = go.Mesh3d(
|
|
558
640
|
x=x,
|
|
559
641
|
y=y,
|
|
560
642
|
z=z,
|
|
@@ -565,18 +647,22 @@ class Plotly:
|
|
|
565
647
|
showlegend = showLegend,
|
|
566
648
|
legendgroup = legendGroup,
|
|
567
649
|
legendrank = legendRank,
|
|
568
|
-
color =
|
|
650
|
+
color = faceColor,
|
|
651
|
+
facecolor = f_groupList,
|
|
569
652
|
colorscale = colorScale,
|
|
570
|
-
colorbar
|
|
653
|
+
#colorbar=dict(x=-0.15, thickness=15, outlinewidth=0, title= "<b>"+scaleTitle+"</b>"),
|
|
654
|
+
#colorbar = {"x":-0.15, "title": "<b>"+scaleTitle+"</b>"},
|
|
571
655
|
intensity = intensities,
|
|
572
656
|
opacity = faceOpacity,
|
|
573
657
|
hoverinfo = 'text',
|
|
574
658
|
text=f_labels,
|
|
575
659
|
hovertext = f_labels,
|
|
576
660
|
flatshading = True,
|
|
577
|
-
showscale =
|
|
661
|
+
showscale = False,
|
|
578
662
|
lighting = {"facenormalsepsilon": 0},
|
|
579
663
|
)
|
|
664
|
+
return trace
|
|
665
|
+
|
|
580
666
|
from topologicpy.Cluster import Cluster
|
|
581
667
|
from topologicpy.Topology import Topology
|
|
582
668
|
from topologicpy.Dictionary import Dictionary
|
|
@@ -652,7 +738,7 @@ class Plotly:
|
|
|
652
738
|
i = Vertex.Index(vertex=w_v, vertices=tp_verts, tolerance=0.01)
|
|
653
739
|
temp_f.append(i)
|
|
654
740
|
faces.append(temp_f)
|
|
655
|
-
data.append(faceData(vertices, faces, dictionaries=f_dictionaries, faceColor=faceColor, faceOpacity=faceOpacity, faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, faceGroups=faceGroups, faceLabel=faceLabel, legendGroup=faceLegendGroup, legendRank=faceLegendRank, showLegend=showFaceLegend, intensities=intensities, colorScale=colorScale, showScale=showScale,
|
|
741
|
+
data.append(faceData(vertices, faces, dictionaries=f_dictionaries, faceColor=faceColor, faceOpacity=faceOpacity, faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, faceGroups=faceGroups, faceLabel=faceLabel, legendGroup=faceLegendGroup, legendRank=faceLegendRank, showLegend=showFaceLegend, intensities=intensities, colorScale=colorScale, showScale=showScale, scaleTitle=scaleTitle))
|
|
656
742
|
return data
|
|
657
743
|
|
|
658
744
|
|
|
@@ -968,11 +1054,11 @@ class Plotly:
|
|
|
968
1054
|
import plotly.express as px
|
|
969
1055
|
|
|
970
1056
|
if chartType.lower() == "line":
|
|
971
|
-
|
|
1057
|
+
figure = px.line(dataFrame, x=labels[0], y=labels[1:], title=title, markers=useMarkers)
|
|
972
1058
|
elif chartType.lower() == "bar":
|
|
973
|
-
|
|
1059
|
+
figure = px.bar(dataFrame, x=labels[0], y=labels[1:], title=title)
|
|
974
1060
|
elif chartType.lower() == "scatter":
|
|
975
|
-
|
|
1061
|
+
figure = px.scatter(dataFrame, x=labels[0], y=labels[1:], title=title)
|
|
976
1062
|
else:
|
|
977
1063
|
raise NotImplementedError
|
|
978
1064
|
|
|
@@ -986,8 +1072,8 @@ class Plotly:
|
|
|
986
1072
|
"plot_bgcolor": backgroundColor,
|
|
987
1073
|
"margin":dict(l=marginLeft, r=marginRight, t=marginTop, b=marginBottom)
|
|
988
1074
|
}
|
|
989
|
-
|
|
990
|
-
return
|
|
1075
|
+
figure.update_layout(layout)
|
|
1076
|
+
return figure
|
|
991
1077
|
|
|
992
1078
|
|
|
993
1079
|
@staticmethod
|
|
@@ -1076,7 +1162,8 @@ class Plotly:
|
|
|
1076
1162
|
plot_bgcolor=backgroundColor,
|
|
1077
1163
|
margin=dict(l=marginLeft, r=marginRight, t=marginTop, b=marginBottom),
|
|
1078
1164
|
)
|
|
1079
|
-
|
|
1165
|
+
figure.update_xaxes(showgrid=False, zeroline=False, visible=False)
|
|
1166
|
+
figure.update_yaxes(showgrid=False, zeroline=False, visible=False)
|
|
1080
1167
|
return figure
|
|
1081
1168
|
|
|
1082
1169
|
@staticmethod
|
topologicpy/Topology.py
CHANGED
|
@@ -3947,11 +3947,254 @@ class Topology():
|
|
|
3947
3947
|
returnTopology = topologic.Cluster.ByTopologies(faces, False)
|
|
3948
3948
|
return returnTopology
|
|
3949
3949
|
|
|
3950
|
+
@staticmethod
|
|
3951
|
+
def RemoveEdges(topology, edges=[]):
|
|
3952
|
+
"""
|
|
3953
|
+
Removes the input list of faces from the input topology
|
|
3954
|
+
|
|
3955
|
+
Parameters
|
|
3956
|
+
----------
|
|
3957
|
+
topology : topologic.Topology
|
|
3958
|
+
The input topology.
|
|
3959
|
+
edges : list
|
|
3960
|
+
The input list of edges.
|
|
3961
|
+
|
|
3962
|
+
Returns
|
|
3963
|
+
-------
|
|
3964
|
+
topologic.Topology
|
|
3965
|
+
The input topology with the input list of edges removed.
|
|
3966
|
+
|
|
3967
|
+
"""
|
|
3968
|
+
|
|
3969
|
+
from topologicpy.Cluster import Cluster
|
|
3970
|
+
if not isinstance(topology, topologic.Topology):
|
|
3971
|
+
return None
|
|
3972
|
+
edges = [e for e in edges if isinstance(e, topologic.Edge)]
|
|
3973
|
+
if len(edges) < 1:
|
|
3974
|
+
return topology
|
|
3975
|
+
t_edges = Topology.Edges(topology)
|
|
3976
|
+
t_faces = Topology.Faces(topology)
|
|
3977
|
+
if len(t_edges) < 1:
|
|
3978
|
+
return topology
|
|
3979
|
+
if len(t_faces) > 0:
|
|
3980
|
+
remove_faces = []
|
|
3981
|
+
for t_e in t_edges:
|
|
3982
|
+
remove = False
|
|
3983
|
+
for i, e in enumerate(edges):
|
|
3984
|
+
if Topology.IsSame(t_e, e):
|
|
3985
|
+
remove = True
|
|
3986
|
+
remove_faces += Topology.SuperTopologies(e, hostTopology=topology, topologyType="face")
|
|
3987
|
+
edges = edges[:i]+ edges[i:]
|
|
3988
|
+
break
|
|
3989
|
+
if len(remove_faces) > 0:
|
|
3990
|
+
return Topology.RemoveFaces(topology, remove_faces)
|
|
3991
|
+
else:
|
|
3992
|
+
remaining_edges = []
|
|
3993
|
+
for t_e in t_edges:
|
|
3994
|
+
remove = False
|
|
3995
|
+
for i, e in enumerate(edges):
|
|
3996
|
+
if Topology.IsSame(t_e, e):
|
|
3997
|
+
remove = True
|
|
3998
|
+
edges = edges[:i]+ edges[i:]
|
|
3999
|
+
break
|
|
4000
|
+
if not remove:
|
|
4001
|
+
remaining_edges.append(t_e)
|
|
4002
|
+
if len(remaining_edges) < 1:
|
|
4003
|
+
return None
|
|
4004
|
+
elif len(remaining_edges) == 1:
|
|
4005
|
+
return remaining_edges[0]
|
|
4006
|
+
return Topology.SelfMerge(Cluster.ByTopologies(remaining_edges))
|
|
4007
|
+
|
|
4008
|
+
@staticmethod
|
|
4009
|
+
def RemoveFaces(topology, faces=[]):
|
|
4010
|
+
"""
|
|
4011
|
+
Removes the input list of faces from the input topology
|
|
4012
|
+
|
|
4013
|
+
Parameters
|
|
4014
|
+
----------
|
|
4015
|
+
topology : topologic.Topology
|
|
4016
|
+
The input topology.
|
|
4017
|
+
faces : list
|
|
4018
|
+
The input list of faces.
|
|
4019
|
+
|
|
4020
|
+
Returns
|
|
4021
|
+
-------
|
|
4022
|
+
topologic.Topology
|
|
4023
|
+
The input topology with the input list of faces removed.
|
|
4024
|
+
|
|
4025
|
+
"""
|
|
4026
|
+
|
|
4027
|
+
from topologicpy.Cluster import Cluster
|
|
4028
|
+
if not isinstance(topology, topologic.Topology):
|
|
4029
|
+
return None
|
|
4030
|
+
faces = [f for f in faces if isinstance(f, topologic.Face)]
|
|
4031
|
+
if len(faces) < 1:
|
|
4032
|
+
return topology
|
|
4033
|
+
t_faces = Topology.Faces(topology)
|
|
4034
|
+
if len(t_faces) < 1:
|
|
4035
|
+
return topology
|
|
4036
|
+
remaining_faces = []
|
|
4037
|
+
for t_f in t_faces:
|
|
4038
|
+
remove = False
|
|
4039
|
+
for i, f in enumerate(faces):
|
|
4040
|
+
if Topology.IsSame(t_f, f):
|
|
4041
|
+
remove = True
|
|
4042
|
+
faces = faces[:i]+ faces[i:]
|
|
4043
|
+
break
|
|
4044
|
+
if not remove:
|
|
4045
|
+
remaining_faces.append(t_f)
|
|
4046
|
+
if len(remaining_faces) < 1:
|
|
4047
|
+
return None
|
|
4048
|
+
elif len(remaining_faces) == 1:
|
|
4049
|
+
return remaining_faces[0]
|
|
4050
|
+
return Topology.SelfMerge(Cluster.ByTopologies(remaining_faces))
|
|
3950
4051
|
|
|
4052
|
+
@staticmethod
|
|
4053
|
+
def RemoveFacesBySelectors(topology, selectors=[], tolerance = 0.0001):
|
|
4054
|
+
"""
|
|
4055
|
+
Removes faces that contain the input list of selectors (vertices) from the input topology
|
|
4056
|
+
|
|
4057
|
+
Parameters
|
|
4058
|
+
----------
|
|
4059
|
+
topology : topologic.Topology
|
|
4060
|
+
The input topology.
|
|
4061
|
+
selectors : list
|
|
4062
|
+
The input list of selectors (vertices).
|
|
4063
|
+
tolerance : float , optional
|
|
4064
|
+
The desired tolerance. The default is 0.0001.
|
|
4065
|
+
|
|
4066
|
+
Returns
|
|
4067
|
+
-------
|
|
4068
|
+
topologic.Topology
|
|
4069
|
+
The input topology with the identified faces removed.
|
|
4070
|
+
|
|
4071
|
+
"""
|
|
4072
|
+
|
|
4073
|
+
from topologicpy.Face import Face
|
|
4074
|
+
from topologicpy.Cluster import Cluster
|
|
4075
|
+
if not isinstance(topology, topologic.Topology):
|
|
4076
|
+
return None
|
|
4077
|
+
selectors = [v for v in selectors if isinstance(v, topologic.Vertex)]
|
|
4078
|
+
if len(selectors) < 1:
|
|
4079
|
+
return topology
|
|
4080
|
+
t_faces = Topology.Faces(topology)
|
|
4081
|
+
to_remove = []
|
|
4082
|
+
for t_f in t_faces:
|
|
4083
|
+
remove = False
|
|
4084
|
+
for i, v in enumerate(selectors):
|
|
4085
|
+
if Face.IsInside(face=t_f, vertex=v, tolerance=tolerance):
|
|
4086
|
+
remove = True
|
|
4087
|
+
selectors = selectors[:i]+ selectors[i:]
|
|
4088
|
+
break
|
|
4089
|
+
if remove:
|
|
4090
|
+
to_remove.append(t_f)
|
|
4091
|
+
if len(to_remove) < 1:
|
|
4092
|
+
return topology
|
|
4093
|
+
return Topology.RemoveFaces(topology, faces = to_remove)
|
|
4094
|
+
|
|
4095
|
+
@staticmethod
|
|
4096
|
+
def RemoveVertices(topology, vertices=[]):
|
|
4097
|
+
"""
|
|
4098
|
+
Removes the input list of vertices from the input topology
|
|
4099
|
+
|
|
4100
|
+
Parameters
|
|
4101
|
+
----------
|
|
4102
|
+
topology : topologic.Topology
|
|
4103
|
+
The input topology.
|
|
4104
|
+
vertices : list
|
|
4105
|
+
The input list of vertices.
|
|
4106
|
+
|
|
4107
|
+
Returns
|
|
4108
|
+
-------
|
|
4109
|
+
topologic.Topology
|
|
4110
|
+
The input topology with the input list of vertices removed.
|
|
4111
|
+
|
|
4112
|
+
"""
|
|
4113
|
+
|
|
4114
|
+
from topologicpy.Cluster import Cluster
|
|
4115
|
+
if not isinstance(topology, topologic.Topology):
|
|
4116
|
+
return None
|
|
4117
|
+
vertices = [v for v in vertices if isinstance(v, topologic.Vertex)]
|
|
4118
|
+
if len(vertices) < 1:
|
|
4119
|
+
return topology
|
|
4120
|
+
t_vertices = Topology.Vertices(topology)
|
|
4121
|
+
t_edges = Topology.Edges(topology)
|
|
4122
|
+
if len(t_vertices) < 1:
|
|
4123
|
+
return topology
|
|
4124
|
+
if len(t_edges) > 0:
|
|
4125
|
+
remove_edges = []
|
|
4126
|
+
for t_v in t_vertices:
|
|
4127
|
+
remove = False
|
|
4128
|
+
for i, v in enumerate(vertices):
|
|
4129
|
+
if Topology.IsSame(t_v, v):
|
|
4130
|
+
remove = True
|
|
4131
|
+
remove_edges += Topology.SuperTopologies(v, hostTopology=topology, topologyType="edge")
|
|
4132
|
+
vertices = vertices[:i]+ vertices[i:]
|
|
4133
|
+
break
|
|
4134
|
+
if len(remove_edges) > 0:
|
|
4135
|
+
return Topology.RemoveEdges(topology, remove_edges)
|
|
4136
|
+
else:
|
|
4137
|
+
remaining_vertices = []
|
|
4138
|
+
for t_v in t_vertices:
|
|
4139
|
+
remove = False
|
|
4140
|
+
for i, e in enumerate(vertices):
|
|
4141
|
+
if Topology.IsSame(t_v, v):
|
|
4142
|
+
remove = True
|
|
4143
|
+
vertices = vertices[:i]+ vertices[i:]
|
|
4144
|
+
break
|
|
4145
|
+
if not remove:
|
|
4146
|
+
remaining_vertices.append(t_v)
|
|
4147
|
+
if len(remaining_vertices) < 1:
|
|
4148
|
+
return None
|
|
4149
|
+
elif len(remaining_vertices) == 1:
|
|
4150
|
+
return remaining_vertices[0]
|
|
4151
|
+
return Topology.SelfMerge(Cluster.ByTopologies(remaining_vertices))
|
|
4152
|
+
|
|
4153
|
+
@staticmethod
|
|
4154
|
+
def ReplaceVertices(topology, verticesA=[], verticesB=[], tolerance=0.0001):
|
|
4155
|
+
"""
|
|
4156
|
+
Replaces the vertices in the first input list with the vertices in the second input list and rebuilds the input topology. The two lists must be of the same length.
|
|
4157
|
+
|
|
4158
|
+
Parameters
|
|
4159
|
+
----------
|
|
4160
|
+
topology : topologic.Topology
|
|
4161
|
+
The input topology.
|
|
4162
|
+
verticesA : list
|
|
4163
|
+
The first input list of vertices.
|
|
4164
|
+
verticesB : list
|
|
4165
|
+
The second input list of vertices.
|
|
4166
|
+
tolerance : float, optional
|
|
4167
|
+
The desired tolerance. The default is 0.0001.
|
|
4168
|
+
|
|
4169
|
+
Returns
|
|
4170
|
+
-------
|
|
4171
|
+
topologic.Topology
|
|
4172
|
+
The new topology.
|
|
4173
|
+
|
|
4174
|
+
"""
|
|
4175
|
+
if not len(verticesA) == len(verticesB):
|
|
4176
|
+
print("Error - Topology.ReplaceVertices: VerticesA and VerticesB must be the same length")
|
|
4177
|
+
return None
|
|
4178
|
+
from topologicpy.Vertex import Vertex
|
|
4179
|
+
geom = Topology.Geometry(topology)
|
|
4180
|
+
g_verts = geom['vertices']
|
|
4181
|
+
g_edges = geom['edges']
|
|
4182
|
+
g_faces = geom['faces']
|
|
4183
|
+
verts = [Topology.Vertices(Topology.ByGeometry(vertices=[g_v]))[0] for g_v in g_verts]
|
|
4184
|
+
for i, v in enumerate(verticesA):
|
|
4185
|
+
n = Vertex.Index(v, verts, tolerance=tolerance)
|
|
4186
|
+
if not n == None:
|
|
4187
|
+
verts[n] = verticesB[i]
|
|
4188
|
+
new_g_verts = []
|
|
4189
|
+
for v in verts:
|
|
4190
|
+
new_g_verts.append([Vertex.X(v),Vertex.Y(v),Vertex.Z(v)])
|
|
4191
|
+
new_topology = Topology.ByGeometry(vertices=new_g_verts, edges=g_edges, faces=g_faces)
|
|
4192
|
+
return new_topology
|
|
4193
|
+
|
|
3951
4194
|
@staticmethod
|
|
3952
4195
|
def Rotate(topology, origin=None, x=0, y=0, z=1, degree=0):
|
|
3953
4196
|
"""
|
|
3954
|
-
|
|
4197
|
+
Rotates the input topology
|
|
3955
4198
|
|
|
3956
4199
|
Parameters
|
|
3957
4200
|
----------
|
|
@@ -4312,7 +4555,16 @@ class Topology():
|
|
|
4312
4555
|
|
|
4313
4556
|
|
|
4314
4557
|
@staticmethod
|
|
4315
|
-
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None,
|
|
4558
|
+
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None,
|
|
4559
|
+
edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[],
|
|
4560
|
+
edgeGroups=[], faceGroups=[], faceColor='white', faceOpacity=0.5,
|
|
4561
|
+
edgeColor='black', edgeWidth=1, vertexColor='black', vertexSize=1.1,
|
|
4562
|
+
showFaces=True, showEdges=True, showVertices=True, width=950, height=500,
|
|
4563
|
+
xAxis=False, yAxis=False, zAxis=False, axisSize=1, backgroundColor='rgba(0,0,0,0)',
|
|
4564
|
+
marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[1.25, 1.25, 1.25],
|
|
4565
|
+
target=[0, 0, 0], up=[0, 0, 1], renderer="notebook", intensityKey=None, showScale=False,
|
|
4566
|
+
values=[], nTicks=5, xPosition=-0.15, colorbarWidth=15, outlineWidth=0, title="",
|
|
4567
|
+
subTitle="", units="", colorScale="viridis", mantissa=4):
|
|
4316
4568
|
"""
|
|
4317
4569
|
Shows the input topology on screen.
|
|
4318
4570
|
|
|
@@ -4408,10 +4660,30 @@ class Topology():
|
|
|
4408
4660
|
The desired up vector. The default is [0,0,1].
|
|
4409
4661
|
renderer : str , optional
|
|
4410
4662
|
The desired renderer. See Plotly.Renderers(). The default is "notebook".
|
|
4411
|
-
intensityKey: str, optional
|
|
4663
|
+
intensityKey : str , optional
|
|
4412
4664
|
If not None, the dictionary of each vertex is searched for the value associated with the intensity key. This value is then used to color-code the vertex based on the colorScale. The default is None.
|
|
4665
|
+
showScale : bool , optional
|
|
4666
|
+
If set to True, the colorbar is shown. The default is False.
|
|
4667
|
+
values : list , optional
|
|
4668
|
+
The input list of values to use for the colorbar. The default is [].
|
|
4669
|
+
nTicks : int , optional
|
|
4670
|
+
The number of ticks to use on the colorbar. The default is 5.
|
|
4671
|
+
xPosition : float , optional
|
|
4672
|
+
The x location of the colorbar. The default is -0.15.
|
|
4673
|
+
colorbarWidth : int , optional
|
|
4674
|
+
The width in pixels of the colorbar. The default is 15
|
|
4675
|
+
outlineWidth : int , optional
|
|
4676
|
+
The width in pixels of the outline of the colorbar. The default is 0.
|
|
4677
|
+
title : str , optional
|
|
4678
|
+
The title of the colorbar. The default is "".
|
|
4679
|
+
subTitle : str , optional
|
|
4680
|
+
The subtitle of the colorbar. The default is "".
|
|
4681
|
+
units: str , optional
|
|
4682
|
+
The units used in the colorbar. The default is ""
|
|
4413
4683
|
colorScale : str , optional
|
|
4414
|
-
The desired type of plotly color scales to use (e.g. "
|
|
4684
|
+
The desired type of plotly color scales to use (e.g. "viridis", "plasma"). The default is "viridis". For a full list of names, see https://plotly.com/python/builtin-colorscales/.
|
|
4685
|
+
mantissa : int , optional
|
|
4686
|
+
The desired length of the mantissa for the values listed on the colorbar. The default is 4.
|
|
4415
4687
|
|
|
4416
4688
|
Returns
|
|
4417
4689
|
-------
|
|
@@ -4423,6 +4695,8 @@ class Topology():
|
|
|
4423
4695
|
return None
|
|
4424
4696
|
data = Plotly.DataByTopology(topology=topology, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, vertexGroups=vertexGroups, edgeGroups=edgeGroups, faceGroups=faceGroups, faceColor=faceColor, faceOpacity=faceOpacity, edgeColor=edgeColor, edgeWidth=edgeWidth, vertexColor=vertexColor, vertexSize=vertexSize, showFaces=showFaces, showEdges=showEdges, showVertices=showVertices, intensityKey=intensityKey, colorScale=colorScale, showScale=showScale)
|
|
4425
4697
|
figure = Plotly.FigureByData(data=data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize, backgroundColor=backgroundColor, marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom)
|
|
4698
|
+
if showScale:
|
|
4699
|
+
figure = Plotly.AddColorBar(figure, values=values, nTicks=nTicks, xPosition=xPosition, width=colorbarWidth, outlineWidth=outlineWidth, title=title, subTitle=subTitle, units=units, colorScale=colorScale, mantissa=mantissa)
|
|
4426
4700
|
Plotly.Show(figure=figure, renderer=renderer, camera=camera, target=target, up=up)
|
|
4427
4701
|
|
|
4428
4702
|
@staticmethod
|
|
@@ -4641,6 +4915,8 @@ class Topology():
|
|
|
4641
4915
|
The list of edges.
|
|
4642
4916
|
|
|
4643
4917
|
"""
|
|
4918
|
+
if isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
4919
|
+
return []
|
|
4644
4920
|
return Topology.SubTopologies(topology=topology, subTopologyType="edge")
|
|
4645
4921
|
|
|
4646
4922
|
@staticmethod
|
|
@@ -4659,6 +4935,8 @@ class Topology():
|
|
|
4659
4935
|
The list of wires.
|
|
4660
4936
|
|
|
4661
4937
|
"""
|
|
4938
|
+
if isinstance(topology, topologic.Wire) or isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
4939
|
+
return []
|
|
4662
4940
|
return Topology.SubTopologies(topology=topology, subTopologyType="wire")
|
|
4663
4941
|
|
|
4664
4942
|
@staticmethod
|
|
@@ -4677,6 +4955,8 @@ class Topology():
|
|
|
4677
4955
|
The list of faces.
|
|
4678
4956
|
|
|
4679
4957
|
"""
|
|
4958
|
+
if isinstance(topology, topologic.Face) or isinstance(topology, topologic.Wire) or isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
4959
|
+
return []
|
|
4680
4960
|
return Topology.SubTopologies(topology=topology, subTopologyType="face")
|
|
4681
4961
|
|
|
4682
4962
|
@staticmethod
|
|
@@ -4695,6 +4975,8 @@ class Topology():
|
|
|
4695
4975
|
The list of shells.
|
|
4696
4976
|
|
|
4697
4977
|
"""
|
|
4978
|
+
if isinstance(topology, topologic.Shell) or isinstance(topology, topologic.Face) or isinstance(topology, topologic.Wire) or isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
4979
|
+
return []
|
|
4698
4980
|
return Topology.SubTopologies(topology=topology, subTopologyType="shell")
|
|
4699
4981
|
|
|
4700
4982
|
@staticmethod
|
|
@@ -4713,6 +4995,9 @@ class Topology():
|
|
|
4713
4995
|
The list of cells.
|
|
4714
4996
|
|
|
4715
4997
|
"""
|
|
4998
|
+
if isinstance(topology, topologic.Cell) or isinstance(topology, topologic.Shell) or isinstance(topology, topologic.Face) or isinstance(topology, topologic.Wire) or isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
4999
|
+
return []
|
|
5000
|
+
return Topology.SubTopologies(topology=topology, subTopologyType="shell")
|
|
4716
5001
|
return Topology.SubTopologies(topology=topology, subTopologyType="cell")
|
|
4717
5002
|
|
|
4718
5003
|
@staticmethod
|
|
@@ -4731,6 +5016,8 @@ class Topology():
|
|
|
4731
5016
|
The list of cellcomplexes.
|
|
4732
5017
|
|
|
4733
5018
|
"""
|
|
5019
|
+
if isinstance(topology, topologic.CellComplex) or isinstance(topology, topologic.Cell) or isinstance(topology, topologic.Shell) or isinstance(topology, topologic.Face) or isinstance(topology, topologic.Wire) or isinstance(topology, topologic.Edge) or isinstance(topology, topologic.Vertex):
|
|
5020
|
+
return []
|
|
4734
5021
|
return Topology.SubTopologies(topology=topology, subTopologyType="cellcomplex")
|
|
4735
5022
|
|
|
4736
5023
|
@staticmethod
|
topologicpy/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: topologicpy
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.8
|
|
4
4
|
Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
|
|
5
5
|
Author-email: Wassim Jabi <wassim.jabi@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/wassimj/TopologicPy
|