#include #include #include // ------------------------------------------------------------------------- void cpInstances::DataObjects::BoundingBox:: SetDataObject( DataObject* o ) { auto i = o->GetITK< itk::LightObject >( ); auto v = o->GetVTK< vtkObjectBase >( ); if( v != NULL ) this->SetVTK( v ); else if( i != NULL ) this->SetITK( i ); this->_UpdateVTK( ); } // ------------------------------------------------------------------------- void cpInstances::DataObjects::BoundingBox:: Copy( Self* other ) { this->m_Points[ 0 ] = other->m_Points[ 0 ]; this->m_Points[ 1 ] = other->m_Points[ 1 ]; this->Modified( ); } // ------------------------------------------------------------------------- void cpInstances::DataObjects::BoundingBox:: Blend( Self* other ) { if( this->m_Points[ 0 ].size( ) < other->m_Points[ 0 ].size( ) ) this->m_Points[ 0 ].resize( other->m_Points[ 0 ].size( ), std::numeric_limits< double >::max( ) ); if( this->m_Points[ 1 ].size( ) < other->m_Points[ 1 ].size( ) ) this->m_Points[ 1 ].resize( other->m_Points[ 1 ].size( ), -std::numeric_limits< double >::max( ) ); for( unsigned int d = 0; d < this->m_Points[ 0 ].size( ); ++d ) if( other->m_Points[ 0 ][ d ] < this->m_Points[ 0 ][ d ] ) this->m_Points[ 0 ][ d ] = other->m_Points[ 0 ][ d ]; for( unsigned int d = 0; d < this->m_Points[ 1 ].size( ); ++d ) 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( ); } // ------------------------------------------------------------------------- cpInstances::DataObjects::BoundingBox:: BoundingBox( ) : Superclass( ) { this->m_Points[ 0 ].push_back( double( 0 ) ); this->m_Points[ 1 ].push_back( double( 0 ) ); this->m_Outline = vtkSmartPointer< vtkOutlineSource >::New( ); this->_UpdateVTK( ); } // ------------------------------------------------------------------------- cpInstances::DataObjects::BoundingBox:: ~BoundingBox( ) { } // ------------------------------------------------------------------------- void cpInstances::DataObjects::BoundingBox:: _UpdateVTK( ) { auto dobj = this->GetVTK< vtkDataSet >( ); if( dobj == NULL ) return; // Get bounds double bounds[ 6 ]; dobj->GetBounds( bounds ); 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 ); this->m_Outline->Update( ); this->m_VTK = this->m_Outline->GetOutput( ); } // eof - $RCSfile$