]> Creatis software - bbtk.git/commitdiff
#3157 BBTK Feature New - NormalInvertCropBox Active
authorEduardo DAVILA <davila@localhost.localdomain>
Wed, 6 Dec 2017 18:54:19 +0000 (19:54 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Wed, 6 Dec 2017 18:54:19 +0000 (19:54 +0100)
packages/vtk/src/bbvtkInversCrop.cxx
packages/vtk/src/bbvtkInversCrop.h

index 97963bca7327d6d4f3edc07a6ac10e4ba8019d7f..28c097afe9bed7b59d237b89d812c3e055e65dbc 100644 (file)
@@ -26,87 +26,93 @@ void InversCrop::Process()
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
 
-    if ((bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) )
-    {
-     if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() ) 
-     {
-        // Creating Image
-       int dim[3];
-       int ext[6];
+       if (bbGetInputActive()==true)
+       {
+printf("EED InversCrop::Process %d %d %d\n", bbGetInputOrigin()[0], bbGetInputOrigin()[1], bbGetInputOrigin()[2]);
+           if ( (bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) )
+           {
+            if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() ) 
+            {
+               // Creating Image
+               int dim[3];
+               int ext[6];
        
-       bbGetInputImageFix()->GetWholeExtent(ext);
-       dim[0]= ext[1]-ext[0]+1;
-       dim[1]= ext[3]-ext[2]+1;
-       dim[2]= ext[5]-ext[4]+1;
+               bbGetInputImageFix()->GetWholeExtent(ext);
+               dim[0]= ext[1]-ext[0]+1;
+               dim[1]= ext[3]-ext[2]+1;
+               dim[2]= ext[5]-ext[4]+1;
 
-       if (bbGetInputType()==0)
-       {
-               _imageoutput = vtkImageData::New();
-               _imageoutput->Initialize();
-               _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() );
-               _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() );
-               _imageoutput->SetDimensions(  dim[0], dim[1], dim[2] );
-               _imageoutput->AllocateScalars();
-       }
-       if (bbGetInputType()==1)
-       {
-               _imageoutput=bbGetInputImageFix();
-       }
-
-
-        // Duplicating Fix Image
-       long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize();    
-       memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage);
-
-       // Copy the Move Image
-       int j,k; 
-       int px,py,pz;
-
-       bbGetInputImageMove()->GetWholeExtent(ext);
-       int dimMoveX = ext[1]-ext[0]+1;
-       int dimMoveY = ext[3]-ext[2]+1;
-       int dimMoveZ = ext[5]-ext[4]+1;
-
-        int spxM=0;  // start px MoveImage
-        int sizeXM=0;  // sizeX MoveImage
-
-       px=bbGetInputOrigin()[0];
-        spxM=0;
-        if (px<=0)
-       { 
-          spxM=px*(-1);
-          px=0;
-       }
-       sizeXM = dimMoveX-spxM;
-       if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px;
-
-       sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize();
-       for (k=0; k<dimMoveZ; k++)
-       {
-          for (j=0; j<dimMoveY; j++)
-          {
-                py=j+bbGetInputOrigin()[1];
-               pz=k+bbGetInputOrigin()[2];
-               
-               if ( (py<dim[1]) && (pz<dim[2]) &&
-                    (py>=0)    && (pz>=0)      &&
-                    (sizeXM>0) ) 
+               if (bbGetInputType()==0)
                {
-                       memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
+                       _imageoutput = vtkImageData::New();
+                       _imageoutput->Initialize();
+                       _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() );
+                       _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() );
+                       _imageoutput->SetDimensions(  dim[0], dim[1], dim[2] );
+                       _imageoutput->AllocateScalars();
                }
+               if (bbGetInputType()==1)
+               {
+                       _imageoutput=bbGetInputImageFix();
+               }
+
+
+               // Duplicating Fix Image
+               long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize();    
+               memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage);
+
+               // Copy the Move Image
+               int j,k; 
+               int px,py,pz;
+
+               bbGetInputImageMove()->GetWholeExtent(ext);
+               int dimMoveX = ext[1]-ext[0]+1;
+               int dimMoveY = ext[3]-ext[2]+1;
+               int dimMoveZ = ext[5]-ext[4]+1;
+
+               int spxM=0;  // start px MoveImage
+               int sizeXM=0;  // sizeX MoveImage
+
+               px=bbGetInputOrigin()[0];
+               spxM=0;
+               if (px<=0)
+               { 
+                  spxM=px*(-1);
+                  px=0;
+               }
+               sizeXM = dimMoveX-spxM;
+               if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px;
+
+               sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize();
+               for (k=0; k<dimMoveZ; k++)
+               {
+                  for (j=0; j<dimMoveY; j++)
+                  {
+                       py=j+bbGetInputOrigin()[1];
+                       pz=k+bbGetInputOrigin()[2];
+               
+                       if ( (py<dim[1]) && (pz<dim[2]) &&
+                            (py>=0)    && (pz>=0)      &&
+                            (sizeXM>0) ) 
+                       {
+                               memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
+                       }
+
+                  } // for j
+               } // for k
+               _imageoutput->Modified();
+             } // If Image Fixe Move the same GetScalarType
+               else {
+                  printf ("ERROR: InversCrop  both ImageFixe and ImageMove need the same format.\n");
+             }  
+           } // If Image Fixe Move != NULL   
+            else {
+               printf ("ERROR: InversCrop  need ImageFixe and ImageMove to run.\n");
+           } 
+           bbSetOutputOut(_imageoutput);
+
+       } // if Active
 
-          } // for j
-       } // for k
-        _imageoutput->Modified();
-      } // If Image Fixe Move the same GetScalarType
-        else {
-           printf ("ERROR: InversCrop  both ImageFixe and ImageMove need the same format.\n");
-      }  
-    } // If Image Fixe Move != NULL
-     else {
-        printf ("ERROR: InversCrop  need ImageFixe and ImageMove to run.\n");
-    } 
-    bbSetOutputOut(_imageoutput);
 }
 
 //===== 
@@ -114,19 +120,17 @@ void InversCrop::Process()
 //===== 
 void InversCrop::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
+   bbSetInputActive(true);
    bbSetInputType(0);
    bbSetInputImageFix(NULL);
    bbSetInputImageMove(NULL);
-
    std::vector<int> origin;
    origin.push_back(0);
    origin.push_back(0);
    origin.push_back(0);
    bbSetInputOrigin(origin);
-   
    _imageoutput=NULL;
 }
 //===== 
index 59d90dc0fafb91446211c8e57a68834952962ee3..fc56a555dd7dd74a5ab807e5f31d7b49ac343429 100644 (file)
@@ -21,6 +21,8 @@ class bbvtk_EXPORT InversCrop
 //===== 
 // 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)
 //===== 
+       
+  BBTK_DECLARE_INPUT(Active,bool);
   BBTK_DECLARE_INPUT(Type,int);
   BBTK_DECLARE_INPUT(ImageFix,vtkImageData*);
   BBTK_DECLARE_INPUT(ImageMove,vtkImageData*);
@@ -40,14 +42,12 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(InversCrop,bbtk::AtomicBlackBox);
   BBTK_AUTHOR("InfoDev");
   BBTK_DESCRIPTION("Invers Crop, Both images had to have the same format");
   BBTK_CATEGORY("");
-
+  BBTK_INPUT(InversCrop,Active,"true/false (default true)",bool,"");
   BBTK_INPUT(InversCrop,Type,"(default 0) 0=Create image for the result FixImage+MoveImage, 1=Use the FixImage as output",int,"");
   BBTK_INPUT(InversCrop,ImageFix,"Fix Image (necesary). Need same format of ImageMove",vtkImageData*,"");
   BBTK_INPUT(InversCrop,ImageMove,"Move Image (necesary). Need same format of ImageFix",vtkImageData*,"");
   BBTK_INPUT(InversCrop,Origin,"Position to be put de Move Image (default 0,0,0 )",std::vector<int>,"");
-
   BBTK_OUTPUT(InversCrop,Out,"First output",vtkImageData*,"");
-
 BBTK_END_DESCRIBE_BLACK_BOX(InversCrop);
 //===== 
 // 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)