}
// Button to select file(s)
wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
- Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile );
+ Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile );
// Button to select directory
wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
m_dicom = true;
Layout();
}
+
//////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////
// Close();
EndModal( resultShowModal );
}
-
-
-void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
-{
- m_exts = i_exts;
-}
+ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
+ {
+ m_exts = i_exts;
+ }
/////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////
break;
}
}
- if (!boost::filesystem::is_directory(itr->status()) && bvalid)
- {
- readImg(itr->string().c_str());
- }
+ if (!boost::filesystem::is_directory(itr->status()) && bvalid)
+ {
+ readImg(itr->string().c_str());
+ }
}
}
SetReturnCode( resultShowModal );
void WxAnySimpleDlg::OnReadGimmick(wxCommandEvent &event)
{
// Run Gimmick
- WxGimmickReaderDialog dlg(0,-1,
+ WxGimmickReaderDialog dlg(0,-1,
namedescp,
namedb,
_T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
- wxString WxAnySimpleDlg::getInfoImage()
+ wxString WxAnySimpleDlg::getInfoImage()
{
return infoimage;
}
// FCY : just to check but not needed, we hardly suppose that we load only same type and dim of images
const std::type_info & WxAnySimpleDlg::getType(const std::string &i_name)
- {
+ {
typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
imageIO->SetFileName(i_name.c_str());
return imageIO->GetComponentTypeInfo();//AsString( imageIO->GetComponentType());
}
- const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
+ const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
{
typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
return imageIO->GetNumberOfDimensions();
}
- void WxAnySimpleDlg::readImg(const std::string &i_name)
- {
+ void WxAnySimpleDlg::readImg(const std::string &i_name)
+ {
size_t dims = getNumberOfDimensions(i_name);
const std::type_info *type= &getType(i_name);
switch(dims)
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
}
- else if (getType(i_name) == typeid(signed char))
- {
+ else if (getType(i_name) == typeid(signed char))
+ {
typedef itk::Image<signed char, 3> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->Update();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
- }
+ }
else if (getType(i_name) == typeid(short))
{
typedef itk::Image<short, 3> TImage;
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
}
- else if (getType(i_name) == typeid(unsigned short))
- {
+ else if (getType(i_name) == typeid(unsigned short))
+ {
typedef itk::Image<unsigned short, 3> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
}
- else if (getType(i_name) == typeid(signed char))
- {
+ else if (getType(i_name) == typeid(signed char))
+ {
typedef itk::Image<signed char, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(unsigned short))
+ }
+ else if (getType(i_name) == typeid(unsigned short))
{
typedef itk::Image<unsigned short, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
}
- else if(getType(i_name) == typeid(short))
- {
+ else if(getType(i_name) == typeid(short))
+ {
typedef itk::Image<short, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(unsigned short))
- {
+ }
+ else if (getType(i_name) == typeid(unsigned short))
+ {
typedef itk::Image<unsigned short, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(unsigned int))
- {
+ }
+ else if (getType(i_name) == typeid(unsigned int))
+ {
typedef itk::Image<unsigned int, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(signed int))
- {
+ }
+ else if (getType(i_name) == typeid(signed int))
+ {
typedef itk::Image<signed int, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(unsigned long))
- {
+ }
+ else if (getType(i_name) == typeid(unsigned long))
+ {
typedef itk::Image<unsigned long, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(signed long))
- {
+ }
+ else if (getType(i_name) == typeid(signed long))
+ {
typedef itk::Image<signed long, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(float))
- {
+ }
+ else if (getType(i_name) == typeid(float))
+ {
typedef itk::Image<float, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else if (getType(i_name) == typeid(double))
- {
+ }
+ else if (getType(i_name) == typeid(double))
+ {
typedef itk::Image<double, 4> TImage;
typedef itk::ImageFileReader<TImage> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->GetOutput()->Register();
m_AnyImages.push_back(reader->GetOutput());
split4Din3Dvtk<TImage>(reader->GetOutput());
- }
- else
- {
+ }
+ else
+ {
//????FCY, so what the type????
- }
- break;
+ }
+ break;
}
// Test to know if we have to add new type
- bool btest = false;
+ bool btest = false;
if( m_AnyDims.size() != 0)
{
btest = true;
else
{
m_AnyDims.push_back(dims);
- m_AnyType.push_back(&getType(i_name));
+ m_AnyType.push_back((std::type_info*)&getType(i_name)); //JPR cast
}
if (btest)
{
if(m_AnyDims.front() != dims || m_AnyType.front()->before(getType(i_name)))
{
m_AnyDims.push_back(dims);
- m_AnyType.push_back(&getType(i_name));
+ m_AnyType.push_back((std::type_info*)&getType(i_name)); //JPR cast
}
else{}
}
else {}
}
-
-
-
void WxAnySimpleDlg::readDicomImg(const std::vector<std::string> &i_names)
{
typedef itk::Image<short,3> TImage;
}
-
-
-
template <typename TImage>
void WxAnySimpleDlg::split3Din3Dvtk(TImage* i_Img)
{
template <typename TImage>
void WxAnySimpleDlg::split4Din3Dvtk(TImage* i_Img)
{
- if(i_Img->GetImageDimension() == 4)
- {
- // size of fourth dimension
- int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
- // Output Type
- typedef itk::Image<unsigned char,3> ImageOutputType;
- typedef itk::ImageSeriesWriter<TImage, ImageOutputType > SeriesWriterType;
- typedef itk::MetaImageIO MetaImageType;
- MetaImageType::Pointer metaIO;
- typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
+ if(i_Img->GetImageDimension() == 4)
+ {
+ // size of fourth dimension
+ int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
+ // Output Type
+ typedef itk::Image<unsigned char,3> ImageOutputType;
+ typedef itk::ImageSeriesWriter<TImage, ImageOutputType > SeriesWriterType;
+ typedef itk::MetaImageIO MetaImageType;
+ MetaImageType::Pointer metaIO;
+ typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
- // from JPR file to generate output files
- typedef itk::NumericSeriesFileNames NamesGeneratorType;
- NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
- namesGenerator->SetStartIndex(0);
- namesGenerator->SetEndIndex(dsize-1);
- namesGenerator->SetIncrementIndex(1);
- std::string format = m_dir;
- format += "/image%03d.mhd";
- namesGenerator->SetSeriesFormat( format.c_str() );
-
- const std::vector<std::string> names = namesGenerator->GetFileNames();
- seriesWriter->SetFileNames( names );
- seriesWriter->SetInput(i_Img);
- seriesWriter->SetImageIO(metaIO);
- try
- {
- seriesWriter->Update();
- vtkMetaImageReader *vReader = vtkMetaImageReader::New();
- std::vector<std::string>::const_iterator it = names.begin();
- for( ;it != names.end(); ++it)
- {
- vReader->SetFileName((*it).c_str());
- vReader->Update();
- m_Vresults.push_back(vReader->GetOutput());
-
- }
- }
- catch( itk::ExceptionObject & excp )
- {
- std::cerr << "Exception thrown while writing the series " << std::endl;
- std::cerr << excp << std::endl;
- //return EXIT_FAILURE;
- }
+ // from JPR file to generate output files
+ typedef itk::NumericSeriesFileNames NamesGeneratorType;
+ NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
+ namesGenerator->SetStartIndex(0);
+ namesGenerator->SetEndIndex(dsize-1);
+ namesGenerator->SetIncrementIndex(1);
+ std::string format = m_dir;
+ format += "/image%03d.mhd";
+ namesGenerator->SetSeriesFormat( format.c_str() );
+
+ const std::vector<std::string> names = namesGenerator->GetFileNames();
+ seriesWriter->SetFileNames( names );
+ seriesWriter->SetInput(i_Img);
+ seriesWriter->SetImageIO(metaIO);
+ try
+ {
+ seriesWriter->Update();
+ vtkMetaImageReader *vReader = vtkMetaImageReader::New();
+ std::vector<std::string>::const_iterator it = names.begin();
+ for( ;it != names.end(); ++it)
+ {
+ vReader->SetFileName((*it).c_str());
+ vReader->Update();
+ m_Vresults.push_back(vReader->GetOutput());
+
}
+ }
+ catch( itk::ExceptionObject & excp )
+ {
+ std::cerr << "Exception thrown while writing the series " << std::endl;
+ std::cerr << excp << std::endl;
+ //return EXIT_FAILURE;
+ }
+ }
}
- bool WxAnySimpleDlg::AllSameType()
- {
+ bool WxAnySimpleDlg::AllSameType()
+ {
if(m_AnyType.size() == 1)
{
return true;
return false;
}
- }
+ }
- }// namespace end
+ } // namespace end