creaImageIO_lib
creaImageIO::WxAnySimpleDlg Class Reference

Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display. More...

#include <creaImageIOWxAnySimpleDlg.h>

Inheritance diagram for creaImageIO::WxAnySimpleDlg:
Collaboration diagram for creaImageIO::WxAnySimpleDlg:

Public Member Functions

 WxAnySimpleDlg (wxWindow *parent, wxString i_title=_T(""), const std::string i_namedescp="localdatabase_Descriptor.dscp", const std::string i_namedb="Local Database")
 Ctor. More...
 
 ~WxAnySimpleDlg ()
 
void setExts (std::vector< std::string >)
 
void OnReadFile (wxCommandEvent &event)
 Callback to read file(s) More...
 
void OnReadDirectory (wxCommandEvent &event)
 Callback to read directory, no recursive. More...
 
void OnReadGimmick (wxCommandEvent &event)
 Callback to select from creaImageIO database. More...
 
std::vector< vtkImageData * > getVtkImagesSelected ()
 return a vtkImageData vector of selected images, if available More...
 
wxString getInfoImage ()
 
void set (bool i_dicom)
 
std::vector< boost::any > & getImagesSelected ()
 
std::vector< size_t > getDims ()
 
std::vector< std::type_info * > getTypes ()
 
template<typename TImage >
std::vector< typename
TImage::Pointer > 
getTemplatedImagesSelected ()
 
bool AllSameType ()
 
template<class TImage >
void split3Din3Dvtk (TImage *i_Img)
 
template<typename TImage >
void split4Din3Dvtk (TImage *i_Img)
 

Private Member Functions

void readImg (const std::string &i_name)
 
void readDicomImg (const std::vector< std::string > &i_names)
 
const size_t getNumberOfDimensions (const std::string &i_name)
 
const std::type_info & getType (const std::string &i_name)
 

Private Attributes

std::vector< size_t > m_AnyDims
 
std::vector< std::type_info * > m_AnyType
 
std::vector< boost::any > m_AnyImages
 
std::vector< std::string > m_exts
 
std::string namedescp
 
std::string namedb
 
wxString infoimage
 
std::string m_dir
 
bool m_dicom
 
SimpleView m_view
 interface to read data More...
 
std::vector< vtkImageData * > m_Vresults
 

Detailed Description

Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display.

Definition at line 47 of file creaImageIOWxAnySimpleDlg.h.

Constructor & Destructor Documentation

creaImageIO::WxAnySimpleDlg::WxAnySimpleDlg ( wxWindow *  parent,
wxString  i_title = _T(""),
const std::string  i_namedescp = "localdatabase_Descriptor.dscp",
const std::string  i_namedb = "Local Database" 
)

Ctor.

Button to select Bruker directory

Definition at line 54 of file creaImageIOWxAnySimpleDlg.cpp.

References m_dicom, namedb, namedescp, OnReadDirectory(), OnReadFile(), and OnReadGimmick().

58  : wxDialog(parent, -1,_T("DISPLAY IMAGES"), wxDefaultPosition, wxSize(230,150))
59  {
60  namedescp = i_namedescp;
61  namedb = i_namedb;
62 
63  if(!i_title.empty())
64  {
65  this->SetTitle(i_title);
66  }
67  // Button to select file(s)
68  wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
69  Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile );
70 
71  // Button to select directory
72  wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
73  Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadDirectory );
74 
75  // button to select creaImageIO
76  wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
77  Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadGimmick );
78 
80  m_dicom = false;
81  Layout();
82  }

Here is the call graph for this function:

creaImageIO::WxAnySimpleDlg::~WxAnySimpleDlg ( )
inline

Definition at line 57 of file creaImageIOWxAnySimpleDlg.h.

57 {};

Member Function Documentation

bool creaImageIO::WxAnySimpleDlg::AllSameType ( )

Definition at line 610 of file creaImageIOWxAnySimpleDlg.cpp.

References m_AnyType.

611  {
612  if(m_AnyType.size() == 1)
613  {
614  return true;
615  }
616  else
617  {
618  return false;
619  }
620 
621  }
std::vector< size_t> creaImageIO::WxAnySimpleDlg::getDims ( )
inline

Definition at line 78 of file creaImageIOWxAnySimpleDlg.h.

78 { return m_AnyDims;} // comment out const // JPR
std::vector<boost::any>& creaImageIO::WxAnySimpleDlg::getImagesSelected ( )
inline

Definition at line 75 of file creaImageIOWxAnySimpleDlg.h.

References creaImageIO::m_AnyImages.

75 { return m_AnyImages;}
wxString creaImageIO::WxAnySimpleDlg::getInfoImage ( )

Definition at line 208 of file creaImageIOWxAnySimpleDlg.cpp.

References infoimage.

209  {
210  return infoimage;
211  }
const size_t creaImageIO::WxAnySimpleDlg::getNumberOfDimensions ( const std::string &  i_name)
private

Definition at line 224 of file creaImageIOWxAnySimpleDlg.cpp.

Referenced by readImg().

225  {
226  typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
227  itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
228  imageIO->SetFileName(i_name.c_str());
229  imageIO->ReadImageInformation();
230  return imageIO->GetNumberOfDimensions();
231  }

Here is the caller graph for this function:

template<typename TImage >
std::vector<typename TImage::Pointer> creaImageIO::WxAnySimpleDlg::getTemplatedImagesSelected ( )
inline

Definition at line 98 of file creaImageIOWxAnySimpleDlg.h.

References creaImageIO::m_AnyImages.

99  {
100  std::vector<typename TImage::Pointer> imgs;
101  std::vector<boost::any>::iterator it = m_AnyImages.begin();
102  for(; it != m_AnyImages.end(); it++)
103  {
104  imgs.push_back(boost::any_cast<TImage*> (*it));
105  }
106  return imgs;
107  }
const std::type_info & creaImageIO::WxAnySimpleDlg::getType ( const std::string &  i_name)
private

Definition at line 215 of file creaImageIOWxAnySimpleDlg.cpp.

Referenced by readImg().

216  {
217  typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
218  itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
219  imageIO->SetFileName(i_name.c_str());
220  imageIO->ReadImageInformation();
221  return imageIO->GetComponentTypeInfo();//AsString( imageIO->GetComponentType());
222  }

Here is the caller graph for this function:

std::vector<std::type_info *> creaImageIO::WxAnySimpleDlg::getTypes ( )
inline

Definition at line 81 of file creaImageIOWxAnySimpleDlg.h.

81 { return m_AnyType;} // comment out const // JPR
std::vector<vtkImageData*> creaImageIO::WxAnySimpleDlg::getVtkImagesSelected ( )
inline

return a vtkImageData vector of selected images, if available

Definition at line 70 of file creaImageIOWxAnySimpleDlg.h.

References creaImageIO::m_Vresults.

70 {return m_Vresults;}
void creaImageIO::WxAnySimpleDlg::OnReadDirectory ( wxCommandEvent &  event)

Callback to read directory, no recursive.

Definition at line 124 of file creaImageIOWxAnySimpleDlg.cpp.

References m_exts, and readImg().

Referenced by WxAnySimpleDlg().

125  {
126  int resultShowModal;
127  bool bvalid = false;
128  long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
129  wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
130 
131  resultShowModal = dirDlg->ShowModal();
132  if ( resultShowModal==wxID_OK )
133  {
134  std::string path = crea::wx2std(dirDlg->GetPath());
135  typedef boost::filesystem::directory_iterator dir_it;
136  dir_it itr(path);
137  dir_it end_itr;
138  /*if (boost::filesystem::exists(path))
139  {*/
140  for(;itr != end_itr; ++itr)
141  {
142  bvalid = m_exts.size() == 0? true : false;
143  std::vector<std::string>::iterator it = m_exts.begin();
144  std::string ext = itr->path().filename().string().substr(itr->path().filename().string().find_last_of("."));
145  for(; it != m_exts.end(); it++)
146  {
147  if(ext == (*it) )
148  {
149  bvalid = true;
150  break;
151  }
152  }
153  if (!boost::filesystem::is_directory(itr->status()) && bvalid)
154  {
155  readImg(itr->path().string().c_str());
156  }
157  }
158  }
159  SetReturnCode( resultShowModal );
160 // Close();
161  EndModal( resultShowModal );
162  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::WxAnySimpleDlg::OnReadFile ( wxCommandEvent &  event)

Callback to read file(s)

Definition at line 88 of file creaImageIOWxAnySimpleDlg.cpp.

References readImg().

Referenced by WxAnySimpleDlg().

89  {
90  int resultShowModal;
91  wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
92 
93  resultShowModal = fileDlg->ShowModal();
94  if ( resultShowModal==wxID_OK )
95  {
96  wxArrayString wxArray;
97  fileDlg->GetPaths(wxArray);
98  if(wxArray.size() >0)
99  {
100  for( int i = 0; i < wxArray.GetCount(); i++)
101  {
102  std::string name = crea::wx2std(wxArray[i]);
103  // FOR THE MOMENT ONLY short 3D et short 4D
104  readImg(name);
105  }
106  }
107  else {
108  // TO DO WARNING MESSAGES
109  }
110  }
111  SetReturnCode( resultShowModal );
112 // Close();
113  EndModal( resultShowModal );
114  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::WxAnySimpleDlg::OnReadGimmick ( wxCommandEvent &  event)

Callback to select from creaImageIO database.

Definition at line 168 of file creaImageIOWxAnySimpleDlg.cpp.

References _3D, creaImageIO::WxGimmickReaderDialog::GetSelectedFiles(), GIMMICK_2D_IMAGE_SELECTION, GIMMICK_3D_IMAGE_SELECTION, m_dicom, namedb, namedescp, creaImageIO::WxGimmickReaderDialog::OnExit(), readDicomImg(), readImg(), and creaImageIO::WxGimmickReaderDialog::stopReading().

Referenced by WxAnySimpleDlg().

169  {
170  // Run Gimmick
171  WxGimmickReaderDialog dlg(0,-1,
172  namedescp,
173  namedb,
174  _T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
175  wxDefaultPosition,
176  wxSize(810,750),
179  _3D,
180  1);
181  dlg.ShowModal();
182  if (dlg.GetReturnCode() == wxID_OK)
183  {
184  std::vector<std::string> out;
185  dlg.stopReading();
186  dlg.GetSelectedFiles(out);
187  if(m_dicom)
188  {
189  readDicomImg( out);
190  }
191  else
192  {
193  std::vector<std::string>::iterator ii = out.begin();
194  for (;ii != out.end();ii++)
195  {
196  readImg( (*ii).c_str() );
197  }
198  }
199  dlg.OnExit();
200  }
201  SetReturnCode( dlg.GetReturnCode() );
202 // Close();
203  EndModal( dlg.GetReturnCode() );
204  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::WxAnySimpleDlg::readDicomImg ( const std::vector< std::string > &  i_names)
private

Definition at line 512 of file creaImageIOWxAnySimpleDlg.cpp.

Referenced by OnReadGimmick().

513  {
514  typedef itk::Image<short,3> TImage;
515  typedef itk::GDCMImageIO GDCMType;
516  typedef itk::DICOMSeriesFileNames dicnames;
517  GDCMType::Pointer gdcmIO = GDCMType::New();
518  dicnames::Pointer generator = dicnames::New();
519 
520 
521  typedef itk::ImageSeriesReader<TImage> ReaderType;
522  ReaderType::Pointer reader = ReaderType::New();
523  reader->SetImageIO(gdcmIO);
524  reader->SetFileNames(i_names);
525  // reader->SetFileName( i_name );
526  try
527  {
528  reader->Update();
529  }
530  catch( itk::ExceptionObject & err )
531  {
532  // std::cout << "Caught an exception reading" << i_name << ": " << std::endl;
533  std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl;
534  throw err;
535  }
536  catch(...)
537  {
538  //std::cout << "Error while reading image " << i_name << std::endl;
539  throw;
540  }
541  //m_Iresults.push_back(reader->GetOutput());
542 
543  }

Here is the caller graph for this function:

void creaImageIO::WxAnySimpleDlg::readImg ( const std::string &  i_name)
private

Definition at line 233 of file creaImageIOWxAnySimpleDlg.cpp.

References getNumberOfDimensions(), getType(), m_AnyDims, m_AnyImages, and m_AnyType.

Referenced by OnReadDirectory(), OnReadFile(), and OnReadGimmick().

234  {
235  size_t dims = getNumberOfDimensions(i_name);
236  //const std::type_info *type= &getType(i_name);
237  switch(dims)
238  {
239  case 3:
240  if (getType(i_name) == typeid(unsigned char))
241  {
242  typedef itk::Image<unsigned char, 3> TImage;
243  typedef itk::ImageFileReader<TImage> ReaderType;
244  ReaderType::Pointer reader = ReaderType::New();
245  reader->SetFileName( i_name );
246  reader->Update();
247  reader->GetOutput()->Register();
248  m_AnyImages.push_back(reader->GetOutput());
249  }
250  else if (getType(i_name) == typeid(signed char))
251  {
252  typedef itk::Image<signed char, 3> TImage;
253  typedef itk::ImageFileReader<TImage> ReaderType;
254  ReaderType::Pointer reader = ReaderType::New();
255  reader->SetFileName( i_name );
256  reader->Update();
257  reader->GetOutput()->Register();
258  m_AnyImages.push_back(reader->GetOutput());
259  }
260  else if (getType(i_name) == typeid(short))
261  {
262  typedef itk::Image<short, 3> TImage;
263  typedef itk::ImageFileReader<TImage> ReaderType;
264  ReaderType::Pointer reader = ReaderType::New();
265  reader->SetFileName( i_name );
266  reader->Update();
267  reader->GetOutput()->Register();
268  m_AnyImages.push_back(reader->GetOutput());
269  }
270  else if (getType(i_name) == typeid(unsigned short))
271  {
272  typedef itk::Image<unsigned short, 3> TImage;
273  typedef itk::ImageFileReader<TImage> ReaderType;
274  ReaderType::Pointer reader = ReaderType::New();
275  reader->SetFileName( i_name );
276  reader->Update();
277  reader->GetOutput()->Register();
278  m_AnyImages.push_back(reader->GetOutput());
279  }
280  else if (getType(i_name) == typeid(unsigned int))
281  {
282  typedef itk::Image<unsigned int, 3> TImage;
283  typedef itk::ImageFileReader<TImage> ReaderType;
284  ReaderType::Pointer reader = ReaderType::New();
285  reader->SetFileName( i_name );
286  reader->Update();
287  reader->GetOutput()->Register();
288  m_AnyImages.push_back(reader->GetOutput());
289  }
290  else if (getType(i_name) == typeid(signed int))
291  {
292  typedef itk::Image<signed int, 3> TImage;
293  typedef itk::ImageFileReader<TImage> ReaderType;
294  ReaderType::Pointer reader = ReaderType::New();
295  reader->SetFileName( i_name );
296  reader->Update();
297  reader->GetOutput()->Register();
298  m_AnyImages.push_back(reader->GetOutput());
299  }
300  else if (getType(i_name) == typeid(unsigned long))
301  {
302  typedef itk::Image<unsigned long, 3> TImage;
303  typedef itk::ImageFileReader<TImage> ReaderType;
304  ReaderType::Pointer reader = ReaderType::New();
305  reader->SetFileName( i_name );
306  reader->Update();
307  reader->GetOutput()->Register();
308  m_AnyImages.push_back(reader->GetOutput());
309  }
310  else if (getType(i_name) == typeid(signed long))
311  {
312  typedef itk::Image<signed long, 3> TImage;
313  typedef itk::ImageFileReader<TImage> ReaderType;
314  ReaderType::Pointer reader = ReaderType::New();
315  reader->SetFileName( i_name );
316  reader->Update();
317  reader->GetOutput()->Register();
318  m_AnyImages.push_back(reader->GetOutput());
319  }
320  else if (getType(i_name) == typeid(float))
321  {
322  typedef itk::Image<float, 3> TImage;
323  typedef itk::ImageFileReader<TImage> ReaderType;
324  ReaderType::Pointer reader = ReaderType::New();
325  reader->SetFileName( i_name );
326  reader->Update();
327  reader->GetOutput()->Register();
328  m_AnyImages.push_back(reader->GetOutput());
329  }
330  else if (getType(i_name) == typeid(double))
331  {
332  typedef itk::Image<double, 3> TImage;
333  typedef itk::ImageFileReader<TImage> ReaderType;
334  ReaderType::Pointer reader = ReaderType::New();
335  reader->SetFileName( i_name );
336  reader->Update();
337  reader->GetOutput()->Register();
338  m_AnyImages.push_back(reader->GetOutput());
339  }
340  else
341  {
342  //????FCY, so what the type????
343  }
344  break;
345  //assume that we have only one 4D file
346  case 4:
347  if (getType(i_name) == typeid(unsigned char))
348  {
349  typedef itk::Image<unsigned char, 4> TImage;
350  typedef itk::ImageFileReader<TImage> ReaderType;
351  ReaderType::Pointer reader = ReaderType::New();
352  reader->SetFileName( i_name );
353  reader->Update();
354  reader->GetOutput()->Register();
355  m_AnyImages.push_back(reader->GetOutput());
356  split4Din3Dvtk<TImage>(reader->GetOutput());
357  }
358  else if (getType(i_name) == typeid(signed char))
359  {
360  typedef itk::Image<signed char, 4> TImage;
361  typedef itk::ImageFileReader<TImage> ReaderType;
362  ReaderType::Pointer reader = ReaderType::New();
363  reader->SetFileName( i_name );
364  reader->Update();
365  reader->GetOutput()->Register();
366  m_AnyImages.push_back(reader->GetOutput());
367  split4Din3Dvtk<TImage>(reader->GetOutput());
368  }
369  else if (getType(i_name) == typeid(unsigned short))
370  {
371  typedef itk::Image<unsigned short, 4> TImage;
372  typedef itk::ImageFileReader<TImage> ReaderType;
373  ReaderType::Pointer reader = ReaderType::New();
374  reader->SetFileName( i_name );
375  reader->Update();
376  reader->GetOutput()->Register();
377  m_AnyImages.push_back(reader->GetOutput());
378  split4Din3Dvtk<TImage>(reader->GetOutput());
379  }
380  else if(getType(i_name) == typeid(short))
381  {
382  typedef itk::Image<short, 4> TImage;
383  typedef itk::ImageFileReader<TImage> ReaderType;
384  ReaderType::Pointer reader = ReaderType::New();
385  reader->SetFileName( i_name );
386  try
387  {
388  reader->Update();
389  }
390  catch( itk::ExceptionObject & err )
391  {
392  std::cout << "Caught an exception reading" << i_name << ": " << std::endl;
393  std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl;
394  throw err;
395  }
396  catch(...)
397  {
398  std::cout << "Error while reading image " << i_name << std::endl;
399  throw;
400  }
401  reader->GetOutput()->Register();
402  m_AnyImages.push_back(reader->GetOutput());
403  split4Din3Dvtk<TImage>(reader->GetOutput());
404  }
405  else if (getType(i_name) == typeid(unsigned short))
406  {
407  typedef itk::Image<unsigned short, 4> TImage;
408  typedef itk::ImageFileReader<TImage> ReaderType;
409  ReaderType::Pointer reader = ReaderType::New();
410  reader->SetFileName( i_name );
411  reader->Update();
412  reader->GetOutput()->Register();
413  m_AnyImages.push_back(reader->GetOutput());
414  split4Din3Dvtk<TImage>(reader->GetOutput());
415  }
416  else if (getType(i_name) == typeid(unsigned int))
417  {
418  typedef itk::Image<unsigned int, 4> TImage;
419  typedef itk::ImageFileReader<TImage> ReaderType;
420  ReaderType::Pointer reader = ReaderType::New();
421  reader->SetFileName( i_name );
422  reader->Update();
423  reader->GetOutput()->Register();
424  m_AnyImages.push_back(reader->GetOutput());
425  split4Din3Dvtk<TImage>(reader->GetOutput());
426  }
427  else if (getType(i_name) == typeid(signed int))
428  {
429  typedef itk::Image<signed int, 4> TImage;
430  typedef itk::ImageFileReader<TImage> ReaderType;
431  ReaderType::Pointer reader = ReaderType::New();
432  reader->SetFileName( i_name );
433  reader->Update();
434  reader->GetOutput()->Register();
435  m_AnyImages.push_back(reader->GetOutput());
436  split4Din3Dvtk<TImage>(reader->GetOutput());
437  }
438  else if (getType(i_name) == typeid(unsigned long))
439  {
440  typedef itk::Image<unsigned long, 4> TImage;
441  typedef itk::ImageFileReader<TImage> ReaderType;
442  ReaderType::Pointer reader = ReaderType::New();
443  reader->SetFileName( i_name );
444  reader->Update();
445  reader->GetOutput()->Register();
446  m_AnyImages.push_back(reader->GetOutput());
447  split4Din3Dvtk<TImage>(reader->GetOutput());
448  }
449  else if (getType(i_name) == typeid(signed long))
450  {
451  typedef itk::Image<signed long, 4> TImage;
452  typedef itk::ImageFileReader<TImage> ReaderType;
453  ReaderType::Pointer reader = ReaderType::New();
454  reader->SetFileName( i_name );
455  reader->Update();
456  reader->GetOutput()->Register();
457  m_AnyImages.push_back(reader->GetOutput());
458  split4Din3Dvtk<TImage>(reader->GetOutput());
459  }
460  else if (getType(i_name) == typeid(float))
461  {
462  typedef itk::Image<float, 4> TImage;
463  typedef itk::ImageFileReader<TImage> ReaderType;
464  ReaderType::Pointer reader = ReaderType::New();
465  reader->SetFileName( i_name );
466  reader->Update();
467  reader->GetOutput()->Register();
468  m_AnyImages.push_back(reader->GetOutput());
469  split4Din3Dvtk<TImage>(reader->GetOutput());
470  }
471  else if (getType(i_name) == typeid(double))
472  {
473  typedef itk::Image<double, 4> TImage;
474  typedef itk::ImageFileReader<TImage> ReaderType;
475  ReaderType::Pointer reader = ReaderType::New();
476  reader->SetFileName( i_name );
477  reader->Update();
478  reader->GetOutput()->Register();
479  m_AnyImages.push_back(reader->GetOutput());
480  split4Din3Dvtk<TImage>(reader->GetOutput());
481  }
482  else
483  {
484  //????FCY, so what the type????
485  }
486  break;
487  }
488 
489  // Test to know if we have to add new type
490  bool btest = false;
491  if( m_AnyDims.size() != 0)
492  {
493  btest = true;
494  }
495  else
496  {
497  m_AnyDims.push_back(dims);
498  m_AnyType.push_back((std::type_info*)&getType(i_name)); //JPR cast
499  }
500  if (btest)
501  {
502  if(m_AnyDims.front() != dims || m_AnyType.front()->before(getType(i_name)))
503  {
504  m_AnyDims.push_back(dims);
505  m_AnyType.push_back((std::type_info*)&getType(i_name)); //JPR cast
506  }
507  else{}
508  }
509  else {}
510  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::WxAnySimpleDlg::set ( bool  i_dicom)
inline

Definition at line 74 of file creaImageIOWxAnySimpleDlg.h.

References creaImageIO::m_dicom.

74 {m_dicom= i_dicom;}
void creaImageIO::WxAnySimpleDlg::setExts ( std::vector< std::string >  i_exts)

Definition at line 116 of file creaImageIOWxAnySimpleDlg.cpp.

References m_exts.

117  {
118  m_exts = i_exts;
119  }
template<class TImage >
void creaImageIO::WxAnySimpleDlg::split3Din3Dvtk ( TImage *  i_Img)
inline

Definition at line 110 of file creaImageIOWxAnySimpleDlg.h.

References creaImageIO::m_Vresults.

111  {
112  typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
113  typename ConnectorType::Pointer connector = ConnectorType::New();
114  connector->SetInput(i_Img);
115  connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
116  connector->Update();
117  vtkImageData *im = vtkImageData::New();
118  im->ShallowCopy(connector->GetOutput());
119  im->Update();
120  m_Vresults.push_back(im);
121  }
template<typename TImage >
void creaImageIO::WxAnySimpleDlg::split4Din3Dvtk ( TImage *  i_Img)

Definition at line 561 of file creaImageIOWxAnySimpleDlg.cpp.

References m_dir, and m_Vresults.

562  {
563  if(i_Img->GetImageDimension() == 4)
564  {
565  // size of fourth dimension
566  int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
567  // Output Type
568  typedef itk::Image<unsigned char,3> ImageOutputType;
569  typedef itk::ImageSeriesWriter<TImage, ImageOutputType > SeriesWriterType;
570  typedef itk::MetaImageIO MetaImageType;
571  MetaImageType::Pointer metaIO;
572  typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
573 
574  // from JPR file to generate output files
575  typedef itk::NumericSeriesFileNames NamesGeneratorType;
576  NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
577  namesGenerator->SetStartIndex(0);
578  namesGenerator->SetEndIndex(dsize-1);
579  namesGenerator->SetIncrementIndex(1);
580  std::string format = m_dir;
581  format += "/image%03d.mhd";
582  namesGenerator->SetSeriesFormat( format.c_str() );
583 
584  const std::vector<std::string> names = namesGenerator->GetFileNames();
585  seriesWriter->SetFileNames( names );
586  seriesWriter->SetInput(i_Img);
587  seriesWriter->SetImageIO(metaIO);
588  try
589  {
590  seriesWriter->Update();
591  vtkMetaImageReader *vReader = vtkMetaImageReader::New();
592  std::vector<std::string>::const_iterator it = names.begin();
593  for( ;it != names.end(); ++it)
594  {
595  vReader->SetFileName((*it).c_str());
596  vReader->Update();
597  m_Vresults.push_back(vReader->GetOutput());
598 
599  }
600  }
601  catch( itk::ExceptionObject & excp )
602  {
603  std::cerr << "Exception thrown while writing the series " << std::endl;
604  std::cerr << excp << std::endl;
605  //return EXIT_FAILURE;
606  }
607  }
608  }

Member Data Documentation

wxString creaImageIO::WxAnySimpleDlg::infoimage
private

Definition at line 137 of file creaImageIOWxAnySimpleDlg.h.

Referenced by getInfoImage().

std::vector< size_t> creaImageIO::WxAnySimpleDlg::m_AnyDims
private

Definition at line 131 of file creaImageIOWxAnySimpleDlg.h.

Referenced by readImg().

std::vector<boost::any> creaImageIO::WxAnySimpleDlg::m_AnyImages
private

Definition at line 133 of file creaImageIOWxAnySimpleDlg.h.

Referenced by readImg().

std::vector< std::type_info *> creaImageIO::WxAnySimpleDlg::m_AnyType
private

Definition at line 132 of file creaImageIOWxAnySimpleDlg.h.

Referenced by AllSameType(), and readImg().

bool creaImageIO::WxAnySimpleDlg::m_dicom
private

Definition at line 141 of file creaImageIOWxAnySimpleDlg.h.

Referenced by OnReadGimmick(), and WxAnySimpleDlg().

std::string creaImageIO::WxAnySimpleDlg::m_dir
private

Definition at line 138 of file creaImageIOWxAnySimpleDlg.h.

Referenced by split4Din3Dvtk().

std::vector<std::string> creaImageIO::WxAnySimpleDlg::m_exts
private

Definition at line 134 of file creaImageIOWxAnySimpleDlg.h.

Referenced by OnReadDirectory(), and setExts().

SimpleView creaImageIO::WxAnySimpleDlg::m_view
private

interface to read data

Definition at line 143 of file creaImageIOWxAnySimpleDlg.h.

std::vector<vtkImageData*> creaImageIO::WxAnySimpleDlg::m_Vresults
private

Definition at line 146 of file creaImageIOWxAnySimpleDlg.h.

Referenced by split4Din3Dvtk().

std::string creaImageIO::WxAnySimpleDlg::namedb
private

Definition at line 136 of file creaImageIOWxAnySimpleDlg.h.

Referenced by OnReadGimmick(), and WxAnySimpleDlg().

std::string creaImageIO::WxAnySimpleDlg::namedescp
private

Definition at line 135 of file creaImageIOWxAnySimpleDlg.h.

Referenced by OnReadGimmick(), and WxAnySimpleDlg().


The documentation for this class was generated from the following files: