topologicpy 0.7.71__py3-none-any.whl → 0.7.73__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/BVH.py +9 -7
- topologicpy/CellComplex.py +92 -23
- topologicpy/Cluster.py +1 -1
- topologicpy/Color.py +67 -1
- topologicpy/Dictionary.py +108 -10
- topologicpy/Edge.py +8 -4
- topologicpy/Face.py +1 -1
- topologicpy/Graph.py +114 -6
- topologicpy/Helper.py +111 -0
- topologicpy/Plotly.py +505 -344
- topologicpy/Shell.py +24 -24
- topologicpy/Topology.py +234 -117
- topologicpy/Wire.py +50 -56
- topologicpy/version.py +1 -1
- {topologicpy-0.7.71.dist-info → topologicpy-0.7.73.dist-info}/METADATA +1 -1
- topologicpy-0.7.73.dist-info/RECORD +36 -0
- {topologicpy-0.7.71.dist-info → topologicpy-0.7.73.dist-info}/WHEEL +1 -1
- topologicpy-0.7.71.dist-info/RECORD +0 -36
- {topologicpy-0.7.71.dist-info → topologicpy-0.7.73.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.71.dist-info → topologicpy-0.7.73.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
@@ -1322,13 +1322,13 @@ class Topology():
|
|
1322
1322
|
x.append(Vertex.X(aVertex, mantissa=mantissa))
|
1323
1323
|
y.append(Vertex.Y(aVertex, mantissa=mantissa))
|
1324
1324
|
z.append(Vertex.Z(aVertex, mantissa=mantissa))
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1325
|
+
x_min = min(x)
|
1326
|
+
y_min = min(y)
|
1327
|
+
z_min = min(z)
|
1328
1328
|
maxX = max(x)
|
1329
1329
|
maxY = max(y)
|
1330
1330
|
maxZ = max(z)
|
1331
|
-
return [
|
1331
|
+
return [x_min, y_min, z_min, maxX, maxY, maxZ]
|
1332
1332
|
|
1333
1333
|
if not Topology.IsInstance(topology, "Topology"):
|
1334
1334
|
print("Topology.BoundingBox - Error: the input topology parameter is not a valid topology. Returning None.")
|
@@ -1344,33 +1344,33 @@ class Topology():
|
|
1344
1344
|
print("Topology.BoundingBox - Error: the input axes parameter is not a recognized string. Returning None.")
|
1345
1345
|
return None
|
1346
1346
|
if Topology.IsInstance(topology, "Vertex"):
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "
|
1351
|
-
box = Vertex.ByCoordinates(
|
1347
|
+
x_min = Vertex.X(topology)
|
1348
|
+
y_min = Vertex.Y(topology)
|
1349
|
+
z_min = Vertex.Z(topology)
|
1350
|
+
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "xmin", "ymin", "zmin", "xmax", "ymax", "zmax", "width", "length", "height"], [0, 0, 0, x_min, y_min, z_min, x_min, y_min, z_min, 0, 0, 0])
|
1351
|
+
box = Vertex.ByCoordinates(x_min, y_min, z_min)
|
1352
1352
|
box = Topology.SetDictionary(box, dictionary)
|
1353
1353
|
return box
|
1354
1354
|
vertices = Topology.SubTopologies(topology, subTopologyType="vertex")
|
1355
1355
|
if len(vertices) == 1: # A Cluster made of one vertex. Rare, but can happen!
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "
|
1360
|
-
box = Vertex.ByCoordinates(
|
1356
|
+
x_min = Vertex.X(vertices[0])
|
1357
|
+
y_min = Vertex.Y(vertices[0])
|
1358
|
+
z_min = Vertex.Z(vertices[0])
|
1359
|
+
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "xmin", "ymin", "zmin", "xmax", "ymax", "zmax", "width", "length", "height"], [0, 0, 0, x_min, y_min, z_min, x_min, y_min, z_min, 0, 0, 0])
|
1360
|
+
box = Vertex.ByCoordinates(x_min, y_min, z_min)
|
1361
1361
|
box = Topology.SetDictionary(box, dictionary)
|
1362
1362
|
return box
|
1363
1363
|
topology = Cluster.ByTopologies(vertices)
|
1364
1364
|
boundingBox = bb(topology)
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
w = abs(
|
1372
|
-
l = abs(
|
1373
|
-
h = abs(
|
1365
|
+
x_min = boundingBox[0]
|
1366
|
+
y_min = boundingBox[1]
|
1367
|
+
z_min = boundingBox[2]
|
1368
|
+
x_max = boundingBox[3]
|
1369
|
+
y_max = boundingBox[4]
|
1370
|
+
z_max = boundingBox[5]
|
1371
|
+
w = abs(x_max - x_min)
|
1372
|
+
l = abs(y_max - y_min)
|
1373
|
+
h = abs(z_max - z_min)
|
1374
1374
|
best_area = 2*l*w + 2*l*h + 2*w*h
|
1375
1375
|
orig_area = best_area
|
1376
1376
|
best_x = 0
|
@@ -1421,17 +1421,17 @@ class Topology():
|
|
1421
1421
|
t = Topology.Rotate(topology, origin=origin, axis=[0, 0, 1], angle=z)
|
1422
1422
|
t = Topology.Rotate(t, origin=origin, axis=[0, 1, 0], angle=y)
|
1423
1423
|
t = Topology.Rotate(t, origin=origin, axis=[1, 0, 0], angle=x)
|
1424
|
-
|
1425
|
-
w = abs(
|
1426
|
-
l = abs(
|
1427
|
-
h = abs(
|
1424
|
+
x_min, y_min, z_min, x_max, y_max, z_max = bb(t)
|
1425
|
+
w = abs(x_max - x_min)
|
1426
|
+
l = abs(y_max - y_min)
|
1427
|
+
h = abs(z_max - z_min)
|
1428
1428
|
area = 2*l*w + 2*l*h + 2*w*h
|
1429
1429
|
if area < orig_area*factor:
|
1430
1430
|
best_area = area
|
1431
1431
|
best_x = x
|
1432
1432
|
best_y = y
|
1433
1433
|
best_z = z
|
1434
|
-
best_bb = [
|
1434
|
+
best_bb = [x_min, y_min, z_min, x_max, y_max, z_max]
|
1435
1435
|
flag = True
|
1436
1436
|
break
|
1437
1437
|
if area < best_area:
|
@@ -1439,27 +1439,27 @@ class Topology():
|
|
1439
1439
|
best_x = x
|
1440
1440
|
best_y = y
|
1441
1441
|
best_z = z
|
1442
|
-
best_bb = [
|
1442
|
+
best_bb = [x_min, y_min, z_min, x_max, y_max, z_max]
|
1443
1443
|
|
1444
1444
|
else:
|
1445
1445
|
best_bb = boundingBox
|
1446
1446
|
|
1447
|
-
|
1448
|
-
vb1 = Vertex.ByCoordinates(
|
1449
|
-
vb2 = Vertex.ByCoordinates(
|
1450
|
-
vb3 = Vertex.ByCoordinates(
|
1451
|
-
vb4 = Vertex.ByCoordinates(
|
1447
|
+
x_min, y_min, z_min, x_max, y_max, z_max = best_bb
|
1448
|
+
vb1 = Vertex.ByCoordinates(x_min, y_min, z_min)
|
1449
|
+
vb2 = Vertex.ByCoordinates(x_max, y_min, z_min)
|
1450
|
+
vb3 = Vertex.ByCoordinates(x_max, y_max, z_min)
|
1451
|
+
vb4 = Vertex.ByCoordinates(x_min, y_max, z_min)
|
1452
1452
|
|
1453
1453
|
baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], close=True)
|
1454
1454
|
baseFace = Face.ByWire(baseWire, tolerance=tolerance)
|
1455
|
-
if abs(
|
1455
|
+
if abs(z_max - z_min) < tolerance:
|
1456
1456
|
box = baseFace
|
1457
1457
|
else:
|
1458
|
-
box = Cell.ByThickenedFace(baseFace, planarize=False, thickness=abs(
|
1458
|
+
box = Cell.ByThickenedFace(baseFace, planarize=False, thickness=abs(z_max - z_min), bothSides=False)
|
1459
1459
|
box = Topology.Rotate(box, origin=origin, axis=[1, 0, 0], angle=-best_x)
|
1460
1460
|
box = Topology.Rotate(box, origin=origin, axis=[0, 1, 0], angle=-best_y)
|
1461
1461
|
box = Topology.Rotate(box, origin=origin, axis=[0, 0, 1], angle=-best_z)
|
1462
|
-
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "
|
1462
|
+
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "xmin", "ymin", "zmin", "xmax", "ymax", "zmax", "width", "length", "height"], [best_x, best_y, best_z, x_min, y_min, z_min, x_max, y_max, z_max, (x_max - x_min), (y_max - y_min), (z_max - z_min)])
|
1463
1463
|
box = Topology.SetDictionary(box, dictionary)
|
1464
1464
|
return box
|
1465
1465
|
|
@@ -1496,7 +1496,7 @@ class Topology():
|
|
1496
1496
|
|
1497
1497
|
|
1498
1498
|
@staticmethod
|
1499
|
-
def ByGeometry(vertices=[], edges=[], faces=[], topologyType = None, tolerance=0.0001):
|
1499
|
+
def ByGeometry(vertices=[], edges=[], faces=[], topologyType: str = None, tolerance: float = 0.0001, silent: bool = False):
|
1500
1500
|
"""
|
1501
1501
|
Create a topology by the input lists of vertices, edges, and faces.
|
1502
1502
|
|
@@ -1512,6 +1512,8 @@ class Topology():
|
|
1512
1512
|
The desired topology type. The options are: "Vertex", "Edge", "Wire", "Face", "Shell", "Cell", "CellComplex". If set to None, a "Cluster" will be returned. The default is None.
|
1513
1513
|
tolerance : float , optional
|
1514
1514
|
The desired tolerance. The default is 0.0001.
|
1515
|
+
silent : bool , optional
|
1516
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1515
1517
|
|
1516
1518
|
Returns
|
1517
1519
|
-------
|
@@ -1542,7 +1544,7 @@ class Topology():
|
|
1542
1544
|
if Topology.IsInstance(cc, "CellComplex"):
|
1543
1545
|
output = CellComplex.ExternalBoundary(cc)
|
1544
1546
|
elif topologyType == "cellcomplex":
|
1545
|
-
output = CellComplex.ByFaces(faces, tolerance=tolerance)
|
1547
|
+
output = CellComplex.ByFaces(faces, tolerance=tolerance, silent=silent)
|
1546
1548
|
if Topology.IsInstance(output, "CellComplex"):
|
1547
1549
|
cells = Topology.Cells(output)
|
1548
1550
|
if len(cells) == 1:
|
@@ -2146,8 +2148,9 @@ class Topology():
|
|
2146
2148
|
# iteration
|
2147
2149
|
for layer in layers:
|
2148
2150
|
if layer_name == layer.dxf.name:
|
2149
|
-
|
2150
|
-
|
2151
|
+
if not layer.rgb == None:
|
2152
|
+
r,g,b = layer.rgb
|
2153
|
+
return [r,g,b]
|
2151
2154
|
return
|
2152
2155
|
|
2153
2156
|
def convert_entity(entity, file, sides=36):
|
@@ -2504,7 +2507,7 @@ class Topology():
|
|
2504
2507
|
|
2505
2508
|
return color, default_transparency, material_list
|
2506
2509
|
|
2507
|
-
def convert_to_topology(entity, settings):
|
2510
|
+
def convert_to_topology(entity, settings, transferDictionaries=False):
|
2508
2511
|
if hasattr(entity, "Representation") and entity.Representation:
|
2509
2512
|
for rep in entity.Representation.Representations:
|
2510
2513
|
if rep.is_a("IfcShapeRepresentation"):
|
@@ -2520,29 +2523,30 @@ class Topology():
|
|
2520
2523
|
# Convert geometry to Topologic format
|
2521
2524
|
#shape_topology = ifc_to_topologic_geometry(verts, edges, faces)
|
2522
2525
|
#shape_topology = Topology.SelfMerge(Topology.ByGeometry(verts, edges, faces))
|
2523
|
-
shape_topology = Topology.ByGeometry(verts, edges, faces,
|
2526
|
+
shape_topology = Topology.ByGeometry(verts, edges, faces, silent=True)
|
2524
2527
|
if removeCoplanarFaces == True:
|
2525
2528
|
shape_topology = Topology.RemoveCoplanarFaces(shape_topology, epsilon=0.0001)
|
2526
2529
|
|
2527
2530
|
# Store relevant information
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2531
|
+
if transferDictionaries == True:
|
2532
|
+
color, transparency, material_list = get_color_transparency_material(entity)
|
2533
|
+
entity_dict = {
|
2534
|
+
"TOPOLOGIC_id": str(Topology.UUID(shape_topology)),
|
2535
|
+
"TOPOLOGIC_name": getattr(entity, 'Name', "Untitled"),
|
2536
|
+
"TOPOLOGIC_type": Topology.TypeAsString(shape_topology),
|
2537
|
+
"TOPOLOGIC_color": color,
|
2538
|
+
"TOPOLOGIC_opacity": 1.0 - transparency,
|
2539
|
+
"IFC_global_id": getattr(entity, 'GlobalId', 0),
|
2540
|
+
"IFC_name": getattr(entity, 'Name', "Untitled"),
|
2541
|
+
"IFC_type": entity.is_a(),
|
2542
|
+
"IFC_material_list": material_list,
|
2543
|
+
}
|
2544
|
+
topology_dict = Dictionary.ByPythonDictionary(entity_dict)
|
2545
|
+
# Get PSETs dictionary
|
2546
|
+
pset_python_dict = get_psets(entity)
|
2547
|
+
pset_dict = Dictionary.ByPythonDictionary(pset_python_dict)
|
2548
|
+
topology_dict = Dictionary.ByMergedDictionaries([topology_dict, pset_dict])
|
2549
|
+
shape_topology = Topology.SetDictionary(shape_topology, topology_dict)
|
2546
2550
|
return shape_topology
|
2547
2551
|
return None
|
2548
2552
|
|
@@ -2559,7 +2563,7 @@ class Topology():
|
|
2559
2563
|
entities.append(product)
|
2560
2564
|
topologies = []
|
2561
2565
|
for entity in entities:
|
2562
|
-
topologies.append(convert_to_topology(entity, settings))
|
2566
|
+
topologies.append(convert_to_topology(entity, settings, transferDictionaries=transferDictionaries))
|
2563
2567
|
return topologies
|
2564
2568
|
|
2565
2569
|
@staticmethod
|
@@ -3836,7 +3840,117 @@ class Topology():
|
|
3836
3840
|
if Topology.IsInstance(topology, "Aperture"):
|
3837
3841
|
return Aperture.Topology(topology).Centroid()
|
3838
3842
|
return topology.Centroid()
|
3839
|
-
|
3843
|
+
|
3844
|
+
@staticmethod
|
3845
|
+
def ClusterByKeys(topologies, *keys, silent=False):
|
3846
|
+
"""
|
3847
|
+
Clusters the input list of topologies based on the input key or keys.
|
3848
|
+
|
3849
|
+
Parameters
|
3850
|
+
----------
|
3851
|
+
topologies : list
|
3852
|
+
The input list of topologies.
|
3853
|
+
keys : str or list or comma-separated str input parameters
|
3854
|
+
The key or keys in the topology's dictionary to use for clustering.
|
3855
|
+
silent : bool , optional
|
3856
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
3857
|
+
|
3858
|
+
|
3859
|
+
Returns
|
3860
|
+
-------
|
3861
|
+
list
|
3862
|
+
A nested list of topologies where each element is a list of topologies with the same key values.
|
3863
|
+
"""
|
3864
|
+
|
3865
|
+
from topologicpy.Dictionary import Dictionary
|
3866
|
+
from topologicpy.Helper import Helper
|
3867
|
+
import inspect
|
3868
|
+
print("input topologies:", topologies)
|
3869
|
+
|
3870
|
+
topologies_list = []
|
3871
|
+
if Topology.IsInstance(topologies, "Topology"):
|
3872
|
+
if not silent:
|
3873
|
+
print("Topology.ClusterByKeys - Warning: The input topologies parameter is a single topology. Returning one cluster.")
|
3874
|
+
return [[topologies]]
|
3875
|
+
if isinstance(topologies, list):
|
3876
|
+
print("topologies_list 1:", topologies_list)
|
3877
|
+
topologies_list = Helper.Flatten(topologies)
|
3878
|
+
print("topologies_list 2:", topologies_list)
|
3879
|
+
topologies_list = [x for x in topologies_list if Topology.IsInstance(x, "Topology")]
|
3880
|
+
print("topologies_list 3:", topologies_list)
|
3881
|
+
if len(topologies_list) == 0:
|
3882
|
+
if not silent:
|
3883
|
+
print("Topology.ClusterByKeys - Error: The input topologies parameter does not contain any valid topologies. Returning None.")
|
3884
|
+
curframe = inspect.currentframe()
|
3885
|
+
calframe = inspect.getouterframes(curframe, 2)
|
3886
|
+
print('caller name:', calframe[1][3])
|
3887
|
+
return None
|
3888
|
+
else:
|
3889
|
+
if not silent:
|
3890
|
+
print("Topology.ClusterByKeys - Error: The input topologies parameter is not a valid list. Returning None.")
|
3891
|
+
curframe = inspect.currentframe()
|
3892
|
+
calframe = inspect.getouterframes(curframe, 2)
|
3893
|
+
print('caller name:', calframe[1][3])
|
3894
|
+
return None
|
3895
|
+
|
3896
|
+
keys_list = list(keys)
|
3897
|
+
keys_list = Helper.Flatten(keys_list)
|
3898
|
+
|
3899
|
+
if len(keys_list) == 0:
|
3900
|
+
if not silent:
|
3901
|
+
print("Topology.ClusterByKeys - Error: The input keys parameter is an empty list. Returning None.")
|
3902
|
+
curframe = inspect.currentframe()
|
3903
|
+
calframe = inspect.getouterframes(curframe, 2)
|
3904
|
+
print('caller name:', calframe[1][3])
|
3905
|
+
return None
|
3906
|
+
keys_list = [x for x in keys_list if isinstance(x, str)]
|
3907
|
+
|
3908
|
+
if len(keys_list) == 0:
|
3909
|
+
if not silent:
|
3910
|
+
print("Topology.ClusterByKeys - Error: The input keys parameter does not contain any valid strings. Returning None.")
|
3911
|
+
curframe = inspect.currentframe()
|
3912
|
+
calframe = inspect.getouterframes(curframe, 2)
|
3913
|
+
print('caller name:', calframe[1][3])
|
3914
|
+
return None
|
3915
|
+
|
3916
|
+
clusters = []
|
3917
|
+
values = []
|
3918
|
+
for topology in topologies_list:
|
3919
|
+
d = Topology.Dictionary(topology)
|
3920
|
+
|
3921
|
+
d_keys = Dictionary.Keys(d)
|
3922
|
+
if len(d_keys) > 0:
|
3923
|
+
values_list = []
|
3924
|
+
for key in keys_list:
|
3925
|
+
v = Dictionary.ValueAtKey(d, key)
|
3926
|
+
if not v == None:
|
3927
|
+
values_list.append(v)
|
3928
|
+
values_list = str(values_list)
|
3929
|
+
d = Dictionary.SetValueAtKey(d, "_clustering_key_", values_list)
|
3930
|
+
topology = Topology.SetDictionary(topology, d)
|
3931
|
+
values.append(values_list)
|
3932
|
+
|
3933
|
+
remaining_topologies = topologies_list
|
3934
|
+
for value in values:
|
3935
|
+
if len(remaining_topologies) == 0:
|
3936
|
+
break
|
3937
|
+
dic = Topology.Filter(remaining_topologies, topologyType="any", searchType="equal to", key="_clustering_key_", value=value)
|
3938
|
+
filtered_topologies = dic['filtered']
|
3939
|
+
final_topologies = []
|
3940
|
+
if len(filtered_topologies) > 0:
|
3941
|
+
for filtered_topology in filtered_topologies:
|
3942
|
+
d = Topology.Dictionary(filtered_topology)
|
3943
|
+
d = Dictionary.RemoveKey(d, "_clustering_key_")
|
3944
|
+
keys = Dictionary.Keys(d)
|
3945
|
+
if len(keys) > 0:
|
3946
|
+
filtered_topology = Topology.SetDictionary(filtered_topology, d)
|
3947
|
+
final_topologies.append(filtered_topology)
|
3948
|
+
clusters.append(final_topologies)
|
3949
|
+
remaining_topologies = dic['other']
|
3950
|
+
if len(remaining_topologies) > 0:
|
3951
|
+
clusters.append(remaining_topologies)
|
3952
|
+
return clusters
|
3953
|
+
|
3840
3954
|
@staticmethod
|
3841
3955
|
def ClusterFaces(topology, angTolerance=2, tolerance=0.0001):
|
3842
3956
|
"""
|
@@ -4159,7 +4273,7 @@ class Topology():
|
|
4159
4273
|
print("Topology.Copy - Error: the input topology parameter is not a valid topology. Returning None.")
|
4160
4274
|
return None
|
4161
4275
|
if deep:
|
4162
|
-
return Topology.ByJSONString(Topology.JSONString([topology])
|
4276
|
+
return Topology.ByJSONString(Topology.JSONString([topology]))[0]
|
4163
4277
|
d = Topology.Dictionary(topology)
|
4164
4278
|
return_topology = Topology.ByBREPString(Topology.BREPString(topology))
|
4165
4279
|
keys = Dictionary.Keys(d)
|
@@ -4183,7 +4297,7 @@ class Topology():
|
|
4183
4297
|
The dictionary of the input topology.
|
4184
4298
|
|
4185
4299
|
"""
|
4186
|
-
if not Topology.IsInstance(topology, "Topology"):
|
4300
|
+
if not Topology.IsInstance(topology, "Topology") and not Topology.IsInstance(topology, "Graph"):
|
4187
4301
|
print("Topology.Dictionary - Error: the input topology parameter is not a valid topology. Returning None.")
|
4188
4302
|
return None
|
4189
4303
|
return topology.GetDictionary()
|
@@ -5717,7 +5831,7 @@ class Topology():
|
|
5717
5831
|
if (Topology.Type(topology) == Topology.TypeID("Edge")): #Input is an Edge, just add it and process it
|
5718
5832
|
topEdges.append(topology)
|
5719
5833
|
elif (Topology.Type(topology) > Topology.TypeID("Vertex")):
|
5720
|
-
|
5834
|
+
topEdges = Topology.Edges(topology)
|
5721
5835
|
for anEdge in topEdges:
|
5722
5836
|
e = []
|
5723
5837
|
sv = anEdge.StartVertex()
|
@@ -5734,8 +5848,7 @@ class Topology():
|
|
5734
5848
|
evIndex = len(vertices)-1
|
5735
5849
|
e.append(svIndex)
|
5736
5850
|
e.append(evIndex)
|
5737
|
-
|
5738
|
-
edges.append(e)
|
5851
|
+
edges.append(e)
|
5739
5852
|
topFaces = []
|
5740
5853
|
if (Topology.Type(topology) == Topology.TypeID("Face")): # Input is a Face, just add it and process it
|
5741
5854
|
topFaces.append(topology)
|
@@ -7346,23 +7459,22 @@ class Topology():
|
|
7346
7459
|
|
7347
7460
|
@staticmethod
|
7348
7461
|
def Show(*topologies,
|
7349
|
-
colorKey = "color",
|
7350
7462
|
opacityKey = "opacity",
|
7351
|
-
showVertices=True, vertexSize=1.1, vertexColor="black",
|
7463
|
+
showVertices=True, vertexSize=1.1, vertexSizeKey = None, vertexColor="black", vertexColorKey = None,
|
7352
7464
|
vertexLabelKey=None, showVertexLabel= False,
|
7353
7465
|
vertexGroupKey=None, vertexGroups=[],
|
7354
7466
|
vertexMinGroup=None, vertexMaxGroup=None,
|
7355
7467
|
showVertexLegend=False, vertexLegendLabel="Topology Vertices", vertexLegendRank=1,
|
7356
7468
|
vertexLegendGroup=1,
|
7357
7469
|
|
7358
|
-
showEdges=True, edgeWidth=1, edgeColor="black",
|
7470
|
+
showEdges=True, edgeWidth=1, edgeWidthKey = None, edgeColor="black", edgeColorKey = None,
|
7359
7471
|
edgeLabelKey=None, showEdgeLabel = False,
|
7360
7472
|
edgeGroupKey=None, edgeGroups=[],
|
7361
7473
|
edgeMinGroup=None, edgeMaxGroup=None,
|
7362
7474
|
showEdgeLegend=False, edgeLegendLabel="Topology Edges", edgeLegendRank=2,
|
7363
7475
|
edgeLegendGroup=2,
|
7364
7476
|
|
7365
|
-
showFaces=True, faceOpacity=0.5, faceColor="#FAFAFA",
|
7477
|
+
showFaces=True, faceOpacity=0.5, faceOpacityKey=None, faceColor="#FAFAFA", faceColorKey = None,
|
7366
7478
|
faceLabelKey=None, faceGroupKey=None, faceGroups=[],
|
7367
7479
|
faceMinGroup=None, faceMaxGroup=None,
|
7368
7480
|
showFaceLegend=False, faceLegendLabel="Topology Faces", faceLegendRank=3,
|
@@ -7376,7 +7488,10 @@ class Topology():
|
|
7376
7488
|
center=[0, 0, 0], up=[0, 0, 1], projection="perspective", renderer="notebook", showScale=False,
|
7377
7489
|
|
7378
7490
|
cbValues=[], cbTicks=5, cbX=-0.15, cbWidth=15, cbOutlineWidth=0, cbTitle="",
|
7379
|
-
cbSubTitle="", cbUnits="", colorScale="Viridis",
|
7491
|
+
cbSubTitle="", cbUnits="", colorScale="Viridis",
|
7492
|
+
|
7493
|
+
sagitta = 0, absolute = False, sides = 8, angle = 0,
|
7494
|
+
mantissa=6, tolerance=0.0001, silent=False):
|
7380
7495
|
"""
|
7381
7496
|
Shows the input topology on screen.
|
7382
7497
|
|
@@ -7384,14 +7499,14 @@ class Topology():
|
|
7384
7499
|
----------
|
7385
7500
|
topologies : topologic_core.Topology or list
|
7386
7501
|
The input topology. This must contain faces and or edges. If the input is a list, a cluster is first created
|
7387
|
-
colorKey : str , optional
|
7388
|
-
The key under which to find the color of the topology. The default is "color".
|
7389
7502
|
opacityKey : str , optional
|
7390
7503
|
The key under which to find the opacity of the topology. The default is "opacity".
|
7391
7504
|
showVertices : bool , optional
|
7392
7505
|
If set to True the vertices will be drawn. Otherwise, they will not be drawn. The default is True.
|
7393
7506
|
vertexSize : float , optional
|
7394
7507
|
The desired size of the vertices. The default is 1.1.
|
7508
|
+
vertexSizeKey : str , optional
|
7509
|
+
The key under which to find the size of the vertex. The default is None.
|
7395
7510
|
vertexColor : str , optional
|
7396
7511
|
The desired color of the output vertices. This can be any plotly color string and may be specified as:
|
7397
7512
|
- A hex string (e.g. '#ff0000')
|
@@ -7400,6 +7515,8 @@ class Topology():
|
|
7400
7515
|
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
|
7401
7516
|
- A named CSS color.
|
7402
7517
|
The default is "black".
|
7518
|
+
vertexColorKey : str , optional
|
7519
|
+
The key under which to find the color of the vertex. The default is None.
|
7403
7520
|
vertexLabelKey : str , optional
|
7404
7521
|
The dictionary key to use to display the vertex label. The default is None.
|
7405
7522
|
showVertexLabels : bool , optional
|
@@ -7433,6 +7550,10 @@ class Topology():
|
|
7433
7550
|
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
|
7434
7551
|
- A named CSS color.
|
7435
7552
|
The default is "black".
|
7553
|
+
edgeColorKey : str , optional
|
7554
|
+
The key under which to find the color of the edge. The default is None.
|
7555
|
+
edgeWidthKey : str , optional
|
7556
|
+
The key under which to find the width of the edge. The default is None.
|
7436
7557
|
edgeLabelKey : str , optional
|
7437
7558
|
The dictionary key to use to display the edge label. The default is None.
|
7438
7559
|
showEdgeLabels : bool , optional
|
@@ -7458,6 +7579,8 @@ class Topology():
|
|
7458
7579
|
If set to True the faces will be drawn. Otherwise, they will not be drawn. The default is True.
|
7459
7580
|
faceOpacity : float , optional
|
7460
7581
|
The desired opacity of the output faces (0=transparent, 1=opaque). The default is 0.5.
|
7582
|
+
faceOpacityKey : str , optional
|
7583
|
+
The key under which to find the opacity of the face. The default is None.
|
7461
7584
|
faceColor : str , optional
|
7462
7585
|
The desired color of the output faces. This can be any plotly color string and may be specified as:
|
7463
7586
|
- A hex string (e.g. '#ff0000')
|
@@ -7466,6 +7589,8 @@ class Topology():
|
|
7466
7589
|
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
|
7467
7590
|
- A named CSS color.
|
7468
7591
|
The default is "#FAFAFA".
|
7592
|
+
faceColorKey : str , optional
|
7593
|
+
The key under which to find the color of the face. The default is None.
|
7469
7594
|
faceLabelKey : str , optional
|
7470
7595
|
The dictionary key to use to display the face label. The default is None.
|
7471
7596
|
faceGroupKey : str , optional
|
@@ -7548,6 +7673,8 @@ class Topology():
|
|
7548
7673
|
The desired length of the mantissa for the values listed on the colorbar. The default is 6.
|
7549
7674
|
tolerance : float , optional
|
7550
7675
|
The desired tolerance. The default is 0.0001.
|
7676
|
+
silent : bool , optional
|
7677
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
7551
7678
|
|
7552
7679
|
Returns
|
7553
7680
|
-------
|
@@ -7564,46 +7691,36 @@ class Topology():
|
|
7564
7691
|
if isinstance(topologies, tuple):
|
7565
7692
|
topologies = Helper.Flatten(list(topologies))
|
7566
7693
|
if isinstance(topologies, list):
|
7567
|
-
new_topologies = [t for t in topologies if Topology.IsInstance(t, "Topology")]
|
7568
|
-
graphs = [Graph.Topology(g) for g in topologies if Topology.IsInstance(g, "Graph")]
|
7569
|
-
new_topologies += graphs
|
7694
|
+
new_topologies = [t for t in topologies if Topology.IsInstance(t, "Topology") or Topology.IsInstance(t, "Graph")]
|
7570
7695
|
if len(new_topologies) == 0:
|
7571
|
-
|
7572
|
-
|
7573
|
-
|
7574
|
-
# topology = new_topologies[0]
|
7575
|
-
# else:
|
7576
|
-
# topology = Cluster.ByTopologies(new_topologies)
|
7577
|
-
# if not Topology.IsInstance(topology, "Topology"):
|
7578
|
-
# print("Topology.Show - Error: the input topology parameter is not a valid topology. Returning None.")
|
7579
|
-
# return None
|
7696
|
+
if not silent:
|
7697
|
+
print("Topology.Show - Error: the input topologies parameter does not contain any valid topology. Returning None.")
|
7698
|
+
return None
|
7580
7699
|
data = []
|
7581
7700
|
for topology in new_topologies:
|
7582
|
-
|
7583
|
-
|
7584
|
-
|
7585
|
-
|
7586
|
-
|
7587
|
-
|
7588
|
-
|
7589
|
-
|
7590
|
-
|
7591
|
-
|
7592
|
-
|
7593
|
-
|
7594
|
-
|
7595
|
-
|
7596
|
-
|
7597
|
-
|
7598
|
-
|
7599
|
-
|
7600
|
-
|
7601
|
-
|
7602
|
-
|
7603
|
-
|
7604
|
-
|
7605
|
-
faceLegendGroup=faceLegendGroup,
|
7606
|
-
intensityKey=intensityKey, intensities=intensities, colorScale=colorScale, mantissa=mantissa, tolerance=tolerance)
|
7701
|
+
if Topology.IsInstance(topology, "Graph"):
|
7702
|
+
data += Plotly.DataByGraph(topology, sagitta=sagitta, absolute=absolute, sides=sides, angle=angle, vertexColor=vertexColor, vertexColorKey=vertexColorKey, vertexSize=vertexSize, vertexSizeKey=vertexSizeKey, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, vertexGroups=vertexGroups, showVertices=showVertices, showVertexLabel=showVertexLabel, showVertexLegend=showVertexLegend, edgeColor=edgeColor, edgeColorKey=edgeColorKey, edgeWidth=edgeWidth, edgeWidthKey=edgeWidthKey, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups, showEdges=showEdges, showEdgeLabel=showEdgeLabel, showEdgeLegend=showEdgeLegend, colorScale=colorScale, silent=silent)
|
7703
|
+
else:
|
7704
|
+
d = Topology.Dictionary(topology)
|
7705
|
+
if not d == None:
|
7706
|
+
faceOpacity = Dictionary.ValueAtKey(d, opacityKey) or faceOpacity
|
7707
|
+
data += Plotly.DataByTopology(topology=topology,
|
7708
|
+
showVertices=showVertices, vertexSize=vertexSize, vertexSizeKey=vertexSizeKey, vertexColor=vertexColor, vertexColorKey=vertexColorKey,
|
7709
|
+
vertexLabelKey=vertexLabelKey, showVertexLabel=showVertexLabel, vertexGroupKey=vertexGroupKey, vertexGroups=vertexGroups,
|
7710
|
+
vertexMinGroup=vertexMinGroup, vertexMaxGroup=vertexMaxGroup,
|
7711
|
+
showVertexLegend=showVertexLegend, vertexLegendLabel=vertexLegendLabel, vertexLegendRank=vertexLegendRank,
|
7712
|
+
vertexLegendGroup=vertexLegendGroup,
|
7713
|
+
showEdges=showEdges, edgeWidth=edgeWidth, edgeWidthKey=edgeWidthKey, edgeColor=edgeColor, edgeColorKey=edgeColorKey,
|
7714
|
+
edgeLabelKey=edgeLabelKey, showEdgeLabel=showEdgeLabel, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups,
|
7715
|
+
edgeMinGroup=edgeMinGroup, edgeMaxGroup=edgeMaxGroup,
|
7716
|
+
showEdgeLegend=showEdgeLegend, edgeLegendLabel=edgeLegendLabel, edgeLegendRank=edgeLegendRank,
|
7717
|
+
edgeLegendGroup=edgeLegendGroup,
|
7718
|
+
showFaces=showFaces, faceOpacity=faceOpacity, faceColor=faceColor, faceColorKey=faceColorKey,
|
7719
|
+
faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, faceGroups=faceGroups,
|
7720
|
+
faceMinGroup=faceMinGroup, faceMaxGroup=faceMaxGroup,
|
7721
|
+
showFaceLegend=showFaceLegend, faceLegendLabel=faceLegendLabel, faceLegendRank=faceLegendRank,
|
7722
|
+
faceLegendGroup=faceLegendGroup,
|
7723
|
+
intensityKey=intensityKey, intensities=intensities, colorScale=colorScale, mantissa=mantissa, tolerance=tolerance)
|
7607
7724
|
figure = Plotly.FigureByData(data=data, width=width, height=height,
|
7608
7725
|
xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize,
|
7609
7726
|
backgroundColor=backgroundColor,
|
@@ -7874,11 +7991,11 @@ class Topology():
|
|
7874
7991
|
origin = Topology.Centroid(topology)
|
7875
7992
|
vertices = Topology.Vertices(topology)
|
7876
7993
|
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
7877
|
-
|
7994
|
+
z_min = min(zList)
|
7878
7995
|
maxZ = max(zList)
|
7879
7996
|
new_vertices = []
|
7880
7997
|
for v in vertices:
|
7881
|
-
ht = (Vertex.Z(v)-
|
7998
|
+
ht = (Vertex.Z(v)-z_min)/(maxZ - z_min)
|
7882
7999
|
rt = ratioRange[0] + ht*(ratioRange[1] - ratioRange[0])
|
7883
8000
|
new_origin = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa))
|
7884
8001
|
new_dist = Vertex.Distance(new_origin, v, mantissa=mantissa)*rt
|
@@ -7928,12 +8045,12 @@ class Topology():
|
|
7928
8045
|
|
7929
8046
|
vertices = Topology.Vertices(topology)
|
7930
8047
|
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
7931
|
-
|
8048
|
+
z_min = min(zList)
|
7932
8049
|
maxZ = max(zList)
|
7933
|
-
h = maxZ -
|
8050
|
+
h = maxZ - z_min
|
7934
8051
|
new_vertices = []
|
7935
8052
|
for v in vertices:
|
7936
|
-
ht = (Vertex.Z(v)-
|
8053
|
+
ht = (Vertex.Z(v)-z_min)/(maxZ - z_min)
|
7937
8054
|
new_rot = angleRange[0] + ht*(angleRange[1] - angleRange[0])
|
7938
8055
|
orig = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa))
|
7939
8056
|
new_vertices.append(Topology.Rotate(v, origin=orig, axis=[0, 0, 1], angle=new_rot))
|