]> Creatis software - creaImageIO.git/blob - bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx
66f810ac388c742f1f5d828f80daddc18ab27c38
[creaImageIO.git] / bbtk / src / bbcreaImageIOItkImagesChooserDialogBox.cxx
1 //===== 
2 // 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)
3 //===== 
4
5 #include "bbcreaImageIOItkImagesChooserDialogBox.h"
6 #include "bbcreaImageIOPackage.h"
7
8 namespace bbcreaImageIO
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaImageIO,ItkImagesChooserDialogBox)
12 BBTK_BLACK_BOX_IMPLEMENTATION(ItkImagesChooserDialogBox,bbtk::AtomicBlackBox);
13 //===== 
14 // 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)
15 //===== 
16 void ItkImagesChooserDialogBox::Process()
17 {
18  
19         dlg = new creaImageIO::WxAnySimpleDlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
20     dlg->ShowModal(); 
21
22         bbtk::TypeInfo typ = bbitk::GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(*dlg->getTypes().front(), dlg->getDims().front());
23         BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, Export);
24         BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, ExportVTK);
25         
26         delete dlg;
27 }
28 template <class TImage>
29 void ItkImagesChooserDialogBox::Export()
30 {
31          if (dlg->getImagesSelected().size() == 1)
32          { 
33                 bbSetOutputOut( dlg->getTemplatedImagesSelected<TImage>().front().GetPointer() ); 
34          } 
35           else if (dlg->getImagesSelected().size() > 1)
36           { 
37                   OutputImagesITKType outVect;
38                 
39                   typename  std::vector<typename TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
40                   typename std::vector<typename TImage::Pointer>::iterator it = tempImgs.begin();
41                   for(;it != tempImgs.end(); ++it)
42                   {
43                           outVect.push_back( (*it).GetPointer() );
44                   }
45                 bbSetOutputOutIImages( outVect); 
46       } 
47           else
48           {
49                 bbSetOutputOut( NULL); 
50           }
51          // FCY To test the Output
52           //typedef itk::Image <short, 3> ImageType;
53          //typedef itk::ImageFileReader< ImageType > itkReaderType;
54      //  typename itkReaderType::Pointer reader = itkReaderType::New();
55      //
56      //  reader->SetFileName("d:\test.hdr");
57      //   reader->Update(); 
58          //reader->GetOutput()->Register();
59      //  this->bbSetOutputOut(reader->GetOutput());
60 }
61 template <class TImage>
62 void ItkImagesChooserDialogBox::ExportVTK()
63 {
64         // BBTK can support only a vector with same dimensions image.
65          if (dlg->getDims().front() < 4)
66          { 
67                   typename std::vector<typename TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
68                   typename std::vector<typename TImage::Pointer>::iterator it = tempImgs.begin();
69                   for(;it != tempImgs.end(); ++it)
70                   {
71                         dlg->split3Din3Dvtk<TImage>( (*it) );
72                   }
73                   bbSetOutputOutVImages( dlg->getVtkImagesSelected() ); 
74          } 
75          else if (dlg->getDims().front() == 4)
76           { 
77                 // To Test
78                  //  dlg->split4Din3Dvtk("d:/temp2");
79                  // bbSetOutputOutVImages( dlg->getVtkImagesSelected()); 
80       } 
81           else
82           {
83                   // NOT IMPLEMENTED YET FOR DIMENSIONS > 4
84                 
85           }
86          
87 }
88 //===== 
89 // 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)
90 //===== 
91 void ItkImagesChooserDialogBox::bbUserSetDefaultValues()
92 {
93  
94  
95   
96 }
97 //===== 
98 // 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)
99 //===== 
100 void ItkImagesChooserDialogBox::bbUserInitializeProcessing()
101 {
102
103 }
104 //===== 
105 // 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)
106 //===== 
107 void ItkImagesChooserDialogBox::bbUserFinalizeProcessing()
108 {
109
110 }
111 }
112 // EO namespace bbcreaImageIO
113
114