[Insight-users] Bresenham Line Iterator

Benjamin King king.benjamin at mh-hannover.de
Wed Jun 8 03:01:04 EDT 2005


Hi Jim,

your suggestions for renaming the classes and methods are good. You are 
welcome to rename everything as you see fit.

In the current form, the scan converter is working on the XY plane, but it's 
possible to make it work on any plane orthogonal to an axis of the coordinate 
system without much of a hassle:

The GetX()/GetY() accessors should be removed in favour of GetIndex() which 
should return some m_currentIndex that replaces m_currentX and m_currentY. 
This would be needed to match ITK convention anyway.

There are only four places outside GetX()/GetY() where m_currentX/m_currentY 
are accessed or modified. Those occurences could be replaced by 
m_currentIndex[m_primaryDirection]/m_currentIndex[m_secondaryDirection].

There are a few options for changes in the constructor:

One would be that the user is still providing the polygon in 2D on the XY 
plane but is allowed to choose a primary and secondary axis that are used to 
map x and y. In addition, the other N-2 index components must be provided as 
well.

Another alternative would be to provide the polygon in ND, for example as an 
itk::PolyLineParametricPath, and a plane on which the vertices should be 
projected. In this version, it would require a little more work in the 
constructor to map the edges of the polygon back to the XY coordinates that 
are feeding the Linear2DIndexInterpolator's.


As I really don't need the scan converter myself right now, I don't know what 
would be more convenient to the user. Providing both alternatives might turn 
out a little confusing. What do you think about it?

Cheers,
	Benjamin

> Benjamin,
>
> This is sounding good.
>
> The IsAtEnd() is the best name we found to describe what an ITK iterator
> is doing.  We liked the STL convention that container.end() returned an
> iterator one past the end of the container.  As you have seen, ITK can
> provide a much richer set of iterators than an STL container, so we
> couldn't incorporate all the iterators into the ITK containers. 
> Furthermore, the ITK iterators are fairly heavyweight, so we wouldn't want
> to create them frequently, like in an STL loop below (in the it !=
> vec.end() clause)
>
> 	for (std::vector<int>:iterator it = vec.begin(); it != vec.end(); ++it)
> 	   {}
>
> I would change the IsAtLastElement() to just IsAtLast(). STL also has a
> notion of front() and back() that could be used.  I always forget the name
> of the back() method in STL and end up trying to call last().  I may have
> polluted some of the ITK iterators with the notion of "last" when it
> probably should be "back".  In my defense, "back" doesn't sound quite right
> to me in the context of ND iterators. (I also wonder if the early versions
> of STL, circa 1992, called back() last()).
>
> Your LineInterpolator2D might be called an Linear2DIndexInterpolator. I'd
> want to keep the name sufficiently different for the ImageFunction
> Interpolators we have.
>
> Your function object CurrentXSmallerCurrentYSmaller could be called
> Linear2DIndexComparator
>
> Does your scan converter only work on the XY plane?  Or could I scan
> convert a polygon on the YZ plane?
>
> Jim


More information about the Insight-users mailing list