]> Creatis software - bbtk.git/commitdiff
2024 Feature FLIP X Y Z
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 5 Jun 2013 14:51:31 +0000 (16:51 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 5 Jun 2013 14:51:31 +0000 (16:51 +0200)
packages/vtk/src/bbvtkFlip.cxx
packages/vtk/src/bbvtkFlip.h

index 1a65c9d3ead709b4a022a7feecc882ed02a5ef2b..d37aa6fb2c8a9e759174bc23d8e19c56c10af017 100644 (file)
@@ -54,6 +54,7 @@ namespace bbvtk
       //std::cout << "-------- entree ds Flip::bbUserSetDefaultValues()\n" << std::endl;
       
       bbSetInputIn(NULL); 
+      bbSetInputAxis("Y"); 
       mImageOut = NULL;
       bbSetOutputOut(NULL);
    }
@@ -120,19 +121,55 @@ void Flip::Process()
                char *lineOut;
                char *debPlanIn;
                char *debPlanOut;
-               int j,k;
-               for(k=0; k<inputdims[2]; k++)  // iterate on planes
+               int i,j,k;
+               
+               if ( (bbGetInputAxis()=="X") || (bbGetInputAxis()=="x") )
                {  
-                       debPlanIn       = pixelsIn+k*planeSize;
-                       debPlanOut      = pixelsOut+k*planeSize;
-                       for(j=0; j<inputdims[1]; j++)  // iterates on rows
-                       { 
-                               lineIn = debPlanIn+j*lineSize;
-                               lineOut = debPlanOut+(inputdims[1]-1-j)*lineSize;
-                               memcpy(lineOut,  lineIn, lineSize);
-                       }       // for j
-               } // for k
-       
+
+                       for(k=0; k<inputdims[2]; k++)  // iterate  planes
+                       {  
+                               for(j=0; j<inputdims[1]; j++)  // iterates  rows
+                               { 
+                                       for(i=0; i<inputdims[0]; i++)  // iterates  columns
+                                       { 
+                                               pixelsIn = (char *)bbGetInputIn()->GetScalarPointer(i,j,k);
+                                               pixelsOut = (char *)mImageOut->GetScalarPointer(inputdims[0]-1-i,j,k);
+                                               memcpy(pixelsOut,  pixelsIn, scalarSize );
+                                       }       // for i
+                               }       // for j
+                       } // for k
+
+               } else if ( (bbGetInputAxis()=="Z") || (bbGetInputAxis()=="z") )  {  
+
+                       for(k=0; k<inputdims[2]; k++)  // iterate  planes
+                       {  
+                               for(j=0; j<inputdims[1]; j++)  // iterates  rows
+                               { 
+                                       for(i=0; i<inputdims[0]; i++)  // iterates  columns
+                                       { 
+                                               pixelsIn = (char *)bbGetInputIn()->GetScalarPointer(i,j,k);
+                                               pixelsOut = (char *)mImageOut->GetScalarPointer(i,j,inputdims[2]-1-k);
+                                               memcpy(pixelsOut,  pixelsIn, scalarSize );
+                                       }       // for i
+                               }       // for j
+                       } // for k
+
+               } else {  
+
+                       for(k=0; k<inputdims[2]; k++)  // iterate  planes
+                       {  
+                               debPlanIn       = pixelsIn+k*planeSize;
+                               debPlanOut      = pixelsOut+k*planeSize;
+                               for(j=0; j<inputdims[1]; j++)  // iterates  rows
+                               { 
+                                       lineIn = debPlanIn+j*lineSize;
+                                       lineOut = debPlanOut+(inputdims[1]-1-j)*lineSize;
+                                       memcpy(lineOut,  lineIn, lineSize);
+                               }       // for j
+                       } // for k
+
+               } //if
+               mImageOut->Modified();
                bbSetOutputOut( mImageOut  );           
        } // bbGetInputIn
 
index 09a91650d0c0059a8b0ff526c2eb0efefb60c159..3cf69561e19d438169f50410fb16a63e734ed533 100644 (file)
@@ -64,7 +64,8 @@ namespace bbvtk
   { 
   public:
     BBTK_BLACK_BOX_INTERFACE(Flip, bbtk::AtomicBlackBox);
-    BBTK_DECLARE_INPUT (In,vtkImageData *);  
+    BBTK_DECLARE_INPUT(In,vtkImageData *);  
+    BBTK_DECLARE_INPUT(Axis,std::string);  
     BBTK_DECLARE_OUTPUT(Out, vtkImageData*);    
     BBTK_PROCESS(Process);
     void Process();
@@ -85,6 +86,7 @@ namespace bbvtk
   BBTK_DESCRIPTION("flips a <vtkImageData*>");
   BBTK_CATEGORY("application, image");
   BBTK_INPUT(Flip, In, "image", vtkImageData *, "");
+  BBTK_INPUT(Flip, Axis, "Axe (default Y)  X Y Z", std::string, "");
   BBTK_OUTPUT(Flip, Out, "fliped image", vtkImageData *, "");
   BBTK_END_DESCRIBE_BLACK_BOX(Flip);   
   //=================================================================