bluemira.geometry._private_tools
A collection of private geometry tools for discretised geometry. Do not use these; use primitive operations in geometry/tools.py instead.
Exceptions
An error to raise when the area of a mixed face does not give a good match to the |
Classes
Utility class for the creation of Faces that combine splines and polygons. |
Functions
|
Returns the length of each individual segment in a set of coordinates |
|
Calculates the side vectors of an anti-clockwise polygon |
|
Get a square-based offset of the coordinates (no splines). N-sized output |
|
Make a circle arc of a specified radius and angle at a given location. |
Converts the provided coordinates into a BluemiraWire using the specified method. |
|
Converts the provided coordinates into a BluemiraFace using the specified method. |
|
|
Construct a BluemiraWire object from the provided coordinates using a combination of |
|
Construct a BluemiraFace object from the provided coordinates using a combination of |
|
Makes a wire from a set of coordinates. |
|
Makes a face from a set of coordinates. |
Module Contents
- exception bluemira.geometry._private_tools.MixedFaceAreaError
Bases:
bluemira.geometry.error.GeometryErrorAn error to raise when the area of a mixed face does not give a good match to the area enclosed by the original coordinates.
- bluemira.geometry._private_tools._segment_lengths(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray) numpy.ndarray
Returns the length of each individual segment in a set of coordinates
- Parameters:
x (numpy.ndarray) – x coordinates [m]
y (numpy.ndarray) – y coordinates [m]
z (numpy.ndarray) – z coordinates [m]
- Return type:
The array of the length of each individual segment in the coordinates
- bluemira.geometry._private_tools._side_vector(polygon_array: numpy.ndarray) numpy.ndarray
Calculates the side vectors of an anti-clockwise polygon
- Parameters:
polygon_array (numpy.ndarray) – The 2-D array of polygon point coordinates
- Returns:
The 2-D array of the polygon side vectors
- Return type:
sides
- bluemira.geometry._private_tools.offset(x: numpy.ndarray, z: numpy.ndarray, offset_value: float) tuple[numpy.ndarray, numpy.ndarray]
Get a square-based offset of the coordinates (no splines). N-sized output
- Parameters:
x (numpy.ndarray) – The x coordinate vector
z (numpy.ndarray) – The x coordinate vector
offset_value (float) – The offset value [m]
- Returns:
xo – The x offset coordinates
zo – The z offset coordinates
- Return type:
tuple[numpy.ndarray, numpy.ndarray]
- bluemira.geometry._private_tools.make_circle_arc(radius: float, x_centre: float = 0, y_centre: float = 0, angle: float = 2 * np.pi, n_points: int = 200, start_angle: float = 0) tuple[numpy.ndarray, numpy.ndarray]
Make a circle arc of a specified radius and angle at a given location.
- Parameters:
radius (float) – The radius of the circle arc
x_centre (float) – The x coordinate of the circle arc centre
y_centre (float) – The y coordinate of the circle arc centre
angle (float) – The angle of the circle arc [radians]
n_points (int) – The number of points on the circle
start_angle (float) – The starting angle of the circle arc
- Returns:
x – The x coordinates of the circle arc
y – The y coordinates of the circle arc
- Return type:
tuple[numpy.ndarray, numpy.ndarray]
- bluemira.geometry._private_tools.convert_coordinates_to_wire(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', method: str = 'mixed', **kwargs: dict[str, Any]) bluemira.geometry.wire.BluemiraWire
Converts the provided coordinates into a BluemiraWire using the specified method.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraWire object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraWire object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraWire object
method (str) –
The conversion method to be used:
mixed (default): results in a mix of splines and polygons
polygon: pure polygon representation
spline: pure spline representation
label (str) – The label for the resulting BluemiraWire object
kwargs (dict[str, Any]) – Any other arguments for the conversion method, see e.g. make_mixed_face
- Return type:
The resulting BluemiraWire from the conversion
- bluemira.geometry._private_tools.convert_coordinates_to_face(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, method: str = 'mixed', label: str = '', **kwargs: dict[str, Any]) bluemira.geometry.face.BluemiraFace
Converts the provided coordinates into a BluemiraFace using the specified method.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraFace object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraFace object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraFace object
method (str) –
The conversion method to be used:
mixed (default): results in a mix of splines and polygons
polygon: pure polygon representation
spline: pure spline representation
label (str) – The label for the resulting BluemiraFace object
kwargs (dict[str, Any]) – Any other arguments for the conversion method, see e.g. make_mixed_face
- Return type:
The resulting BluemiraFace from the conversion
- bluemira.geometry._private_tools.make_mixed_wire(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', *, median_factor: float = 2.0, n_segments: int = 4, a_acute: float = 150.0, cleaning_atol: float = 1e-06, allow_fallback: bool = True, debug: bool = False) bluemira.geometry.wire.BluemiraWire
Construct a BluemiraWire object from the provided coordinates using a combination of polygon and spline wires. Polygons are determined by having a median length larger than the threshold or an angle that is more acute than the threshold.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraWire object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraWire object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraWire object
label (str) – The label for the resulting BluemiraWire object
median_factor (float) – The factor of the median for which to filter segment lengths (below median_factor*median_length –> spline)
n_segments (int) – The minimum number of segments for a spline
a_acute (float) – The angle [degrees] between two consecutive segments deemed to be too acute to be fit with a spline.
cleaning_atol (float) – If a point lies within this distance [m] of the previous point then it will be treated as a duplicate and removed. This can stabilise the conversion in cases where the point density is too high for a wire to be constructed as a spline. By default this is set to 1e-6.
allow_fallback (bool) – If True then a failed attempt to make a mixed wire will fall back to a polygon wire, else an exception will be raised. By default True.
debug (bool) – Whether or not to print debugging information
- Return type:
The BluemiraWire of the mixed polygon/spline coordinates
- Raises:
RuntimeError – Cannot create mixed face
- bluemira.geometry._private_tools.make_mixed_face(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', *, median_factor: float = 2.0, n_segments: int = 4, a_acute: float = 150.0, cleaning_atol: float = 1e-06, area_rtol: float = 0.05, allow_fallback: bool = True, debug: bool = False) bluemira.geometry.face.BluemiraFace
Construct a BluemiraFace object from the provided coordinates using a combination of polygon and spline wires. Polygons are determined by having a median length larger than the threshold or an angle that is more acute than the threshold.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraFace object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraFace object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraFace object
label (str) – The label for the resulting BluemiraFace object
median_factor (float) – The factor of the median for which to filter segment lengths (below median_factor*median_length –> spline)
n_segments (int) – The minimum number of segments for a spline
a_acute (float) – The angle [degrees] between two consecutive segments deemed to be too acute to be fit with a spline.
cleaning_atol (float) – If a point lies within this distance [m] of the previous point then it will be treated as a duplicate and removed. This can stabilise the conversion in cases where the point density is too high for a wire to be constructed as a spline. By default this is set to 1e-6.
area_rtol (float) – If the area of the resulting face deviates by this relative value from the area enclosed by the provided coordinates then the conversion will fail and either fall back to a polygon-like face or raise an exception, depending on the setting of allow_fallback.
allow_fallback (bool) – If True then a failed attempt to make a mixed face will fall back to a polygon wire, else an exception will be raised. By default True.
debug (bool) – Whether or not to print debugging information
- Return type:
The BluemiraFace of the mixed polygon/spline coordinates
- Raises:
MixedFaceAreaError – Face and coordinates area are not close
RuntimeError – Can make mixed face
- bluemira.geometry._private_tools.make_wire(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', *, spline: bool = False) bluemira.geometry.wire.BluemiraWire
Makes a wire from a set of coordinates.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraWire object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraWire object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraWire object
label (str) – The label for the resulting BluemiraWire object
spline (bool) – If True then creates the BluemiraWire using a Bezier spline curve, by default False
- Return type:
The BluemiraWire bound by the coordinates
- bluemira.geometry._private_tools.make_face(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', *, spline: bool = False) bluemira.geometry.face.BluemiraFace
Makes a face from a set of coordinates.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraFace object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraFace object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraFace object
label (str) – The label for the resulting BluemiraFace object
spline (bool) – If True then creates the BluemiraFace using a Bezier spline curve, by default False
- Return type:
The BluemiraFace bound by the coordinates
- class bluemira.geometry._private_tools.MixedFaceMaker(x: numpy.ndarray, y: numpy.ndarray, z: numpy.ndarray, label: str = '', *, median_factor: float = 2.0, n_segments: int = 4, a_acute: float = 150.0, cleaning_atol: float = 1e-06, debug: bool = False)
Utility class for the creation of Faces that combine splines and polygons.
Polygons are detected by median length and turning angle.
- Parameters:
x (numpy.ndarray) – The x coordinates of points to be converted to a BluemiraFace object
y (numpy.ndarray) – The y coordinates of points to be converted to a BluemiraFace object
z (numpy.ndarray) – The z coordinates of points to be converted to a BluemiraFace object
label (str) – The label for the resulting BluemiraFace object
median_factor (float) – The factor of the median for which to filter segment lengths (below median_factor*median_length –> spline)
n_segments (int) – The minimum number of segments for a spline
a_acute (float) – The angle [degrees] between two consecutive segments deemed to be too acute to be fit with a spline.
cleaning_atol (float) – If a point lies within this distance [m] of the previous point then it will be treated as a duplicate and removed. This can stabilise the conversion in cases where the point density is too high for a wire to be constructed as a spline. By default this is set to 1e-6.
debug (bool) – Whether or not to print debugging information
- x
- y
- z
- num_points
- label = ''
- median_factor = 2.0
- n_segments = 4
- a_acute = 150.0
- cleaning_atol = 1e-06
- debug = False
- edges = None
- wire = None
- face = None
- polygon_loops = None
- spline_loops = None
- flag_spline_first = None
- _debugger = None
- build()
Carry out the MixedFaceMaker sequence to make a Face
- _find_polygon_vertices() numpy.ndarray
Finds all vertices in the Coordinates which belong to polygon-like edges
- Return type:
The vertices of the coordinates which are polygon-like (dtype=int)
- _get_polygon_sequences(vertices: numpy.ndarray) list[list[float]]
Gets the sequences of polygon segments
- Parameters:
vertices (numpy.ndarray) – The vertices of the lcoordinates which are polygon-like
- Returns:
The list of start and end tuples of the polygon segments
list([start, end], [start, end])
- Raises:
GeometryError – Not a good candidate for splining
- Return type:
list[list[float]]
- _get_spline_sequences(polygon_sequences: numpy.ndarray) list[list[float]]
Gets the sequences of spline segments
- Parameters:
polygon_sequences (numpy.ndarray) – The list of start and end tuples of the polygon segments
- Returns:
The list of start and end tuples of the spline segments
list([start, end], [start, end])
- Return type:
list[list[float]]
- _clean_coordinates(coords: numpy.ndarray) numpy.ndarray
Clean the provided coordinates by removing any values that are closer than the instance’s cleaning_atol value.
- Parameters:
coords (numpy.ndarray) – 3D array of coordinates to be cleaned.
- Return type:
3D array of cleaned coordinates.
- _make_subcoordinates(polygon_sequences: numpy.ndarray, spline_sequences: numpy.ndarray)
- Parameters:
polygon_sequences (numpy.ndarray)
spline_sequences (numpy.ndarray)
- _make_subwires()
- _make_wire()
- _make_face()