packages feed

waterfall-cad-examples 0.5.1.1 → 0.6.0.0

raw patch · 7 files changed

+74/−22 lines, 7 filesdep ~opencascade-hsdep ~waterfall-caddep ~waterfall-cad-svgPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: opencascade-hs, waterfall-cad, waterfall-cad-svg

API changes (from Hackage documentation)

+ TwoDBooleansExample: twoDBooleansExample :: Solid

Files

CHANGELOG.md view
@@ -8,6 +8,13 @@  ## Unreleased +## 0.6.0.0++### Added++- Added `TwoDBooleansExample` demonstrating 2D boolean operations+- Added Chamfers to `FilletExample`+ ## 0.5.1.1  - Add 3D models to Haddocks
app/Main.hs view
@@ -12,6 +12,7 @@ import TextExample (textExample) import BoundingBoxExample (boundingBoxExample) import ReadSolidExpressionExample (readSolidExpressionExample)+import TwoDBooleansExample (twoDBooleansExample) import SVG.PathExample (pathExample) import SVG.ReadFileExample (readFileExample) import Waterfall.SVG (writeDiagramSVG)@@ -74,6 +75,7 @@       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' twoDBooleansExample (OA.long "2d-booleans" <> OA.help "demonstrates 2D boolean operations (union, intersection, difference) on shapes" ) <|>       (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) <*>
src/BoundingBoxExample.hs view
@@ -19,9 +19,9 @@             Transforms.rotate (unit _z) 1 &             Transforms.rotate (unit _y) 0.5         obb = OBB.orientedBoundingBox shape &-            maybe Solids.nowhere OBB.obbToSolid+            maybe Solids.emptySolid OBB.obbToSolid         aabb = AABB.axisAlignedBoundingBox shape &-            maybe Solids.nowhere AABB.aabbToSolid+            maybe Solids.emptySolid AABB.aabbToSolid         in mconcat              [ Transforms.translate (unit _y ^* (-5)) shape             , obb
src/FilletExample.hs view
@@ -7,21 +7,43 @@  import Waterfall.Solids( Solid, centeredCube ) import Waterfall.Transforms (translate)-import Waterfall.Fillet(roundFillet, roundConditionalFillet, roundIndexedConditionalFillet)+import Waterfall.Fillet+    ( roundFillet+    , roundConditionalFillet+    , roundIndexedConditionalFillet+    , chamfer+    , conditionalChamfer+    , indexedConditionalChamfer+    ) import Control.Lens ((^.)) import Linear (V3 (..), _z) import Control.Monad (guard)  filletExample :: Solid filletExample =-    mconcat $ zipWith-        (\i -> translate (V3 i 0 0 ))-        [0, 2 ..]-        -- round every edge-        [ roundFillet 0.1 centeredCube-        -- round horizontal edges -        , roundConditionalFillet (\(s, e) -> if s ^. _z == e ^._z then Nothing else Just 0.1) centeredCube-        -- round edges with odd indices by a variable radius depending on the edge index-        , roundIndexedConditionalFillet (\i _ -> (fromIntegral i * 0.04) <$ guard (odd i)) centeredCube-        ]-+    let gridLayout = +            mconcat .+            zipWith +                (\i -> translate (V3 i 0 0 ))+                [0, 2 ..]+                . fmap (+                    mconcat .+                    zipWith+                        (\i -> translate (V3 0 i 0 ))+                        [0, 2 ..]+            )+    in gridLayout +         -- round every edge+        [[ roundFillet 0.1 centeredCube+            -- round horizontal edges +         , roundConditionalFillet (\(s, e) -> if s ^. _z == e ^._z then Nothing else Just 0.1) centeredCube+         -- round edges with odd indices by a variable radius depending on the edge index+         , roundIndexedConditionalFillet (\i _ -> (fromIntegral i * 0.04) <$ guard (odd i)) centeredCube+        ], +        -- chamfer every edge+        [ chamfer 0.1 centeredCube+         -- chamfer horizontal edges +         , conditionalChamfer (\(s, e) -> if s ^. _z == e ^._z then Nothing else Just 0.1) centeredCube+         -- chamfer edges with odd indices by a variable amount depending on the edge index+         , indexedConditionalChamfer (\i _ -> (fromIntegral i * 0.04) <$ guard (odd i)) centeredCube+        ]]
src/SVG/ReadFileExample.hs view
@@ -13,5 +13,5 @@ readFileExample filepath =     let expandVertically = Transforms.translate (V3 0 0 (-0.5)) . Transforms.scale (V3 1 1 2)         xor a b = (a `Booleans.difference` expandVertically b) <> (b `Booleans.difference` expandVertically a)-        solidify = foldr xor Solids.nowhere . fmap (Solids.prism 1 . Shape.makeShape)+        solidify = foldr xor Solids.emptySolid . fmap (Solids.prism 1 . Shape.makeShape)     in either (error . show) solidify <$> Waterfall.SVG.readSVG filepath
+ src/TwoDBooleansExample.hs view
@@ -0,0 +1,20 @@+{-|+<<models/2d-booleans.glb>>+-}+module TwoDBooleansExample +( twoDBooleansExample+) where++import qualified Waterfall.TwoD.Shape as Shape+import qualified Waterfall.Booleans as Booleans+import Waterfall.TwoD.Transforms (translate2D)+import Waterfall.Solids (prism, Solid)+import Linear (V2 (..))++twoDBooleansExample :: Solid+twoDBooleansExample = +    let offsetSquare = translate2D (V2 0.5 0.5) Shape.centeredSquare+        complexShape = Booleans.difference +            (Booleans.union Shape.unitCircle offsetSquare)+            (Booleans.intersection Shape.unitCircle offsetSquare)+    in prism 0.2 complexShape
waterfall-cad-examples.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-examples-version:        0.5.1.1+version:        0.6.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@@ -42,6 +42,7 @@       SVG.ReadFileExample       SweepExample       TextExample+      TwoDBooleansExample   other-modules:       Paths_waterfall_cad_examples   hs-source-dirs:@@ -51,14 +52,14 @@       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.5.1.1 && <0.6+    , opencascade-hs >=0.6.0.0 && <0.7     , optparse-applicative >=0.17 && <0.19     , parsec ==3.1.*     , parser-combinators >=1.2 && <1.4     , raw-strings-qq >=1.1 && <2     , svg-tree >=0.6 && <1.0-    , waterfall-cad >=0.5.1.1 && <0.6-    , waterfall-cad-svg >=0.5.1.1 && <0.6+    , waterfall-cad >=0.6.0.0 && <0.7+    , waterfall-cad-svg >=0.6.0.0 && <0.7     , xml ==1.*   default-language: Haskell2010 @@ -73,14 +74,14 @@       base >=4.7 && <5     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.5.1.1 && <0.6+    , opencascade-hs >=0.6.0.0 && <0.7     , optparse-applicative >=0.17 && <0.19     , parsec ==3.1.*     , parser-combinators >=1.2 && <1.4     , raw-strings-qq >=1.1 && <2     , svg-tree >=0.6 && <1.0-    , waterfall-cad >=0.5.1.1 && <0.6+    , waterfall-cad >=0.6.0.0 && <0.7     , waterfall-cad-examples-    , waterfall-cad-svg >=0.5.1.1 && <0.6+    , waterfall-cad-svg >=0.6.0.0 && <0.7     , xml ==1.*   default-language: Haskell2010