[Insight-developers] spatial object iterators

Damion Shelton beowulf@cs.cmu.edu
Sun, 9 Feb 2003 21:22:46 -0500


I've been looking over the spatial object code to see how easy it will 
be to integrate them with the conditional iterators and I have a few 
comments and questions.

First, the primary difference between spatial objects and spatial 
functions is the means by which a value is returned. The 
InteriorExteriorSpatialFunction's (to be renamed to 
BooleanSpatialFunctions) return true when a point is inside the 
function, and false otherwise, in response to an Evaluate() call. This 
is the "condition" in the conditional iterators. SpatialObjects are 
quite similar, but the corresponding call is IsInside().

There are a several ways I can see of solving this problem:

1) Because the conditional iterators are templated, it should be 
possible to use any of them with SpatialObjects, provided 
SpatialObjects have an Evaluate() function. I don't know how much sense 
this makes in the context of spatial objects (in that they don't really 
"Evaluate"), but it would be relatively simple to wrap IsInside() into 
Evaluate(). Both functions expect N-d points, so there's no fundamental 
data type problem.

2) It may be possible to do type checking at runtime, and call the 
appropriate function. Is this true?

3) SpatialObjects might be a subclass of SpatialFunctions, although I 
haven't convinced myself of this. Are there any problems with 
subclassing the spatial objects from spatial functions?

4) It would be relatively straightforward to write additional 
conditional iterators, where the IsPixelIncluded() function is 
implemented to call IsInside(). My concerns here are that this code 
would essentially duplicate that of the spatial function iterators 
(with the exception of one line) and therefore would create extra code 
to maintain.

A final issue is the name of the resulting iterators. Right now, we 
have FloodFilledSpatialFunctionConditionalIterator; if we create a 
version of this which can iterate over spatial objects, would the name 
be confusing?

-Damion-