topologicpy 0.8.12__py3-none-any.whl → 0.8.14__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/Cell.py CHANGED
@@ -2185,62 +2185,154 @@ class Cell():
2185
2185
  return Cell.Area(cell=cell, mantissa=mantissa)
2186
2186
 
2187
2187
  @staticmethod
2188
- def Tetrahedron(origin= None, radius: float = 0.5,
2189
- direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001):
2188
+ def Tetrahedron(origin = None, length: float = 1, depth: int = 1, direction=[0,0,1], placement="center", mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
2190
2189
  """
2191
- Creates a tetrahedron. See https://en.wikipedia.org/wiki/Tetrahedron.
2190
+ Creates a recursive tetrahedron cell.
2192
2191
 
2193
2192
  Parameters
2194
2193
  ----------
2195
2194
  origin : topologic_core.Vertex , optional
2196
2195
  The origin location of the tetrahedron. The default is None which results in the tetrahedron being placed at (0, 0, 0).
2197
- radius : float , optional
2198
- The radius of the tetrahedron's circumscribed sphere. The default is 0.5.
2196
+ length : float , optional
2197
+ The length of the edge of the tetrahedron. The default is 1.
2198
+ depth : int , optional
2199
+ The desired maximum number of recrusive subdivision levels.
2199
2200
  direction : list , optional
2200
2201
  The vector representing the up direction of the tetrahedron. The default is [0, 0, 1].
2201
2202
  placement : str , optional
2202
2203
  The description of the placement of the origin of the tetrahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
2204
+ mantissa : int , optional
2205
+ The desired length of the mantissa. The default is 6.
2203
2206
  tolerance : float , optional
2204
2207
  The desired tolerance. The default is 0.0001.
2205
2208
 
2206
2209
  Returns
2207
2210
  -------
2208
- topologic_core.Cell
2211
+ topologic_core.CellComplex
2209
2212
  The created tetrahedron.
2210
2213
 
2211
2214
  """
2212
-
2213
2215
  from topologicpy.Vertex import Vertex
2214
- from topologicpy.Wire import Wire
2215
2216
  from topologicpy.Face import Face
2217
+ from topologicpy.Cell import Cell
2218
+ from topologicpy.CellComplex import CellComplex
2219
+ from topologicpy.Cluster import Cluster
2216
2220
  from topologicpy.Topology import Topology
2217
- import math
2221
+ from topologicpy.Dictionary import Dictionary
2218
2222
 
2219
- if not Topology.IsInstance(origin, "Vertex"):
2220
- origin = Vertex.ByCoordinates(0, 0, 0)
2221
- if not Topology.IsInstance(origin, "Vertex"):
2222
- print("Cell.Tetrahedron - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
2223
- return None
2223
+ from math import sqrt
2224
2224
 
2225
- vb1 = Vertex.ByCoordinates(math.sqrt(8/9), 0, -1/3)
2226
- vb2 = Vertex.ByCoordinates(-math.sqrt(2/9), math.sqrt(2/3), -1/3)
2227
- vb3 = Vertex.ByCoordinates(-math.sqrt(2/9), -math.sqrt(2/3), -1/3)
2228
- vb4 = Vertex.ByCoordinates(0, 0, 1)
2229
- f1 = Face.ByVertices([vb1, vb2, vb3])
2230
- f2 = Face.ByVertices([vb4, vb1, vb2])
2231
- f3 = Face.ByVertices([vb4, vb2, vb3])
2232
- f4 = Face.ByVertices([vb4, vb3, vb1])
2233
- tetrahedron = Cell.ByFaces([f1, f2, f3, f4])
2234
- tetrahedron = Topology.Scale(tetrahedron, origin=Vertex.Origin(), x=0.5, y=0.5, z=0.5)
2235
- tetrahedron = Topology.Scale(tetrahedron, origin=Vertex.Origin(), x=radius/0.5, y=radius/0.5, z=radius/0.5)
2225
+ def subdivide_tetrahedron(tetrahedron, depth):
2226
+ """
2227
+ Recursively subdivides a tetrahedron into smaller tetrahedra.
2236
2228
 
2237
- if placement.lower() == "lowerleft":
2238
- tetrahedron = Topology.Translate(tetrahedron, radius, radius, radius)
2229
+ Parameters:
2230
+ tetrahedron (Cell): The tetrahedron to subdivide.
2231
+ depth (int): Recursion depth for the subdivision.
2232
+
2233
+ Returns:
2234
+ list: List of smaller tetrahedral cells.
2235
+ """
2236
+ if depth == 0:
2237
+ return [tetrahedron]
2238
+
2239
+ # Extract the vertices of the tetrahedron
2240
+ vertices = Topology.Vertices(tetrahedron)
2241
+ v0, v1, v2, v3 = vertices
2242
+
2243
+ # Calculate midpoints of the edges
2244
+ m01 = Vertex.ByCoordinates((v0.X() + v1.X()) / 2, (v0.Y() + v1.Y()) / 2, (v0.Z() + v1.Z()) / 2)
2245
+ m02 = Vertex.ByCoordinates((v0.X() + v2.X()) / 2, (v0.Y() + v2.Y()) / 2, (v0.Z() + v2.Z()) / 2)
2246
+ m03 = Vertex.ByCoordinates((v0.X() + v3.X()) / 2, (v0.Y() + v3.Y()) / 2, (v0.Z() + v3.Z()) / 2)
2247
+ m12 = Vertex.ByCoordinates((v1.X() + v2.X()) / 2, (v1.Y() + v2.Y()) / 2, (v1.Z() + v2.Z()) / 2)
2248
+ m13 = Vertex.ByCoordinates((v1.X() + v3.X()) / 2, (v1.Y() + v3.Y()) / 2, (v1.Z() + v3.Z()) / 2)
2249
+ m23 = Vertex.ByCoordinates((v2.X() + v3.X()) / 2, (v2.Y() + v3.Y()) / 2, (v2.Z() + v3.Z()) / 2)
2250
+
2251
+ # Create smaller tetrahedra
2252
+ tetrahedra = [
2253
+ Cell.ByFaces([
2254
+ Face.ByVertices([v0, m01, m02]),
2255
+ Face.ByVertices([v0, m01, m03]),
2256
+ Face.ByVertices([v0, m02, m03]),
2257
+ Face.ByVertices([m01, m02, m03])
2258
+ ]),
2259
+ Cell.ByFaces([
2260
+ Face.ByVertices([m01, v1, m12]),
2261
+ Face.ByVertices([m01, v1, m13]),
2262
+ Face.ByVertices([m01, m12, m13]),
2263
+ Face.ByVertices([v1, m12, m13])
2264
+ ]),
2265
+ Cell.ByFaces([
2266
+ Face.ByVertices([m02, m12, v2]),
2267
+ Face.ByVertices([m02, m12, m23]),
2268
+ Face.ByVertices([m02, v2, m23]),
2269
+ Face.ByVertices([m12, v2, m23])
2270
+ ]),
2271
+ Cell.ByFaces([
2272
+ Face.ByVertices([m03, m13, m23]),
2273
+ Face.ByVertices([m03, v3, m13]),
2274
+ Face.ByVertices([m03, v3, m23]),
2275
+ Face.ByVertices([m13, v3, m23])
2276
+ ])
2277
+ ]
2278
+
2279
+ # Recursively subdivide the smaller tetrahedra
2280
+ result = []
2281
+ for t in tetrahedra:
2282
+ result.extend(subdivide_tetrahedron(t, depth - 1))
2283
+ return result
2284
+
2285
+ if not Topology.IsInstance(origin, "vertex"):
2286
+ origin = Vertex.Origin()
2287
+
2288
+ # Define the four vertices of the tetrahedron
2289
+ v0 = Vertex.ByCoordinates(0, 0, 0)
2290
+ v1 = Vertex.ByCoordinates(length, 0, 0)
2291
+ v2 = Vertex.ByCoordinates(length/2, sqrt(3)/2*length, 0)
2292
+ v3 = Vertex.ByCoordinates(length/2, sqrt(3)/2*length/3, sqrt(2/3)*length)
2293
+
2294
+ # Create the initial tetrahedron
2295
+ tetrahedron = Cell.ByFaces([
2296
+ Face.ByVertices([v0, v1, v2]),
2297
+ Face.ByVertices([v0, v1, v3]),
2298
+ Face.ByVertices([v1, v2, v3]),
2299
+ Face.ByVertices([v2, v0, v3]),
2300
+ ])
2301
+
2302
+ bbox = Topology.BoundingBox(tetrahedron)
2303
+ d = Topology.Dictionary(bbox)
2304
+ bb_width = Dictionary.ValueAtKey(d, "width")
2305
+ bb_length = Dictionary.ValueAtKey(d, "length")
2306
+ bb_height = Dictionary.ValueAtKey(d, "height")
2307
+
2308
+ centroid = Topology.Centroid(tetrahedron)
2309
+ c_x, c_y, c_z = Vertex.Coordinates(centroid, mantissa=mantissa)
2310
+
2311
+ if placement.lower() == "center":
2312
+ tetrahedron = Topology.Translate(tetrahedron, -c_x, -c_y, -c_z)
2239
2313
  elif placement.lower() == "bottom":
2240
- tetrahedron = Topology.Translate(tetrahedron, 0, 0, radius)
2241
- tetrahedron = Topology.Place(tetrahedron, originA=Vertex.Origin(), originB=origin)
2242
- tetrahedron = Topology.Orient(tetrahedron, origin=origin, dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
2243
- return tetrahedron
2314
+ tetrahedron = Topology.Translate(tetrahedron,-c_x, -c_y, 0)
2315
+ elif placement.lower() == "upperleft":
2316
+ tetrahedron = Topology.Translate(tetrahedron, 0, 0, -bb_height)
2317
+ elif placement.lower() == "upperright":
2318
+ tetrahedron = Topology.Translate(tetrahedron, -bb_width, -bb_length, -bb_height)
2319
+ elif placement.lower() == "bottomright":
2320
+ tetrahedron = Topology.Translate(tetrahedron, -bb_width, -bb_length, 0)
2321
+ elif placement.lower() == "top":
2322
+ tetrahedron = Topology.Translate(tetrahedron,-c_x, -c_y, -bb_height)
2323
+
2324
+ tetrahedron = Topology.Place(tetrahedron, Vertex.Origin(), origin)
2325
+ if not direction == [0,0,1]:
2326
+ tetrahedron = Topology.Orient(tetrahedron, origin=origin, dirA=[0,0,1], dirB=direction)
2327
+
2328
+ depth = max(depth, 0)
2329
+ if depth == 0:
2330
+ return tetrahedron
2331
+ else:
2332
+ # Recursively subdivide the tetrahedron
2333
+ subdivided_tetrahedra = subdivide_tetrahedron(tetrahedron, depth)
2334
+ # Create a cell complex from the subdivided tetrahedra
2335
+ return CellComplex.ExternalBoundary(CellComplex.ByCells([tetrahedron]+subdivided_tetrahedra))
2244
2336
 
2245
2337
  @staticmethod
2246
2338
  def Torus(origin= None, majorRadius: float = 0.5, minorRadius: float = 0.125, uSides: int = 16, vSides: int = 8, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
@@ -1012,6 +1012,151 @@ class CellComplex():
1012
1012
  shells = Topology.Shells(cellComplex)
1013
1013
  return shells
1014
1014
 
1015
+ @staticmethod
1016
+ def Tetrahedron(origin = None, length: float = 1, depth: int = 1, direction=[0,0,1], placement="center", mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
1017
+ """
1018
+ Creates a recursive tetrahedron cellComplex with internal cells.
1019
+
1020
+ Parameters
1021
+ ----------
1022
+ origin : topologic_core.Vertex , optional
1023
+ The origin location of the tetrahedron. The default is None which results in the tetrahedron being placed at (0, 0, 0).
1024
+ length : float , optional
1025
+ The length of the edge of the tetrahedron. The default is 1.
1026
+ depth : int , optional
1027
+ The desired maximum number of recrusive subdivision levels.
1028
+ direction : list , optional
1029
+ The vector representing the up direction of the tetrahedron. The default is [0, 0, 1].
1030
+ placement : str , optional
1031
+ The description of the placement of the origin of the tetrahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
1032
+ mantissa : int , optional
1033
+ The desired length of the mantissa. The default is 6.
1034
+ tolerance : float , optional
1035
+ The desired tolerance. The default is 0.0001.
1036
+
1037
+ Returns
1038
+ -------
1039
+ topologic_core.CellComplex
1040
+ The created tetrahedron.
1041
+
1042
+ """
1043
+ from topologicpy.Vertex import Vertex
1044
+ from topologicpy.Face import Face
1045
+ from topologicpy.Cell import Cell
1046
+ from topologicpy.Topology import Topology
1047
+ from topologicpy.Dictionary import Dictionary
1048
+
1049
+ from math import sqrt
1050
+
1051
+ def subdivide_tetrahedron(tetrahedron, depth):
1052
+ """
1053
+ Recursively subdivides a tetrahedron into smaller tetrahedra.
1054
+
1055
+ Parameters:
1056
+ tetrahedron (Cell): The tetrahedron to subdivide.
1057
+ depth (int): Recursion depth for the subdivision.
1058
+
1059
+ Returns:
1060
+ list: List of smaller tetrahedral cells.
1061
+ """
1062
+ if depth == 0:
1063
+ return [tetrahedron]
1064
+
1065
+ # Extract the vertices of the tetrahedron
1066
+ vertices = Topology.Vertices(tetrahedron)
1067
+ v0, v1, v2, v3 = vertices
1068
+
1069
+ # Calculate midpoints of the edges
1070
+ m01 = Vertex.ByCoordinates((v0.X() + v1.X()) / 2, (v0.Y() + v1.Y()) / 2, (v0.Z() + v1.Z()) / 2)
1071
+ m02 = Vertex.ByCoordinates((v0.X() + v2.X()) / 2, (v0.Y() + v2.Y()) / 2, (v0.Z() + v2.Z()) / 2)
1072
+ m03 = Vertex.ByCoordinates((v0.X() + v3.X()) / 2, (v0.Y() + v3.Y()) / 2, (v0.Z() + v3.Z()) / 2)
1073
+ m12 = Vertex.ByCoordinates((v1.X() + v2.X()) / 2, (v1.Y() + v2.Y()) / 2, (v1.Z() + v2.Z()) / 2)
1074
+ m13 = Vertex.ByCoordinates((v1.X() + v3.X()) / 2, (v1.Y() + v3.Y()) / 2, (v1.Z() + v3.Z()) / 2)
1075
+ m23 = Vertex.ByCoordinates((v2.X() + v3.X()) / 2, (v2.Y() + v3.Y()) / 2, (v2.Z() + v3.Z()) / 2)
1076
+
1077
+ # Create smaller tetrahedra
1078
+ tetrahedra = [
1079
+ Cell.ByFaces([
1080
+ Face.ByVertices([v0, m01, m02]),
1081
+ Face.ByVertices([v0, m01, m03]),
1082
+ Face.ByVertices([v0, m02, m03]),
1083
+ Face.ByVertices([m01, m02, m03])
1084
+ ]),
1085
+ Cell.ByFaces([
1086
+ Face.ByVertices([m01, v1, m12]),
1087
+ Face.ByVertices([m01, v1, m13]),
1088
+ Face.ByVertices([m01, m12, m13]),
1089
+ Face.ByVertices([v1, m12, m13])
1090
+ ]),
1091
+ Cell.ByFaces([
1092
+ Face.ByVertices([m02, m12, v2]),
1093
+ Face.ByVertices([m02, m12, m23]),
1094
+ Face.ByVertices([m02, v2, m23]),
1095
+ Face.ByVertices([m12, v2, m23])
1096
+ ]),
1097
+ Cell.ByFaces([
1098
+ Face.ByVertices([m03, m13, m23]),
1099
+ Face.ByVertices([m03, v3, m13]),
1100
+ Face.ByVertices([m03, v3, m23]),
1101
+ Face.ByVertices([m13, v3, m23])
1102
+ ])
1103
+ ]
1104
+
1105
+ # Recursively subdivide the smaller tetrahedra
1106
+ result = []
1107
+ for t in tetrahedra:
1108
+ result.extend(subdivide_tetrahedron(t, depth - 1))
1109
+ return result
1110
+
1111
+ if not Topology.IsInstance(origin, "vertex"):
1112
+ origin = Vertex.Origin()
1113
+
1114
+ # Define the four vertices of the tetrahedron
1115
+ v0 = Vertex.ByCoordinates(0, 0, 0)
1116
+ v1 = Vertex.ByCoordinates(length, 0, 0)
1117
+ v2 = Vertex.ByCoordinates(length/2, sqrt(3)/2*length, 0)
1118
+ v3 = Vertex.ByCoordinates(length/2, sqrt(3)/2*length/3, sqrt(2/3)*length)
1119
+
1120
+ # Create the initial tetrahedron
1121
+ tetrahedron = Cell.ByFaces([
1122
+ Face.ByVertices([v0, v1, v2]),
1123
+ Face.ByVertices([v0, v1, v3]),
1124
+ Face.ByVertices([v1, v2, v3]),
1125
+ Face.ByVertices([v2, v0, v3]),
1126
+ ])
1127
+
1128
+ bbox = Topology.BoundingBox(tetrahedron)
1129
+ d = Topology.Dictionary(bbox)
1130
+ bb_width = Dictionary.ValueAtKey(d, "width")
1131
+ bb_length = Dictionary.ValueAtKey(d, "length")
1132
+ bb_height = Dictionary.ValueAtKey(d, "height")
1133
+
1134
+ centroid = Topology.Centroid(tetrahedron)
1135
+ c_x, c_y, c_z = Vertex.Coordinates(centroid, mantissa=mantissa)
1136
+
1137
+ if placement.lower() == "center":
1138
+ tetrahedron = Topology.Translate(tetrahedron, -c_x, -c_y, -c_z)
1139
+ elif placement.lower() == "bottom":
1140
+ tetrahedron = Topology.Translate(tetrahedron,-c_x, -c_y, 0)
1141
+ elif placement.lower() == "upperleft":
1142
+ tetrahedron = Topology.Translate(tetrahedron, 0, 0, -bb_height)
1143
+ elif placement.lower() == "upperright":
1144
+ tetrahedron = Topology.Translate(tetrahedron, -bb_width, -bb_length, -bb_height)
1145
+ elif placement.lower() == "bottomright":
1146
+ tetrahedron = Topology.Translate(tetrahedron, -bb_width, -bb_length, 0)
1147
+ elif placement.lower() == "top":
1148
+ tetrahedron = Topology.Translate(tetrahedron,-c_x, -c_y, -bb_height)
1149
+
1150
+ tetrahedron = Topology.Place(tetrahedron, Vertex.Origin(), origin)
1151
+ if not direction == [0,0,1]:
1152
+ tetrahedron = Topology.Orient(tetrahedron, origin=origin, dirA=[0,0,1], dirB=direction)
1153
+
1154
+ depth = max(depth, 1)
1155
+ # Recursively subdivide the tetrahedron
1156
+ subdivided_tetrahedra = subdivide_tetrahedron(tetrahedron, depth)
1157
+ # Create a cell complex from the subdivided tetrahedra
1158
+ return CellComplex.ByCells([tetrahedron]+subdivided_tetrahedra)
1159
+
1015
1160
  @staticmethod
1016
1161
  def Torus(origin= None, majorRadius: float = 0.5, minorRadius: float = 0.125, uSides: int = 16, vSides: int = 8, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
1017
1162
  """
topologicpy/Graph.py CHANGED
@@ -1358,7 +1358,7 @@ class Graph:
1358
1358
  return bot_graph.serialize(format=format)
1359
1359
 
1360
1360
  @staticmethod
1361
- def BetweennessCentrality(graph, method: str = "vertex", weightKey="length", normalize: bool = False, nx: bool = False, key: str = "betweenness_centrality", colorKey="bc_color", colorScale="viridis", mantissa: int = 6, tolerance: float = 0.001, silent: bool = False):
1361
+ def BetweennessCentrality(graph, method: str = "vertex", weightKey="length", normalize: bool = False, nxCompatible: bool = False, key: str = "betweenness_centrality", colorKey="bc_color", colorScale="viridis", mantissa: int = 6, tolerance: float = 0.001, silent: bool = False):
1362
1362
  """
1363
1363
  Returns the betweenness centrality of the input graph. The order of the returned list is the same as the order of vertices/edges. See https://en.wikipedia.org/wiki/Betweenness_centrality.
1364
1364
 
@@ -1374,7 +1374,7 @@ class Graph:
1374
1374
  This is used in weighted graphs. if weightKey is set to "Length" or "Distance", the length of the edge will be used as its weight.
1375
1375
  normalize : bool , optional
1376
1376
  If set to True, the values are normalized to be in the range 0 to 1. Otherwise they are not. The default is False.
1377
- nx : bool , optional
1377
+ nxCompatible : bool , optional
1378
1378
  If set to True, and normalize input parameter is also set to True, the values are set to be identical to NetworkX values. Otherwise, they are normalized between 0 and 1. The default is False.
1379
1379
  key : str , optional
1380
1380
  The desired dictionary key under which to store the betweenness centrality score. The default is "betweenness_centrality".
@@ -1423,12 +1423,12 @@ class Graph:
1423
1423
  if "vert" in method.lower():
1424
1424
  elements = Graph.Vertices(graph)
1425
1425
  elements_dict = nx.betweenness_centrality(nx_graph, normalized=normalize, weight=weightKey)
1426
- values = list(elements_dict.values())
1426
+ values = [round(value, mantissa) for value in list(elements_dict.values())]
1427
1427
  else:
1428
1428
  elements = Graph.Edges(graph)
1429
1429
  elements_dict = nx.edge_betweenness_centrality(nx_graph, normalized=normalize, weight=weightKey)
1430
1430
  values = [round(value, mantissa) for value in list(elements_dict.values())]
1431
- if nx == False:
1431
+ if nxCompatible == False:
1432
1432
  if mantissa > 0: # We cannot have values in the range 0 to 1 with a mantissa < 1
1433
1433
  values = [round(v, mantissa) for v in Helper.Normalize(values)]
1434
1434
  else:
@@ -4686,7 +4686,7 @@ class Graph:
4686
4686
  return graph
4687
4687
 
4688
4688
  @staticmethod
4689
- def ClosenessCentrality(graph, weightKey="length", normalize: bool = False, nx: bool = True, key: str = "closeness_centrality", colorKey="cc_color", colorScale="viridis", mantissa: int = 6, tolerance: float = 0.001, silent: bool = False):
4689
+ def ClosenessCentrality(graph, weightKey="length", normalize: bool = False, nxCompatible: bool = True, key: str = "closeness_centrality", colorKey="cc_color", colorScale="viridis", mantissa: int = 6, tolerance: float = 0.001, silent: bool = False):
4690
4690
  """
4691
4691
  Returns the closeness centrality of the input graph. The order of the returned list is the same as the order of vertices/edges. See https://en.wikipedia.org/wiki/Betweenness_centrality.
4692
4692
 
@@ -4700,7 +4700,7 @@ class Graph:
4700
4700
  This is used in weighted graphs. if weightKey is set to "Length" or "Distance", the length of the edge will be used as its weight.
4701
4701
  normalize : bool , optional
4702
4702
  If set to True, the values are normalized to be in the range 0 to 1. Otherwise they are not. The default is False.
4703
- nx : bool , optional
4703
+ nxCompatible : bool , optional
4704
4704
  If set to True, use networkX to scale by the fraction of nodes reachable. This gives the Wasserman and Faust improved formula.
4705
4705
  For single component graphs it is the same as the original formula.
4706
4706
  key : str , optional
@@ -4753,7 +4753,7 @@ class Graph:
4753
4753
  weightKey = "length"
4754
4754
  nx_graph = Graph.NetworkXGraph(graph)
4755
4755
  elements = Graph.Vertices(graph)
4756
- elements_dict = nx.closeness_centrality(nx_graph, distance=weightKey, wf_improved=nx)
4756
+ elements_dict = nx.closeness_centrality(nx_graph, distance=weightKey, wf_improved=nxCompatible)
4757
4757
  values = [round(v, mantissa) for v in list(elements_dict.values())]
4758
4758
  if normalize == True:
4759
4759
  if mantissa > 0: # We cannot round numbers from 0 to 1 with a mantissa = 0.
topologicpy/Honeybee.py CHANGED
@@ -300,33 +300,27 @@ class Honeybee:
300
300
  sensorGrids = []
301
301
  for spaceNumber, tpCell in enumerate(tpCells):
302
302
  tpDictionary = Topology.Dictionary(tpCell)
303
- tpCellName = None
304
- tpCellStory = None
303
+ tpCellName = "Untitled Space"
304
+ tpCellStory = fl[0]
305
305
  tpCellProgramIdentifier = None
306
306
  tpCellConstructionSetIdentifier = None
307
307
  tpCellConditioned = True
308
308
  if tpDictionary:
309
309
  keyName = getKeyName(tpDictionary, 'Story')
310
- try:
311
- tpCellStory = Dictionary.ValueAtKey(tpDictionary, keyName)
312
- if tpCellStory:
313
- tpCellStory = tpCellStory.replace(" ","_")
314
- except:
315
- tpCellStory = fl[spaceNumber]
310
+ tpCellStory = Dictionary.ValueAtKey(tpDictionary, keyName, silent=True) or fl[spaceNumber]
311
+ if tpCellStory:
312
+ tpCellStory = tpCellStory.replace(" ","_")
313
+ else:
314
+ tpCellStory = "Untitled_Floor"
316
315
  if roomNameKey:
317
316
  keyName = getKeyName(tpDictionary, roomNameKey)
318
317
  else:
319
318
  keyName = getKeyName(tpDictionary, 'Name')
320
- try:
321
- tpCellName = Dictionary.ValueAtKey(tpDictionary,keyName)
322
- if tpCellName:
323
- tpCellName = createUniqueName(tpCellName.replace(" ","_"), spaceNames, 1)
324
- except:
325
- tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1))
319
+ tpCellName = Dictionary.ValueAtKey(tpDictionary,keyName, silent=True) or createUniqueName(tpCellStory+"_SPACE_"+(str(spaceNumber+1)), spaceNames, 1)
326
320
  if roomTypeKey:
327
321
  keyName = getKeyName(tpDictionary, roomTypeKey)
328
322
  try:
329
- tpCellProgramIdentifier = Dictionary.ValueAtKey(tpDictionary, keyName)
323
+ tpCellProgramIdentifier = Dictionary.ValueAtKey(tpDictionary, keyName, silent=True)
330
324
  if tpCellProgramIdentifier:
331
325
  program = prog_type_lib.program_type_by_identifier(tpCellProgramIdentifier)
332
326
  elif defaultProgramIdentifier:
@@ -335,7 +329,7 @@ class Honeybee:
335
329
  program = prog_type_lib.office_program #Default Office Program as a last resort
336
330
  keyName = getKeyName(tpDictionary, 'construction_set')
337
331
  try:
338
- tpCellConstructionSetIdentifier = Dictionary.ValueAtKey(tpDictionary, keyName)
332
+ tpCellConstructionSetIdentifier = Dictionary.ValueAtKey(tpDictionary, keyName, silent=True)
339
333
  if tpCellConstructionSetIdentifier:
340
334
  constr_set = constr_set_lib.construction_set_by_identifier(tpCellConstructionSetIdentifier)
341
335
  elif defaultConstructionSetIdentifier:
@@ -344,7 +338,7 @@ class Honeybee:
344
338
  constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set")
345
339
  else:
346
340
  tpCellStory = fl[spaceNumber]
347
- tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1))
341
+ tpCellName = str(tpCellStory)+"_SPACE_"+(str(spaceNumber+1))
348
342
  program = prog_type_lib.office_program
349
343
  constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set")
350
344
  spaceNames.append(tpCellName)
@@ -366,7 +360,7 @@ class Honeybee:
366
360
  tpFaceApertureDictionary = Topology.Dictionary(apertureTopology)
367
361
  if tpFaceApertureDictionary:
368
362
  apertureKeyName = getKeyName(tpFaceApertureDictionary, apertureTypeKey)
369
- tpFaceApertureType = Dictionary.ValueAtKey(tpFaceApertureDictionary,apertureKeyName)
363
+ tpFaceApertureType = Dictionary.ValueAtKey(tpFaceApertureDictionary,apertureKeyName, silent=True)
370
364
  hbFaceAperturePoints = []
371
365
  tpFaceApertureVertices = []
372
366
  tpFaceApertureVertices = Topology.Vertices(Face.ExternalBoundary(apertureTopology))
@@ -383,7 +377,7 @@ class Honeybee:
383
377
  else:
384
378
  tpFaceDictionary = Topology.Dictionary(tpCellFace)
385
379
  if (abs(tpCellFaceNormal[2]) < 1e-6) and tpFaceDictionary: #It is a mostly vertical wall and has a dictionary
386
- apertureRatio = Dictionary.ValueAtKey(tpFaceDictionary,'apertureRatio')
380
+ apertureRatio = Dictionary.ValueAtKey(tpFaceDictionary,'apertureRatio', silent=True)
387
381
  if apertureRatio:
388
382
  hbRoomFace.apertures_by_ratio(apertureRatio, tolerance=0.01)
389
383
  fType = honeybee.facetype.get_type_from_normal(Vector3D(tpCellFaceNormal[0],tpCellFaceNormal[1],tpCellFaceNormal[2]), roof_angle=30, floor_angle=150)
topologicpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.8.12'
1
+ __version__ = '0.8.14'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: topologicpy
3
- Version: 0.8.12
3
+ Version: 0.8.14
4
4
  Summary: An AI-Powered Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  License: AGPL v3 License
@@ -1,8 +1,8 @@
1
1
  topologicpy/ANN.py,sha256=m_WxD1lgQqDhUpaM20Lia6TmJACDYaAE96wigsi-99U,47932
2
2
  topologicpy/Aperture.py,sha256=p9pUzTQSBWoUaDiug1V1R1hnEIEwYSXFg2t7iRAmNRY,2723
3
3
  topologicpy/BVH.py,sha256=1q2lR5eDs7Wnwv7M-Kr7Cj3GG_iy7d1ddaZqWGHdX-w,12932
4
- topologicpy/Cell.py,sha256=Wwr2RsNEagfdt4Uz0GYosRTgNQj0pc5NOlzEWbL7cjQ,114343
5
- topologicpy/CellComplex.py,sha256=23bO0RYFIg6MOyt3PMFayaK523Alt8aHhc6UyJO02X0,51610
4
+ topologicpy/Cell.py,sha256=DYVXGfzioMBsQOkrP-BhJ5iHExKhTGAxOhMlmWeG4vw,118262
5
+ topologicpy/CellComplex.py,sha256=udDzbMub3d2QYn1XGMzt3F9Su2VXuAGvn0eoTtOIn3g,58207
6
6
  topologicpy/Cluster.py,sha256=o5jdMRpcGfSGGiXQdFg-e9XcnBF5AqTj3xb1nSpwJWE,58606
7
7
  topologicpy/Color.py,sha256=q9xsGmxFMz7sQKmygwSVS12GaTRB-OT0-_i6t3-cthE,20307
8
8
  topologicpy/Context.py,sha256=ppApYKngZZCQBFWaxIMi2z2dokY23c935IDCBosxDAE,3055
@@ -11,10 +11,10 @@ topologicpy/Dictionary.py,sha256=t0O7Du-iPq46FyKqZfcjHfsUK1E8GS_e67R2V5cpkbw,331
11
11
  topologicpy/Edge.py,sha256=yxkCVDYBflJNEYxnjMmlyvbkpg8TNy7y5bSH3yQ4jzs,71418
12
12
  topologicpy/EnergyModel.py,sha256=UoQ9Jm-hYsN383CbcLKw-y6BKitRHj0uyh84yQ-8ACg,53856
13
13
  topologicpy/Face.py,sha256=tn3PI-t9rXikgI1QMclw0PFwQ5vvyLi-wJKqZZZ9xmw,182755
14
- topologicpy/Graph.py,sha256=4zO0ntmRFz4k1WtsLmsbzjlor1tuQGLBIkpFk2Y_4hI,498848
14
+ topologicpy/Graph.py,sha256=FBmiMObzztPwZFJ2T846Ivz0Y1kpzMF0sF-PDUMPk4o,498946
15
15
  topologicpy/Grid.py,sha256=2s9cSlWldivn1i9EUz4OOokJyANveqmRe_vR93CAndI,18245
16
16
  topologicpy/Helper.py,sha256=4H5KPiv_eiEs489UOOyGLe9RaeoZIfmMh3mk_YCHmXg,29100
17
- topologicpy/Honeybee.py,sha256=Y_El6M8x3ixvvIe_VcRiwj_4C89ZZg5_WlT7adbCkpw,21849
17
+ topologicpy/Honeybee.py,sha256=uDVtDbloydNoaBFcSNukKL_2PLyD6XKkCp1VHz1jtaU,21751
18
18
  topologicpy/Matrix.py,sha256=mqcCk14kM9OOwJPwd9ce-8SFM0IxS3jYb2XpWhVjUAc,19503
19
19
  topologicpy/Neo4j.py,sha256=BKOF29fRgXmdpMGkrNzuYbyqgCJ6ElPPMYlfTxXiVbc,22392
20
20
  topologicpy/Plotly.py,sha256=RU_VioIRLGIYzwyKI9OQHOx9OxxGppdpagysgTbdxIE,115942
@@ -28,9 +28,9 @@ topologicpy/Vector.py,sha256=GkGt-aJ591IJ2IPffMAudvITLDPi2qZibZc4UAav6m8,42407
28
28
  topologicpy/Vertex.py,sha256=xr8KSgKnx-hgVp-eIvMPAKRv04R-wk-_4zc57xVyEqE,80793
29
29
  topologicpy/Wire.py,sha256=x7tOeR1o5qi5cXp_d9JrQrSXfYztCWiBC1OnVl6Yp7A,228463
30
30
  topologicpy/__init__.py,sha256=vlPCanUbxe5NifC4pHcnhSzkmmYcs_UrZrTlVMsxcFs,928
31
- topologicpy/version.py,sha256=VV54c1MEFjYlfKiA8ImJRkIYgUTfdMJOJs5zzf-BKgE,23
32
- topologicpy-0.8.12.dist-info/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
33
- topologicpy-0.8.12.dist-info/METADATA,sha256=owpJTXYjSfnJDFWPqrGOm1DoEVeWTghesziE4T-nt2I,10513
34
- topologicpy-0.8.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
- topologicpy-0.8.12.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
36
- topologicpy-0.8.12.dist-info/RECORD,,
31
+ topologicpy/version.py,sha256=Lw9k1hHakMjGPEzEp8wU2hEIGzA0_SHXmAYeLmbM_Kg,23
32
+ topologicpy-0.8.14.dist-info/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
33
+ topologicpy-0.8.14.dist-info/METADATA,sha256=HVOo7iDJt80dFu4DEf_0H0du_Zq8rCW2WFLikjwb7HU,10513
34
+ topologicpy-0.8.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
+ topologicpy-0.8.14.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
36
+ topologicpy-0.8.14.dist-info/RECORD,,