]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/PointList.hxx
95e9e1fa5a89db2c345fa01b9bf389427cee702e
[cpPlugins.git] / lib / cpPlugins / Interface / PointList.hxx
1 #ifndef __CPPLUGINS__INTERFACE__POINTLIST__HXX__
2 #define __CPPLUGINS__INTERFACE__POINTLIST__HXX__
3
4 #include <itkSimpleDataObjectDecorator.h>
5 #include <utility>
6 #include <vector>
7
8 // -------------------------------------------------------------------------
9 template< class P >
10 void cpPlugins::Interface::PointList::
11 AddPoint( const P& p )
12 {
13   typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
14
15   _T* container = NULL;
16   if( this->m_NumberOfPoints == 0 )
17   {
18     typename _T::Pointer obj = _T::New( );
19     container = obj.GetPointer( );
20     this->m_ITKObject = container;
21   }
22   else
23     container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
24
25   if( container != NULL )
26   {
27     container->Get( ).push_back( p );
28     this->m_NumberOfPoints += 1;
29
30   } // fi
31 }
32
33 // -------------------------------------------------------------------------
34 template< class P >
35 P cpPlugins::Interface::PointList::
36 GetPoint( const unsigned long& i ) const
37 {
38   typedef itk::SimpleDataObjectDecorator< std::vector< P > > _T;
39
40   P ret;
41   if( i < this->m_NumberOfPoints )
42   {
43     _T* container = dynamic_cast< _T* >( this->m_ITKObject.GetPointer( ) );
44     if( container != NULL )
45       ret = container->Get( )[ i ];
46     
47   } // fi
48   return( ret );
49 }
50
51 #endif // __CPPLUGINS__INTERFACE__POINTLIST__HXX__
52
53 // eof - $RCSfile$