using Jobberwocky.GeometryAlgorithms.Source.Core; using Jobberwocky.GeometryAlgorithms.Source.Algorithms.Hull2D; using Jobberwocky.GeometryAlgorithms.Source.Algorithms.Hull3D; using Jobberwocky.GeometryAlgorithms.Source.Parameters; using UnityEngine; using System; namespace Jobberwocky.GeometryAlgorithms.Source.API { /// /// Class for the generation of hulls in 2D and 3D /// public class HullAPI : ThreadingAPI { /// /// Creates a 2D hull by using another thread. The callback function is used when the thread is finished. /// /// /// public void Hull2DAsync(Action callback, Hull2DParameters parameters) { StartWorker( (IParameters param, Action callbackResult) => { var hull2DWrapper = new Hull2DWrapper(); var hullGeometry = hull2DWrapper.Hull2D((Hull2DParameters)param); return new ThreadingResult(callbackResult, hullGeometry); }, parameters, callback); } /// /// Creates a 2D hull of the given input points and the concavity or maximal edge length defined in the parameters object. /// /// /// Unity mesh public Mesh Hull2D(Hull2DParameters parameters) { return Hull2DRaw(parameters).ToUnityMesh(); } /// /// Creates a 2D hull of the given input points and the concavity or maximal edge length defined in the parameters object. /// /// /// Geometry public Geometry Hull2DRaw(Hull2DParameters parameters) { var hull2DWrapper = new Hull2DWrapper(); return hull2DWrapper.Hull2D(parameters); } /// /// Creates a 3D convex hull of the given input points /// /// /// Unity mesh public Mesh ConvexHull3D(Hull3DParameters parameters) { return ConvexHull3DRaw(parameters).ToUnityMesh(); } /// /// Creates a 3D convex hull of the given input points /// /// /// HullMesh public Geometry ConvexHull3DRaw(Hull3DParameters parameters) { var hull3DWrapper = new Hull3DWrapper(); return hull3DWrapper.Hull3D(parameters); } /// /// Creates a 3D hull by using another thread. The callback function is used when the thread is finished. /// /// /// /// public void ConvexHull3DAsync(Action callback, Hull3DParameters parameters) { StartWorker( (IParameters param, Action callbackResult) => { var hull3DWrapper = new Hull3DWrapper(); var hullGeometry = hull3DWrapper.Hull3D((Hull3DParameters)param); return new ThreadingResult(callbackResult, hullGeometry); }, parameters, callback); } } }