[ITK-users] STL methods and ITK

Hammond, Emily M emily-hammond at uiowa.edu
Wed Jan 28 10:36:08 EST 2015


Hello all,

I am trying to wrap some functionality into a class. I am trying to write a function that reads in a transform file, however, I want it to take the list of transform pointers that it reads in and merge/insert them into an already existing list. Here is the relevant code with more details below it:

#include "itkTransform.h"
#include "itkTransformFileReader.h"

public:
typedef itk::TransformFileReaderTemplate< double > TransformReaderType;
typedef TransformReaderType::TransformListType TransformListType;

void ReadTransformFile( const char * transformFilename );

protected:
LandmarkAnalysis()
{
TransformListType * m_TransformList = 0;
TransformListType * m_TransformListTemporary = 0;
}

private:
TransformListType * m_TransformList;
TransformListType * m_TransformListTemporary;
};


.hxx file
void LandmarkAnalysis::ReadTransformFile( const char * transformFilename )
{
TransformReaderType::Pointer reader = TransformReaderType::New();
reader->SetFileName( transformFilename );
reader->Update();

// put output into member variable
m_TransformListTemporary = reader->GetTransformList();
//(*m_TransformList).merge( *m_TransformListTemporary );
// print out to prove that it was completed
TransformListType::const_iterator tempIt = m_TransformListTemporary->begin();
TransformListType::iterator it = m_TransformList->begin(); ***CODE BREAKS AT THIS LINE***

for(; tempIt !=m_TransformListTemporary->end(); tempIt++)
{
std::cout << (*tempIt) << std::endl;
(*m_TransformList).insert(it, (*tempIt));
}

std::cout << transformFilename << " has been read in." << std::endl;
return;
}

Here is my problem: I know that at the base level both m_TransformListTemporary and m_TransformList are lists of transform pointers. However, I cannot use any of the c++ stl list member functions such as merge or insert (I get runtime errors.) Is there some fundamental concept that I do not understand with how ITK interacts with the STL? In addition, through debugging, the line shown above instantiating an iterator for m_TransformList breaks the code, even though the previous line (which, to my understanding, does the same thing, but with a different list) works fine.

Any help would be very much appreciated.

Emily Hammond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150128/fcb2c36c/attachment.html>


More information about the Insight-users mailing list