]> Creatis software - cpPlugins.git/blob - lib/cpInstances/DataObjects/BoundingBox.h
...
[cpPlugins.git] / lib / cpInstances / DataObjects / BoundingBox.h
1 #ifndef __cpInstances__BoundingBox__h__
2 #define __cpInstances__BoundingBox__h__
3
4 #define ITK_MANUAL_INSTANTIATION
5 #include <cpInstances/cpPluginsDataObjects_Export.h>
6 #include <vector>
7 #include <cpPlugins/Pipeline/DataObject.h>
8 #include <vtkOutlineSource.h>
9 #include <vtkSmartPointer.h>
10
11 namespace cpInstances
12 {
13   namespace DataObjects
14   {
15     /**
16      */
17     class cpPluginsDataObjects_EXPORT BoundingBox
18       : public cpPlugins::Pipeline::DataObject
19     {
20     public:
21       typedef BoundingBox                     Self;
22       typedef cpPlugins::Pipeline::DataObject Superclass;
23       typedef itk::SmartPointer< Self >       Pointer;
24       typedef itk::SmartPointer< const Self > ConstPointer;
25
26     public:
27       itkNewMacro( Self );
28       itkTypeMacro( BoundingBox, DataObject );
29       cpPlugins_Id_Macro( BoundingBox, Object );
30       cpPlugins_Compatibility_Macro;
31
32     public:
33       void SetDataObject( DataObject* o );
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     private:
92       // Purposely not implemented
93       BoundingBox( const Self& );
94       Self& operator=( const Self& );
95
96     protected:
97       std::vector< double > m_Points[ 2 ];
98       vtkSmartPointer< vtkOutlineSource > m_Outline;
99     };
100
101   } // ecapseman
102
103 } // ecapseman
104
105 #endif // __cpInstances__BoundingBox__h__
106
107 // eof - $RCSfile$