binvox

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package binvox provides functions for reading and writing binvox files. See: http://www.patrickmin.com/binvox/binvox.html for more information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TriangleLess

func TriangleLess(t []*gl.Triangle) func(a, b int) bool

TriangleLess provides a Less function for sort.Slice.

Types

type BinVOX

type BinVOX struct {
	NX, NY, NZ int     // number of voxels in each dimension
	TX, TY, TZ float64 // translation (location of origin in world space)
	Scale      float64 // uniform scale in millimeters
	Voxels     []gl.Voxel
}

BinVOX represents a voxel model (or subregion) in binvox format. Voxels have uniform dimensions in X, Y, and Z and can be thought of as 3D "pixels".

NX, NY, and NZ are the number of voxels in each dimension and must be positive (non-zero).

Scale represents the uniform scale of this subregion's largest dimension (in millimeters). So if "dim = max(NX,NY,NZ)", then there are dim/Scale voxels per millimeter in each direction.

Translating the subregion to (TX,TY,TZ) will correctly place this region in world space (in millimeters).

func Read

func Read(filename string, sx, sy, sz, nx, ny, nz int) (*BinVOX, error)

Read reads a binvox file and returns a BinVOX. sx, sy, sz are the starting indices for reading a model. nx, ny, nz are the number of voxels to read in each direction (0=all).

func (*BinVOX) Dim

func (b *BinVOX) Dim() int

Dim returns the maximum dimension (the max of NX, NY, and NZ).

func (*BinVOX) MBB

func (b *BinVOX) MBB() *gl.Box

MBB returns the minimum bounding box of the subregion in millimeters.

func (*BinVOX) ManifoldMesh

func (b *BinVOX) ManifoldMesh() *gl.Mesh

func (*BinVOX) MarchingCubes

func (b *BinVOX) MarchingCubes() *gl.Mesh

func (*BinVOX) String

func (b *BinVOX) String() string

String returns a summary string of the BinVOX.

func (*BinVOX) ToMesh

func (b *BinVOX) ToMesh() *gl.Mesh

ToMesh converts a BinVOX to a mesh.

func (*BinVOX) Voxelize

func (b *BinVOX) Voxelize(mesh *gl.Mesh) error

Voxelize voxelizes a subregion of the mesh using (b.TX,b.TY,b.TZ) as the origin. The voxelized subregion will be: (0,0,0)-(b.NX-1,b.NY-1,b.NZ-1) (inclusive). b.Scale determines the scale of the voxelization. See Dim and VoxelsPerMM.

Voxelize overwrites the Voxels slice in b.

func (*BinVOX) VoxelizeZ

func (b *BinVOX) VoxelizeZ(mesh *gl.Mesh, zi int) error

func (*BinVOX) VoxelsPerMM

func (b *BinVOX) VoxelsPerMM() float64

VoxelsPerMM returns the number of voxels per millimeter.

func (*BinVOX) Write

func (b *BinVOX) Write(filename string, sx, sy, sz, nx, ny, nz int) error

Write writes a binvox file. sx, sy, sz are the starting indices of the model. nx, ny, nz are the number of voxels to write in each direction (0=all).

Jump to

Keyboard shortcuts

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