]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuSliceImage.cxx
f55ea4703c40cff05c617ee760f19695708b5a3a
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuSliceImage.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "bbcreaMaracasVisuSliceImage.h"
27 #include "bbcreaMaracasVisuPackage.h"
28 namespace bbcreaMaracasVisu
29 {
30
31         
32         
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,SliceImage)
34 BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
35 void SliceImage::Process()
36 {
37         //printf("EED 0 SliceImage::Process \n");
38         vtkImageData *imagedata=NULL;
39
40         //std::cout<<"MSJ: test SliceImage::Process()"<<this<<std::endl;
41         if ( bbGetInputIn()!=NULL )
42         {
43           imageReslice->SetInput( bbGetInputIn() );
44           imageReslice->SetInformationInput(bbGetInputIn() );
45
46           if (bbGetInputTypeOrientation()==2)
47           {
48                imageReslice->SetResliceAxesDirectionCosines(0,0,1, 1,0,0 ,0,1,0);  // 2=YZ
49           } else if (bbGetInputTypeOrientation()==1) {     
50                imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,0,-1 ,0,1,0);  // 1=XZ
51           } else    
52           {
53                imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);   // 0=XY
54           } 
55
56
57
58           imageReslice->SetResliceAxesOrigin(0,0, bbGetInputZ()*bbGetInputIn()->GetSpacing()[2] );
59           imageReslice->SetOutputDimensionality(2);
60           imageReslice->SetInterpolationModeToLinear();
61           imagedata = imageReslice->GetOutput();
62           imagedata->Update();
63           imagedata->UpdateInformation();       
64           //printf("EED 1 SliceImage::Process %p\n", imagedata);
65         }
66   bbSetOutputOut( imagedata );
67 }
68         
69         
70         //-----------------------------------------------------------------     
71         void SliceImage::bbUserSetDefaultValues()
72         {
73                 bbSetInputIn(NULL);
74                 bbSetInputZ(0);
75                 bbSetInputTypeOrientation(0);
76                 imageReslice=NULL;
77         }
78         
79         //-----------------------------------------------------------------     
80         void SliceImage::bbUserInitializeProcessing()
81         {
82                 imageReslice = vtkImageReslice::New();
83         }
84         
85         //-----------------------------------------------------------------     
86         void SliceImage::bbUserFinalizeProcessing()
87         {
88         }
89         
90         //-----------------------------------------------------------------     
91         
92         
93 }
94 // EO namespace bbcreaMaracasVisu
95
96