-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpolygon_test.go
57 lines (50 loc) · 1.64 KB
/
polygon_test.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
package graphile
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestParsePLYElementVertex(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 6906")
assert.Equal(t, 6906, g.vertexSize)
}
func TestParsePLYVector(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 1")
g.parseLinePLY("1.56444 -0.204025 0.346805")
assert.Equal(t, 1, g.vertexSize)
assert.Equal(t, []float32{1.56444, -0.204025, 0.346805}, g.vertex[len(g.vertex)-1])
}
func TestParsePLYVectorScientificPrecition(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 1")
g.parseLinePLY("0.167500E-02 0.505000E-02 0.000000E+00")
assert.Equal(t, 1, g.vertexSize)
assert.Equal(t, []float32{0.001675, 0.00505, 0.0}, g.vertex[len(g.vertex)-1])
}
func TestParsePLYFaceTriangles(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 1")
g.parseLinePLY("1.0 0.0 0.0")
g.parseLinePLY("3 1 2 3")
assert.Equal(t, []int32{1, 2, 3}, g.triangles[0])
}
func TestParsePLYFaceCuads(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 1")
g.parseLinePLY("1.0 0.0 0.0")
g.parseLinePLY("4 1 2 3 4")
assert.Equal(t, []int32{1, 2, 3}, g.triangles[0])
assert.Equal(t, []int32{3, 4, 1}, g.triangles[1])
}
func TestPolygonCompile(t *testing.T) {
g := GeometryFile{format: "polygon"}
g.parseLinePLY("element vertex 3")
g.parseLinePLY("0 0 0")
g.parseLinePLY("1 0 0")
g.parseLinePLY("1 1 0")
g.parseLinePLY("3 1 2 3")
mesh, err := g.compile()
assert.Nil(t, err)
assert.Equal(t, []float32{0, 0, 0, 1, 0, 0, 1, 1, 0}, mesh.Vertex)
}