bluemira.geometry.base

Base classes and functionality for the bluemira geometry module.

Attributes

BluemiraGeoT

Classes

_Orientation

Create a collection of name/value pairs.

BluemiraGeo

Abstract base class for geometry.

Module Contents

class bluemira.geometry.base._Orientation(*args, **kwds)

Bases: enum.Enum

Inheritance diagram of bluemira.geometry.base._Orientation

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

FORWARD = 'Forward'
REVERSED = 'Reversed'
bluemira.geometry.base.BluemiraGeoT
class bluemira.geometry.base.BluemiraGeo(boundary: BluemiraGeoT | list[BluemiraGeoT], label: str = '', boundary_classes: list[type[BluemiraGeoT]] | None = None)

Bases: abc.ABC, bluemira.mesh.meshing.Meshable

Inheritance diagram of bluemira.geometry.base.BluemiraGeo

Abstract base class for geometry.

Parameters:
  • boundary (BluemiraGeoT | list[BluemiraGeoT]) – shape’s boundary

  • label (str) – identification label for the shape

  • boundary_classes (list[type[BluemiraGeoT]] | None) – list of allowed class types for shape’s boundary

_boundary_classes = []
__orientation
label = ''
property _orientation
_check_reverse(obj)
static _converter(func)

Function used in __getattr__ to modify the added functions.

Returns:

Function used in __getattr__ to modify the added functions.

_check_boundary(objs)

Check if objects objs can be used as boundaries.

Returns:

The objects that can be used as boundaries.

Raises:

TypeError – Only given boundary classes can be the boundary

Notes

Empty BluemiraGeo are allowed in case of objs == None.

property boundary: tuple

The shape’s boundary.

Return type:

tuple

_set_boundary(objs, *, replace_shape: bool = True)
Parameters:

replace_shape (bool)

abstract _create_shape()

Create the shape from the boundary

property shape: bluemira.codes._freecadapi.apiShape

The primitive shape of the object.

Return type:

bluemira.codes._freecadapi.apiShape

_set_shape(value: bluemira.codes._freecadapi.apiShape)
Parameters:

value (bluemira.codes._freecadapi.apiShape)

property length: float

The shape’s length.

Return type:

float

property area: float

The shape’s area.

Return type:

float

property volume: float

The shape’s volume.

Return type:

float

property center_of_mass: numpy.ndarray

The shape’s center of mass.

Return type:

numpy.ndarray

property bounding_box: bluemira.geometry.bound_box.BoundingBox

The bounding box of the shape.

Notes

If your shape is complicated, i.e. contains splines, this method is potentially less accurate. Consider using optimal_bounding_box instead.

Return type:

bluemira.geometry.bound_box.BoundingBox

property optimal_bounding_box: bluemira.geometry.bound_box.BoundingBox

Get the optimised bounding box of the shape, via freecad’s optimalBoundingBox method.

Returns:

The optimised bounding box of the shape.

Return type:

bluemira.geometry.bound_box.BoundingBox

Notes

For more complicated geometries, this gives a tighter bounding box, but is slower. For simpler geometries where no tigher bounding box can be found, the time taken by this is the same as bounding_box.

is_null() bool

Check if the shape is null.

Returns:

A boolean for if the shape is null.

Return type:

bool

is_closed() bool

Check if the shape is closed.

Returns:

A boolean for if the shape is closed.

Return type:

bool

is_valid() bool

Check if the shape is valid.

Returns:

A boolean for if the shape is valid.

Return type:

bool

is_same(obj: BluemiraGeo) bool

Check if obj has the same shape as self

Returns:

A boolean for if the obj is the same shape as self.

Parameters:

obj (BluemiraGeo)

Return type:

bool

search(label: str) list[BluemiraGeo]

Search for a shape with the specified label

Parameters:

label (str) – Shape label

Return type:

List of shapes that have the specified label

scale(factor: float) None

Apply scaling with factor to this object. This function modifies the self object.

Note

The operation is made on shape and boundary in order to maintain the consistency. Shape is then not reconstructed from boundary (in order to reduce the computational time and avoid problems due to api objects orientation).

Parameters:

factor (float)

Return type:

None

_tessellate(tolerance: float = 1.0) tuple[numpy.ndarray, numpy.ndarray]

Tessellate the geometry object.

Parameters:

tolerance (float) – Tolerance with which to tessellate the geometry

Returns:

  • vertices – Array of the vertices (N, 3, dtype=float) from the tesselation operation

  • indices – Array of the indices (M, 3, dtype=int) from the tesselation operation

Return type:

tuple[numpy.ndarray, numpy.ndarray]

Notes

Once tesselated, an object’s properties may change. Tesselation cannot be reverted to a previous lower value, but can be increased (irreversibly).

translate(vector: tuple[float, float, float]) None

Translate this shape with the vector. This function modifies the self object.

Note

The operation is made on shape and boundary in order to maintain the consistency. Shape is then not reconstructed from boundary (in order to reduce the computational time and avoid problems due to api objects orientation).

Parameters:

vector (tuple[float, float, float])

Return type:

None

rotate(base: tuple[float, float, float] = (0.0, 0.0, 0.0), direction: tuple[float, float, float] = (0.0, 0.0, 1.0), degree: float = 180)

Rotate this shape.

Parameters:
  • base (tuple[float, float, float]) – Origin location of the rotation

  • direction (tuple[float, float, float]) – The direction vector

  • degree (float) – rotation angle

Notes

The operation is made on shape and boundary in order to maintain the consistency. Shape is then not reconstructed from boundary (in order to reduce the computational time and avoid problems due to api objects orientation).

change_placement(placement: bluemira.geometry.placement.BluemiraPlacement) None

Change the placement of self .. note:

The operation is made on shape and boundary in order to maintain the consistency.
Shape is then not reconstructed from boundary (in order to reduce the
computational time and avoid problems due to api objects orientation).
Parameters:

placement (bluemira.geometry.placement.BluemiraPlacement)

Return type:

None

__repr__() str
Return type:

str

__deepcopy__(memo)

Deepcopy for BluemiraGeo.

FreeCAD shapes cannot be deepcopied on versions >=0.21

Returns:

A deepcopy of the BluemiraGeo.

copy(label: str | None = None) BluemiraGeo

Make a copy of the BluemiraGeo.

Returns:

A copy of the BluemiraGeo.

Parameters:

label (str | None)

Return type:

BluemiraGeo

deepcopy(label: str | None = None) BluemiraGeo

Make a deepcopy of the BluemiraGeo.

Returns:

A deepcopy of the BluemiraGeo.

Parameters:

label (str | None)

Return type:

BluemiraGeo

property vertexes: bluemira.geometry.coordinates.Coordinates
Abstractmethod:

Return type:

bluemira.geometry.coordinates.Coordinates

The vertexes of the BluemiraGeo.

property edges: tuple
Abstractmethod:

Return type:

tuple

The edges of the BluemiraGeo.

property wires: tuple
Abstractmethod:

Return type:

tuple

The wires of the BluemiraGeo.

property faces: tuple
Abstractmethod:

Return type:

tuple

The faces of the BluemiraGeo.

property shells: tuple
Abstractmethod:

Return type:

tuple

The shells of the BluemiraGeo.

property solids: tuple
Abstractmethod:

Return type:

tuple

The solids of the BluemiraGeo.