Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windowparameter): Do not create degenerate windows #514

Merged
merged 1 commit into from Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions dragonfly/windowparameter.py
Expand Up @@ -147,6 +147,8 @@ def add_window_to_face(self, face, tolerance=0.01):
tolerance: Optional tolerance value. Default: 0.01, suitable for
objects in meters.
"""
if self._width == 0 or self._height == 0:
return None
width_seg = LineSegment3D.from_end_points(face.geometry[0], face.geometry[1])
height_seg = LineSegment3D.from_end_points(face.geometry[1], face.geometry[2])
max_width = width_seg.length * 0.99
Expand Down Expand Up @@ -258,6 +260,8 @@ def add_window_to_face(self, face, tolerance=0.01):
tolerance: Optional tolerance value. Default: 0.01, suitable for
objects in meters.
"""
if self._window_ratio == 0:
return None
scale_factor = self.window_ratio ** .5
ap_face = face.geometry.scale(scale_factor, face.geometry.center)
aperture = Aperture('{}_Glz1'.format(face.identifier), ap_face)
Expand Down Expand Up @@ -380,6 +384,8 @@ def add_window_to_face(self, face, tolerance=0.01):
considered a part of a rectangle. Default: 0.01, suitable for
objects in meters.
"""
if self._window_ratio == 0:
return None
face.apertures_by_ratio_rectangle(
self.window_ratio, self.window_height, self.sill_height,
self.horizontal_separation, self.vertical_separation, tolerance)
Expand Down Expand Up @@ -531,6 +537,8 @@ def add_window_to_face(self, face, tolerance=0.01):
considered a part of a rectangle. Default: 0.01, suitable for
objects in meters.
"""
if self._window_width == 0 or self._window_height == 0:
return None
face.apertures_by_width_height_rectangle(
self.window_height, self.window_width, self.sill_height,
self.horizontal_separation, tolerance)
Expand Down Expand Up @@ -670,6 +678,8 @@ def __init__(self, origins, widths, heights):

assert len(self._origins) == len(self._widths) == len(self._heights), \
'Number of window origins, widths, and heights must match.'
assert len(self._origins) != 0, \
'There must be at least one window to use RectangularWindows.'

@property
def origins(self):
Expand Down Expand Up @@ -883,6 +893,8 @@ def __init__(self, polygons):
for polygon in polygons:
assert isinstance(polygon, Polygon2D), \
'Expected Polygon2D for window polygon. Got {}'.format(type(polygon))
assert len(polygons) != 0, \
'There must be at least one polygon to use DetailedWindows.'
self._polygons = polygons

@classmethod
Expand Down