]> Creatis software - bbtk.git/commitdiff
2118 BBTK Feature New High InversCrop
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Fri, 23 Aug 2013 06:25:24 +0000 (08:25 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Fri, 23 Aug 2013 06:25:24 +0000 (08:25 +0200)
packages/vtk/src/bbvtkCreateImage.cxx
packages/vtk/src/bbvtkCreateImage.h

index 9aa9a467c413ea15e34ad2f2c5dd5814904d5768..9bc6d5144adcdc2c6448f662aeb59eb9065eeba5 100644 (file)
@@ -54,21 +54,23 @@ void CreateImage::Process()
 //      (the one provided in the attribute 'type' of the tag 'input')
 
        
+       printf("EED CreateImage::Process Start\n");
+
        double  spc[6];
        int             dim[3]; 
        int             outputformat = VTK_UNSIGNED_SHORT;
        
-       if (bbGetInputOutputFormat()=="VTK_BIT")                                        outputformat = VTK_BIT;
-       else if (bbGetInputOutputFormat()=="VTK_CHAR")                          outputformat = VTK_CHAR;
+       if (bbGetInputOutputFormat()=="VTK_BIT")                        outputformat = VTK_BIT;
+       else if (bbGetInputOutputFormat()=="VTK_CHAR")                  outputformat = VTK_CHAR;
        else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR")           outputformat = VTK_SIGNED_CHAR;
        else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR")         outputformat = VTK_UNSIGNED_CHAR;
        else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT")        outputformat = VTK_UNSIGNED_SHORT;
-       else if (bbGetInputOutputFormat()=="VTK_INT")                           outputformat = VTK_INT;
+       else if (bbGetInputOutputFormat()=="VTK_INT")                   outputformat = VTK_INT;
        else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT")          outputformat = VTK_UNSIGNED_INT;
-       else if (bbGetInputOutputFormat()=="VTK_LONG")                          outputformat = VTK_LONG;
+       else if (bbGetInputOutputFormat()=="VTK_LONG")                  outputformat = VTK_LONG;
        else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG")         outputformat = VTK_UNSIGNED_LONG;
-       else if (bbGetInputOutputFormat()=="VTK_FLOAT")                         outputformat = VTK_FLOAT;
-       else if (bbGetInputOutputFormat()=="VTK_DOUBLE")                        outputformat = VTK_DOUBLE;
+       else if (bbGetInputOutputFormat()=="VTK_FLOAT")                 outputformat = VTK_FLOAT;
+       else if (bbGetInputOutputFormat()=="VTK_DOUBLE")                outputformat = VTK_DOUBLE;
                
        spc[0] = bbGetInputSpacing()[0];
        spc[1] = bbGetInputSpacing()[1];
@@ -84,21 +86,33 @@ void CreateImage::Process()
        imageoutput->SetDimensions(  dim[0], dim[1], dim[2] );
        imageoutput->AllocateScalars();
        
-               
+
                int i,j,k;
+               long sizeBlock; 
+
                for (i=0; i<dim[0]; i++)
                {
-                       for (j=0; j<dim[1]; j++)
-                       {
-                               for (k=0; k<dim[2]; k++)
-                               {
-                                       imageoutput->SetScalarComponentFromDouble(i,j,k, 0, bbGetInputInitialValue() );
-                               } // for k
-                       } // for j
-               } // for i
+                       imageoutput->SetScalarComponentFromDouble(i,0,0, 0, bbGetInputInitialValue() );
+               }
                
+               sizeBlock= dim[0] * imageoutput->GetScalarSize();
+                for (j=1; j<dim[1]; j++)
+               {
+                       memcpy(  imageoutput->GetScalarPointer(0,j,0), imageoutput->GetScalarPointer()  , sizeBlock );
+               }               
+
+               sizeBlock= dim[0] * dim[1] * imageoutput->GetScalarSize();
+               for (k=0; k<dim[2]; k++)
+               {
+                       memcpy(  imageoutput->GetScalarPointer(0,0,k) ,imageoutput->GetScalarPointer()  , sizeBlock );
+               } // for k
+
+               imageoutput->Update();
+               imageoutput->Modified();
                bbSetOutputOut(imageoutput);
 
+ printf("EED CreateImage::Process End\n");
+
 }      
        
 //===== 
@@ -114,9 +128,9 @@ void CreateImage::bbUserSetDefaultValues()
        dim.push_back(250);
        dim.push_back(250);
        std::vector<double> spc;
-       dim.push_back(1.0);
-       dim.push_back(1.0);
-       dim.push_back(1.0);
+       spc.push_back(1.0);
+       spc.push_back(1.0);
+       spc.push_back(1.0);
        
        bbSetInputDimensions(dim);
        bbSetInputSpacing(spc);
index 7e72e8b2b092034afe09e674b165a7a9e051b705..5d43aee0507e9e2a4374ca88bac45c375275538f 100644 (file)
@@ -75,7 +75,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(CreateImage,bbtk::AtomicBlackBox);
        
        BBTK_INPUT(CreateImage,Dimensions,"[SizeX SizeY SizeZ] of the image ([250 250 250] default)",std::vector<int>,"");
        BBTK_INPUT(CreateImage,Spacing,"[SpcX SpcY SpcZ] of the image ([1 1 1] default)",std::vector<double>,"");
-       BBTK_INPUT(CreateImage,OutputFormat,"Image output format:  VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT VTK_UNSIGNED_SHORT (default), VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,"");
+       BBTK_INPUT(CreateImage,OutputFormat,"Image output format:  VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT, VTK_UNSIGNED_SHORT (default), VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,"");
        BBTK_INPUT(CreateImage,InitialValue,"Initial value inside the image (0 default)",double,"");
 
        BBTK_OUTPUT(CreateImage,Out,"Output vtkImageData",vtkImageData*,"");