1 #include <cpInstances/BoundingBox.h>
3 #include <vtkDataSet.h>
5 // -------------------------------------------------------------------------
6 void cpInstances::BoundingBox::
7 SetDataObject( DataObject* o )
9 auto i = o->GetITK< itk::LightObject >( );
10 auto v = o->GetVTK< vtkObjectBase >( );
11 if( v != NULL ) this->SetVTK( v );
12 else if( i != NULL ) this->SetITK( i );
16 // -------------------------------------------------------------------------
17 void cpInstances::BoundingBox::
20 this->m_Points[ 0 ] = other->m_Points[ 0 ];
21 this->m_Points[ 1 ] = other->m_Points[ 1 ];
25 // -------------------------------------------------------------------------
26 void cpInstances::BoundingBox::
29 if( this->m_Points[ 0 ].size( ) < other->m_Points[ 0 ].size( ) )
30 this->m_Points[ 0 ].resize(
31 other->m_Points[ 0 ].size( ),
32 std::numeric_limits< double >::max( )
34 if( this->m_Points[ 1 ].size( ) < other->m_Points[ 1 ].size( ) )
35 this->m_Points[ 1 ].resize(
36 other->m_Points[ 1 ].size( ),
37 -std::numeric_limits< double >::max( )
39 for( unsigned int d = 0; d < this->m_Points[ 0 ].size( ); ++d )
40 if( other->m_Points[ 0 ][ d ] < this->m_Points[ 0 ][ d ] )
41 this->m_Points[ 0 ][ d ] = other->m_Points[ 0 ][ d ];
42 for( unsigned int d = 0; d < this->m_Points[ 1 ].size( ); ++d )
43 if( other->m_Points[ 1 ][ d ] > this->m_Points[ 1 ][ d ] )
44 this->m_Points[ 1 ][ d ] = other->m_Points[ 1 ][ d ];
49 // -------------------------------------------------------------------------
50 cpInstances::BoundingBox::
54 this->m_Points[ 0 ].push_back( double( 0 ) );
55 this->m_Points[ 1 ].push_back( double( 0 ) );
56 this->m_Outline = vtkSmartPointer< vtkOutlineSource >::New( );
60 // -------------------------------------------------------------------------
61 cpInstances::BoundingBox::
66 // -------------------------------------------------------------------------
67 void cpInstances::BoundingBox::
70 auto dobj = this->GetVTK< vtkDataSet >( );
76 dobj->GetBounds( bounds );
78 this->m_Points[ 0 ].clear( );
79 this->m_Points[ 1 ].clear( );
80 this->m_Points[ 0 ].push_back( bounds[ 0 ] );
81 this->m_Points[ 0 ].push_back( bounds[ 2 ] );
82 this->m_Points[ 0 ].push_back( bounds[ 4 ] );
83 this->m_Points[ 1 ].push_back( bounds[ 1 ] );
84 this->m_Points[ 1 ].push_back( bounds[ 3 ] );
85 this->m_Points[ 1 ].push_back( bounds[ 5 ] );
88 this->m_Outline->SetBounds( bounds );
89 this->m_Outline->Update( );
90 this->m_VTK = this->m_Outline->GetOutput( );