pack3d

package
v0.0.0-...-b375704 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AxisXRotations []fauxgl.Matrix
View Source
var AxisYRotations []fauxgl.Matrix
View Source
var AxisZRotations []fauxgl.Matrix

Functions

This section is empty.

Types

type AnnealCallback

type AnnealCallback func(Annealable)

type Annealable

type Annealable interface {
	Energy() float64
	DoMove([]fauxgl.Vector, fauxgl.Vector, int) (Undo, int)
	UndoMove(Undo)
	Copy() Annealable
}

func Anneal

func Anneal(state Annealable, maxTemp, minTemp float64, steps int, callback AnnealCallback, singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector, packItemNum int) (Annealable, int)

type Axis

type Axis uint8
const (
	AxisNone Axis = iota
	AxisX
	AxisY
	AxisZ
)

func (Axis) Vector

func (a Axis) Vector() fauxgl.Vector

type Item

type Item struct {
	Mesh               *fauxgl.Mesh
	Trees              []Tree // struc tree -> []Box, struc Box -> {min, max} vector
	RotationId         int    // index of a rotation within Rotations.
	Translation        fauxgl.Vector
	AvailableRotations []fauxgl.Matrix
}

func (*Item) Copy

func (item *Item) Copy() *Item

func (*Item) Matrix

func (item *Item) Matrix() fauxgl.Matrix

type Model

type Model struct {
	Items     []*Item
	MinVolume float64
	MaxVolume float64
	Deviation float64
}

func NewModel

func NewModel() *Model

func (*Model) Add

func (m *Model) Add(mesh *fauxgl.Mesh, detail, count int, spacing float64, rotations []fauxgl.Matrix)

func (*Model) BoundingBox

func (m *Model) BoundingBox() fauxgl.Box

func (*Model) Copy

func (m *Model) Copy() Annealable

func (*Model) DoMove

func (m *Model) DoMove(singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector, packItemNum int) (Undo, int)

func (*Model) Energy

func (m *Model) Energy() float64

func (*Model) Mesh

func (m *Model) Mesh() *fauxgl.Mesh

func (*Model) Meshes

func (m *Model) Meshes() []*fauxgl.Mesh

func (*Model) Pack

func (m *Model) Pack(iterations int, callback AnnealCallback, singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector, packItemNum int) (*Model, int)

func (*Model) Reset

func (m *Model) Reset()

func (*Model) Transformation

func (m *Model) Transformation() []fauxgl.Matrix

This function will return the tranformation matrices of all items

func (*Model) TreeMesh

func (m *Model) TreeMesh() *fauxgl.Mesh

func (*Model) TreeMeshes

func (m *Model) TreeMeshes() []*fauxgl.Mesh

func (*Model) UndoMove

func (m *Model) UndoMove(undo Undo)

func (*Model) ValidBound

func (m *Model) ValidBound(i int, singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector) bool

True if the passed move it within maximum_packing_area, false in all other cases.

func (*Model) ValidChange

func (m *Model) ValidChange(i int) bool

This function is to make sure no intersection between objects

func (*Model) Volume

func (m *Model) Volume() float64

type Node

type Node struct {
	Box   fauxgl.Box
	Left  *Node
	Right *Node
}

func NewNode

func NewNode(boxes []fauxgl.Box, depth int, space float64) *Node

func (*Node) Flatten

func (a *Node) Flatten(tree Tree, i int)

func (*Node) Split

func (node *Node) Split(boxes []fauxgl.Box, depth int, space float64)

type Tree

type Tree []fauxgl.Box

func NewTreeForMesh

func NewTreeForMesh(mesh *fauxgl.Mesh, depth int, spacing float64) Tree

func (Tree) Intersects

func (a Tree) Intersects(b Tree, t1, t2 fauxgl.Vector) bool

func (Tree) Transform

func (a Tree) Transform(m fauxgl.Matrix) Tree

type Undo

type Undo struct {
	Index       int
	Rotation    int
	Translation fauxgl.Vector
}

Jump to

Keyboard shortcuts

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