]> Creatis software - creaImageIO.git/blob - bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx
2d9074973262fb6015f58e07eac71ddaa57c3634
[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                   std::vector<TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
39                   std::vector<TImage::Pointer>::iterator it = tempImgs.begin();
40                   for(;it != tempImgs.end(); ++it)
41                   {
42                           outVect.push_back( (*it).GetPointer() );
43                   }
44                 bbSetOutputOutIImages( outVect); 
45       } 
46           else
47           {
48                 bbSetOutputOut( NULL); 
49           }
50          // FCY To test the Output
51           //typedef itk::Image <short, 3> ImageType;
52          //typedef itk::ImageFileReader< ImageType > itkReaderType;
53      //  typename itkReaderType::Pointer reader = itkReaderType::New();
54      //
55      //  reader->SetFileName("d:\test.hdr");
56      //   reader->Update(); 
57          //reader->GetOutput()->Register();
58      //  this->bbSetOutputOut(reader->GetOutput());
59 }
60 template <class TImage>
61 void ItkImagesChooserDialogBox::ExportVTK()
62 {
63         // BBTK can support only a vector with same dimensions image.
64          if (dlg->getDims().front() < 4)
65          { 
66                   std::vector<TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
67                   std::vector<TImage::Pointer>::iterator it = tempImgs.begin();
68                   for(;it != tempImgs.end(); ++it)
69                   {
70                         dlg->split3Din3Dvtk<TImage>( (*it) );
71                   }
72                   bbSetOutputOutVImages( dlg->getVtkImagesSelected() ); 
73          } 
74          else if (dlg->getDims().front() == 4)
75           { 
76                 // To Test
77                  //  dlg->split4Din3Dvtk("d:/temp2");
78                  // bbSetOutputOutVImages( dlg->getVtkImagesSelected()); 
79       } 
80           else
81           {
82                   // NOT IMPLEMENTED YET FOR DIMENSIONS > 4
83                 
84           }
85          
86 }
87 //===== 
88 // 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)
89 //===== 
90 void ItkImagesChooserDialogBox::bbUserSetDefaultValues()
91 {
92  
93  
94   
95 }
96 //===== 
97 // 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)
98 //===== 
99 void ItkImagesChooserDialogBox::bbUserInitializeProcessing()
100 {
101
102 }
103 //===== 
104 // 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)
105 //===== 
106 void ItkImagesChooserDialogBox::bbUserFinalizeProcessing()
107 {
108
109 }
110 }
111 // EO namespace bbcreaImageIO
112
113