topologicpy 0.8.59__py3-none-any.whl → 0.8.71__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 +478 -211
- topologicpy/Cell.py +5 -2
- topologicpy/Dictionary.py +17 -6
- topologicpy/Face.py +23 -50
- topologicpy/Graph.py +660 -42
- topologicpy/Kuzu.py +1 -1
- topologicpy/Shell.py +50 -14
- topologicpy/Topology.py +138 -108
- topologicpy/Vertex.py +333 -99
- topologicpy/version.py +1 -1
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/METADATA +1 -1
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/RECORD +15 -15
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/WHEEL +0 -0
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/top_level.txt +0 -0
topologicpy/Kuzu.py
CHANGED
topologicpy/Shell.py
CHANGED
@@ -1013,12 +1013,15 @@ class Shell():
|
|
1013
1013
|
@staticmethod
|
1014
1014
|
def InternalBoundaries(shell, tolerance=0.0001):
|
1015
1015
|
"""
|
1016
|
-
Returns the internal boundaries
|
1016
|
+
Returns the internal boundaries of the input shell.
|
1017
1017
|
|
1018
1018
|
Parameters
|
1019
1019
|
----------
|
1020
1020
|
shell : topologic_core.Shell
|
1021
1021
|
The input shell.
|
1022
|
+
groupKey : str , optional
|
1023
|
+
The edge dictionary key under which to save the edge group number. The default is "group".
|
1024
|
+
Edges that separate the same faces belong to the same group.
|
1022
1025
|
tolerance : float , optional
|
1023
1026
|
The desired tolerance. Default is 0.0001.
|
1024
1027
|
|
@@ -1028,19 +1031,54 @@ class Shell():
|
|
1028
1031
|
The list of internal boundaries
|
1029
1032
|
|
1030
1033
|
"""
|
1034
|
+
from topologicpy.Wire import Wire
|
1031
1035
|
from topologicpy.Cluster import Cluster
|
1032
1036
|
from topologicpy.Topology import Topology
|
1033
|
-
|
1034
|
-
|
1037
|
+
from topologicpy.Dictionary import Dictionary
|
1038
|
+
faces = Shell.Faces(shell)
|
1039
|
+
for i, f in enumerate(faces):
|
1040
|
+
d = Topology.Dictionary(f)
|
1041
|
+
d = Dictionary.SetValueAtKey(d, "__id__", i)
|
1042
|
+
f = Topology.SetDictionary(f, d)
|
1043
|
+
|
1044
|
+
edges = Topology.Edges(shell)
|
1035
1045
|
ibEdges = []
|
1046
|
+
groups = []
|
1036
1047
|
for anEdge in edges:
|
1037
|
-
faces =
|
1038
|
-
_ = anEdge.Faces(shell, faces)
|
1048
|
+
faces = Topology.SuperTopologies(anEdge, shell, topologyType="face")
|
1039
1049
|
if len(faces) > 1:
|
1050
|
+
d = Topology.Dictionary(anEdge)
|
1051
|
+
ids = []
|
1052
|
+
for aFace in faces:
|
1053
|
+
face_d = Topology.Dictionary(aFace)
|
1054
|
+
ids.append(Dictionary.ValueAtKey(face_d, "__id__", -1))
|
1055
|
+
ids.sort()
|
1056
|
+
ids = str(ids)
|
1057
|
+
groups.append(ids)
|
1058
|
+
d = Dictionary.SetValueAtKey(d, "__group__", ids)
|
1059
|
+
anEdge = Topology.SetDictionary(anEdge, d)
|
1040
1060
|
ibEdges.append(anEdge)
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1061
|
+
for aFace in faces:
|
1062
|
+
face_d = Topology.Dictionary(aFace)
|
1063
|
+
face_d = Dictionary.RemoveKey(face_d, "__id__")
|
1064
|
+
|
1065
|
+
groups = list(set(groups))
|
1066
|
+
for edge in ibEdges:
|
1067
|
+
d = Topology.Dictionary(edge)
|
1068
|
+
id = groups.index(Dictionary.ValueAtKey(d, "__group__"))
|
1069
|
+
d = Dictionary.SetValueAtKey(d, "__group__", id)
|
1070
|
+
edge_groups = []
|
1071
|
+
for group in groups:
|
1072
|
+
edge_group = Topology.Filter(ibEdges, searchType="equal to", key="__group__", value=group)['filtered']
|
1073
|
+
edge_groups.append(edge_group)
|
1074
|
+
final_groups = []
|
1075
|
+
for edge_group in edge_groups:
|
1076
|
+
final_groups.append(Topology.SelfMerge(Cluster.ByTopologies(edge_group, silent=True), tolerance=tolerance))
|
1077
|
+
for edge in ibEdges:
|
1078
|
+
d = Topology.Dictionary(edge)
|
1079
|
+
d = Dictionary.RemoveKey(d, "__group__")
|
1080
|
+
edge = Topology.SetDictionary(edge, d)
|
1081
|
+
return final_groups
|
1044
1082
|
|
1045
1083
|
|
1046
1084
|
@staticmethod
|
@@ -1750,8 +1788,7 @@ class Shell():
|
|
1750
1788
|
else:
|
1751
1789
|
return f
|
1752
1790
|
elif Topology.IsInstance(ext_boundary, "Cluster"):
|
1753
|
-
wires =
|
1754
|
-
_ = ext_boundary.Wires(None, wires)
|
1791
|
+
wires = Topology.Wires(ext_boundary)
|
1755
1792
|
faces = []
|
1756
1793
|
areas = []
|
1757
1794
|
for aWire in wires:
|
@@ -1770,8 +1807,7 @@ class Shell():
|
|
1770
1807
|
temp_wires = []
|
1771
1808
|
_ = int_boundary.Wires(None, temp_wires)
|
1772
1809
|
int_wires.append(Topology.RemoveCollinearEdges(temp_wires[0], angTolerance))
|
1773
|
-
temp_wires =
|
1774
|
-
_ = ext_boundary.Wires(None, temp_wires)
|
1810
|
+
temp_wires = Topology.Wire(ext_boundary)
|
1775
1811
|
ext_wire = Topology.RemoveCollinearEdges(temp_wires[0], angTolerance)
|
1776
1812
|
try:
|
1777
1813
|
return Face.ByWires(ext_wire, int_wires, tolerance=tolerance)
|
@@ -2067,7 +2103,7 @@ class Shell():
|
|
2067
2103
|
if not Topology.IsInstance(shell, "Shell"):
|
2068
2104
|
return None
|
2069
2105
|
vertices = []
|
2070
|
-
_ = shell.Vertices(None, vertices)
|
2106
|
+
_ = shell.Vertices(None, vertices) # Hook to core
|
2071
2107
|
return vertices
|
2072
2108
|
|
2073
2109
|
@staticmethod
|
@@ -2205,7 +2241,7 @@ class Shell():
|
|
2205
2241
|
if not Topology.IsInstance(shell, "Shell"):
|
2206
2242
|
return None
|
2207
2243
|
wires = []
|
2208
|
-
_ = shell.Wires(None, wires)
|
2244
|
+
_ = shell.Wires(None, wires) # Hook to core
|
2209
2245
|
return wires
|
2210
2246
|
|
2211
2247
|
|
topologicpy/Topology.py
CHANGED
@@ -225,6 +225,7 @@ class Topology():
|
|
225
225
|
|
226
226
|
"""
|
227
227
|
from topologicpy.Dictionary import Dictionary
|
228
|
+
from topologicpy.BVH import BVH
|
228
229
|
|
229
230
|
if not Topology.IsInstance(topology, "Topology"):
|
230
231
|
print("Topology.AddApertures - Error: The input topology parameter is not a valid topology. Returning None.")
|
@@ -248,7 +249,23 @@ class Topology():
|
|
248
249
|
d = Dictionary.SetValueAtKey(d, "type", "Aperture")
|
249
250
|
aperture = Topology.SetDictionary(aperture, d)
|
250
251
|
|
251
|
-
|
252
|
+
if subTopologyType == "self":
|
253
|
+
topology = Topology.AddContent(topology, apertures, subTopologyType=subTopologyType, tolerance=tolerance)
|
254
|
+
return topology
|
255
|
+
else:
|
256
|
+
bvh = BVH.ByTopologies(Topology.SubTopologies(topology, subTopologyType=subTopologyType), silent=True)
|
257
|
+
used = []
|
258
|
+
for aperture in apertures:
|
259
|
+
result = BVH.Clashes(bvh, aperture)
|
260
|
+
if isinstance(result, list):
|
261
|
+
if len(result) > 0:
|
262
|
+
subTopology = result[0]
|
263
|
+
if Topology.IsInstance(subTopology, "topology"):
|
264
|
+
used.append(subTopology)
|
265
|
+
if exclusive == True:
|
266
|
+
if subTopology in used:
|
267
|
+
continue
|
268
|
+
subTopology = Topology.AddContent(subTopology, [aperture], subTopologyType="self", tolerance=tolerance)
|
252
269
|
return topology
|
253
270
|
|
254
271
|
@staticmethod
|
@@ -273,6 +290,9 @@ class Topology():
|
|
273
290
|
The input topology with the contents added to it.
|
274
291
|
|
275
292
|
"""
|
293
|
+
|
294
|
+
from topologicpy.Context import Context
|
295
|
+
|
276
296
|
if not Topology.IsInstance(topology, "Topology"):
|
277
297
|
print("Topology.AddContent - Error: the input topology parameter is not a valid topology. Returning None.")
|
278
298
|
return None
|
@@ -292,10 +312,14 @@ class Topology():
|
|
292
312
|
print("Topology.AddContent - Error: the input subtopology type parameter is not a recognized type. Returning None.")
|
293
313
|
return None
|
294
314
|
if subTopologyType.lower() == "self":
|
295
|
-
|
315
|
+
context = Context.ByTopologyParameters(topology)
|
316
|
+
for content in contents:
|
317
|
+
content.AddContext(context) # Hook to Core
|
318
|
+
topology.AddContent(content) # Hook to Core
|
296
319
|
else:
|
297
320
|
t = Topology.TypeID(subTopologyType)
|
298
|
-
|
321
|
+
topology.AddContents(contents, t) # Hook to Core
|
322
|
+
return topology
|
299
323
|
|
300
324
|
@staticmethod
|
301
325
|
def AddDictionary(topology, dictionary):
|
@@ -886,7 +910,7 @@ class Topology():
|
|
886
910
|
for i, eb in enumerate(eb_list):
|
887
911
|
v = Topology.Vertices(eb)[0]
|
888
912
|
if found == False:
|
889
|
-
if Vertex.IsInternal(v, topologyA_wire) or Vertex.IsInternal(v, topologyB_wire):
|
913
|
+
if Vertex.IsInternal(v, topologyA_wire, tolerance=tolerance) or Vertex.IsInternal(v, topologyB_wire, tolerance=tolerance):
|
890
914
|
external_boundary = eb
|
891
915
|
found = True
|
892
916
|
else:
|
@@ -2390,7 +2414,7 @@ class Topology():
|
|
2390
2414
|
return topology
|
2391
2415
|
'''
|
2392
2416
|
@staticmethod
|
2393
|
-
def ByJSONFile(file, tolerance=0.0001):
|
2417
|
+
def ByJSONFile(file, tolerance: float = 0.0001, silent: bool = False):
|
2394
2418
|
"""
|
2395
2419
|
Imports the topology from a JSON file.
|
2396
2420
|
|
@@ -2400,6 +2424,8 @@ class Topology():
|
|
2400
2424
|
The input JSON file.
|
2401
2425
|
tolerance : float , optional
|
2402
2426
|
The desired tolerance. Default is 0.0001.
|
2427
|
+
silent : bool , optional
|
2428
|
+
If set to True, error and warning messages are suppressed. Default is False.
|
2403
2429
|
|
2404
2430
|
Returns
|
2405
2431
|
-------
|
@@ -2407,14 +2433,21 @@ class Topology():
|
|
2407
2433
|
The list of imported topologies (Warning: the list could contain 0, 1, or many topologies, but this method will always return a list)
|
2408
2434
|
|
2409
2435
|
"""
|
2436
|
+
import json
|
2410
2437
|
if not file:
|
2411
|
-
|
2438
|
+
if not silent:
|
2439
|
+
print("Topology.ByJSONFile - Error: the input file parameter is not a valid file. Returning None.")
|
2440
|
+
return None
|
2441
|
+
try:
|
2442
|
+
json_dict = json.load(file)
|
2443
|
+
except Exception as e:
|
2444
|
+
if not silent:
|
2445
|
+
print("Topology.ByJSONFile - Error: Could not load the JSON file: {e}. Returning None.")
|
2412
2446
|
return None
|
2413
|
-
json_dict =
|
2414
|
-
return Topology.ByJSONDictionary(json_dict, tolerance=tolerance)
|
2447
|
+
return Topology.ByJSONDictionary(json_dict, tolerance=tolerance, silent=silent)
|
2415
2448
|
|
2416
2449
|
@staticmethod
|
2417
|
-
def ByJSONPath(path, tolerance=0.0001):
|
2450
|
+
def ByJSONPath(path, tolerance: float = 0.0001, silent: bool = False):
|
2418
2451
|
"""
|
2419
2452
|
Imports the topology from a JSON file.
|
2420
2453
|
|
@@ -2424,6 +2457,8 @@ class Topology():
|
|
2424
2457
|
The file path to the json file.
|
2425
2458
|
tolerance : float , optional
|
2426
2459
|
The desired tolerance. Default is 0.0001.
|
2460
|
+
silent : bool , optional
|
2461
|
+
If set to True, error and warning messages are suppressed. Default is False.
|
2427
2462
|
|
2428
2463
|
Returns
|
2429
2464
|
-------
|
@@ -2433,15 +2468,20 @@ class Topology():
|
|
2433
2468
|
"""
|
2434
2469
|
import json
|
2435
2470
|
if not path:
|
2436
|
-
|
2471
|
+
if not silent:
|
2472
|
+
print("Topology.ByJSONPath - Error: the input path parameter is not a valid path. Returning None.")
|
2437
2473
|
return None
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2474
|
+
try:
|
2475
|
+
with open(path) as file:
|
2476
|
+
json_dict = json.load(file)
|
2477
|
+
except Exception as e:
|
2478
|
+
if not silent:
|
2479
|
+
print("Topology.ByJSONPath - Error: Could not load file: {e}. Returning None.")
|
2480
|
+
return None
|
2481
|
+
return Topology.ByJSONDictionary(json_dict, tolerance=tolerance, silent=silent)
|
2442
2482
|
|
2443
2483
|
@staticmethod
|
2444
|
-
def ByJSONDictionary(jsonDictionary, tolerance=0.0001):
|
2484
|
+
def ByJSONDictionary(jsonDictionary: dict, tolerance: float = 0.0001, silent: bool = False):
|
2445
2485
|
"""
|
2446
2486
|
Imports the topology from a JSON dictionary.
|
2447
2487
|
|
@@ -2451,6 +2491,8 @@ class Topology():
|
|
2451
2491
|
The input JSON dictionary.
|
2452
2492
|
tolerance : float , optional
|
2453
2493
|
The desired tolerance. Default is 0.0001.
|
2494
|
+
silent : bool , optional
|
2495
|
+
If set to True, error and warning messages are suppressed. Default is False.
|
2454
2496
|
|
2455
2497
|
Returns
|
2456
2498
|
-------
|
@@ -2489,41 +2531,41 @@ class Topology():
|
|
2489
2531
|
# Create basic topological entities
|
2490
2532
|
if entity_type == 'Vertex':
|
2491
2533
|
parent_entity = Vertex.ByCoordinates(*entity['coordinates'])
|
2492
|
-
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
2534
|
+
parent_entity = Topology.SetDictionary(parent_entity, entity_dict, silent=silent)
|
2493
2535
|
vertices[entity['uuid']] = parent_entity
|
2494
2536
|
|
2495
2537
|
elif entity_type == 'Edge':
|
2496
2538
|
vertex1 = vertices[entity['vertices'][0]]
|
2497
2539
|
vertex2 = vertices[entity['vertices'][1]]
|
2498
|
-
parent_entity = Edge.ByVertices([vertex1, vertex2])
|
2499
|
-
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
2540
|
+
parent_entity = Edge.ByVertices([vertex1, vertex2], tolerance=tolerance, silent=silent)
|
2541
|
+
parent_entity = Topology.SetDictionary(parent_entity, entity_dict, silent=silent)
|
2500
2542
|
edges[entity['uuid']] = parent_entity
|
2501
2543
|
|
2502
2544
|
elif entity_type == 'Wire':
|
2503
2545
|
wire_edges = [edges[uuid] for uuid in entity['edges']]
|
2504
|
-
parent_entity = Wire.ByEdges(wire_edges)
|
2505
|
-
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
2546
|
+
parent_entity = Wire.ByEdges(wire_edges, tolerance=tolerance, silent=silent)
|
2547
|
+
parent_entity = Topology.SetDictionary(parent_entity, entity_dict, silent=silent)
|
2506
2548
|
wires[entity['uuid']] = parent_entity
|
2507
2549
|
|
2508
2550
|
elif entity_type == 'Face':
|
2509
2551
|
face_wires = [wires[uuid] for uuid in entity['wires']]
|
2510
2552
|
if len(face_wires) > 1:
|
2511
|
-
parent_entity = Face.ByWires(face_wires[0], face_wires[1:])
|
2553
|
+
parent_entity = Face.ByWires(face_wires[0], face_wires[1:], tolerance=tolerance, silent=silent)
|
2512
2554
|
else:
|
2513
|
-
parent_entity = Face.ByWire(face_wires[0])
|
2514
|
-
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
2555
|
+
parent_entity = Face.ByWire(face_wires[0], tolerance=tolerance, silent=silent)
|
2556
|
+
parent_entity = Topology.SetDictionary(parent_entity, entity_dict, silent=silent)
|
2515
2557
|
faces[entity['uuid']] = parent_entity
|
2516
2558
|
|
2517
2559
|
elif entity_type == 'Shell':
|
2518
2560
|
shell_faces = [faces[uuid] for uuid in entity['faces']]
|
2519
|
-
parent_entity = Shell.ByFaces(shell_faces)
|
2520
|
-
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
2561
|
+
parent_entity = Shell.ByFaces(shell_faces, tolerance=tolerance, silent=silent)
|
2562
|
+
parent_entity = Topology.SetDictionary(parent_entity, entity_dict, silent=silent)
|
2521
2563
|
shells[entity['uuid']] = parent_entity
|
2522
2564
|
|
2523
2565
|
elif entity_type == 'Cell':
|
2524
2566
|
cell_shells = [shells[uuid] for uuid in entity['shells']]
|
2525
2567
|
if len(cell_shells) > 1:
|
2526
|
-
parent_entity = Cell.ByShells(cell_shells[0], cell_shells[1:])
|
2568
|
+
parent_entity = Cell.ByShells(cell_shells[0], cell_shells[1:], tolerance=tolerance, silent=silent)
|
2527
2569
|
else:
|
2528
2570
|
parent_entity = Cell.ByShell(cell_shells[0])
|
2529
2571
|
parent_entity = Topology.SetDictionary(parent_entity, entity_dict)
|
@@ -2649,7 +2691,7 @@ class Topology():
|
|
2649
2691
|
return top_level_list
|
2650
2692
|
|
2651
2693
|
@staticmethod
|
2652
|
-
def ByJSONString(string, tolerance=0.0001):
|
2694
|
+
def ByJSONString(string: str, tolerance: float = 0.0001, silent: bool = False):
|
2653
2695
|
"""
|
2654
2696
|
Imports the topology from a JSON string.
|
2655
2697
|
|
@@ -2659,6 +2701,8 @@ class Topology():
|
|
2659
2701
|
The input JSON string.
|
2660
2702
|
tolerance : float , optional
|
2661
2703
|
The desired tolerance. Default is 0.0001.
|
2704
|
+
silent : bool , optional
|
2705
|
+
If set to True, error and warning messages are suppressed. Default is False.
|
2662
2706
|
|
2663
2707
|
Returns
|
2664
2708
|
-------
|
@@ -2666,9 +2710,17 @@ class Topology():
|
|
2666
2710
|
The list of imported topologies (Warning: the list could contain 0, 1, or many topologies, but this method will always return a list)
|
2667
2711
|
|
2668
2712
|
"""
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2713
|
+
import inspect
|
2714
|
+
try:
|
2715
|
+
json_dict = json.loads(string)
|
2716
|
+
except Exception as e:
|
2717
|
+
if not silent:
|
2718
|
+
print(f"Topology.ByJSONString - Error: Could not read the input string: {e}. Returning None.")
|
2719
|
+
curframe = inspect.currentframe()
|
2720
|
+
calframe = inspect.getouterframes(curframe, 2)
|
2721
|
+
print('caller name:', calframe[1][3])
|
2722
|
+
return None
|
2723
|
+
return Topology.ByJSONDictionary(json_dict, tolerance=tolerance, silent=silent)
|
2672
2724
|
|
2673
2725
|
@staticmethod
|
2674
2726
|
def ByMeshData(dictionary, transferDictionaries: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
|
@@ -3971,7 +4023,7 @@ class Topology():
|
|
3971
4023
|
print("Topology.Contents - Error: the input topology parameter is not a valid topology. Returning None.")
|
3972
4024
|
return None
|
3973
4025
|
contents = []
|
3974
|
-
_ = topology.Contents(contents)
|
4026
|
+
_ = topology.Contents(contents) # Hook to Core
|
3975
4027
|
return contents
|
3976
4028
|
|
3977
4029
|
@staticmethod
|
@@ -3994,7 +4046,7 @@ class Topology():
|
|
3994
4046
|
print("Topology.Contexts - Error: the input topology parameter is not a valid topology. Returning None.")
|
3995
4047
|
return None
|
3996
4048
|
contexts = []
|
3997
|
-
_ = topology.Contexts(contexts)
|
4049
|
+
_ = topology.Contexts(contexts) # Hook to Core
|
3998
4050
|
return contexts
|
3999
4051
|
|
4000
4052
|
@staticmethod
|
@@ -9710,45 +9762,9 @@ class Topology():
|
|
9710
9762
|
|
9711
9763
|
"""
|
9712
9764
|
from topologicpy.Vertex import Vertex
|
9713
|
-
from topologicpy.Dictionary import Dictionary
|
9714
9765
|
from topologicpy.Cluster import Cluster
|
9715
|
-
from topologicpy.
|
9716
|
-
|
9717
|
-
|
9718
|
-
def transfer_dictionaries_by_selectors(object, selectors, tranVertices=False, tranEdges=False, tranFaces=False, tranCells=False, tolerance=0.0001):
|
9719
|
-
if tranVertices == True:
|
9720
|
-
vertices = Topology.Vertices(object)
|
9721
|
-
for vertex in vertices:
|
9722
|
-
for selector in selectors:
|
9723
|
-
d = Vertex.Distance(selector, vertex)
|
9724
|
-
if d <= tolerance:
|
9725
|
-
vertex = Topology.SetDictionary(vertex, Topology.Dictionary(selector), silent=True)
|
9726
|
-
break
|
9727
|
-
if tranEdges == True:
|
9728
|
-
edges = Topology.Edges(object)
|
9729
|
-
for selector in selectors:
|
9730
|
-
for edge in edges:
|
9731
|
-
d = Vertex.Distance(selector, edge)
|
9732
|
-
if d <= tolerance:
|
9733
|
-
|
9734
|
-
edge = Topology.SetDictionary(edge, Topology.Dictionary(selector), silent=True)
|
9735
|
-
break
|
9736
|
-
if tranFaces == True:
|
9737
|
-
faces = Topology.Faces(object)
|
9738
|
-
for face in faces:
|
9739
|
-
for selector in selectors:
|
9740
|
-
d = Vertex.Distance(selector, face)
|
9741
|
-
if d <= tolerance:
|
9742
|
-
face = Topology.SetDictionary(face, Topology.Dictionary(selector), silent=True)
|
9743
|
-
break
|
9744
|
-
if tranCells == True:
|
9745
|
-
cells = Topology.Cells(object)
|
9746
|
-
for cell in cells:
|
9747
|
-
for selector in selectors:
|
9748
|
-
if Vertex.IsInternal(selector, cell):
|
9749
|
-
cell = Topology.SetDictionary(cell, Topology.Dictionary(selector), silent=True)
|
9750
|
-
break
|
9751
|
-
return object
|
9766
|
+
from topologicpy.Dictionary import Dictionary
|
9767
|
+
from topologicpy.BVH import BVH
|
9752
9768
|
|
9753
9769
|
if not Topology.IsInstance(topology, "Topology"):
|
9754
9770
|
print("Topology.TransferDictionariesBySelectors - Error: The input topology parameter is not a valid topology. Returning None.")
|
@@ -9756,51 +9772,65 @@ class Topology():
|
|
9756
9772
|
if not isinstance(selectors, list):
|
9757
9773
|
print("Topology.TransferDictionariesBySelectors - Error: The input selectors parameter is not a valid list. Returning None.")
|
9758
9774
|
return None
|
9759
|
-
if numWorkers == None:
|
9760
|
-
import multiprocessing
|
9761
|
-
numWorkers = multiprocessing.cpu_count()*2
|
9762
9775
|
selectors_tmp = [x for x in selectors if Topology.IsInstance(x, "Vertex")]
|
9763
9776
|
if len(selectors_tmp) < 1:
|
9764
9777
|
print("Topology.TransferDictionariesBySelectors - Error: The input selectors do not contain any valid topologies. Returning None.")
|
9765
9778
|
return None
|
9766
9779
|
|
9767
|
-
|
9768
|
-
|
9769
|
-
|
9770
|
-
|
9771
|
-
|
9772
|
-
|
9773
|
-
|
9774
|
-
|
9775
|
-
|
9776
|
-
|
9777
|
-
|
9778
|
-
|
9779
|
-
|
9780
|
-
|
9781
|
-
|
9782
|
-
|
9783
|
-
|
9784
|
-
|
9785
|
-
|
9786
|
-
|
9787
|
-
|
9788
|
-
|
9789
|
-
if Topology.
|
9790
|
-
|
9791
|
-
|
9792
|
-
|
9793
|
-
|
9794
|
-
|
9795
|
-
|
9796
|
-
|
9797
|
-
|
9798
|
-
|
9799
|
-
|
9800
|
-
|
9780
|
+
|
9781
|
+
# --------------------------
|
9782
|
+
# Collect primitives
|
9783
|
+
# --------------------------
|
9784
|
+
def collect_cells(topo):
|
9785
|
+
if Topology.IsInstance(topo, "cell"):
|
9786
|
+
return [topo]
|
9787
|
+
else:
|
9788
|
+
return Topology.Cells(topo)
|
9789
|
+
|
9790
|
+
def collect_faces(topo):
|
9791
|
+
if Topology.IsInstance(topo, "face"):
|
9792
|
+
return [topo]
|
9793
|
+
else:
|
9794
|
+
return Topology.Faces(topo)
|
9795
|
+
|
9796
|
+
def collect_edges(topo):
|
9797
|
+
if Topology.IsInstance(topo, "edge"):
|
9798
|
+
return [topo]
|
9799
|
+
else:
|
9800
|
+
return Topology.Edges(topo)
|
9801
|
+
def collect_vertices(topo):
|
9802
|
+
if Topology.IsInstance(topo, "vertex"):
|
9803
|
+
return [topo]
|
9804
|
+
else:
|
9805
|
+
return Topology.Vertices(topo)
|
9806
|
+
|
9807
|
+
vertices = []
|
9808
|
+
edges = []
|
9809
|
+
faces = []
|
9810
|
+
cells = []
|
9811
|
+
if tranVertices:
|
9812
|
+
vertices = collect_vertices(topology)
|
9813
|
+
if tranEdges:
|
9814
|
+
edges = collect_edges(topology)
|
9815
|
+
if tranFaces:
|
9816
|
+
faces = collect_faces(topology)
|
9817
|
+
if tranCells:
|
9818
|
+
cells = collect_cells(topology)
|
9819
|
+
primitives = []
|
9820
|
+
primitives.extend(cells)
|
9821
|
+
primitives.extend(faces)
|
9822
|
+
primitives.extend(edges)
|
9823
|
+
primitives.extend(vertices)
|
9824
|
+
cluster = Cluster.ByTopologies(primitives)
|
9825
|
+
for s in selectors:
|
9826
|
+
status, element = Vertex.IsInternal(s, cluster, identify=True, tolerance=tolerance)
|
9827
|
+
if status:
|
9828
|
+
d1 = Topology.Dictionary(s)
|
9829
|
+
d2 = Topology.Dictionary(element)
|
9830
|
+
d3 = Dictionary.ByMergedDictionaries(d1, d2)
|
9831
|
+
element = Topology.SetDictionary(element, d3)
|
9801
9832
|
return topology
|
9802
9833
|
|
9803
|
-
|
9804
9834
|
@staticmethod
|
9805
9835
|
def Transform(topology, matrix: list, silent: bool = False):
|
9806
9836
|
"""
|