Subject: Re: bug in recursiveNeighbourhood: n
From: Pierre Bommel (bommel@cirad.fr)
Date: Mon Aug 23 2004 - 18:00:56 CEST
Hello all,
This error was already notified and corrected by Stan (http://cormas.cirad.fr/forum/cormas/archives/0104.html).
In Cormas2004 version the body of this method is now quite different :
recursiveNeighbourhood: radius
"Returns a collection of the cells include into the radius.
radius = Integer > 0"
| allCells layers |
allCells := OrderedCollection new.
layers := self allLayersTo: radius.
layers do: [:layer | allCells addAll: layer].
^allCells
and it is much more quick than previously.
This is one of the new features that I didn't describe in the "what's new" page...
Best regards,
Pierre
"Hoekstra, J. (Jeljer)" a écrit :
> Hi all,
>
> I found an error in recursiveNeighbourhood: n (version 2003, perhaps also in 2004). It does some double counting. The bug is fixed by changing newVoisins in peripherie in the last line of the loop.
> The bug free version of recursiveNeighbourhood: n is added below.
>
> cheers,
> Jeljer
>
> recursiveNeighbourhood: n
> | ensemble peripherie newVoisins |
> ensemble := OrderedCollection new.
> ensemble add: self.
> peripherie := OrderedCollection new.
> peripherie add: self.
> n timesRepeat:
> [newVoisins := OrderedCollection new.
> peripherie do: [:p | p neighbourhood do:[:v| (newVoisins includes: v) ifFalse: [newVoisins add: v]]].
> "peripherie do: [:p | newVoisins addAll: p neighbourhood]."
> peripherie := newVoisins reject: [ :i | ensemble includes: i ].
> ensemble addAll: peripherie "newVoisins"].
> ^ensemble
-- *********************************** Pierre Bommel CIRAD TA 60/15 73, rue Jean-François Breton 34398 Montpellier cedex 5 France Phone: +33 (0)4 67 59 38 53 Fax: +33 (0)4 67 59 38 27 http://cormas.cirad.fr ***********************************