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