mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +00:00
@@ -631,15 +631,13 @@ class IfcImporter:
|
|||||||
verts = geometry["verts"]
|
verts = geometry["verts"]
|
||||||
mesh["has_cartesian_point_offset"] = False
|
mesh["has_cartesian_point_offset"] = False
|
||||||
|
|
||||||
if geometry["faces"]:
|
if geometry["faces"].size:
|
||||||
mesh = tool.Loader.create_mesh_from_shape(
|
mesh = tool.Loader.create_mesh_from_shape(
|
||||||
mesh=mesh, faces=geometry["faces"].reshape(-1, 3), verts=verts.reshape(-1, 3)
|
mesh=mesh, faces=geometry["faces"].reshape(-1, 3), verts=verts.reshape(-1, 3)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
e = geometry["edges"]
|
vertices = verts.reshape(-1, 3).tolist()
|
||||||
v = verts
|
edges = geometry["edges"].reshape(-1, 2).tolist()
|
||||||
vertices = [[v[i], v[i + 1], v[i + 2]] for i in range(0, len(v), 3)]
|
|
||||||
edges = [[e[i], e[i + 1]] for i in range(0, len(e), 2)]
|
|
||||||
mesh.from_pydata(vertices, edges, [])
|
mesh.from_pydata(vertices, edges, [])
|
||||||
|
|
||||||
mesh["ios_materials"] = geometry["materials"]
|
mesh["ios_materials"] = geometry["materials"]
|
||||||
|
|||||||
@@ -246,18 +246,19 @@ class sqlite(file):
|
|||||||
geometry = {}
|
geometry = {}
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if row["geometry"] and row["geometry"] not in geometry:
|
if row["geometry"] and row["geometry"] not in geometry:
|
||||||
|
# Same data types as in ifcopenshell.util.shape.
|
||||||
geometry[row["geometry"]] = {
|
geometry[row["geometry"]] = {
|
||||||
"verts": np.frombuffer(row["verts"]).tolist() if row["verts"] else [],
|
"verts": np.frombuffer(row["verts"], dtype="d") if row["verts"] else np.empty(0, dtype="d"),
|
||||||
"edges": np.frombuffer(row["edges"], dtype=np.int64).tolist() if row["edges"] else [],
|
"edges": np.frombuffer(row["edges"], dtype="i") if row["edges"] else np.empty(0, dtype="i"),
|
||||||
"faces": np.frombuffer(row["faces"], dtype=np.int64).tolist() if row["faces"] else [],
|
"faces": np.frombuffer(row["faces"], dtype="i") if row["faces"] else np.empty(0, dtype="i"),
|
||||||
"material_ids": (
|
"material_ids": (
|
||||||
np.frombuffer(row["material_ids"], dtype=np.int64).tolist() if row["material_ids"] else []
|
np.frombuffer(row["material_ids"], dtype="i") if row["material_ids"] else np.empty(0, dtype="i")
|
||||||
),
|
),
|
||||||
"materials": json.loads(row["materials"]) if row["materials"] else [],
|
"materials": json.loads(row["materials"]) if row["materials"] else [],
|
||||||
}
|
}
|
||||||
shapes[row["ifc_id"]] = {
|
shapes[row["ifc_id"]] = {
|
||||||
"co": [row["x"], row["y"], row["z"]],
|
"co": [row["x"], row["y"], row["z"]],
|
||||||
"matrix": np.copy(np.frombuffer(row["matrix"]).reshape((4, 4))),
|
"matrix": np.copy(np.frombuffer(row["matrix"], dtype="d").reshape((4, 4))),
|
||||||
"geometry": row["geometry"],
|
"geometry": row["geometry"],
|
||||||
}
|
}
|
||||||
ids_without_geometry = set(ids) - set(shapes.keys())
|
ids_without_geometry = set(ids) - set(shapes.keys())
|
||||||
|
|||||||
@@ -692,7 +692,8 @@ def calculate_unit_scale(ifc_file: ifcopenshell.file, unit_type: str = "LENGTHUN
|
|||||||
:returns: The scale factor
|
:returns: The scale factor
|
||||||
"""
|
"""
|
||||||
if (
|
if (
|
||||||
unit_type
|
type(ifc_file) is ifcopenshell.file
|
||||||
|
and unit_type
|
||||||
not in ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema_identifier)
|
not in ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema_identifier)
|
||||||
.declaration_by_name("IfcUnitEnum")
|
.declaration_by_name("IfcUnitEnum")
|
||||||
.enumeration_items()
|
.enumeration_items()
|
||||||
|
|||||||
Reference in New Issue
Block a user