Source code for viiapackage.strengthening.helper_functions.find_wall_openings

### ===================================================================================================================
###   viia_find_wall_openings
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

from typing import List

# References for functions and classes in the fem-client
from rhdhv_fem.shapes import Wall
from rhdhv_fem.fem_shapes import fem_min_max_points
from rhdhv_fem.fem_math import fem_unit_vector_2_points, fem_dot_product_vector


### ===================================================================================================================
###   2. Function to find the wall openings
### ===================================================================================================================

[docs]def viia_find_wall_openings(wall: Wall, direction_axis: List[float]): """ This function finds the openings of the wall with respect to the defined local x-axis. This axis generally goes from left to right, seen from the inside (i.e. the direction of the outward wall vector). It returns a list that contains the extreme x- and y-coordinates of wall openings. Input: - wall (obj): Object reference of wall shape. - direction_axis (list of 3 floats): Vector of the direction in which the points of the openings are ordered. Output: - Returns a list with lists of 3 floats. """ # Initiate container for openings opening_locations = [] # Find extreme x- and y-coordinates of openings if wall.openings is not None: for opening in wall.openings: points = fem_min_max_points(collection=[opening]) # Find combination of x- and y-components of the extremes that are parallel to the localXAxis pminmin = [points['x-min'], points['y-min'], 0] pmaxmax = [points['x-max'], points['y-max'], 0] pminmax = [points['x-min'], points['y-max'], 0] pmaxmin = [points['x-max'], points['y-min'], 0] uv1 = fem_unit_vector_2_points(pminmin, pmaxmax) uv2 = fem_unit_vector_2_points(pminmax, pmaxmin) # A dot product of 1 indicates parallel unit vectors with the same direction # A dot product of -1 indicates parallel unit vectors with opposing direction dp1 = fem_dot_product_vector(uv1, direction_axis) dp2 = fem_dot_product_vector(uv2, direction_axis) # Add opening in direction of localXAxis if dp1 == 1: opening_locations.append([pminmin, pmaxmax]) elif dp1 == -1: opening_locations.append([pmaxmax, pminmin]) elif dp2 == 1: opening_locations.append([pminmax, pmaxmin]) elif dp2 == -1: opening_locations.append([pmaxmin, pminmax]) return opening_locations
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================