Skip to content

Commit

Permalink
loading and visualization of megacapture OK
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://orchestra.med.harvard.edu/svn/megason/Code/GoFigure2@1720 ef826fda-c0ae-4237-af8e-f8dcbcf7929c
  • Loading branch information
Arnaud Gelas committed Nov 6, 2009
1 parent 4b6030b commit 8a72c76
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 123 deletions.
69 changes: 40 additions & 29 deletions branches/GoFigure2Beta/Code/GUI/lib/ContourStructureHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ FindContourGivenContourId(
{
std::list< ContourStructure > oList;

ContourStructureMultiIndexContainer::index< ContourId >::type::iterator
it = iContainer.get< ContourId >().find( iId );

if( it != iContainer.get< ContourId >().end() )
if( !iContainer.empty() )
{
while( it->ContourId == iId )
ContourStructureMultiIndexContainer::index< ContourId >::type::iterator
it = iContainer.get< ContourId >().find( iId );

if( it != iContainer.get< ContourId >().end() )
{
oList.push_back( *it );
++it;
while( it->ContourId == iId )
{
oList.push_back( *it );
++it;
}
}
}

Expand All @@ -31,51 +34,59 @@ FindContourGivenActor(
ContourStructureMultiIndexContainer iContainer,
vtkActor* iActor )
{
ContourStructureMultiIndexContainer::nth_index< 1 >::type::iterator
it = iContainer.get< 1 >().find( iActor );

if( it != iContainer.get< 1 >().end() )
if( !iContainer.empty() )
{
return (*it);
}
else
{
return ContourStructure();
ContourStructureMultiIndexContainer::nth_index< 1 >::type::iterator
it = iContainer.get< 1 >().find( iActor );

if( it != iContainer.get< 1 >().end() )
{
return (*it);
}
else
{
return ContourStructure();
}
}
return ContourStructure();
}

ContourStructure
FindContourGivenNodes(
ContourStructureMultiIndexContainer iContainer,
vtkPolyData* iNodes )
{
ContourStructureMultiIndexContainer::nth_index< 2 >::type::iterator
it = iContainer.get< 2 >().find( iNodes );

if( it != iContainer.get< 2 >().end() )
if( !iContainer.empty() )
{
return (*it);
}
else
{
return ContourStructure();
ContourStructureMultiIndexContainer::nth_index< 2 >::type::iterator
it = iContainer.get< 2 >().find( iNodes );

if( it != iContainer.get< 2 >().end() )
{
return (*it);
}
}
return ContourStructure();
}

std::list< ContourStructure >
FindContourGivenTimePoint(
ContourStructureMultiIndexContainer iContainer,
const unsigned int& iTimePoint )
{
ContourStructureMultiIndexContainer::index< TCoord >::type::iterator it0, it1;
boost::tuples::tie(it0,it1) = iContainer.get< TCoord >().equal_range( iTimePoint );
std::list< ContourStructure > oList;

std::list< ContourStructure > oList;
if( !iContainer.empty() )
{
ContourStructureMultiIndexContainer::index< TCoord >::type::iterator it0, it1;
boost::tuples::tie(it0,it1) = iContainer.get< TCoord >().equal_range( iTimePoint );

while( it0 != it1 )
{
oList.push_back( *it0 );
++it0;
}
return oList;
}

return oList;
}
151 changes: 113 additions & 38 deletions branches/GoFigure2Beta/Code/GUI/lib/QGoTabImageView3DwT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,14 @@ QGoTabImageView3DwT::
SetMegaCaptureFile(
const GoFigureFileInfoHelperMultiIndexContainer& iContainer,
const GoFigure::FileType& iFileType,
const std::string& iHeader,
const unsigned int& iTimePoint )
{
m_TimePoint = iTimePoint;
m_FileList = iContainer;
m_FileType = iFileType;

m_MegaCaptureReader->SetInput( m_FileList );
m_MegaCaptureReader->SetMegaCaptureHeader( iHeader );
m_MegaCaptureReader->SetFileType( m_FileType );
m_MegaCaptureReader->SetTimeBased( true );
m_MegaCaptureReader->SetTimePoint( iTimePoint );
Expand Down Expand Up @@ -447,10 +448,6 @@ SetMegaCaptureFile(
for( int i = 1; i < NumberOfChannels; i++ )
{
m_VisuDockWidget->SetChannel( i );

m_LSMReader.push_back( vtkLSMReader::New() );
m_LSMReader.back()->SetFileName( m_LSMReader[0]->GetFileName() );
m_LSMReader.back()->SetUpdateChannel( i );
}
}

Expand Down Expand Up @@ -517,7 +514,7 @@ SetTimePointWithMegaCapture( const int& iTimePoint )
unsigned int min_ch = m_MegaCaptureReader->GetMinChannel();
unsigned int max_ch = m_MegaCaptureReader->GetMaxChannel();

int NumberOfChannels = max_ch - min_ch;
int NumberOfChannels = max_ch - min_ch + 1;

if( NumberOfChannels > 1 )
{
Expand Down Expand Up @@ -681,8 +678,8 @@ SetTimePoint( const int& iTimePoint )
{
if( !m_FileList.empty() )
{
if( ( iTimePoint <= m_MegaCaptureReader->GetMinTimePoint() ) ||
( iTimePoint >= m_MegaCaptureReader->GetMaxTimePoint() ) )
if( ( iTimePoint < m_MegaCaptureReader->GetMinTimePoint() ) ||
( iTimePoint > m_MegaCaptureReader->GetMaxTimePoint() ) )
{
return;
}
Expand Down Expand Up @@ -968,51 +965,118 @@ void QGoTabImageView3DwT::ShowAllChannels( bool iChecked )
{
if( iChecked )
{
int NumberOfChannels = m_LSMReader[0]->GetNumberOfChannels();
if( !m_LSMReader.empty() )
{
int NumberOfChannels = m_LSMReader[0]->GetNumberOfChannels();

std::vector< vtkImageData* > temp_image( NumberOfChannels );
temp_image[0] = vtkImageData::New();
temp_image[0]->ShallowCopy( m_LSMReader[0]->GetOutput() );
std::vector< vtkImageData* > temp_image( NumberOfChannels );
temp_image[0] = vtkImageData::New();
temp_image[0]->ShallowCopy( m_LSMReader[0]->GetOutput() );

vtkImageAppendComponents* append_filter =
vtkImageAppendComponents::New();
append_filter->AddInput( temp_image[0] );
vtkImageAppendComponents* append_filter =
vtkImageAppendComponents::New();
append_filter->AddInput( temp_image[0] );

for( int i = 1; i < NumberOfChannels; i++ )
{
m_LSMReader[i]->SetUpdateTimePoint( m_TimePoint );
m_LSMReader[i]->Update();
for( int i = 1; i < NumberOfChannels; i++ )
{
m_LSMReader[i]->SetUpdateTimePoint( m_TimePoint );
m_LSMReader[i]->Update();

temp_image[i] = vtkImageData::New();
temp_image[i]->ShallowCopy( m_LSMReader[i]->GetOutput() );
append_filter->AddInput( temp_image[i] );
}
// This is really stupid!!!
if( NumberOfChannels < 3 )
{
for( int i = NumberOfChannels; i < 3; i++ )
temp_image[i] = vtkImageData::New();
temp_image[i]->ShallowCopy( m_LSMReader[i]->GetOutput() );
append_filter->AddInput( temp_image[i] );
}
// This is really stupid!!!
if( NumberOfChannels < 3 )
{
append_filter->AddInput( temp_image[0] );
for( int i = NumberOfChannels; i < 3; i++ )
{
append_filter->AddInput( temp_image[0] );
}
}
}
append_filter->Update();
append_filter->Update();

m_Image->ShallowCopy( append_filter->GetOutput() );
Update();
m_Image->ShallowCopy( append_filter->GetOutput() );
Update();

append_filter->Delete();
append_filter->Delete();

for( int i = 0; i < NumberOfChannels; i++ )
for( int i = 0; i < NumberOfChannels; i++ )
{
temp_image[i]->Delete();
}
}
else
{
temp_image[i]->Delete();
if( !m_FileList.empty() )
{
m_MegaCaptureReader->Update();

int NumberOfChannels = 1 +
m_MegaCaptureReader->GetMaxChannel() -
m_MegaCaptureReader->GetMinChannel();

std::vector< vtkImageData* > temp_image( NumberOfChannels );
temp_image[0] = vtkImageData::New();
temp_image[0]->ShallowCopy( m_MegaCaptureReader->GetOutput() );

vtkImageAppendComponents* append_filter =
vtkImageAppendComponents::New();
append_filter->AddInput( temp_image[0] );

for( int i = 1; i < NumberOfChannels; i++ )
{
m_MegaCaptureReader->SetChannel( i );
m_MegaCaptureReader->Update();

temp_image[i] = vtkImageData::New();
temp_image[i]->ShallowCopy( m_MegaCaptureReader->GetOutput() );
append_filter->AddInput( temp_image[i] );
}
// This is really stupid!!!
if( NumberOfChannels < 3 )
{
for( int i = NumberOfChannels; i < 3; i++ )
{
append_filter->AddInput( temp_image[0] );
}
}
append_filter->Update();

// Do we really need to delete m_Image?
if( !m_Image )
{
m_Image = vtkImageData::New();
}

m_Image->ShallowCopy( append_filter->GetOutput() );
append_filter->Delete();

for( int i = 0; i < NumberOfChannels; i++ )
{
temp_image[i]->Delete();
}
}
}
}
else
{
int ch = this->m_VisuDockWidget->GetCurrentChannel();
if( ch != -1 )
{
m_Image->ShallowCopy( m_LSMReader[ch]->GetOutput() );
if( !m_LSMReader.empty() )
{
m_Image->ShallowCopy( m_LSMReader[ch]->GetOutput() );
}
else
{
if( !m_FileList.empty() )
{
m_MegaCaptureReader->SetChannel( ch );
m_MegaCaptureReader->Update();
m_Image->ShallowCopy( m_MegaCaptureReader->GetOutput() );
}
}
Update();
}
}
Expand All @@ -1021,13 +1085,24 @@ void QGoTabImageView3DwT::ShowAllChannels( bool iChecked )
void QGoTabImageView3DwT::
ShowOneChannel( int iChannel )
{
if( !m_LSMReader.empty() && m_Image )
if( ( m_Image ) && ( iChannel != -1 ) )
{
if( iChannel != -1 )
if( !m_LSMReader.empty() )
{
m_Image->ShallowCopy( m_LSMReader[iChannel]->GetOutput() );
Update();
}
else
{
if( !m_FileList.empty() )
{
m_MegaCaptureReader->SetChannel( iChannel );
m_MegaCaptureReader->Update();

m_Image->ShallowCopy( m_MegaCaptureReader->GetOutput() );
Update();
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions branches/GoFigure2Beta/Code/GUI/lib/QGoTabImageView3DwT.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class QGoTabImageView3DwT : public QGoTabElementBase
void SetMegaCaptureFile(
const GoFigureFileInfoHelperMultiIndexContainer& iContainer,
const GoFigure::FileType& iFileType,
const std::string& iHeader,
const unsigned int& iTimePoint );

virtual void Update();
Expand Down
Loading

0 comments on commit 8a72c76

Please sign in to comment.