1 #ifndef __CPM__VTK__POLYDATATOMESHFILTER__HXX__
2 #define __CPM__VTK__POLYDATATOMESHFILTER__HXx__
4 #include <itkPolygonCell.h>
7 // -------------------------------------------------------------------------
9 const vtkPolyData* cpm::VTK::PolyDataToMeshFilter< M >::
12 return( this->m_Input );
15 // -------------------------------------------------------------------------
17 void cpm::VTK::PolyDataToMeshFilter< M >::
18 SetInput( const vtkPolyData* input )
20 if( this->m_Input != input )
22 this->m_Input = input;
28 // -------------------------------------------------------------------------
30 cpm::VTK::PolyDataToMeshFilter< M >::
31 PolyDataToMeshFilter( )
37 // -------------------------------------------------------------------------
39 cpm::VTK::PolyDataToMeshFilter< M >::
40 ~PolyDataToMeshFilter( )
44 // -------------------------------------------------------------------------
46 void cpm::VTK::PolyDataToMeshFilter< M >::
49 typedef typename M::PixelType _TScalar;
50 typedef itk::PolygonCell< typename M::CellType > _TPolygonCell;
52 vtkPolyData* in = const_cast< vtkPolyData* >( this->m_Input );
53 typename M::Pointer out = this->GetOutput( );
60 typename M::PointType ipnt;
61 for( unsigned long pId = 0; pId < in->GetNumberOfPoints( ); ++pId )
63 in->GetPoint( pId, vpnt );
64 ipnt.Fill( _TScalar( 0 ) );
65 if( M::PointDimension > 0 ) ipnt[ 0 ] = _TScalar( vpnt[ 0 ] );
66 if( M::PointDimension > 1 ) ipnt[ 1 ] = _TScalar( vpnt[ 1 ] );
67 if( M::PointDimension > 2 ) ipnt[ 2 ] = _TScalar( vpnt[ 2 ] );
68 out->SetPoint( pId, ipnt );
73 for( unsigned long cId = 0; cId < in->GetNumberOfCells( ); ++cId )
75 vtkCell* vcell = in->GetCell( cId );
76 unsigned int nPoints = vcell->GetNumberOfPoints( );
80 typename M::CellAutoPointer cell;
81 _TPolygonCell* face = new _TPolygonCell( );
82 for( unsigned int k = 0; k < nPoints; ++k )
83 face->AddPointId( vcell->GetPointId( k ) );
84 cell.TakeOwnership( face );
85 out->SetCell( out->GetNumberOfCells( ), cell );
92 #endif // __CPM__VTK__POLYDATATOMESHFILTER__HXX__