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
topologicpy/Color.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import plotly.colors
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
class Color:
|
|
5
|
+
@staticmethod
|
|
6
|
+
def ByValueInRange(value: float = 0.5, minValue: float = 0.0, maxValue: float = 1.0, alpha: float = 1.0, useAlpha: float = False, colorScale="viridis"):
|
|
7
|
+
"""
|
|
8
|
+
Retursn the r, g, b, (and optionally) a list of numbers representing the red, green, blue and alpha color elements.
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
value : float , optional
|
|
12
|
+
The input value. The default is 0.5.
|
|
13
|
+
minValue : float , optional
|
|
14
|
+
the input minimum value. The default is 0.0.
|
|
15
|
+
maxValue : float , optional
|
|
16
|
+
The input maximum value. The default is 1.0.
|
|
17
|
+
alpha : float , optional
|
|
18
|
+
The int alpha (transparency) value. 0.0 means the color is fully transparent, 1.0 means the color is fully opaque. The default is 1.0.
|
|
19
|
+
useAlpha : bool , optional
|
|
20
|
+
If set to True, the returns list includes the alpha value as a fourth element in the lists.
|
|
21
|
+
colorScale : str , optional
|
|
22
|
+
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/.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
TYPE
|
|
27
|
+
DESCRIPTION.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
# Code based on: https://stackoverflow.com/questions/62710057/access-color-from-plotly-color-scale
|
|
32
|
+
|
|
33
|
+
def hex_to_rgb(value):
|
|
34
|
+
value = str(value)
|
|
35
|
+
value = value.lstrip('#')
|
|
36
|
+
lv = len(value)
|
|
37
|
+
returnValue = tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
|
|
38
|
+
return str(returnValue)
|
|
39
|
+
|
|
40
|
+
def get_color(colorscale_name, loc):
|
|
41
|
+
from _plotly_utils.basevalidators import ColorscaleValidator
|
|
42
|
+
# first parameter: Name of the property being validated
|
|
43
|
+
# second parameter: a string, doesn't really matter in our use case
|
|
44
|
+
cv = ColorscaleValidator("colorscale", "")
|
|
45
|
+
# colorscale will be a list of lists: [[loc1, "rgb1"], [loc2, "rgb2"], ...]
|
|
46
|
+
colorscale = cv.validate_coerce(colorscale_name)
|
|
47
|
+
if hasattr(loc, "__iter__"):
|
|
48
|
+
return [get_continuous_color(colorscale, x) for x in loc]
|
|
49
|
+
color = get_continuous_color(colorscale, loc)
|
|
50
|
+
color = color.replace("rgb", "")
|
|
51
|
+
color = color.replace("(", "")
|
|
52
|
+
color = color.replace(")", "")
|
|
53
|
+
color = color.split(",")
|
|
54
|
+
final_colors = []
|
|
55
|
+
for c in color:
|
|
56
|
+
final_colors.append(math.floor(float(c)))
|
|
57
|
+
return final_colors
|
|
58
|
+
|
|
59
|
+
def get_continuous_color(colorscale, intermed):
|
|
60
|
+
"""
|
|
61
|
+
Plotly continuous colorscales assign colors to the range [0, 1]. This function computes the intermediate
|
|
62
|
+
color for any value in that range.
|
|
63
|
+
|
|
64
|
+
Plotly doesn't make the colorscales directly accessible in a common format.
|
|
65
|
+
Some are ready to use:
|
|
66
|
+
|
|
67
|
+
colorscale = plotly.colors.PLOTLY_SCALES["Greens"]
|
|
68
|
+
|
|
69
|
+
Others are just swatches that need to be constructed into a colorscale:
|
|
70
|
+
|
|
71
|
+
viridis_colors, scale = plotly.colors.convert_colors_to_same_type(plotly.colors.sequential.Viridis)
|
|
72
|
+
colorscale = plotly.colors.make_colorscale(viridis_colors, scale=scale)
|
|
73
|
+
|
|
74
|
+
:param colorscale: A plotly continuous colorscale defined with RGB string colors.
|
|
75
|
+
:param intermed: value in the range [0, 1]
|
|
76
|
+
:return: color in rgb string format
|
|
77
|
+
:rtype: str
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
if len(colorscale) < 1:
|
|
81
|
+
raise ValueError("colorscale must have at least one color")
|
|
82
|
+
if intermed <= 0 or len(colorscale) == 1:
|
|
83
|
+
c = colorscale[0][1]
|
|
84
|
+
return c if c[0] != "#" else hex_to_rgb(c)
|
|
85
|
+
if intermed >= 1:
|
|
86
|
+
c = colorscale[-1][1]
|
|
87
|
+
return c if c[0] != "#" else hex_to_rgb(c)
|
|
88
|
+
for cutoff, color in colorscale:
|
|
89
|
+
if intermed > cutoff:
|
|
90
|
+
low_cutoff, low_color = cutoff, color
|
|
91
|
+
else:
|
|
92
|
+
high_cutoff, high_color = cutoff, color
|
|
93
|
+
break
|
|
94
|
+
if (low_color[0] == "#") or (high_color[0] == "#"):
|
|
95
|
+
# some color scale names (such as cividis) returns:
|
|
96
|
+
# [[loc1, "hex1"], [loc2, "hex2"], ...]
|
|
97
|
+
low_color = hex_to_rgb(low_color)
|
|
98
|
+
high_color = hex_to_rgb(high_color)
|
|
99
|
+
return plotly.colors.find_intermediate_color(
|
|
100
|
+
lowcolor=low_color,
|
|
101
|
+
highcolor=high_color,
|
|
102
|
+
intermed=((intermed - low_cutoff) / (high_cutoff - low_cutoff)),
|
|
103
|
+
colortype="rgb",
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def get_color_default(ratio):
|
|
107
|
+
r = 0.0
|
|
108
|
+
g = 0.0
|
|
109
|
+
b = 0.0
|
|
110
|
+
|
|
111
|
+
finalRatio = ratio;
|
|
112
|
+
if (finalRatio < 0.0):
|
|
113
|
+
finalRatio = 0.0
|
|
114
|
+
elif(finalRatio > 1.0):
|
|
115
|
+
finalRatio = 1.0
|
|
116
|
+
|
|
117
|
+
if (finalRatio >= 0.0 and finalRatio <= 0.25):
|
|
118
|
+
r = 0.0
|
|
119
|
+
g = 4.0 * finalRatio
|
|
120
|
+
b = 1.0
|
|
121
|
+
elif (finalRatio > 0.25 and finalRatio <= 0.5):
|
|
122
|
+
r = 0.0
|
|
123
|
+
g = 1.0
|
|
124
|
+
b = 1.0 - 4.0 * (finalRatio - 0.25)
|
|
125
|
+
elif (finalRatio > 0.5 and finalRatio <= 0.75):
|
|
126
|
+
r = 4.0*(finalRatio - 0.5);
|
|
127
|
+
g = 1.0
|
|
128
|
+
b = 0.0
|
|
129
|
+
else:
|
|
130
|
+
r = 1.0
|
|
131
|
+
g = 1.0 - 4.0 * (finalRatio - 0.75)
|
|
132
|
+
b = 0.0
|
|
133
|
+
|
|
134
|
+
rcom = (max(min(r, 1.0), 0.0))
|
|
135
|
+
gcom = (max(min(g, 1.0), 0.0))
|
|
136
|
+
bcom = (max(min(b, 1.0), 0.0))
|
|
137
|
+
|
|
138
|
+
return [rcom,gcom,bcom]
|
|
139
|
+
|
|
140
|
+
if minValue > maxValue:
|
|
141
|
+
temp = minValue;
|
|
142
|
+
maxValue = minValue
|
|
143
|
+
maxValue = temp
|
|
144
|
+
|
|
145
|
+
val = value
|
|
146
|
+
val = max(min(val,maxValue), minValue) # bracket value to the min and max values
|
|
147
|
+
if (maxValue - minValue) != 0:
|
|
148
|
+
val = (val - minValue)/(maxValue - minValue)
|
|
149
|
+
else:
|
|
150
|
+
val = 0
|
|
151
|
+
if not colorScale or colorScale.lower() == "default":
|
|
152
|
+
rgbList = get_color_default(val)
|
|
153
|
+
else:
|
|
154
|
+
rgbList = get_color(colorScale, val)
|
|
155
|
+
if useAlpha:
|
|
156
|
+
rgbList.append(alpha)
|
|
157
|
+
return rgbList
|
topologicpy/Context.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import topologicpy
|
|
2
|
+
import topologic
|
|
3
|
+
|
|
4
|
+
class Context:
|
|
5
|
+
@staticmethod
|
|
6
|
+
def ByTopologyParameters(topology, u = 0.5, v = 0.5, w = 0.5):
|
|
7
|
+
"""
|
|
8
|
+
Creates a context object represented by the input topology.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
topology : topologic.Topology
|
|
13
|
+
The input topology.
|
|
14
|
+
u : float , optional
|
|
15
|
+
The input *u* parameter. This defines the relative parameteric location of the content object along the *u* axis.
|
|
16
|
+
v : TYPE
|
|
17
|
+
The input *v* parameter. This defines the relative parameteric location of the content object along the *v* axis..
|
|
18
|
+
w : TYPE
|
|
19
|
+
The input *w* parameter. This defines the relative parameteric location of the content object along the *w* axis.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
topologic.Context
|
|
24
|
+
The created context object. See Aperture.ByObjectContext.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
context = None
|
|
29
|
+
try:
|
|
30
|
+
context = topologic.Context.ByTopologyParameters(topology, u, v, w)
|
|
31
|
+
except:
|
|
32
|
+
context = None
|
|
33
|
+
return context
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def Topology(context):
|
|
37
|
+
"""
|
|
38
|
+
Returns the topology of the input context.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
context : topologic.Context
|
|
43
|
+
The input context.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
topologic.Topology
|
|
48
|
+
The topology of the input context.
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
topology = None
|
|
52
|
+
try:
|
|
53
|
+
topology = context.Topology()
|
|
54
|
+
except:
|
|
55
|
+
topology = None
|
|
56
|
+
return topology
|