[Insight-developers] Initialization question
Hans Johnson
hans-johnson at uiowa.edu
Thu Feb 26 09:38:21 EST 2009
I was reviewing the code in itkImageBase and I think I found a possible
un-initialized memory location.
Should line 176 be change to:
scale.Fill(0.0);
In order to ensure that the matrix is has zeros on the off diagonal
locations? Or is it guaranteed that the constructor for itkMarix will zero
out all the memory locations?
If the constructor does zero out the memory, then a comment to that effect
would be nice. This just did not look correct since in most places when
declaring a multi-element entity where only some of the elements are
touched, it is common to have the myvar.Fill(0.0) immediately after the
declaration.
Hans
169
//--------------------------------------------------------------------------
--
170 template<unsigned int VImageDimension>
171 void
172 ImageBase<VImageDimension>
173 ::ComputeIndexToPhysicalPointMatrices()
174 {
175 DirectionType scale;
176
177 for (unsigned int i=0; i < VImageDimension; i++)
178 {
179 if (this->m_Spacing[i] == 0.0)
180 {
181 itkExceptionMacro("A spacing of 0 is not allowed: Spacing is " <<
this->m_Spacing);
182 }
183 scale[i][i] = this->m_Spacing[i];
184 }
185
186 if (vnl_determinant(this->m_Direction.GetVnlMatrix()) == 0.0)
187 {
188 itkExceptionMacro(<< "Bad direction, determinant is 0. Direction is
" << this->m_Direction);
189 }
190
191 this->m_IndexToPhysicalPoint = this->m_Direction * scale;
192 this->m_PhysicalPointToIndex = m_IndexToPhysicalPoint.GetInverse();
193
194 this->Modified();
195 }
--
Hans J. Johnson, Ph.D.
Hans-johnson at uiowa.edu
278 GH
The University of Iowa
Iowa City, IA 52241
(319) 353 8587
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