stl

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package stl provides functionality for writing 3D models in STL (stereolithography) binary format.

STL is a widely used file format for 3D printing and computer-aided design (CAD). This package implements the binary STL format specification, which is more compact and efficient than the ASCII variant. The binary format consists of:

  • An 80-byte header
  • A 4-byte unsigned integer indicating the number of triangles
  • Triangle data, where each triangle consists of:
  • A normal vector (3 x 32-bit floats)
  • Three vertices (9 x 32-bit floats)
  • A 2-byte attribute count (unused in most applications)

This package provides optimized writing capabilities with buffered I/O and efficient memory usage, making it suitable for generating large 3D models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContributionGeometry

func CreateContributionGeometry(contributions [][]types.ContributionDay, yearIndex int, maxContrib int) []types.Triangle

CreateContributionGeometry generates geometry for a single year's worth of contributions

func GenerateSTL

func GenerateSTL(contributions [][]types.ContributionDay, outputPath, username string, year int) error

GenerateSTL creates a 3D model from GitHub contribution data and writes it to an STL file. It's a convenience wrapper around GenerateSTLRange for single year processing.

func GenerateSTLRange

func GenerateSTLRange(contributions [][][]types.ContributionDay, outputPath, username string, startYear, endYear int) error

GenerateSTLRange creates a 3D model from multiple years of GitHub contribution data. It handles the complete process from data validation through geometry generation to file output. Parameters:

  • contributions: 3D slice of contribution data ([year][week][day])
  • outputPath: destination path for the STL file
  • username: GitHub username for the contribution data
  • startYear: first year in the range
  • endYear: last year in the range

func WriteSTLBinary

func WriteSTLBinary(filename string, triangles []types.Triangle) error

WriteSTLBinary writes triangles to a binary STL file with optimized buffering.

The binary STL format consists of: 1. 80-byte header - typically containing version/generator information 2. 4-byte unsigned integer - number of triangles 3. For each triangle:

  • Normal vector: 3 x float32 (12 bytes)
  • Vertex 1: 3 x float32 (12 bytes)
  • Vertex 2: 3 x float32 (12 bytes)
  • Vertex 3: 3 x float32 (12 bytes)
  • Attribute byte count: uint16 (2 bytes, usually 0)

Types

This section is empty.

Directories

Path Synopsis
Package geometry provides 3D geometry generation functions for STL models.
Package geometry provides 3D geometry generation functions for STL models.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL