Skip to content

Commit

Permalink
XZListAOIManager accepts aoidist Coord argument
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaonanln committed Aug 3, 2018
1 parent 637aab1 commit 5e9d879
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions XZListAOIManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type XZListAOIManager struct {
}

// NewXZListAOIManager creates a new XZListAOIManager
func NewXZListAOIManager() AOIManager {
func NewXZListAOIManager(aoidist Coord) AOIManager {
return &XZListAOIManager{
xSweepList: newXAOIList(),
zSweepList: newYAOIList(),
xSweepList: newXAOIList(aoidist),
zSweepList: newYAOIList(aoidist),
}
}

Expand Down
2 changes: 1 addition & 1 deletion aoi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
)

func TestXZListAOIManager(t *testing.T) {
testAOI(t, "XZListAOI", NewXZListAOIManager(), NUM_OBJS)
testAOI(t, "XZListAOI", NewXZListAOIManager(100), NUM_OBJS)
}

func TestTowerAOIManager(t *testing.T) {
Expand Down
17 changes: 9 additions & 8 deletions xAOIList.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package aoi

type xAOIList struct {
head *xzaoi
tail *xzaoi
aoidist Coord
head *xzaoi
tail *xzaoi
}

func newXAOIList() *xAOIList {
return &xAOIList{}
func newXAOIList(aoidist Coord) *xAOIList {
return &xAOIList{aoidist: aoidist}
}

func (sl *xAOIList) Insert(aoi *xzaoi) {
Expand Down Expand Up @@ -129,14 +130,14 @@ func (sl *xAOIList) Mark(aoi *xzaoi) {
prev := aoi.xPrev
coord := aoi.aoi.x

minCoord := coord - aoi.aoi.dist
minCoord := coord - sl.aoidist
for prev != nil && prev.aoi.x >= minCoord {
prev.markVal += 1
prev = prev.xPrev
}

next := aoi.xNext
maxCoord := coord + aoi.aoi.dist
maxCoord := coord + sl.aoidist
for next != nil && next.aoi.x <= maxCoord {
next.markVal += 1
next = next.xNext
Expand All @@ -146,7 +147,7 @@ func (sl *xAOIList) Mark(aoi *xzaoi) {
func (sl *xAOIList) GetClearMarkedNeighbors(aoi *xzaoi) {
prev := aoi.xPrev
coord := aoi.aoi.x
minCoord := coord - aoi.aoi.dist
minCoord := coord - sl.aoidist
for prev != nil && prev.aoi.x >= minCoord {
if prev.markVal == 2 {
aoi.neighbors[prev] = struct{}{}
Expand All @@ -159,7 +160,7 @@ func (sl *xAOIList) GetClearMarkedNeighbors(aoi *xzaoi) {
}

next := aoi.xNext
maxCoord := coord + aoi.aoi.dist
maxCoord := coord + sl.aoidist
for next != nil && next.aoi.x <= maxCoord {
if next.markVal == 2 {
aoi.neighbors[next] = struct{}{}
Expand Down
17 changes: 9 additions & 8 deletions zAOIList.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package aoi

type yAOIList struct {
head *xzaoi
tail *xzaoi
aoidist Coord
head *xzaoi
tail *xzaoi
}

func newYAOIList() *yAOIList {
return &yAOIList{}
func newYAOIList(aoidist Coord) *yAOIList {
return &yAOIList{aoidist: aoidist}
}

func (sl *yAOIList) Insert(aoi *xzaoi) {
Expand Down Expand Up @@ -129,14 +130,14 @@ func (sl *yAOIList) Mark(aoi *xzaoi) {
prev := aoi.yPrev
coord := aoi.aoi.y

minCoord := coord - aoi.aoi.dist
minCoord := coord - sl.aoidist
for prev != nil && prev.aoi.y >= minCoord {
prev.markVal += 1
prev = prev.yPrev
}

next := aoi.yNext
maxCoord := coord + aoi.aoi.dist
maxCoord := coord + sl.aoidist
for next != nil && next.aoi.y <= maxCoord {
next.markVal += 1
next = next.yNext
Expand All @@ -147,14 +148,14 @@ func (sl *yAOIList) ClearMark(aoi *xzaoi) {
prev := aoi.yPrev
coord := aoi.aoi.y

minCoord := coord - aoi.aoi.dist
minCoord := coord - sl.aoidist
for prev != nil && prev.aoi.y >= minCoord {
prev.markVal = 0
prev = prev.yPrev
}

next := aoi.yNext
maxCoord := coord + aoi.aoi.dist
maxCoord := coord + sl.aoidist
for next != nil && next.aoi.y <= maxCoord {
next.markVal = 0
next = next.yNext
Expand Down

0 comments on commit 5e9d879

Please sign in to comment.