vshell

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package vshell provides functions for reading and writing .vsh files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NeighborBitMap

type NeighborBitMap uint32

NeighborBitMap represents the neighbors of a voxel and can be used to calculate the normal of the voxel.

const (
	X_1Y_1Z_1 NeighborBitMap = 1 << iota
	X_1Y_1Z0
	X_1Y_1Z1
	X_1Y0Z_1
	X_1Y0Z0
	X_1Y0Z1
	X_1Y1Z_1
	X_1Y1Z0
	X_1Y1Z1
	X0Y_1Z_1
	X0Y_1Z0
	X0Y_1Z1
	X0Y0Z_1

	X0Y0Z1
	X0Y1Z_1
	X0Y1Z0
	X0Y1Z1
	X1Y_1Z_1
	X1Y_1Z0
	X1Y_1Z1
	X1Y0Z_1
	X1Y0Z0
	X1Y0Z1
	X1Y1Z_1
	X1Y1Z0
	X1Y1Z1
)

func (NeighborBitMap) String

func (n NeighborBitMap) String() string

String returns an easy-to-read (bit possibly long) representation of NeighborBitMap.

type VShVoxel

type VShVoxel struct {
	X, Y, Z int
	N       NeighborBitMap
}

VShVoxel represents a VShell Voxel.

func (VShVoxel) String

func (v VShVoxel) String() string

String returns a summary string of a VshVoxel.

type VShell

type VShell 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     []VShVoxel
}

VShell represents a voxel model (or subregion) in vshell 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).

VShells differ from BinVOX as follows:

  • BinVOX lists the presence of each voxel as a sparse matrix
  • VShell lists only the voxels exposed on the outer shell of the model. That is, all "internal" voxels are elided. Along with each outer "shell" voxel, its NeighborBitMap is also retained.

func Merge

func Merge(binfiles []string) (*VShell, error)

Merge merges one or more binvox files into a single VShell.

func New

func New(bv *binvox.BinVOX) (*VShell, error)

New returns a new VShell from a BinVOX.

func Read

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

Read reads a vshell file and returns a VShell. 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 (*VShell) Add

func (vs *VShell) Add(bv *binvox.BinVOX) (err error)

Add adds shell voxels from bv to vs.

func (*VShell) Dim

func (v *VShell) Dim() int

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

func (*VShell) MBB

func (v *VShell) MBB() *gl.Box

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

func (*VShell) String

func (v *VShell) String() string

String returns a summary string of the VShell.

func (*VShell) VoxelsPerMM

func (v *VShell) VoxelsPerMM() float64

VoxelsPerMM returns the number of voxels per millimeter.

func (*VShell) Write

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

Write writes a vshell 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