waterfall-cad-0.2.2.0: Declarative CAD/Solid Modeling Library
Safe HaskellNone
LanguageHaskell2010

Waterfall.IO

Synopsis

Documentation

data WaterfallIOExceptionCause Source #

Reason for an IO action to have failed

Constructors

FileError

Something went wrong when accessing a file, eg. a write to a file path that is unreachable, or a read to a file in the wrong format

BadGeometryError

The contents of a file could not be converted into a Solid e.g the file did not contain a solid object

UnrecognizedFormatError

The readSolid/writeSolid functions could not infer the correct file format from a filepath

Solid Writers

writeSolid :: Double -> FilePath -> Solid -> IO () Source #

Write a Solid to a file, work out the format from the file extension

Errors if passed a filename with an unrecognized extension

Because BRep representations of objects can store arbitrary precision curves, but some of the supported file formats store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

writeSTL :: Double -> FilePath -> Solid -> IO () Source #

Write a Solid to a (binary) STL file at a given path

Because BRep representations of objects can store arbitrary precision curves, but STL files store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

writeAsciiSTL :: Double -> FilePath -> Solid -> IO () Source #

Write a Solid to an Ascii STL file at a given path

Because BRep representations of objects can store arbitrary precision curves, but STL files store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

writeSTEP :: FilePath -> Solid -> IO () Source #

Write a Solid to a STEP file at a given path

STEP files can be imported by FreeCAD

writeGLTF :: Double -> FilePath -> Solid -> IO () Source #

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

Because BRep representations of objects can store arbitrary precision curves, but glTF files store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

writeGLB :: Double -> FilePath -> Solid -> IO () Source #

Write a Solid to a glb file at a given path

glb is the binary variant of the glTF file format

Because BRep representations of objects can store arbitrary precision curves, but glTF files store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

writeOBJ :: Double -> FilePath -> Solid -> IO () Source #

Write a Solid to an obj file at a given path

Wavefront OBJ is a simple ascii file format that stores geometric data.

Because BRep representations of objects can store arbitrary precision curves, but obj files store triangulated surfaces, this function takes a "deflection" argument used to discretize curves.

The deflection is the maximum allowable distance between a curve and the generated triangulation.

Solid Readers

Load a Solid from a file

At present, the "read*" functions do slightly less validation on the loaded solid than they arguably should and may succeed when reading solids that may generate invalid geometry when processed

readSolid :: FilePath -> IO Solid Source #

Read a Solid from a file at a given path

Throws an error if loading fails, or if it's unable to work out the intended file format from the path

readSTL :: FilePath -> IO Solid Source #

Read a Solid from an STL file at a given path

readSTEP :: FilePath -> IO Solid Source #

Read a Solid from a STEP file at a given path

readGLTF :: FilePath -> IO Solid Source #

Read a Solid from a GLTF file at a given path

This should support reading both the GLTF (json) and GLB (binary) formats

readOBJ :: FilePath -> IO Solid Source #

Read a Solid from an obj file at a given path

This should support reading both the GLTF (json) and GLB (binary) formats