]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.cxx
#3506 JSON write box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkJSONDataSetWriter.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 #include "bbcreaVtkJSONDataSetWriter.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include <vtkJSONDataSetWriter.h>
8 #include <vtkArchiver.h>
9
10 namespace bbcreaVtk
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,JSONDataSetWriter)
14 BBTK_BLACK_BOX_IMPLEMENTATION(JSONDataSetWriter,bbtk::AtomicBlackBox);
15 //===== 
16 // 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)
17 //===== 
18 void JSONDataSetWriter::Process()
19 {
20
21 // THE MAIN PROCESSING METHOD BODY
22 //   Here we simply set the input 'In' value to the output 'Out'
23 //   And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 //    void bbSet{Input|Output}NAME(const TYPE&)
26 //    const TYPE& bbGet{Input|Output}NAME() const 
27 //    Where :
28 //    * NAME is the name of the input/output
29 //      (the one provided in the attribute 'name' of the tag 'input')
30 //    * TYPE is the C++ type of the input/output
31 //      (the one provided in the attribute 'type' of the tag 'input')
32 //    bbSetOutputOut( bbGetInputIn() );
33 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
34   
35     
36     int             i;
37     int             sizeLstImages         = bbGetInputLstImages().size();
38     int             sizeLstFileNames    = bbGetInputLstFileNames().size();
39     vtkImageData    *image;
40     std::string     filename;
41     if ( (sizeLstImages>0) && (sizeLstImages==sizeLstFileNames) )
42     {
43         for ( i=0 ; i<sizeLstImages ; i++ )
44         {
45             image       = bbGetInputLstImages()[i];
46             filename    = bbGetInputLstFileNames()[i];
47             if (image!=NULL)
48             {
49                 vtkJSONDataSetWriter *writer = vtkJSONDataSetWriter::New();
50                 writer->GetArchiver()->SetArchiveName( filename.c_str() );
51                 writer->SetInputData( image );
52                 writer->Update();
53             } // if image
54         }// for
55     } // if size
56     
57 }
58 //===== 
59 // 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)
60 //===== 
61 void JSONDataSetWriter::bbUserSetDefaultValues()
62 {
63
64 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
65 //    Here we initialize the input 'In' to 0
66 //   bbSetInputIn(NULL);
67   
68 }
69 //===== 
70 // 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)
71 //===== 
72 void JSONDataSetWriter::bbUserInitializeProcessing()
73 {
74
75 //  THE INITIALIZATION METHOD BODY :
76 //    Here does nothing 
77 //    but this is where you should allocate the internal/output pointers 
78 //    if any 
79
80   
81 }
82 //===== 
83 // 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)
84 //===== 
85 void JSONDataSetWriter::bbUserFinalizeProcessing()
86 {
87
88 //  THE FINALIZATION METHOD BODY :
89 //    Here does nothing 
90 //    but this is where you should desallocate the internal/output pointers 
91 //    if any
92   
93 }
94 }
95 // EO namespace bbcreaVtk
96
97