Documentation ¶
Index ¶
- Constants
- func MarshalModel(m *Model) ([]byte, error)
- func Register(namespace string, spec spec.Spec)
- func UnmarshalModel(data []byte, model *Model) error
- type Any
- type AnyAttr
- type Asset
- type Attachment
- type Base
- type BaseMaterials
- type Box
- type Build
- type ChildModel
- type Component
- type Components
- type Decoder
- type Encoder
- type Extension
- type Item
- type Matrix
- type Mesh
- type MeshBuilder
- type Metadata
- type Model
- func (m *Model) BoundingBox() Box
- func (m *Model) FindAsset(path string, id uint32) (Asset, bool)
- func (m *Model) FindObject(path string, id uint32) (*Object, bool)
- func (m *Model) FindResources(path string) (*Resources, bool)
- func (m *Model) PathOrDefault() string
- func (m *Model) Validate() error
- func (m *Model) ValidateCoherency() error
- func (m *Model) WalkAssets(fn func(string, Asset) error) error
- func (m *Model) WalkObjects(fn func(string, *Object) error) error
- type Object
- type ObjectType
- type Point2D
- type Point3D
- type ReadCloser
- type Relationship
- type Resources
- type Triangle
- type Units
- type UnknownAsset
- type WriteCloser
Constants ¶
const ( // Namespace is the canonical name of this extension. Namespace = "http://schemas.microsoft.com/3dmanufacturing/core/2015/02" // RelType3DModel is the canonical 3D model relationship type. RelType3DModel = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel" // RelTypeThumbnail is the canonical thumbnail relationship type. RelTypeThumbnail = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" // RelTypePrintTicket is the canonical print ticket relationship type. RelTypePrintTicket = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket" // RelTypeMustPreserve is the canonical must preserve relationship type. RelTypeMustPreserve = "http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve" // DefaultModelPath is the recommended root model part name. DefaultModelPath = "/3D/3dmodel.model" // DefaultPrintTicketName is the recommended print ticket part name. DefaultPrintTicketName = "/3D/Metadata/Model_PT.xml" // Default3DTexturesDir is the recommended directory for 3D textures. Default3DTexturesDir = "/3D/Textures/" // Default3DOtherDir is the recommended directory for non-standard parts. Default3DOtherDir = "/3D/Other/" // DefaultMetadataDir is the recommended directory for standard metadata. DefaultMetadataDir = "/Metadata/" // ContentType3DModel is the 3D model content type. ContentType3DModel = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" // ContentTypePrintTicket is the print ticket content type. ContentTypePrintTicket = "application/vnd.ms-printing.printticket+xml" )
Variables ¶
This section is empty.
Functions ¶
func MarshalModel ¶
MarshalModel returns the XML encoding of m.
func Register ¶
Register makes a spec available by the provided namesoace. If Register is called twice with the same name or if spec is nil, it panics.
func UnmarshalModel ¶
UnmarshalModel fills a model with the data of a root model file using not strict mode.
Types ¶
type AnyAttr ¶
type AnyAttr []spec.MarshalerAttr
AnyAttr is an extension point containing <anyAttribute> information.
func (*AnyAttr) AddUnknownAttr ¶
func (AnyAttr) GetUnknownAttr ¶
func (any AnyAttr) GetUnknownAttr() *spec.UnknownAttrs
type Attachment ¶
Attachment defines the Model Attachment.
type Base ¶
Base defines the Model Base Material Resource. A model material resource is an in memory representation of the 3MF material resource object.
type BaseMaterials ¶
BaseMaterials defines a slice of Base.
func (*BaseMaterials) Identify ¶
func (r *BaseMaterials) Identify() uint32
Identify returns the unique ID of the resource.
func (*BaseMaterials) Marshal3MF ¶
func (r *BaseMaterials) Marshal3MF(x spec.Encoder) error
type ChildModel ¶
type ChildModel struct { Resources Resources Relationships []Relationship Any Any }
ChildModel repreents de content of a non-root model file.
It is not supported by the core spec but a common concept for multiple official specs. The relationships are usually managed by the extensions themself, but they are usefull to reference custom attachments.
type Component ¶
A Component is an in memory representation of the 3MF component.
func (*Component) HasTransform ¶
HasTransform returns true if the transform is different than the identity.
func (*Component) ObjectPath ¶
ObjectPath search an extension attribute with an ObjectPath function that return a non empty path. Else returns the default path.
type Components ¶
A Components is an in memory representation of the 3MF components.
type Decoder ¶
type Decoder struct { Strict bool // contains filtered or unexported fields }
Decoder implements a 3mf file decoder.
func NewDecoder ¶
NewDecoder returns a new Decoder reading a 3mf file from r.
type Encoder ¶
type Encoder struct { FloatPrecision int // contains filtered or unexported fields }
An Encoder writes Model data to an output stream.
See the documentation for strconv.FormatFloat for details about the FloatPrecision behaviour.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
type Item ¶
type Item struct { ObjectID uint32 Transform Matrix PartNumber string Metadata []Metadata AnyAttr AnyAttr }
A Item is an in memory representation of the 3MF build item.
func (*Item) HasTransform ¶
HasTransform returns true if the transform is different than the identity.
func (*Item) ObjectPath ¶
ObjectPath search an extension attribute with an ObjectPath function that return a non empty path. Else returns an empty path.
type Matrix ¶
type Matrix [16]float32
Matrix is a 4x4 matrix in row major order.
m[4*r + c] is the element in the r'th row and c'th column.
func Identity ¶
func Identity() Matrix
Identity returns the 4x4 identity matrix. The identity matrix is a square matrix with the value 1 on its diagonals. The characteristic property of the identity matrix is that any matrix multiplied by it is itself. (MI = M; IN = N)
type Mesh ¶
A Mesh is an in memory representation of the 3MF mesh object. Each node and face have an ID, which allows to identify them. Each face have an orientation (i.e. the face can look up or look down) and have three nodes. The orientation is defined by the order of its nodes.
func (*Mesh) BoundingBox ¶
BoundingBox returns the bounding box of the mesh.
func (*Mesh) ValidateCoherency ¶
ValidateCoherency checks that the mesh is non-empty, manifold and oriented.
type MeshBuilder ¶
type MeshBuilder struct { // True to automatically check if a node with the same coordinates already exists in the mesh // when calling AddVertex. If it exists, the return value will be the existing node and no node will be added. // Using this option produces an speed penalty. CalculateConnectivity bool // Do not modify the pointer to Mesh once the build process has started. Mesh *Mesh // contains filtered or unexported fields }
MeshBuilder is a helper that creates mesh following a configurable criteria. It must be instantiated using NewMeshBuilder.
func NewMeshBuilder ¶
func NewMeshBuilder(m *Mesh) *MeshBuilder
NewMeshBuilder returns a new MeshBuilder.
func (*MeshBuilder) AddVertex ¶
func (mb *MeshBuilder) AddVertex(node Point3D) uint32
AddVertex adds a node the the mesh at the target position.
type Metadata ¶
Metadata item is an in memory representation of the 3MF metadata, and can be attached to any 3MF model node.
type Model ¶
type Model struct { Path string Language string Units Units Thumbnail string Resources Resources Build Build Attachments []Attachment Extensions []Extension // space -> spec Metadata []Metadata Childs map[string]*ChildModel // path -> child RootRelationships []Relationship Relationships []Relationship Any Any AnyAttr AnyAttr }
A Model is an in memory representation of the 3MF file.
If path is empty, the default path '/3D/3dmodel.model' will be used. The relationships are usually managed by the extensions themself, but they are usefull to reference custom attachments. Childs keys cannot be an empty string. RootRelationships are the OPC root relationships.
func (*Model) BoundingBox ¶
BoundingBox returns the bounding box of the model.
func (*Model) FindObject ¶
FindObject returns the object with the target path and ID.
func (*Model) FindResources ¶
FindResources returns the resource associated with path.
func (*Model) PathOrDefault ¶
PathOrDefault returns Path if not empty, else DefaultModelPath.
func (*Model) ValidateCoherency ¶
ValidateCoherency checks that all the mesh are non-empty, manifold and oriented.
func (*Model) WalkAssets ¶
WalkAssets walks the assets of the root and child models, calling fn for asset and stopping if fn returns an error.
The child models are first walked in lexical order and then the root model is walked. The root model path is always empty, regardless of the defined model path.
func (*Model) WalkObjects ¶
WalkObjects walks the objects of the root and child models, calling fn for object and stopping if fn returns an error.
The child models are first walked in lexical order and then the root model is walked. The root model path is always empty, regardless of the defined model path.
type Object ¶
type Object struct { ID uint32 Name string PartNumber string Thumbnail string PID uint32 PIndex uint32 Type ObjectType Metadata []Metadata Mesh *Mesh Components *Components AnyAttr AnyAttr }
An Object is an in memory representation of the 3MF model object.
type ObjectType ¶
type ObjectType int8
ObjectType defines the allowed object types.
const ( ObjectTypeModel ObjectType = iota ObjectTypeOther ObjectTypeSupport ObjectTypeSolidSupport ObjectTypeSurface )
Supported object types.
func (ObjectType) String ¶
func (o ObjectType) String() string
type Point2D ¶
type Point2D [2]float32
Point2D defines a node of a slice as an array of 2 coordinates: x and y.
type Point3D ¶
type Point3D [3]float32
Point3D defines a node of a mesh as an array of 3 coordinates: x, y and z.
type ReadCloser ¶
type ReadCloser struct { Decoder // contains filtered or unexported fields }
ReadCloser wrapps a Decoder than can be closed.
func OpenReader ¶
func OpenReader(name string) (*ReadCloser, error)
OpenReader will open the 3MF file specified by name and return a ReadCloser.
func (*ReadCloser) Close ¶
func (r *ReadCloser) Close() error
Close closes the 3MF file, rendering it unusable for I/O.
type Relationship ¶
Relationship defines a dependency between the owner of the relationsip and the attachment referenced by path. ID is optional, if not set a random value will be used when encoding.
type Resources ¶
The Resources element acts as the root element of a library of constituent pieces of the overall 3D object definition.
func (*Resources) FindObject ¶
FindObject returns the resource with the target ID.
type UnknownAsset ¶
type UnknownAsset struct { spec.UnknownTokens // contains filtered or unexported fields }
UnknownAsset wraps a spec.UnknownTokens to fulfill the Asset interface.
func (UnknownAsset) Identify ¶
func (u UnknownAsset) Identify() uint32
type WriteCloser ¶
type WriteCloser struct { Encoder // contains filtered or unexported fields }
WriteCloser wrapps an Encoder than can be closed.
func CreateWriter ¶
func CreateWriter(name string) (*WriteCloser, error)
CreateWriter will create the 3MF file specified by name and return a WriteCloser.
func (*WriteCloser) Close ¶
func (w *WriteCloser) Close() error
Close closes the 3MF file, rendering it unusable for I/O.