Documentation ¶
Index ¶
- Constants
- func Write3MFMesh(w io.Writer, unit ThreeMFUnit, vertices [][3]float64, triangles [][3]int) (err error)
- type MTLFile
- type MTLFileMaterial
- type MTLFileTextureMap
- type OBJFile
- type OBJFileFaceGroup
- type OFFReader
- type PLYElement
- type PLYFormat
- type PLYHeader
- type PLYMeshWriter
- type PLYProperty
- type PLYPropertyType
- type PLYReader
- type PLYValue
- type PLYValueFloat32
- type PLYValueFloat64
- type PLYValueInt16
- type PLYValueInt32
- type PLYValueInt64
- type PLYValueInt8
- type PLYValueList
- type PLYValueUint16
- type PLYValueUint32
- type PLYValueUint64
- type PLYValueUint8
- type PLYWriter
- type STLReader
- type STLWriter
- type SVGWriter
- type SegmentCSVReader
- type SegmentCSVWriter
- type ThreeMFUnit
Constants ¶
const ( ThreeMFUnitMicron ThreeMFUnit = "micron" ThreeMFUnitMillimeter = "millimeter" ThreeMFUnitCentimeter = "centimeter" ThreeMFUnitInch = "inch" ThreeMFUnitFoot = "foot" ThreeMFUnitMeter = "meter" )
const ( PLYPropertyTypeNone PLYPropertyType = "" PLYPropertyTypeChar = "char" PLYPropertyTypeUchar = "uchar" PLYPropertyTypeShort = "short" PLYPropertyTypeUshort = "ushort" PLYPropertyTypeInt = "int" PLYPropertyTypeUint = "uint" PLYPropertyTypeFloat = "float" PLYPropertyTypeDouble = "double" PLYPropertyTypeInt8 = "int8" PLYPropertyTypeUint8 = "uint8" PLYPropertyTypeInt16 = "int16" PLYPropertyTypeUint16 = "uint16" PLYPropertyTypeInt32 = "int32" PLYPropertyTypeUint32 = "uint32" PLYPropertyTypeFloat32 = "float32" PLYPropertyTypeFloat64 = "float64" )
Variables ¶
This section is empty.
Functions ¶
func Write3MFMesh ¶ added in v0.4.4
func Write3MFMesh(w io.Writer, unit ThreeMFUnit, vertices [][3]float64, triangles [][3]int) (err error)
Write3MFMesh encodes a mesh as a 3MF file.
The mesh is passed as a collection of vertices, and triangles which index into this vertex list starting at 0 for the first vertex.
Types ¶
type MTLFile ¶
type MTLFile struct {
Materials []*MTLFileMaterial
}
MTLFile represents the contents of a Wavefront mtl file, which is a companion of an obj file.
type MTLFileMaterial ¶
type MTLFileMaterial struct { Name string Ambient [3]float32 Diffuse [3]float32 Specular [3]float32 SpecularExponent float32 // Texture maps AmbientMap *MTLFileTextureMap DiffuseMap *MTLFileTextureMap SpecularMap *MTLFileTextureMap HighlightMap *MTLFileTextureMap }
MTLFileMaterial is a single material in an MTLFile.
type MTLFileTextureMap ¶
MTLFileTextureMap is a configured texture map for an MTLFileMaterial.
type OBJFile ¶
type OBJFile struct { MaterialFiles []string Vertices [][3]float64 VertexColors [][3]float64 UVs [][2]float64 Normals [][3]float64 FaceGroups []*OBJFileFaceGroup }
An OBJFile represents the contents of a Wavefront obj file.
type OBJFileFaceGroup ¶
type OBJFileFaceGroup struct { // Material is the material name, or "" by default. Material string // Each face has three vertices, which itself has a // vertex, texture, and normal index. // If a texture or normal index is 0, it is omitted. Faces [][3][3]int }
An OBJFileFaceGroup is a group of faces with one material in a Wavefront obj file.
type OFFReader ¶
type OFFReader struct {
// contains filtered or unexported fields
}
An OFFReader reads an OFF file.
For info on the OFF format, see http://segeval.cs.princeton.edu/public/off_format.html.
func NewOFFReader ¶
NewOFFReader reads the header from an OFF file and returns the new reader, if successful.
type PLYElement ¶ added in v0.3.4
type PLYElement struct { Name string Count int64 Properties []*PLYProperty }
func NewPLYElementColoredVertex ¶ added in v0.3.4
func NewPLYElementColoredVertex(count int64) *PLYElement
func NewPLYElementFace ¶ added in v0.3.4
func NewPLYElementFace(count int64) *PLYElement
func (*PLYElement) DecodeInstanceBinary ¶ added in v0.3.4
func (*PLYElement) DecodeInstanceString ¶ added in v0.3.4
func (p *PLYElement) DecodeInstanceString(line string) ([]PLYValue, error)
func (*PLYElement) Encode ¶ added in v0.3.4
func (p *PLYElement) Encode() string
func (*PLYElement) IsStandardFace ¶ added in v0.4.2
func (p *PLYElement) IsStandardFace() bool
func (*PLYElement) IsStandardVertex ¶ added in v0.4.2
func (p *PLYElement) IsStandardVertex() bool
type PLYHeader ¶ added in v0.3.4
type PLYHeader struct { Format PLYFormat Elements []*PLYElement }
func NewPLYHeaderDecode ¶ added in v0.3.4
type PLYMeshWriter ¶ added in v0.3.4
type PLYMeshWriter struct {
// contains filtered or unexported fields
}
A PLYMeshWriter encodes a colored mesh PLY file.
This may use buffering as it writes the file, but the full file will always be flushed by the time the last triangle is written.
func NewPLYMeshWriter ¶ added in v0.3.4
func NewPLYMeshWriter(w io.Writer, numCoords, numTris int) (*PLYMeshWriter, error)
NewPLYMeshWriter creates a new PLYMeshWriter and writes the file header.
func (*PLYMeshWriter) WriteCoord ¶ added in v0.3.4
func (p *PLYMeshWriter) WriteCoord(c [3]float64, color [3]uint8) error
WriteCoord writes the next coordinate to the file.
This should be called exactly numCoords times.
func (*PLYMeshWriter) WriteTriangle ¶ added in v0.3.4
func (p *PLYMeshWriter) WriteTriangle(coords [3]int) (err error)
WriteTriangle writes the next triangle to the file.
This should be called exactly numTris times.
type PLYProperty ¶ added in v0.3.4
type PLYProperty struct { // May be PLYPropertyTypeNone for non-lists. LenType PLYPropertyType ElemType PLYPropertyType Name string }
func NewPLYPropertyString ¶ added in v0.3.4
func NewPLYPropertyString(lineData string) (*PLYProperty, error)
type PLYPropertyType ¶ added in v0.3.4
type PLYPropertyType string
func (PLYPropertyType) DecodeBinary ¶ added in v0.3.4
func (PLYPropertyType) Parse ¶ added in v0.3.4
func (p PLYPropertyType) Parse(s string) (PLYValue, error)
func (PLYPropertyType) Size ¶ added in v0.3.4
func (p PLYPropertyType) Size() int
func (PLYPropertyType) Validate ¶ added in v0.3.4
func (p PLYPropertyType) Validate() error
type PLYReader ¶ added in v0.3.4
type PLYReader struct {
// contains filtered or unexported fields
}
A PLYReader reads arbitrary PLY files.
func (*PLYReader) Header ¶ added in v0.4.2
Header gets the file header that was read when the reader was created.
The caller should not modify the returned object.
func (*PLYReader) Read ¶ added in v0.3.4
func (p *PLYReader) Read() ([]PLYValue, *PLYElement, error)
Read reads the next element row from the file.
If all element rows have been read, io.EOF is returned. If reading fails for some other reason, a different error is returned, such as io.UnexpectedEOF.
type PLYValueFloat32 ¶ added in v0.3.4
type PLYValueFloat32 struct {
Value float32
}
func (PLYValueFloat32) EncodeBinary ¶ added in v0.3.4
func (p PLYValueFloat32) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueFloat32) EncodeString ¶ added in v0.3.4
func (p PLYValueFloat32) EncodeString() string
func (PLYValueFloat32) LengthValue ¶ added in v0.3.4
func (p PLYValueFloat32) LengthValue() (int, error)
type PLYValueFloat64 ¶ added in v0.3.4
type PLYValueFloat64 struct {
Value float64
}
func (PLYValueFloat64) EncodeBinary ¶ added in v0.3.4
func (p PLYValueFloat64) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueFloat64) EncodeString ¶ added in v0.3.4
func (p PLYValueFloat64) EncodeString() string
func (PLYValueFloat64) LengthValue ¶ added in v0.3.4
func (p PLYValueFloat64) LengthValue() (int, error)
type PLYValueInt16 ¶ added in v0.3.4
type PLYValueInt16 struct {
Value int16
}
func (PLYValueInt16) EncodeBinary ¶ added in v0.3.4
func (p PLYValueInt16) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueInt16) EncodeString ¶ added in v0.3.4
func (p PLYValueInt16) EncodeString() string
func (PLYValueInt16) LengthValue ¶ added in v0.3.4
func (p PLYValueInt16) LengthValue() (int, error)
type PLYValueInt32 ¶ added in v0.3.4
type PLYValueInt32 struct {
Value int32
}
func (PLYValueInt32) EncodeBinary ¶ added in v0.3.4
func (p PLYValueInt32) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueInt32) EncodeString ¶ added in v0.3.4
func (p PLYValueInt32) EncodeString() string
func (PLYValueInt32) LengthValue ¶ added in v0.3.4
func (p PLYValueInt32) LengthValue() (int, error)
type PLYValueInt64 ¶ added in v0.3.4
type PLYValueInt64 struct {
Value int64
}
func (PLYValueInt64) EncodeBinary ¶ added in v0.3.4
func (p PLYValueInt64) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueInt64) EncodeString ¶ added in v0.3.4
func (p PLYValueInt64) EncodeString() string
func (PLYValueInt64) LengthValue ¶ added in v0.3.4
func (p PLYValueInt64) LengthValue() (int, error)
type PLYValueInt8 ¶ added in v0.3.4
type PLYValueInt8 struct {
Value int8
}
func (PLYValueInt8) EncodeBinary ¶ added in v0.3.4
func (p PLYValueInt8) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueInt8) EncodeString ¶ added in v0.3.4
func (p PLYValueInt8) EncodeString() string
func (PLYValueInt8) LengthValue ¶ added in v0.3.4
func (p PLYValueInt8) LengthValue() (int, error)
type PLYValueList ¶ added in v0.3.4
func (PLYValueList) EncodeBinary ¶ added in v0.3.4
func (p PLYValueList) EncodeBinary(encoding binary.ByteOrder) []byte
func (PLYValueList) EncodeString ¶ added in v0.3.4
func (p PLYValueList) EncodeString() string
func (PLYValueList) LengthValue ¶ added in v0.3.4
func (p PLYValueList) LengthValue() (int, error)
type PLYValueUint16 ¶ added in v0.3.4
type PLYValueUint16 struct {
Value uint16
}
func (PLYValueUint16) EncodeBinary ¶ added in v0.3.4
func (p PLYValueUint16) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueUint16) EncodeString ¶ added in v0.3.4
func (p PLYValueUint16) EncodeString() string
func (PLYValueUint16) LengthValue ¶ added in v0.3.4
func (p PLYValueUint16) LengthValue() (int, error)
type PLYValueUint32 ¶ added in v0.3.4
type PLYValueUint32 struct {
Value uint32
}
func (PLYValueUint32) EncodeBinary ¶ added in v0.3.4
func (p PLYValueUint32) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueUint32) EncodeString ¶ added in v0.3.4
func (p PLYValueUint32) EncodeString() string
func (PLYValueUint32) LengthValue ¶ added in v0.3.4
func (p PLYValueUint32) LengthValue() (int, error)
type PLYValueUint64 ¶ added in v0.3.4
type PLYValueUint64 struct {
Value uint64
}
func (PLYValueUint64) EncodeBinary ¶ added in v0.3.4
func (p PLYValueUint64) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueUint64) EncodeString ¶ added in v0.3.4
func (p PLYValueUint64) EncodeString() string
func (PLYValueUint64) LengthValue ¶ added in v0.3.4
func (p PLYValueUint64) LengthValue() (int, error)
type PLYValueUint8 ¶ added in v0.3.4
type PLYValueUint8 struct {
Value uint8
}
func (PLYValueUint8) EncodeBinary ¶ added in v0.3.4
func (p PLYValueUint8) EncodeBinary(b binary.ByteOrder) []byte
func (PLYValueUint8) EncodeString ¶ added in v0.3.4
func (p PLYValueUint8) EncodeString() string
func (PLYValueUint8) LengthValue ¶ added in v0.3.4
func (p PLYValueUint8) LengthValue() (int, error)
type PLYWriter ¶
type PLYWriter struct {
// contains filtered or unexported fields
}
A PLYWriter encodes an arbitrary PLY file.
This may use buffering as it writes the file, but the full file will always be flushed by the time the last element is written.
func NewPLYWriter ¶
NewPLYWriter creates a new PLYWriter and writes the file header.
type STLReader ¶
type STLReader struct {
// contains filtered or unexported fields
}
An STLReader reads STL files.
func NewSTLReader ¶
NewSTLReader creates an STL reader by reading the header of an STL file.
func (*STLReader) IsBinary ¶ added in v0.4.0
IsBinary returns true if this file is encoded in the binary STL format, rather than the ASCII format.
func (*STLReader) NumTriangles ¶
NumTriangles gets the total number of triangles in the file as reported by the header, if this is a binary file. If it is an ASCII file, this always returns 0.
func (*STLReader) ReadTriangle ¶
ReadTriangle reads the next triangle from the file, or returns an error if no more triangles can be read.
The error io.EOF is returned when the file ended and there are no more triangles to be read. When the file ends abruptly and incorrectly, io.ErrUnexpectedEOF is returned instead.
type STLWriter ¶
type STLWriter struct {
// contains filtered or unexported fields
}
An STLWriter writes a triangle mesh in the STL format.
func NewSTLWriter ¶
NewSTLWriter creates an STLWriter and writes a header, which requires knowledge of the total number of triangles being written.
type SVGWriter ¶ added in v0.2.23
type SVGWriter struct {
// contains filtered or unexported fields
}
An SVGWriter encodes paths to SVG files.
func NewSVGWriter ¶ added in v0.2.23
NewSVGWriter creates writes an SVG header and returns a new SVGWriter.
The viewbox argument specifies the bounding box of the image as [minX, minY, width, height].
func (*SVGWriter) WritePoly ¶ added in v0.2.23
WritePoly writes a polygon or a polyline depending on whether the final point matches up with the first.
func (*SVGWriter) WritePolyPath ¶ added in v0.4.2
WritePolyPath writes one or more polygons into a single path element. Each polygon is either closed or left open depending on whether the final point matches up with the first.
type SegmentCSVReader ¶ added in v0.3.3
type SegmentCSVReader struct {
// contains filtered or unexported fields
}
A SegmentCSVReader reads a CSV file encoding a 2D mesh where each row is one segment.
func NewSegmentCSVReader ¶ added in v0.3.3
func NewSegmentCSVReader(r io.Reader) *SegmentCSVReader
NewSegmentCSVReader creates a SegmentCSVReader that wraps an underlying io.Reader.
func (*SegmentCSVReader) Read ¶ added in v0.3.3
func (s *SegmentCSVReader) Read() ([4]float64, error)
Read reads a segment from the file.
Returns io.EOF if the file is complete.
type SegmentCSVWriter ¶ added in v0.3.3
type SegmentCSVWriter struct {
// contains filtered or unexported fields
}
A SegmentCSVWriter writes a CSV file encoding a 2D mesh where each row is one segment.
func NewSegmentCSVWriter ¶ added in v0.3.3
func NewSegmentCSVWriter(w io.Writer) *SegmentCSVWriter
NewSegmentCSVWriter creates a SegmentCSVWriter that wraps an underlying io.Writer.
func (*SegmentCSVWriter) Write ¶ added in v0.3.3
func (s *SegmentCSVWriter) Write(seg [4]float64) error
Write writes a segment to the file.
The segment is stored as {x1, y1, x2, y2}.
type ThreeMFUnit ¶ added in v0.4.4
type ThreeMFUnit string