]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/DataObjects/BoundingBox.h
...
[cpPlugins.git] / lib / cpPlugins / DataObjects / BoundingBox.h
1 #ifndef __cpPlugins__DataObjects__BoundingBox__h__
2 #define __cpPlugins__DataObjects__BoundingBox__h__
3
4 #include <vector>
5 #include <cpPlugins/BaseObjects/DataObject.h>
6 #include <vtkOutlineSource.h>
7 #include <vtkSmartPointer.h>
8
9 namespace cpPlugins
10 {
11   namespace DataObjects
12   {
13     /**
14      */
15     class cpPlugins_EXPORT BoundingBox
16       : public cpPlugins::BaseObjects::DataObject
17     {
18     public:
19       typedef BoundingBox                        Self;
20       typedef cpPlugins::BaseObjects::DataObject Superclass;
21       typedef itk::SmartPointer< Self >          Pointer;
22       typedef itk::SmartPointer< const Self >    ConstPointer;
23
24     public:
25       itkNewMacro( Self );
26       itkTypeMacro( BoundingBox, DataObject );
27       cpPlugins_Id_Macro( BoundingBox, Object );
28       cpPlugins_Compatibility_Macro;
29
30     public:
31       void SetDataObject( DataObject* o );
32       virtual void SetITK( itk::LightObject* o ) cpPlugins_OVERRIDE;
33       virtual void SetVTK( vtkObjectBase* o ) cpPlugins_OVERRIDE;
34
35       void Copy( Self* other );
36       void Blend( Self* other );
37
38       template< class _TPoint >
39       inline void SetMinimum( const _TPoint& p )
40         {
41           this->_SetPoint( 0, p );
42         }
43
44       template< class _TPoint >
45       inline void SetMaximum( const _TPoint& p )
46         {
47           this->_SetPoint( 1, p );
48         }
49
50       template< class _TPoint >
51       inline _TPoint GetMinimum( ) const
52         {
53           return( this->_GetPoint< _TPoint >( 0 ) );
54         }
55
56       template< class _TPoint >
57       inline _TPoint GetMaximum( ) const
58         {
59           return( this->_GetPoint< _TPoint >( 1 ) );
60         }
61
62     protected:
63       BoundingBox( );
64       virtual ~BoundingBox( );
65
66       void _UpdateVTK( );
67
68       template< class _TPoint >
69       inline void _SetPoint( unsigned int m, const _TPoint& p )
70         {
71           this->m_Points[ m ].clear( );
72           for( unsigned int d = 0; d < _TPoint::PointDimension; ++d )
73             this->m_Points[ m ].push_back( double( p[ d ] ) );
74           this->_UpdateVTK( );
75           this->Modified( );
76         }
77
78       template< class _TPoint >
79       inline _TPoint _GetPoint( unsigned int m ) const
80         {
81           unsigned int dim = this->m_Points[ m ].size( );
82           dim =
83             ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim;
84           _TPoint p;
85           p.Fill( 0 );
86           for( unsigned int d = 0; d < dim; ++d )
87             p[ d ] = this->m_Points[ m ][ d ];
88           return( p );
89         }
90
91       template< unsigned int _NDim >
92       inline bool _ITKImage( itk::LightObject* o );
93
94       template< class _TScalar, unsigned int _NDim >
95       inline bool _ITKPointSet( itk::LightObject* o );
96
97     private:
98       // Purposely not implemented
99       BoundingBox( const Self& );
100       Self& operator=( const Self& );
101
102     protected:
103       std::vector< double > m_Points[ 2 ];
104       vtkSmartPointer< vtkOutlineSource > m_Outline;
105     };
106
107   } // ecapseman
108
109 } // ecapseman
110
111 // #include <cpPlugins/DataObjects/BoundingBox.hxx>
112
113 #endif // __cpPlugins__DataObjects__BoundingBox__h__
114
115 // eof - $RCSfile$