Documentation
¶
Index ¶
- Constants
- Variables
- func SetTestRand(r *rand.Rand)
- type AnnealCallback
- type Annealable
- type AxesLock
- type Axis
- type Config
- type ConfigItem
- type Copack
- type Item
- type Model
- func (m *Model) Add(mesh *fauxgl.Mesh, detail, count int, spacing float64, ...)
- func (m *Model) BoundingBox() fauxgl.Box
- func (m *Model) Copy() Annealable
- func (m *Model) DoMove(singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector, packItemNum int) (Undo, int)
- func (m *Model) Energy() float64
- func (m *Model) Mesh() *fauxgl.Mesh
- func (m *Model) Meshes() []*fauxgl.Mesh
- func (m *Model) Pack(iterations int, callback AnnealCallback, singleStlSize []fauxgl.Vector, ...) (*Model, int)
- func (m *Model) Reset()
- func (m *Model) Transformation() []fauxgl.Matrix
- func (m *Model) TreeMesh() *fauxgl.Mesh
- func (m *Model) TreeMeshes() []*fauxgl.Mesh
- func (m *Model) UndoMove(undo Undo)
- func (m *Model) ValidBound(i int, singleStlSize []fauxgl.Vector, frameSize fauxgl.Vector) bool
- func (m *Model) ValidChange(i int) bool
- func (m *Model) Volume() float64
- type Node
- type Object
- type Packer
- type PackingOutput
- type TransMap
- type Tree
- type Undo
Constants ¶
const ( BVH_DETAIL = 8 ANNEALING_ITERATIONS = 2000000 // # of trials )
const MAX_MOVE_ATTEMPTS = 200
Maximum number of attempts to find a valid move (bounds + collision). When DoMove exhausts this many attempts without finding a valid position, it signals that the chosen item is stuck. Anneal uses this threshold to detect per-move failures.
const MAX_STUCK_RATIO = 3
How many consecutive DoMove failures (each of MAX_MOVE_ATTEMPTS) the annealing loop tolerates before declaring the packing stuck. The actual limit is max(packItemNum * MAX_STUCK_RATIO, MAX_MOVE_ATTEMPTS) so that the algorithm has a chance to sample different items before giving up — a single stuck item should not abort the entire anneal.
Variables ¶
var AxisXRotations []fauxgl.Matrix
var AxisYRotations []fauxgl.Matrix
var AxisZRotations []fauxgl.Matrix
var NULL_TRANSFORMATION = fauxgl.Matrix{
X00: 0, X01: 0, X02: 0, X03: 0,
X10: 0, X11: 0, X12: 0, X13: 0,
X20: 0, X21: 0, X22: 0, X23: 0,
X30: 0, X31: 0, X32: 0, X33: 0,
}
Functions ¶
func SetTestRand ¶ added in v1.6.1
SetTestRand sets the RNG used by the packing algorithm. When non-nil, it replaces the default (global) RNG. Pass nil to restore default behaviour. Used by tests for deterministic, repeatable packing.
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 AxesLock ¶
type AxesLock struct {
ThetaX *float64 `json:"theta_x"`
ThetaY *float64 `json:"theta_y"`
ThetaZ *float64 `json:"theta_z"`
}
The struct name AxesLock is incorrect and should be replaced with MfgOrientation and corrected everywhere else in this file. This naming issue was spotted during the handoff to Tyler.
type Config ¶
type Config struct {
BuildVolume [3]float64 `json:"build_volume"`
Spacing float64 `json:"spacing"`
ConfigItems []ConfigItem `json:"items"`
}
func ParseConfig ¶
func (*Config) TotalItems ¶
type ConfigItem ¶
type ConfigItem struct {
Filename string `json:"filename"`
Scale float64 `json:"scale"`
Count int `json:"count"`
Copack []*Copack `json:"copack,omitempty"`
AxesLock *AxesLock `json:"axes_lock"`
}
func (*ConfigItem) AvailableRotations ¶
func (c *ConfigItem) AvailableRotations() []fauxgl.Matrix
This function returns only the available rotations which depend on the unlocked axes provided by the user. An unlocked axis is characterised by a `nil` theta angle. Setting a theta angle with a Float instead means that that rotation axis is locked to a specific angle.
func (*ConfigItem) ManufacturingOrientation ¶
func (c *ConfigItem) ManufacturingOrientation() fauxgl.Matrix
This function's purpose is to create a composite rotation matrix from the three provided angles. Tech debt: this function might need to be moved into a function in fauxgl.mesh. NOTE: The THREE.Euler's rotation order (in Rapidfab) has been set as 'ZYX' to match Blender's rotation order and pack3d "seems" to be the same order of rotation but with the "minus" sign for all three angles.
e.g.: -fauxgl.Radians(*item.AxesLock.ThetaX)
type Item ¶
type Model ¶
func (*Model) BoundingBox ¶
func (*Model) Copy ¶
func (m *Model) Copy() Annealable
func (*Model) Transformation ¶
This function will return the tranformation matrices of all items
func (*Model) TreeMeshes ¶
func (*Model) ValidBound ¶
True if the passed move it within maximum_packing_area, false in all other cases.
func (*Model) ValidChange ¶
This function is to make sure no intersection between objects
type PackingOutput ¶
func Pack ¶
func Pack(config *Config) (*PackingOutput, error)
Attempts to pack a list of objects, applying rotation, scaling, and co-packing if specified.