mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
black .
This commit is contained in:
@@ -225,7 +225,7 @@ class DumbSlabPlaner:
|
||||
for inverse in tool.Ifc.get().get_inverse(layer_set):
|
||||
if not inverse.is_a("IfcMaterialLayerSetUsage") or inverse.LayerSetDirection != "AXIS3":
|
||||
continue
|
||||
|
||||
|
||||
if tool.Ifc.get().schema == "IFC2X3":
|
||||
for rel in tool.Ifc.get().get_inverse(inverse):
|
||||
if not rel.is_a("IfcRelAssociatesMaterial"):
|
||||
@@ -277,10 +277,12 @@ class DumbSlabPlaner:
|
||||
return
|
||||
self.change_thickness(element, total_thickness)
|
||||
|
||||
def change_thickness(self, element: ifcopenshell.entity_instance, thickness: float, preserve_offset: bool = False) -> None:
|
||||
def change_thickness(
|
||||
self, element: ifcopenshell.entity_instance, thickness: float, preserve_offset: bool = False
|
||||
) -> None:
|
||||
if tool.Model.get_usage_type(element) != "LAYER3":
|
||||
return
|
||||
|
||||
|
||||
layer_params = tool.Model.get_material_layer_parameters(element)
|
||||
ifc_file = tool.Ifc.get()
|
||||
body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
||||
@@ -299,7 +301,7 @@ class DumbSlabPlaner:
|
||||
extrusion = tool.Model.get_extrusion(representation)
|
||||
if extrusion:
|
||||
direction_ratios = Vector(extrusion.ExtrudedDirection.DirectionRatios)
|
||||
|
||||
|
||||
# Calculate the actual extrusion angle from vertical
|
||||
extrusion_angle = 0
|
||||
if direction_ratios.length > 0:
|
||||
|
||||
@@ -1039,7 +1039,7 @@ class Loader(bonsai.core.tool.Loader):
|
||||
z_coords = [v.co.z for v in mesh.vertices]
|
||||
mesh_z_min = min(z_coords)
|
||||
mesh_z_max = max(z_coords)
|
||||
|
||||
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(mesh)
|
||||
|
||||
@@ -1068,54 +1068,54 @@ class Loader(bonsai.core.tool.Loader):
|
||||
thickness_dir = -thickness_dir
|
||||
|
||||
no = thickness_dir
|
||||
|
||||
|
||||
# Find start point by projecting vertices onto thickness direction
|
||||
if len(mesh.vertices) > 0:
|
||||
projections = [Vector(v.co).dot(no) for v in mesh.vertices]
|
||||
min_proj = min(projections)
|
||||
max_proj = max(projections)
|
||||
|
||||
|
||||
centroid = sum((Vector(v.co) for v in mesh.vertices), Vector()) / len(mesh.vertices)
|
||||
centroid_proj = centroid.dot(no)
|
||||
|
||||
|
||||
if sense_factor == 1:
|
||||
start_proj = min_proj
|
||||
else:
|
||||
start_proj = max_proj
|
||||
|
||||
|
||||
offset_dist = start_proj - centroid_proj
|
||||
co = centroid + no * offset_dist
|
||||
|
||||
|
||||
actual_mesh_height = max_proj - min_proj
|
||||
else:
|
||||
co = Vector((0.0, 0.0, 0.0))
|
||||
|
||||
|
||||
advance_direction = thickness_dir
|
||||
elif usage.LayerSetDirection == "AXIS3":
|
||||
# AXIS3 layers go through slab thickness (local Z)
|
||||
no = Vector([0.0, 0.0, 1.0])
|
||||
|
||||
|
||||
# Find start point by projecting vertices onto Z direction
|
||||
if len(mesh.vertices) > 0:
|
||||
projections = [Vector(v.co).dot(no) for v in mesh.vertices]
|
||||
min_proj = min(projections)
|
||||
max_proj = max(projections)
|
||||
|
||||
|
||||
centroid = sum((Vector(v.co) for v in mesh.vertices), Vector()) / len(mesh.vertices)
|
||||
centroid_proj = centroid.dot(no)
|
||||
|
||||
|
||||
if sense_factor == 1:
|
||||
start_proj = min_proj
|
||||
else:
|
||||
start_proj = max_proj
|
||||
|
||||
|
||||
offset = start_proj - centroid_proj
|
||||
co = centroid + no * offset
|
||||
|
||||
|
||||
actual_mesh_height = max_proj - min_proj
|
||||
else:
|
||||
co = Vector((0.0, 0.0, 0.0))
|
||||
|
||||
|
||||
advance_direction = no
|
||||
elif usage.LayerSetDirection == "AXIS1":
|
||||
co = Vector((0.0, 0.0, offset))
|
||||
@@ -1156,13 +1156,13 @@ class Loader(bonsai.core.tool.Loader):
|
||||
# Calculate scale factor
|
||||
total_layer_thickness = sum(layer.LayerThickness for _, layer in layer_list)
|
||||
|
||||
if 'actual_mesh_height' not in locals():
|
||||
if "actual_mesh_height" not in locals():
|
||||
actual_mesh_height = mesh_z_max - mesh_z_min if len(mesh.vertices) > 0 else total_layer_thickness
|
||||
|
||||
thickness_scale = actual_mesh_height / total_layer_thickness if total_layer_thickness > 0 else 1.0
|
||||
|
||||
last_i = len(layer_set.MaterialLayers) - 1
|
||||
|
||||
|
||||
for idx, (original_i, layer) in enumerate(layer_list):
|
||||
if idx != last_i:
|
||||
prev_co = co.copy()
|
||||
|
||||
Reference in New Issue
Block a user