--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbcreaImageIOReadImages.h"
+#include "bbcreaImageIOPackage.h"
+
+#include "creaImageIOSimpleView.h"
+
+namespace bbcreaImageIO
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaImageIO,ReadImages)
+BBTK_BLACK_BOX_IMPLEMENTATION(ReadImages,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ReadImages::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+// bbSetOutputOut( bbGetInputIn() );
+// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+ std::vector<vtkImageData*> mResults;
+ VectorMapInfoDicom mResultsDicomAtr;
+ creaImageIO::SimpleView mView;
+ if( mView.readFile(bbGetInputLstNameImages() , bbGetInputDicomTags() , mResultsDicomAtr , mResults)==true )
+ {
+ bbSetOutputOut( mView.getVolumeSelected( mResults ) );
+ bbSetOutputOutImages( mResults );
+ bbSetOutputDicomInfo( mResultsDicomAtr );
+ } else {
+ bbSetOutputOut( NULL );
+ printf("EED Warning! ReadImages::Process Files(s) not found. \n");
+ }// if readFile
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ReadImages::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+// bbSetInputIn(0);
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ReadImages::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ReadImages::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbcreaImageIO
+
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifndef __bbcreaImageIOReadImages_h_INCLUDED__
+#define __bbcreaImageIOReadImages_h_INCLUDED__
+
+#include "bbcreaImageIO_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+#include <vtkImageData.h>
+
+namespace bbcreaImageIO
+{
+
+
+typedef std::map<std::string, std::string> MapInfoDicom;
+typedef std::vector< MapInfoDicom > VectorMapInfoDicom;
+
+class bbcreaImageIO_EXPORT ReadImages
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(ReadImages,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ BBTK_DECLARE_INPUT(DicomTags,std::vector<std::string>);
+ BBTK_DECLARE_INPUT(LstNameImages,std::vector<std::string>);
+ BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+ BBTK_DECLARE_OUTPUT(OutImages,std::vector<vtkImageData*>);
+ BBTK_DECLARE_OUTPUT(DicomInfo,VectorMapInfoDicom);
+ BBTK_PROCESS(Process);
+ void Process();
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReadImages,bbtk::AtomicBlackBox);
+ BBTK_NAME("ReadImages");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+
+ BBTK_INPUT(ReadImages,DicomTags,"Dicom Tags (vector of Dicom tags ex: D0028_0030 D0020_0037)",std::vector<std::string>,"");
+ BBTK_INPUT(ReadImages,LstNameImages,"List path to images",std::vector<std::string>,"");
+
+ BBTK_OUTPUT(ReadImages,Out,"Output Image",vtkImageData*,"");
+ BBTK_OUTPUT(ReadImages,OutImages,"List of Output Image",std::vector<vtkImageData*>,"");
+ BBTK_OUTPUT(ReadImages,DicomInfo,"vector of maps of Dicom tags",VectorMapInfoDicom,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(ReadImages);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+}
+// EO namespace bbcreaImageIO
+
+#endif // __bbcreaImageIOReadImages_h_INCLUDED__
+
}
return bresult;
}
+
+
+ vtkImageData* SimpleView::getVolumeSelected( std::vector<vtkImageData*> lstImages)
+ {
+ vtkImageData *result;
+
+// creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
+// dlg.SetAttrDicomTags( bbGetInputDicomTags() );
+// dlg.ShowModal();
+// bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
+
+ if (lstImages.size()!=0){
+// bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+ if(lstImages.size() ==1)
+ {
+ result = lstImages[0] ;
+ } else {
+ // FCY: it will be a big problem if we have several kind of data in the same folder.
+ // creation of a huge vtkImageData!!!!
+ vtkImageData* first = lstImages[0];
+ int dim[3];
+ first->GetDimensions(dim);
+ if (dim[2]==1)
+ {
+ vtkImageData *out = vtkImageData::New();
+ int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ first->GetWholeExtent(ext);
+#else
+ first->GetExtent(ext);
+#endif
+ if(ext[5] == 0)
+ {
+ ext[5] = lstImages.size()-1;
+ } else {
+ ext[5] = ext[5] * lstImages.size()-1; // to deal with multiframes
+ } // ext
+ out->SetExtent(ext);
+ double spac[3];
+ first->GetDimensions(dim);
+ first->GetSpacing(spac);
+ if (spac[0]==spac[1])
+ {
+ spac[2]=spac[0];
+ }
+ out->SetSpacing(spac);
+ out->SetDimensions(dim[0], dim[1], lstImages.size() );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+
+ out->SetScalarType(first->GetScalarType());
+ out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+ out->AllocateScalars();
+ out->Update();
+#else
+ out->AllocateScalars(first->GetScalarType(),first->GetNumberOfScalarComponents());
+#endif
+
+
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * dim[2]; // deal with multiframes here
+ // differents formats char , short, etc...
+ // differents components 1..3 ex. jpg ->RGB 3
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+ int slice,sizeImageVector=lstImages.size();
+ for (slice=0 ; slice<sizeImageVector ; slice++)
+ {
+ vtkImageData *img = lstImages[slice];
+ memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
+ //img->Delete();
+ } // for slice
+ out->Modified();
+//EED This is NOT working. The iteration over the pointer vtkImageData
+// int slice=0;
+// std::vector<vtkImageData*>::iterator it;
+// for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
+// {
+// memcpy(out->GetScalarPointer(0,0,slice), (*it)->GetScalarPointer(0,0,0), imsize);
+// slice++;
+// }
+// //for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
+// //{
+// // (*it)->Delete();
+// //}
+
+ result =out;
+
+ } else {
+ result = first;
+ } // dim
+ } // if getImagesSelected size
+ } else {
+ result = NULL;
+ } // getImagesSelected().size()!=0
+ result->Modified();
+ return result;
+ }
+
+
}
public:
/// Ctor
SimpleView(){}
-
///Dtor
~SimpleView(){}
-
/// read file(s) and return a vector of vtkImageData
bool readFile( std::vector<std::string> i_filenames, // in information names
std::vector<std::string> i_attr, // in information attributes names
std::vector<std::map <std::string,std::string> > &i_imgAttr, // out information attributes names-values
std::vector< vtkImageData *> &i_img); // out information vtkImageData
-
/// read a directory and return a vector of vtkImageData
bool readDirectory( const std::string i_pathname, // in information names
std::vector<std::string> i_attr, // in information attributes names
std::vector<std::map <std::string , std::string> > &i_imgAttr, // out information attributes names-values
std::vector<vtkImageData *> &i_imgs); // out information vtkImageData
-
-
-
-
- };
+ vtkImageData* getVolumeSelected( std::vector<vtkImageData*> images);
+ };
}
-
#endif
//-----------------------------------------------------------------------------
vtkImageData* WxSimpleDlg::getVolumeSelected()
{
- vtkImageData *result;
-
-// creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
-// dlg.SetAttrDicomTags( bbGetInputDicomTags() );
-// dlg.ShowModal();
-// bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
-
- if (getImagesSelected().size()!=0){
-// bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
- if(getImagesSelected().size() ==1)
- {
- result = getImagesSelected()[0] ;
- } else {
- // FCY: it will be a big problem if we have several kind of data in the same folder.
- // creation of a huge vtkImageData!!!!
- vtkImageData* first = getImagesSelected()[0];
- int dim[3];
- first->GetDimensions(dim);
- if (dim[2]==1)
- {
- vtkImageData *out = vtkImageData::New();
- int ext[6];
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
- first->GetWholeExtent(ext);
-#else
- first->GetExtent(ext);
-#endif
- if(ext[5] == 0)
- {
- ext[5] = getImagesSelected().size()-1;
- } else {
- ext[5] = ext[5] * getImagesSelected().size()-1; // to deal with multiframes
- } // ext
- out->SetExtent(ext);
- double spac[3];
- first->GetDimensions(dim);
- first->GetSpacing(spac);
- if (spac[0]==spac[1])
- {
- spac[2]=spac[0];
- }
- out->SetSpacing(spac);
- out->SetDimensions(dim[0], dim[1], getImagesSelected().size() );
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-
- out->SetScalarType(first->GetScalarType());
- out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
- out->AllocateScalars();
- out->Update();
-#else
- out->AllocateScalars(first->GetScalarType(),first->GetNumberOfScalarComponents());
-#endif
-
-
- unsigned long imsize = dim[0] * dim[1];
- imsize = imsize * dim[2]; // deal with multiframes here
- // differents formats char , short, etc...
- // differents components 1..3 ex. jpg ->RGB 3
- imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
- int slice,sizeImageVector=getImagesSelected().size();
- for (slice=0 ; slice<sizeImageVector ; slice++)
- {
- vtkImageData *img = getImagesSelected()[slice];
- memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
- //img->Delete();
- } // for slice
- out->Modified();
-//EED This is NOT working. The iteration over the pointer vtkImageData
-// int slice=0;
-// std::vector<vtkImageData*>::iterator it;
-// for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
-// {
-// memcpy(out->GetScalarPointer(0,0,slice), (*it)->GetScalarPointer(0,0,0), imsize);
-// slice++;
-// }
-// //for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
-// //{
-// // (*it)->Delete();
-// //}
-
- result =out;
-
- } else {
- result = first;
- } // dim
- } // if getImagesSelected size
- } else {
- result = NULL;
- } // getImagesSelected().size()!=0
-
- result->Modified();
- return result;
-
- }
-
-
+ return m_view.getVolumeSelected( getImagesSelected() );
+ }
} // namespace creaImageIO
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL-B
-# license as circulated by CEA, CNRS and INRIA at the following URL
+# license as circulated by CEA, CNRS and INRIA at the following URL m_view
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
# or in the file LICENSE.txt.
#
std::string namedb;
wxString infoimage;
wxString infoimageSource;
-
/// interface to read data
SimpleView m_view;
-
/// vtkImageData vector
std::vector<vtkImageData*> m_results;
std::vector< std::map<std::string,std::string> > m_resultsDicomAtr;
std::vector<std::string> m_attrDicomTags; // DXXXX_YYYY DAAAA_BBBB ...
-
- std::vector<creaImageIO::OutStrGimmick> m_resultsInfo;
-
+ std::vector<creaImageIO::OutStrGimmick> m_resultsInfo;
};
}