topologicpy 0.7.50__py3-none-any.whl → 0.7.52__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
@@ -371,7 +371,7 @@ class Color:
371
371
  Parameters
372
372
  ----------
373
373
  color : list
374
- The input color list. This is assumed to be in the format [r, g, b] or [r, g, b, a]
374
+ The input color list. This is assumed to be in the format [r, g, b] or [r, g, b, a] where the range is from 0 to 255.
375
375
  alpha : float , optional
376
376
  The transparency value. 0.0 means the color is fully transparent, 1.0 means the color is fully opaque. The default is 1.0.
377
377
  useAlpha : bool , optional
topologicpy/Dictionary.py CHANGED
@@ -642,10 +642,8 @@ class Dictionary():
642
642
  The value found at the input key in the input dictionary.
643
643
 
644
644
  """
645
- import json
646
645
  from topologicpy.Topology import Topology
647
646
 
648
-
649
647
  if not Topology.IsInstance(dictionary, "Dictionary") and not isinstance(dictionary, dict):
650
648
  print("Dictionary.ValueAtKey - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
651
649
  return None
topologicpy/Face.py CHANGED
@@ -2373,7 +2373,7 @@ class Face():
2373
2373
  from topologicpy.Face import Face
2374
2374
 
2375
2375
  if not Topology.IsInstance(face, "Face"):
2376
- print("Shell.ByMeshFace - Error: The input face parameter is not a valid face. Returning None.")
2376
+ print("Face.Triangulate - Error: The input face parameter is not a valid face. Returning None.")
2377
2377
  return None
2378
2378
  if not meshSize:
2379
2379
  bounding_face = Face.BoundingRectangle(face)
@@ -2477,9 +2477,11 @@ class Face():
2477
2477
  wire = Face.ExternalBoundary(f)
2478
2478
  wire = Wire.Invert(wire)
2479
2479
  f = Face.ByWire(wire)
2480
- finalFaces.append(f)
2480
+ if Topology.IsInstance(f, "Face"):
2481
+ finalFaces.append(f)
2481
2482
  else:
2482
- finalFaces.append(f)
2483
+ if Topology.IsInstance(f, "face"):
2484
+ finalFaces.append(f)
2483
2485
  face_normal = Face.Normal(face)
2484
2486
  return_faces = []
2485
2487
  for ff in finalFaces:
topologicpy/Graph.py CHANGED
@@ -2177,6 +2177,12 @@ class Graph:
2177
2177
  for ifc_rel in ifc_relationships:
2178
2178
  source = None
2179
2179
  destinations = []
2180
+ if ifc_rel.is_a("IfcRelConnectsPorts"):
2181
+ source = ifc_rel.RelatingPort
2182
+ destinations = ifc_rel.RelatedPorts
2183
+ if ifc_rel.is_a("IfcRelConnectsPortToElement"):
2184
+ source = ifc_rel.RelatingPort
2185
+ destinations = [ifc_rel.RelatedElement]
2180
2186
  if ifc_rel.is_a("IfcRelAggregates"):
2181
2187
  source = ifc_rel.RelatingObject
2182
2188
  destinations = ifc_rel.RelatedObjects
topologicpy/Plotly.py CHANGED
@@ -372,12 +372,11 @@ class Plotly:
372
372
  v_label = ""
373
373
  v_group = ""
374
374
  d = Topology.Dictionary(v)
375
- v_group = Dictionary.ValueAtKey(d, key=vertexGroupKey)
376
375
  if d:
377
376
  if vertexLabelKey:
378
377
  v_label = str(Dictionary.ValueAtKey(d, key=vertexLabelKey)) or ""
379
378
  if vertexGroupKey:
380
- v_group = Dictionary.ValueAtKey(d, key=vertexGroupKey) or None
379
+ v_group = Dictionary.ValueAtKey(d, key=vertexGroupKey) or ""
381
380
  try:
382
381
  v_groupList.append(vertexGroups.index(v_group))
383
382
  except:
@@ -439,14 +438,10 @@ class Plotly:
439
438
  e_group = ""
440
439
  d = Topology.Dictionary(e)
441
440
  if d:
442
- try:
441
+ if not edgeLabelKey == None:
443
442
  e_label = str(Dictionary.ValueAtKey(d, key=edgeLabelKey)) or ""
444
- except:
445
- e_label = ""
446
- try:
443
+ if not edgeGroupKey == None:
447
444
  e_group = str(Dictionary.ValueAtKey(d, key=edgeGroupKey)) or ""
448
- except:
449
- e_group = ""
450
445
  try:
451
446
  e_groupList.append(edgeGroups.index(e_group))
452
447
  except:
@@ -490,12 +485,12 @@ class Plotly:
490
485
  @staticmethod
491
486
  def DataByTopology(topology,
492
487
  showVertices=True, vertexSize=1.1, vertexColor="black",
493
- vertexLabelKey=None, vertexGroupKey=None, vertexGroups=[],
488
+ vertexLabelKey=None, showVertexLabel=False, vertexGroupKey=None, vertexGroups=[],
494
489
  vertexMinGroup=None, vertexMaxGroup=None,
495
490
  showVertexLegend=False, vertexLegendLabel="Topology Vertices", vertexLegendRank=1,
496
491
  vertexLegendGroup=1,
497
492
  showEdges=True, edgeWidth=1, edgeColor="black",
498
- edgeLabelKey=None, edgeGroupKey=None, edgeGroups=[],
493
+ edgeLabelKey=None, showEdgeLabel=False, edgeGroupKey=None, edgeGroups=[],
499
494
  edgeMinGroup=None, edgeMaxGroup=None,
500
495
  showEdgeLegend=False, edgeLegendLabel="Topology Edges", edgeLegendRank=2,
501
496
  edgeLegendGroup=2,
@@ -633,14 +628,14 @@ class Plotly:
633
628
  def closest_index(input_value, values):
634
629
  return int(min(range(len(values)), key=lambda i: abs(values[i] - input_value)))
635
630
 
636
- def vertexData(vertices, dictionaries=[], color="black", size=1.1, labelKey=None, groupKey=None, minGroup=None, maxGroup=None, groups=[], legendLabel="Topology Vertices", legendGroup=1, legendRank=1, showLegend=True, colorScale="Viridis"):
631
+ def vertexData(vertices, dictionaries=[], color="black", size=1.1, labelKey=None, showVertexLabel = False, groupKey=None, minGroup=None, maxGroup=None, groups=[], legendLabel="Topology Vertices", legendGroup=1, legendRank=1, showLegend=True, colorScale="Viridis"):
637
632
  x = []
638
633
  y = []
639
634
  z = []
640
635
  labels = []
641
636
  groupList = []
642
637
  label = ""
643
- group = ""
638
+ group = None
644
639
  if labelKey or groupKey:
645
640
  if groups:
646
641
  if len(groups) > 0:
@@ -660,20 +655,18 @@ class Plotly:
660
655
  y.append(v[1])
661
656
  z.append(v[2])
662
657
  label = ""
663
- group = ""
658
+ group = None
664
659
  if len(dictionaries) > 0:
665
660
  d = dictionaries[m]
666
661
  if d:
667
- try:
662
+ if not labelKey == None:
668
663
  label = str(Dictionary.ValueAtKey(d, key=labelKey)) or ""
669
- except:
670
- label = ""
671
- try:
672
- group = Dictionary.ValueAtKey(d, key=groupKey) or None
673
- except:
674
- group = ""
664
+ if not groupKey == None:
665
+ group = Dictionary.ValueAtKey(d, key=groupKey) or ""
675
666
  try:
676
- if type(group) == int or type(group) == float:
667
+ if group == "":
668
+ color = 'white'
669
+ elif type(group) == int or type(group) == float:
677
670
  if group < minGroup:
678
671
  group = minGroup
679
672
  if group > maxGroup:
@@ -696,13 +689,17 @@ class Plotly:
696
689
  groupList = color
697
690
  if len(labels) < 1:
698
691
  labels = ""
692
+ if showVertexLabel == True:
693
+ mode = "markers+text"
694
+ else:
695
+ mode = "markers"
699
696
  vData= go.Scatter3d(x=x,
700
697
  y=y,
701
698
  z=z,
702
699
  name=legendLabel,
703
700
  showlegend=showLegend,
704
701
  marker=dict(color=groupList, size=vertexSize),
705
- mode='markers',
702
+ mode=mode,
706
703
  legendgroup=legendGroup,
707
704
  legendrank=legendRank,
708
705
  text=labels,
@@ -711,7 +708,7 @@ class Plotly:
711
708
  )
712
709
  return vData
713
710
 
714
- def edgeData(vertices, edges, dictionaries=None, color="black", width=1, labelKey=None, groupKey=None, minGroup=None, maxGroup=None, groups=[], legendLabel="Topology Edges", legendGroup=2, legendRank=2, showLegend=True, colorScale="Viridis"):
711
+ def edgeData(vertices, edges, dictionaries=None, color="black", width=1, labelKey=None, showEdgeLabel = False, groupKey=None, minGroup=None, maxGroup=None, groups=[], legendLabel="Topology Edges", legendGroup=2, legendRank=2, showLegend=True, colorScale="Viridis"):
715
712
  x = []
716
713
  y = []
717
714
  z = []
@@ -740,19 +737,17 @@ class Plotly:
740
737
  y+=[sv[1], ev[1], None] # y-coordinates of edge ends
741
738
  z+=[sv[2], ev[2], None] # z-coordinates of edge ends
742
739
  label = ""
743
- group = ""
740
+ group = None
744
741
  if len(dictionaries) > 0:
745
742
  d = dictionaries[m]
746
743
  if d:
747
- try:
744
+ if not labelKey == None:
748
745
  label = str(Dictionary.ValueAtKey(d, key=labelKey)) or ""
749
- except:
750
- label = ""
751
- try:
752
- group = Dictionary.ValueAtKey(d, key=groupKey) or None
753
- except:
754
- group = ""
746
+ if not groupKey == None:
747
+ group = Dictionary.ValueAtKey(d, key=groupKey) or ""
755
748
  try:
749
+ if group == "":
750
+ color = 'white'
756
751
  if type(group) == int or type(group) == float:
757
752
  if group < minGroup:
758
753
  group = minGroup
@@ -778,13 +773,17 @@ class Plotly:
778
773
  groupList = color
779
774
  if len(labels) < 1:
780
775
  labels = ""
776
+ if showEdgeLabel == True:
777
+ mode = "lines+text"
778
+ else:
779
+ mode = "lines"
781
780
  eData = go.Scatter3d(x=x,
782
781
  y=y,
783
782
  z=z,
784
783
  name=legendLabel,
785
784
  showlegend=showLegend,
786
785
  marker_size=0,
787
- mode="lines",
786
+ mode=mode,
788
787
  line=dict(color=groupList, width=edgeWidth),
789
788
  legendgroup=legendGroup,
790
789
  legendrank=legendRank,
@@ -834,16 +833,14 @@ class Plotly:
834
833
  if len(dictionaries) > 0:
835
834
  d = dictionaries[m]
836
835
  if d:
837
- try:
836
+ if not labelKey == None:
838
837
  label = str(Dictionary.ValueAtKey(d, key=labelKey)) or ""
839
- except:
840
- label = ""
841
- try:
838
+ if not groupKey == None:
842
839
  group = Dictionary.ValueAtKey(d, key=groupKey) or None
843
- except:
844
- group = ""
845
840
  try:
846
- if type(group) == int or type(group) == float:
841
+ if group == "":
842
+ color = 'white'
843
+ elif type(group) == int or type(group) == float:
847
844
  if group < minGroup:
848
845
  group = minGroup
849
846
  if group > maxGroup:
@@ -955,7 +952,7 @@ class Plotly:
955
952
  d = Topology.Dictionary(tp_v)
956
953
  v_dictionaries.append(d)
957
954
  vertices.append([Vertex.X(tp_v, mantissa=mantissa), Vertex.Y(tp_v, mantissa=mantissa), Vertex.Z(tp_v, mantissa=mantissa)])
958
- data.append(vertexData(vertices, dictionaries=v_dictionaries, color=vertexColor, size=vertexSize, labelKey=vertexLabelKey, groupKey=vertexGroupKey, minGroup=vertexMinGroup, maxGroup=vertexMaxGroup, groups=vertexGroups, legendLabel=vertexLegendLabel, legendGroup=vertexLegendGroup, legendRank=vertexLegendRank, showLegend=showVertexLegend, colorScale=colorScale))
955
+ data.append(vertexData(vertices, dictionaries=v_dictionaries, color=vertexColor, size=vertexSize, labelKey=vertexLabelKey, showVertexLabel=showVertexLabel, groupKey=vertexGroupKey, minGroup=vertexMinGroup, maxGroup=vertexMaxGroup, groups=vertexGroups, legendLabel=vertexLegendLabel, legendGroup=vertexLegendGroup, legendRank=vertexLegendRank, showLegend=showVertexLegend, colorScale=colorScale))
959
956
 
960
957
  if showEdges and Topology.Type(topology) > Topology.TypeID("Vertex"):
961
958
  if Topology.Type(topology) == Topology.TypeID("Edge"):
@@ -971,7 +968,7 @@ class Plotly:
971
968
  geo = Topology.Geometry(e_cluster, mantissa=mantissa)
972
969
  vertices = geo['vertices']
973
970
  edges = geo['edges']
974
- data.append(edgeData(vertices, edges, dictionaries=e_dictionaries, color=edgeColor, width=edgeWidth, labelKey=edgeLabelKey, groupKey=edgeGroupKey, minGroup=edgeMinGroup, maxGroup=edgeMaxGroup, groups=edgeGroups, legendLabel=edgeLegendLabel, legendGroup=edgeLegendGroup, legendRank=edgeLegendRank, showLegend=showEdgeLegend, colorScale=colorScale))
971
+ data.append(edgeData(vertices, edges, dictionaries=e_dictionaries, color=edgeColor, width=edgeWidth, labelKey=edgeLabelKey, showEdgeLabel=showEdgeLabel, groupKey=edgeGroupKey, minGroup=edgeMinGroup, maxGroup=edgeMaxGroup, groups=edgeGroups, legendLabel=edgeLegendLabel, legendGroup=edgeLegendGroup, legendRank=edgeLegendRank, showLegend=showEdgeLegend, colorScale=colorScale))
975
972
 
976
973
  if showFaces and Topology.Type(topology) >= Topology.TypeID("Face"):
977
974
  if Topology.IsInstance(topology, "Face"):