packages feed

waterfall-cad 0.5.0.1 → 0.5.1.0

raw patch · 4 files changed

+50/−3 lines, 4 filesdep ~opencascade-hsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: opencascade-hs

API changes (from Hackage documentation)

+ Waterfall.Booleans: intersections :: [Solid] -> Solid
+ Waterfall.Booleans: unions :: [Solid] -> Solid
+ Waterfall.Internal.Solid: intersections :: [Solid] -> Solid
+ Waterfall.Internal.Solid: unions :: [Solid] -> Solid

Files

CHANGELOG.md view
@@ -9,6 +9,12 @@  ## Unreleased +## 0.5.1.0++### Added++- Added `unions`, `intersections`, and specialized mconcat for `Solid` to improve performance+ ## 0.5.0.1  ### Fixed
src/Waterfall/Booleans.hs view
@@ -6,6 +6,8 @@ , difference , intersection , complement+, unions+, intersections ) where -import Waterfall.Internal.Solid(union, difference, intersection, complement)+import Waterfall.Internal.Solid(union, unions, difference, intersection, intersections, complement)
src/Waterfall/Internal/Solid.hs view
@@ -7,6 +7,8 @@ , union , difference , intersection+, unions+, intersections , nowhere , complement , debug@@ -22,8 +24,13 @@ import qualified OpenCascade.BRepAlgoAPI.Cut as Cut import qualified OpenCascade.BRepAlgoAPI.Common as Common import qualified OpenCascade.BRepBuilderAPI.MakeSolid as MakeSolid+import qualified OpenCascade.BOPAlgo.Operation as BOPAlgo.Operation+import qualified OpenCascade.BOPAlgo.BOP as BOPAlgo.BOP+import qualified OpenCascade.BOPAlgo.Builder as BOPAlgo.Builder import OpenCascade.Inheritance (upcast) import Waterfall.Internal.Finalizers (toAcquire, unsafeFromAcquire)+import qualified OpenCascade.BOPAlgo.Builder as BOPAlgo+import Data.Foldable (traverse_)  -- | The Boundary Representation of a solid object. --@@ -43,6 +50,7 @@ solidFromAcquire :: Acquire (Ptr TopoDS.Shape.Shape) -> Solid solidFromAcquire = Solid . unsafeFromAcquire + -- | print debug information about a Solid when it's evaluated  -- exposes the properties of the underlying OpenCacade.TopoDS.Shape debug :: Solid -> String@@ -105,6 +113,29 @@ union :: Solid -> Solid -> Solid union = toBoolean Fuse.fuse ++toBooleans :: BOPAlgo.Operation.Operation -> [Solid] -> Solid+toBooleans _ [] = nowhere+toBooleans _ [x] = x+toBooleans op (h:solids) = Solid . unsafeFromAcquire $ do+    firstPtr <- toAcquire . rawSolid $ h+    ptrs <- traverse (toAcquire . rawSolid) solids+    bop <- BOPAlgo.BOP.new+    let builder = upcast bop+    liftIO $ do+        BOPAlgo.BOP.setOperation bop op+        BOPAlgo.Builder.addArgument builder firstPtr+        traverse_ (BOPAlgo.BOP.addTool bop) ptrs+        BOPAlgo.setRunParallel builder True+        BOPAlgo.Builder.perform builder+    BOPAlgo.Builder.shape builder++-- | Take the sum of a list of solids +-- +-- May be more performant than chaining multiple applications of `union`+unions :: [Solid] -> Solid+unions = toBooleans BOPAlgo.Operation.Fuse+ -- | Take the difference of two solids --  -- The region occupied by the first, but not the second.@@ -117,6 +148,13 @@ intersection :: Solid -> Solid -> Solid intersection = toBoolean Common.common ++-- | Take the intersection of a list of solids +-- +-- May be more performant than chaining multiple applications of `intersection`+intersections :: [Solid] -> Solid+intersections = toBooleans BOPAlgo.Operation.Common+ -- | While `Solid` could form a Semigroup via either `union` or `intersection`. -- the default Semigroup is from `union`. --@@ -127,6 +165,7 @@  instance Monoid Solid where     mempty = nowhere+    mconcat = unions  instance Lattice Solid where      (/\) = intersection
waterfall-cad.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-version:        0.5.0.1+version:        0.5.1.0 synopsis:       Declarative CAD/Solid Modeling Library description:    Please see the README on GitHub at <https://github.com/joe-warren/opencascade-hs#readme> category:       Graphics@@ -70,7 +70,7 @@     , lattices >=2.0 && <3     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.5.0.1 && <0.6+    , opencascade-hs >=0.5.1.0 && <0.6     , primitive >=0.7 && <0.10     , resourcet >=1.2 && <1.4   default-language: Haskell2010