@@ -25,12 +25,19 @@ import (
2525 "fmt"
2626 "sync"
2727
28- "github.com/deadsy/sdfx/vec/conv "
28+ v3 "github.com/deadsy/sdfx/vec/v3 "
2929 "github.com/hpinc/go3mf"
3030)
3131
3232//-----------------------------------------------------------------------------
3333
34+ // toPoint3D converts a 3D float vector to a go3mf 3D vector.
35+ func toPoint3D (a v3.Vec ) go3mf.Point3D {
36+ return go3mf.Point3D {float32 (a .X ), float32 (a .Y ), float32 (a .Z )}
37+ }
38+
39+ //-----------------------------------------------------------------------------
40+
3441// Write3MF writes a stream of triangles to a 3MF file.
3542func Write3MF (wg * sync.WaitGroup , path string ) (chan <- []* Triangle3 , error ) {
3643
@@ -62,9 +69,9 @@ func Write3MF(wg *sync.WaitGroup, path string) (chan<- []*Triangle3, error) {
6269 // read triangles from the channel and add them to the model
6370 for ts := range c {
6471 for _ , t := range ts {
65- v1 := mb .AddVertex (V3ToPoint3D (t .V [0 ]))
66- v2 := mb .AddVertex (V3ToPoint3D (t .V [1 ]))
67- v3 := mb .AddVertex (V3ToPoint3D (t .V [2 ]))
72+ v1 := mb .AddVertex (toPoint3D (t .V [0 ]))
73+ v2 := mb .AddVertex (toPoint3D (t .V [1 ]))
74+ v3 := mb .AddVertex (toPoint3D (t .V [2 ]))
6875 mesh .Triangles .Triangle = append (mesh .Triangles .Triangle , go3mf.Triangle {V1 : v1 , V2 : v2 , V3 : v3 })
6976 }
7077 }
@@ -78,9 +85,4 @@ func Write3MF(wg *sync.WaitGroup, path string) (chan<- []*Triangle3, error) {
7885 return c , nil
7986}
8087
81- // V3ToPoint3D converts a 3D float vector to a go3mf 3D vector.
82- func V3ToPoint3D (a v3.Vec ) go3mf.Point3D {
83- return go3mf.Point3D {float32 (a .X ), float32 (a .Y ), float32 (a .Z )}
84- }
85-
8688//-----------------------------------------------------------------------------
0 commit comments