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(room2d): Expose filter tolerance on generate_alignment_axes #744

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dragonfly/room2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4554,7 +4554,7 @@ def room_orientation_plane(room_2ds, angle_tolerance=1.0):

@staticmethod
def generate_alignment_axes(room_2ds, distance, direction=Vector2D(0, 1),
angle_tolerance=1.0):
angle_tolerance=1.0, filter_tolerance=0):
"""Get suggested LineSegment2Ds for the Room2D.align method.

This method will return the most common axes across the input Room2D
Expand All @@ -4578,6 +4578,11 @@ def generate_alignment_axes(room_2ds, distance, direction=Vector2D(0, 1),
angle_tolerance: The max angle difference in degrees that the Room2D
segment direction can differ from the input direction before the
segments are not factored into this calculation of common axes.
filter_tolerance: A number that can be used to filter out axes in the
result, which are already perfectly aligned with the input polygon
segments. Setting this to zero wil guarantee that no axes are
filtered out no matter how close they are to the existing polygon
segments. (Default: 0).

Returns:
A tuple with two elements.
Expand All @@ -4601,7 +4606,7 @@ def generate_alignment_axes(room_2ds, distance, direction=Vector2D(0, 1),
polygons.append(hole)
# return the common axes and values
return Polygon2D.common_axes(
polygons, direction, min_distance, merge_distance, ang_tol)
polygons, direction, min_distance, merge_distance, ang_tol, filter_tolerance)

@staticmethod
def floor_segment_by_index(geometry, segment_index):
Expand Down