-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdoc.go
70 lines (52 loc) · 2.41 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Package stl implements functions to read, write, and transform files
in the Stereolithography/Surface Tesselation Language (.stl) file format
used in 3D modelling.
The format specification was taken from http://www.ennex.com/~fabbers/StL.asp,
found at http://en.wikipedia.org/wiki/STL_%28file_format%29.
While STL stores the data in single precision 32 bit floating point numbers,
the stl package does all calculations beyond simple addition in double
precision 64 bit (float64).
Usage Example
// Read STL file
solid, errRead := stl.ReadFile(inputFilename)
if errRead != nil {
fmt.Fprintln(os.Stderr, errRead)
os.Exit(1)
}
// Convert from Inches to mm
solid.Scale(25.4)
// Write STL file
errWrite := solid.WriteFile(outputFilename)
if errWrite != nil {
fmt.Fprintln(os.Stderr, errWrite)
os.Exit(2)
}
Everything that operates on a model is defined as a method of Solid.
Note that The STL format has two variants, a human-readable ASCII variant,
and a more compact and precise binary variant which is preferrable.
ASCII Format Specialities
The Solid.BinaryHeader field and the Triangle.Attributes fields will
be empty, after reading, as these are not part of the ASCII format. The Solid.Name
field is read from the first line after "solid ". It is not checked
against the name at the end of the file after "endsolid ". The stl package
will also not cope with Unicode byte order marks, which some text editors
might automatically place at the beginning of a file.
Binary Format Specialities
The Solid.BinaryHeader field is filled with all 80 bytes of header data.
Then, ReadFile will try to fill solid.Name with an ASCII string
read from the header data from the first byte until a \0 or a non-ASCII
character is detected.
Numerical Errors
As always when you do linear transformations on floating point numbers,
you get numerical errors. So you should expect a vertex being
rotated for 360° not to end up at exactly the original coordinates, but instead
just very close to them. As the error is usually far smaller than the available
precision of 3D printing applications, this is not an issue in most cases.
Stream Processing
You can implement the Writer interface to directly write into your own data structures.
This way you can use the CopyFile and CopyAll functions.
var ownData ownDataStructure // implements stl.Writer
err := stl.CopyFile("somefile.stl", &ownData)
*/
package stl