module Waterfall.Sweep
( sweep
) where

import Waterfall.Internal.Solid (Solid (..))
import Waterfall.Internal.Path (Path (..))
import Waterfall.TwoD.Internal.Shape (Shape (..))
import qualified OpenCascade.BRepOffsetAPI.MakePipe as MakePipe
import qualified OpenCascade.BRepBuilderAPI.MakeShape as MakeShape
import OpenCascade.Inheritance (upcast)

-- | Sweep a 2D `Shape` along a `Path`, constructing a `Solid`
-- 
-- I may still need to make some tweaks to the alignment of the `Shape` and the `Path`.
-- This will likely impact the shapes that are generated when the start point of the `Path` 
-- is not parallel to the z axis.
sweep :: Path -> Shape -> Solid
sweep :: Path -> Shape -> Solid
sweep (Path Acquire (Ptr Wire)
runThePath) (Shape Acquire (Ptr Shape)
runTheShape) = Acquire (Ptr Shape) -> Solid
Solid (Acquire (Ptr Shape) -> Solid) -> Acquire (Ptr Shape) -> Solid
forall a b. (a -> b) -> a -> b
$ do
    Ptr Wire
path <- Acquire (Ptr Wire)
runThePath
    Ptr Shape
shape <- Acquire (Ptr Shape)
runTheShape
    Ptr MakePipe
builder <- Ptr Wire -> Ptr Shape -> Acquire (Ptr MakePipe)
MakePipe.fromWireAndShape Ptr Wire
path Ptr Shape
shape
    Ptr MakeShape -> Acquire (Ptr Shape)
MakeShape.shape (Ptr MakePipe -> Ptr MakeShape
forall a b. SubTypeOf a b => Ptr b -> Ptr a
upcast Ptr MakePipe
builder)