]> Creatis software - creaVtk.git/commitdiff
#3500 bug ImageCutByAxis
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 20 Jan 2023 11:37:36 +0000 (12:37 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 20 Jan 2023 11:37:36 +0000 (12:37 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.h

index 687ee7394d561e28836f19f38a5b7838558f2b25..7884c293d4df70b1c5aadcd759bda8d030cadd17 100644 (file)
@@ -42,27 +42,39 @@ void ImageCutByAxis::Process()
        bbGetInputIn()->GetExtent(ext);
 #endif
 
-       double dimX=ext[1]-ext[0]+1;
-       double dimY=ext[3]-ext[2]+1;
-       double dimZ=ext[5]-ext[4]+1;
+       double  dimX    = ext[1]-ext[0]+1;
+       double  dimY    = ext[3]-ext[2]+1;
+       double  dimZ    = ext[5]-ext[4]+1;
 
-       int x=bbGetInputPoint()[0];
-       int y=bbGetInputPoint()[1];
-       int z=bbGetInputPoint()[2];
+       int     x       = bbGetInputPoint()[0];
+       int     y       = bbGetInputPoint()[1];
+       int     z       = bbGetInputPoint()[2];
 
-       int i,j;
+       int i,j,k;
        bool c1=false;
        bool c2=false;
        bool c3=false;
        bool c4=false;
+    bool c5=false;
+    bool c6=false;
+    bool c7=false;
+    bool c8=false;
 
        if ( bbGetInputType()=="x-y-z+" ) 
        {
                if (bbGetInputTypeOrientation()==0)  { c1=false;        c2=true;        c3=true;        c4=true;        }
                if (bbGetInputTypeOrientation()==1)  { c1=true;         c2=false;       c3=true;        c4=true;        }
                if (bbGetInputTypeOrientation()==2)  { c1=true;         c2=false;       c3=true;        c4=true;        }
+        if (bbGetInputTypeOrientation()==3)  { c1=false;    c2=true;    c3=true;    c4=true;    }
        }
 
+    if ( bbGetInputType()=="x+y+z+"    )
+    {
+        if (bbGetInputTypeOrientation()==3)  { c1=false;    c2=false;    c3=false;    c4=false;  c5=true;    c6=false;    c7=false;    c8=false;  }
+    }
+
+    
+    
        if (bbGetInputInsideVol()==true)
        {
                c1=!c1;
@@ -71,8 +83,13 @@ void ImageCutByAxis::Process()
                c4=!c4;
        } // IndideVol
 
+    printf("EED  ImageCutByAxis::Process\n");
+    if (c1==true) printf("EED  ImageCutByAxis::Process flag 1\n");
+    if (c2==true) printf("EED  ImageCutByAxis::Process flag 2\n");
+    if (c3==true) printf("EED  ImageCutByAxis::Process flag 3\n");
+    if (c4==true) printf("EED  ImageCutByAxis::Process flag 4\n");
 
-       int xmin,xmax,ymin,ymax;
+       int xmin,xmax,ymin,ymax,zmin,zmax;
 
 //     void *imgPtr;
 //             imgPtr=bbGetInputIn()->GetScalarPointer(x,y,z,0);
@@ -80,19 +97,25 @@ void ImageCutByAxis::Process()
        
        if (c1==true)
        {
-               if (bbGetInputTypeOrientation()==0)  { xmin=0; xmax=x; ymin=0; ymax=y;                          }
-               if (bbGetInputTypeOrientation()==1)  { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY;          }
-               if (bbGetInputTypeOrientation()==2)  { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY;          }
-               for (j=ymin;j<ymax;j++){
-                       for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
-               } // for j
+        if (bbGetInputTypeOrientation()==0)  { xmin=0; xmax=x; ymin=0;      ymax=y;        zmin=0; zmax=1;         }
+        if (bbGetInputTypeOrientation()==1)  { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY;     zmin=0; zmax=1;         }
+        if (bbGetInputTypeOrientation()==2)  { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY;             zmin=0; zmax=1;             }
+        if (bbGetInputTypeOrientation()==3)  { xmin=0; xmax=x; ymin=0;      ymax=y;         zmin=0; zmax=z;    }   // xyz
+        printf("EED  ImageCutByAxis::Process x=%d %d      y= %d %d     z=%d %d\n", xmin,xmax , ymin,ymax, zmin,zmax );
+
+        for (k=zmin;k<zmax;k++){
+            for (j=ymin;j<ymax;j++){
+                for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,k,0,0);} // for i
+            } // for j
+        } // for k
        }  // c1
 
        if (c2==true)
-       { 
+       {
                if (bbGetInputTypeOrientation()==0)  { xmin=0; xmax=x; ymin=y; ymax=dimY;                       }
                if (bbGetInputTypeOrientation()==1)  { xmin=0; xmax=x; ymin=0; ymax=dimY-z;                     }
                if (bbGetInputTypeOrientation()==2)  { xmin=0; xmax=y; ymin=0; ymax=dimY-z;             }
+        if (bbGetInputTypeOrientation()==3)  { xmin=0; xmax=x; ymin=y; ymax=dimY;             }
                for (j=ymin;j<ymax;j++){
                        for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
                } // for j
@@ -100,9 +123,10 @@ void ImageCutByAxis::Process()
 
        if (c3==true)  
        { 
-               if (bbGetInputTypeOrientation()==0)  { xmin=x; xmax=dimX; ymin=0; ymax=y;                       }
-               if (bbGetInputTypeOrientation()==1)  { xmin=x; xmax=dimX; ymin=dimY-z; ymax=dimY;       }
-               if (bbGetInputTypeOrientation()==2)  { xmin=y; xmax=dimX; ymin=dimY-z; ymax=dimY;       }
+               if (bbGetInputTypeOrientation()==0)  { xmin=x; xmax=dimX; ymin=0;       ymax=y;     }
+               if (bbGetInputTypeOrientation()==1)  { xmin=x; xmax=dimX; ymin=dimY-z;  ymax=dimY;      }
+               if (bbGetInputTypeOrientation()==2)  { xmin=y; xmax=dimX; ymin=dimY-z;  ymax=dimY;      }
+        if (bbGetInputTypeOrientation()==3)  { xmin=x; xmax=dimX; ymin=0;       ymax=y;     }
                for (j=ymin;j<ymax;j++){
                        for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
                } // for j
@@ -113,11 +137,32 @@ void ImageCutByAxis::Process()
                if (bbGetInputTypeOrientation()==0)  { xmin=x; xmax=dimX; ymin=y; ymax=dimY;            }
                if (bbGetInputTypeOrientation()==1)  { xmin=x; xmax=dimX; ymin=0; ymax=dimY-z;          }
                if (bbGetInputTypeOrientation()==2)  { xmin=y; xmax=dimX; ymin=0; ymax=dimY-z;          }
+        if (bbGetInputTypeOrientation()==3)  { xmin=x; xmax=dimX; ymin=y; ymax=dimY;         }
                for (j=ymin;j<ymax;j++){
                        for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
                } // for j
 
        } //c4
+    
+    
+    if (c5==true)
+    {
+        if (bbGetInputTypeOrientation()==0)  { xmin=0; xmax=x;    ymin=0;      ymax=y;           zmin=0; zmax=1;         }
+        if (bbGetInputTypeOrientation()==1)  { xmin=0; xmax=x;    ymin=dimY-z; ymax=dimY;        zmin=0; zmax=1;       }
+        if (bbGetInputTypeOrientation()==2)  { xmin=0; xmax=y;    ymin=dimY-z; ymax=dimY;         zmin=0; zmax=1;       }
+        if (bbGetInputTypeOrientation()==3)  { xmin=x; xmax=dimX; ymin=y;      ymax=dimY;         zmin=z; zmax=dimZ;    }   // xyz
+        printf("EED  ImageCutByAxis::Process x=%d %d      y= %d %d     z=%d %d\n", xmin,xmax , ymin,ymax, zmin,zmax );
+
+        for (k=zmin;k<zmax;k++){
+            for (j=ymin;j<ymax;j++){
+                for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,k,0,0);} // for i
+            } // for j
+        } // for k
+    }  // c1
+
+    
+    
+    
        newData->Modified();
        bbSetOutputOut( newData );
 
index 6c9dc47db2ca76a02cf4458530c2880fd1204252..2348c0c53d8002903528d011dbc244f2938df1e3 100644 (file)
@@ -43,7 +43,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageCutByAxis,bbtk::AtomicBlackBox);
        BBTK_INPUT(ImageCutByAxis,Type,"(default x-y-z+)  missing all options:x y z  x+y+  x-y+ x+y- x-y-  y+z+  y+z- y-z+ y-z-  x+z+  x+z- x-z+ x-z-   x+y+z+ x-y+z+ x+y-z+ x+y+z- x-y-z+ x-y+z- x+y-z- x-y-z-",std::string,"");
        BBTK_INPUT(ImageCutByAxis,InsideVol,"Inside volume",bool,"");
        BBTK_INPUT(ImageCutByAxis,Point,"First input",std::vector<int>,"");
-       BBTK_INPUT(ImageCutByAxis,TypeOrientation,"TypeOrientation (default 0) 0=XY 1=XZ 2=YZ",int,"");
+       BBTK_INPUT(ImageCutByAxis,TypeOrientation,"TypeOrientation (default 0) 0=XY 1=XZ 2=YZ 3=XYZ",int,"");
        BBTK_OUTPUT(ImageCutByAxis,Out,"Output image",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ImageCutByAxis);
 //=====