topologicpy 0.7.49__py3-none-any.whl → 0.7.50__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/Topology.py +58 -14
- topologicpy/version.py +1 -1
- {topologicpy-0.7.49.dist-info → topologicpy-0.7.50.dist-info}/METADATA +1 -1
- {topologicpy-0.7.49.dist-info → topologicpy-0.7.50.dist-info}/RECORD +7 -7
- {topologicpy-0.7.49.dist-info → topologicpy-0.7.50.dist-info}/WHEEL +1 -1
- {topologicpy-0.7.49.dist-info → topologicpy-0.7.50.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.49.dist-info → topologicpy-0.7.50.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
@@ -2227,6 +2227,8 @@ class Topology():
|
|
2227
2227
|
from topologicpy.Cluster import Cluster
|
2228
2228
|
from topologicpy.Dictionary import Dictionary
|
2229
2229
|
import uuid
|
2230
|
+
import random
|
2231
|
+
import hashlib
|
2230
2232
|
|
2231
2233
|
try:
|
2232
2234
|
import ifcopenshell
|
@@ -2247,34 +2249,72 @@ class Topology():
|
|
2247
2249
|
if not file:
|
2248
2250
|
print("Topology.ByIFCFile - Error: the input file parameter is not a valid file. Returning None.")
|
2249
2251
|
return None
|
2252
|
+
|
2253
|
+
# Function to generate a unique random color based on material ID
|
2254
|
+
def generate_color_for_material(material_id):
|
2255
|
+
# Use a hash function to get a consistent "random" seed
|
2256
|
+
hash_object = hashlib.sha1(material_id.encode())
|
2257
|
+
seed = int(hash_object.hexdigest(), 16) % (10 ** 8)
|
2258
|
+
random.seed(seed)
|
2259
|
+
# Generate a random color
|
2260
|
+
r = random.random()
|
2261
|
+
g = random.random()
|
2262
|
+
b = random.random()
|
2263
|
+
return [r, g, b]
|
2264
|
+
|
2265
|
+
# Function to get the material IDs associated with an entity
|
2266
|
+
def get_material_ids_of_entity(entity):
|
2267
|
+
material_name = "None"
|
2268
|
+
material_ids = []
|
2269
|
+
if hasattr(entity, "HasAssociations"):
|
2270
|
+
for association in entity.HasAssociations:
|
2271
|
+
if association.is_a("IfcRelAssociatesMaterial"):
|
2272
|
+
material = association.RelatingMaterial
|
2273
|
+
material_name = material.Name
|
2274
|
+
if material.is_a("IfcMaterial"):
|
2275
|
+
material_ids.append(material.id())
|
2276
|
+
elif material.is_a("IfcMaterialList"):
|
2277
|
+
for mat in material.Materials:
|
2278
|
+
material_ids.append(mat.id())
|
2279
|
+
elif material.is_a("IfcMaterialLayerSetUsage") or material.is_a("IfcMaterialLayerSet"):
|
2280
|
+
for layer in material.ForLayerSet.MaterialLayers:
|
2281
|
+
material_ids.append(layer.Material.id())
|
2282
|
+
elif material.is_a("IfcMaterialConstituentSet"):
|
2283
|
+
for constituent in material.MaterialConstituents:
|
2284
|
+
material_ids.append(constituent.Material.id())
|
2285
|
+
|
2286
|
+
return material_ids, material_name
|
2287
|
+
|
2288
|
+
|
2289
|
+
|
2250
2290
|
includeTypes = [s.lower() for s in includeTypes]
|
2251
2291
|
excludeTypes = [s.lower() for s in excludeTypes]
|
2252
2292
|
topologies = []
|
2253
2293
|
settings = ifcopenshell.geom.settings()
|
2254
2294
|
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
|
2255
2295
|
settings.set(settings.USE_WORLD_COORDS, True)
|
2256
|
-
iterator = ifcopenshell.geom.iterator(settings, file, multiprocessing.cpu_count())
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2296
|
+
#iterator = ifcopenshell.geom.iterator(settings, file, multiprocessing.cpu_count())
|
2297
|
+
for entity in file.by_type('IfcProduct'): # You might want to refine the types you check
|
2298
|
+
if hasattr(entity, "Representation") and entity.Representation:
|
2299
|
+
for rep in entity.Representation.Representations:
|
2300
|
+
if rep.is_a("IfcShapeRepresentation"):
|
2301
|
+
# Generate the geometry for this entity
|
2302
|
+
shape = ifcopenshell.geom.create_shape(settings, entity)
|
2303
|
+
is_a = shape.type.lower()
|
2304
|
+
if (is_a in includeTypes or len(includeTypes) == 0) and (not is_a in excludeTypes):
|
2263
2305
|
verts = shape.geometry.verts
|
2264
2306
|
edges = shape.geometry.edges
|
2265
2307
|
faces = shape.geometry.faces
|
2266
2308
|
grouped_verts = [ [verts[i], verts[i + 1], verts[i + 2]] for i in range(0, len(verts), 3)]
|
2267
2309
|
grouped_edges = [[edges[i], edges[i + 1]] for i in range(0, len(edges), 2)]
|
2268
2310
|
grouped_faces = [ [faces[i], faces[i + 1], faces[i + 2]] for i in range(0, len(faces), 3)]
|
2269
|
-
topology = Topology.ByGeometry(grouped_verts, grouped_edges, grouped_faces)
|
2311
|
+
topology = Topology.SelfMerge(Topology.ByGeometry(grouped_verts, grouped_edges, grouped_faces))
|
2270
2312
|
if removeCoplanarFaces:
|
2271
2313
|
topology = Topology.RemoveCoplanarFaces(topology)
|
2272
2314
|
topologies.append(topology)
|
2273
2315
|
if transferDictionaries:
|
2274
2316
|
keys = []
|
2275
2317
|
values = []
|
2276
|
-
keys.append("TOPOLOGIC_color")
|
2277
|
-
values.append([1.0, 1.0, 1.0, 1.0])
|
2278
2318
|
keys.append("TOPOLOGIC_id")
|
2279
2319
|
values.append(str(uuid.uuid4()))
|
2280
2320
|
keys.append("TOPOLOGIC_name")
|
@@ -2291,13 +2331,17 @@ class Topology():
|
|
2291
2331
|
values.append(shape.name)
|
2292
2332
|
keys.append("IFC_type")
|
2293
2333
|
values.append(shape.type)
|
2334
|
+
material_ids, material_name = get_material_ids_of_entity(entity)
|
2335
|
+
keys.append("IFC_material_ids")
|
2336
|
+
values.append(material_ids)
|
2337
|
+
keys.append("IFC_material_name")
|
2338
|
+
values.append(material_name)
|
2339
|
+
keys.append("TOPOLOGIC_color")
|
2340
|
+
color = generate_color_for_material(str(material_ids))
|
2341
|
+
values.append(color)
|
2294
2342
|
d = Dictionary.ByKeysValues(keys, values)
|
2295
2343
|
topology = Topology.SetDictionary(topology, d)
|
2296
2344
|
topologies.append(topology)
|
2297
|
-
except:
|
2298
|
-
pass
|
2299
|
-
if not iterator.next():
|
2300
|
-
break
|
2301
2345
|
return topologies
|
2302
2346
|
|
2303
2347
|
@staticmethod
|
topologicpy/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.7.
|
1
|
+
__version__ = '0.7.50'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: topologicpy
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.50
|
4
4
|
Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
|
5
5
|
Author-email: Wassim Jabi <wassim.jabi@gmail.com>
|
6
6
|
License: MIT License
|
@@ -22,14 +22,14 @@ topologicpy/PyG.py,sha256=3U59QObO56EBwrvaplGeLZhbTao0gJCYhWm3oTpjFAE,109505
|
|
22
22
|
topologicpy/Shell.py,sha256=joahFtpRQTWJpQOmi3qU4Xe0Sx2XXeayHlXTNx8CzMk,87610
|
23
23
|
topologicpy/Speckle.py,sha256=rUS6PCaxIjEF5_fUruxvMH47FMKg-ohcoU0qAUb-yNM,14267
|
24
24
|
topologicpy/Sun.py,sha256=42tDWMYpwRG7Z2Qjtp94eRgBuqySq7k8TgNUZDK7QxQ,36837
|
25
|
-
topologicpy/Topology.py,sha256=
|
25
|
+
topologicpy/Topology.py,sha256=NONehbPs2Z0J-BaQXRUChCZfTzJSzVngkhojKSxSij8,382087
|
26
26
|
topologicpy/Vector.py,sha256=WQQUbwrg7VKImtxuBUi2i-FRiPT77WlrzLP05gdXKM8,33079
|
27
27
|
topologicpy/Vertex.py,sha256=bLY60YWoMsgCgHk7F7k9F93Sq2FJ6AzUcTfJ83NZfHA,71107
|
28
28
|
topologicpy/Wire.py,sha256=9EJE0Iq3nGz5X7Suy6xxjmuOpfV49By6WH98UAL_7m4,153532
|
29
29
|
topologicpy/__init__.py,sha256=D7ky87CAQMiS2KE6YLvcTLkTgA2PY7rASe6Z23pjp9k,872
|
30
|
-
topologicpy/version.py,sha256=
|
31
|
-
topologicpy-0.7.
|
32
|
-
topologicpy-0.7.
|
33
|
-
topologicpy-0.7.
|
34
|
-
topologicpy-0.7.
|
35
|
-
topologicpy-0.7.
|
30
|
+
topologicpy/version.py,sha256=gEkNhj8f1k7FiRl8ltgMlJxkt4i1ODTsl0_a2BsR4wI,23
|
31
|
+
topologicpy-0.7.50.dist-info/LICENSE,sha256=BRNw73R2WdDBICtwhI3wm3cxsaVqLTAGuRwrTltcfxs,1068
|
32
|
+
topologicpy-0.7.50.dist-info/METADATA,sha256=bQrEvJSs5DBgeaLDmx_HZPF_Qz_rZCXSLa3YUuOa33s,10918
|
33
|
+
topologicpy-0.7.50.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
34
|
+
topologicpy-0.7.50.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
|
35
|
+
topologicpy-0.7.50.dist-info/RECORD,,
|
File without changes
|
File without changes
|