mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
add_window_representation - remove mathutils dependency #5192
This commit is contained in:
@@ -17,13 +17,12 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import collections.abc
|
import numpy as np
|
||||||
import ifcopenshell.util.unit
|
|
||||||
from ifcopenshell.util.shape_builder import ShapeBuilder, V
|
|
||||||
from itertools import chain
|
|
||||||
from mathutils import Vector
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from typing import Any, Optional, Literal, Union
|
import ifcopenshell.util.unit
|
||||||
|
from itertools import chain
|
||||||
|
from ifcopenshell.util.shape_builder import ShapeBuilder, V
|
||||||
|
from typing import Any, Optional, Literal, Union, overload
|
||||||
|
|
||||||
|
|
||||||
# SCHEMAS describe panels setup
|
# SCHEMAS describe panels setup
|
||||||
@@ -32,6 +31,18 @@ from typing import Any, Optional, Literal, Union
|
|||||||
# - schema columns represent window Y axis
|
# - schema columns represent window Y axis
|
||||||
# - order of rows is from top of the window to bottom
|
# - order of rows is from top of the window to bottom
|
||||||
|
|
||||||
|
WINDOW_TYPE = Literal[
|
||||||
|
"SINGLE_PANEL",
|
||||||
|
"DOUBLE_PANEL_HORIZONTAL",
|
||||||
|
"DOUBLE_PANEL_VERTICAL",
|
||||||
|
"TRIPLE_PANEL_BOTTOM",
|
||||||
|
"TRIPLE_PANEL_HORIZONTAL",
|
||||||
|
"TRIPLE_PANEL_LEFT",
|
||||||
|
"TRIPLE_PANEL_RIGHT",
|
||||||
|
"TRIPLE_PANEL_TOP",
|
||||||
|
"TRIPLE_PANEL_VERTICAL",
|
||||||
|
]
|
||||||
|
|
||||||
DEFAULT_PANEL_SCHEMAS = {
|
DEFAULT_PANEL_SCHEMAS = {
|
||||||
"SINGLE_PANEL": [[0]],
|
"SINGLE_PANEL": [[0]],
|
||||||
"DOUBLE_PANEL_HORIZONTAL": [[0], [1]],
|
"DOUBLE_PANEL_HORIZONTAL": [[0], [1]],
|
||||||
@@ -51,28 +62,32 @@ def mm(x: float) -> float:
|
|||||||
|
|
||||||
|
|
||||||
def create_ifc_window_frame_simple(
|
def create_ifc_window_frame_simple(
|
||||||
builder: ShapeBuilder, size: Vector, thickness: list, position: Vector = V(0, 0, 0).freeze()
|
builder: ShapeBuilder, size: np.ndarray, thickness: Union[list[float], float], position: Optional[np.ndarray] = None
|
||||||
):
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
"""`thickness` of the profile is defined as list in the following order:
|
"""`thickness` of the profile is defined as list in the following order:
|
||||||
`(LEFT, TOP, RIGHT, BOTTOM)`
|
`(LEFT, TOP, RIGHT, BOTTOM)`
|
||||||
|
|
||||||
`thickness` can be also defined just as 1 float value.
|
`thickness` can be also defined just as 1 float value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not isinstance(thickness, collections.abc.Iterable):
|
if not isinstance(thickness, list):
|
||||||
thickness = [thickness] * 4
|
thickness = [thickness] * 4
|
||||||
|
if position is None:
|
||||||
|
position = np.zeros(3)
|
||||||
|
np_X, np_Y, np_Z = 0, 1, 2
|
||||||
|
np_XZ = [0, 2]
|
||||||
th_left, th_up, th_right, th_bottom = thickness
|
th_left, th_up, th_right, th_bottom = thickness
|
||||||
|
|
||||||
def get_extruded_profile(profile):
|
def get_extruded_profile(profile: ifcopenshell.entity_instance):
|
||||||
return builder.extrude(profile, size.y, position=position, **builder.extrude_kwargs("Y"))
|
return builder.extrude(profile, size[np_Y], position=position, **builder.extrude_kwargs("Y"))
|
||||||
|
|
||||||
# if all lining sides are present then we can just use two rectangles
|
# if all lining sides are present then we can just use two rectangles
|
||||||
# as inner and outer curves of the profile
|
# as inner and outer curves of the profile
|
||||||
if thickness.count(0) == 0:
|
if thickness.count(0) == 0:
|
||||||
panel_rect = builder.rectangle(size=size.xz)
|
panel_rect = builder.rectangle(size=size[np_XZ])
|
||||||
|
|
||||||
inner_rect_size = size - V(th_left + th_right, 0, th_bottom + th_up)
|
inner_rect_size = size - (th_left + th_right, 0, th_bottom + th_up)
|
||||||
inner_rect = builder.rectangle(size=inner_rect_size.xz, position=V(th_left, th_bottom))
|
inner_rect = builder.rectangle(size=inner_rect_size[np_XZ], position=(th_left, th_bottom))
|
||||||
|
|
||||||
panel_profile = builder.profile(panel_rect, inner_curves=inner_rect)
|
panel_profile = builder.profile(panel_rect, inner_curves=inner_rect)
|
||||||
return [get_extruded_profile(panel_profile)]
|
return [get_extruded_profile(panel_profile)]
|
||||||
@@ -81,12 +96,12 @@ def create_ifc_window_frame_simple(
|
|||||||
# and need to generate L/U shape or just separate rectangles
|
# and need to generate L/U shape or just separate rectangles
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def get_segments_from_thickness():
|
def get_segments_from_thickness() -> list[tuple[float, ...]]:
|
||||||
nonlocal thickness
|
nonlocal thickness
|
||||||
segments = []
|
segments = []
|
||||||
cur_segment = []
|
cur_segment = []
|
||||||
for i, thickness in enumerate(thickness):
|
for i, thickness_ in enumerate(thickness):
|
||||||
if thickness == 0:
|
if thickness_ == 0:
|
||||||
if cur_segment:
|
if cur_segment:
|
||||||
segments.append(tuple(cur_segment))
|
segments.append(tuple(cur_segment))
|
||||||
cur_segment = []
|
cur_segment = []
|
||||||
@@ -103,20 +118,20 @@ def create_ifc_window_frame_simple(
|
|||||||
# prepare coords to build a lining
|
# prepare coords to build a lining
|
||||||
# fmt: off
|
# fmt: off
|
||||||
outer_coords = [
|
outer_coords = [
|
||||||
(V(0, 0), V(0, size.z)),
|
((0, 0), (0, size[np_Z])),
|
||||||
(V(0, size.z), V(size.x, size.z)),
|
((0, size[np_Z]), (size[np_X], size[np_Z])),
|
||||||
(V(size.x, size.z), V(size.x, 0)),
|
((size[np_X], size[np_Z]), (size[np_X], 0)),
|
||||||
(V(size.x, 0), V(0, 0)),
|
((size[np_X], 0), (0, 0)),
|
||||||
]
|
]
|
||||||
inner_coords = [
|
inner_coords = [
|
||||||
(V(th_left, th_bottom), V(th_left, size.z - th_up)),
|
((th_left, th_bottom), (th_left, size[np_Z] - th_up)),
|
||||||
(V(th_left, size.z - th_up), V(size.x - th_right, size.z - th_up)),
|
((th_left, size[np_Z] - th_up), (size[np_X] - th_right, size[np_Z] - th_up)),
|
||||||
(V(size.x - th_right, size.z - th_up), V(size.x - th_right, th_bottom)),
|
((size[np_X] - th_right, size[np_Z] - th_up), (size[np_X] - th_right, th_bottom)),
|
||||||
(V(size.x - th_right, th_bottom), V(th_left, th_bottom)),
|
((size[np_X] - th_right, th_bottom), (th_left, th_bottom)),
|
||||||
]
|
]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
def get_points(segment):
|
def get_points(segment: tuple[float, ...]) -> list[tuple[float, float]]:
|
||||||
points = []
|
points = []
|
||||||
for side in segment:
|
for side in segment:
|
||||||
outer = outer_coords[side]
|
outer = outer_coords[side]
|
||||||
@@ -132,7 +147,7 @@ def create_ifc_window_frame_simple(
|
|||||||
return points
|
return points
|
||||||
|
|
||||||
segments = get_segments_from_thickness()
|
segments = get_segments_from_thickness()
|
||||||
segments_items = []
|
segments_items: list[ifcopenshell.entity_instance] = []
|
||||||
for seg in segments:
|
for seg in segments:
|
||||||
polyline = builder.polyline(points=get_points(seg), closed=True)
|
polyline = builder.polyline(points=get_points(seg), closed=True)
|
||||||
panel_profile = builder.profile(polyline)
|
panel_profile = builder.profile(polyline)
|
||||||
@@ -142,11 +157,11 @@ def create_ifc_window_frame_simple(
|
|||||||
|
|
||||||
|
|
||||||
def window_l_shape_check(
|
def window_l_shape_check(
|
||||||
lining_to_panel_offset_y_full,
|
lining_to_panel_offset_y_full: float,
|
||||||
lining_depth,
|
lining_depth: float,
|
||||||
lining_to_panel_offset_x: list,
|
lining_to_panel_offset_x: list[float],
|
||||||
lining_thickness: list,
|
lining_thickness: list[float],
|
||||||
):
|
) -> bool:
|
||||||
"""`lining_thickness` and `lining_to_panel_offset_x` expected to be defined as a list,
|
"""`lining_thickness` and `lining_to_panel_offset_x` expected to be defined as a list,
|
||||||
similarly to `create_ifc_window_frame_simple` `thickness` argument"""
|
similarly to `create_ifc_window_frame_simple` `thickness` argument"""
|
||||||
l_shape_check = lining_to_panel_offset_y_full < lining_depth and any(
|
l_shape_check = lining_to_panel_offset_y_full < lining_depth and any(
|
||||||
@@ -156,39 +171,41 @@ def window_l_shape_check(
|
|||||||
|
|
||||||
|
|
||||||
def create_ifc_window(
|
def create_ifc_window(
|
||||||
builder,
|
builder: ShapeBuilder,
|
||||||
lining_size: Vector,
|
lining_size: np.ndarray,
|
||||||
lining_thickness: list,
|
lining_thickness: list[float],
|
||||||
lining_to_panel_offset_x,
|
lining_to_panel_offset_x: float,
|
||||||
lining_to_panel_offset_y_full,
|
lining_to_panel_offset_y_full: float,
|
||||||
frame_size: Vector,
|
frame_size: np.ndarray,
|
||||||
frame_thickness,
|
frame_thickness: float,
|
||||||
glass_thickness,
|
glass_thickness: float,
|
||||||
position: Vector,
|
position: np.ndarray,
|
||||||
x_offsets: list = None,
|
x_offsets: Optional[list[float]] = None,
|
||||||
):
|
) -> tuple[list[ifcopenshell.entity_instance], list[ifcopenshell.entity_instance], list[ifcopenshell.entity_instance]]:
|
||||||
"""`lining_thickness` and `x_offsets` are expected to be defined as a list,
|
"""`lining_thickness` and `x_offsets` are expected to be defined as a list,
|
||||||
similarly to `create_ifc_window_frame_simple` `thickness` argument"""
|
similarly to `create_ifc_window_frame_simple` `thickness` argument"""
|
||||||
lining_items = []
|
lining_items: list[ifcopenshell.entity_instance] = []
|
||||||
main_lining_size = lining_size
|
main_lining_size = lining_size
|
||||||
|
|
||||||
|
np_Y = 1
|
||||||
|
|
||||||
if x_offsets is None:
|
if x_offsets is None:
|
||||||
x_offsets = [lining_to_panel_offset_x] * 4
|
x_offsets = [lining_to_panel_offset_x] * 4
|
||||||
# need to check offsets to decide whether lining should be rectangle
|
# need to check offsets to decide whether lining should be rectangle
|
||||||
# or L shaped
|
# or L shaped
|
||||||
l_shape_check = window_l_shape_check(
|
l_shape_check = window_l_shape_check(
|
||||||
lining_to_panel_offset_y_full,
|
lining_to_panel_offset_y_full,
|
||||||
lining_size.y,
|
lining_size[np_Y],
|
||||||
x_offsets,
|
x_offsets,
|
||||||
lining_thickness,
|
lining_thickness,
|
||||||
)
|
)
|
||||||
|
|
||||||
if l_shape_check:
|
if l_shape_check:
|
||||||
main_lining_size = lining_size.copy()
|
main_lining_size = lining_size.copy()
|
||||||
main_lining_size.y = lining_to_panel_offset_y_full
|
main_lining_size[np_Y] = lining_to_panel_offset_y_full
|
||||||
|
|
||||||
second_lining_size = lining_size.copy()
|
second_lining_size = lining_size.copy()
|
||||||
second_lining_size.y = lining_size.y - lining_to_panel_offset_y_full
|
second_lining_size[np_Y] = lining_size[np_Y] - lining_to_panel_offset_y_full
|
||||||
second_lining_position = V(0, lining_to_panel_offset_y_full, 0)
|
second_lining_position = V(0, lining_to_panel_offset_y_full, 0)
|
||||||
second_lining_thickness = [min(th, x_offset) for th, x_offset in zip(lining_thickness, x_offsets, strict=True)]
|
second_lining_thickness = [min(th, x_offset) for th, x_offset in zip(lining_thickness, x_offsets, strict=True)]
|
||||||
|
|
||||||
@@ -208,11 +225,11 @@ def create_ifc_window(
|
|||||||
|
|
||||||
frame_extruded_items = create_ifc_window_frame_simple(builder, frame_size, frame_thickness, frame_position)
|
frame_extruded_items = create_ifc_window_frame_simple(builder, frame_size, frame_thickness, frame_position)
|
||||||
|
|
||||||
glass_position = frame_position + V(0, frame_size.y / 2 - glass_thickness / 2, 0)
|
glass_position = frame_position + V(0, frame_size[np_Y] / 2 - glass_thickness / 2, 0)
|
||||||
glass_rect = builder.deep_copy(frame_extruded_items[0].SweptArea.InnerCurves[0])
|
glass_rect = builder.deep_copy(frame_extruded_items[0].SweptArea.InnerCurves[0])
|
||||||
glass = builder.extrude(glass_rect, glass_thickness, position=glass_position, **builder.extrude_kwargs("Y"))
|
glass = builder.extrude(glass_rect, glass_thickness, position=glass_position, **builder.extrude_kwargs("Y"))
|
||||||
|
|
||||||
output_items = [lining_items, frame_extruded_items, [glass]]
|
output_items = (lining_items, frame_extruded_items, [glass])
|
||||||
builder.translate(chain(*output_items), position)
|
builder.translate(chain(*output_items), position)
|
||||||
|
|
||||||
return output_items
|
return output_items
|
||||||
@@ -343,17 +360,7 @@ def add_window_representation(
|
|||||||
context: ifcopenshell.entity_instance,
|
context: ifcopenshell.entity_instance,
|
||||||
overall_height: Optional[float] = None,
|
overall_height: Optional[float] = None,
|
||||||
overall_width: Optional[float] = None,
|
overall_width: Optional[float] = None,
|
||||||
partition_type: Literal[
|
partition_type: WINDOW_TYPE = "SINGLE_PANEL",
|
||||||
"SINGLE_PANEL",
|
|
||||||
"DOUBLE_PANEL_HORIZONTAL",
|
|
||||||
"DOUBLE_PANEL_VERTICAL",
|
|
||||||
"TRIPLE_PANEL_BOTTOM",
|
|
||||||
"TRIPLE_PANEL_HORIZONTAL",
|
|
||||||
"TRIPLE_PANEL_LEFT",
|
|
||||||
"TRIPLE_PANEL_RIGHT",
|
|
||||||
"TRIPLE_PANEL_TOP",
|
|
||||||
"TRIPLE_PANEL_VERTICAL",
|
|
||||||
] = "SINGLE_PANEL",
|
|
||||||
lining_properties: Optional[Union[WindowLiningProperties, dict[str, Any]]] = None,
|
lining_properties: Optional[Union[WindowLiningProperties, dict[str, Any]]] = None,
|
||||||
panel_properties: Optional[list[Union[WindowPanelProperties, dict[str, Any]]]] = None,
|
panel_properties: Optional[list[Union[WindowPanelProperties, dict[str, Any]]]] = None,
|
||||||
unit_scale: Optional[float] = None,
|
unit_scale: Optional[float] = None,
|
||||||
@@ -361,26 +368,17 @@ def add_window_representation(
|
|||||||
"""units in usecase_settings expected to be in ifc project units
|
"""units in usecase_settings expected to be in ifc project units
|
||||||
|
|
||||||
:param context: IfcGeometricRepresentationContext for the representation.
|
:param context: IfcGeometricRepresentationContext for the representation.
|
||||||
:type context: ifcopenshell.entity_instance
|
|
||||||
:param overall_height: Overall window height. Defaults to 0.9m.
|
:param overall_height: Overall window height. Defaults to 0.9m.
|
||||||
:type overall_height: float, optional
|
|
||||||
:param overall_width: Overall window width. Defaults to 0.6m.
|
:param overall_width: Overall window width. Defaults to 0.6m.
|
||||||
:type overall_width: float, optional
|
|
||||||
:param partition_type: Type of the window. Defaults to SINGLE_PANEL.
|
:param partition_type: Type of the window. Defaults to SINGLE_PANEL.
|
||||||
:type partition_type: str, optional
|
|
||||||
:param lining_properties: WindowLiningProperties or a dictionary to create one.
|
:param lining_properties: WindowLiningProperties or a dictionary to create one.
|
||||||
See WindowLiningProperties description for details.
|
See WindowLiningProperties description for details.
|
||||||
:type lining_properties: Union[WindowLiningProperties, dict[str, Any]]]
|
|
||||||
:param panel_properties: A list of WindowPanelProperties or dictionaries to create one.
|
:param panel_properties: A list of WindowPanelProperties or dictionaries to create one.
|
||||||
See WindowPanelProperties description for details.
|
See WindowPanelProperties description for details.
|
||||||
:type panel_properties: list[Union[WindowPanelProperties, dict[str, Any]]]]
|
|
||||||
:param unit_scale: The unit scale as calculated by
|
:param unit_scale: The unit scale as calculated by
|
||||||
ifcopenshell.util.unit.calculate_unit_scale. If not provided, it
|
ifcopenshell.util.unit.calculate_unit_scale. If not provided, it
|
||||||
will be automatically calculated for you.
|
will be automatically calculated for you.
|
||||||
:type unit_scale: float, optional
|
|
||||||
:return: IfcShapeRepresentation for a window.
|
:return: IfcShapeRepresentation for a window.
|
||||||
:rtype: ifcopenshell.entity_instance
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
usecase = Usecase()
|
usecase = Usecase()
|
||||||
usecase.file = file
|
usecase.file = file
|
||||||
@@ -428,49 +426,50 @@ def add_window_representation(
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def execute(self):
|
def execute(self):
|
||||||
builder = ShapeBuilder(self.file)
|
builder = ShapeBuilder(self.file)
|
||||||
overall_height = self.settings["overall_height"]
|
np_X, np_Y, np_Z = 0, 1, 2
|
||||||
overall_width = self.settings["overall_width"]
|
overall_height: float = self.settings["overall_height"]
|
||||||
|
overall_width: float = self.settings["overall_width"]
|
||||||
|
|
||||||
if self.settings["context"].TargetView == "ELEVATION_VIEW":
|
if self.settings["context"].TargetView == "ELEVATION_VIEW":
|
||||||
rect = builder.rectangle(V(overall_width, 0, overall_height))
|
rect = builder.rectangle(V(overall_width, 0, overall_height))
|
||||||
representation_evelevation = builder.get_representation(self.settings["context"], rect)
|
representation_evelevation = builder.get_representation(self.settings["context"], rect)
|
||||||
return representation_evelevation
|
return representation_evelevation
|
||||||
|
|
||||||
panel_schema = self.settings["panel_schema"]
|
panel_schema: list[list[int]] = self.settings["panel_schema"]
|
||||||
panels = self.settings["panel_properties"]
|
panels: list[dict[str, Any]] = self.settings["panel_properties"]
|
||||||
accumulated_height = [0] * len(panel_schema[0])
|
accumulated_height = [0] * len(panel_schema[0])
|
||||||
built_panels = []
|
built_panels: list[int] = []
|
||||||
window_items = []
|
window_items: list[ifcopenshell.entity_instance] = []
|
||||||
|
|
||||||
lining_props = self.settings["lining_properties"]
|
lining_props: dict[str, Any] = self.settings["lining_properties"]
|
||||||
lining_thickness = lining_props["LiningThickness"]
|
lining_thickness: float = lining_props["LiningThickness"]
|
||||||
lining_depth = lining_props["LiningDepth"]
|
lining_depth: float = lining_props["LiningDepth"]
|
||||||
lining_offset = lining_props["LiningOffset"]
|
lining_offset: float = lining_props["LiningOffset"]
|
||||||
lining_to_panel_offset_x = lining_props["LiningToPanelOffsetX"]
|
lining_to_panel_offset_x: float = lining_props["LiningToPanelOffsetX"]
|
||||||
lining_to_panel_offset_y = lining_props["LiningToPanelOffsetY"]
|
lining_to_panel_offset_y: float = lining_props["LiningToPanelOffsetY"]
|
||||||
overall_depth = lining_depth + lining_to_panel_offset_y
|
overall_depth: float = lining_depth + lining_to_panel_offset_y
|
||||||
|
|
||||||
mullion_thickness = lining_props["MullionThickness"] / 2
|
mullion_thickness: float = lining_props["MullionThickness"] / 2
|
||||||
first_mullion_offset = lining_props["FirstMullionOffset"]
|
first_mullion_offset: float = lining_props["FirstMullionOffset"]
|
||||||
second_mullion_offset = lining_props["SecondMullionOffset"]
|
second_mullion_offset: flaot = lining_props["SecondMullionOffset"]
|
||||||
transom_thickness = lining_props["TransomThickness"] / 2
|
transom_thickness: float = lining_props["TransomThickness"] / 2
|
||||||
first_transom_offset = lining_props["FirstTransomOffset"]
|
first_transom_offset: float = lining_props["FirstTransomOffset"]
|
||||||
second_transom_offset = lining_props["SecondTransomOffset"]
|
second_transom_offset: float = lining_props["SecondTransomOffset"]
|
||||||
glass_thickness = self.convert_si_to_unit(0.01)
|
glass_thickness: float = self.convert_si_to_unit(0.01)
|
||||||
|
|
||||||
panel_schema = list(reversed(panel_schema))
|
panel_schema = list(reversed(panel_schema))
|
||||||
|
|
||||||
# create 2d representation
|
# create 2d representation
|
||||||
def create_ifc_window_2d_representation():
|
def create_ifc_window_2d_representation() -> ifcopenshell.entity_instance:
|
||||||
items_2d = []
|
items_2d: list[ifcopenshell.entity_instance] = []
|
||||||
|
|
||||||
top_row = panel_schema[-1]
|
top_row = panel_schema[-1]
|
||||||
unique_cols = len(set(top_row))
|
unique_cols = len(set(top_row))
|
||||||
built_panels = []
|
built_panels: list[int] = []
|
||||||
accumulated_width = 0
|
accumulated_width: float = 0
|
||||||
|
|
||||||
for column_i, panel_i in enumerate(top_row):
|
for column_i, panel_i in enumerate(top_row):
|
||||||
cur_panel_items = []
|
cur_panel_items: list[ifcopenshell.entity_instance] = []
|
||||||
|
|
||||||
# lists represent left and right linings
|
# lists represent left and right linings
|
||||||
window_lining_thickness = [lining_thickness] * 2
|
window_lining_thickness = [lining_thickness] * 2
|
||||||
@@ -504,8 +503,8 @@ class Usecase:
|
|||||||
else:
|
else:
|
||||||
panel_width = overall_width
|
panel_width = overall_width
|
||||||
|
|
||||||
frame_depth = panels[panel_i]["FrameDepth"]
|
frame_depth: float = panels[panel_i]["FrameDepth"]
|
||||||
frame_thickness = panels[panel_i]["FrameThickness"]
|
frame_thickness: float = panels[panel_i]["FrameThickness"]
|
||||||
lining_to_panel_offset_y_full = (lining_depth - frame_depth) + lining_to_panel_offset_y
|
lining_to_panel_offset_y_full = (lining_depth - frame_depth) + lining_to_panel_offset_y
|
||||||
base_frame_clear = lining_to_panel_offset_x + frame_thickness - lining_thickness
|
base_frame_clear = lining_to_panel_offset_x + frame_thickness - lining_thickness
|
||||||
current_offset_x = base_frame_clear - frame_thickness + mullion_thickness
|
current_offset_x = base_frame_clear - frame_thickness + mullion_thickness
|
||||||
@@ -514,13 +513,15 @@ class Usecase:
|
|||||||
cur_panel_items.append(
|
cur_panel_items.append(
|
||||||
builder.polyline(
|
builder.polyline(
|
||||||
[
|
[
|
||||||
V(window_lining_thickness[0], 0),
|
(window_lining_thickness[0], 0),
|
||||||
V(panel_width - window_lining_thickness[1], 0),
|
(panel_width - window_lining_thickness[1], 0),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_lining_shape(lining_thickness, closed=True, mirror=False, x_offset=None):
|
def get_lining_shape(
|
||||||
|
lining_thickness: float, closed: bool = True, mirror: bool = False, x_offset: Optional[float] = None
|
||||||
|
) -> ifcopenshell.entity_instance:
|
||||||
if x_offset is None:
|
if x_offset is None:
|
||||||
x_offset = lining_to_panel_offset_x
|
x_offset = lining_to_panel_offset_x
|
||||||
l_shape_check = window_l_shape_check(
|
l_shape_check = window_l_shape_check(
|
||||||
@@ -532,25 +533,22 @@ class Usecase:
|
|||||||
if l_shape_check:
|
if l_shape_check:
|
||||||
lining_shape = builder.polyline(
|
lining_shape = builder.polyline(
|
||||||
[
|
[
|
||||||
V(0, lining_depth),
|
(0, lining_depth),
|
||||||
V(x_offset, lining_depth),
|
(x_offset, lining_depth),
|
||||||
V(
|
(x_offset, lining_to_panel_offset_y_full),
|
||||||
x_offset,
|
(lining_thickness, lining_to_panel_offset_y_full),
|
||||||
lining_to_panel_offset_y_full,
|
(lining_thickness, 0),
|
||||||
),
|
(0, 0),
|
||||||
V(lining_thickness, lining_to_panel_offset_y_full),
|
|
||||||
V(lining_thickness, 0),
|
|
||||||
V(0, 0),
|
|
||||||
],
|
],
|
||||||
closed=closed,
|
closed=closed,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
lining_shape = builder.polyline(
|
lining_shape = builder.polyline(
|
||||||
[
|
[
|
||||||
V(0, lining_depth),
|
(0, lining_depth),
|
||||||
V(lining_thickness, lining_depth),
|
(lining_thickness, lining_depth),
|
||||||
V(lining_thickness, 0),
|
(lining_thickness, 0),
|
||||||
V(0, 0),
|
(0, 0),
|
||||||
],
|
],
|
||||||
closed=closed,
|
closed=closed,
|
||||||
)
|
)
|
||||||
@@ -558,8 +556,8 @@ class Usecase:
|
|||||||
if mirror:
|
if mirror:
|
||||||
builder.mirror(
|
builder.mirror(
|
||||||
lining_shape,
|
lining_shape,
|
||||||
mirror_axes=V(1, 0),
|
mirror_axes=(1, 0),
|
||||||
mirror_point=V(panel_width / 2, 0),
|
mirror_point=(panel_width / 2, 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
return lining_shape
|
return lining_shape
|
||||||
@@ -581,9 +579,9 @@ class Usecase:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# add frame
|
# add frame
|
||||||
frame_items = []
|
frame_items: list[ifcopenshell.entity_instance] = []
|
||||||
|
|
||||||
frame_position = V(
|
frame_position = (
|
||||||
current_offset_x if right_to_mullion else lining_to_panel_offset_x,
|
current_offset_x if right_to_mullion else lining_to_panel_offset_x,
|
||||||
lining_to_panel_offset_y_full,
|
lining_to_panel_offset_y_full,
|
||||||
)
|
)
|
||||||
@@ -592,39 +590,39 @@ class Usecase:
|
|||||||
frame_width -= current_offset_x if left_to_mullion else lining_to_panel_offset_x
|
frame_width -= current_offset_x if left_to_mullion else lining_to_panel_offset_x
|
||||||
frame_width -= current_offset_x if right_to_mullion else lining_to_panel_offset_x
|
frame_width -= current_offset_x if right_to_mullion else lining_to_panel_offset_x
|
||||||
|
|
||||||
frame_vertical = builder.rectangle(size=V(frame_thickness, frame_depth))
|
frame_vertical = builder.rectangle(size=(frame_thickness, frame_depth))
|
||||||
frame_items.extend(
|
frame_items.extend(
|
||||||
[
|
[
|
||||||
frame_vertical,
|
frame_vertical,
|
||||||
builder.mirror(
|
builder.mirror(
|
||||||
frame_vertical,
|
frame_vertical,
|
||||||
mirror_axes=V(1, 0),
|
mirror_axes=(1, 0),
|
||||||
mirror_point=V(frame_width / 2, 0),
|
mirror_point=(frame_width / 2, 0),
|
||||||
create_copy=True,
|
create_copy=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
frame_horizontal = builder.polyline([V(frame_thickness, 0), V(frame_width - frame_thickness, 0)])
|
frame_horizontal = builder.polyline([(frame_thickness, 0), (frame_width - frame_thickness, 0)])
|
||||||
frame_items.extend(
|
frame_items.extend(
|
||||||
[
|
[
|
||||||
frame_horizontal,
|
frame_horizontal,
|
||||||
builder.translate(frame_horizontal, V(0, frame_depth), create_copy=True),
|
builder.translate(frame_horizontal, (0, frame_depth), create_copy=True),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
# glass
|
# glass
|
||||||
frame_items.append(builder.translate(frame_horizontal, V(0, frame_depth / 2), create_copy=True))
|
frame_items.append(builder.translate(frame_horizontal, (0, frame_depth / 2), create_copy=True))
|
||||||
|
|
||||||
builder.translate(frame_items, frame_position)
|
builder.translate(frame_items, frame_position)
|
||||||
cur_panel_items.extend(frame_items)
|
cur_panel_items.extend(frame_items)
|
||||||
|
|
||||||
builder.translate(cur_panel_items, V(accumulated_width, 0))
|
builder.translate(cur_panel_items, (accumulated_width, 0))
|
||||||
|
|
||||||
accumulated_width += panel_width
|
accumulated_width += panel_width
|
||||||
built_panels.append(panel_i)
|
built_panels.append(panel_i)
|
||||||
items_2d.extend(cur_panel_items)
|
items_2d.extend(cur_panel_items)
|
||||||
|
|
||||||
builder.translate(items_2d, V(0, lining_offset))
|
builder.translate(items_2d, (0, lining_offset))
|
||||||
representation_2d = builder.get_representation(self.settings["context"], items_2d)
|
representation_2d = builder.get_representation(self.settings["context"], items_2d)
|
||||||
return representation_2d
|
return representation_2d
|
||||||
|
|
||||||
@@ -711,9 +709,8 @@ class Usecase:
|
|||||||
|
|
||||||
window_lining_size = V(panel_width, lining_depth, panel_height)
|
window_lining_size = V(panel_width, lining_depth, panel_height)
|
||||||
frame_size = window_lining_size.copy()
|
frame_size = window_lining_size.copy()
|
||||||
frame_size.y = frame_depth
|
frame_size[np_Y] = frame_depth
|
||||||
frame_size.x -= x_offsets[0] + x_offsets[2]
|
frame_size[np_X] -= x_offsets[0] + x_offsets[2]
|
||||||
frame_size.z -= x_offsets[1] + x_offsets[3]
|
|
||||||
|
|
||||||
window_panel_position = V(accumulated_width, 0, accumulated_height[column_i])
|
window_panel_position = V(accumulated_width, 0, accumulated_height[column_i])
|
||||||
# create window panel
|
# create window panel
|
||||||
@@ -735,9 +732,14 @@ class Usecase:
|
|||||||
accumulated_height[column_i] += panel_height
|
accumulated_height[column_i] += panel_height
|
||||||
accumulated_width += panel_width
|
accumulated_width += panel_width
|
||||||
|
|
||||||
builder.translate(window_items, V(0, lining_offset, 0)) # wall offset
|
builder.translate(window_items, (0, lining_offset, 0)) # wall offset
|
||||||
representation = builder.get_representation(self.settings["context"], window_items)
|
representation = builder.get_representation(self.settings["context"], window_items)
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
def convert_si_to_unit(self, value):
|
@overload
|
||||||
return value / self.settings["unit_scale"]
|
def convert_si_to_unit(self, value: float) -> float: ...
|
||||||
|
@overload
|
||||||
|
def convert_si_to_unit(self, value: np.ndarray) -> np.ndarray: ...
|
||||||
|
def convert_si_to_unit(self, value: Union[float, np.ndarray]) -> Union[float, np.ndarray]:
|
||||||
|
si_conversion = 1 / self.settings["unit_scale"]
|
||||||
|
return value * si_conversion
|
||||||
|
|||||||
Reference in New Issue
Block a user