render

package
v0.0.0-...-c238eda Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 []*Line) error

SaveDXF writes line segments to a DXF file.

func SaveSTL

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

SaveSTL writes a triangle mesh to an STL file.

func SaveSVG

func SaveSVG(path, lineStyle string, mesh []*Line) 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 Write3MF

func Write3MF(wg *sync.WaitGroup, path string) (chan<- []*Triangle3, error)

Write3MF writes a stream of triangles to a 3MF file.

func WriteDXF

func WriteDXF(wg *sync.WaitGroup, path string) (chan<- []*Line, error)

WriteDXF writes a stream of line segments to a DXF file.

func WriteSTL

func WriteSTL(wg *sync.WaitGroup, path string) (chan<- []*Triangle3, error)

WriteSTL writes a stream of triangles to an STL file.

func WriteSVG

func WriteSVG(wg *sync.WaitGroup, path, lineStyle string) (chan<- []*Line, error)

WriteSVG writes a stream of line segments to an SVG file.

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) Line

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

Line adds a line to a dxf drawing object.

func (*DXF) Lines

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

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 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 chan<- []*Line)

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 Line

type Line [2]v2.Vec

Line is a 2d line segment defined with 2 points.

func (Line) Degenerate

func (l Line) Degenerate(tolerance float64) bool

Degenerate returns true if the line is degenerate.

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 chan<- []*Triangle3)

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 chan<- []*Triangle3)

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 chan<- []*Line)

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 chan<- []*Line)

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

func (*MarchingSquaresUniform) ToArray

func (r *MarchingSquaresUniform) ToArray(s sdf.SDF2) array

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 Triangle2)

Triangle adds a triangle to a png object.

type Render2

type Render2 interface {
	Render(s sdf.SDF2, output chan<- []*Line)
	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 chan<- []*Triangle3)
	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 Triangle2

type Triangle2 [3]v2.Vec

Triangle2 is a 2D triangle

func (Triangle2) Circumcenter

func (t Triangle2) Circumcenter() (v2.Vec, error)

Circumcenter returns the circumcenter of a triangle.

func (Triangle2) InCircumcircle

func (t Triangle2) InCircumcircle(p v2.Vec) (inside, done bool)

InCircumcircle return inside == true if the point is inside the circumcircle of the triangle. Returns done == true if the vertex and the subsequent x-ordered vertices are outside the circumcircle.

type Triangle3

type Triangle3 struct {
	V [3]v3.Vec
}

Triangle3 is a 3D triangle

func NewTriangle3

func NewTriangle3(a, b, c v3.Vec) *Triangle3

NewTriangle3 returns a new 3D triangle.

func (*Triangle3) Degenerate

func (t *Triangle3) Degenerate(tolerance float64) bool

Degenerate returns true if the triangle is degenerate.

func (*Triangle3) Normal

func (t *Triangle3) Normal() v3.Vec

Normal returns the normal vector to the plane defined by the 3D triangle.

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) 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