]> Creatis software - bbtk.git/commitdiff
#3467 Bug: InvertCrop Dimension of 2D or 3D
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 21 Jun 2021 11:41:04 +0000 (13:41 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 21 Jun 2021 11:41:04 +0000 (13:41 +0200)
packages/vtk/src/bbvtkInversCrop.cxx

index 03673e6f1b476d88636824cfb70c7591c8a7e17f..1c71fe01fafe20e98a37f7568354ab36c9e5fd25 100644 (file)
@@ -98,18 +98,39 @@ printf("EED InversCrop::Process 2   %d %d  %d \n",dim[0],dim[1],dim[2]  );
                {
                        dimMoveZ = ext[5]-ext[4]+1;
                } 
-
-               
 printf("EED InversCrop::Process 3   %d %d  %d \n",dimMoveX,dimMoveY,dimMoveZ  );
 
+
+               double org[3];
+               org[0]=0;
+               org[1]=0;
+               org[2]=0;
                
+               if (bbGetInputOrigin().size()==3)
+               {
+                       org[0]=bbGetInputOrigin()[0];
+                       org[1]=bbGetInputOrigin()[1];
+                       org[2]=bbGetInputOrigin()[2];
+               }
+               
+               if (bbGetInputOrigin().size()==2)
+               {
+                       org[0]=bbGetInputOrigin()[0];
+                       org[1]=bbGetInputOrigin()[1];
+               }
+
+               if (bbGetInputOrigin().size()==1)
+               {
+                       org[0]=bbGetInputOrigin()[0];
+               }
+
                
                int spxM                = 0;  // start px MoveImage
                int sizeXM              = 0;  // sizeX MoveImage
 printf("EED InversCrop::Process 3.1   sizeOrigin %d \n", bbGetInputOrigin().size() );
-printf("EED InversCrop::Process 3.1   Origin %d  %d %d\n", bbGetInputOrigin()[0],bbGetInputOrigin()[1],bbGetInputOrigin()[2] );
+printf("EED InversCrop::Process 3.1   Origin %f  %f %f\n", org[0],org[1],org[2] );
 
-               px                              = bbGetInputOrigin()[0];
+               px                              = org[0];
                spxM                    = 0;
                if (px<0)
                { 
@@ -119,14 +140,15 @@ printf("EED InversCrop::Process 3.1   Origin %d  %d %d\n", bbGetInputOrigin()[0]
                sizeXM  = dimMoveX-spxM;
                if (px+sizeXM>=dim[0]) { sizeXM=dim[0]-px; }
                sizeXM  = sizeXM * bbGetInputImageFix()->GetScalarSize();
+printf("4. \n");
                for (k=0; k<dimMoveZ; k++)
                {
                   for (j=0; j<dimMoveY; j++)
                   {
-                       py = j+bbGetInputOrigin()[1];
+                       py = j+org[1];
                                if (bbGetInputImageMove()->GetDataDimension()==3) 
                                {
-                                       pz = k+bbGetInputOrigin()[2];
+                                       pz = k+org[2];
                                } else {
                                        pz = k;
                                }// Dimension 3
@@ -134,12 +156,16 @@ printf("EED InversCrop::Process 3.1   Origin %d  %d %d\n", bbGetInputOrigin()[0]
                                 (py>=0)    && (pz>=0)  &&
                                         (sizeXM>0) ) 
                                {
+printf("5. \n");
+
                                        memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
+printf("6. \n");
+
                                }
 
                   } // for j
                } // for k
-printf("EED InversCrop::Process 4   %d %d  %d \n",px,py,pz  );
+printf("EED InversCrop::Process 7   %d %d  %d \n",px,py,pz  );
 
                _imageoutput->Modified();
        } else { // If Image Fixe Move the same GetScalarType