[Insight-developers] Need help fixing PostOrderTreeIterator type errors!
Williams, Norman K
norman-k-williams at uiowa.edu
Fri Jun 17 17:08:19 EDT 2011
This makes no sense to me after fiddling around with it for a couple of
hours, so I'm asking for help.
There is this bug report: http://www.itk.org/Bug/view.php?id=7455
Consider this test program:
#include "itkSpatialObject.h"
#include "itkSpatialObjectTreeContainer.h"
#include "itkPostOrderTreeIterator.h"
int
itkSpatialObjectTreeContainerIteratorTest(int ac, char *av[])
{
typedef itk::SpatialObjectTreeContainer<3> SOTreeType;
typedef itk::PostOrderTreeIterator<SOTreeType> PostOrderItType;
SOTreeType::Pointer tree = SOTreeType::New();
PostOrderItType it(tree);
return EXIT_SUCCESS;
}
Basically if you try to use a PostOrderTreeIterator with a
SpatialObjectTreeContainer, you get compile errors (see at end of message).
The problem is subtle, and difficult for me to see how to fix:
itkSpatialObjectTreeContainer defines TreeNodeType as
typedef SpatialObjectTreeNode< TDimension > TreeNodeType;
but its parent class, TreeContainer defines TreeNodeType as
typedef TreeNode< ValueType > TreeNodeType;
The problem is that PostOrderTreeIterator<SpatialObjectTreeContainer<3> >
assumes that TreeContainer::TreeNodeType and
SpatialObjectTreeNodeContainer::TreeNodeType are assignment compatible.
Unfortunately C++ compilers (in my case g++-4.2.1) don't agree.
I've tried a couple of workarounds, but the only thing that seems to work
without causing test regressions is to use reinterpret_cast, which is the
solution of last resort.
I've pushed a patch to Gerrit that fixes the problem, but I think there
must be
a more elegant way to fix the issue.
PATCH: http://review.source.kitware.com/#change,1939
COMPILER ERRORS:
Building CXX object
Modules/Core/SpatialObjects/test/CMakeFiles/ITK-SpatialObjectsTestDriver.di
r/itkSpatialObjectTreeContainerIteratorTest.cxx.o
Modules/Core/Common/include/itkPostOrderTreeIterator.h: In constructor
'itk::PostOrderTreeIterator<TTreeType>::PostOrderTreeIterator(TTreeType*)
[with TTreeType = itk::SpatialObjectTreeContainer<3u>]':
Modules/Core/SpatialObjects/test/itkSpatialObjectTreeContainerIteratorTest.
cxx:36: instantiated from here
Modules/Core/Common/include/itkPostOrderTreeIterator.h:68: error: invalid
conversion from 'itk::TreeNode<itk::SpatialObject<3u>*>*' to
'itk::SpatialObjectTreeNode<3u>*'
Modules/Core/Common/include/itkPostOrderTreeIterator.h: In member function
'const typename itk::PostOrderTreeIterator<TTreeType>::TreeNodeType*
itk::PostOrderTreeIterator<TTreeType>::FindMostRightLeaf(typename
itk::TreeIteratorBase<TTreeType>::TreeNodeType*) const [with TTreeType =
itk::SpatialObjectTreeContainer<3u>]':
Modules/Core/Common/include/itkPostOrderTreeIterator.h:76: instantiated
from
'itk::PostOrderTreeIterator<TTreeType>::PostOrderTreeIterator(TTreeType*)
[with TTreeType = itk::SpatialObjectTreeContainer<3u>]'
Modules/Core/SpatialObjects/test/itkSpatialObjectTreeContainerIteratorTest.
cxx:36: instantiated from here
Modules/Core/Common/include/itkPostOrderTreeIterator.h:169: error: invalid
conversion from 'itk::TreeNode<itk::SpatialObject<3u>*>*' to
'itk::SpatialObjectTreeNode<3u>*'
Modules/Core/Common/include/itkPostOrderTreeIterator.h: In member function
'const typename itk::PostOrderTreeIterator<TTreeType>::TreeNodeType*
itk::PostOrderTreeIterator<TTreeType>::FindNextNode() const [with
TTreeType = itk::SpatialObjectTreeContainer<3u>]':
Modules/Core/Common/include/itkPostOrderTreeIterator.h:94: instantiated
from 'bool itk::PostOrderTreeIterator<TTreeType>::HasNext() const [with
TTreeType = itk::SpatialObjectTreeContainer<3u>]'
Modules/Core/SpatialObjects/test/itkSpatialObjectTreeContainerIteratorTest.
cxx:37: instantiated from here
Modules/Core/Common/include/itkPostOrderTreeIterator.h:126: error: invalid
conversion from 'itk::TreeNode<itk::SpatialObject<3u>*>*' to 'const
itk::SpatialObjectTreeNode<3u>*'
Modules/Core/Common/include/itkPostOrderTreeIterator.h: In member function
'const typename itk::PostOrderTreeIterator<TTreeType>::TreeNodeType*
itk::PostOrderTreeIterator<TTreeType>::FindSister(typename
itk::TreeIteratorBase<TTreeType>::TreeNodeType*) const [with TTreeType =
itk::SpatialObjectTreeContainer<3u>]':
Modules/Core/Common/include/itkPostOrderTreeIterator.h:119: instantiated
from 'const typename itk::PostOrderTreeIterator<TTreeType>::TreeNodeType*
itk::PostOrderTreeIterator<TTreeType>::FindNextNode() const [with
TTreeType = itk::SpatialObjectTreeContainer<3u>]'
Modules/Core/Common/include/itkPostOrderTreeIterator.h:94: instantiated
from 'bool itk::PostOrderTreeIterator<TTreeType>::HasNext() const [with
TTreeType = itk::SpatialObjectTreeContainer<3u>]'
Modules/Core/SpatialObjects/test/itkSpatialObjectTreeContainerIteratorTest.
cxx:37: instantiated from here
Modules/Core/Common/include/itkPostOrderTreeIterator.h:139: error: invalid
conversion from 'itk::TreeNode<itk::SpatialObject<3u>*>*' to
'itk::SpatialObjectTreeNode<3u>*'
Modules/Core/Common/include/itkPostOrderTreeIterator.h:145: error: invalid
conversion from 'itk::TreeNode<itk::SpatialObject<3u>*>*' to
'itk::SpatialObjectTreeNode<3u>*'
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
More information about the Insight-developers
mailing list