packages feed

waterfall-cad-examples 0.1.2.2 → 0.2.0.0

raw patch · 5 files changed

+69/−34 lines, 5 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)

+ BoundingBoxExample: boundingBoxExample :: Solid
- TextExample: textExample :: FilePath -> Double -> String -> Double -> Solid
+ TextExample: textExample :: FilePath -> Double -> String -> Double -> IO Solid

Files

CHANGELOG.md view
@@ -8,6 +8,10 @@  ## Unreleased +## 0.2.0.0++- Add an example demonstrating both `Waterfall.BoundingBox.Oriented` and `Waterfall.BoundingBox.AxisAligned`+ ## 0.1.2.2 - 2024-01-09   ### Fixed
app/Main.hs view
@@ -8,10 +8,11 @@ import SweepExample (sweepExample) import OffsetExample (offsetExample) import TextExample (textExample)+import BoundingBoxExample (boundingBoxExample) import Waterfall.IO (writeSTL, writeSTEP) import qualified Waterfall.Solids as Solids import qualified Options.Applicative as OA-import Control.Applicative ((<|>))+import Control.Applicative ((<|>), liftA2) import Control.Monad (join)  outputOption :: OA.Parser (Solids.Solid -> IO ()) @@ -21,33 +22,36 @@         stepOption = writeSTEP <$> OA.strOption (OA.long "step" <> OA.metavar "Stl file to write results to")      in stlOption <|> stepOption -exampleOption :: OA.Parser Solids.Solid-exampleOption = OA.flag' csgExample (OA.long "csg" <> OA.help "example from the wikipedia page on Constructive Solid Geometry" ) <|>-                OA.flag' prismExample (OA.long "prism" <> OA.help "need to give this a better name" ) <|>-                OA.flag' filletExample (OA.long "fillet" <> OA.help "demonstrates adding fillets to an object" ) <|>-                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' gearExample (OA.long "gear" <> OA.help "generate an involute gear") <*>-                 (OA.option OA.auto (OA.long "thickness" <> OA.help "gear depth") <|> pure 1.0) <*>-                 (OA.option OA.auto (OA.long "module" <> OA.help "gear module") <|> pure 5.0) <*>-                 (OA.option OA.auto (OA.long "nGears" <> OA.help "number of gears") <|> pure 20) <*>-                 (OA.option OA.auto (OA.long "pitch" <> OA.help "pitchAngle") -                    <|> ((* (pi/180)) <$> OA.option OA.auto (OA.long "pitchDegrees" <> OA.help "pitch angle in degrees"))-                    <|> pure (20*pi/180)) -                ) <|> -                (OA.flag' textExample (OA.long "text" <> OA.help "render text") <*>-                 (OA.strOption (OA.long "font" <> OA.help "font path")) <*>-                 (OA.option OA.auto (OA.long "size" <> OA.help "font size") <|> pure 12.0) <*>-                 (OA.strOption (OA.long "content" <> OA.help "text to render") <|> pure "Waterfall CAD") <*>-                 (OA.option OA.auto (OA.long "depth" <> OA.help "depth to extrude the text to") <|> pure 10.0) -                )+exampleOption :: OA.Parser (IO Solids.Solid)+exampleOption = +    fmap pure (+      OA.flag' csgExample (OA.long "csg" <> OA.help "example from the wikipedia page on Constructive Solid Geometry" ) <|>+      OA.flag' prismExample (OA.long "prism" <> OA.help "need to give this a better name" ) <|>+      OA.flag' filletExample (OA.long "fillet" <> OA.help "demonstrates adding fillets to an object" ) <|>+      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' 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) <*>+       (OA.option OA.auto (OA.long "module" <> OA.help "gear module") <|> pure 5.0) <*>+       (OA.option OA.auto (OA.long "nGears" <> OA.help "number of gears") <|> pure 20) <*>+       (OA.option OA.auto (OA.long "pitch" <> OA.help "pitchAngle") +          <|> ((* (pi/180)) <$> OA.option OA.auto (OA.long "pitchDegrees" <> OA.help "pitch angle in degrees"))+          <|> pure (20*pi/180)) +      )) <|> +      (OA.flag' textExample (OA.long "text" <> OA.help "render text") <*>+       (OA.strOption (OA.long "font" <> OA.help "font path")) <*>+       (OA.option OA.auto (OA.long "size" <> OA.help "font size") <|> pure 12.0) <*>+       (OA.strOption (OA.long "content" <> OA.help "text to render") <|> pure "Waterfall CAD") <*>+       (OA.option OA.auto (OA.long "depth" <> OA.help "depth to extrude the text to") <|> pure 10.0) +      )   main :: IO () main = join (OA.execParser opts)     where-        opts = OA.info ((outputOption <*> exampleOption) OA.<**> OA.helper) +        opts = OA.info ((liftA2 (=<<) outputOption  exampleOption) OA.<**> OA.helper)              (OA.fullDesc              <> OA.progDesc "generate and write a 3D model"              <> OA.header "examples for Waterfall-CAD")
+ src/BoundingBoxExample.hs view
@@ -0,0 +1,26 @@+module BoundingBoxExample+(boundingBoxExample+) where++import Data.Function ((&))+import qualified Waterfall.Solids as Solids+import qualified Waterfall.BoundingBox.Oriented as OBB+import qualified Waterfall.BoundingBox.AxisAligned as AABB+import qualified Waterfall.Transforms as Transforms+import Linear (V3 (..), unit, _y, _z, (^*))++boundingBoxExample :: Solids.Solid+boundingBoxExample = +    let shape = Solids.unitSphere &+            Transforms.scale (V3 0.5 3 5) &+            Transforms.rotate (unit _z) 1 &+            Transforms.rotate (unit _y) 0.5+        obb = OBB.orientedBoundingBox shape &+            maybe Solids.nowhere OBB.obbToSolid+        aabb = AABB.axisAlignedBoundingBox shape &+            maybe Solids.nowhere AABB.aabbToSolid+        in mconcat +            [ Transforms.translate (unit _y ^* (-5)) shape+            , obb+            , Transforms.translate (unit _y ^* 5) aabb+            ]   
src/TextExample.hs view
@@ -4,7 +4,7 @@  import qualified Waterfall -textExample :: FilePath -> Double -> String -> Double -> Waterfall.Solid-textExample fontpath fontSize content depth = -    let font = Waterfall.fontFromPath fontpath fontSize-    in Waterfall.prism depth $ Waterfall.text font content+textExample :: FilePath -> Double -> String -> Double -> IO Waterfall.Solid+textExample fontpath fontSize content depth = do+    font <- Waterfall.fontFromPath fontpath fontSize+    return . Waterfall.prism depth $ Waterfall.text font content
waterfall-cad-examples.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-examples-version:        0.1.2.2+version:        0.2.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@@ -28,6 +28,7 @@  library   exposed-modules:+      BoundingBoxExample       CsgExample       FilletExample       GearExample@@ -40,14 +41,14 @@       Paths_waterfall_cad_examples   hs-source-dirs:       src-  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+  ghc-options: -Wall -Werror=compat -Werror=identities -Werror=incomplete-record-updates -Werror=incomplete-uni-patterns -Werror=missing-home-modules -Werror=missing-export-lists -Werror=partial-fields -Werror=redundant-constraints -optc -Werror-implicit-function-declaration   build-depends:       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.1.2.2 && <0.2+    , opencascade-hs >=0.2.0.0 && <0.3     , optparse-applicative >=0.17 && <0.19-    , waterfall-cad >=0.1.2.2 && <0.2+    , waterfall-cad >=0.2.0.0 && <0.3   default-language: Haskell2010  executable waterfall-cad-examples@@ -56,13 +57,13 @@       Paths_waterfall_cad_examples   hs-source-dirs:       app-  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+  ghc-options: -Wall -Werror=compat -Werror=identities -Werror=incomplete-record-updates -Werror=incomplete-uni-patterns -Werror=missing-home-modules -Werror=missing-export-lists -Werror=partial-fields -Werror=redundant-constraints -optc -Werror-implicit-function-declaration -threaded -rtsopts -with-rtsopts=-N   build-depends:       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.1.2.2 && <0.2+    , opencascade-hs >=0.2.0.0 && <0.3     , optparse-applicative >=0.17 && <0.19-    , waterfall-cad >=0.1.2.2 && <0.2+    , waterfall-cad >=0.2.0.0 && <0.3     , waterfall-cad-examples   default-language: Haskell2010