lsh / tinystl-zig

A zero dependency STL data reader written in Zig inspired by MicroSTL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TinySTL - A small loader for STL files.

This project is heavily inspired by, and adapted from, cry-inc's microstl library. The goal is to provide a zero-dependency way to easily load and write STL files. It is assumed that all binary files are little endian.

Example

const StlData = @include("stldata.zig").StlData;

pub fn main() !void {
 var allocator = std.heap.page_allocator;
 var file = try std.fs.cwd().openFile("my_mesh.stl", .{});
 defer file.close();
 var data = try StlData.readFromFile(file, allocator, .{});
 defer data.deinit();

 var out_file = try std.fs.cwd().createFile("my_mesh_output.stl", .{});
 defer out_file.close();
 try data.writeBinaryFile(file, .{});
}

About

A zero dependency STL data reader written in Zig inspired by MicroSTL

License:MIT License


Languages

Language:Zig 100.0%