bluemira.geometry.base ====================== .. py:module:: bluemira.geometry.base .. autoapi-nested-parse:: Base classes and functionality for the bluemira geometry module. Attributes ---------- .. autoapisummary:: bluemira.geometry.base.BluemiraGeoT Classes ------- .. autoapisummary:: bluemira.geometry.base._Orientation bluemira.geometry.base.BluemiraGeo Module Contents --------------- .. py:class:: _Orientation(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.geometry.base._Orientation :parts: 1 :private-bases: 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 - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: FORWARD :value: 'Forward' .. py:attribute:: REVERSED :value: 'Reversed' .. py:data:: BluemiraGeoT .. py:class:: BluemiraGeo(boundary: BluemiraGeoT | list[BluemiraGeoT], label: str = '', boundary_classes: list[type[BluemiraGeoT]] | None = None) Bases: :py:obj:`abc.ABC`, :py:obj:`bluemira.mesh.meshing.Meshable` .. autoapi-inheritance-diagram:: bluemira.geometry.base.BluemiraGeo :parts: 1 :private-bases: Abstract base class for geometry. :param boundary: shape's boundary :param label: identification label for the shape :param boundary_classes: list of allowed class types for shape's boundary .. py:attribute:: _boundary_classes :value: [] .. py:attribute:: __orientation .. py:attribute:: label :value: '' .. py:property:: _orientation .. py:method:: _check_reverse(obj) .. py:method:: _converter(func) :staticmethod: Function used in __getattr__ to modify the added functions. :returns: Function used in __getattr__ to modify the added functions. .. py:method:: _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 .. rubric:: Notes Empty BluemiraGeo are allowed in case of objs == None. .. py:property:: boundary :type: tuple The shape's boundary. .. py:method:: _set_boundary(objs, *, replace_shape: bool = True) .. py:method:: _create_shape() :abstractmethod: Create the shape from the boundary .. py:property:: shape :type: bluemira.codes._freecadapi.apiShape The primitive shape of the object. .. py:method:: _set_shape(value: bluemira.codes._freecadapi.apiShape) .. py:property:: length :type: float The shape's length. .. py:property:: area :type: float The shape's area. .. py:property:: volume :type: float The shape's volume. .. py:property:: center_of_mass :type: numpy.ndarray The shape's center of mass. .. py:property:: bounding_box :type: bluemira.geometry.bound_box.BoundingBox The bounding box of the shape. .. rubric:: Notes If your shape is complicated, i.e. contains splines, this method is potentially less accurate. Consider using :attr:`~bluemira.geometry.base.BluemiraGeo.optimal_bounding_box` instead. .. py:property:: optimal_bounding_box :type: 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. .. rubric:: 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 :attr:`~bluemira.geometry.base.BluemiraGeo.bounding_box`. .. py:method:: is_null() -> bool Check if the shape is null. :returns: A boolean for if the shape is null. .. py:method:: is_closed() -> bool Check if the shape is closed. :returns: A boolean for if the shape is closed. .. py:method:: is_valid() -> bool Check if the shape is valid. :returns: A boolean for if the shape is valid. .. py:method:: 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. .. py:method:: search(label: str) -> list[BluemiraGeo] Search for a shape with the specified label :param label: Shape label :rtype: List of shapes that have the specified label .. py:method:: 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). .. py:method:: _tessellate(tolerance: float = 1.0) -> tuple[numpy.ndarray, numpy.ndarray] Tessellate the geometry object. :param tolerance: 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 .. rubric:: Notes Once tesselated, an object's properties may change. Tesselation cannot be reverted to a previous lower value, but can be increased (irreversibly). .. py:method:: 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). .. py:method:: 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. :param base: Origin location of the rotation :param direction: The direction vector :param degree: rotation angle .. rubric:: 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). .. py:method:: 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). .. py:method:: __repr__() -> str .. py:method:: __deepcopy__(memo) Deepcopy for BluemiraGeo. FreeCAD shapes cannot be deepcopied on versions >=0.21 :returns: A deepcopy of the BluemiraGeo. .. py:method:: copy(label: str | None = None) -> BluemiraGeo Make a copy of the BluemiraGeo. :returns: A copy of the BluemiraGeo. .. py:method:: deepcopy(label: str | None = None) -> BluemiraGeo Make a deepcopy of the BluemiraGeo. :returns: A deepcopy of the BluemiraGeo. .. py:property:: vertexes :type: bluemira.geometry.coordinates.Coordinates :abstractmethod: The vertexes of the BluemiraGeo. .. py:property:: edges :type: tuple :abstractmethod: The edges of the BluemiraGeo. .. py:property:: wires :type: tuple :abstractmethod: The wires of the BluemiraGeo. .. py:property:: faces :type: tuple :abstractmethod: The faces of the BluemiraGeo. .. py:property:: shells :type: tuple :abstractmethod: The shells of the BluemiraGeo. .. py:property:: solids :type: tuple :abstractmethod: The solids of the BluemiraGeo.