]> Creatis software - creaImageIO.git/blob - bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx
Feature #1764
[creaImageIO.git] / bbtk / src / bbcreaImageIOItkImagesChooserDialogBox.cxx
1 /*
2         # ---------------------------------------------------------------------
3         #
4         # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5         #                        pour la Santé)
6         # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7         # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8         # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9         #
10         #  This software is governed by the CeCILL-B license under French law and 
11         #  abiding by the rules of distribution of free software. You can  use, 
12         #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13         #  license as circulated by CEA, CNRS and INRIA at the following URL 
14         #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15         #  or in the file LICENSE.txt.
16         #
17         #  As a counterpart to the access to the source code and  rights to copy,
18         #  modify and redistribute granted by the license, users are provided only
19         #  with a limited warranty  and the software's author,  the holder of the
20         #  economic rights,  and the successive licensors  have only  limited
21         #  liability. 
22         #
23         #  The fact that you are presently reading this means that you have had
24         #  knowledge of the CeCILL-B license and that you accept its terms.
25         # ------------------------------------------------------------------------
26 */
27 //===== 
28 // 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)
29 //===== 
30
31 #include "bbcreaImageIOItkImagesChooserDialogBox.h"
32 #include "bbcreaImageIOPackage.h"
33
34 namespace bbcreaImageIO
35 {
36
37 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaImageIO,ItkImagesChooserDialogBox)
38 BBTK_BLACK_BOX_IMPLEMENTATION(ItkImagesChooserDialogBox,bbtk::AtomicBlackBox);
39 //===== 
40 // 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)
41 //===== 
42 void ItkImagesChooserDialogBox::Process()
43 {
44  
45     dlg = new creaImageIO::WxAnySimpleDlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
46     dlg->ShowModal(); 
47
48     bbtk::TypeInfo typ = bbitk::GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(*dlg->getTypes().front(), dlg->getDims().front());
49     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, Export);
50     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ, ExportVTK);
51
52     delete dlg;
53 }
54
55 template <class TImage>
56 void ItkImagesChooserDialogBox::Export()
57 {
58    if (dlg->getImagesSelected().size() == 1)
59    { 
60                 bbSetOutputOut( dlg->getTemplatedImagesSelected<TImage>().front().GetPointer() ); 
61    } 
62    else if (dlg->getImagesSelected().size() > 1)
63    { 
64       OutputImagesITKType outVect;
65
66       typename  std::vector<typename TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
67       typename std::vector<typename TImage::Pointer>::iterator it = tempImgs.begin();
68       for(;it != tempImgs.end(); ++it)
69       {
70          outVect.push_back( (*it).GetPointer() );
71       }
72       bbSetOutputOutIImages( outVect); 
73    } 
74    else
75    {
76       // warning: passing NULL to non-pointer 
77       //bbSetOutputOut( NULL);
78       bbSetOutputOut(0); // JPR
79    }
80          // FCY To test the Output
81           //typedef itk::Image <short, 3> ImageType;
82          //typedef itk::ImageFileReader< ImageType > itkReaderType;
83      //  typename itkReaderType::Pointer reader = itkReaderType::New();
84      //
85      //  reader->SetFileName("d:\test.hdr");
86      //   reader->Update(); 
87          //reader->GetOutput()->Register();
88      //  this->bbSetOutputOut(reader->GetOutput());
89 }
90 template <class TImage>
91 void ItkImagesChooserDialogBox::ExportVTK()
92 {
93         // BBTK can support only a vector with same dimensions image.
94          if (dlg->getDims().front() < 4)
95          { 
96                   typename std::vector<typename TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
97                   typename std::vector<typename TImage::Pointer>::iterator it = tempImgs.begin();
98                   for(;it != tempImgs.end(); ++it)
99                   {
100                         dlg->split3Din3Dvtk<TImage>( (*it) );
101                   }
102                   bbSetOutputOutVImages( dlg->getVtkImagesSelected() ); 
103          } 
104          else if (dlg->getDims().front() == 4)
105          { 
106                 // To Test
107                  //  dlg->split4Din3Dvtk("d:/temp2");
108                  // bbSetOutputOutVImages( dlg->getVtkImagesSelected()); 
109          } 
110          else
111          {
112                   // NOT IMPLEMENTED YET FOR DIMENSIONS > 4
113         
114          }
115          
116 }
117 //===== 
118 // 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)
119 //===== 
120 void ItkImagesChooserDialogBox::bbUserSetDefaultValues()
121 {
122  
123 }
124 //===== 
125 // 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)
126 //===== 
127 void ItkImagesChooserDialogBox::bbUserInitializeProcessing()
128 {
129
130 }
131 //===== 
132 // 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)
133 //===== 
134 void ItkImagesChooserDialogBox::bbUserFinalizeProcessing()
135 {
136
137 }
138 }
139 // EO namespace bbcreaImageIO