Close shape if not closed in ComplexPolygon GetShape()
This commit is contained in:
parent
485b49f4cf
commit
05c31ff74c
|
@ -32,9 +32,10 @@ func (p ComplexPolygon) GetShape() (r Shape) {
|
|||
panic(err)
|
||||
}
|
||||
for _, contour := range p.Pol {
|
||||
start := math.NewVector2(contour[0].X, contour[0].Y)
|
||||
r = append(r, records.LineRecord{
|
||||
To: math.NewVector2(contour[1].X, contour[1].Y),
|
||||
Start: math.NewVector2(contour[0].X, contour[0].Y),
|
||||
Start: start,
|
||||
})
|
||||
for _, point := range contour[2:] {
|
||||
r = append(r, records.LineRecord{
|
||||
|
@ -42,6 +43,13 @@ func (p ComplexPolygon) GetShape() (r Shape) {
|
|||
Start: r[len(r)-1].GetEnd(),
|
||||
})
|
||||
}
|
||||
|
||||
if !r[len(r)-1].GetEnd().Equals(start) { //not closed
|
||||
r = append(r, records.LineRecord{
|
||||
To: start,
|
||||
Start: r[len(r)-1].GetEnd(),
|
||||
})
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue