point_vector.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package s2
  15. // Shape interface enforcement
  16. var (
  17. _ Shape = (*PointVector)(nil)
  18. )
  19. // PointVector is a Shape representing a set of Points. Each point
  20. // is represented as a degenerate point with the same starting and ending
  21. // vertices.
  22. //
  23. // This type is useful for adding a collection of points to an ShapeIndex.
  24. //
  25. // Its methods are on *PointVector due to implementation details of ShapeIndex.
  26. type PointVector []Point
  27. func (p *PointVector) NumEdges() int { return len(*p) }
  28. func (p *PointVector) Edge(i int) Edge { return Edge{(*p)[i], (*p)[i]} }
  29. func (p *PointVector) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) }
  30. func (p *PointVector) NumChains() int { return len(*p) }
  31. func (p *PointVector) Chain(i int) Chain { return Chain{i, 1} }
  32. func (p *PointVector) ChainEdge(i, j int) Edge { return Edge{(*p)[i], (*p)[j]} }
  33. func (p *PointVector) ChainPosition(e int) ChainPosition { return ChainPosition{e, 0} }
  34. func (p *PointVector) Dimension() int { return 0 }
  35. func (p *PointVector) IsEmpty() bool { return defaultShapeIsEmpty(p) }
  36. func (p *PointVector) IsFull() bool { return defaultShapeIsFull(p) }
  37. func (p *PointVector) privateInterface() {}