]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/DataObjects/BoundingBox.cxx
...
[cpPlugins.git] / lib / cpPlugins / DataObjects / BoundingBox.cxx
index 0a0480c3dab4f2792c83af00de90b8772d72850b..4a81b0b6a578c12250f7ba7b9f4fd755f6185ece 100644 (file)
@@ -10,44 +10,7 @@ SetDataObject( DataObject* o )
   auto v = o->GetVTK< vtkObjectBase >( );
   if( v != NULL )      this->SetVTK( v );
   else if( i != NULL ) this->SetITK( i );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObjects::BoundingBox::
-SetITK( itk::LightObject* o )
-{
-  bool     r = this->_ITKImage< 1 >( o );
-  if( !r ) r = this->_ITKImage< 2 >( o );
-  if( !r ) r = this->_ITKImage< 3 >( o );
-  if( !r ) r = this->_ITKImage< 4 >( o );
-  if( !r ) r = this->_ITKPointSet< float, 2 >( o );
-  if( !r ) r = this->_ITKPointSet< double, 2 >( o );
-  if( !r ) r = this->_ITKPointSet< float, 3 >( o );
-  if( !r ) r = this->_ITKPointSet< double, 3 >( o );
-  if( r )
-    this->_UpdateVTK( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::DataObjects::BoundingBox::
-SetVTK( vtkObjectBase* o )
-{
-  auto ds = dynamic_cast< vtkDataSet* >( o );
-  if( ds != NULL )
-  {
-    double bounds[ 6 ];
-    ds->GetBounds( bounds );
-    this->m_Points[ 0 ].clear( );
-    this->m_Points[ 1 ].clear( );
-    this->m_Points[ 0 ].push_back( bounds[ 0 ] );
-    this->m_Points[ 1 ].push_back( bounds[ 1 ] );
-    this->m_Points[ 0 ].push_back( bounds[ 2 ] );
-    this->m_Points[ 1 ].push_back( bounds[ 3 ] );
-    this->m_Points[ 0 ].push_back( bounds[ 4 ] );
-    this->m_Points[ 1 ].push_back( bounds[ 5 ] );
-    this->_UpdateVTK( );
-
-  } // fi
+  this->_UpdateVTK( );
 }
 
 // -------------------------------------------------------------------------
@@ -80,6 +43,7 @@ Blend( Self* other )
     if( other->m_Points[ 1 ][ d ] > this->m_Points[ 1 ][ d ] )
       this->m_Points[ 1 ][ d ] = other->m_Points[ 1 ][ d ];
   this->Modified( );
+  this->_UpdateVTK( );
 }
 
 // -------------------------------------------------------------------------
@@ -103,17 +67,22 @@ cpPlugins::DataObjects::BoundingBox::
 void cpPlugins::DataObjects::BoundingBox::
 _UpdateVTK( )
 {
+  auto dobj = this->GetVTK< vtkDataSet >( );
+  if( dobj == NULL )
+    return;
+
   // Get bounds
-  double bounds[ 6 ] = { 0 };
-  unsigned int dim = this->m_Points[ 0 ].size( );
-  dim = ( this->m_Points[ 1 ].size( ) < dim )? this->m_Points[ 1 ].size( ): dim;
-  dim = ( dim < 3 )? dim: 3;
-  for( unsigned int d = 0; d < dim; ++d )
-  {
-    bounds[ d << 1 ] = this->m_Points[ 0 ][ d ];
-    bounds[ ( d << 1 ) + 1 ] = this->m_Points[ 1 ][ d ];
+  double bounds[ 6 ];
+  dobj->GetBounds( bounds );
 
-  } // rof
+  this->m_Points[ 0 ].clear( );
+  this->m_Points[ 1 ].clear( );
+  this->m_Points[ 0 ].push_back( bounds[ 0 ] );
+  this->m_Points[ 0 ].push_back( bounds[ 2 ] );
+  this->m_Points[ 0 ].push_back( bounds[ 4 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 1 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 3 ] );
+  this->m_Points[ 1 ].push_back( bounds[ 5 ] );
 
   // Update vtk objects
   this->m_Outline->SetBounds( bounds );