<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello Emily,<div><br></div><div>This has recently been fixed in ITK:</div><div><a href="https://github.com/InsightSoftwareConsortium/ITK/commit/240b5568b641bb995ba01cbc338ddadffd95d5fa">https://github.com/InsightSoftwareConsortium/ITK/commit/240b5568b641bb995ba01cbc338ddadffd95d5fa</a></div><div><br></div><div>The return for GetTransformList is now a constant pointer:</div><div><br></div><div><span class="pl-s" style="box-sizing: border-box; color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16px; white-space: pre; background-color: rgb(234, 255, 234);">const</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16px; white-space: pre; background-color: rgb(234, 255, 234);"> TransformListType * </span><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16px; white-space: pre; background-color: rgb(234, 255, 234);">GetTransformList</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16px; white-space: pre; background-color: rgb(234, 255, 234);">()</span></div><div><div><br></div><div>Truthfully I am not sure why this method is returning a pointer and not a reference.</div><div><br></div><div>So the return should not be modified, which is your issue. The pointer is to an STL list managed by the reader.</div><div><br></div><div>The list is of itk::SmartPointers, so doing a copy should be light weight. So you should do something like:</div><div><br></div><div>TransformListType m_TransformList;</div><div><br></div><div>this->m_TransformList = *(reader->GetTranformList());</div><div><br></div><div>Brad</div><div><br><div><div>On Jan 28, 2015, at 10:36 AM, Hammond, Emily M <<a href="mailto:emily-hammond@uiowa.edu">emily-hammond@uiowa.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div fpstyle="1" ocsi="0" class=" hasGoogleVoiceExt" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="direction: ltr; font-family: Tahoma; font-size: 10pt;">Hello all,<div><br></div><div>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:</div><div><br></div><div><div>#include "itkTransform.h"</div><div>#include "itkTransformFileReader.h"</div></div><div><br></div><div>public:</div><div><div><span class="Apple-tab-span" style="white-space: pre;"></span>typedef itk::TransformFileReaderTemplate< double ><span class="Apple-tab-span" style="white-space: pre;">
</span>TransformReaderType;<span class="Apple-tab-span" style="white-space: pre;"> </span></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>typedef TransformReaderType::TransformListType<span class="Apple-tab-span" style="white-space: pre;">
</span>TransformListType;</div></div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>void ReadTransformFile( const char * transformFilename );</div><div><br></div><div>protected:</div><div><div><span class="Apple-tab-span" style="white-space: pre;"></span>LandmarkAnalysis()</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>{</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre;"></span><span style="font-size: 10pt;">TransformListType * m_TransformList = 0;</span></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>TransformListType * m_TransformListTemporary = 0;</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>}</div></div><div><br></div><div>private:</div><div><div><span class="Apple-tab-span" style="white-space: pre;"></span>TransformListType * m_TransformList;</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>TransformListType * m_TransformListTemporary;</div><div>};</div></div><div><br></div><div><br></div><div>.hxx file</div><div><div><span class="Apple-tab-span" style="white-space: pre;"></span>void LandmarkAnalysis::ReadTransformFile( const char * transformFilename )</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>{</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>TransformReaderType::Pointer reader = TransformReaderType::New();</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>reader->SetFileName( transformFilename );</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre;"></span><span style="font-size: 10pt;">reader->Update();</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>// put output into member variable</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>m_TransformListTemporary = reader->GetTransformList();</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>//(*m_TransformList).merge( *m_TransformListTemporary );</div><div><span class="Apple-tab-span" style="white-space: pre;"></span></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>// print out to prove that it was completed<span class="Apple-tab-span" style="white-space: pre;">
</span></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>TransformListType::const_iterator tempIt = m_TransformListTemporary->begin();</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre;"></span><span style="font-size: 10pt;">TransformListType::iterator it = m_TransformList->begin(); ***CODE BREAKS AT THIS LINE***</span></div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>for(; tempIt !=m_TransformListTemporary->end(); tempIt++)</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>{</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>std::cout << (*tempIt) << std::endl;</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>(*m_TransformList).insert(it, (*tempIt));</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>std::cout << transformFilename << " has been read in." << std::endl;</div><div><span class="Apple-tab-span" style="white-space: pre;"></span></div><div><span class="Apple-tab-span" style="white-space: pre;"></span>return;</div><div><span class="Apple-tab-span" style="white-space: pre;"></span>}</div></div><div><br></div><div>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. </div><div><br></div><div>Any help would be very much appreciated.</div><div><br></div><div>Emily Hammond</div></div>_____________________________________<br>Powered by<span class="Apple-converted-space"> </span><a href="http://www.kitware.com/">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><br>_______________________________________________<br>Community mailing list<br><a href="mailto:Community@itk.org">Community@itk.org</a><br><a href="http://public.kitware.com/mailman/listinfo/community">http://public.kitware.com/mailman/listinfo/community</a></div></blockquote></div><br></div></div></body></html>