topologicpy 0.7.54__py3-none-any.whl → 0.7.56__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/Plotly.py CHANGED
@@ -374,32 +374,33 @@ class Plotly:
374
374
  d = Topology.Dictionary(v)
375
375
  if d:
376
376
  if vertexLabelKey:
377
- v_label = str(Dictionary.ValueAtKey(d, key=vertexLabelKey)) or ""
377
+ v_label = str(Dictionary.ValueAtKey(d, key=vertexLabelKey))
378
+ if v_label == None:
379
+ v_label = ""
378
380
  if vertexGroupKey:
379
- v_group = Dictionary.ValueAtKey(d, key=vertexGroupKey) or ""
381
+ v_group = Dictionary.ValueAtKey(d, key=vertexGroupKey)
382
+ if v_group == None:
383
+ v_group = ""
380
384
  try:
381
385
  v_groupList.append(vertexGroups.index(v_group))
382
386
  except:
383
387
  v_groupList.append(len(vertexGroups))
384
- # if not v_label == "" and not v_group == "":
385
- # if v_group == 0:
386
- # v_label = v_label+" (0)"
387
- # else:
388
- # v_label = v_label+" ("+str(v_group)+")"
389
388
  v_labels.append(v_label)
390
389
  else:
391
390
  for v in vertices:
392
391
  Xn=[Vertex.X(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
393
392
  Yn=[Vertex.Y(v, mantissa=mantissa) for v in vertices] # y-coordinates of nodes
394
393
  Zn=[Vertex.Z(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
395
- if len(list(set(v_groupList))) < 2:
396
- v_groupList = vertexColor
397
394
  if len(v_labels) < 1:
398
395
  v_labels = ""
399
396
  if showVertexLabels == True:
400
397
  mode = "markers+text"
401
398
  else:
402
399
  mode = "markers"
400
+ # Normalize categories to a range between 0 and 1 for the color scale
401
+ min_category = 0
402
+ max_category = max(len(vertexGroups), 1)
403
+ normalized_categories = [(cat - min_category) / (max_category - min_category) for cat in v_groupList]
403
404
  v_trace=go.Scatter3d(x=Xn,
404
405
  y=Yn,
405
406
  z=Zn,
@@ -410,8 +411,10 @@ class Plotly:
410
411
  showlegend=showVertexLegend,
411
412
  marker=dict(symbol='circle',
412
413
  size=vertexSize,
413
- color=v_groupList,
414
+ color=normalized_categories,
414
415
  colorscale=Plotly.ColorScale(colorScale),
416
+ cmin = 0,
417
+ cmax=1,
415
418
  line=dict(color=edgeColor, width=0.5)
416
419
  ),
417
420
  text=v_labels,
topologicpy/Topology.py CHANGED
@@ -858,6 +858,7 @@ class Topology():
858
858
  subTopologies = []
859
859
  if not subTopologyType:
860
860
  _ = topology.Apertures(apertures)
861
+ apertures = [x.Topology() for x in apertures]
861
862
  contents = Topology.Contents(topology)
862
863
  for content in contents:
863
864
  d = Topology.Dictionary(content)
@@ -875,6 +876,7 @@ class Topology():
875
876
  subTopologies = Topology.Cells(topology)
876
877
  elif subTopologyType.lower() == "all":
877
878
  _ = topology.Apertures(apertures)
879
+ apertures = [x.Topology() for x in apertures]
878
880
  subTopologies = Topology.Vertices(topology)
879
881
  subTopologies += Topology.Edges(topology)
880
882
  subTopologies += Topology.Faces(topology)
@@ -3260,475 +3262,6 @@ class Topology():
3260
3262
  entity = Topology.AddApertures(entity, vertex_apertures, subTopologyType="Vertex", tolerance=0.001)
3261
3263
  top_level_list.append(entity)
3262
3264
  return top_level_list
3263
-
3264
- @staticmethod
3265
- def ByJSONString_old(string, progressBar=False, tolerance=0.0001):
3266
- """
3267
- Imports the topology from a JSON string.
3268
-
3269
- Parameters
3270
- ----------
3271
- string : str
3272
- The input JSON string.
3273
- progressBar : bool , optional
3274
- If set to True a tqdm progress bar is shown. If not, it will not be shown. The default is False.
3275
- tolerance : float , optional
3276
- The desired tolerance. The default is 0.0001.
3277
-
3278
- Returns
3279
- -------
3280
- list or topologicpy.Topology
3281
- The list of imported topologies. If the list only contains one element, it returns that element.
3282
-
3283
- """
3284
-
3285
- from topologicpy.Dictionary import Dictionary
3286
- from topologicpy.Context import Context
3287
- from topologicpy.Vertex import Vertex
3288
- from topologicpy.Edge import Edge
3289
- from topologicpy.Wire import Wire
3290
- from topologicpy.Face import Face
3291
- from topologicpy.Shell import Shell
3292
- from topologicpy.Cell import Cell
3293
- from topologicpy.CellComplex import CellComplex
3294
- from topologicpy.Cluster import Cluster
3295
- from topologicpy.Aperture import Aperture
3296
- from topologicpy.Helper import Helper
3297
- from topologicpy.Topology import Topology
3298
- from tqdm.auto import tqdm
3299
- import time
3300
-
3301
- def getUUID(topology, uuidKey="uuid"):
3302
- d = Topology.Dictionary(topology)
3303
- if d == None:
3304
- uuidOne = str(uuid.uuid1())
3305
- d = Dictionary.ByKeyValue(uuidKey, uuidOne)
3306
- elif uuidKey not in Dictionary.Keys(d):
3307
- uuidOne = str(uuid.uuid1())
3308
- d = Dictionary.SetValueAtKey(d, uuidKey, uuidOne)
3309
- topology = Topology.SetDictionary(topology, d)
3310
- else:
3311
- uuidOne = Dictionary.ValueAtKey(d, uuidKey)
3312
- return uuidOne
3313
-
3314
- def find_json_item(json_list, key, value):
3315
- for item in json_list:
3316
- if key in item and item[key] == value:
3317
- return item
3318
- return None
3319
-
3320
- def buildAperture(j_aperture):
3321
- j_vertices = []
3322
- j_edges = []
3323
- j_wires = []
3324
- j_faces = []
3325
- j_shells = []
3326
- j_cells = []
3327
- j_cellComplexes = []
3328
- for jsonItem in j_aperture:
3329
- topology_type = jsonItem['type']
3330
- if topology_type.lower() == "vertex":
3331
- j_vertices.append(jsonItem)
3332
- elif topology_type.lower() == "edge":
3333
- j_edges.append(jsonItem)
3334
- elif topology_type.lower() == "wire":
3335
- j_wires.append(jsonItem)
3336
- elif topology_type.lower() == "face":
3337
- j_faces.append(jsonItem)
3338
- elif topology_type.lower() == "shell":
3339
- j_shells.append(jsonItem)
3340
- elif topology_type.lower() == "cell":
3341
- j_cells.append(jsonItem)
3342
- elif topology_type.lower() == "cellcomplex":
3343
- j_cellComplexes.append(jsonItem)
3344
-
3345
- vertices = [buildVertex(j_v) for j_v in j_vertices]
3346
- edges = [buildEdge(j_e, j_vertices, uuidKey="uuid") for j_e in j_edges]
3347
- wires = [buildWire(j_w, j_edges, j_vertices, uuidKey="uuid") for j_w in j_wires]
3348
- faces = [buildFace(j_f, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_f in j_faces]
3349
- faces = Helper.Flatten(faces)
3350
- shells = [buildShell(j_s, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_s in j_shells]
3351
- cells = [buildCell(j_c, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_c in j_cells]
3352
- cellComplexes = [buildCellComplex(j_cc, j_cells, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_cc in j_cellComplexes]
3353
- if len(cellComplexes) > 0:
3354
- everything = cellComplexes
3355
- elif len(cells) > 0:
3356
- everything = cells
3357
- elif len(shells) > 0:
3358
- everything = shells
3359
- elif len(faces) > 0:
3360
- everything = faces
3361
- elif len(wires) > 0:
3362
- everything = wires
3363
- elif len(edges) > 0:
3364
- everything = edges
3365
- elif len(vertices) > 0:
3366
- everything = vertices
3367
- else:
3368
- return None
3369
- if len(everything) == 1:
3370
- aperture = everything[0]
3371
- else:
3372
- aperture = Topology.SelfMerge(Cluster.ByTopologies(everything), tolerance=tolerance)
3373
- return aperture
3374
-
3375
- def buildVertex(json_item):
3376
- x, y, z = json_item['coordinates']
3377
- d = json_item['dictionary']
3378
- v = Vertex.ByCoordinates(x, y, z)
3379
- if v == None:
3380
- print("Topology.ByJSONString - Error: Could not build a vertex. Returning None.")
3381
- return None
3382
- v = Topology.SetDictionary(v, Dictionary.ByPythonDictionary(d))
3383
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3384
- context = Context.ByTopologyParameters(v, u=0.5, v=0.5, w=0.5)
3385
- for ap in apertures:
3386
- _ = Aperture.ByTopologyContext(ap, context)
3387
- return v
3388
-
3389
- def buildEdge(json_item, j_vertices, uuidKey="uuid", tolerance=0.0001):
3390
- edge_vertices = json_item['vertices']
3391
- vertices = []
3392
- for j_v in edge_vertices:
3393
- vertices.append(buildVertex(find_json_item(j_vertices, uuidKey, j_v)))
3394
- e = Edge.ByVertices(vertices, tolerance=tolerance)
3395
- if e == None:
3396
- print("Topology.ByJSONString - Error: Could not build an edge. Returning None.")
3397
- return None
3398
- d = json_item['dictionary']
3399
- e = Topology.SetDictionary(e, Dictionary.ByPythonDictionary(d))
3400
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3401
- context = Context.ByTopologyParameters(e, u=0.5, v=0.5, w=0.5)
3402
- for ap in apertures:
3403
- _ = Aperture.ByTopologyContext(ap, context)
3404
- return e
3405
-
3406
- def buildWire(json_item, j_edges, j_vertices, uuidKey="uuid", tolerance=0.0001):
3407
- wire_edges = json_item['edges']
3408
- edges = []
3409
- for j_e in wire_edges:
3410
- edges.append(buildEdge(find_json_item(j_edges, uuidKey, j_e), j_vertices, uuidKey=uuidKey, tolerance=tolerance))
3411
- w = Wire.ByEdges(edges, tolerance=tolerance)
3412
- if w == None:
3413
- print("Topology.ByJSONString - Error: Could not build a wire. Returning None.")
3414
- return None
3415
- d = json_item['dictionary']
3416
- w = Topology.SetDictionary(w, Dictionary.ByPythonDictionary(d))
3417
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3418
- context = Context.ByTopologyParameters(w, u=0.5, v=0.5, w=0.5)
3419
- for ap in apertures:
3420
- _ = Aperture.ByTopologyContext(ap, context)
3421
- return w
3422
-
3423
- def buildFace(json_item, j_wires, j_edges, j_vertices, uuidKey="uuid", tolerance=0.0001):
3424
- face_wires = json_item['wires']
3425
- external_boundary = buildWire(find_json_item(j_wires, uuidKey, face_wires[0]), j_edges, j_vertices, uuidKey=uuidKey, tolerance=tolerance)
3426
- if not Topology.IsInstance(external_boundary, "Wire"):
3427
- print("Topology.ByJSONString - ERROR: Something went wrong with original external boundary. Returning None.")
3428
- return None
3429
- if not Topology.IsPlanar(external_boundary, tolerance=tolerance):
3430
- temp_boundary = Wire.Planarize(external_boundary, tolerance=tolerance)
3431
- if temp_boundary == None or not Topology.IsInstance(temp_boundary, "Wire"):
3432
- print("Topology.ByJSONString - Error: Something went wrong with external boundary. Returning None.")
3433
- return None
3434
- else:
3435
- external_boundary = temp_boundary
3436
- if not Wire.IsClosed(external_boundary):
3437
- external_boundary = Wire.Close(external_boundary)
3438
- internal_boundaries = []
3439
- for j_w in face_wires[1:]:
3440
- ib = buildWire(find_json_item(j_wires, uuidKey, j_w),j_edges, j_vertices, uuidKey=uuidKey)
3441
- if not Topology.IsPlanar(external_boundary):
3442
- ib = Wire.Planarize(ib)
3443
- if not Topology.IsInstance(ib, "Wire"):
3444
- print("Topology.ByJSONString - ERROR: Something went wrong with original internal boundary. Returning None.")
3445
- return None
3446
- if not Wire.IsClosed(ib):
3447
- ib = Wire.Close(ib)
3448
- internal_boundaries.append(ib)
3449
-
3450
- f = Face.ByWires(external_boundary, internal_boundaries, tolerance=tolerance)
3451
- if not Topology.IsInstance(f, "Face"):
3452
- print("Topology.ByJSONString - Error: Could not build a face. Returning None.", f, "Ex Bound:", external_boundary)
3453
- return None
3454
- area = Face.Area(f)
3455
- if area == None:
3456
- print("Topology.ByJSONString - Error: Could not compute the area of the built face. Returning None.")
3457
- return None
3458
- if Face.Area(f) < 0:
3459
- external_boundary = Wire.Invert(external_boundary)
3460
- f = Face.ByWires(external_boundary, internal_boundaries, tolerance=tolerance)
3461
- if f == None:
3462
- print("Topology.ByJSONString - Error: Could not build a face. Returning None.")
3463
- return None
3464
- d = json_item['dictionary']
3465
- f = Topology.SetDictionary(f, Dictionary.ByPythonDictionary(d))
3466
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3467
- if len(apertures) > 0:
3468
- context = Context.ByTopologyParameters(f, u=0.5, v=0.5, w=0.5)
3469
- for ap in apertures:
3470
- _ = Aperture.ByTopologyContext(ap, context)
3471
- return f
3472
-
3473
- def buildShell(json_item, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid", tolerance=0.0001):
3474
- shell_faces = json_item['faces']
3475
- faces = []
3476
- for j_f in shell_faces:
3477
- faces.append(buildFace(find_json_item(j_faces, uuidKey, j_f), j_wires, j_edges, j_vertices, uuidKey=uuidKey))
3478
- faces = Helper.Flatten(faces)
3479
- s = Shell.ByFaces(faces, tolerance=tolerance) # This can return a list
3480
- if not Topology.IsInstance(s, "Shell"):
3481
- print("Topology.ByJSONString - Error: Could not build a shell. Returning None.")
3482
- return None
3483
- d = json_item['dictionary']
3484
- s = Topology.SetDictionary(s, Dictionary.ByPythonDictionary(d))
3485
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3486
- if len(apertures) > 0:
3487
- context = Context.ByTopologyParameters(s, u=0.5, v=0.5, w=0.5)
3488
- for ap in apertures:
3489
- _ = Aperture.ByTopologyContext(ap, context)
3490
- return s
3491
-
3492
- def buildCell(json_item, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid", tolerance=0.0001):
3493
- cell_shells = json_item['shells']
3494
- external_boundary = buildShell(find_json_item(j_shells, uuidKey, cell_shells[0]), j_faces, j_wires, j_edges, j_vertices, uuidKey=uuidKey, tolerance=tolerance)
3495
- internal_boundaries = []
3496
- for j_s in cell_shells[1:]:
3497
- internal_boundaries.append(buildShell(find_json_item(j_shells, uuidKey, j_s), j_faces, j_wires, j_edges, j_vertices, uuidKey=uuidKey, tolerance=tolerance))
3498
- c = Cell.ByShell(external_boundary)
3499
- if c == None:
3500
- print("Topology.ByJSONString - Error: Could not build a cell. Returning None.")
3501
- return None
3502
- for ib in internal_boundaries:
3503
- ib_c = Cell.ByShell(ib)
3504
- c = Topology.Difference(c, ib_c, tolerance=tolerance)
3505
- d = json_item['dictionary']
3506
- c = Topology.SetDictionary(c, Dictionary.ByPythonDictionary(d))
3507
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3508
- context = Context.ByTopologyParameters(c, u=0.5, v=0.5, w=0.5)
3509
- for ap in apertures:
3510
- _ = Aperture.ByTopologyContext(ap, context)
3511
- return c
3512
-
3513
- def buildCellComplex(json_item, j_cells, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid", tolerance=0.0001):
3514
- cc_cells = json_item['cells']
3515
- cells = []
3516
- for j_c in cc_cells:
3517
- cells.append(buildCell(find_json_item(j_cells, uuidKey, j_c), j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey=uuidKey, tolerance=tolerance))
3518
- cc = CellComplex.ByCells(cells, transferDictionaries=False, silent=True, tolerance=tolerance)
3519
- if cc == None:
3520
- print("Topology.ByJSONString - Error: Could not build a cellcomplex. Returning None.")
3521
- return None
3522
- d = json_item['dictionary']
3523
- cc = Topology.SetDictionary(cc, Dictionary.ByPythonDictionary(d))
3524
- apertures = [buildAperture(j_ap) for j_ap in json_item['apertures']]
3525
- context = Context.ByTopologyParameters(cc, u=0.5, v=0.5, w=0.5)
3526
- for ap in apertures:
3527
- _ = Aperture.ByTopologyContext(ap, context)
3528
- return cc
3529
-
3530
- def addAperturesUUID(topology, uuidKey="uuid"):
3531
- topology_apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(topology)]
3532
- apertures_uuid = []
3533
- for top_a in topology_apertures:
3534
- uuid = getUUID(top_a, uuidKey=uuidKey)
3535
- apertures_uuid.append(uuid)
3536
- d = Topology.Dictionary(topology)
3537
- d = Dictionary.SetValueAtKey(d, 'apertures', apertures_uuid)
3538
- topology = Topology.SetDictionary(topology, d)
3539
- s = Topology.InternalVertex(topology, tolerance=tolerance)
3540
- s = Topology.SetDictionary(s, d)
3541
- return topology, s, topology_apertures
3542
-
3543
- def findAperture(uuid, apertures, uuidKey="uuid"):
3544
- for ap in apertures:
3545
- d = Topology.Dictionary(ap)
3546
- ap_uuid = Dictionary.ValueAtKey(d, uuidKey)
3547
- if uuid == ap_uuid:
3548
- return ap
3549
- return None
3550
-
3551
- def setApertures(topology, allApertures, uuidKey="uuid"):
3552
- apertures = []
3553
- d = Topology.Dictionary(topology)
3554
- apertures_uuid = Dictionary.ValueAtKey(d, 'apertures')
3555
- if not isinstance(apertures_uuid, list):
3556
- apertures_uuid = [apertures_uuid]
3557
- for ap_uuid in apertures_uuid:
3558
- ap = findAperture(ap_uuid, allApertures, uuidKey=uuidKey)
3559
- if ap != None:
3560
- apertures.append(ap)
3561
- context = Context.ByTopologyParameters(topology, u=0.5, v=0.5, w=0.5)
3562
-
3563
- for ap in apertures:
3564
- _ = Aperture.ByTopologyContext(ap, context)
3565
- return topology
3566
-
3567
-
3568
- jsondata = json.loads(string)
3569
- if not isinstance(jsondata, list):
3570
- jsondata = [jsondata]
3571
-
3572
- j_vertices = []
3573
- j_edges = []
3574
- j_wires = []
3575
- j_faces = []
3576
- j_shells = []
3577
- j_cells = []
3578
- j_cellComplexes = []
3579
-
3580
- vertices = []
3581
- edges = []
3582
- wires = []
3583
- faces = []
3584
- shells = []
3585
- cells = []
3586
- cellComplexes = []
3587
-
3588
- if progressBar:
3589
- for jsonItem in tqdm(jsondata):
3590
- try:
3591
- topology_type = jsonItem['type']
3592
- if topology_type.lower() == "vertex":
3593
- j_vertices.append(jsonItem)
3594
- elif topology_type.lower() == "edge":
3595
- j_edges.append(jsonItem)
3596
- elif topology_type.lower() == "wire":
3597
- j_wires.append(jsonItem)
3598
- elif topology_type.lower() == "face":
3599
- j_faces.append(jsonItem)
3600
- elif topology_type.lower() == "shell":
3601
- j_shells.append(jsonItem)
3602
- elif topology_type.lower() == "cell":
3603
- j_cells.append(jsonItem)
3604
- elif topology_type.lower() == "cellcomplex":
3605
- j_cellComplexes.append(jsonItem)
3606
- except:
3607
- continue
3608
- else:
3609
- for jsonItem in jsondata:
3610
- try:
3611
- topology_type = jsonItem['type']
3612
- if topology_type.lower() == "vertex":
3613
- j_vertices.append(jsonItem)
3614
- elif topology_type.lower() == "edge":
3615
- j_edges.append(jsonItem)
3616
- elif topology_type.lower() == "wire":
3617
- j_wires.append(jsonItem)
3618
- elif topology_type.lower() == "face":
3619
- j_faces.append(jsonItem)
3620
- elif topology_type.lower() == "shell":
3621
- j_shells.append(jsonItem)
3622
- elif topology_type.lower() == "cell":
3623
- j_cells.append(jsonItem)
3624
- elif topology_type.lower() == "cellcomplex":
3625
- j_cellComplexes.append(jsonItem)
3626
- except:
3627
- continue
3628
-
3629
- vertices = [buildVertex(j_v) for j_v in j_vertices]
3630
- vertex_selectors = []
3631
- all_vertex_apertures = []
3632
- for v in vertices:
3633
- v, s, vertex_apertures = addAperturesUUID(v, uuidKey="uuid")
3634
- all_vertex_apertures += vertex_apertures
3635
- vertex_selectors.append(s)
3636
-
3637
- edges = [buildEdge(j_e, j_vertices, uuidKey="uuid") for j_e in j_edges]
3638
- edge_selectors = []
3639
- all_edge_apertures = []
3640
- for e in edges:
3641
- e, s, edge_apertures = addAperturesUUID(e, uuidKey="uuid")
3642
- all_edge_apertures += edge_apertures
3643
- edge_selectors.append(s)
3644
-
3645
- wires = [buildWire(j_w, j_edges, j_vertices, uuidKey="uuid") for j_w in j_wires]
3646
- wire_selectors = []
3647
- all_wire_apertures = []
3648
- for w in wires:
3649
- w, s, wire_apertures = addAperturesUUID(w, uuidKey="uuid")
3650
- all_wire_apertures += wire_apertures
3651
- wire_selectors.append(s)
3652
-
3653
- faces = []
3654
- for j_f in j_faces:
3655
- f = buildFace(j_f, j_wires, j_edges, j_vertices, uuidKey="uuid")
3656
- faces.append(f)
3657
-
3658
- faces = Helper.Flatten(faces)
3659
- face_selectors = []
3660
- all_face_apertures = []
3661
- for f in faces:
3662
- f, s, face_apertures = addAperturesUUID(f, uuidKey="uuid")
3663
- all_face_apertures += face_apertures
3664
- face_selectors.append(s)
3665
-
3666
- shells = [buildShell(j_s, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_s in j_shells]
3667
- shell_selectors = []
3668
- all_shell_apertures = []
3669
- for sh in shells:
3670
- sh, s, shell_apertures = addAperturesUUID(sh, uuidKey="uuid")
3671
- all_shell_apertures += shell_apertures
3672
- shell_selectors.append(s)
3673
-
3674
- cells = [buildCell(j_c, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_c in j_cells]
3675
- cell_selectors = []
3676
- all_cell_apertures = []
3677
- for c in cells:
3678
- c, s, cell_apertures = addAperturesUUID(c, uuidKey="uuid")
3679
- all_cell_apertures += cell_apertures
3680
- cell_selectors.append(s)
3681
-
3682
- cellComplexes = [buildCellComplex(j_cc, j_cells, j_shells, j_faces, j_wires, j_edges, j_vertices, uuidKey="uuid") for j_cc in j_cellComplexes]
3683
- cellComplex_selectors = []
3684
- all_cellComplex_apertures = []
3685
- for cc in cellComplexes:
3686
- cc, s, cellComplex_apertures = addAperturesUUID(cc, uuidKey="uuid")
3687
- all_cellComplex_apertures += cellComplex_apertures
3688
- cellComplex_selectors.append(s)
3689
-
3690
- everything = vertices+edges+wires+faces+shells+cells+cellComplexes
3691
- toplevelTopologies = []
3692
- for ev in everything:
3693
- d = Topology.Dictionary(ev)
3694
- if Dictionary.ValueAtKey(d,'toplevel') == True:
3695
- toplevelTopologies.append(ev)
3696
- return_topologies = []
3697
- for tp in toplevelTopologies:
3698
- # This is a hack because sometimes the imported topologies get weird. I think it is an opencascade bug.
3699
- tp = Topology.ByBREPString(Topology.BREPString(tp))
3700
- if len(all_vertex_apertures) > 0:
3701
- tp_vertices = Topology.Vertices(tp)
3702
- for tp_vertex in tp_vertices:
3703
- tp_vertex = setApertures(tp_vertex, all_vertex_apertures, uuidKey="uuid")
3704
- if len(all_edge_apertures) > 0:
3705
- tp_edges = Topology.Edges(tp)
3706
- for tp_edge in tp_edges:
3707
- tp_edge = setApertures(tp_edge, all_edge_apertures, uuidKey="uuid")
3708
- if len(all_face_apertures) > 0:
3709
- tp_faces = Topology.Faces(tp)
3710
- for tp_face in tp_faces:
3711
- tp_face = setApertures(tp_face, all_face_apertures, uuidKey="uuid")
3712
- if len(all_cell_apertures) > 0:
3713
- tp_cells = Topology.Cells(tp)
3714
- for tp_cell in tp_cells:
3715
- tp_cell = setApertures(tp_cell, all_cell_apertures, uuidKey="uuid")
3716
-
3717
- if len(vertex_selectors) > 0:
3718
- _ = Topology.TransferDictionariesBySelectors(tp, vertex_selectors, tranVertices=True, tolerance=tolerance)
3719
- if len(edge_selectors) > 0:
3720
- _ = Topology.TransferDictionariesBySelectors(tp, edge_selectors, tranEdges=True, tolerance=tolerance)
3721
- if len(face_selectors) > 0:
3722
- _ = Topology.TransferDictionariesBySelectors(tp, face_selectors, tranFaces=True, tolerance=tolerance)
3723
- if len(cell_selectors) > 0:
3724
- _ = Topology.TransferDictionariesBySelectors(tp, cell_selectors, tranCells=True, tolerance=tolerance)
3725
-
3726
- return_topologies.append(tp)
3727
-
3728
- if len(return_topologies) == 1:
3729
- return return_topologies[0]
3730
- else:
3731
- return return_topologies
3732
3265
 
3733
3266
  @staticmethod
3734
3267
  def ByOBJFile(objFile, mtlFile = None,
@@ -5526,13 +5059,11 @@ class Topology():
5526
5059
  return returnDict
5527
5060
 
5528
5061
  def getFace(topology, uuidKey="uuid"):
5529
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(topology)]
5530
5062
  returnDict = {}
5531
5063
  uuidOne = getUUID(topology, uuidKey=uuidKey)
5532
5064
  returnDict['type'] = "Face"
5533
5065
  returnDict['uuid'] = uuidOne
5534
5066
  wires = []
5535
- external_boundary = Face.ExternalBoundary(topology)
5536
5067
  wires.append(getUUID(Face.ExternalBoundary(topology), uuidKey=uuidKey))
5537
5068
  internal_boundaries = [getUUID(ib, uuidKey=uuidKey) for ib in Face.InternalBoundaries(topology)]
5538
5069
  wires += internal_boundaries
@@ -5592,7 +5123,7 @@ class Topology():
5592
5123
  d = getCellComplex(topology, uuidKey=uuidKey)
5593
5124
  d['dictionary']['toplevel'] = topLevel
5594
5125
  json_data += getSubTopologyData(topology, uuidKey=uuidKey)
5595
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(topology)]
5126
+ apertures = Topology.Apertures(topology)
5596
5127
  aperture_data = []
5597
5128
  for ap in apertures:
5598
5129
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5606,7 +5137,7 @@ class Topology():
5606
5137
  for v in vertices:
5607
5138
  d = getVertex(v, uuidKey=uuidKey)
5608
5139
  d['dictionary']['toplevel'] = False
5609
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(v)]
5140
+ apertures = Topology.Apertures(v)
5610
5141
  aperture_data = []
5611
5142
  for ap in apertures:
5612
5143
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5616,7 +5147,7 @@ class Topology():
5616
5147
  for e in edges:
5617
5148
  d = getEdge(e, uuidKey=uuidKey)
5618
5149
  d['dictionary']['toplevel'] = False
5619
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(e)]
5150
+ apertures = Topology.Apertures(e)
5620
5151
  aperture_data = []
5621
5152
  for ap in apertures:
5622
5153
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5626,7 +5157,7 @@ class Topology():
5626
5157
  for w in wires:
5627
5158
  d = getWire(w, uuidKey=uuidKey)
5628
5159
  d['dictionary']['toplevel'] = False
5629
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(w)]
5160
+ apertures = Topology.Apertures(w)
5630
5161
  aperture_data = []
5631
5162
  for ap in apertures:
5632
5163
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5636,7 +5167,7 @@ class Topology():
5636
5167
  for f in faces:
5637
5168
  d = getFace(f, uuidKey=uuidKey)
5638
5169
  d['dictionary']['toplevel'] = False
5639
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(f)]
5170
+ apertures = Topology.Apertures(f)
5640
5171
  aperture_data = []
5641
5172
  for ap in apertures:
5642
5173
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5646,7 +5177,7 @@ class Topology():
5646
5177
  for s in shells:
5647
5178
  d = getShell(s, uuidKey=uuidKey)
5648
5179
  d['dictionary']['toplevel'] = False
5649
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(s)]
5180
+ apertures = Topology.Apertures(s)
5650
5181
  aperture_data = []
5651
5182
  for ap in apertures:
5652
5183
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5656,7 +5187,7 @@ class Topology():
5656
5187
  for c in cells:
5657
5188
  d = getCell(c, uuidKey=uuidKey)
5658
5189
  d['dictionary']['toplevel'] = False
5659
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(c)]
5190
+ apertures = Topology.Apertures(c)
5660
5191
  aperture_data = []
5661
5192
  for ap in apertures:
5662
5193
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5666,7 +5197,7 @@ class Topology():
5666
5197
  for cc in cellComplexes:
5667
5198
  d = getCellComplex(cc, uuidKey=uuidKey)
5668
5199
  d['dictionary']['toplevel'] = False
5669
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(cc)]
5200
+ apertures = Topology.Apertures(cc)
5670
5201
  aperture_data = []
5671
5202
  for ap in apertures:
5672
5203
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -5695,7 +5226,7 @@ class Topology():
5695
5226
  return None
5696
5227
  d['dictionary']['toplevel'] = topLevel
5697
5228
  json_data += getSubTopologyData(topology, uuidKey=uuidKey)
5698
- apertures = [Aperture.Topology(ap) for ap in Topology.Apertures(topology)]
5229
+ apertures = Topology.Apertures(topology)
5699
5230
  aperture_data = []
5700
5231
  for ap in apertures:
5701
5232
  aperture_data.append(getApertureData(ap, topLevel=False, uuidKey=uuidKey))
@@ -8630,7 +8161,7 @@ class Topology():
8630
8161
  elif subTopologyType.lower() == "cluster":
8631
8162
  _ = topology.Clusters(None, subTopologies)
8632
8163
  elif subTopologyType.lower() == "aperture":
8633
- _ = topology.Apertures(subTopologies)
8164
+ subTopologies = Topology.Apertures(topology)
8634
8165
  if not subTopologies:
8635
8166
  return [] # Make sure to return an empty list instead of None
8636
8167
  return subTopologies
@@ -9217,13 +8748,13 @@ class Topology():
9217
8748
  namespace_uuid = uuid.uuid5(predefined_namespace_dns, namespace)
9218
8749
  cellComplexes = Topology.CellComplexes(topology)
9219
8750
  cells = Topology.Cells(topology)
9220
- Shells = Topology.Shells(topology)
9221
- Faces = Topology.Faces(topology)
9222
- Wires = Topology.Wires(topology)
9223
- Edges = Topology.Edges(topology)
9224
- Vertices = Topology.Vertices(topology)
9225
- Apertures = Topology.Apertures(topology, subTopologyType="all")
9226
- subTopologies = cellComplexes+cells+Shells+Faces+Wires+Edges+Vertices+Apertures
8751
+ shells = Topology.Shells(topology)
8752
+ faces = Topology.Faces(topology)
8753
+ wires = Topology.Wires(topology)
8754
+ edges = Topology.Edges(topology)
8755
+ vertices = Topology.Vertices(topology)
8756
+ apertures = Topology.Apertures(topology, subTopologyType="all")
8757
+ subTopologies = cellComplexes+cells+shells+faces+wires+edges+vertices+apertures
9227
8758
  dictionaries = [Dictionary.PythonDictionary(Topology.Dictionary(topology))]
9228
8759
  dictionaries += [Dictionary.PythonDictionary(Topology.Dictionary(s)) for s in subTopologies]
9229
8760
  dict_str = str(dictionaries)
topologicpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.7.54'
1
+ __version__ = '0.7.56'