bluemira.geometry.overlap_checking

Contains functions to efficiently check for overlaps between solids.

Functions

two_set_mutually_exclusive(→ numpy.ndarray)

Given TWO lists of bounds, (e.g. x-bounds, i.e. x-min and x-max for each cell),

check_two_sets_bb_non_interference(→ numpy.ndarray)

Check which bounding box do not interfere/overlap with which other bounding box.

get_overlaps_asymmetric(→ numpy.ndarray)

Get the indices of the bounding boxes that are overlapping. The overlap matrix is the

is_mutually_exclusive(→ numpy.ndarray)

Given a list of bounds, (e.g. x-bounds, showing .xmin() and .xmax() for each cell),

check_bb_non_interference(→ numpy.ndarray)

Check which bounding box do not interfere/overlap with which other bounding box.

get_overlaps_arr(→ numpy.ndarray)

Get the indices of the bounding boxes that are overlapping. The overlap matrix is the

scale_points_from_centroid(points, scale_factor)

Scale a set of points from their centroid by a given scale factor.

find_approx_overlapping_pairs(solids, *[, use_cgal])

Finds the pairs of solids that are approximately overlapping.

Module Contents

bluemira.geometry.overlap_checking.two_set_mutually_exclusive(min_a: numpy.ndarray[float], max_a: numpy.ndarray[float], min_b: numpy.ndarray[float], max_b: numpy.ndarray[float]) numpy.ndarray

Given TWO lists of bounds, (e.g. x-bounds, i.e. x-min and x-max for each cell), find whether each cell is mutually exclusive (i.e. does NOT overlap) with other cells. This forms a 2D exclusivity matrix.

Parameters:
  • min_a (numpy.ndarray[float]) – lower bound for each cell in set A, a 1D array.

  • max_a (numpy.ndarray[float]) – upper bound for each cell in set A, a 1D array.

  • min_b (numpy.ndarray[float]) – lower bound for each cell in set B, a 1D array.

  • max_b (numpy.ndarray[float]) – upper bound for each cell in set B, a 1D array.

Returns:

A 2D exclusivity matrix showing True where they’re NOT overlapping, False if overlapping. The main-diagonal of this matrix can be ignored.

Return type:

numpy.ndarray

Note

Must have the property that all(min_a<=max_a) and all(min_b<=max_b).

bluemira.geometry.overlap_checking.check_two_sets_bb_non_interference(set_a_3d_tensor: numpy.ndarray, set_b_3d_tensor: numpy.ndarray) numpy.ndarray

Check which bounding box do not interfere/overlap with which other bounding box.

Parameters:
  • set_a_3d_tensor (numpy.ndarray) – An array of 2D arrays (each with shape = (3,2)), each row of the 2D array is the x, y, z bounds (min, max) for that set A cell.

  • set_b_3d_tensor (numpy.ndarray) – An array of 2D arrays (each with shape = (3,2)), each row of the 2D array is the x, y, z bounds (min, max) for that set B cell.

Returns:

A matrix of booleans showing whether the bounding boxes overlap.

Return type:

exclusivity_matrix

bluemira.geometry.overlap_checking.get_overlaps_asymmetric(exclusivity_matrix) numpy.ndarray

Get the indices of the bounding boxes that are overlapping. The overlap matrix is the element-wise negation of the exclusivity matrix. This function returns the 2-D indices of non-zero elements.

Parameters:

exclusivity_matrix – The matrix denoting whether each bounding box overlap with other bounding boxes, generated by check_two_sets_bb_non_interference().

Returns:

2D array of integers, each row is a pair of indices of i<j

Return type:

indices

bluemira.geometry.overlap_checking.is_mutually_exclusive(min_: numpy.ndarray[float], max_: numpy.ndarray[float]) numpy.ndarray

Given a list of bounds, (e.g. x-bounds, showing .xmin() and .xmax() for each cell), find whether each cell is mutually exclusive (i.e. does NOT overlap) with other cells. This forms a 2D exclusivity matrix.

Parameters:
  • min – lower bound for each cell, a 1D array.

  • max – upper bound for each cell, a 1D array.

  • min_ (numpy.ndarray[float])

  • max_ (numpy.ndarray[float])

Returns:

A 2D exclusivity matrix showing True where they’re NOT overlapping, False if overlapping. The main-diagonal of this matrix can be ignored.

Return type:

numpy.ndarray

Note

Must have the property that all(min_<=max_)==True.

bluemira.geometry.overlap_checking.check_bb_non_interference(tensor_3d: numpy.ndarray) numpy.ndarray

Check which bounding box do not interfere/overlap with which other bounding box.

Parameters:

tensor_3d (numpy.ndarray) – An array of 2D arrays (each with shape = (3,2)), each row of the 2D array is the x, y, z bounds (min, max) for that cell.

Returns:

A matrix of booleans showing whether the bounding boxes overlap.

Return type:

exclusivity_matrix

bluemira.geometry.overlap_checking.get_overlaps_arr(exclusivity_matrix) numpy.ndarray

Get the indices of the bounding boxes that are overlapping. The overlap matrix is the element-wise negation of the exclusivity matrix. This function returns the 2-D indices of non-zero elements on the upper-right triangle of this matrix.

Parameters:

exclusivity_matrix – The matrix denoting whether each bounding box overlap with other bounding boxes, generated by check_bb_non_interference().

Returns:

2D array of integers, each row is a pair of indices of i<j

Return type:

indices

bluemira.geometry.overlap_checking.scale_points_from_centroid(points, scale_factor)

Scale a set of points from their centroid by a given scale factor.

Parameters:
  • points (np.ndarray) – An array of shape (n, 3) representing the x, y, z coordinates of the points.

  • scale_factor (float) – The scale factor by which to scale the points.

Returns:

scaled_points – An array of shape (n, 3) representing the scaled x, y, z coordinates of the points.

Return type:

np.ndarray

bluemira.geometry.overlap_checking.find_approx_overlapping_pairs(solids: collections.abc.Iterable[bluemira.geometry.solid.BluemiraSolid], *, use_cgal: bool = True)

Finds the pairs of solids that are approximately overlapping.

This function uses bounding boxes to quickly eliminate non-overlapping pairs, and then refines the results using a numpy (or CGAL, if installed) based apporach to refind the number of overlapping pairs taking into the geometry, in a confirmal manner.

Parameters:
  • solids (collections.abc.Iterable[bluemira.geometry.solid.BluemiraSolid]) – An iterable of BluemiraSolid objects to check for overlaps between.

  • use_cgal (bool) – If True, use CGAL to check for overlaps. Otherwise, use numpy. If CGAL is not available, this will default to numpy (even if True).

Return type:

A list of tuples of indices of overlapping pairs.