topologicpy 0.4.87__py3-none-any.whl → 0.4.89__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/Graph.py CHANGED
@@ -4112,7 +4112,11 @@ class Graph:
4112
4112
  if not key in node_attributes.keys():
4113
4113
  node_attributes[key] = valueType(values[m])
4114
4114
  if isinstance(values[m], str):
4115
- values[m] = values[m].replace('&','_and_')
4115
+ values[m] = values[m].replace('&','&')
4116
+ values[m] = values[m].replace('<','&lt;')
4117
+ values[m] = values[m].replace('>','&gt;')
4118
+ values[m] = values[m].replace('"','&quot;')
4119
+ values[m] = values[m].replace('\'','&apos;')
4116
4120
  node_dict[key] = values[m]
4117
4121
  dict_color = None
4118
4122
  if not defaultVertexColor in Color.CSSNamedColors():
@@ -4148,6 +4152,12 @@ class Graph:
4148
4152
  vertex_label = Dictionary.ValueAtKey(d, vertexLabelKey)
4149
4153
  if not isinstance(vertex_label, str):
4150
4154
  vertex_label = "Node "+str(i)
4155
+ if isinstance(vertex_label, str):
4156
+ vertex_label = vertex_label.replace('&','&amp;')
4157
+ vertex_label = vertex_label.replace('<','&lt;')
4158
+ vertex_label = vertex_label.replace('>','&gt;')
4159
+ vertex_label = vertex_label.replace('"','&quot;')
4160
+ vertex_label = vertex_label.replace('\'','&apos;')
4151
4161
  node_dict['label'] = vertex_label
4152
4162
 
4153
4163
  nodes[i] = node_dict
@@ -5036,12 +5046,14 @@ class Graph:
5036
5046
  for edge in Topology.Edges(temp_path):
5037
5047
  new_edges.append(g_edges[Edge.Index(edge, g_edges)])
5038
5048
  longest_path = Topology.SelfMerge(Cluster.ByTopologies(new_edges), tolerance=tolerance)
5049
+
5039
5050
  sv = Topology.Vertices(longest_path)[0]
5040
5051
  if Vertex.Distance(sv, vertexB) < tolerance: # Wire is reversed. Re-reverse it
5041
5052
  if isinstance(longest_path, topologic.Edges):
5042
5053
  longest_path = Edge.Reverse(longest_path)
5043
5054
  if isinstance(longest_path, topologic.Wire):
5044
5055
  longest_path = Wire.Reverse(longest_path)
5056
+ longest_path = Wire.OrientEdges(longest_path, Wire.StartVertex(longest_path), tolerance=tolerance)
5045
5057
  if not costKey == None:
5046
5058
  lengths.sort()
5047
5059
  d = Dictionary.ByKeysValues([costKey], [cost])
@@ -5692,7 +5704,7 @@ class Graph:
5692
5704
  return scores
5693
5705
 
5694
5706
  @staticmethod
5695
- def Path(graph, vertexA, vertexB):
5707
+ def Path(graph, vertexA, vertexB, tolerance=0.0001):
5696
5708
  """
5697
5709
  Returns a path (wire) in the input graph that connects the input vertices.
5698
5710
 
@@ -5704,6 +5716,8 @@ class Graph:
5704
5716
  The first input vertex.
5705
5717
  vertexB : topologic.Vertex
5706
5718
  The second input vertex.
5719
+ tolerance : float, optional
5720
+ The desired tolerance. The default is 0.0001.
5707
5721
 
5708
5722
  Returns
5709
5723
  -------
@@ -5711,6 +5725,8 @@ class Graph:
5711
5725
  The path (wire) in the input graph that connects the input vertices.
5712
5726
 
5713
5727
  """
5728
+ from topologicpy.Wire import Wire
5729
+
5714
5730
  if not isinstance(graph, topologic.Graph):
5715
5731
  print("Graph.Path - Error: The input graph is not a valid graph. Returning None.")
5716
5732
  return None
@@ -5720,7 +5736,11 @@ class Graph:
5720
5736
  if not isinstance(vertexB, topologic.Vertex):
5721
5737
  print("Graph.Path - Error: The input vertexB is not a valid vertex. Returning None.")
5722
5738
  return None
5723
- return graph.Path(vertexA, vertexB)
5739
+ path = graph.Path(vertexA, vertexB)
5740
+ if isinstance(path, topologic.Wire):
5741
+ path = Wire.OrientEdges(path, Wire.StartVertex(path), tolerance=tolerance)
5742
+ return path
5743
+
5724
5744
 
5725
5745
  @staticmethod
5726
5746
  def PyvisGraph(graph, path, overwrite=True, height=900, backgroundColor="white", fontColor="black", notebook=False,
@@ -6046,6 +6066,7 @@ class Graph:
6046
6066
  if Vertex.Distance(sv, gev) < tolerance: # Path is reversed. Correct it.
6047
6067
  if isinstance(shortest_path, topologic.Wire):
6048
6068
  shortest_path = Wire.Reverse(shortest_path)
6069
+ shortest_path = Wire.OrientEdges(shortest_path, Wire.StartVertex(shortest_path), tolerance=tolerance)
6049
6070
  return shortest_path
6050
6071
  except:
6051
6072
  return None
topologicpy/Wire.py CHANGED
@@ -281,6 +281,8 @@ class Wire(Topology):
281
281
  if not isinstance(wire, topologic.Wire):
282
282
  print("Wire.ByEdges - Error: The operation failed. Returning None.")
283
283
  wire = None
284
+ if Wire.IsManifold(wire):
285
+ wire = Wire.OrientEdges(wire, Wire.StartVertex(wire), tolerance=tolerance)
284
286
  return wire
285
287
 
286
288
  @staticmethod
@@ -567,7 +569,10 @@ class Wire(Topology):
567
569
  if len(edges) < 1:
568
570
  print("Wire.ByVertices - Error: The number of edges is less than 1. Returning None.")
569
571
  return None
570
- wire = Topology.SelfMerge(Cluster.ByTopologies(edges), tolerance=tolerance)
572
+ elif len(edges) == 1:
573
+ wire = topologic.Wire.ByEdges(edges)
574
+ else:
575
+ wire = Topology.SelfMerge(Cluster.ByTopologies(edges), tolerance=tolerance)
571
576
  return wire
572
577
 
573
578
  @staticmethod
@@ -1953,6 +1958,65 @@ class Wire(Topology):
1953
1958
  vertices.append(Edge.EndVertex(edge))
1954
1959
  return Wire.ByVertices(vertices)
1955
1960
 
1961
+ @staticmethod
1962
+ def OrientEdges(wire, vertexA, tolerance=0.0001):
1963
+ """
1964
+ Returns a correctly oriented head-to-tail version of the input wire. The input wire must be manifold.
1965
+
1966
+ Parameters
1967
+ ----------
1968
+ wire : topologic.Wire
1969
+ The input wire.
1970
+ vertexA : topologic.Vertex
1971
+ The desired start vertex of the wire.
1972
+ tolerance : float, optional
1973
+ The desired tolerance. The default is 0.0001.
1974
+
1975
+ Returns
1976
+ -------
1977
+ topologic.Wire
1978
+ The oriented wire.
1979
+
1980
+ """
1981
+ from topologicpy.Vertex import Vertex
1982
+ from topologicpy.Edge import Edge
1983
+
1984
+ if not isinstance(wire, topologic.Wire):
1985
+ print("Wire.OrientEdges - Error: The input wire parameter is not a valid wire. Returning None.")
1986
+ return None
1987
+ if not isinstance(vertexA, topologic.Vertex):
1988
+ print("Wire.OrientEdges - Error: The input vertexA parameter is not a valid vertex. Returning None.")
1989
+ return None
1990
+ if not Wire.IsManifold(wire):
1991
+ print("Wire.OrientEdges - Error: The input wire parameter is not a manifold wire. Returning None.")
1992
+ return None
1993
+ oriented_edges = []
1994
+ remaining_edges = Topology.Edges(wire)
1995
+
1996
+ current_vertex = vertexA
1997
+ while remaining_edges:
1998
+ next_edge = None
1999
+ for edge in remaining_edges:
2000
+ if Vertex.Distance(Edge.StartVertex(edge), current_vertex) < tolerance:
2001
+ next_edge = edge
2002
+ break
2003
+ elif Vertex.Distance(Edge.EndVertex(edge), current_vertex) < tolerance:
2004
+ next_edge = Edge.Reverse(edge)
2005
+ break
2006
+
2007
+ if next_edge:
2008
+ oriented_edges.append(next_edge)
2009
+ remaining_edges.remove(next_edge)
2010
+ current_vertex = Edge.EndVertex(next_edge)
2011
+ else:
2012
+ # Unable to find a next edge connected to the current vertex
2013
+ break
2014
+ vertices = [Edge.StartVertex(oriented_edges[0])]
2015
+ for i, edge in enumerate(oriented_edges):
2016
+ vertices.append(Edge.EndVertex(edge))
2017
+
2018
+ return Wire.ByVertices(vertices, close=Wire.IsClosed(wire))
2019
+
1956
2020
  @staticmethod
1957
2021
  def Planarize(wire: topologic.Wire, origin: topologic.Vertex = None, mantissa: int = 6, tolerance: float = 0.0001) -> topologic.Wire:
1958
2022
  """
topologicpy/__init__.py CHANGED
@@ -18,7 +18,7 @@ import sys
18
18
  import os, re
19
19
  from sys import platform
20
20
 
21
- __version__ = '0.4.87'
21
+ __version__ = '0.4.89'
22
22
  __version_info__ = tuple([ int(num) for num in __version__.split('.')])
23
23
 
24
24
  if platform == 'win32':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: topologicpy
3
- Version: 0.4.87
3
+ Version: 0.4.89
4
4
  Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/wassimj/TopologicPy
@@ -9,7 +9,7 @@ topologicpy/Dictionary.py,sha256=vGhiXPu7e7GsgQyTsX6rZBncnnrDlcYfM9xRb9h-l3U,247
9
9
  topologicpy/Edge.py,sha256=425HQJyERHdaCnr7mi5Nbdk8jSuupKyGXE9td01MN7k,45693
10
10
  topologicpy/EnergyModel.py,sha256=kl8N-6NsKwKeSUt6vWm0B-MBacw9vMymE6lbvymJdVM,51758
11
11
  topologicpy/Face.py,sha256=uQyrXVtFQYlYZxiywl1S4cCHIAfQMbgeJ40Af34-CmI,93617
12
- topologicpy/Graph.py,sha256=-1Zfs-yvawMDIhYqo9bmsnKlqqRGXpDadCdlLbbcO3M,314209
12
+ topologicpy/Graph.py,sha256=rq0ZStL-1xGOUFGeOsFuUOUP8dSlurWtY-uuLx2C_5c,315393
13
13
  topologicpy/Grid.py,sha256=q6uAs8MGbdteYNbjqRjqlhFMquYAvSngwzxsFl9-338,17371
14
14
  topologicpy/Helper.py,sha256=vqBZE-CcHBeTCnzC9OzbRaCTx4XT4SZpPF__Vi19nDQ,16049
15
15
  topologicpy/Honeybee.py,sha256=ygiGMS7u-YQJWpK2CmkBuJu1DBABVUmpMdg9HewOhN4,20349
@@ -22,8 +22,8 @@ topologicpy/Speckle.py,sha256=zKqiHYuw7498W_9UWvDn2xsdBskhahNjJejxegMpbJA,14773
22
22
  topologicpy/Topology.py,sha256=6Pga5O3_awhRUMxF8_JiNOPgSWmCmqTVDfnJygnTtZk,287822
23
23
  topologicpy/Vector.py,sha256=57ZoYLd3chEQhjN8Sf1Wv_UR3klltLoaT8TQN0kP-f8,22166
24
24
  topologicpy/Vertex.py,sha256=A7hCI-WpHaemow4eDiaqVhZ0ekgifXcWFpa-82txwYM,55187
25
- topologicpy/Wire.py,sha256=l7EfmBuwl6qMsklkIMj24Mvgb2342YRHPSEdooHYFsw,134108
26
- topologicpy/__init__.py,sha256=6NwR2-LQXfDa6p91s3dhQS9tQi3sjhwxoHf2rgejCmo,1445
25
+ topologicpy/Wire.py,sha256=pM63N7c0YoNRNvMtt05CPY8bzP62BG5rFTerA0eELIc,136664
26
+ topologicpy/__init__.py,sha256=Y_R-8dvvLH7g2os2OWB_Swtrqf1jK5lFBmVvLWw5caA,1445
27
27
  topologicpy/bin/linux/topologic/__init__.py,sha256=XlFReDf3FWlYdM9uXtanYPIafgPb6GVTQczS_xJAXD0,60
28
28
  topologicpy/bin/linux/topologic/libTKBO-6bdf205d.so.7.7.0,sha256=ANok9DQKcnWcLd9T_LAt-i-X4nsYYy16q9kQlcTre1E,2996488
29
29
  topologicpy/bin/linux/topologic/libTKBRep-2960a069.so.7.7.0,sha256=OJ3XesL79du8LeBHrsleGPXub6OpJdOilxha0mwjqQo,1378768
@@ -84,8 +84,8 @@ topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd,sha256=F0sPLuMpD
84
84
  topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd,sha256=aBAJQj3OmJ58MOAF1ZIFybL_5fFK7FNR9hrIps6b6pc,1551872
85
85
  topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd,sha256=aLgNf54nbJmGc7Tdmkuy-V0m6B9zLxabIbpRwAy7cBA,1551360
86
86
  topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd,sha256=_8cp205hiRxkFHtzQQOweA4DhCPk8caH4kTVLWGQeVw,1411584
87
- topologicpy-0.4.87.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
- topologicpy-0.4.87.dist-info/METADATA,sha256=ccCHulZrPy4cw_e9eXmUmQpEZFJNscXiYvEHstT8NG4,7278
89
- topologicpy-0.4.87.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
- topologicpy-0.4.87.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
- topologicpy-0.4.87.dist-info/RECORD,,
87
+ topologicpy-0.4.89.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
+ topologicpy-0.4.89.dist-info/METADATA,sha256=ZZRlJuY_SBnyqOUJAqYHr89-yPq-neQwL-Sx8XTbOBQ,7278
89
+ topologicpy-0.4.89.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
+ topologicpy-0.4.89.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
+ topologicpy-0.4.89.dist-info/RECORD,,