fabex.utilities.silhouette_utils
================================

.. py:module:: fabex.utilities.silhouette_utils


Functions
---------

.. autoapisummary::

   fabex.utilities.silhouette_utils.silhouette_offset
   fabex.utilities.silhouette_utils.get_object_silhouette
   fabex.utilities.silhouette_utils.ensure_multipolygon
   fabex.utilities.silhouette_utils.get_operation_silhouette
   fabex.utilities.silhouette_utils.get_object_outline


Module Contents
---------------

.. py:function:: silhouette_offset(context, offset, style=1, mitrelimit=1.0)

   Offset the silhouette of a curve or font object in Blender.

   This function takes an active curve or font object in Blender and
   creates an offset silhouette based on the specified parameters. It first
   retrieves the silhouette of the object and then applies a buffer
   operation to create the offset shape. The resulting shape is then
   converted back into a curve object in the Blender scene.

   :param context: The current Blender context.
   :type context: bpy.context
   :param offset: The distance to offset the silhouette.
   :type offset: float
   :param style: The join style for the offset. Defaults to 1.
   :type style: int?
   :param mitrelimit: The mitre limit for the offset. Defaults to 1.0.
   :type mitrelimit: float?

   :returns: A dictionary indicating the operation is finished.
   :rtype: dict


.. py:function:: get_object_silhouette(stype, objects=None, use_modifiers=False)

   Get the silhouette of objects based on the specified type.

   This function computes the silhouette of a given set of objects in
   Blender based on the specified type. It can handle both curves and mesh
   objects, converting curves to polygon format and calculating the
   silhouette for mesh objects. The function also considers the use of
   modifiers if specified. The silhouette is generated by processing the
   geometry of the objects and returning a Shapely representation of the
   silhouette.

   :param stype: The type of silhouette to generate ('CURVES' or 'OBJECTS').
   :type stype: str
   :param objects: A list of Blender objects to process. Defaults to None.
   :type objects: list?
   :param use_modifiers: Whether to apply modifiers to the objects. Defaults to False.
   :type use_modifiers: bool?

   :returns: The computed silhouette as a Shapely MultiPolygon.
   :rtype: shapely.geometry.MultiPolygon


.. py:function:: ensure_multipolygon(geom)

   Ensures a geometry is a MultiPolygon, even if it is a single Polygon.


.. py:function:: get_operation_silhouette(operation)

   Gets the silhouette for the given operation.

   This function determines the silhouette of an operation using image
   thresholding techniques. It handles different geometry sources, such as
   objects or images, and applies specific methods based on the type of
   geometry. If the geometry source is 'OBJECT' or 'COLLECTION', it checks
   whether to process curves or not. The function also considers the number
   of faces in mesh objects to decide on the appropriate method for
   silhouette extraction.

   :param operation: An object containing the necessary data
   :type operation: Operation

   :returns: The computed silhouette for the operation.
   :rtype: Silhouette


.. py:function:: get_object_outline(radius, o, Offset)

   Get the outline of a geometric object based on specified parameters.

   This function generates an outline for a given geometric object by
   applying a buffer operation to its polygons. The buffer radius can be
   adjusted based on the `radius` parameter, and the operation can be
   offset based on the `Offset` flag. The function also considers whether
   the polygons should be merged or not, depending on the properties of the
   object `o`.

   :param radius: The radius for the buffer operation.
   :type radius: float
   :param o: An object containing properties that influence the outline generation.
   :type o: object
   :param Offset: A flag indicating whether to apply a positive or negative offset.
   :type Offset: bool

   :returns: The resulting outline of the geometric object as a MultiPolygon.
   :rtype: MultiPolygon


