topologicpy 0.7.93__py3-none-any.whl → 0.7.96__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/Face.py CHANGED
@@ -1124,6 +1124,123 @@ class Face():
1124
1124
  dirA = Face.Normal(face, outputType="xyz", mantissa=mantissa)
1125
1125
  return Vector.CompassAngle(vectorA=dirA, vectorB=north, mantissa=mantissa, tolerance=tolerance)
1126
1126
 
1127
+ @staticmethod
1128
+ def CShape(origin=None,
1129
+ width=1,
1130
+ length=1,
1131
+ a=0.25,
1132
+ b=0.25,
1133
+ c=0.25,
1134
+ flipHorizontal = False,
1135
+ flipVertical = False,
1136
+ direction=[0,0,1],
1137
+ placement="center",
1138
+ tolerance=0.0001,
1139
+ silent=False):
1140
+ """
1141
+ Creates a C-shape.
1142
+
1143
+ Parameters
1144
+ ----------
1145
+ origin : topologic_core.Vertex , optional
1146
+ The location of the origin of the C-shape. The default is None which results in the C-shape being placed at (0, 0, 0).
1147
+ width : float , optional
1148
+ The overall width of the C-shape. The default is 1.0.
1149
+ length : float , optional
1150
+ The overall length of the C-shape. The default is 1.0.
1151
+ a : float , optional
1152
+ The hortizontal thickness of the vertical arm of the C-shape. The default is 0.25.
1153
+ b : float , optional
1154
+ The vertical thickness of the bottom horizontal arm of the C-shape. The default is 0.25.
1155
+ c : float , optional
1156
+ The vertical thickness of the top horizontal arm of the C-shape. The default is 0.25.
1157
+ direction : list , optional
1158
+ The vector representing the up direction of the C-shape. The default is [0, 0, 1].
1159
+ placement : str , optional
1160
+ The description of the placement of the origin of the C-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
1161
+ tolerance : float , optional
1162
+ The desired tolerance. The default is 0.0001.
1163
+ silent : bool , optional
1164
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
1165
+
1166
+ Returns
1167
+ -------
1168
+ topologic_core.Face
1169
+ The created C-shape.
1170
+
1171
+ """
1172
+ from topologicpy.Vertex import Vertex
1173
+ from topologicpy.Wire import Wire
1174
+ from topologicpy.Topology import Topology
1175
+
1176
+ if not isinstance(width, int) and not isinstance(width, float):
1177
+ if not silent:
1178
+ print("Face.CShape - Error: The width input parameter is not a valid number. Returning None.")
1179
+ return None
1180
+ if not isinstance(length, int) and not isinstance(length, float):
1181
+ if not silent:
1182
+ print("Face.CShape - Error: The length input parameter is not a valid number. Returning None.")
1183
+ return None
1184
+ if not isinstance(a, int) and not isinstance(a, float):
1185
+ if not silent:
1186
+ print("Face.CShape - Error: The a input parameter is not a valid number. Returning None.")
1187
+ return None
1188
+ if not isinstance(b, int) and not isinstance(b, float):
1189
+ if not silent:
1190
+ print("Face.CShape - Error: The b input parameter is not a valid number. Returning None.")
1191
+ return None
1192
+ if width <= tolerance:
1193
+ if not silent:
1194
+ print("Face.CShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1195
+ return None
1196
+ if length <= tolerance:
1197
+ if not silent:
1198
+ print("Face.CShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1199
+ return None
1200
+ if a <= tolerance:
1201
+ if not silent:
1202
+ print("Face.CShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1203
+ return None
1204
+ if b <= tolerance:
1205
+ if not silent:
1206
+ print("Face.CShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1207
+ return None
1208
+ if a >= (width - tolerance):
1209
+ if not silent:
1210
+ print("Face.CShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
1211
+ return None
1212
+ if b+c >= (length - tolerance):
1213
+ if not silent:
1214
+ print("Face.CShape - Error: The b and c input parameters must add to less than the length input parameter. Returning None.")
1215
+ return None
1216
+ if origin == None:
1217
+ origin = Vertex.Origin()
1218
+ if not Topology.IsInstance(origin, "vertex"):
1219
+ if not silent:
1220
+ print("Face.CShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
1221
+ return None
1222
+ if not isinstance(direction, list):
1223
+ if not silent:
1224
+ print("Face.CShape - Error: The direction input parameter is not a valid list. Returning None.")
1225
+ return None
1226
+ if not len(direction) == 3:
1227
+ if not silent:
1228
+ print("Face.CShape - Error: The direction input parameter is not a valid vector. Returning None.")
1229
+ return None
1230
+ c_shape_wire = Wire.CShape(origin=origin,
1231
+ width=width,
1232
+ length=length,
1233
+ a=a,
1234
+ b=b,
1235
+ c=c,
1236
+ flipHorizontal=flipHorizontal,
1237
+ flipVertical=flipVertical,
1238
+ direction=direction,
1239
+ placement=placement,
1240
+ tolerance=tolerance,
1241
+ silent=silent)
1242
+ return Face.ByWire(c_shape_wire, tolerance=tolerance, silent=silent)
1243
+
1127
1244
  @staticmethod
1128
1245
  def Edges(face) -> list:
1129
1246
  """
@@ -1685,6 +1802,123 @@ class Face():
1685
1802
  plane_b = normalize_plane_coefficients(plane_b)
1686
1803
  return are_planes_coplanar(plane_a, plane_b, tolerance=tolerance)
1687
1804
 
1805
+ @staticmethod
1806
+ def IShape(origin=None,
1807
+ width=1,
1808
+ length=1,
1809
+ a=0.25,
1810
+ b=0.25,
1811
+ c=0.25,
1812
+ flipHorizontal = False,
1813
+ flipVertical = False,
1814
+ direction=[0,0,1],
1815
+ placement="center",
1816
+ tolerance=0.0001,
1817
+ silent=False):
1818
+ """
1819
+ Creates an I-shape.
1820
+
1821
+ Parameters
1822
+ ----------
1823
+ origin : topologic_core.Vertex , optional
1824
+ The location of the origin of the I-shape. The default is None which results in the I-shape being placed at (0, 0, 0).
1825
+ width : float , optional
1826
+ The overall width of the I-shape. The default is 1.0.
1827
+ length : float , optional
1828
+ The overall length of the I-shape. The default is 1.0.
1829
+ a : float , optional
1830
+ The hortizontal thickness of the central vertical arm of the I-shape. The default is 0.25.
1831
+ b : float , optional
1832
+ The vertical thickness of the bottom horizontal arm of the I-shape. The default is 0.25.
1833
+ c : float , optional
1834
+ The vertical thickness of the top horizontal arm of the I-shape. The default is 0.25.
1835
+ direction : list , optional
1836
+ The vector representing the up direction of the I-shape. The default is [0, 0, 1].
1837
+ placement : str , optional
1838
+ The description of the placement of the origin of the I-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
1839
+ tolerance : float , optional
1840
+ The desired tolerance. The default is 0.0001.
1841
+ silent : bool , optional
1842
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
1843
+
1844
+ Returns
1845
+ -------
1846
+ topologic_core.Face
1847
+ The created I-shape.
1848
+
1849
+ """
1850
+ from topologicpy.Vertex import Vertex
1851
+ from topologicpy.Wire import Wire
1852
+ from topologicpy.Topology import Topology
1853
+
1854
+ if not isinstance(width, int) and not isinstance(width, float):
1855
+ if not silent:
1856
+ print("Face.IShape - Error: The width input parameter is not a valid number. Returning None.")
1857
+ return None
1858
+ if not isinstance(length, int) and not isinstance(length, float):
1859
+ if not silent:
1860
+ print("Face.IShape - Error: The length input parameter is not a valid number. Returning None.")
1861
+ return None
1862
+ if not isinstance(a, int) and not isinstance(a, float):
1863
+ if not silent:
1864
+ print("Face.IShape - Error: The a input parameter is not a valid number. Returning None.")
1865
+ return None
1866
+ if not isinstance(b, int) and not isinstance(b, float):
1867
+ if not silent:
1868
+ print("Face.IShape - Error: The b input parameter is not a valid number. Returning None.")
1869
+ return None
1870
+ if width <= tolerance:
1871
+ if not silent:
1872
+ print("Face.IShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1873
+ return None
1874
+ if length <= tolerance:
1875
+ if not silent:
1876
+ print("Face.IShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1877
+ return None
1878
+ if a <= tolerance:
1879
+ if not silent:
1880
+ print("Face.IShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1881
+ return None
1882
+ if b <= tolerance:
1883
+ if not silent:
1884
+ print("Face.IShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
1885
+ return None
1886
+ if a >= (width - tolerance):
1887
+ if not silent:
1888
+ print("Face.IShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
1889
+ return None
1890
+ if b+c >= (length - tolerance):
1891
+ if not silent:
1892
+ print("Face.IShape - Error: The b and c input parameters must add to less than the length input parameter. Returning None.")
1893
+ return None
1894
+ if origin == None:
1895
+ origin = Vertex.Origin()
1896
+ if not Topology.IsInstance(origin, "vertex"):
1897
+ if not silent:
1898
+ print("Face.IShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
1899
+ return None
1900
+ if not isinstance(direction, list):
1901
+ if not silent:
1902
+ print("Face.IShape - Error: The direction input parameter is not a valid list. Returning None.")
1903
+ return None
1904
+ if not len(direction) == 3:
1905
+ if not silent:
1906
+ print("Face.IShape - Error: The direction input parameter is not a valid vector. Returning None.")
1907
+ return None
1908
+ i_shape_wire = Wire.IShape(origin=origin,
1909
+ width=width,
1910
+ length=length,
1911
+ a=a,
1912
+ b=b,
1913
+ c=c,
1914
+ flipHorizontal=flipHorizontal,
1915
+ flipVertical=flipVertical,
1916
+ direction=direction,
1917
+ placement=placement,
1918
+ tolerance=tolerance,
1919
+ silent=silent)
1920
+ return Face.ByWire(i_shape_wire, tolerance=tolerance, silent=silent)
1921
+
1688
1922
  @staticmethod
1689
1923
  def Isovist(face, vertex, obstacles: list = [], direction: list = [0,1,0], fov: float = 360, transferDictionaries: bool = False, metrics: bool = False, triangles: bool = False, mantissa: int = 6, tolerance: float = 0.0001):
1690
1924
  """
@@ -2294,6 +2528,120 @@ class Face():
2294
2528
  return_face = Topology.AddContent(return_face, triangle_list)
2295
2529
  return return_face
2296
2530
 
2531
+
2532
+ @staticmethod
2533
+ def LShape(origin=None,
2534
+ width=1,
2535
+ length=1,
2536
+ a=0.25,
2537
+ b=0.25,
2538
+ flipHorizontal = False,
2539
+ flipVertical = False,
2540
+ direction=[0,0,1],
2541
+ placement="center",
2542
+ tolerance=0.0001,
2543
+ silent=False):
2544
+ """
2545
+ Creates an L-shape.
2546
+
2547
+ Parameters
2548
+ ----------
2549
+ origin : topologic_core.Vertex , optional
2550
+ The location of the origin of the L-shape. The default is None which results in the L-shape being placed at (0, 0, 0).
2551
+ width : float , optional
2552
+ The overall width of the L-shape. The default is 1.0.
2553
+ length : float , optional
2554
+ The overall length of the L-shape. The default is 1.0.
2555
+ a : float , optional
2556
+ The hortizontal thickness of the vertical arm of the L-shape. The default is 0.25.
2557
+ b : float , optional
2558
+ The vertical thickness of the horizontal arm of the L-shape. The default is 0.25.
2559
+ direction : list , optional
2560
+ The vector representing the up direction of the L-shape. The default is [0, 0, 1].
2561
+ placement : str , optional
2562
+ The description of the placement of the origin of the L-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
2563
+ tolerance : float , optional
2564
+ The desired tolerance. The default is 0.0001.
2565
+ silent : bool , optional
2566
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
2567
+
2568
+ Returns
2569
+ -------
2570
+ topologic_core.Face
2571
+ The created L-shape.
2572
+
2573
+ """
2574
+ from topologicpy.Vertex import Vertex
2575
+ from topologicpy.Wire import Wire
2576
+ from topologicpy.Topology import Topology
2577
+
2578
+ if not isinstance(width, int) and not isinstance(width, float):
2579
+ if not silent:
2580
+ print("Face.LShape - Error: The width input parameter is not a valid number. Returning None.")
2581
+ return None
2582
+ if not isinstance(length, int) and not isinstance(length, float):
2583
+ if not silent:
2584
+ print("Face.LShape - Error: The length input parameter is not a valid number. Returning None.")
2585
+ return None
2586
+ if not isinstance(a, int) and not isinstance(a, float):
2587
+ if not silent:
2588
+ print("Face.LShape - Error: The a input parameter is not a valid number. Returning None.")
2589
+ return None
2590
+ if not isinstance(b, int) and not isinstance(b, float):
2591
+ if not silent:
2592
+ print("Face.LShape - Error: The b input parameter is not a valid number. Returning None.")
2593
+ return None
2594
+ if width <= tolerance:
2595
+ if not silent:
2596
+ print("Face.LShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2597
+ return None
2598
+ if length <= tolerance:
2599
+ if not silent:
2600
+ print("Face.LShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2601
+ return None
2602
+ if a <= tolerance:
2603
+ if not silent:
2604
+ print("Face.LShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2605
+ return None
2606
+ if b <= tolerance:
2607
+ if not silent:
2608
+ print("Face.LShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
2609
+ return None
2610
+ if a >= (width - tolerance):
2611
+ if not silent:
2612
+ print("Face.LShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
2613
+ return None
2614
+ if b >= (length - tolerance):
2615
+ if not silent:
2616
+ print("Face.LShape - Error: The b input parameter must be less than the length input parameter. Returning None.")
2617
+ return None
2618
+ if origin == None:
2619
+ origin = Vertex.Origin()
2620
+ if not Topology.IsInstance(origin, "vertex"):
2621
+ if not silent:
2622
+ print("Face.LShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
2623
+ return None
2624
+ if not isinstance(direction, list):
2625
+ if not silent:
2626
+ print("Face.LShape - Error: The direction input parameter is not a valid list. Returning None.")
2627
+ return None
2628
+ if not len(direction) == 3:
2629
+ if not silent:
2630
+ print("Face.LShape - Error: The direction input parameter is not a valid vector. Returning None.")
2631
+ return None
2632
+ l_shape_wire = Wire.LShape(origin=origin,
2633
+ width=width,
2634
+ length=length,
2635
+ a=a,
2636
+ b=b,
2637
+ flipHorizontal=flipHorizontal,
2638
+ flipVertical=flipVertical,
2639
+ direction=direction,
2640
+ placement=placement,
2641
+ tolerance=tolerance,
2642
+ silent=silent)
2643
+ return Face.ByWire(l_shape_wire, tolerance=tolerance, silent=silent)
2644
+
2297
2645
  @staticmethod
2298
2646
  def MedialAxis(face, resolution: int = 0, externalVertices: bool = False, internalVertices: bool = False, toLeavesOnly: bool = False, angTolerance: float = 0.1, tolerance: float = 0.0001):
2299
2647
  """
@@ -3193,6 +3541,119 @@ class Face():
3193
3541
  trimmed_face = face.Difference(trimmed_face)
3194
3542
  return trimmed_face
3195
3543
 
3544
+ @staticmethod
3545
+ def TShape(origin=None,
3546
+ width=1,
3547
+ length=1,
3548
+ a=0.5,
3549
+ b=0.5,
3550
+ flipHorizontal = False,
3551
+ flipVertical = False,
3552
+ direction=[0,0,1],
3553
+ placement="center",
3554
+ tolerance=0.0001,
3555
+ silent=False):
3556
+ """
3557
+ Creates a T-shape.
3558
+
3559
+ Parameters
3560
+ ----------
3561
+ origin : topologic_core.Vertex , optional
3562
+ The location of the origin of the T-shape. The default is None which results in the T-shape being placed at (0, 0, 0).
3563
+ width : float , optional
3564
+ The overall width of the T-shape. The default is 1.0.
3565
+ length : float , optional
3566
+ The overall length of the T-shape. The default is 1.0.
3567
+ a : float , optional
3568
+ The hortizontal thickness of the vertical arm of the T-shape. The default is 0.5.
3569
+ b : float , optional
3570
+ The vertical thickness of the horizontal arm of the T-shape. The default is 0.5.
3571
+ direction : list , optional
3572
+ The vector representing the up direction of the T-shape. The default is [0, 0, 1].
3573
+ placement : str , optional
3574
+ The description of the placement of the origin of the T-shape. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
3575
+ tolerance : float , optional
3576
+ The desired tolerance. The default is 0.0001.
3577
+ silent : bool , optional
3578
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
3579
+
3580
+ Returns
3581
+ -------
3582
+ topologic_core.Face
3583
+ The created T-shape.
3584
+
3585
+ """
3586
+ from topologicpy.Vertex import Vertex
3587
+ from topologicpy.Wire import Wire
3588
+ from topologicpy.Topology import Topology
3589
+
3590
+ if not isinstance(width, int) and not isinstance(width, float):
3591
+ if not silent:
3592
+ print("Face.TShape - Error: The width input parameter is not a valid number. Returning None.")
3593
+ return None
3594
+ if not isinstance(length, int) and not isinstance(length, float):
3595
+ if not silent:
3596
+ print("Face.TShape - Error: The length input parameter is not a valid number. Returning None.")
3597
+ return None
3598
+ if not isinstance(a, int) and not isinstance(a, float):
3599
+ if not silent:
3600
+ print("Face.TShape - Error: The a input parameter is not a valid number. Returning None.")
3601
+ return None
3602
+ if not isinstance(b, int) and not isinstance(b, float):
3603
+ if not silent:
3604
+ print("Face.LShape - Error: The b input parameter is not a valid number. Returning None.")
3605
+ return None
3606
+ if width <= tolerance:
3607
+ if not silent:
3608
+ print("Face.TShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
3609
+ return None
3610
+ if length <= tolerance:
3611
+ if not silent:
3612
+ print("Face.TShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
3613
+ return None
3614
+ if a <= tolerance:
3615
+ if not silent:
3616
+ print("Face.TShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
3617
+ return None
3618
+ if b <= tolerance:
3619
+ if not silent:
3620
+ print("Face.TShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
3621
+ return None
3622
+ if a >= (width - tolerance):
3623
+ if not silent:
3624
+ print("Face.TShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
3625
+ return None
3626
+ if b >= (length - tolerance):
3627
+ if not silent:
3628
+ print("Face.TShape - Error: The b input parameter must be less than the length input parameter. Returning None.")
3629
+ return None
3630
+ if origin == None:
3631
+ origin = Vertex.Origin()
3632
+ if not Topology.IsInstance(origin, "vertex"):
3633
+ if not silent:
3634
+ print("Face.TShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
3635
+ return None
3636
+ if not isinstance(direction, list):
3637
+ if not silent:
3638
+ print("Face.TShape - Error: The direction input parameter is not a valid list. Returning None.")
3639
+ return None
3640
+ if not len(direction) == 3:
3641
+ if not silent:
3642
+ print("Face.TShape - Error: The direction input parameter is not a valid vector. Returning None.")
3643
+ return None
3644
+ t_shape_wire = Wire.TShape(origin=origin,
3645
+ width=width,
3646
+ length=length,
3647
+ a=a,
3648
+ b=b,
3649
+ flipHorizontal=flipHorizontal,
3650
+ flipVertical=flipVertical,
3651
+ direction=direction,
3652
+ placement=placement,
3653
+ tolerance=tolerance,
3654
+ silent=silent)
3655
+ return Face.ByWire(t_shape_wire, tolerance=tolerance, silent=silent)
3656
+
3196
3657
  @staticmethod
3197
3658
  def VertexByParameters(face, u: float = 0.5, v: float = 0.5):
3198
3659
  """
topologicpy/Graph.py CHANGED
@@ -751,7 +751,7 @@ class Graph:
751
751
  return paths
752
752
 
753
753
  @staticmethod
754
- def AreIsomorphic(graphA, graphB, maxIterations=10, silent=False):
754
+ def IsIsomorphic(graphA, graphB, maxIterations=10, silent=False):
755
755
  """
756
756
  Tests if the two input graphs are isomorphic according to the Weisfeiler Lehman graph isomorphism test. See https://en.wikipedia.org/wiki/Weisfeiler_Leman_graph_isomorphism_test
757
757
 
@@ -827,19 +827,19 @@ class Graph:
827
827
 
828
828
  if not Topology.IsInstance(graphA, "Graph") and not Topology.IsInstance(graphB, "Graph"):
829
829
  if not silent:
830
- print("Graph.AreIsomorphic - Error: The input graph parameters are not valid graphs. Returning None.")
830
+ print("Graph.IsIsomorphic - Error: The input graph parameters are not valid graphs. Returning None.")
831
831
  return None
832
832
  if not Topology.IsInstance(graphA, "Graph"):
833
833
  if not silent:
834
- print("Graph.AreIsomorphic - Error: The input graphA parameter is not a valid graph. Returning None.")
834
+ print("Graph.IsIsomorphic - Error: The input graphA parameter is not a valid graph. Returning None.")
835
835
  return None
836
836
  if not Topology.IsInstance(graphB, "Graph"):
837
837
  if not silent:
838
- print("Graph.AreIsomorphic - Error: The input graphB parameter is not a valid graph. Returning None.")
838
+ print("Graph.IsIsomorphic - Error: The input graphB parameter is not a valid graph. Returning None.")
839
839
  return None
840
840
  if maxIterations <= 0:
841
841
  if not silent:
842
- print("Graph.AreIsomorphic - Error: The input maxIterations parameter is not within a valid range. Returning None.")
842
+ print("Graph.IsIsomorphic - Error: The input maxIterations parameter is not within a valid range. Returning None.")
843
843
  return None
844
844
 
845
845
  g1 = Graph.AdjacencyDictionary(graphA)
@@ -4517,37 +4517,39 @@ class Graph:
4517
4517
  import warnings
4518
4518
 
4519
4519
  try:
4520
- import community as community_louvain
4520
+ import igraph as ig
4521
4521
  except:
4522
- print("Graph.Community - Installing required pyhon-louvain library.")
4522
+ print("Graph.Community - Installing required pyhon-igraph library.")
4523
4523
  try:
4524
- os.system("pip install python-louvain")
4524
+ os.system("pip install python-igraph")
4525
4525
  except:
4526
- os.system("pip install python-louvain --user")
4526
+ os.system("pip install python-igraph --user")
4527
4527
  try:
4528
- import community as community_louvain
4529
- print("Graph.Community - python-louvain library installed correctly.")
4528
+ import igraph as ig
4529
+ print("Graph.Community - python-igraph library installed correctly.")
4530
4530
  except:
4531
- warnings.warn("Graph.Community - Error: Could not import python-louvain. Please install manually.")
4531
+ warnings.warn("Graph.Community - Error: Could not import python-igraph. Please install manually.")
4532
4532
 
4533
4533
  if not Topology.IsInstance(graph, "graph"):
4534
4534
  if not silent:
4535
4535
  print("Graph.Community - Error: The input graph parameter is not a valid topologic graph. Returning None")
4536
4536
  return None
4537
4537
 
4538
+ mesh_data = Graph.MeshData(graph)
4539
+ # Create an igraph graph from the edge list
4540
+ ig_graph = ig.Graph(edges=mesh_data['edges'])
4541
+
4542
+ # Detect communities using Louvain method
4543
+ communities = ig_graph.community_multilevel()
4544
+
4545
+ # Get the list of communities sorted same as vertices
4546
+ community_list = communities.membership
4538
4547
  vertices = Graph.Vertices(graph)
4539
- nx_graph = Graph.NetworkXGraph(graph, mantissa=mantissa, tolerance=tolerance)
4540
- # Apply the Louvain algorithm
4541
- partition = community_louvain.best_partition(nx_graph)
4542
- communities = []
4543
- # Add the partition value to each node's properties
4544
- for node, community_id in partition.items():
4545
- nx_graph.nodes[node][key] = community_id
4546
- d = Topology.Dictionary(vertices[node])
4547
- d = Dictionary.SetValueAtKey(d, key, community_id)
4548
- vertices[node] = Topology.SetDictionary(vertices[node], d)
4549
- communities.append(community_id)
4550
- return communities
4548
+ for i, v in enumerate(vertices):
4549
+ d = Topology.Dictionary(v)
4550
+ d = Dictionary.SetValueAtKey(d, key, community_list[i])
4551
+ v = Topology.SetDictionary(v, d)
4552
+ return community_list
4551
4553
 
4552
4554
  @staticmethod
4553
4555
  def Connect(graph, verticesA, verticesB, tolerance=0.0001):
@@ -8102,6 +8104,7 @@ class Graph:
8102
8104
 
8103
8105
  """
8104
8106
  from topologicpy.Vertex import Vertex
8107
+ from topologicpy.Edge import Edge
8105
8108
  from topologicpy.Dictionary import Dictionary
8106
8109
  from topologicpy.Topology import Topology
8107
8110
 
@@ -8116,8 +8119,8 @@ class Graph:
8116
8119
  m_edges = []
8117
8120
  e_dicts = []
8118
8121
  for g_edge in g_edges:
8119
- sv = g_edge.StartVertex()
8120
- ev = g_edge.EndVertex()
8122
+ sv = Edge.StartVertex(g_edge)
8123
+ ev = Edge.EndVertex(g_edge)
8121
8124
  si = Vertex.Index(sv, g_vertices, tolerance=tolerance)
8122
8125
  ei = Vertex.Index(ev, g_vertices, tolerance=tolerance)
8123
8126
  if (not si == None) and (not ei == None):
topologicpy/Honeybee.py CHANGED
@@ -255,7 +255,7 @@ class Honeybee:
255
255
 
256
256
  def cellFloor(cell):
257
257
  faces = Topology.Faces(cell)
258
- c = [x.CenterOfMass().Z() for x in faces]
258
+ c = [Vertex.Z(Topology.CenterOfMass(x)) for x in faces]
259
259
  return round(min(c),2)
260
260
 
261
261
  def floorLevels(cells, min_difference):
topologicpy/Neo4j.py CHANGED
@@ -413,6 +413,7 @@ class Neo4j:
413
413
 
414
414
  """
415
415
  from topologicpy.Vertex import Vertex
416
+ from topologicpy.Edge import Edge
416
417
  from topologicpy.Graph import Graph
417
418
  from topologicpy.Topology import Topology
418
419
  from topologicpy.Dictionary import Dictionary
@@ -458,8 +459,8 @@ class Neo4j:
458
459
  nodes.append(n)
459
460
  for i in range(len(edges)):
460
461
  e = edges[i]
461
- sv = e.StartVertex()
462
- ev = e.EndVertex()
462
+ sv = Edge.StartVertex(e)
463
+ ev = Edge.EndVertex(e)
463
464
  sn = nodes[Vertex.Index(vertex=sv, vertices=vertices, strict=False, tolerance=tolerance)]
464
465
  en = nodes[Vertex.Index(vertex=ev, vertices=vertices, strict=False, tolerance=tolerance)]
465
466
  ed = Topology.Dictionary(e)