...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package s2
16
17
18 var (
19 _ Shape = (*edgeVectorShape)(nil)
20 )
21
22
23
24
25
26 type edgeVectorShape struct {
27 edges []Edge
28 }
29
30
31 func edgeVectorShapeFromPoints(a, b Point) *edgeVectorShape {
32 e := &edgeVectorShape{
33 edges: []Edge{
34 {a, b},
35 },
36 }
37 return e
38 }
39
40
41 func (e *edgeVectorShape) Add(a, b Point) {
42 e.edges = append(e.edges, Edge{a, b})
43 }
44 func (e *edgeVectorShape) NumEdges() int { return len(e.edges) }
45 func (e *edgeVectorShape) Edge(id int) Edge { return e.edges[id] }
46 func (e *edgeVectorShape) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) }
47 func (e *edgeVectorShape) NumChains() int { return len(e.edges) }
48 func (e *edgeVectorShape) Chain(chainID int) Chain { return Chain{chainID, 1} }
49 func (e *edgeVectorShape) ChainEdge(chainID, offset int) Edge { return e.edges[chainID] }
50 func (e *edgeVectorShape) ChainPosition(edgeID int) ChainPosition { return ChainPosition{edgeID, 0} }
51 func (e *edgeVectorShape) IsEmpty() bool { return defaultShapeIsEmpty(e) }
52 func (e *edgeVectorShape) IsFull() bool { return defaultShapeIsFull(e) }
53 func (e *edgeVectorShape) Dimension() int { return 1 }
54 func (e *edgeVectorShape) typeTag() typeTag { return typeTagNone }
55 func (e *edgeVectorShape) privateInterface() {}
56
View as plain text