mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 19:34:34 +00:00
Fix three small but significant typos in previous fixes.
BTW @andrej730 that optimisation is awesome. Here's a timeit:
import bpy
import numpy as np
import timeit
obj = bpy.context.active_object
verts = obj.data.vertices
def foreach_get_method():
coords = np.empty(len(verts) * 3, dtype=np.float32)
obj.data.vertices.foreach_get("co", coords)
coords = coords.reshape(-1, 3)
coords = coords.astype("d")
coords /= 10
return coords
def list_comprehension_method():
coords = [v.co / 10 for v in verts]
return coords
# Number of times each function will be executed
num_runs = 10000
t_listcomp = timeit.timeit(list_comprehension_method, number=num_runs)
t_foreach = timeit.timeit(foreach_get_method, number=num_runs)
print("foreach method: {:.6f} seconds over {} runs".format(t_foreach,
num_runs))
print("List comprehension method: {:.6f} seconds over {}
runs".format(t_listcomp, num_runs))
# foreach method: 0.088656 seconds over 10000 runs
# List comprehension method: 0.644446 seconds over 10000 runs
This commit is contained in:
@@ -113,7 +113,7 @@ class OverrideMeshSeparate(bpy.types.Operator, tool.Ifc.Operator):
|
||||
representation_type = representation.RepresentationType
|
||||
if representation_type in ("Brep", "AdvancedBrep"):
|
||||
item = builder.faceted_brep(verts, faces)
|
||||
elif representation_type in ("Tessellation"):
|
||||
elif representation_type == "Tessellation":
|
||||
item = builder.mesh(verts, faces)
|
||||
else:
|
||||
assert False, f"Unexpected representation type: '{representation_type}'."
|
||||
|
||||
@@ -1150,6 +1150,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
# It's faster to get them as f and then convert to d
|
||||
# with .astype("d"), if precision is needed.
|
||||
coords = np.empty(len(verts) * 3, dtype="f")
|
||||
verts.foreach_get("co", coords)
|
||||
coords = coords.reshape(-1, 3)
|
||||
return coords
|
||||
|
||||
|
||||
@@ -1750,7 +1750,7 @@ class Model(bonsai.core.tool.Model):
|
||||
else:
|
||||
profile_defs.append(tmp.createIfcArbitraryClosedProfileDef("AREA", None, curve))
|
||||
|
||||
if total_profile_defs := len(profile_defs) == 0:
|
||||
if (total_profile_defs := len(profile_defs)) == 0:
|
||||
return
|
||||
elif total_profile_defs == 1:
|
||||
profile_def = profile_defs[0]
|
||||
|
||||
Reference in New Issue
Block a user