objc2-vision 0.3.2

Bindings to the Vision framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/vision/vngeometryutils?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNGeometryUtils;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for VNGeometryUtils {}
);

impl VNGeometryUtils {
    extern_methods!(
        #[cfg(feature = "VNGeometry")]
        /// Calculates a bounding circle that includes a collection of points or a VNContour object. Note that because this is based on a geometric shape the aspect ratio is important when using normalized points.
        /// This takes the aspect ratio of the contour into account when using a VNContour as an input.
        /// boundingCircleForPoints and boundingCircleForSIMDPoints assume that the aspect ratio is correctly applied to the points.
        ///
        ///
        /// Parameter `contour`: A contour around which to find the bounding circle.
        ///
        ///
        /// Parameter `points`: A collection of points around which to find the bounding circle.
        ///
        ///
        /// Parameter `pointCount`: Number of points in points
        ///
        ///
        /// Parameter `contour`: VNContour object whose bounding circle needs to be calculated
        ///
        ///
        /// Parameter `error`: An output parameter, populated only in case of algorithmic failure
        ///
        ///
        /// Returns: the VNCircle object describing the bounding circle or nil, if the algorithm failed. The latter case is accompanied by populating an 'error' output parameter
        #[unsafe(method(boundingCircleForContour:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn boundingCircleForContour_error(
            contour: &VNContour,
        ) -> Result<Retained<VNCircle>, Retained<NSError>>;

        #[cfg(feature = "VNGeometry")]
        #[unsafe(method(boundingCircleForPoints:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn boundingCircleForPoints_error(
            points: &NSArray<VNPoint>,
        ) -> Result<Retained<VNCircle>, Retained<NSError>>;

        #[cfg(feature = "VNGeometry")]
        /// Calculates a closed contour area using Green's theorem. The contour is represented by a set of points in VNContour object,
        /// It's important to note that a random set of points, or a contour with self-crossing edges will likely produce undefined results
        /// Note that because this is based on a geometric shape the aspect ratio is important when using normalized points.
        /// This takes the aspect ratio of the contour into account when using a VNContour as an input.
        ///
        ///
        /// Parameter `area`: Output parameter to be populated with calculated contour area
        ///
        ///
        /// Parameter `contour`: A VNContour object whose area is being calculated
        ///
        ///
        /// Parameter `orientedArea`: If true, returns signed area - positive for CCW oriented contours and negative for CW oriented contours.
        /// If false, returned area is always positive.
        ///
        ///
        /// Parameter `error`: An output parameter, populated only in case of algorithmic failure
        ///
        ///
        /// Returns: Area calculation status, YES indicates success, NO - failure. The failure case is accompanied by populating an 'error' output parameter
        ///
        /// # Safety
        ///
        /// `area` must be a valid pointer.
        #[unsafe(method(calculateArea:forContour:orientedArea:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn calculateArea_forContour_orientedArea_error(
            area: NonNull<c_double>,
            contour: &VNContour,
            oriented_area: bool,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "VNGeometry")]
        /// Calculates perimeter, or a sum of all arc-lengths (edges), of a closed contour. The contour is represented by a set of points in VNContour object.
        /// Note that because this is based on a geometric shape the aspect ratio is important when using normalized points.
        /// This takes the aspect ratio of the contour into account when using a VNContour as an input.
        ///
        ///
        /// Parameter `perimeter`: Output parameter to be populated with calculated contour perimeter
        ///
        ///
        /// Parameter `contour`: A VNContour object whose perimeter is being calculated
        ///
        ///
        /// Parameter `error`: An output parameter, populated only in case of algorithmic failure
        ///
        ///
        /// Returns: Perimeter calculation status, YES indicates success, NO - failure. The failure case is accompanied by populating an 'error' output parameter
        ///
        /// # Safety
        ///
        /// `perimeter` must be a valid pointer.
        #[unsafe(method(calculatePerimeter:forContour:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn calculatePerimeter_forContour_error(
            perimeter: NonNull<c_double>,
            contour: &VNContour,
        ) -> Result<(), Retained<NSError>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl VNGeometryUtils {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}