packages feed

waterfall-cad-examples 0.3.0.1 → 0.4.0.0

raw patch · 4 files changed

+71/−5 lines, 4 filesdep ~opencascade-hsdep ~waterfall-cadPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: opencascade-hs, waterfall-cad

API changes (from Hackage documentation)

+ LoftExample: loftExample :: Solid

Files

CHANGELOG.md view
@@ -8,6 +8,11 @@  ## Unreleased ++## 0.4.0.0++- Add LoftExample+ ## 0.3.0.1  ## 0.3.0.0
app/Main.hs view
@@ -7,6 +7,7 @@ import RevolutionExample (revolutionExample) import SweepExample (sweepExample) import OffsetExample (offsetExample)+import LoftExample (loftExample) import TextExample (textExample) import BoundingBoxExample (boundingBoxExample) import ReadSolidExpressionExample (readSolidExpressionExample)@@ -37,6 +38,7 @@       OA.flag' revolutionExample (OA.long "revolution" <> OA.help "demonstrates revolving a path into a solid" ) <|>       OA.flag' sweepExample (OA.long "sweep" <> OA.help "demonstrates sweeping a shape along a path" ) <|>       OA.flag' offsetExample (OA.long "offset" <> OA.help "demonstrates offsetting the surface of a shape" ) <|>+      OA.flag' loftExample (OA.long "loft" <> OA.help "generating a boat, defined as a loft of a series of paths" ) <|>       OA.flag' boundingBoxExample (OA.long "bound" <> OA.help "demonstrates calculating the oriented bounding box, and axis aligned bounding box, of a shape" ) <|>       (OA.flag' gearExample (OA.long "gear" <> OA.help "generate an involute gear") <*>        (OA.option OA.auto (OA.long "thickness" <> OA.help "gear depth") <|> pure 1.0) <*>
+ src/LoftExample.hs view
@@ -0,0 +1,58 @@+{-|+Module: Waterfall.Loft++-}++module LoftExample +( loftExample+) where++import Linear (V3 (..))+import qualified Waterfall.Transforms as Transforms+import qualified Waterfall.TwoD.Transforms as Transforms2D+import qualified Waterfall.Booleans as Booleans+import qualified Waterfall.Solids as Solids+import qualified Waterfall.Sweep as Sweep+import qualified Waterfall.TwoD.Shape as Shape+import qualified Waterfall.Loft as Loft+import qualified Waterfall.Path.Common as Path++-- | [Loft](https://en.wikipedia.org/wiki/Loft_\(3D\)) is a method to create smooth 3D shapes. +--+-- Analagous to the [lofting](https://en.wikipedia.org/wiki/Lofting) process in boat building. +-- A loft is defined by planar cross-sections of the desired shape at chosen locations. +-- These cross-sections are then interpolated to form a smooth 3d shape.+--+-- This example demonstrates the `Loft` module, by generating a boat, with the profile of the boat specified by a series of bezier curves.+loftExample :: Solids.Solid+loftExample = +    let precision = 1e-6+        paths = +          [ let p x z = V3 x 0 z +              -- the curve at the rear of the boat is tilted _slightly_ back+              in Transforms.rotate (V3 1 0 0) 0.2 $+                  Path.bezier (p 0 0) (p 4 0) (p 5 3) (p 5 4)+          , let p x z = V3 x 2 z +              in  Path.bezier (p 0 0) (p 4 0) (p 5 3) (p 5 4)+          , let p x z = V3 x 5 z +              in  Path.bezier (p 0 0) (p 4 0) (p 5 3) (p 5 4)+          , let p x z = V3 x 10 z+              in Path.bezier (p 1 0) (p 4.5 0) (p 5.25 3) (p 5.25 4.2)+          ]+        mirror = Transforms.mirror (V3 1 0 0 ) . Path.reversePath+        makeSymetric p = mirror p <> p+        symetricPaths = makeSymetric <$> paths+        body = +          Loft.pointedLoft +            precision +            Nothing+            (Path.closeLoop <$>  symetricPaths)+            (Just (V3 0 20 5))+        -- shrink the boat shape slightly, and translate it+        -- use this to hollow out the boat+        cavity = Transforms.translate (V3 0 (0.025 * 20) 0.3) $ Transforms.uScale 0.95 body+        -- sweep a circle along each of the paths, this makes them visible in the generated model+        sweepWithCircle = (`Sweep.sweep` Transforms2D.uScale2D 0.2 Shape.unitCircle)+        splines = mconcat $ sweepWithCircle <$> symetricPaths+      in Transforms.uScale 0.1 $+          (body <> splines) `Booleans.difference` cavity
waterfall-cad-examples.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-examples-version:        0.3.0.1+version:        0.4.0.0 synopsis:       Examples for Waterfall CAD, a Declarative CAD/Solid Modeling Library description:    Please see the README on GitHub at <https://github.com/joe-warren/opencascade-hs#readme> category:       Graphics@@ -32,6 +32,7 @@       CsgExample       FilletExample       GearExample+      LoftExample       OffsetExample       PrismExample       ReadSolidExpressionExample@@ -47,11 +48,11 @@       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.3.0.1 && <0.4+    , opencascade-hs >=0.4.0.0 && <0.5     , optparse-applicative >=0.17 && <0.19     , parsec ==3.1.*     , parser-combinators >=1.2 && <1.4-    , waterfall-cad >=0.3.0.1 && <0.4+    , waterfall-cad >=0.4.0.0 && <0.5   default-language: Haskell2010  executable waterfall-cad-examples@@ -65,10 +66,10 @@       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.3.0.1 && <0.4+    , opencascade-hs >=0.4.0.0 && <0.5     , optparse-applicative >=0.17 && <0.19     , parsec ==3.1.*     , parser-combinators >=1.2 && <1.4-    , waterfall-cad >=0.3.0.1 && <0.4+    , waterfall-cad >=0.4.0.0 && <0.5     , waterfall-cad-examples   default-language: Haskell2010