17 #ifndef __itkPointSetToImageFilter_txx
18 #define __itkPointSetToImageFilter_txx
22 #include <itkNumericTraits.h>
28 template <
class TInputPo
intSet,
class TOutputImage>
32 this->SetNumberOfRequiredInputs(1);
36 m_Direction.SetIdentity();
37 m_InsideValue = NumericTraits< ValueType >::OneValue();
38 m_OutsideValue = NumericTraits< ValueType >::ZeroValue();
42 template <
class TInputPo
intSet,
class TOutputImage>
50 template <
class TInputPo
intSet,
class TOutputImage>
57 const_cast< InputPointSetType * >( input ) );
62 template <
class TInputPo
intSet,
class TOutputImage>
65 ::SetInput(
unsigned int index,
const TInputPointSet * pointset )
69 const_cast< TInputPointSet *>( pointset ) );
73 template <
class TInputPo
intSet,
class TOutputImage>
78 if (this->GetNumberOfInputs() < 1)
83 return static_cast<const TInputPointSet *
>
88 template <
class TInputPo
intSet,
class TOutputImage>
93 return static_cast< const TInputPointSet *
>
97 template <
class TInputPo
intSet,
class TOutputImage>
104 spacing.CastFrom(vf);
105 this->SetSpacing(spacing);
108 template <
class TInputPo
intSet,
class TOutputImage>
114 this->SetSpacing(spacing);
117 template <
class TInputPo
intSet,
class TOutputImage>
125 this->SetOrigin(origin);
128 template <
class TInputPo
intSet,
class TOutputImage>
134 this->SetOrigin(origin);
140 template <
class TInputPo
intSet,
class TOutputImage>
146 itkDebugMacro(<<
"PointSetToImageFilter::Update() called");
153 double origin[InputPointSetDimension];
156 typedef typename InputPointSetType::BoundingBoxType BoundingBoxType;
157 const BoundingBoxType * bb = InputPointSet->GetBoundingBox();
159 for(i=0;i<InputPointSetDimension;i++)
161 size[i] = (
unsigned long)(bb->GetBounds()[2*i+1]-bb->GetBounds()[2*i]);
166 typename OutputImageType::RegionType region;
172 bool specified =
false;
173 for (i = 0; i < OutputImageDimension; i++)
184 region.SetSize( m_Size );
188 region.SetSize( size );
191 OutputImage->SetRegions( region);
198 for (i = 0; i < OutputImageDimension; i++)
200 if (m_Spacing[i] != 0)
209 OutputImage->SetSpacing(this->m_Spacing);
214 for (i = 0; i < OutputImageDimension; i++)
216 if (m_Origin[i] != 0)
225 for (i = 0; i < OutputImageDimension; i++)
227 origin[i] = m_Origin[i];
231 OutputImage->SetOrigin(origin);
232 OutputImage->SetDirection(m_Direction);
233 OutputImage->Allocate();
234 OutputImage->FillBuffer(m_OutsideValue);
236 typedef typename InputPointSetType::PointsContainer::ConstIterator PointIterator;
237 PointIterator pointItr = InputPointSet->GetPoints()->Begin();
238 PointIterator pointEnd = InputPointSet->GetPoints()->End();
240 typename OutputImageType::IndexType index;
242 while( pointItr != pointEnd )
244 if(OutputImage->TransformPhysicalPointToIndex(pointItr.Value(),index))
246 OutputImage->SetPixel(index,m_InsideValue);
251 itkDebugMacro(<<
"PointSetToImageFilter::Update() finished");
256 template<
class TInputPo
intSet,
class TOutputImage>
261 Superclass::PrintSelf(os, indent);
262 os << indent <<
"Size : " << m_Size << std::endl;
263 os << indent <<
"Origin: " << m_Origin << std::endl;
264 os << indent <<
"Spacing: " << m_Spacing << std::endl;
265 os << indent <<
"Direction: " << m_Direction << std::endl;
266 os << indent <<
"Inside Value : "
267 <<
static_cast<typename NumericTraits<ValueType>::PrintType
>(m_InsideValue)
269 os << indent <<
"Outside Value : "
270 <<
static_cast<typename NumericTraits<ValueType>::PrintType
>(m_OutsideValue)