simplify

package module
Version: v0.0.0-...-d32f302 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: MIT Imports: 7 Imported by: 4

README

3D Mesh Simplification

Implementation of Surface Simplification Using Quadric Error Metrics, SIGGRAPH 97, written in Go.

Bunny

270,000 faces vs. 2,700 faces (1%)


Install

go get -u github.com/fogleman/simplify/cmd/simplify

Command-Line Usage

Usage: simplify [-f FACTOR] input.stl output.stl

$ simplify -f 0.1 bunny.stl out.stl
Loading bunny.stl
Input mesh contains 270021 faces
Simplifying to 10% of original...
Output mesh contains 27001 faces
Writing out.stl

API Usage

// Use LoadSTL (ASCII) or LoadBinarySTL
mesh, err := simplify.LoadBinarySTL(inputPath)
// handle err
mesh = mesh.Simplify(factor)
mesh.SaveBinarySTL(outputPath)

Animated

Iteratively simplifying by 50% until only 16 faces remain

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveBinarySTL

func SaveBinarySTL(path string, mesh *Mesh) error

Types

type Face

type Face struct {
	V1, V2, V3 *Vertex
	Removed    bool
}

func NewFace

func NewFace(v1, v2, v3 *Vertex) *Face

func (*Face) Degenerate

func (f *Face) Degenerate() bool

func (*Face) Normal

func (f *Face) Normal() Vector

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

func (Matrix) Add

func (a Matrix) Add(b Matrix) Matrix

func (Matrix) Determinant

func (a Matrix) Determinant() float64

func (Matrix) Inverse

func (a Matrix) Inverse() Matrix

func (Matrix) MulPosition

func (a Matrix) MulPosition(b Vector) Vector

func (Matrix) QuadricError

func (a Matrix) QuadricError(v Vector) float64

func (Matrix) QuadricVector

func (a Matrix) QuadricVector() Vector

type Mesh

type Mesh struct {
	Triangles []*Triangle
}

func LoadBinarySTL

func LoadBinarySTL(path string) (*Mesh, error)

func LoadSTL

func LoadSTL(path string) (*Mesh, error)

func NewMesh

func NewMesh(triangles []*Triangle) *Mesh

func Simplify

func Simplify(input *Mesh, factor float64) *Mesh

func (*Mesh) SaveBinarySTL

func (m *Mesh) SaveBinarySTL(path string) error

func (*Mesh) Simplify

func (m *Mesh) Simplify(factor float64) *Mesh

type Pair

type Pair struct {
	A, B        *Vertex
	Index       int
	Removed     bool
	CachedError float64
}

func NewPair

func NewPair(a, b *Vertex) *Pair

func (*Pair) Error

func (p *Pair) Error() float64

func (*Pair) Quadric

func (p *Pair) Quadric() Matrix

func (*Pair) Vector

func (p *Pair) Vector() Vector

type PairKey

type PairKey struct {
	A, B Vector
}

func MakePairKey

func MakePairKey(a, b *Vertex) PairKey

type PriorityQueue

type PriorityQueue []*Pair

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type STLHeader

type STLHeader struct {
	Count uint32
	// contains filtered or unexported fields
}

type STLTriangle

type STLTriangle struct {
	N, V1, V2, V3 [3]float32
	// contains filtered or unexported fields
}

type Triangle

type Triangle struct {
	V1, V2, V3 Vector
}

func NewTriangle

func NewTriangle(v1, v2, v3 Vector) *Triangle

func (*Triangle) Normal

func (t *Triangle) Normal() Vector

func (*Triangle) Quadric

func (t *Triangle) Quadric() Matrix

type Vector

type Vector struct {
	X, Y, Z float64
}

func (Vector) Add

func (a Vector) Add(b Vector) Vector

func (Vector) Cross

func (a Vector) Cross(b Vector) Vector

func (Vector) Dot

func (a Vector) Dot(b Vector) float64

func (Vector) Length

func (a Vector) Length() float64

func (Vector) Less

func (a Vector) Less(b Vector) bool

func (Vector) MulScalar

func (a Vector) MulScalar(b float64) Vector

func (Vector) Normalize

func (a Vector) Normalize() Vector

func (Vector) Sub

func (a Vector) Sub(b Vector) Vector

type Vertex

type Vertex struct {
	Vector
	Quadric Matrix
}

func NewVertex

func NewVertex(v Vector) *Vertex

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL