]> 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
33       void Copy( Self* other );
34       void Blend( Self* other );
35
36       template< class _TPoint >
37       inline void SetMinimum( const _TPoint& p )
38         {
39           this->_SetPoint( 0, p );
40         }
41
42       template< class _TPoint >
43       inline void SetMaximum( const _TPoint& p )
44         {
45           this->_SetPoint( 1, p );
46         }
47
48       template< class _TPoint >
49       inline _TPoint GetMinimum( ) const
50         {
51           return( this->_GetPoint< _TPoint >( 0 ) );
52         }
53
54       template< class _TPoint >
55       inline _TPoint GetMaximum( ) const
56         {
57           return( this->_GetPoint< _TPoint >( 1 ) );
58         }
59
60     protected:
61       BoundingBox( );
62       virtual ~BoundingBox( );
63
64       void _UpdateVTK( );
65
66       template< class _TPoint >
67       inline void _SetPoint( unsigned int m, const _TPoint& p )
68         {
69           this->m_Points[ m ].clear( );
70           for( unsigned int d = 0; d < _TPoint::PointDimension; ++d )
71             this->m_Points[ m ].push_back( double( p[ d ] ) );
72           this->_UpdateVTK( );
73           this->Modified( );
74         }
75
76       template< class _TPoint >
77       inline _TPoint _GetPoint( unsigned int m ) const
78         {
79           unsigned int dim = this->m_Points[ m ].size( );
80           dim =
81             ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim;
82           _TPoint p;
83           p.Fill( 0 );
84           for( unsigned int d = 0; d < dim; ++d )
85             p[ d ] = this->m_Points[ m ][ d ];
86           return( p );
87         }
88
89     private:
90       // Purposely not implemented
91       BoundingBox( const Self& );
92       Self& operator=( const Self& );
93
94     protected:
95       std::vector< double > m_Points[ 2 ];
96       vtkSmartPointer< vtkOutlineSource > m_Outline;
97     };
98
99   } // ecapseman
100
101 } // ecapseman
102
103 // #include <cpPlugins/DataObjects/BoundingBox.hxx>
104
105 #endif // __cpPlugins__DataObjects__BoundingBox__h__
106
107 // eof - $RCSfile$