]> Creatis software - cpPlugins.git/blobdiff - lib/cpInstances/DataObjects/BoundingBox.h
yet another refactoring
[cpPlugins.git] / lib / cpInstances / DataObjects / BoundingBox.h
diff --git a/lib/cpInstances/DataObjects/BoundingBox.h b/lib/cpInstances/DataObjects/BoundingBox.h
new file mode 100644 (file)
index 0000000..dfe1300
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef __cpInstances__BoundingBox__h__
+#define __cpInstances__BoundingBox__h__
+
+#define ITK_MANUAL_INSTANTIATION
+#include <cpInstances/cpPluginsDataObjects_Export.h>
+#include <vector>
+#include <cpPlugins/Pipeline/DataObject.h>
+#include <vtkOutlineSource.h>
+#include <vtkSmartPointer.h>
+
+namespace cpInstances
+{
+  namespace DataObjects
+  {
+    /**
+     */
+    class cpPluginsDataObjects_EXPORT BoundingBox
+      : public cpPlugins::Pipeline::DataObject
+    {
+    public:
+      typedef BoundingBox                     Self;
+      typedef cpPlugins::Pipeline::DataObject Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( BoundingBox, DataObject );
+      cpPlugins_Id_Macro( BoundingBox, Object );
+      cpPlugins_Compatibility_Macro;
+
+    public:
+      void SetDataObject( DataObject* o );
+
+      void Copy( Self* other );
+      void Blend( Self* other );
+
+      template< class _TPoint >
+      inline void SetMinimum( const _TPoint& p )
+        {
+          this->_SetPoint( 0, p );
+        }
+
+      template< class _TPoint >
+      inline void SetMaximum( const _TPoint& p )
+        {
+          this->_SetPoint( 1, p );
+        }
+
+      template< class _TPoint >
+      inline _TPoint GetMinimum( ) const
+        {
+          return( this->_GetPoint< _TPoint >( 0 ) );
+        }
+
+      template< class _TPoint >
+      inline _TPoint GetMaximum( ) const
+        {
+          return( this->_GetPoint< _TPoint >( 1 ) );
+        }
+
+    protected:
+      BoundingBox( );
+      virtual ~BoundingBox( );
+
+      void _UpdateVTK( );
+
+      template< class _TPoint >
+      inline void _SetPoint( unsigned int m, const _TPoint& p )
+        {
+          this->m_Points[ m ].clear( );
+          for( unsigned int d = 0; d < _TPoint::PointDimension; ++d )
+            this->m_Points[ m ].push_back( double( p[ d ] ) );
+          this->_UpdateVTK( );
+          this->Modified( );
+        }
+
+      template< class _TPoint >
+      inline _TPoint _GetPoint( unsigned int m ) const
+        {
+          unsigned int dim = this->m_Points[ m ].size( );
+          dim =
+            ( _TPoint::PointDimension < dim )? _TPoint::PointDimension: dim;
+          _TPoint p;
+          p.Fill( 0 );
+          for( unsigned int d = 0; d < dim; ++d )
+            p[ d ] = this->m_Points[ m ][ d ];
+          return( p );
+        }
+
+    private:
+      // Purposely not implemented
+      BoundingBox( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      std::vector< double > m_Points[ 2 ];
+      vtkSmartPointer< vtkOutlineSource > m_Outline;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __cpInstances__BoundingBox__h__
+
+// eof - $RCSfile$