topologicpy 0.2.1__py3-none-any.whl → 0.2.3__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/Cell.py +129 -127
- topologicpy/CellComplex.py +21 -23
- topologicpy/Cluster.py +7 -11
- topologicpy/DGL.py +10 -5
- topologicpy/Face.py +124 -38
- topologicpy/Honeybee.py +158 -334
- topologicpy/Plotly.py +51 -33
- topologicpy/Shell.py +30 -50
- topologicpy/Topology.py +231 -79
- topologicpy/UnitTest.py +2 -2
- topologicpy/Vector.py +242 -17
- topologicpy/Wire.py +38 -66
- topologicpy/__init__.py +1 -1
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/METADATA +3 -1
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/RECORD +18 -18
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/LICENSE +0 -0
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/WHEEL +0 -0
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
|
@@ -1073,13 +1073,13 @@ class Topology():
|
|
|
1073
1073
|
if len(faces) == 1:
|
|
1074
1074
|
return faces[0]
|
|
1075
1075
|
if outputMode.lower() == "cell":
|
|
1076
|
-
output = Cell.ByFaces(faces, tolerance)
|
|
1076
|
+
output = Cell.ByFaces(faces, tolerance=tolerance)
|
|
1077
1077
|
if output:
|
|
1078
1078
|
return output
|
|
1079
1079
|
else:
|
|
1080
1080
|
return None
|
|
1081
1081
|
if outputMode.lower() == "cellcomplex":
|
|
1082
|
-
output = CellComplex.ByFaces(faces, tolerance)
|
|
1082
|
+
output = CellComplex.ByFaces(faces, tolerance=tolerance)
|
|
1083
1083
|
if output:
|
|
1084
1084
|
return output
|
|
1085
1085
|
else:
|
|
@@ -1243,7 +1243,7 @@ class Topology():
|
|
|
1243
1243
|
topologies = []
|
|
1244
1244
|
if ifc_file:
|
|
1245
1245
|
settings = ifcopenshell.geom.settings()
|
|
1246
|
-
settings.set(settings.DISABLE_TRIANGULATION,
|
|
1246
|
+
settings.set(settings.DISABLE_TRIANGULATION, True)
|
|
1247
1247
|
settings.set(settings.USE_BREP_DATA, True)
|
|
1248
1248
|
settings.set(settings.USE_WORLD_COORDS, True)
|
|
1249
1249
|
settings.set(settings.SEW_SHELLS, True)
|
|
@@ -1283,13 +1283,13 @@ class Topology():
|
|
|
1283
1283
|
|
|
1284
1284
|
'''
|
|
1285
1285
|
@staticmethod
|
|
1286
|
-
def ByImportedIFC(
|
|
1286
|
+
def ByImportedIFC(path, typeList):
|
|
1287
1287
|
"""
|
|
1288
1288
|
NOT DONE YET
|
|
1289
1289
|
|
|
1290
1290
|
Parameters
|
|
1291
1291
|
----------
|
|
1292
|
-
|
|
1292
|
+
path : TYPE
|
|
1293
1293
|
DESCRIPTION.
|
|
1294
1294
|
typeList : TYPE
|
|
1295
1295
|
DESCRIPTION.
|
|
@@ -1364,7 +1364,7 @@ class Topology():
|
|
|
1364
1364
|
settings.set(settings.SEW_SHELLS,True)
|
|
1365
1365
|
settings.set(settings.USE_WORLD_COORDS,False)
|
|
1366
1366
|
|
|
1367
|
-
ifc_file = ifcopenshell.open(
|
|
1367
|
+
ifc_file = ifcopenshell.open(path)
|
|
1368
1368
|
if len(typeList) < 1:
|
|
1369
1369
|
typeList = ifc_file.types()
|
|
1370
1370
|
returnList = []
|
|
@@ -1443,13 +1443,13 @@ class Topology():
|
|
|
1443
1443
|
return topology
|
|
1444
1444
|
'''
|
|
1445
1445
|
@staticmethod
|
|
1446
|
-
def ByImportedJSONMK1(
|
|
1446
|
+
def ByImportedJSONMK1(path, tolerance=0.0001):
|
|
1447
1447
|
"""
|
|
1448
1448
|
Imports the topology from a JSON file.
|
|
1449
1449
|
|
|
1450
1450
|
Parameters
|
|
1451
1451
|
----------
|
|
1452
|
-
|
|
1452
|
+
path : str
|
|
1453
1453
|
The file path to the json file.
|
|
1454
1454
|
tolerance : float , optional
|
|
1455
1455
|
The desired tolerance. The default is 0.0001.
|
|
@@ -1507,7 +1507,7 @@ class Topology():
|
|
|
1507
1507
|
return v
|
|
1508
1508
|
|
|
1509
1509
|
topology = None
|
|
1510
|
-
file = open(
|
|
1510
|
+
file = open(path)
|
|
1511
1511
|
if file:
|
|
1512
1512
|
topologies = []
|
|
1513
1513
|
jsondata = json.load(file)
|
|
@@ -1570,13 +1570,13 @@ class Topology():
|
|
|
1570
1570
|
return None
|
|
1571
1571
|
|
|
1572
1572
|
@staticmethod
|
|
1573
|
-
def ByImportedJSONMK2(
|
|
1573
|
+
def ByImportedJSONMK2(path, tolerance=0.0001):
|
|
1574
1574
|
"""
|
|
1575
1575
|
Imports the topology from a JSON file.
|
|
1576
1576
|
|
|
1577
1577
|
Parameters
|
|
1578
1578
|
----------
|
|
1579
|
-
|
|
1579
|
+
path : str
|
|
1580
1580
|
The file path to the json file.
|
|
1581
1581
|
tolerance : float , optional
|
|
1582
1582
|
The desired tolerance. The default is 0.0001.
|
|
@@ -1592,8 +1592,8 @@ class Topology():
|
|
|
1592
1592
|
returnApertures = []
|
|
1593
1593
|
for item in apertureList:
|
|
1594
1594
|
brepFileName = item['brep']
|
|
1595
|
-
|
|
1596
|
-
brepFile = open(
|
|
1595
|
+
breppath = os.path.join(folderPath, brepFileName+".brep")
|
|
1596
|
+
brepFile = open(breppath)
|
|
1597
1597
|
if brepFile:
|
|
1598
1598
|
brepString = brepFile.read()
|
|
1599
1599
|
aperture = Topology.ByString(brepString)
|
|
@@ -1637,15 +1637,15 @@ class Topology():
|
|
|
1637
1637
|
return v
|
|
1638
1638
|
|
|
1639
1639
|
topology = None
|
|
1640
|
-
jsonFile = open(
|
|
1641
|
-
folderPath = os.path.dirname(
|
|
1640
|
+
jsonFile = open(path)
|
|
1641
|
+
folderPath = os.path.dirname(path)
|
|
1642
1642
|
if jsonFile:
|
|
1643
1643
|
topologies = []
|
|
1644
1644
|
jsondata = json.load(jsonFile)
|
|
1645
1645
|
for jsonItem in jsondata:
|
|
1646
1646
|
brepFileName = jsonItem['brep']
|
|
1647
|
-
|
|
1648
|
-
brepFile = open(
|
|
1647
|
+
breppath = os.path.join(folderPath, brepFileName+".brep")
|
|
1648
|
+
brepFile = open(breppath)
|
|
1649
1649
|
if brepFile:
|
|
1650
1650
|
brepString = brepFile.read()
|
|
1651
1651
|
topology = Topology.ByString(brepString)
|
|
@@ -1707,13 +1707,13 @@ class Topology():
|
|
|
1707
1707
|
return None
|
|
1708
1708
|
|
|
1709
1709
|
@staticmethod
|
|
1710
|
-
def ByImportedOBJ(
|
|
1710
|
+
def ByImportedOBJ(path, transposeAxes = True, tolerance=0.0001):
|
|
1711
1711
|
"""
|
|
1712
1712
|
Imports the topology from a Weverfront OBJ file. This is a very experimental method and only works with simple planar solids. Materials and Colors are ignored.
|
|
1713
1713
|
|
|
1714
1714
|
Parameters
|
|
1715
1715
|
----------
|
|
1716
|
-
|
|
1716
|
+
path : str
|
|
1717
1717
|
The file path to the OBJ file.
|
|
1718
1718
|
transposeAxes : bool , optional
|
|
1719
1719
|
If set to True the Z and Y coordinates are transposed so that Y points "up"
|
|
@@ -1728,7 +1728,7 @@ class Topology():
|
|
|
1728
1728
|
"""
|
|
1729
1729
|
vertices = []
|
|
1730
1730
|
faces = []
|
|
1731
|
-
file = open(
|
|
1731
|
+
file = open(path)
|
|
1732
1732
|
if file:
|
|
1733
1733
|
lines = file.readlines()
|
|
1734
1734
|
for i in range(len(lines)):
|
|
@@ -2010,7 +2010,7 @@ class Topology():
|
|
|
2010
2010
|
from topologicpy.Shell import Shell
|
|
2011
2011
|
from topologicpy.Cell import Cell
|
|
2012
2012
|
from topologicpy.Cluster import Cluster
|
|
2013
|
-
def convexHull3D(item,
|
|
2013
|
+
def convexHull3D(item, tolerance, option):
|
|
2014
2014
|
if item:
|
|
2015
2015
|
vertices = []
|
|
2016
2016
|
_ = item.Vertices(None, vertices)
|
|
@@ -2038,7 +2038,7 @@ class Topology():
|
|
|
2038
2038
|
edges.append(Edge.ByVertices([sv, ev]))
|
|
2039
2039
|
faces.append(Face.ByWire(Wire.ByEdges(edges)))
|
|
2040
2040
|
try:
|
|
2041
|
-
c = Cell.ByFaces(faces,
|
|
2041
|
+
c = Cell.ByFaces(faces, tolerance=tolerance)
|
|
2042
2042
|
return c
|
|
2043
2043
|
except:
|
|
2044
2044
|
returnTopology = Cluster.SelfMerge(Cluster.ByTopologies(faces))
|
|
@@ -2308,7 +2308,7 @@ class Topology():
|
|
|
2308
2308
|
|
|
2309
2309
|
|
|
2310
2310
|
@staticmethod
|
|
2311
|
-
def ExportToBRep(topology,
|
|
2311
|
+
def ExportToBRep(topology, path, overwrite=True, version=3):
|
|
2312
2312
|
"""
|
|
2313
2313
|
Exports the input topology to a BREP file. See https://dev.opencascade.org/doc/occt-6.7.0/overview/html/occt_brep_format.html.
|
|
2314
2314
|
|
|
@@ -2316,7 +2316,7 @@ class Topology():
|
|
|
2316
2316
|
----------
|
|
2317
2317
|
topology : topologic.Topology
|
|
2318
2318
|
The input topology.
|
|
2319
|
-
|
|
2319
|
+
path : str
|
|
2320
2320
|
The input file path.
|
|
2321
2321
|
overwrite : bool , optional
|
|
2322
2322
|
If set to True the ouptut file will overwrite any pre-existing file. Otherwise, it won't.
|
|
@@ -2331,20 +2331,20 @@ class Topology():
|
|
|
2331
2331
|
"""
|
|
2332
2332
|
if not isinstance(topology, topologic.Topology):
|
|
2333
2333
|
return None
|
|
2334
|
-
if not isinstance(
|
|
2334
|
+
if not isinstance(path, str):
|
|
2335
2335
|
return None
|
|
2336
2336
|
# Make sure the file extension is .BREP
|
|
2337
|
-
ext =
|
|
2337
|
+
ext = path[len(path)-5:len(path)]
|
|
2338
2338
|
if ext.lower() != ".brep":
|
|
2339
|
-
|
|
2339
|
+
path = path+".brep"
|
|
2340
2340
|
f = None
|
|
2341
2341
|
try:
|
|
2342
2342
|
if overwrite == True:
|
|
2343
|
-
f = open(
|
|
2343
|
+
f = open(path, "w")
|
|
2344
2344
|
else:
|
|
2345
|
-
f = open(
|
|
2345
|
+
f = open(path, "x") # Try to create a new File
|
|
2346
2346
|
except:
|
|
2347
|
-
raise Exception("Error: Could not create a new file at the following location: "+
|
|
2347
|
+
raise Exception("Error: Could not create a new file at the following location: "+path)
|
|
2348
2348
|
if (f):
|
|
2349
2349
|
s = topology.String(version)
|
|
2350
2350
|
f.write(s)
|
|
@@ -2379,19 +2379,19 @@ class Topology():
|
|
|
2379
2379
|
"""
|
|
2380
2380
|
# topology, url, port, user, password = item
|
|
2381
2381
|
|
|
2382
|
-
def exportToBREP(topology,
|
|
2382
|
+
def exportToBREP(topology, path, overwrite):
|
|
2383
2383
|
# Make sure the file extension is .BREP
|
|
2384
|
-
ext =
|
|
2384
|
+
ext = path[len(path)-5:len(path)]
|
|
2385
2385
|
if ext.lower() != ".brep":
|
|
2386
|
-
|
|
2386
|
+
path = path+".brep"
|
|
2387
2387
|
f = None
|
|
2388
2388
|
try:
|
|
2389
2389
|
if overwrite == True:
|
|
2390
|
-
f = open(
|
|
2390
|
+
f = open(path, "w")
|
|
2391
2391
|
else:
|
|
2392
|
-
f = open(
|
|
2392
|
+
f = open(path, "x") # Try to create a new File
|
|
2393
2393
|
except:
|
|
2394
|
-
raise Exception("Error: Could not create a new file at the following location: "+
|
|
2394
|
+
raise Exception("Error: Could not create a new file at the following location: "+path)
|
|
2395
2395
|
if (f):
|
|
2396
2396
|
topString = topology.String()
|
|
2397
2397
|
f.write(topString)
|
|
@@ -2399,19 +2399,19 @@ class Topology():
|
|
|
2399
2399
|
return True
|
|
2400
2400
|
return False
|
|
2401
2401
|
|
|
2402
|
-
|
|
2403
|
-
if exportToBREP(topology,
|
|
2402
|
+
path = os.path.expanduser('~')+"/tempFile.brep"
|
|
2403
|
+
if exportToBREP(topology, path, True):
|
|
2404
2404
|
url = url.replace('http://','')
|
|
2405
2405
|
url = '/dns/'+url+'/tcp/'+port+'/https'
|
|
2406
2406
|
client = ipfshttpclient.connect(url, auth=(user, password))
|
|
2407
|
-
newfile = client.add(
|
|
2408
|
-
os.remove(
|
|
2407
|
+
newfile = client.add(path)
|
|
2408
|
+
os.remove(path)
|
|
2409
2409
|
return newfile['Hash']
|
|
2410
2410
|
return ''
|
|
2411
2411
|
'''
|
|
2412
2412
|
|
|
2413
2413
|
@staticmethod
|
|
2414
|
-
def ExportToJSONMK1(topologies,
|
|
2414
|
+
def ExportToJSONMK1(topologies, path, overwrite=False, tolerance=0.0001):
|
|
2415
2415
|
"""
|
|
2416
2416
|
Export the input list of topologies to a JSON file
|
|
2417
2417
|
|
|
@@ -2419,7 +2419,7 @@ class Topology():
|
|
|
2419
2419
|
----------
|
|
2420
2420
|
topologies : list
|
|
2421
2421
|
The input list of topologies.
|
|
2422
|
-
|
|
2422
|
+
path : str
|
|
2423
2423
|
The path to the JSON file.
|
|
2424
2424
|
overwrite : bool , optional
|
|
2425
2425
|
If set to True, any existing file will be overwritten. The default is False.
|
|
@@ -2557,20 +2557,20 @@ class Topology():
|
|
|
2557
2557
|
|
|
2558
2558
|
if not (isinstance(topologies,list)):
|
|
2559
2559
|
topologies = [topologies]
|
|
2560
|
-
#
|
|
2560
|
+
# path = item[1]
|
|
2561
2561
|
# tol = item[2]
|
|
2562
2562
|
# Make sure the file extension is .json
|
|
2563
|
-
ext =
|
|
2563
|
+
ext = path[len(path)-5:len(path)]
|
|
2564
2564
|
if ext.lower() != ".json":
|
|
2565
|
-
|
|
2565
|
+
path = path+".json"
|
|
2566
2566
|
f = None
|
|
2567
2567
|
try:
|
|
2568
2568
|
if overwrite == True:
|
|
2569
|
-
f = open(
|
|
2569
|
+
f = open(path, "w")
|
|
2570
2570
|
else:
|
|
2571
|
-
f = open(
|
|
2571
|
+
f = open(path, "x") # Try to create a new File
|
|
2572
2572
|
except:
|
|
2573
|
-
raise Exception("Error: Could not create a new file at the following location: "+
|
|
2573
|
+
raise Exception("Error: Could not create a new file at the following location: "+path)
|
|
2574
2574
|
if (f):
|
|
2575
2575
|
jsondata = []
|
|
2576
2576
|
for topology in topologies:
|
|
@@ -2592,7 +2592,7 @@ class Topology():
|
|
|
2592
2592
|
The input list of topologies.
|
|
2593
2593
|
folderPath : list
|
|
2594
2594
|
The path to the folder containing the json file and brep files.
|
|
2595
|
-
|
|
2595
|
+
path : str
|
|
2596
2596
|
The path to the JSON file.
|
|
2597
2597
|
overwrite : bool , optional
|
|
2598
2598
|
If set to True, any existing file will be overwritten. The default is False.
|
|
@@ -2702,8 +2702,8 @@ class Topology():
|
|
|
2702
2702
|
apertureDicts = []
|
|
2703
2703
|
for index, anAperture in enumerate(apertureList):
|
|
2704
2704
|
apertureName = brepName+"_aperture_"+str(index+1).zfill(5)
|
|
2705
|
-
|
|
2706
|
-
brepFile = open(
|
|
2705
|
+
breppath = os.path.join(folderPath, apertureName+".brep")
|
|
2706
|
+
brepFile = open(breppath, "w")
|
|
2707
2707
|
brepFile.write(anAperture.String())
|
|
2708
2708
|
brepFile.close()
|
|
2709
2709
|
apertureData = {}
|
|
@@ -2751,20 +2751,20 @@ class Topology():
|
|
|
2751
2751
|
if ext.lower() != ".json":
|
|
2752
2752
|
fileName = fileName+".json"
|
|
2753
2753
|
jsonFile = None
|
|
2754
|
-
|
|
2754
|
+
jsonpath = os.path.join(folderPath, fileName)
|
|
2755
2755
|
try:
|
|
2756
2756
|
if overwrite == True:
|
|
2757
|
-
jsonFile = open(
|
|
2757
|
+
jsonFile = open(jsonpath, "w")
|
|
2758
2758
|
else:
|
|
2759
|
-
jsonFile = open(
|
|
2759
|
+
jsonFile = open(jsonpath, "x") # Try to create a new File
|
|
2760
2760
|
except:
|
|
2761
|
-
raise Exception("Error: Could not create a new file at the following location: "+
|
|
2762
|
-
if (
|
|
2761
|
+
raise Exception("Error: Could not create a new file at the following location: "+jsonpath)
|
|
2762
|
+
if (jsonpath):
|
|
2763
2763
|
jsondata = []
|
|
2764
2764
|
for index, topology in enumerate(topologies):
|
|
2765
2765
|
brepName = "topology_"+str(index+1).zfill(5)
|
|
2766
|
-
|
|
2767
|
-
brepFile = open(
|
|
2766
|
+
breppath = os.path.join(folderPath, brepName+".brep")
|
|
2767
|
+
brepFile = open(breppath, "w")
|
|
2768
2768
|
brepFile.write(topology.String())
|
|
2769
2769
|
brepFile.close()
|
|
2770
2770
|
jsondata.append(getTopologyData(topology, brepName, folderPath, tolerance))
|
|
@@ -2774,7 +2774,7 @@ class Topology():
|
|
|
2774
2774
|
return False
|
|
2775
2775
|
|
|
2776
2776
|
@staticmethod
|
|
2777
|
-
def ExportToOBJ(topology,
|
|
2777
|
+
def ExportToOBJ(topology, path, transposeAxes=True, overwrite=True):
|
|
2778
2778
|
"""
|
|
2779
2779
|
Exports the input topology to a Wavefront OBJ file. This is very experimental and outputs a simple solid topology.
|
|
2780
2780
|
|
|
@@ -2782,7 +2782,7 @@ class Topology():
|
|
|
2782
2782
|
----------
|
|
2783
2783
|
topology : topologic.Topology
|
|
2784
2784
|
The input topology.
|
|
2785
|
-
|
|
2785
|
+
path : str
|
|
2786
2786
|
The input file path.
|
|
2787
2787
|
transposeAxes : bool , optional
|
|
2788
2788
|
If set to True the Z and Y coordinates are transposed so that Y points "up"
|
|
@@ -2802,13 +2802,13 @@ class Topology():
|
|
|
2802
2802
|
|
|
2803
2803
|
if not isinstance(topology, topologic.Topology):
|
|
2804
2804
|
return None
|
|
2805
|
-
if not overwrite and exists(
|
|
2805
|
+
if not overwrite and exists(path):
|
|
2806
2806
|
return None
|
|
2807
2807
|
|
|
2808
2808
|
# Make sure the file extension is .txt
|
|
2809
|
-
ext =
|
|
2809
|
+
ext = path[len(path)-4:len(path)]
|
|
2810
2810
|
if ext.lower() != ".obj":
|
|
2811
|
-
|
|
2811
|
+
path = path+".obj"
|
|
2812
2812
|
status = False
|
|
2813
2813
|
lines = []
|
|
2814
2814
|
version = Helper.Version()
|
|
@@ -2831,7 +2831,7 @@ class Topology():
|
|
|
2831
2831
|
finalLines = lines[0]
|
|
2832
2832
|
for i in range(1,len(lines)):
|
|
2833
2833
|
finalLines = finalLines+"\n"+lines[i]
|
|
2834
|
-
with open(
|
|
2834
|
+
with open(path, "w") as f:
|
|
2835
2835
|
f.writelines(finalLines)
|
|
2836
2836
|
f.close()
|
|
2837
2837
|
status = True
|
|
@@ -3382,6 +3382,128 @@ class Topology():
|
|
|
3382
3382
|
"""
|
|
3383
3383
|
return topology.GetOcctShape()
|
|
3384
3384
|
|
|
3385
|
+
def Degree(topology, hostTopology):
|
|
3386
|
+
"""
|
|
3387
|
+
Returns the number of immediate super topologies that use the input topology
|
|
3388
|
+
|
|
3389
|
+
Parameters
|
|
3390
|
+
----------
|
|
3391
|
+
topology : topologic.Topology
|
|
3392
|
+
The input topology.
|
|
3393
|
+
hostTopology : topologic.Topology
|
|
3394
|
+
The input host topology to which the input topology belongs
|
|
3395
|
+
|
|
3396
|
+
Returns
|
|
3397
|
+
-------
|
|
3398
|
+
int
|
|
3399
|
+
The degree of the topology (the number of immediate super topologies that use the input topology).
|
|
3400
|
+
|
|
3401
|
+
"""
|
|
3402
|
+
if not isinstance(topology, topologic.Topology):
|
|
3403
|
+
return None
|
|
3404
|
+
if not isinstance(hostTopology, topologic.Topology):
|
|
3405
|
+
return None
|
|
3406
|
+
|
|
3407
|
+
hostTopologyType = Topology.TypeAsString(hostTopology).lower()
|
|
3408
|
+
type = Topology.TypeAsString(topology).lower()
|
|
3409
|
+
superType = ""
|
|
3410
|
+
if type == "vertex" and (hostTopologyType == "cellcomplex" or hostTopologyType == "cell" or hostTopologyType == "shell"):
|
|
3411
|
+
superType = "face"
|
|
3412
|
+
elif type == "vertex" and (hostTopologyType == "wire" or hostTopologyType == "edge"):
|
|
3413
|
+
superType = "edge"
|
|
3414
|
+
elif type == "edge" and (hostTopologyType == "cellcomplex" or hostTopologyType == "cell" or hostTopologyType == "shell"):
|
|
3415
|
+
superType = "face"
|
|
3416
|
+
elif type == "face" and (hostTopologyType == "cellcomplex"):
|
|
3417
|
+
superType = "cell"
|
|
3418
|
+
superTopologies = Topology.SuperTopologies(topology, hostTopology=hostTopology, topologyType=superType)
|
|
3419
|
+
if not superTopologies:
|
|
3420
|
+
return 0
|
|
3421
|
+
return len(superTopologies)
|
|
3422
|
+
|
|
3423
|
+
def NonPlanarFaces(topology, tolerance=0.0001):
|
|
3424
|
+
"""
|
|
3425
|
+
Returns any nonplanar faces in the input topology
|
|
3426
|
+
|
|
3427
|
+
Parameters
|
|
3428
|
+
----------
|
|
3429
|
+
topology : topologic.Topology
|
|
3430
|
+
The input topology.
|
|
3431
|
+
tolerance : float , optional
|
|
3432
|
+
The desired tolerance. The default is 0.0001.
|
|
3433
|
+
Returns
|
|
3434
|
+
-------
|
|
3435
|
+
list
|
|
3436
|
+
The list of nonplanar faces.
|
|
3437
|
+
|
|
3438
|
+
"""
|
|
3439
|
+
if not isinstance(topology, topologic.Topology):
|
|
3440
|
+
return None
|
|
3441
|
+
faces = Topology.SubTopologies(topology, subTopologyType="face")
|
|
3442
|
+
return [f for f in faces if not Topology.IsPlanar(f, tolerance=tolerance)]
|
|
3443
|
+
|
|
3444
|
+
def OpenFaces(topology):
|
|
3445
|
+
"""
|
|
3446
|
+
Returns the faces that border no cells.
|
|
3447
|
+
|
|
3448
|
+
Parameters
|
|
3449
|
+
----------
|
|
3450
|
+
topology : topologic.Topology
|
|
3451
|
+
The input topology.
|
|
3452
|
+
|
|
3453
|
+
Returns
|
|
3454
|
+
-------
|
|
3455
|
+
list
|
|
3456
|
+
The list of open edges.
|
|
3457
|
+
|
|
3458
|
+
"""
|
|
3459
|
+
|
|
3460
|
+
if not isinstance(topology, topologic.Topology):
|
|
3461
|
+
return None
|
|
3462
|
+
|
|
3463
|
+
return [f for f in Topology.SubTopologies(topology, subTopologyType="face") if Topology.Degree(f, hostTopology=topology) < 1]
|
|
3464
|
+
|
|
3465
|
+
def OpenEdges(topology):
|
|
3466
|
+
"""
|
|
3467
|
+
Returns the edges that border only one face.
|
|
3468
|
+
|
|
3469
|
+
Parameters
|
|
3470
|
+
----------
|
|
3471
|
+
topology : topologic.Topology
|
|
3472
|
+
The input topology.
|
|
3473
|
+
|
|
3474
|
+
Returns
|
|
3475
|
+
-------
|
|
3476
|
+
list
|
|
3477
|
+
The list of open edges.
|
|
3478
|
+
|
|
3479
|
+
"""
|
|
3480
|
+
|
|
3481
|
+
if not isinstance(topology, topologic.Topology):
|
|
3482
|
+
return None
|
|
3483
|
+
|
|
3484
|
+
return [e for e in Topology.SubTopologies(topology, subTopologyType="edge") if Topology.Degree(e, hostTopology=topology) < 2]
|
|
3485
|
+
|
|
3486
|
+
def OpenVertices(topology):
|
|
3487
|
+
"""
|
|
3488
|
+
Returns the vertices that border only one edge.
|
|
3489
|
+
|
|
3490
|
+
Parameters
|
|
3491
|
+
----------
|
|
3492
|
+
topology : topologic.Topology
|
|
3493
|
+
The input topology.
|
|
3494
|
+
|
|
3495
|
+
Returns
|
|
3496
|
+
-------
|
|
3497
|
+
list
|
|
3498
|
+
The list of open edges.
|
|
3499
|
+
|
|
3500
|
+
"""
|
|
3501
|
+
|
|
3502
|
+
if not isinstance(topology, topologic.Topology):
|
|
3503
|
+
return None
|
|
3504
|
+
|
|
3505
|
+
return [v for v in Topology.SubTopologies(topology, subTopologyType="vertex") if Topology.Degree(v, hostTopology=topology) < 2]
|
|
3506
|
+
|
|
3385
3507
|
def Orient(topology, origin=None, dirA=[0,0,1], dirB=[0,0,1], tolerance=0.0001):
|
|
3386
3508
|
"""
|
|
3387
3509
|
Orients the input topology such that the input such that the input dirA vector is parallel to the input dirB vector.
|
|
@@ -3612,7 +3734,7 @@ class Topology():
|
|
|
3612
3734
|
returnTopology = topology
|
|
3613
3735
|
elif t == 32: # Cell
|
|
3614
3736
|
try:
|
|
3615
|
-
returnTopology = topologic.Cell.ByFaces(stl_final_faces, tolerance)
|
|
3737
|
+
returnTopology = topologic.Cell.ByFaces(stl_final_faces, tolerance=tolerance)
|
|
3616
3738
|
except:
|
|
3617
3739
|
returnTopology = topology
|
|
3618
3740
|
elif t == 64: #CellComplex
|
|
@@ -3646,7 +3768,7 @@ class Topology():
|
|
|
3646
3768
|
return topology.RemoveContents(contents)
|
|
3647
3769
|
|
|
3648
3770
|
@staticmethod
|
|
3649
|
-
def RemoveCoplanarFaces(topology, angTolerance=0.1, tolerance=0.0001):
|
|
3771
|
+
def RemoveCoplanarFaces(topology, planarize=False, angTolerance=0.1, tolerance=0.0001):
|
|
3650
3772
|
"""
|
|
3651
3773
|
Removes coplanar faces in the input topology
|
|
3652
3774
|
|
|
@@ -3654,6 +3776,8 @@ class Topology():
|
|
|
3654
3776
|
----------
|
|
3655
3777
|
topology : topologic.Topology
|
|
3656
3778
|
The input topology.
|
|
3779
|
+
planarize : bool , optional
|
|
3780
|
+
If set to True, the algorithm will attempt to planarize the final merged faces. Otherwise, it will triangulate any final nonplanar faces. The default is False.
|
|
3657
3781
|
angTolerance : float , optional
|
|
3658
3782
|
The desired angular tolerance for removing coplanar faces. The default is 0.1.
|
|
3659
3783
|
tolerance : float , optional
|
|
@@ -3668,6 +3792,7 @@ class Topology():
|
|
|
3668
3792
|
from topologicpy.Wire import Wire
|
|
3669
3793
|
from topologicpy.Face import Face
|
|
3670
3794
|
from topologicpy.Shell import Shell
|
|
3795
|
+
from topologicpy.Cell import Cell
|
|
3671
3796
|
from topologicpy.Cluster import Cluster
|
|
3672
3797
|
from topologicpy.Topology import Topology
|
|
3673
3798
|
t = topology.Type()
|
|
@@ -3742,15 +3867,17 @@ class Topology():
|
|
|
3742
3867
|
if not returnTopology:
|
|
3743
3868
|
returnTopology = topologic.Cluster.ByTopologies(faces, False)
|
|
3744
3869
|
elif t == 32:
|
|
3745
|
-
|
|
3870
|
+
print("Trying to build a Cell")
|
|
3871
|
+
returnTopology = Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
|
3746
3872
|
if not returnTopology:
|
|
3873
|
+
print("Failed, trying to build a Shell instead")
|
|
3747
3874
|
returnTopology = topologic.Shell.ByFaces(faces, tolerance)
|
|
3748
3875
|
if not returnTopology:
|
|
3749
3876
|
returnTopology = topologic.Cluster.ByTopologies(faces, False)
|
|
3750
3877
|
elif t == 64:
|
|
3751
3878
|
returnTopology = topologic.CellComplex.ByFaces(faces, tolerance, False)
|
|
3752
3879
|
if not returnTopology:
|
|
3753
|
-
returnTopology =
|
|
3880
|
+
returnTopology = Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
|
3754
3881
|
if not returnTopology:
|
|
3755
3882
|
returnTopology = topologic.Shell.ByFaces(faces, tolerance)
|
|
3756
3883
|
if not returnTopology:
|
|
@@ -4020,7 +4147,7 @@ class Topology():
|
|
|
4020
4147
|
return {"vertices":vOutput, "edges":eOutput, "wires":wOutput, "faces":fOutput}
|
|
4021
4148
|
|
|
4022
4149
|
@staticmethod
|
|
4023
|
-
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor='white', faceOpacity=0.5, edgeColor='black', edgeWidth=1, vertexColor='black', vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[1.25, 1.25, 1.25], target=[0, 0, 0], up=[0, 0, 1], renderer="notebook"):
|
|
4150
|
+
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor='white', faceOpacity=0.5, edgeColor='black', edgeWidth=1, vertexColor='black', vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, axisSize=1, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[1.25, 1.25, 1.25], target=[0, 0, 0], up=[0, 0, 1], renderer="notebook"):
|
|
4024
4151
|
"""
|
|
4025
4152
|
Shows the input topology on screen.
|
|
4026
4153
|
|
|
@@ -4126,7 +4253,7 @@ class Topology():
|
|
|
4126
4253
|
if not isinstance(topology, topologic.Topology):
|
|
4127
4254
|
return None
|
|
4128
4255
|
data = Plotly.DataByTopology(topology=topology, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, vertexGroups=vertexGroups, edgeGroups=edgeGroups, faceGroups=faceGroups, faceColor=faceColor, faceOpacity=faceOpacity, edgeColor=edgeColor, edgeWidth=edgeWidth, vertexColor=vertexColor, vertexSize=vertexSize, showFaces=showFaces, showEdges=showEdges, showVertices=showVertices)
|
|
4129
|
-
figure = Plotly.FigureByData(data=data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, backgroundColor=backgroundColor, marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom)
|
|
4256
|
+
figure = Plotly.FigureByData(data=data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize, backgroundColor=backgroundColor, marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom)
|
|
4130
4257
|
Plotly.Show(figure=figure, renderer=renderer, camera=camera, target=target, up=up)
|
|
4131
4258
|
|
|
4132
4259
|
@staticmethod
|
|
@@ -4175,7 +4302,7 @@ class Topology():
|
|
|
4175
4302
|
return {"sorted":sortedTopologies, "unsorted":unsortedTopologies}
|
|
4176
4303
|
|
|
4177
4304
|
@staticmethod
|
|
4178
|
-
def Spin(topology, origin=None, triangulate=True,
|
|
4305
|
+
def Spin(topology, origin=None, triangulate=True, direction=[0,0,1], degree=360, sides=16,
|
|
4179
4306
|
tolerance=0.0001):
|
|
4180
4307
|
"""
|
|
4181
4308
|
Spins the input topology around an axis to create a new topology.See https://en.wikipedia.org/wiki/Solid_of_revolution.
|
|
@@ -4188,12 +4315,8 @@ class Topology():
|
|
|
4188
4315
|
The origin (center) of the spin.
|
|
4189
4316
|
triangulate : bool , optional
|
|
4190
4317
|
If set to True, the result will be triangulated. The default is True.
|
|
4191
|
-
|
|
4192
|
-
The
|
|
4193
|
-
dirY : float , optional
|
|
4194
|
-
The 'y' component of the axis (vector) of spin. The default is 0.
|
|
4195
|
-
dirZ : float , optional
|
|
4196
|
-
The 'z' component of the axis (vector) of spin. The default is 1.
|
|
4318
|
+
direction : list , optional
|
|
4319
|
+
The vector representing the direction of the spin axis. The default is [0,0,1].
|
|
4197
4320
|
degree : float , optional
|
|
4198
4321
|
The angle in degrees for the spin. The default is 360.
|
|
4199
4322
|
sides : int , optional
|
|
@@ -4222,7 +4345,7 @@ class Topology():
|
|
|
4222
4345
|
topologies = []
|
|
4223
4346
|
unit_degree = degree / float(sides)
|
|
4224
4347
|
for i in range(sides+1):
|
|
4225
|
-
topologies.append(topologic.TopologyUtility.Rotate(topology, origin,
|
|
4348
|
+
topologies.append(topologic.TopologyUtility.Rotate(topology, origin, direction[0], direction[1], direction[2], unit_degree*i))
|
|
4226
4349
|
returnTopology = None
|
|
4227
4350
|
if topology.Type() == topologic.Vertex.Type():
|
|
4228
4351
|
returnTopology = Wire.ByVertices(topologies, False)
|
|
@@ -4386,6 +4509,7 @@ class Topology():
|
|
|
4386
4509
|
superTopologies = []
|
|
4387
4510
|
|
|
4388
4511
|
if not topologyType:
|
|
4512
|
+
print("Topology.SuperTopologies 4515 - ", topology)
|
|
4389
4513
|
typeID = 2*Topology.TypeID(topology)
|
|
4390
4514
|
else:
|
|
4391
4515
|
typeID = Topology.TypeID(topologyType)
|
|
@@ -4644,6 +4768,34 @@ class Topology():
|
|
|
4644
4768
|
if not isinstance(topology, topologic.Topology):
|
|
4645
4769
|
return None
|
|
4646
4770
|
return topologic.TopologyUtility.Translate(topology, x, y, z)
|
|
4771
|
+
|
|
4772
|
+
@staticmethod
|
|
4773
|
+
def TranslateByDirectionDistance(topology, direction, distance):
|
|
4774
|
+
"""
|
|
4775
|
+
Translates (moves) the input topology along the input direction by the specified distance.
|
|
4776
|
+
|
|
4777
|
+
Parameters
|
|
4778
|
+
----------
|
|
4779
|
+
topology : topologic.topology
|
|
4780
|
+
The input topology.
|
|
4781
|
+
x : float , optional
|
|
4782
|
+
The x translation value. The default is 0.
|
|
4783
|
+
y : float , optional
|
|
4784
|
+
The y translation value. The default is 0.
|
|
4785
|
+
z : float , optional
|
|
4786
|
+
The z translation value. The default is 0.
|
|
4787
|
+
|
|
4788
|
+
Returns
|
|
4789
|
+
-------
|
|
4790
|
+
topologic.Topology
|
|
4791
|
+
The translated topology.
|
|
4792
|
+
|
|
4793
|
+
"""
|
|
4794
|
+
from topologicpy.Vector import Vector
|
|
4795
|
+
if not isinstance(topology, topologic.Topology):
|
|
4796
|
+
return None
|
|
4797
|
+
v = Vector.SetMagnitude(direction, distance)
|
|
4798
|
+
return topologic.TopologyUtility.Translate(topology, v[0], v[1], v[2])
|
|
4647
4799
|
|
|
4648
4800
|
|
|
4649
4801
|
@staticmethod
|
|
@@ -4710,7 +4862,7 @@ class Topology():
|
|
|
4710
4862
|
shell = Topology.TransferDictionariesBySelectors(shell, selectors, tranFaces=True)
|
|
4711
4863
|
return shell
|
|
4712
4864
|
elif t == 32: # Cell
|
|
4713
|
-
cell = Cell.ByFaces(faceTriangles, tolerance)
|
|
4865
|
+
cell = Cell.ByFaces(faceTriangles, tolerance=tolerance)
|
|
4714
4866
|
if transferDictionaries:
|
|
4715
4867
|
cell = Topology.TransferDictionariesBySelectors(cell, selectors, tranFaces=True)
|
|
4716
4868
|
return cell
|
topologicpy/UnitTest.py
CHANGED
|
@@ -24,6 +24,6 @@ assert d == 17.321, "Vertex.Distance. Should be 17.321"
|
|
|
24
24
|
|
|
25
25
|
origin = Vertex.ByCoordinates(0,0,0)
|
|
26
26
|
cc = CellComplex.Prism(origin=origin, width=10, length=10, height=10, uSides=2, vSides=2, wSides=2,
|
|
27
|
-
|
|
27
|
+
direction=[0,0,1], originLocation="Center")
|
|
28
28
|
assert isinstance(cc, topologic.CellComplex), "Vertex.EnclosingCell. Should be topologic.CellComplex"
|
|
29
|
-
EnclosingCell(vertex, topology, exclusive=True, tolerance=0.0001)
|
|
29
|
+
EnclosingCell(vertex, topology, exclusive=True, tolerance=0.0001)
|