mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 08:13:14 +00:00
Handle IfcCompositeProfileDef in derive_from_slab
When a slab consists of multiple separate closed loops, the swept area is IfcCompositeProfileDef which has a Profiles attribute rather than OuterCurve. Iterate over each profile and generate walls for all loops. Generated with the assistance of an AI coding tool.
This commit is contained in:
committed by
GitHub
parent
bcaf64eda0
commit
97c2d112cd
@@ -1398,27 +1398,33 @@ class DumbWallGenerator:
|
|||||||
elevation = self.container_obj.location.z
|
elevation = self.container_obj.location.z
|
||||||
representation = ifcopenshell.util.representation.get_representation(slab, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(slab, "Model", "Body", "MODEL_VIEW")
|
||||||
extrusion = tool.Model.get_extrusion(representation)
|
extrusion = tool.Model.get_extrusion(representation)
|
||||||
outer_curve = extrusion.SweptArea.OuterCurve
|
swept_area = extrusion.SweptArea
|
||||||
if self._curve_has_arc_segments(outer_curve):
|
if swept_area.is_a("IfcCompositeProfileDef"):
|
||||||
polyline_points = self._derive_points_from_arc_segments(slab_obj, elevation, outer_curve)
|
profiles = swept_area.Profiles
|
||||||
elif outer_curve.is_a("IfcCircle"):
|
|
||||||
polyline_points = self._derive_points_from_circle(slab_obj, elevation, outer_curve)
|
|
||||||
else:
|
else:
|
||||||
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
|
profiles = [swept_area]
|
||||||
polyline_points = builder.get_polyline_coords(outer_curve)
|
|
||||||
polyline_points = [[(v * self.unit_scale) for v in p] for p in polyline_points]
|
|
||||||
polyline_points = [slab_obj.matrix_world @ Vector((p[0], p[1], elevation)) for p in polyline_points]
|
|
||||||
|
|
||||||
if len(polyline_points) < 3:
|
|
||||||
return []
|
|
||||||
if not tool.Cad.is_counter_clockwise_order(polyline_points[0], polyline_points[1], polyline_points[2]):
|
|
||||||
polyline_points = polyline_points[::-1]
|
|
||||||
walls = []
|
walls = []
|
||||||
for i in range(len(polyline_points) - 1):
|
for profile in profiles:
|
||||||
vec1 = polyline_points[i]
|
outer_curve = profile.OuterCurve
|
||||||
vec2 = polyline_points[i + 1]
|
if self._curve_has_arc_segments(outer_curve):
|
||||||
coords = (vec1, vec2)
|
polyline_points = self._derive_points_from_arc_segments(slab_obj, elevation, outer_curve)
|
||||||
walls.append(self.create_wall_from_2_points(coords))
|
elif outer_curve.is_a("IfcCircle"):
|
||||||
|
polyline_points = self._derive_points_from_circle(slab_obj, elevation, outer_curve)
|
||||||
|
else:
|
||||||
|
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
|
||||||
|
polyline_points = builder.get_polyline_coords(outer_curve)
|
||||||
|
polyline_points = [[(v * self.unit_scale) for v in p] for p in polyline_points]
|
||||||
|
polyline_points = [slab_obj.matrix_world @ Vector((p[0], p[1], elevation)) for p in polyline_points]
|
||||||
|
|
||||||
|
if len(polyline_points) < 3:
|
||||||
|
continue
|
||||||
|
if not tool.Cad.is_counter_clockwise_order(polyline_points[0], polyline_points[1], polyline_points[2]):
|
||||||
|
polyline_points = polyline_points[::-1]
|
||||||
|
for i in range(len(polyline_points) - 1):
|
||||||
|
vec1 = polyline_points[i]
|
||||||
|
vec2 = polyline_points[i + 1]
|
||||||
|
coords = (vec1, vec2)
|
||||||
|
walls.append(self.create_wall_from_2_points(coords))
|
||||||
return walls
|
return walls
|
||||||
|
|
||||||
def create_wall_from_2_points(self, coords, should_round=False) -> Union[dict[str, Any], None]:
|
def create_wall_from_2_points(self, coords, should_round=False) -> Union[dict[str, Any], None]:
|
||||||
|
|||||||
Reference in New Issue
Block a user