30 #ifndef __itkTransformToDeformationFieldSource_txx
31 #define __itkTransformToDeformationFieldSource_txx
45 template <
class TOutputImage,
class TTransformPrecisionType>
49 this->m_OutputSpacing.Fill(1.0);
50 this->m_OutputOrigin.Fill(0.0);
51 this->m_OutputDirection.SetIdentity();
55 this->m_OutputRegion.SetSize( size );
59 this->m_OutputRegion.SetIndex( index );
70 template <
class TOutputImage,
class TTransformPrecisionType>
75 Superclass::PrintSelf( os, indent );
77 os << indent <<
"OutputRegion: " << this->m_OutputRegion << std::endl;
78 os << indent <<
"OutputSpacing: " << this->m_OutputSpacing << std::endl;
79 os << indent <<
"OutputOrigin: " << this->m_OutputOrigin << std::endl;
80 os << indent <<
"OutputDirection: " << this->m_OutputDirection << std::endl;
81 os << indent <<
"Transform: " << this->m_Transform.GetPointer() << std::endl;
87 template <
class TOutputImage,
class TTransformPrecisionType>
92 this->m_OutputRegion.SetSize( size );
98 template <
class TOutputImage,
class TTransformPrecisionType>
100 TTransformPrecisionType>
105 return this->m_OutputRegion.GetSize();
111 template <
class TOutputImage,
class TTransformPrecisionType>
116 this->m_OutputRegion.SetIndex( index );
122 template <
class TOutputImage,
class TTransformPrecisionType>
124 TTransformPrecisionType>
129 return this->m_OutputRegion.GetIndex();
135 template <
class TOutputImage,
class TTransformPrecisionType>
142 this->SetOutputSpacing( s );
148 template <
class TOutputImage,
class TTransformPrecisionType>
155 this->SetOutputOrigin( p );
159 template <
class TOutputImage,
class TTransformPrecisionType>
166 itkExceptionMacro(<<
"Cannot use a null image reference");
169 this->SetOutputOrigin( image->
GetOrigin() );
170 this->SetOutputSpacing( image->
GetSpacing() );
180 template <
class TOutputImage,
class TTransformPrecisionType>
185 if ( !this->m_Transform )
187 itkExceptionMacro(<<
"Transform not set");
194 template <
class TOutputImage,
class TTransformPrecisionType>
204 if ( this->m_Transform->IsLinear() )
206 this->LinearThreadedGenerateData( outputRegionForThread, threadId );
212 this->NonlinearThreadedGenerateData( outputRegionForThread, threadId );
215 template <
class TOutputImage,
class TTransformPrecisionType>
227 OutputIteratorType outIt( outputPtr, outputRegionForThread );
237 outputRegionForThread.GetNumberOfPixels() );
241 while ( !outIt.IsAtEnd() )
244 outputPtr->TransformIndexToPhysicalPoint( outIt.GetIndex(), outputPoint );
247 transformedPoint = this->m_Transform->TransformPoint( outputPoint );
250 for (
unsigned int i = 0; i < ImageDimension; ++i )
253 transformedPoint[i] - outputPoint[i] );
257 outIt.Set( deformation );
265 template <
class TOutputImage,
class TTransformPrecisionType>
277 OutputIteratorType outIt( outputPtr, outputRegionForThread );
279 outIt.SetDirection( 0 );
291 outputRegionForThread.GetNumberOfPixels() );
295 index = outIt.GetIndex();
296 outputPtr->TransformIndexToPhysicalPoint( index, outputPoint );
299 transformedPoint = this->m_Transform->TransformPoint( outputPoint );
309 outputPtr->TransformIndexToPhysicalPoint( index, outputPointNeighbour );
310 transformedPointNeighbour = this->m_Transform->TransformPoint(
311 outputPointNeighbour );
312 delta = transformedPointNeighbour - transformedPoint
313 - ( outputPointNeighbour - outputPoint );
316 while ( !outIt.IsAtEnd() )
319 index = outIt.GetIndex();
320 outputPtr->TransformIndexToPhysicalPoint( index, outputPoint );
323 transformedPoint = this->m_Transform->TransformPoint( outputPoint );
325 while ( !outIt.IsAtEndOfLine() )
328 for (
unsigned int i = 0; i < ImageDimension; ++i )
331 transformedPoint[i] - outputPoint[i] );
335 outIt.Set( deformation );
338 progress.CompletedPixel();
340 transformedPoint += delta;
350 template <
class TOutputImage,
class TTransformPrecisionType>
356 Superclass::GenerateOutputInformation();
365 outputPtr->SetLargestPossibleRegion( m_OutputRegion );
367 outputPtr->SetSpacing( m_OutputSpacing );
368 outputPtr->SetOrigin( m_OutputOrigin );
369 outputPtr->SetDirection( m_OutputDirection );
375 template <
class TOutputImage,
class TTransformPrecisionType>
382 if ( this->m_Transform )
384 if ( latestTime < this->m_Transform->GetMTime() )
386 latestTime = this->m_Transform->GetMTime();
394 #endif // end #ifndef _itkTransformToDeformationFieldSource_txx