topologicpy 0.8.42__py3-none-any.whl → 0.8.44__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/Color.py +37 -1
- topologicpy/Dictionary.py +116 -41
- topologicpy/Topology.py +95 -18
- topologicpy/version.py +1 -1
- {topologicpy-0.8.42.dist-info → topologicpy-0.8.44.dist-info}/METADATA +1 -1
- {topologicpy-0.8.42.dist-info → topologicpy-0.8.44.dist-info}/RECORD +9 -9
- {topologicpy-0.8.42.dist-info → topologicpy-0.8.44.dist-info}/WHEEL +0 -0
- {topologicpy-0.8.42.dist-info → topologicpy-0.8.44.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.42.dist-info → topologicpy-0.8.44.dist-info}/top_level.txt +0 -0
topologicpy/Color.py
CHANGED
@@ -19,6 +19,40 @@ import math
|
|
19
19
|
|
20
20
|
class Color:
|
21
21
|
|
22
|
+
def AddHex(*colors):
|
23
|
+
"""
|
24
|
+
Adds the input hexadecimal color codes channel-wise, clipping each channel to a max of 255.
|
25
|
+
|
26
|
+
Parameters
|
27
|
+
----------
|
28
|
+
colors : *list or str
|
29
|
+
The input list of hexadecimal colors.
|
30
|
+
|
31
|
+
Returns
|
32
|
+
-------
|
33
|
+
str
|
34
|
+
The resulting hex color after addition (e.g., "#FF88FF").
|
35
|
+
"""
|
36
|
+
import inspect
|
37
|
+
from topologicpy.Helper import Helper
|
38
|
+
|
39
|
+
def add(hex1, hex2):
|
40
|
+
# Remove "#" if present
|
41
|
+
hex1 = hex1.lstrip('#')
|
42
|
+
hex2 = hex2.lstrip('#')
|
43
|
+
|
44
|
+
# Convert to RGB integers
|
45
|
+
r1, g1, b1 = int(hex1[0:2], 16), int(hex1[2:4], 16), int(hex1[4:6], 16)
|
46
|
+
r2, g2, b2 = int(hex2[0:2], 16), int(hex2[2:4], 16), int(hex2[4:6], 16)
|
47
|
+
|
48
|
+
# Add each channel, clip to 255
|
49
|
+
r = min(r1 + r2, 255)
|
50
|
+
g = min(g1 + g2, 255)
|
51
|
+
b = min(b1 + b2, 255)
|
52
|
+
|
53
|
+
# Return as hex string
|
54
|
+
return f"#{r:02X}{g:02X}{b:02X}"
|
55
|
+
|
22
56
|
@staticmethod
|
23
57
|
def AnyToHex(color):
|
24
58
|
"""
|
@@ -35,6 +69,8 @@ class Color:
|
|
35
69
|
A hexadecimal color string in the format '#RRGGBB'.
|
36
70
|
"""
|
37
71
|
return_hex = None
|
72
|
+
if isinstance(color, list) and all(isinstance(item, str) for item in color):
|
73
|
+
return Color.Average(color)
|
38
74
|
if isinstance(color, list):
|
39
75
|
if len(color) == 4: # Probably CMYK
|
40
76
|
if all(0 <= x <= 1 for x in color[:4]):
|
@@ -56,7 +92,7 @@ class Color:
|
|
56
92
|
return return_hex.upper()
|
57
93
|
|
58
94
|
@staticmethod
|
59
|
-
def
|
95
|
+
def Average(*colors, silent: bool = False):
|
60
96
|
"""
|
61
97
|
Averages the input list of hex colors.
|
62
98
|
|
topologicpy/Dictionary.py
CHANGED
@@ -75,6 +75,7 @@ class Dictionary():
|
|
75
75
|
The adjacency dictionary.
|
76
76
|
"""
|
77
77
|
from topologicpy.Edge import Edge
|
78
|
+
from topologicpy.Face import Face
|
78
79
|
from topologicpy.Dictionary import Dictionary
|
79
80
|
from topologicpy.Topology import Topology
|
80
81
|
from topologicpy.Graph import Graph
|
@@ -116,7 +117,7 @@ class Dictionary():
|
|
116
117
|
if d == None:
|
117
118
|
d = Dictionary.ByKeyValue(labelKey, value)
|
118
119
|
else:
|
119
|
-
d = Dictionary.SetValueAtKey(d, labelKey, value)
|
120
|
+
d = Dictionary.SetValueAtKey(d, labelKey, value, silent=silent)
|
120
121
|
subtopology = Topology.SetDictionary(subtopology, d)
|
121
122
|
labels.append(value)
|
122
123
|
all_subtopologies = Helper.Sort(all_subtopologies, labels)
|
@@ -129,7 +130,7 @@ class Dictionary():
|
|
129
130
|
adjacent_topologies = Topology.AdjacentTopologies(subtopology, hostTopology=topology, topologyType=subTopologyType)
|
130
131
|
temp_list = []
|
131
132
|
for adj_topology in adjacent_topologies:
|
132
|
-
adj_label = Dictionary.ValueAtKey(Topology.Dictionary(adj_topology), labelKey)
|
133
|
+
adj_label = Dictionary.ValueAtKey(Topology.Dictionary(adj_topology), labelKey, silent=silent)
|
133
134
|
adj_index = labels.index(adj_label)
|
134
135
|
if includeWeights == True:
|
135
136
|
if weightKey == None:
|
@@ -141,7 +142,7 @@ class Dictionary():
|
|
141
142
|
elif "area" in weightKey.lower():
|
142
143
|
shared_topologies = Topology.SharedTopologies(subtopology, adj_topology)
|
143
144
|
faces = shared_topologies.get("faces", [])
|
144
|
-
weight = sum([
|
145
|
+
weight = sum([Face.Area(face, mantissa=mantissa) for face in faces])
|
145
146
|
else:
|
146
147
|
shared_topologies = Topology.SharedTopologies(subtopology, adj_topology)
|
147
148
|
vertices = shared_topologies.get("vertices", [])
|
@@ -166,7 +167,7 @@ class Dictionary():
|
|
166
167
|
return adjDict
|
167
168
|
|
168
169
|
@staticmethod
|
169
|
-
def ByKeyValue(key, value):
|
170
|
+
def ByKeyValue(key, value, silent: bool = False):
|
170
171
|
"""
|
171
172
|
Creates a Dictionary from the input key and the input value.
|
172
173
|
|
@@ -176,6 +177,8 @@ class Dictionary():
|
|
176
177
|
The string representing the key of the value in the dictionary.
|
177
178
|
value : int, float, str, or list
|
178
179
|
A value corresponding to the input key. A value can be an integer, a float, a string, or a list.
|
180
|
+
silent : bool , optional
|
181
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
179
182
|
|
180
183
|
Returns
|
181
184
|
-------
|
@@ -184,9 +187,10 @@ class Dictionary():
|
|
184
187
|
|
185
188
|
"""
|
186
189
|
if not isinstance(key, str):
|
187
|
-
|
190
|
+
if not silent:
|
191
|
+
print("Dictionary.ByKeyValue - Error: The input key is not a valid string. Returning None.")
|
188
192
|
return None
|
189
|
-
return Dictionary.ByKeysValues([key], [value])
|
193
|
+
return Dictionary.ByKeysValues([key], [value], silent=silent)
|
190
194
|
|
191
195
|
|
192
196
|
@staticmethod
|
@@ -234,7 +238,7 @@ class Dictionary():
|
|
234
238
|
return attr
|
235
239
|
|
236
240
|
@staticmethod
|
237
|
-
def ByKeysValues(keys, values):
|
241
|
+
def ByKeysValues(keys, values, silent: bool = False):
|
238
242
|
"""
|
239
243
|
Creates a Dictionary from the input list of keys and the input list of values.
|
240
244
|
|
@@ -244,6 +248,8 @@ class Dictionary():
|
|
244
248
|
A list of strings representing the keys of the dictionary.
|
245
249
|
values : list
|
246
250
|
A list of values corresponding to the list of keys. Values can be integers, floats, strings, or lists
|
251
|
+
silent : bool , optional
|
252
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
247
253
|
|
248
254
|
Returns
|
249
255
|
-------
|
@@ -253,13 +259,16 @@ class Dictionary():
|
|
253
259
|
"""
|
254
260
|
|
255
261
|
if not isinstance(keys, list):
|
256
|
-
|
262
|
+
if not silent:
|
263
|
+
print("Dictionary.ByKeysValues - Error: The input keys parameter is not a valid list. Returning None.")
|
257
264
|
return None
|
258
265
|
if not isinstance(values, list):
|
259
|
-
|
266
|
+
if not silent:
|
267
|
+
print("Dictionary.ByKeysValues - Error: The input values parameter is not a valid list. Returning None.")
|
260
268
|
return None
|
261
269
|
if len(keys) != len(values):
|
262
|
-
|
270
|
+
if not silent:
|
271
|
+
print("Dictionary.ByKeysValues - Error: The input keys and values parameters are not of equal length. Returning None.")
|
263
272
|
return None
|
264
273
|
stl_keys = []
|
265
274
|
stl_values = []
|
@@ -440,7 +449,7 @@ class Dictionary():
|
|
440
449
|
'''
|
441
450
|
|
442
451
|
@staticmethod
|
443
|
-
def ByPythonDictionary(pythonDictionary):
|
452
|
+
def ByPythonDictionary(pythonDictionary, silent: bool = False):
|
444
453
|
"""
|
445
454
|
Creates a dictionary equivalent to the input python dictionary.
|
446
455
|
|
@@ -448,6 +457,8 @@ class Dictionary():
|
|
448
457
|
----------
|
449
458
|
pythonDictionary : dict
|
450
459
|
The input python dictionary.
|
460
|
+
silent : bool , optional
|
461
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
451
462
|
|
452
463
|
Returns
|
453
464
|
-------
|
@@ -456,7 +467,8 @@ class Dictionary():
|
|
456
467
|
|
457
468
|
"""
|
458
469
|
if not isinstance(pythonDictionary, dict):
|
459
|
-
|
470
|
+
if not silent:
|
471
|
+
print("Dictionary.ByPythonDictionary - Error: The input dictionary parameter is not a valid python dictionary. Returning None.")
|
460
472
|
return None
|
461
473
|
keys = list(pythonDictionary.keys())
|
462
474
|
values = []
|
@@ -480,7 +492,8 @@ class Dictionary():
|
|
480
492
|
A copy of the input dictionary.
|
481
493
|
|
482
494
|
"""
|
483
|
-
|
495
|
+
from topologicpy.Topology import Topology
|
496
|
+
if not Topology.IsInstance(dictionary, "dictionary"):
|
484
497
|
if not silent:
|
485
498
|
print("Dictionary.Copy - Error: The input dictionary parameter is not a valid dictionary. Returning None.")
|
486
499
|
return None
|
@@ -580,7 +593,7 @@ class Dictionary():
|
|
580
593
|
return {"filteredDictionaries": filteredDictionaries, "otherDictionaries": otherDictionaries, "filteredIndices": filteredIndices, "otherIndices": otherIndices, "filteredElements": filteredElements, "otherElements": otherElements}
|
581
594
|
|
582
595
|
@staticmethod
|
583
|
-
def Keys(dictionary):
|
596
|
+
def Keys(dictionary, silent: bool = False):
|
584
597
|
"""
|
585
598
|
Returns the keys of the input dictionary.
|
586
599
|
|
@@ -588,6 +601,8 @@ class Dictionary():
|
|
588
601
|
----------
|
589
602
|
dictionary : topologic_core.Dictionary or dict
|
590
603
|
The input dictionary.
|
604
|
+
silent : bool , optional
|
605
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
591
606
|
|
592
607
|
Returns
|
593
608
|
-------
|
@@ -596,8 +611,14 @@ class Dictionary():
|
|
596
611
|
|
597
612
|
"""
|
598
613
|
from topologicpy.Topology import Topology
|
614
|
+
import inspect
|
615
|
+
|
599
616
|
if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
|
600
|
-
|
617
|
+
if not silent:
|
618
|
+
print("Dictionary.Keys - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
619
|
+
curframe = inspect.currentframe()
|
620
|
+
calframe = inspect.getouterframes(curframe, 2)
|
621
|
+
print('caller name:', calframe[1][3])
|
601
622
|
return None
|
602
623
|
if isinstance(dictionary, dict):
|
603
624
|
return list(dictionary.keys())
|
@@ -627,7 +648,7 @@ class Dictionary():
|
|
627
648
|
return returnList
|
628
649
|
|
629
650
|
@staticmethod
|
630
|
-
def PythonDictionary(dictionary):
|
651
|
+
def PythonDictionary(dictionary, silent: bool = False):
|
631
652
|
"""
|
632
653
|
Returns the input dictionary as a python dictionary
|
633
654
|
|
@@ -635,6 +656,8 @@ class Dictionary():
|
|
635
656
|
----------
|
636
657
|
dictionary : topologic_core.Dictionary
|
637
658
|
The input dictionary.
|
659
|
+
silent : bool , optional
|
660
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
638
661
|
|
639
662
|
Returns
|
640
663
|
-------
|
@@ -645,10 +668,12 @@ class Dictionary():
|
|
645
668
|
from topologicpy.Topology import Topology
|
646
669
|
|
647
670
|
if isinstance(dictionary, dict):
|
648
|
-
|
671
|
+
if not silent:
|
672
|
+
print("Dictionary.PythonDictionary - Warning: The input dictionary parameter is already a python dictionary. Returning that dictionary.")
|
649
673
|
return dictionary
|
650
674
|
if not Topology.IsInstance(dictionary, "Dictionary"):
|
651
|
-
|
675
|
+
if not silent:
|
676
|
+
print("Dictionary.PythonDictionary - Error: The input dictionary parameter is not a valid topologic dictionary. Returning None.")
|
652
677
|
return None
|
653
678
|
keys = dictionary.Keys()
|
654
679
|
pythonDict = {}
|
@@ -674,7 +699,7 @@ class Dictionary():
|
|
674
699
|
return pythonDict
|
675
700
|
|
676
701
|
@staticmethod
|
677
|
-
def RemoveKey(dictionary, key):
|
702
|
+
def RemoveKey(dictionary, key, silent: bool = False):
|
678
703
|
"""
|
679
704
|
Removes the key (and its associated value) from the input dictionary.
|
680
705
|
|
@@ -684,6 +709,8 @@ class Dictionary():
|
|
684
709
|
The input dictionary.
|
685
710
|
key : string
|
686
711
|
The input key.
|
712
|
+
silent : bool , optional
|
713
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
687
714
|
|
688
715
|
Returns
|
689
716
|
-------
|
@@ -713,10 +740,12 @@ class Dictionary():
|
|
713
740
|
return Dictionary.ByKeysValues(new_keys, new_values)
|
714
741
|
|
715
742
|
if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
|
716
|
-
|
743
|
+
if not silent:
|
744
|
+
print("Dictionary.RemoveKey - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
717
745
|
return None
|
718
746
|
if not isinstance(key, str):
|
719
|
-
|
747
|
+
if not silent:
|
748
|
+
print("Dictionary.RemoveKey - Error: The input key parameter is not a valid string. Returning None.")
|
720
749
|
return None
|
721
750
|
|
722
751
|
if isinstance(dictionary, dict):
|
@@ -727,7 +756,7 @@ class Dictionary():
|
|
727
756
|
return None
|
728
757
|
|
729
758
|
@staticmethod
|
730
|
-
def SetValueAtKey(dictionary, key, value):
|
759
|
+
def SetValueAtKey(dictionary, key, value, silent: bool = False):
|
731
760
|
"""
|
732
761
|
Creates a key/value pair in the input dictionary.
|
733
762
|
|
@@ -739,6 +768,8 @@ class Dictionary():
|
|
739
768
|
The input key.
|
740
769
|
value : int , float , string, or list
|
741
770
|
The value associated with the key.
|
771
|
+
silent : bool , optional
|
772
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
742
773
|
|
743
774
|
Returns
|
744
775
|
-------
|
@@ -768,10 +799,12 @@ class Dictionary():
|
|
768
799
|
return d
|
769
800
|
|
770
801
|
if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
|
771
|
-
|
802
|
+
if not silent:
|
803
|
+
print("Dictionary.SetValueAtKey - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
772
804
|
return None
|
773
805
|
if not isinstance(key, str):
|
774
|
-
|
806
|
+
if not silent:
|
807
|
+
print("Dictionary.SetValueAtKey - Error: The input key parameter is not a valid string. Returning None.")
|
775
808
|
return None
|
776
809
|
if value == None:
|
777
810
|
value = "__NONE__"
|
@@ -783,7 +816,7 @@ class Dictionary():
|
|
783
816
|
return None
|
784
817
|
|
785
818
|
@staticmethod
|
786
|
-
def SetValuesAtKeys(dictionary, keys, values):
|
819
|
+
def SetValuesAtKeys(dictionary, keys, values, silent: bool = False):
|
787
820
|
"""
|
788
821
|
Creates a key/value pair in the input dictionary.
|
789
822
|
|
@@ -793,6 +826,8 @@ class Dictionary():
|
|
793
826
|
A list of strings representing the keys of the dictionary.
|
794
827
|
values : list
|
795
828
|
A list of values corresponding to the list of keys. Values can be integers, floats, strings, or lists
|
829
|
+
silent : bool , optional
|
830
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
796
831
|
|
797
832
|
Returns
|
798
833
|
-------
|
@@ -802,17 +837,20 @@ class Dictionary():
|
|
802
837
|
"""
|
803
838
|
|
804
839
|
if not isinstance(keys, list):
|
805
|
-
|
840
|
+
if not silent:
|
841
|
+
print("Dictionary.SetValuesAtKeys - Error: The input keys parameter is not a valid list. Returning None.")
|
806
842
|
return None
|
807
843
|
if not isinstance(values, list):
|
808
|
-
|
844
|
+
if not silent:
|
845
|
+
print("Dictionary.SetValuesAtkeys - Error: The input values parameter is not a valid list. Returning None.")
|
809
846
|
return None
|
810
847
|
if len(keys) != len(values):
|
811
|
-
|
848
|
+
if not silent:
|
849
|
+
print("Dictionary.SetValuesAtKeys - Error: The input keys and values parameters are not of equal length. Returning None.")
|
812
850
|
return None
|
813
851
|
|
814
852
|
for i, key in enumerate(keys):
|
815
|
-
dictionary = Dictionary.SetValueAtKey(dictionary, key, values[i])
|
853
|
+
dictionary = Dictionary.SetValueAtKey(dictionary, key, values[i], silent=silent)
|
816
854
|
return dictionary
|
817
855
|
|
818
856
|
@staticmethod
|
@@ -930,18 +968,9 @@ class Dictionary():
|
|
930
968
|
elif isinstance(dictionary, dict):
|
931
969
|
return dictionary.get(key, defaultValue)
|
932
970
|
return defaultValue
|
933
|
-
|
934
|
-
# if isinstance(dictionary, dict):
|
935
|
-
# attr = dictionary[key]
|
936
|
-
# elif Topology.IsInstance(dictionary, "Dictionary"):
|
937
|
-
# attr = dictionary.ValueAtKey(key)
|
938
|
-
# else:
|
939
|
-
# return None
|
940
|
-
# return_value = Dictionary._ConvertAttribute(attr)
|
941
|
-
# return return_value
|
942
|
-
|
971
|
+
|
943
972
|
@staticmethod
|
944
|
-
def Values(dictionary):
|
973
|
+
def Values(dictionary, silent: bool = False):
|
945
974
|
"""
|
946
975
|
Returns the list of values in the input dictionary.
|
947
976
|
|
@@ -949,6 +978,8 @@ class Dictionary():
|
|
949
978
|
----------
|
950
979
|
dictionary : topologic_core.Dictionary or dict
|
951
980
|
The input dictionary.
|
981
|
+
silent : bool , optional
|
982
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
952
983
|
|
953
984
|
Returns
|
954
985
|
-------
|
@@ -959,7 +990,8 @@ class Dictionary():
|
|
959
990
|
from topologicpy.Topology import Topology
|
960
991
|
|
961
992
|
if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
|
962
|
-
|
993
|
+
if not silent:
|
994
|
+
print("Dictionary.Values - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
963
995
|
return None
|
964
996
|
keys = None
|
965
997
|
if isinstance(dictionary, dict):
|
@@ -981,5 +1013,48 @@ class Dictionary():
|
|
981
1013
|
returnList.append(attr)
|
982
1014
|
return returnList
|
983
1015
|
|
1016
|
+
@staticmethod
|
1017
|
+
def ValuesAtKeys(dictionary, keys, defaultValue=None, silent: bool = False):
|
1018
|
+
"""
|
1019
|
+
Returns the list of values of the input list of keys in the input dictionary.
|
1020
|
+
|
1021
|
+
Parameters
|
1022
|
+
----------
|
1023
|
+
dictionary : topologic_core.Dictionary or dict
|
1024
|
+
The input dictionary.
|
1025
|
+
keys : list
|
1026
|
+
The input list of keys.
|
1027
|
+
defaultValue : any , optional
|
1028
|
+
The default value to return if the key or value are not found. The default is None.
|
1029
|
+
silent : bool , optional
|
1030
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
1031
|
+
|
1032
|
+
Returns
|
1033
|
+
-------
|
1034
|
+
list
|
1035
|
+
The list of values found at the input list of keys in the input dictionary.
|
1036
|
+
|
1037
|
+
"""
|
1038
|
+
from topologicpy.Topology import Topology
|
1039
|
+
|
1040
|
+
if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
|
1041
|
+
if not silent == True:
|
1042
|
+
print("Dictionary.ValuesAtKeys - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
1043
|
+
return None
|
1044
|
+
if not isinstance(keys, list):
|
1045
|
+
if not silent == True:
|
1046
|
+
print("Dictionary.ValuesAtKeys - Error: The input keys parameter is not a valid list. Returning None.")
|
1047
|
+
return None
|
1048
|
+
|
1049
|
+
local_keys = [k for k in keys if isinstance(k, str)]
|
1050
|
+
if len(local_keys) == 0:
|
1051
|
+
if not silent == True:
|
1052
|
+
print("Dictionary.ValuesAtKeys - Error: The input keys parameter does not contain valid key strings. Returning None.")
|
1053
|
+
return None
|
1054
|
+
if not len(local_keys) == len(keys):
|
1055
|
+
if not silent == True:
|
1056
|
+
print("Dictionary.ValuesAtKeys - Error: The input keys parameter contains invalid values. Returning None.")
|
1057
|
+
return None
|
1058
|
+
return [Dictionary.ValueAtKey(dictionary, key, defaultValue=defaultValue, silent=silent) for key in keys]
|
984
1059
|
|
985
1060
|
|
topologicpy/Topology.py
CHANGED
@@ -941,7 +941,68 @@ class Topology():
|
|
941
941
|
return Cluster.ByTopologies(return_list)
|
942
942
|
else:
|
943
943
|
return None
|
944
|
+
|
945
|
+
|
946
|
+
@staticmethod
|
947
|
+
def Inherit(targets, sources, keys: list = None, exclusive: bool = True, tolerance: float = 0.0001, silent: bool = False):
|
948
|
+
"""
|
949
|
+
Transfers dictionary information from topologiesB to topologiesA based on co-location of internal vertices.
|
950
|
+
|
951
|
+
Parameters
|
952
|
+
----------
|
953
|
+
targets : list of topologic_core.Topology
|
954
|
+
The list of target topologies that will inherit the dictionaries.
|
955
|
+
sources : list of topologic_core. Topology
|
956
|
+
The list of source topologies from which to inherit dictionary information.
|
957
|
+
exclusive : bool , optional
|
958
|
+
If set to True, a target will inherit information only from the first eligible source. The default is True.
|
959
|
+
tolerance : float , optional
|
960
|
+
The desired tolerance. The default is 0.0001.
|
961
|
+
silent : bool , optional
|
962
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
944
963
|
|
964
|
+
Returns
|
965
|
+
-------
|
966
|
+
list
|
967
|
+
The list of target topologies with the dictionary information inherited from the list of source topologies.
|
968
|
+
|
969
|
+
"""
|
970
|
+
from topologicpy.Topology import Topology
|
971
|
+
from topologicpy.Vertex import Vertex
|
972
|
+
from topologicpy.Dictionary import Dictionary
|
973
|
+
|
974
|
+
topologies_a = [a for a in targets if Topology.IsInstance(a, "Topology")]
|
975
|
+
if len(topologies_a) == 0:
|
976
|
+
if not silent:
|
977
|
+
print("Topology.Inherit - Error: The list of targets does not contain any valid topologies. Returning None.")
|
978
|
+
return None
|
979
|
+
topologies_b = [b for b in sources if Topology.IsInstance(b, "Topology")]
|
980
|
+
if len(topologies_b) == 0:
|
981
|
+
if not silent:
|
982
|
+
print("Topology.Inherit - Error: The list of sources does not contain any valid topologies. Returning None.")
|
983
|
+
return None
|
984
|
+
for i, top_a in enumerate(topologies_a):
|
985
|
+
iv = Topology.InternalVertex(top_a, tolerance=tolerance, silent=silent)
|
986
|
+
d_a = Topology.Dictionary(top_a, silent=silent)
|
987
|
+
found = False
|
988
|
+
for j, top_b in enumerate(topologies_b):
|
989
|
+
if Vertex.IsInternal(iv, top_b, tolerance=tolerance, silent=silent):
|
990
|
+
d_b = Topology.Dictionary(top_b)
|
991
|
+
if isinstance(keys, list):
|
992
|
+
values = Dictionary.ValuesAtKeys(d_b, keys, silent=silent)
|
993
|
+
d_c = Dictionary.ByKeysValues(keys, values)
|
994
|
+
d_a = Dictionary.ByMergedDictionaries(d_a, d_c, silent=silent)
|
995
|
+
else:
|
996
|
+
d_a = Dictionary.ByMergedDictionaries(d_a, d_b, silent=silent)
|
997
|
+
top_a = Topology.SetDictionary(top_a, d_a, silent=silent)
|
998
|
+
found = True
|
999
|
+
if exclusive:
|
1000
|
+
break
|
1001
|
+
if found == False:
|
1002
|
+
if not silent:
|
1003
|
+
print("Topology.Inherit - Warning: Could not find a source for target number: "+str(i+1)+". Consider increasing the tolerance value.")
|
1004
|
+
return targets
|
1005
|
+
|
945
1006
|
@staticmethod
|
946
1007
|
def Intersect(topologyA, topologyB, tranDict=False, tolerance=0.0001):
|
947
1008
|
"""
|
@@ -4144,7 +4205,7 @@ class Topology():
|
|
4144
4205
|
return round(max_distance, mantissa)
|
4145
4206
|
|
4146
4207
|
@staticmethod
|
4147
|
-
def Dictionary(topology):
|
4208
|
+
def Dictionary(topology, silent: bool = False):
|
4148
4209
|
"""
|
4149
4210
|
Returns the dictionary of the input topology
|
4150
4211
|
|
@@ -4152,6 +4213,8 @@ class Topology():
|
|
4152
4213
|
----------
|
4153
4214
|
topology : topologic_core.Topology
|
4154
4215
|
The input topology.
|
4216
|
+
silent : bool , optional
|
4217
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
4155
4218
|
|
4156
4219
|
Returns
|
4157
4220
|
-------
|
@@ -4160,12 +4223,13 @@ class Topology():
|
|
4160
4223
|
|
4161
4224
|
"""
|
4162
4225
|
if not Topology.IsInstance(topology, "Topology") and not Topology.IsInstance(topology, "Graph"):
|
4163
|
-
|
4226
|
+
if not silent:
|
4227
|
+
print("Topology.Dictionary - Error: the input topology parameter is not a valid topology. Returning None.")
|
4164
4228
|
return None
|
4165
4229
|
return topology.GetDictionary()
|
4166
4230
|
|
4167
4231
|
@staticmethod
|
4168
|
-
def Dimensionality(topology):
|
4232
|
+
def Dimensionality(topology, silent: bool = False):
|
4169
4233
|
"""
|
4170
4234
|
Returns the dimensionality of the input topology
|
4171
4235
|
|
@@ -4173,6 +4237,8 @@ class Topology():
|
|
4173
4237
|
----------
|
4174
4238
|
topology : topologic_core.Topology
|
4175
4239
|
The input topology.
|
4240
|
+
silent : bool , optional
|
4241
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
4176
4242
|
|
4177
4243
|
Returns
|
4178
4244
|
-------
|
@@ -4181,12 +4247,13 @@ class Topology():
|
|
4181
4247
|
|
4182
4248
|
"""
|
4183
4249
|
if not Topology.IsInstance(topology, "Topology"):
|
4184
|
-
|
4250
|
+
if not silent:
|
4251
|
+
print("Topology.Dimensionality - Error: the input topology parameter is not a valid topology. Returning None.")
|
4185
4252
|
return None
|
4186
4253
|
return topology.Dimensionality()
|
4187
4254
|
|
4188
4255
|
@staticmethod
|
4189
|
-
def Divide(topologyA, topologyB, transferDictionary=False, addNestingDepth=False):
|
4256
|
+
def Divide(topologyA, topologyB, transferDictionary=False, addNestingDepth=False, silent: bool = False):
|
4190
4257
|
"""
|
4191
4258
|
Divides the input topology by the input tool and places the results in the contents of the input topology.
|
4192
4259
|
|
@@ -4200,6 +4267,8 @@ class Topology():
|
|
4200
4267
|
If set to True the dictionary of the input topology is transferred to the divided topologies.
|
4201
4268
|
addNestingDepth : bool , optional
|
4202
4269
|
If set to True the nesting depth of the division is added to the dictionaries of the divided topologies.
|
4270
|
+
silent : bool , optional
|
4271
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
4203
4272
|
|
4204
4273
|
Returns
|
4205
4274
|
-------
|
@@ -4210,13 +4279,15 @@ class Topology():
|
|
4210
4279
|
from topologicpy.Dictionary import Dictionary
|
4211
4280
|
|
4212
4281
|
if not Topology.IsInstance(topologyA, "Topology"):
|
4213
|
-
|
4282
|
+
if not silent:
|
4283
|
+
print("Topology.Divide - Error: the input topologyA parameter is not a valid topology. Returning None.")
|
4214
4284
|
return None
|
4215
4285
|
if not Topology.IsInstance(topologyB, "Topology"):
|
4216
|
-
|
4286
|
+
if not silent:
|
4287
|
+
print("Topology.Divide - Error: the input topologyB parameter is not a valid topology. Returning None.")
|
4217
4288
|
return None
|
4218
4289
|
try:
|
4219
|
-
_ = topologyA.Divide(topologyB, False) # Don't transfer dictionaries just yet
|
4290
|
+
_ = topologyA.Divide(topologyB, False) # Don't transfer dictionaries just yet # Hook to Core
|
4220
4291
|
except:
|
4221
4292
|
raise Exception("TopologyDivide - Error: Divide operation failed.")
|
4222
4293
|
nestingDepth = "1"
|
@@ -4251,7 +4322,7 @@ class Topology():
|
|
4251
4322
|
_ = Topology.SetDictionary(topologyA, parentDictionary)
|
4252
4323
|
values[keys.index("nesting_depth")] = nestingDepth+"_"+str(i+1)
|
4253
4324
|
d = Dictionary.ByKeysValues(keys, values)
|
4254
|
-
_ = contents[i].SetDictionary(d)
|
4325
|
+
_ = contents[i].SetDictionary(d) # Hook to Core
|
4255
4326
|
if addNestingDepth and not transferDictionary:
|
4256
4327
|
parentDictionary = Topology.Dictionary(topologyA)
|
4257
4328
|
if parentDictionary != None:
|
@@ -4275,7 +4346,7 @@ class Topology():
|
|
4275
4346
|
return topologyA
|
4276
4347
|
|
4277
4348
|
@staticmethod
|
4278
|
-
def Explode(topology, origin=None, scale: float = 1.25, typeFilter: str = None, axes: str = "xyz", transferDictionaries: bool = False, mantissa: int = 6, tolerance: float = 0.0001):
|
4349
|
+
def Explode(topology, origin=None, scale: float = 1.25, typeFilter: str = None, axes: str = "xyz", transferDictionaries: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
|
4279
4350
|
"""
|
4280
4351
|
Explodes the input topology. See https://en.wikipedia.org/wiki/Exploded-view_drawing.
|
4281
4352
|
|
@@ -4297,6 +4368,8 @@ class Topology():
|
|
4297
4368
|
The desired length of the mantissa. The default is 6.
|
4298
4369
|
tolerance : float , optional
|
4299
4370
|
The desired tolerance. The default is 0.0001.
|
4371
|
+
silent : bool , optional
|
4372
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
4300
4373
|
|
4301
4374
|
Returns
|
4302
4375
|
-------
|
@@ -4348,27 +4421,31 @@ class Topology():
|
|
4348
4421
|
return typeFilter
|
4349
4422
|
|
4350
4423
|
if not Topology.IsInstance(topology, "Topology"):
|
4351
|
-
|
4424
|
+
if not silent:
|
4425
|
+
print("Topology.Explode - Error: the input topology parameter is not a valid topology. Returning None.")
|
4352
4426
|
return None
|
4353
4427
|
if not Topology.IsInstance(origin, "Vertex"):
|
4354
4428
|
origin = Topology.CenterOfMass(topology)
|
4355
4429
|
if not typeFilter:
|
4356
4430
|
typeFilter = getTypeFilter(topology)
|
4357
4431
|
if not isinstance(typeFilter, str):
|
4358
|
-
|
4432
|
+
if not silent:
|
4433
|
+
print("Topology.Explode - Error: the input typeFilter parameter is not a valid string. Returning None.")
|
4359
4434
|
return None
|
4360
4435
|
if not isinstance(axes, str):
|
4361
|
-
|
4436
|
+
if not silent:
|
4437
|
+
print("Topology.Explode - Error: the input axes parameter is not a valid string. Returning None.")
|
4362
4438
|
return None
|
4363
|
-
if Topology.IsInstance(topology, "Topology"):
|
4364
|
-
|
4365
|
-
|
4439
|
+
# if Topology.IsInstance(topology, "Topology"):
|
4440
|
+
# # Hack to fix a weird bug that seems to be a problem with OCCT memory handling.
|
4441
|
+
# topology = Topology.ByJSONString(Topology.JSONString([topology]))[0]
|
4366
4442
|
axes = axes.lower()
|
4367
4443
|
x_flag = "x" in axes
|
4368
4444
|
y_flag = "y" in axes
|
4369
4445
|
z_flag = "z" in axes
|
4370
4446
|
if not x_flag and not y_flag and not z_flag:
|
4371
|
-
|
4447
|
+
if not silent:
|
4448
|
+
print("Topology.Explode - Error: the input axes parameter is not a valid string. Returning None.")
|
4372
4449
|
return None
|
4373
4450
|
|
4374
4451
|
topologies = []
|
@@ -4405,7 +4482,7 @@ class Topology():
|
|
4405
4482
|
if transferDictionaries == True:
|
4406
4483
|
newTopology = Topology.SetDictionary(newTopology, Topology.Dictionary(aTopology))
|
4407
4484
|
newTopologies.append(newTopology)
|
4408
|
-
return Cluster.ByTopologies(newTopologies)
|
4485
|
+
return Cluster.ByTopologies(newTopologies, silent=silent)
|
4409
4486
|
|
4410
4487
|
@staticmethod
|
4411
4488
|
def ExportToBIM(topologies, path : str, overwrite: bool = False, version: str = "1.0.0",
|
topologicpy/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.8.
|
1
|
+
__version__ = '0.8.44'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: topologicpy
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.44
|
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
|
@@ -5,10 +5,10 @@ topologicpy/CSG.py,sha256=uDkOSmc8m1V_k7T3UCerODhOSyYNO4FRDzoOqt0kEt8,15590
|
|
5
5
|
topologicpy/Cell.py,sha256=M4Xv4gabSgtKYYA-Wh0lgYEbRNRVF9zr4DYejOXJc-4,176278
|
6
6
|
topologicpy/CellComplex.py,sha256=c2B3mF1c3iwOfT-V0JWt9qNcFdd6DPR0aBOE2UnZTn4,61165
|
7
7
|
topologicpy/Cluster.py,sha256=wvfMAx6aPrSAt5nQ4--KnqD4EK9MGjch6Dg985WF7JQ,58748
|
8
|
-
topologicpy/Color.py,sha256=
|
8
|
+
topologicpy/Color.py,sha256=OTtXo9htNuOqZaZZpfK5BoLsJFJssauk3jbHzIBnWx8,24518
|
9
9
|
topologicpy/Context.py,sha256=G3CwMvN8Jw2rnQRwB-n4MaQq_wLS0vPimbXKwsdMJ80,3055
|
10
10
|
topologicpy/DGL.py,sha256=HQXy9iDnrvWGDxaBfe5pRbweQ2zLBvAf6UdjfhKkQYI,139041
|
11
|
-
topologicpy/Dictionary.py,sha256=
|
11
|
+
topologicpy/Dictionary.py,sha256=sPskW5bopbDzLz6MGKm8lN_OeyeAgsqdLvwwNcG0J3g,44690
|
12
12
|
topologicpy/Edge.py,sha256=dLoAPuRKbjVg_dzloTgjRnQyv_05U9nfrtLO3tqyuys,74167
|
13
13
|
topologicpy/EnergyModel.py,sha256=Pyb28gDDwhzlQIH0xqAygqS0P3SJxWyyV7OWS_AAfRs,53856
|
14
14
|
topologicpy/Face.py,sha256=pN1fssyDLYWf1vU0NOBRx69DaUL958wRSxT-7VBCuCg,203184
|
@@ -25,14 +25,14 @@ topologicpy/ShapeGrammar.py,sha256=UVb8VPwVKd6V3zDTNzpBecQPgYo1EjSsS10XJ8k5YcI,2
|
|
25
25
|
topologicpy/Shell.py,sha256=fx0WTndC8blkvWe38nKsJsI_AmklOA0qsjU0gbZp4b4,90501
|
26
26
|
topologicpy/Speckle.py,sha256=-eiTqJugd7pHiHpD3pDUcDO6CGhVyPV14HFRzaqEoaw,18187
|
27
27
|
topologicpy/Sun.py,sha256=_VBBAUIDhvpkp72JBZlv7k9qx9jYubm3yM56UZ1Nc6c,36837
|
28
|
-
topologicpy/Topology.py,sha256
|
28
|
+
topologicpy/Topology.py,sha256=-9hsN1PSvhH7qDo1HXjd545xteRZZY7-fxtxoBtU1Tw,471584
|
29
29
|
topologicpy/Vector.py,sha256=X12eqskn28bdB7sLY1EZhq3noPYzPbNEgHPb4a959ss,42302
|
30
30
|
topologicpy/Vertex.py,sha256=RlGQnxQSb_kAus3tJgXd-v-Ptubtt09PQPA9IMwfXmI,84835
|
31
31
|
topologicpy/Wire.py,sha256=sJE8qwqYOomvN3snMWmj2P2-Sq25ul_OQ95YFz6DFUw,230553
|
32
32
|
topologicpy/__init__.py,sha256=RMftibjgAnHB1vdL-muo71RwMS4972JCxHuRHOlU428,928
|
33
|
-
topologicpy/version.py,sha256=
|
34
|
-
topologicpy-0.8.
|
35
|
-
topologicpy-0.8.
|
36
|
-
topologicpy-0.8.
|
37
|
-
topologicpy-0.8.
|
38
|
-
topologicpy-0.8.
|
33
|
+
topologicpy/version.py,sha256=H1GigrgdekxMys9lmJxIRnIFrNk4zrmX7xz5PrqPdxE,23
|
34
|
+
topologicpy-0.8.44.dist-info/licenses/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
|
35
|
+
topologicpy-0.8.44.dist-info/METADATA,sha256=YU_ze05mFUZrce4XzGuVddWEEOzOM_oTPndhJHejKC0,10535
|
36
|
+
topologicpy-0.8.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
37
|
+
topologicpy-0.8.44.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
|
38
|
+
topologicpy-0.8.44.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|