objc2-model-io 0.3.2

Bindings to the ModelIO 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!(
    /// Voxel data represented on a three dimensional grid. Voxel data can
    /// include voxels considered to be on the surface of an object, and a
    /// series of shells on the outside and inside of the surface.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvoxelarray?language=objc)
    #[unsafe(super(MDLObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MDLObject")]
    pub struct MDLVoxelArray;
);

#[cfg(all(feature = "MDLObject", feature = "MDLTypes"))]
extern_conformance!(
    unsafe impl MDLNamed for MDLVoxelArray {}
);

#[cfg(feature = "MDLObject")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MDLVoxelArray {}
);

#[cfg(feature = "MDLObject")]
impl MDLVoxelArray {
    extern_methods!(
        #[cfg(feature = "MDLAsset")]
        /// Initialize a voxel grid from an MDLAsset. Attempts to create a closed volume
        /// model by applying "patches" of radius patchRadius to any holes found in the
        /// orginal mesh. Choose a patch radius that will be large enough to fill in the largest
        /// hole in the model.
        #[unsafe(method(initWithAsset:divisions:patchRadius:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset_divisions_patchRadius(
            this: Allocated<Self>,
            asset: &MDLAsset,
            divisions: c_int,
            patch_radius: c_float,
        ) -> Retained<Self>;

        #[cfg(feature = "MDLAsset")]
        /// Initialize a voxel grid from an MDLAsset and dilate the resulting voxels by
        /// a number of interior and exterior shells.
        /// Routine will attempt to create a closed volume model by applying patches of
        /// a given radius to any holes it may find in the asset.
        ///
        ///
        /// Parameter `divisions`: The number of divisions to divide the vertical extent of the
        /// model by.
        ///
        /// Parameter `interiorShells`: The number of shells to compute inside the surface shell
        ///
        /// Parameter `exteriorShells`: The number of shells to compute outside the surface shell
        ///
        /// Parameter `patchRadius`: The radius of the largest model mending patch in world space units
        #[deprecated]
        #[unsafe(method(initWithAsset:divisions:interiorShells:exteriorShells:patchRadius:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset_divisions_interiorShells_exteriorShells_patchRadius(
            this: Allocated<Self>,
            asset: &MDLAsset,
            divisions: c_int,
            interior_shells: c_int,
            exterior_shells: c_int,
            patch_radius: c_float,
        ) -> Retained<Self>;

        #[cfg(feature = "MDLAsset")]
        /// Initialize a voxel grid from an MDLAsset and dilate the resulting voxels by
        /// a spatial distance in the interior and exterior directions.
        /// Routine will attempt to create a closed volume model by applying "patches" of
        /// a given radius to any holes it may find in the asset.
        ///
        ///
        /// Parameter `divisions`: The number of divisions to divide the vertical extent of the
        /// model by.
        ///
        /// Parameter `interiorNBWidth`: The interior narrow band width in world space units
        ///
        /// Parameter `exteriorNBWidth`: The exterior narrow band width in world space units
        ///
        /// Parameter `patchRadius`: The radius of the largest model mending patch in world space units
        #[deprecated]
        #[unsafe(method(initWithAsset:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset_divisions_interiorNBWidth_exteriorNBWidth_patchRadius(
            this: Allocated<Self>,
            asset: &MDLAsset,
            divisions: c_int,
            interior_nb_width: c_float,
            exterior_nb_width: c_float,
            patch_radius: c_float,
        ) -> Retained<Self>;

        /// The number of voxels in the grid
        #[unsafe(method(count))]
        #[unsafe(method_family = none)]
        pub unsafe fn count(&self) -> NSUInteger;

        /// Returns an NSData containing the indices of all voxels in the voxel grid
        #[unsafe(method(voxelIndices))]
        #[unsafe(method_family = none)]
        pub unsafe fn voxelIndices(&self) -> Option<Retained<NSData>>;

        #[cfg(feature = "MDLMesh")]
        /// Set voxels corresponding to a mesh.
        /// Routine will attempt to create a closed volume model by applying "patches" of
        /// a given radius to any holes it may find in the mesh.
        #[unsafe(method(setVoxelsForMesh:divisions:patchRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVoxelsForMesh_divisions_patchRadius(
            &self,
            mesh: &MDLMesh,
            divisions: c_int,
            patch_radius: c_float,
        );

        #[cfg(feature = "MDLMesh")]
        /// Set voxels corresponding to a mesh
        /// Routine will attempt to create a closed volume model by applying "patches" of
        /// a given radius to any holes it may find in the mesh.
        ///
        ///
        /// Parameter `divisions`: The number of divisions to divide the vertical extent of the
        /// model by.
        ///
        /// Parameter `interiorShells`: The number of shells to compute inside the surface shell
        ///
        /// Parameter `exteriorShells`: The number of shells to compute outside the surface shell
        ///
        /// Parameter `patchRadius`: The radius of the largest model mending patch in world space units
        #[deprecated]
        #[unsafe(method(setVoxelsForMesh:divisions:interiorShells:exteriorShells:patchRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVoxelsForMesh_divisions_interiorShells_exteriorShells_patchRadius(
            &self,
            mesh: &MDLMesh,
            divisions: c_int,
            interior_shells: c_int,
            exterior_shells: c_int,
            patch_radius: c_float,
        );

        #[cfg(feature = "MDLMesh")]
        /// Set voxels corresponding to a mesh
        /// Routine will attempt to create a closed volume model by applying "patches" of
        /// a given radius to any holes it may find in the mesh.
        ///
        ///
        /// Parameter `divisions`: The number of divisions to divide the vertical extent of the
        /// model by.
        ///
        /// Parameter `interiorNBWidth`: The interior narrow band width in world space units
        ///
        /// Parameter `exteriorNBWidth`: The exterior narrow band width in world space units
        ///
        /// Parameter `patchRadius`: The radius of the largest model mending patch in world space units
        #[deprecated]
        #[unsafe(method(setVoxelsForMesh:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVoxelsForMesh_divisions_interiorNBWidth_exteriorNBWidth_patchRadius(
            &self,
            mesh: &MDLMesh,
            divisions: c_int,
            interior_nb_width: c_float,
            exterior_nb_width: c_float,
            patch_radius: c_float,
        );

        /// Union modifies the voxel grid to be the merger with the supplied voxel grid.
        /// It is assumed that the spatial voxel extent of one voxel in the supplied grid is the same as that of the voxel grid.
        /// Note that the shell level data will be cleared.
        #[unsafe(method(unionWithVoxels:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unionWithVoxels(&self, voxels: &MDLVoxelArray);

        /// Intersection modifies the voxel grid so that only voxels that are also in the supplied voxel grid are retained.
        /// It is assumed that the spatial voxel extent of one voxel in the supplied grid is the same as that of the voxel grid.
        /// Note that the shell level data will be cleared.
        #[unsafe(method(intersectWithVoxels:))]
        #[unsafe(method_family = none)]
        pub unsafe fn intersectWithVoxels(&self, voxels: &MDLVoxelArray);

        /// Difference modifies the voxel grid so that voxels also in the supplied voxel grid are removed.
        /// It is assumed that the spatial voxel extent of one voxel in the supplied grid is the same as that of the voxel grid.
        /// Note that the shell level data will be cleared.
        #[unsafe(method(differenceWithVoxels:))]
        #[unsafe(method_family = none)]
        pub unsafe fn differenceWithVoxels(&self, voxels: &MDLVoxelArray);

        /// Converts volume grid into a signed shell field by surrounding the surface voxels, which have shell
        /// level values of zero, by an inner layer of voxels with shell level values of negative one and an
        /// outer layer of voxels with shell level values of positive one.
        ///
        /// The volume model must be closed in order to generate a signed shell field.
        #[unsafe(method(convertToSignedShellField))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertToSignedShellField(&self);

        /// Returns whether or not the volume grid is in a valid signed shell field form.
        ///
        /// This property will be set to YES after calling generateSignedShellField. All other
        /// methods that modify the voxel grid will cause this property to be set to NO. Setting
        /// shellFieldInteriorThickness and shellFieldExteriorThickness will not affect the value
        /// of this property.
        #[unsafe(method(isValidSignedShellField))]
        #[unsafe(method_family = none)]
        pub unsafe fn isValidSignedShellField(&self) -> bool;

        /// If voxel grid is in a valid signed shell field form, sets the interior thickness to the desired width,
        /// as measured from the model surface. If the voxel grid is not in a valid signed shell field form, the
        /// value of this property is zero.
        #[unsafe(method(shellFieldInteriorThickness))]
        #[unsafe(method_family = none)]
        pub unsafe fn shellFieldInteriorThickness(&self) -> c_float;

        /// Setter for [`shellFieldInteriorThickness`][Self::shellFieldInteriorThickness].
        #[unsafe(method(setShellFieldInteriorThickness:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShellFieldInteriorThickness(
            &self,
            shell_field_interior_thickness: c_float,
        );

        /// If voxel grid is in a valid signed shell field form, sets the exterior thickness to the desired width,
        /// as measured from the model surface. If the voxel grid is not in a valid signed shell field form, the
        /// value of this property is zero.
        #[unsafe(method(shellFieldExteriorThickness))]
        #[unsafe(method_family = none)]
        pub unsafe fn shellFieldExteriorThickness(&self) -> c_float;

        /// Setter for [`shellFieldExteriorThickness`][Self::shellFieldExteriorThickness].
        #[unsafe(method(setShellFieldExteriorThickness:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShellFieldExteriorThickness(
            &self,
            shell_field_exterior_thickness: c_float,
        );

        #[cfg(feature = "MDLMesh")]
        /// Creates a coarse mesh from the voxel grid
        #[unsafe(method(coarseMesh))]
        #[unsafe(method_family = none)]
        pub unsafe fn coarseMesh(&self) -> Option<Retained<MDLMesh>>;

        #[cfg(all(feature = "MDLMesh", feature = "MDLMeshBuffer"))]
        #[unsafe(method(coarseMeshUsingAllocator:))]
        #[unsafe(method_family = none)]
        pub unsafe fn coarseMeshUsingAllocator(
            &self,
            allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
        ) -> Option<Retained<MDLMesh>>;

        #[cfg(all(feature = "MDLMesh", feature = "MDLMeshBuffer"))]
        /// Creates a smooth mesh from the voxel grid
        #[unsafe(method(meshUsingAllocator:))]
        #[unsafe(method_family = none)]
        pub unsafe fn meshUsingAllocator(
            &self,
            allocator: Option<&ProtocolObject<dyn MDLMeshBufferAllocator>>,
        ) -> Option<Retained<MDLMesh>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "MDLObject")]
impl MDLVoxelArray {
    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>;
    );
}