render

package
v0.0.0-...-02f6ed8 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 27 Imported by: 99

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSTL

func LoadSTL(path string) ([]*sdf.Triangle3, error)

LoadSTL loads an STL file (ascii or binary) and returns the triangle mesh.

func Poly

func Poly(p *sdf.Polygon, path string) error

Poly outputs a polygon as a 2D DXF file.

func SaveDXF

func SaveDXF(path string, mesh []*sdf.Line2) error

SaveDXF writes line segments to a DXF file.

func SaveSTL

func SaveSTL(path string, mesh []*sdf.Triangle3) error

SaveSTL writes a triangle mesh to an STL file.

func SaveSVG

func SaveSVG(path, lineStyle string, mesh []*sdf.Line2) error

SaveSVG writes line segments to an SVG file.

func To3MF

func To3MF(
	s sdf.SDF3,
	path string,
	r Render3,
)

To3MF renders an SDF3 to a 3MF file.

func ToDXF

func ToDXF(
	s sdf.SDF2,
	path string,
	r Render2,
)

ToDXF renders an SDF2 to a DXF file.

func ToSTL

func ToSTL(
	s sdf.SDF3,
	path string,
	r Render3,
)

ToSTL renders an SDF3 to an STL file.

func ToSVG

func ToSVG(
	s sdf.SDF2,
	path string,
	r Render2,
)

ToSVG renders an SDF2 to an SVG file.

func ToTriangles

func ToTriangles(
	s sdf.SDF3,
	r Render3,
) []*sdf.Triangle3

ToTriangles renders an SDF3 to a triangle mesh.

Types

type DXF

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

DXF is a dxf drawing object.

func NewDXF

func NewDXF(name string) *DXF

NewDXF returns an empty dxf drawing object.

func (*DXF) Box

func (d *DXF) Box(a *sdf.Box2)

Box adds a box to a dxf drawing object.

func (*DXF) Line

func (d *DXF) Line(line *sdf.Line2)

Line adds a line to a dxf drawing object.

func (*DXF) Lines

func (d *DXF) Lines(lines []*sdf.Line2)

Lines adds a set of lines to a dxf drawing object.

func (*DXF) Points

func (d *DXF) Points(s v2.VecSet, r float64)

Points adds a set of points to a dxf drawing object.

func (*DXF) Save

func (d *DXF) Save() error

Save writes a dxf drawing object to a file.

func (*DXF) Triangle

func (d *DXF) Triangle(t sdf.Triangle2)

Triangle adds a triangle to a dxf drawing object.

type DualContouring2D

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

DualContouring2D renders is a 2D dual contouring renderer.

func NewDualContouring2D

func NewDualContouring2D(meshCells int) *DualContouring2D

NewDualContouring2D returns a Render2 object.

func (*DualContouring2D) Info

func (r *DualContouring2D) Info(s sdf.SDF2) string

Info returns a string describing the rendered area.

func (*DualContouring2D) Render

func (r *DualContouring2D) Render(s sdf.SDF2, output sdf.Line2Writer)

Render produces a 2d line mesh over the bounding area of an sdf2.

type EdgeI

type EdgeI [2]int

EdgeI is a 2d/3d edge referencing a list of vertices.

type MarchingCubesOctree

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

MarchingCubesOctree renders using marching cubes with octree space sampling.

func NewMarchingCubesOctree

func NewMarchingCubesOctree(meshCells int) *MarchingCubesOctree

NewMarchingCubesOctree returns a Render3 object.

func (*MarchingCubesOctree) Info

func (r *MarchingCubesOctree) Info(s sdf.SDF3) string

Info returns a string describing the rendered volume.

func (*MarchingCubesOctree) Render

func (r *MarchingCubesOctree) Render(s sdf.SDF3, output sdf.Triangle3Writer)

Render produces a 3d triangle mesh over the bounding volume of an sdf3.

type MarchingCubesUniform

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

MarchingCubesUniform renders using marching cubes with uniform space sampling.

func NewMarchingCubesUniform

func NewMarchingCubesUniform(meshCells int) *MarchingCubesUniform

NewMarchingCubesUniform returns a Render3 object.

func (*MarchingCubesUniform) Info

func (r *MarchingCubesUniform) Info(s sdf.SDF3) string

Info returns a string describing the rendered volume.

func (*MarchingCubesUniform) Render

func (r *MarchingCubesUniform) Render(s sdf.SDF3, output sdf.Triangle3Writer)

Render produces a 3d triangle mesh over the bounding volume of an sdf3.

type MarchingSquaresQuadtree

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

MarchingSquaresQuadtree renders using marching squares with quadtree area sampling.

func NewMarchingSquaresQuadtree

func NewMarchingSquaresQuadtree(meshCells int) *MarchingSquaresQuadtree

NewMarchingSquaresQuadtree returns a Render2 object.

func (*MarchingSquaresQuadtree) Info

Info returns a string describing the rendered area.

func (*MarchingSquaresQuadtree) Render

func (r *MarchingSquaresQuadtree) Render(s sdf.SDF2, output sdf.Line2Writer)

Render produces a 2d line mesh over the bounding area of an sdf2.

type MarchingSquaresUniform

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

MarchingSquaresUniform renders using marching squares with uniform area sampling.

func NewMarchingSquaresUniform

func NewMarchingSquaresUniform(meshCells int) *MarchingSquaresUniform

NewMarchingSquaresUniform returns a Render2 object.

func (*MarchingSquaresUniform) Info

Info returns a string describing the rendered area.

func (*MarchingSquaresUniform) Render

func (r *MarchingSquaresUniform) Render(s sdf.SDF2, output sdf.Line2Writer)

Render produces a 2d line mesh over the bounding area of an sdf2.

type PNG

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

PNG is a png image object.

func NewPNG

func NewPNG(name string, bb sdf.Box2, pixels v2i.Vec) (*PNG, error)

NewPNG returns an empty PNG object.

func (*PNG) Image

func (d *PNG) Image() *image.RGBA

Image returns the rendered image instead of writing it to a file

func (*PNG) Line

func (d *PNG) Line(p0, p1 v2.Vec)

Line adds a line to a png object.

func (*PNG) Lines

func (d *PNG) Lines(s v2.VecSet)

Lines adds a set of lines line to a png object.

func (*PNG) RenderSDF2

func (d *PNG) RenderSDF2(s sdf.SDF2)

RenderSDF2 renders a 2d signed distance field as gray scale.

func (*PNG) RenderSDF2MinMax

func (d *PNG) RenderSDF2MinMax(s sdf.SDF2, dmin, dmax float64)

RenderSDF2MinMax renders a 2d signed distance field as gray scale (with defined min/max levels).

func (*PNG) Save

func (d *PNG) Save() error

Save saves a png object to a file.

func (*PNG) Triangle

func (d *PNG) Triangle(t sdf.Triangle2)

Triangle adds a triangle to a png object.

type Render2

type Render2 interface {
	Render(s sdf.SDF2, output sdf.Line2Writer)
	Info(s sdf.SDF2) string
}

Render2 renders a 2D line set over the bounding area of an sdf2.

type Render3

type Render3 interface {
	Render(sdf3 sdf.SDF3, output sdf.Triangle3Writer)
	Info(sdf3 sdf.SDF3) string
}

Render3 renders a 3D triangle mesh over the bounding volume of an sdf3.

type STLHeader

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

STLHeader defines the STL file header.

type STLTriangle

type STLTriangle struct {
	Normal, Vertex1, Vertex2, Vertex3 [3]float32
	// contains filtered or unexported fields
}

STLTriangle defines the triangle data within an STL file.

type SVG

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

SVG represents an SVG renderer.

func NewSVG

func NewSVG(filename, lineStyle string) *SVG

NewSVG returns an SVG renderer.

func (*SVG) Line

func (s *SVG) Line(p0, p1 v2.Vec)

Line outputs a line to the SVG file.

func (*SVG) Save

func (s *SVG) Save() error

Save closes the SVG file.

type TriangleI

type TriangleI [3]int

TriangleI is a 2d/3d triangle referencing a list of vertices.

func (*TriangleI) Canonical

func (t *TriangleI) Canonical()

Canonical converts a triangle to it's lowest index first form. Preserve the winding order.

func (TriangleI) ToTriangle2

func (t TriangleI) ToTriangle2(p []v2.Vec) sdf.Triangle2

ToTriangle2 given vertex indices and the vertex array, return the triangle with real vertices.

type TriangleIByIndex

type TriangleIByIndex []TriangleI

TriangleIByIndex sorts triangles by index.

func (TriangleIByIndex) Len

func (a TriangleIByIndex) Len() int

func (TriangleIByIndex) Less

func (a TriangleIByIndex) Less(i, j int) bool

func (TriangleIByIndex) Swap

func (a TriangleIByIndex) Swap(i, j int)

type TriangleISet

type TriangleISet []TriangleI

TriangleISet is a set of triangles defined by vertice indices.

func Delaunay2d

func Delaunay2d(vs v2.VecSet) (TriangleISet, error)

Delaunay2d returns the delaunay triangulation of a 2d point set.

func Delaunay2dSlow

func Delaunay2dSlow(vs v2.VecSet) (TriangleISet, error)

Delaunay2dSlow returns the delaunay triangulation of a 2d point set. This is a slow reference implementation for testing faster algorithms. See: Computational Geometry, Joseph O'Rourke, 2nd edition, Code 5.1

func (TriangleISet) Canonical

func (ts TriangleISet) Canonical() []TriangleI

Canonical converts a triangle set to it's canonical form. This common form is used to facilitate comparison between the results of different implementations.

func (TriangleISet) Equals

func (ts TriangleISet) Equals(s TriangleISet) bool

Equals tests two triangle sets for equality.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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