neilpa / go-stl

Go STL file decoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-stl

CI GoDoc

Simple go library for decoding binary and ASCII STL files as well as binary encoder.

Usage

Reading triangle vertices of a binary or ASCII STL file

package main

import (
    "fmt"
    "log"
    "os"

    "neilpa.me/go-stl"
)

func main() {
    f, err := os.Open("path/to/mesh.stl")
    if err != nil {
        log.Fatal(err)
    }

    mesh, err := stl.Decode(f)
    if err != nil {
        log.Fatal(err)
    }

    for _, face := range mesh.Faces {
        fmt.Println(face.Verts)
    }
}

See also stlbox for an example of calculating the bounding box.

License

MIT

About

Go STL file decoder

License:MIT License


Languages

Language:Go 100.0%