creaImageIO_lib
creaImageIO::SimpleView Class Reference

#include <creaImageIOSimpleView.h>

Public Member Functions

 SimpleView ()
 Ctor. More...
 
 ~SimpleView ()
 Dtor. More...
 
bool readFile (std::vector< std::string > i_filenames, std::vector< vtkImageData * > &i_img)
 read file(s) and return a vector of vtkImageData More...
 
bool readDirectory (const std::string i_pathname, std::vector< vtkImageData * > &i_imgs)
 read a directory and return a vector of vtkImageData More...
 

Detailed Description

Definition at line 41 of file creaImageIOSimpleView.h.

Constructor & Destructor Documentation

creaImageIO::SimpleView::SimpleView ( )
inline

Ctor.

Definition at line 45 of file creaImageIOSimpleView.h.

45 {}
creaImageIO::SimpleView::~SimpleView ( )
inline

Dtor.

Definition at line 48 of file creaImageIOSimpleView.h.

48 {}

Member Function Documentation

bool creaImageIO::SimpleView::readDirectory ( const std::string  i_pathname,
std::vector< vtkImageData * > &  i_imgs 
)

read a directory and return a vector of vtkImageData

Definition at line 56 of file creaImageIOSimpleView.cpp.

References creaImageIO::ImageReader::CanRead(), and creaImageIO::ImageReader::ReadImage().

Referenced by creaImageIO::WxSimpleDlg::OnReadDirectory().

57  {
58  bool bresult = true;
59  ImageReader *mReader = new ImageReader();
60  std::vector<std::string> names;
61  bresult = boost::filesystem::exists( i_pathname );
62  if (bresult)
63  {
64  boost::filesystem::directory_iterator itr(i_pathname);
65  boost::filesystem::directory_iterator end_itr;
66  for(;itr != end_itr; ++itr)
67  {
68  if (!boost::filesystem::is_directory(itr->status()))
69  {
70  if( mReader->CanRead(itr->path().string()) )
71  {
72  names.push_back(itr->path().string());
73  }
74  }
75  }
76  std::sort (names.begin(), names.end()); // make sure names are in lexicographical order
77  int lgr = (int)names.size();
78 
79  for(int i=0; i<lgr; i++)
80  {
81  std::cout << names[i] << std::endl;
82  i_imgs.push_back( mReader->ReadImage(names[i]) );
83  }
84  }
85  return bresult;
86  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SimpleView::readFile ( std::vector< std::string >  i_filenames,
std::vector< vtkImageData * > &  i_img 
)

read file(s) and return a vector of vtkImageData

Definition at line 35 of file creaImageIOSimpleView.cpp.

References creaImageIO::ImageReader::CanRead(), and creaImageIO::ImageReader::ReadImage().

Referenced by creaImageIO::WxSimpleDlg::OnReadFile().

36  {
37  bool bresult, bfinal = true;
38  ImageReader *mReader = new ImageReader();
39  std::vector<std::string>::iterator it = i_filenames.begin();
40  for (; it != i_filenames.end(); it++)
41  {
42  bresult = mReader->CanRead((*it).c_str());
43  if(bresult)
44  {
45  i_img.push_back(mReader->ReadImage((*it).c_str()));
46  } else {
47  printf("ERROR. Impossible to read file %s\n", (*it).c_str() );
48  bfinal = false;
49  } // if
50  } // for
51  delete mReader;
52  return bfinal;
53  }

Here is the call graph for this function:

Here is the caller graph for this function:


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