]> Creatis software - creaMaracasVisu.git/commitdiff
#3168 creaMaracas Visu Feature New Normal - In box ImageChangeInformation SetOrigin
authorEduardo DAVILA <davila@localhost.localdomain>
Fri, 5 Jan 2018 15:30:59 +0000 (16:30 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Fri, 5 Jan 2018 15:30:59 +0000 (16:30 +0100)
bbtk/src/bbmaracasvisuImageChangeInformation.cxx
bbtk/src/bbmaracasvisuImageChangeInformation.h

index 3ced61e9bf20037c59fe2731ef2af6e231f0d932..b956413ec6464a5ec823f63f58958306be973b12 100644 (file)
@@ -32,25 +32,19 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ImageChangeInformation)
 BBTK_BLACK_BOX_IMPLEMENTATION(ImageChangeInformation,bbtk::AtomicBlackBox);
 void ImageChangeInformation::Process()
 {
-       int ext[6];
-       double spc[3];
-       vtkImageData* img = bbGetInputIn();
-       if(img!=NULL){
+       int                     ext[6];
+       double                  spc[3];
+       double                  origin[3];
+       vtkImageData    *img = bbGetInputIn();
+       if(img!=NULL)
+       {
                if(mchange != NULL)
                {
                        mchange->Delete();
                }
                mchange = vtkImageChangeInformation::New();
                img->GetExtent( ext );  
-//             double origin[3];
-//             origin[0] = 0.0;
-//             origin[1] = 0.0;
-//             origin[2] = 0.0;
-//             img->SetOrigin(origin);         
                mchange->SetInput( img );
-//EED 2016 15 06
-//             mchange->SetExtentTranslation( -ext[0], -ext[2], -ext[4] );
-               mchange->SetOutputOrigin (0, 0, 0);
                mchange->SetOutputExtentStart(0,0,0);
                if (bbGetInputNewSpacing().size()==3)
                {
@@ -59,12 +53,29 @@ void ImageChangeInformation::Process()
                        spc[2] = bbGetInputNewSpacing()[2];
                        mchange->SetOutputSpacing( spc[0] , spc[1] , spc [2] );    //spacing
                }
+               if (bbGetInputNewOrigin().size()==3)
+               {
+                       if ( (bbGetInputNewOrigin()[0]==-1) && (bbGetInputNewOrigin()[1]==-1) && (bbGetInputNewOrigin()[2]==-1) )
+                       {
+                               img->GetOrigin( origin );       
+                       } else {
+                               origin[0] = bbGetInputNewOrigin()[0];
+                               origin[1] = bbGetInputNewOrigin()[1];
+                               origin[2] = bbGetInputNewOrigin()[2];
+                       }
+               } else {
+                       origin[0] = 0;
+                       origin[1] = 0;
+                       origin[2] = 0;
+               }
+               mchange->SetOutputOrigin( origin );
                mchange->Modified();    //important
                mchange->Update();    //important
                bbSetOutputOut( mchange->GetOutput() );
-       }  
+       }  // if img
 }
 
+
 void ImageChangeInformation::bbUserSetDefaultValues()
 {
        mchange = NULL;
index 7bfb67853efc48e6c14341fa12062336f14d25a2..9e0d0bfeb42af8ff063ba636d2e323dcf21e0896 100644 (file)
@@ -41,13 +41,13 @@ class /*BBTK_EXPORT*/ ImageChangeInformation
   BBTK_BLACK_BOX_INTERFACE(ImageChangeInformation,bbtk::AtomicBlackBox);
        BBTK_DECLARE_INPUT(In,vtkImageData*);
        BBTK_DECLARE_INPUT(NewSpacing,std::vector<double>);
-       
+       BBTK_DECLARE_INPUT(NewOrigin,std::vector<double>);
        BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
   BBTK_PROCESS(Process);
   void Process();
 
 private:
-           vtkImageChangeInformation   *mchange;
+       vtkImageChangeInformation       *mchange;
 
 };
 
@@ -57,7 +57,8 @@ BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
 BBTK_DESCRIPTION("vtkImageData change information. Translate extern to 0,0,0");
        BBTK_CATEGORY("filter");
        BBTK_INPUT(ImageChangeInformation,In,"Input image",vtkImageData*,"");
-       BBTK_INPUT(ImageChangeInformation,NewSpacing,"New spacing of the image (default: the same spacing of the original image)",std::vector<double>,"");
+       BBTK_INPUT(ImageChangeInformation,NewSpacing,"New spacing of the image. 3 elements (default: the same spacing of the original image)", std::vector<double> ,"");
+       BBTK_INPUT(ImageChangeInformation,NewOrigin,"New origin of the image. 3 elements (default: 0,0,0). (-1,-1,-1) get the same origin of the original image", std::vector<double> ,"");
        BBTK_OUTPUT(ImageChangeInformation,Out,"Output image",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ImageChangeInformation);
 }