Skip to content

Commit

Permalink
Added PDF Import
Browse files Browse the repository at this point in the history
  • Loading branch information
wassimj committed Dec 1, 2024
1 parent 06d80ca commit f4169d9
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 11 deletions.
191 changes: 191 additions & 0 deletions notebooks/PDF_Import.ipynb

Large diffs are not rendered by default.

Binary file added notebooks/pdf_import_test.pdf
Binary file not shown.
18 changes: 14 additions & 4 deletions src/topologicpy/Plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,17 @@ def edgeData(vertices, edges, dictionaries=None, color="black", colorKey=None, w
else:
minGroup = 0
maxGroup = 1


if colorKey or widthKey or labelKey or groupKey:
keys = [x for x in [colorKey, widthKey, labelKey, groupKey] if not x == None]
temp_dict = Helper.ClusterByKeys(edges, dictionaries, keys, silent=False)
dict_clusters = temp_dict["dictionaries"]
elements_clusters = temp_dict['elements']
n = len(str(len(elements_clusters)))
labels = []
for j, elements_cluster in enumerate(elements_clusters):
labels.append("Edge_"+str(j+1).zfill(n))
d = dict_clusters[j][0] # All dicitonaries have same values in dictionaries, so take first one.
if d:
if not colorKey == None:
Expand All @@ -629,6 +633,7 @@ def edgeData(vertices, edges, dictionaries=None, color="black", colorKey=None, w
else:
d_color = Color.ByValueInRange(groups.index(group), minValue=minGroup, maxValue=maxGroup, colorScale=colorScale)
color = d_color

x = []
y = []
z = []
Expand All @@ -639,15 +644,19 @@ def edgeData(vertices, edges, dictionaries=None, color="black", colorKey=None, w
y+=[sv[1], ev[1], None] # y-coordinates of edge ends
z+=[sv[2], ev[2], None] # z-coordinates of edge ends
if showEdgeLabel == True:
mode = "lines+text"
mode = "markers+lines+text"
else:
mode = "lines"
mode = "markers+lines"
if isinstance(width, list):
marker_width = width[0]*0.25
else:
marker_width = width*0.25
trace = go.Scatter3d(x=x,
y=y,
z=z,
name=label,
showlegend=showLegend,
marker_size=0,
marker=dict(symbol="circle", size=marker_width),
mode=mode,
line=dict(color=color, width=width),
legendgroup=legendGroup,
Expand Down Expand Up @@ -894,7 +903,7 @@ def faceData(vertices, faces, dictionaries=None, color="#FAFAFA", colorKey=None,
label = ""
group = None
groupList.append(Color.AnyToHex(color)) # Store a default color for that face
labels.append("Face_"+str(m+1).zfill(n))
labels.append("Mace_"+str(m+1).zfill(n))
if len(dictionaries) > 0:
d = dictionaries[m]
if d:
Expand Down Expand Up @@ -1033,6 +1042,7 @@ def faceData(vertices, faces, dictionaries=None, color="#FAFAFA", colorKey=None,
if edgeColorKey or edgeWidthKey or edgeLabelKey or edgeGroupKey:
for tp_edge in tp_edges:
e_dictionaries.append(Topology.Dictionary(tp_edge))

e_cluster = Cluster.ByTopologies(tp_edges)
geo = Topology.Geometry(e_cluster, mantissa=mantissa)
vertices = geo['vertices']
Expand Down
Loading

0 comments on commit f4169d9

Please sign in to comment.