1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbcreaMaracasVisuSliceImage.h"
27 #include "bbcreaMaracasVisuPackage.h"
28 namespace bbcreaMaracasVisu
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,SliceImage)
34 BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
35 void SliceImage::Process()
37 vtkImageData *imagedata=NULL;
39 //std::cout<<"MSJ: test SliceImage::Process()"<<this<<std::endl;
40 if ( bbGetInputIn()!=NULL )
42 imageReslice->SetInput( bbGetInputIn() );
43 imageReslice->SetInformationInput(bbGetInputIn() );
45 if (bbGetInputTypeOrientation()==3)
47 // Orientation 3 = FREE
48 // v1 = [ v1x , v1y , v1z ]
49 // v2 = [ v2x , v2y , v2z ]
50 // v3 = [ v3x , v3y , v3z ]
51 // SetResliceAxesDirectionCosines(v1x,v2x,v3x,v1y,v2y,v3y,v1z,v2z,v3z);
52 imageReslice->SetResliceAxesDirectionCosines( bbGetInputResliceAxesDirectionCosines()[0], // v1x
53 bbGetInputResliceAxesDirectionCosines()[3], // v2x
54 bbGetInputResliceAxesDirectionCosines()[6], // v3x
55 bbGetInputResliceAxesDirectionCosines()[1], // v1y
56 bbGetInputResliceAxesDirectionCosines()[4], // v2y
57 bbGetInputResliceAxesDirectionCosines()[7], // v3y
58 bbGetInputResliceAxesDirectionCosines()[2], // v1z
59 bbGetInputResliceAxesDirectionCosines()[5], // v2z
60 bbGetInputResliceAxesDirectionCosines()[8] // v3z
62 imageReslice->SetResliceAxesOrigin( bbGetInputSlice()*bbGetInputIn()->GetSpacing()[0] ,0 ,0);
63 } else if (bbGetInputTypeOrientation()==2)
69 // SetResliceAxesDirectionCosines(v1x,v2x,v3x,v1y,v2y,v3y,v1z,v2z,v3z);
70 imageReslice->SetResliceAxesDirectionCosines(0,1,0, 0,0,-1 ,-1,0,0);
71 imageReslice->SetResliceAxesOrigin( bbGetInputSlice()*bbGetInputIn()->GetSpacing()[0] ,0 ,0);
72 } else if (bbGetInputTypeOrientation()==1) {
77 // SetResliceAxesDirectionCosines(v1x,v2x,v3x,v1y,v2y,v3y,v1z,v2z,v3z);
78 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,0,-1 ,0,1,0);
79 imageReslice->SetResliceAxesOrigin(0, bbGetInputSlice()*bbGetInputIn()->GetSpacing()[1],0 );
86 // SetResliceAxesDirectionCosines(v1x,v2x,v3x,v1y,v2y,v3y,v1z,v2z,v3z);
87 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
88 imageReslice->SetResliceAxesOrigin(0,0, bbGetInputSlice()*bbGetInputIn()->GetSpacing()[2] );
90 imageReslice->SetOutputDimensionality(2);
91 imageReslice->SetInterpolationModeToLinear();
92 imagedata = imageReslice->GetOutput();
94 imagedata->UpdateInformation();
96 bbSetOutputOut( imagedata );
100 //-----------------------------------------------------------------
101 void SliceImage::bbUserSetDefaultValues()
106 bbSetInputTypeOrientation(0);
108 std::vector<double> lstCos;
109 lstCos.push_back(1); // v1x
110 lstCos.push_back(0); // v1y
111 lstCos.push_back(0); // v1z
113 lstCos.push_back(0); // v2x
114 lstCos.push_back(1); // v2y
115 lstCos.push_back(0); // v2z
117 lstCos.push_back(0); // v3x
118 lstCos.push_back(0); // v3y
119 lstCos.push_back(1); // v3z
120 bbSetInputResliceAxesDirectionCosines(lstCos);
123 //-----------------------------------------------------------------
124 void SliceImage::bbUserInitializeProcessing()
126 imageReslice = vtkImageReslice::New();
129 //-----------------------------------------------------------------
130 void SliceImage::bbUserFinalizeProcessing()
134 //-----------------------------------------------------------------
138 // EO namespace bbcreaMaracasVisu