stl v0.1.0 STL
Functions for working with STL files and structs. Triangle count and bounding box finding is done during parsing and is a constant-time operation. Surface area calculation, if not able to be calculated during parsing, is done every time the function is called and thus is potentially an expensive operation.
Link to this section Summary
Types
Will always have exactly 8 points in the list, equivelant to the number of vertexes a box has.
Dimensions are always in the order {x, y, z}
Functions
Get the 8 points of the STL file's bounding box. Points are returned as 3 item tuples with float values. Dimensions are always in the order {x, y, z}
Parse a STL struct from a binary
Parse a STL struct from a file.
Get a pre-summed surface area off the STL struct, or if if not already calculated, sum the area of every facet in the STL file to get the total STL surface_area.
Get the triangle count of the STL file
Link to this section Types
Will always have exactly 8 points in the list, equivelant to the number of vertexes a box has.
Dimensions are always in the order {x, y, z}
t()
t() :: %STL{ bounding_box: bounding_box(), facets: [STL.Facet.t(), ...], name: String.t(), surface_area: float(), triangle_count: integer() }
Link to this section Functions
bounding_box(stl)
Get the 8 points of the STL file's bounding box. Points are returned as 3 item tuples with float values. Dimensions are always in the order {x, y, z}
iex> STL.bounding_box(my_stl)
[
{26.5269, 90.2, 13.5885},
{26.5269, 90.2, -13.6694},
{26.5269, 4.426, 13.5885},
{26.5269, 4.426, -13.6694},
{-26.5748, 90.2, 13.5885},
{-26.5748, 90.2, -13.6694},
{-26.5748, 4.426, 13.5885},
{-26.5748, 4.426, -13.6694}
]
parse!(binary)
Parse a STL struct from a binary
iex> STL.parse!(stl_binary)
%STL{...}
Specify the parser with the optional second argument
iex> STL.parse!(stl_binary, MyApp.Parser)
%STL{...}
parse!(binary, parser)
parse_file!(file)
Parse a STL struct from a file.
iex> STL.parse_file!("my.stl")
%STL{...}
Specify the parser with the optional second argument
iex> STL.parse_file!("my.stl", MyApp.Parser)
%STL{...}
parse_file!(file, parser)
surface_area(stl)
Get a pre-summed surface area off the STL struct, or if if not already calculated, sum the area of every facet in the STL file to get the total STL surface_area.
iex> STL.surface_area(my_stl)
1000
triangle_count(stl)
Get the triangle count of the STL file
iex> STL.triangle_count(my_stl)
100