topologicpy 0.8.43__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 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 AverageHex(*colors, silent: bool = False):
95
+ def Average(*colors, silent: bool = False):
60
96
  """
61
97
  Averages the input list of hex colors.
62
98
 
topologicpy/Topology.py CHANGED
@@ -944,7 +944,7 @@ class Topology():
944
944
 
945
945
 
946
946
  @staticmethod
947
- def Inherit(targets, sources, keys: list = None, tolerance: float = 0.0001, silent: bool = False):
947
+ def Inherit(targets, sources, keys: list = None, exclusive: bool = True, tolerance: float = 0.0001, silent: bool = False):
948
948
  """
949
949
  Transfers dictionary information from topologiesB to topologiesA based on co-location of internal vertices.
950
950
 
@@ -954,6 +954,8 @@ class Topology():
954
954
  The list of target topologies that will inherit the dictionaries.
955
955
  sources : list of topologic_core. Topology
956
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.
957
959
  tolerance : float , optional
958
960
  The desired tolerance. The default is 0.0001.
959
961
  silent : bool , optional
@@ -983,17 +985,19 @@ class Topology():
983
985
  iv = Topology.InternalVertex(top_a, tolerance=tolerance, silent=silent)
984
986
  d_a = Topology.Dictionary(top_a, silent=silent)
985
987
  found = False
986
- for top_b in topologies_b:
988
+ for j, top_b in enumerate(topologies_b):
987
989
  if Vertex.IsInternal(iv, top_b, tolerance=tolerance, silent=silent):
988
990
  d_b = Topology.Dictionary(top_b)
989
991
  if isinstance(keys, list):
990
992
  values = Dictionary.ValuesAtKeys(d_b, keys, silent=silent)
991
- d_c = Dictionary.SetValuesAtKeys(d_a, keys, values, silent=silent)
993
+ d_c = Dictionary.ByKeysValues(keys, values)
994
+ d_a = Dictionary.ByMergedDictionaries(d_a, d_c, silent=silent)
992
995
  else:
993
- d_c = Dictionary.SetValuesAtKeys(d_a, Dictionary.Keys(d_b, silent=silent), Dictionary.Values(d_b, silent=silent))
994
- top_a = Topology.SetDictionary(top_a, d_c, silent=silent)
996
+ d_a = Dictionary.ByMergedDictionaries(d_a, d_b, silent=silent)
997
+ top_a = Topology.SetDictionary(top_a, d_a, silent=silent)
995
998
  found = True
996
- break
999
+ if exclusive:
1000
+ break
997
1001
  if found == False:
998
1002
  if not silent:
999
1003
  print("Topology.Inherit - Warning: Could not find a source for target number: "+str(i+1)+". Consider increasing the tolerance value.")
@@ -4432,9 +4436,9 @@ class Topology():
4432
4436
  if not silent:
4433
4437
  print("Topology.Explode - Error: the input axes parameter is not a valid string. Returning None.")
4434
4438
  return None
4435
- if Topology.IsInstance(topology, "Topology"):
4436
- # Hack to fix a weird bug that seems to be a problem with OCCT memory handling.
4437
- topology = Topology.ByJSONString(Topology.JSONString([topology]))[0]
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]
4438
4442
  axes = axes.lower()
4439
4443
  x_flag = "x" in axes
4440
4444
  y_flag = "y" in axes
topologicpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.8.43'
1
+ __version__ = '0.8.44'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: topologicpy
3
- Version: 0.8.43
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,7 +5,7 @@ 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=FcR0-__giyGQqvgiOrG8GkA65arHbiS33Si-QbUADPI,23362
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
11
  topologicpy/Dictionary.py,sha256=sPskW5bopbDzLz6MGKm8lN_OeyeAgsqdLvwwNcG0J3g,44690
@@ -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=tl5VTJIG3lZfIZ88nN9-tzE571gc8FxFqDF4t_Yuekw,471333
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=hF3_b4wm6P2C7FhxNisjLlDWfDYZXkMWBDfjYGulhT4,23
34
- topologicpy-0.8.43.dist-info/licenses/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
35
- topologicpy-0.8.43.dist-info/METADATA,sha256=5dzgC4p5xWYC7uU9VOqvU-PT1fTDCOqSl_5uGk97oZQ,10535
36
- topologicpy-0.8.43.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- topologicpy-0.8.43.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
38
- topologicpy-0.8.43.dist-info/RECORD,,
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,,