packages feed

waterfall-cad 0.2.0.0 → 0.2.1.0

raw patch · 3 files changed

+43/−2 lines, 3 filesdep ~opencascade-hsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: opencascade-hs

API changes (from Hackage documentation)

+ Waterfall.IO: writeGLB :: Double -> FilePath -> Solid -> IO ()
+ Waterfall.IO: writeGLTF :: Double -> FilePath -> Solid -> IO ()

Files

CHANGELOG.md view
@@ -9,6 +9,12 @@  ## Unreleased +## 0.2.1.0++### Added++- graphicsLibraryTransmissionFormat support: `writeGLTF` and `writeGLB` in `Waterfall.IO`+ ## 0.2.0.0  ### Added 
src/Waterfall/IO.hs view
@@ -1,6 +1,8 @@ module Waterfall.IO (  writeSTL , writeSTEP+, writeGLTF+, writeGLB ) where   import Waterfall.Internal.Solid (Solid(..))@@ -8,6 +10,12 @@ import qualified OpenCascade.StlAPI.Writer as StlWriter import qualified OpenCascade.STEPControl.Writer as StepWriter import qualified OpenCascade.STEPControl.StepModelType as StepModelType+import qualified OpenCascade.TDocStd.Document as TDocStd.Document+import qualified OpenCascade.Message.ProgressRange as Message.ProgressRange+import qualified OpenCascade.TColStd.IndexedDataMapOfStringString as TColStd.IndexedDataMapOfStringString+import qualified OpenCascade.RWGltf.CafWriter as RWGltf.CafWriter+import qualified OpenCascade.XCAFDoc.DocumentTool as XCafDoc.DocumentTool+import qualified OpenCascade.XCAFDoc.ShapeTool as XCafDoc.ShapeTool import Control.Monad.IO.Class (liftIO) import Control.Monad (void, unless) import System.IO (hPutStrLn, stderr)@@ -43,3 +51,30 @@     _ <- liftIO $ StepWriter.transfer writer s StepModelType.Asls True     void . liftIO $ StepWriter.write writer filepath +writeGLTFOrGLB :: Bool -> Double -> FilePath -> Solid -> IO ()+writeGLTFOrGLB binary linDeflection filepath (Solid ptr) = (`withAcquire` pure) $ do+    s <- toAcquire ptr+    mesh <- BRepMesh.IncrementalMesh.fromShapeAndLinDeflection s linDeflection+    liftIO $ BRepMesh.IncrementalMesh.perform mesh+    doc <- TDocStd.Document.fromStorageFormat ""+    mainLabel <- TDocStd.Document.main doc+    shapeTool <- XCafDoc.DocumentTool.shapeTool mainLabel+    _ <- XCafDoc.ShapeTool.addShape shapeTool s True True+    meta <- TColStd.IndexedDataMapOfStringString.new+    progress <- Message.ProgressRange.new+    writer <- RWGltf.CafWriter.new filepath binary+    liftIO $ RWGltf.CafWriter.perform writer doc meta progress+    return ()++-- | Write a `Solid` to a glTF file at a given path+--+-- glTF, or Graphics Library Transmission Format is a JSON based format +-- used for three-dimensional scenes and models+writeGLTF :: Double -> FilePath -> Solid -> IO ()+writeGLTF = writeGLTFOrGLB False++-- | Write a `Solid` to a glb file at a given path+--+-- glb is the binary variant of the glTF file format+writeGLB :: Double -> FilePath -> Solid -> IO ()+writeGLB = writeGLTFOrGLB True
waterfall-cad.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-version:        0.2.0.0+version:        0.2.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@@ -63,7 +63,7 @@     , lattices >=2.0 && <3     , lens ==5.*     , linear >=1.21 && <2-    , opencascade-hs >=0.2.0.0 && <0.3+    , opencascade-hs >=0.2.1.0 && <0.3     , primitive >=0.7 && <0.10     , resourcet >=1.2 && <1.4   default-language: Haskell2010