]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuAxeVolume.cxx
no message
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuAxeVolume.cxx
index de06d970df238d0f35f1fe881a3c8a659b0f969c..17f2381755c03eb295309bc1374dbebf793a6c03 100644 (file)
@@ -7,7 +7,7 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,AxeVolume)
 BBTK_BLACK_BOX_IMPLEMENTATION(AxeVolume,bbtk::AtomicBlackBox);
 void AxeVolume::Process()
 {
-       
+
        printf("EED AxeVolume::Process start \n");
 
        if ( mimage!=NULL )
@@ -21,12 +21,22 @@ void AxeVolume::Process()
        int sizeY=ext[3]-ext[2];
        int sizeZ=ext[5]-ext[4];
 
-       mimage = vtkImageData::New(); 
+    double spc[3];
+       bbGetInputIn()->GetSpacing(spc);
+    double invSpc[3];
+    invSpc[0] = 1/spc[0];
+    invSpc[1] = 1/spc[1];
+    invSpc[2] = 1/spc[2];
+
+printf("EED AxeVolume::Process invSpc %f %f %f\n",invSpc[0],invSpc[1],invSpc[2] );
+
+       mimage = vtkImageData::New();
        mimage->SetDimensions(sizeX,sizeY,sizeZ);
        mimage->SetOrigin(0,0,0);
        mimage->SetExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 );
        mimage->SetWholeExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 );
        mimage->SetScalarTypeToUnsignedShort();
+       mimage->SetSpacing(spc);
        mimage->AllocateScalars();
 
 
@@ -53,34 +63,34 @@ void AxeVolume::Process()
                {
                        if (bbGetInputlstPointR().size()>=1)
                        {
-                               r = bbGetInputlstPointR()[ bbGetInputlstPointR().size()-1 ];
+                               r = bbGetInputlstPointR()[ bbGetInputlstPointR().size()-1 ]    * invSpc[0];
                        } else {
                                r = 1;
                        }
                } else {
-                       r = bbGetInputlstPointR()[ iAxe ];
+                       r = bbGetInputlstPointR()[ iAxe ]* invSpc[0];
                }
-               px = bbGetInputlstPointX()[iAxe];
-               py = bbGetInputlstPointY()[iAxe];
-               pz = bbGetInputlstPointZ()[iAxe];
-//              printf("AxeVolume::Process %d ->  %f, %f, %f\n",iAxe, px,py,pz);
+               px = bbGetInputlstPointX()[iAxe] * invSpc[0];
+               py = bbGetInputlstPointY()[iAxe] * invSpc[1];
+               pz = bbGetInputlstPointZ()[iAxe] * invSpc[2];
+                printf("AxeVolume::Process %d ->  %f, %f, %f,%f\n",iAxe, px,py,pz,r);
                px1 = px - r;
                py1 = py - r;
                pz1 = pz - r;
                px2 = px + r;
                py2 = py + r;
                pz2 = pz + r;
-               rr=r*r; 
+               rr=r*r;
 
-               for ( i=px1 ; i<=px2 ; i++ ) 
+               for ( i=px1 ; i<=px2 ; i++ )
                {
                        rx      =       i - px;
                        rx      =       rx*rx;
-                       for ( j=py1 ; j<py2 ; j++ ) 
+                       for ( j=py1 ; j<py2 ; j++ )
                        {
                                ry      =       j - py;
                                ry      =       ry*ry;
-                               for ( k=pz1 ; k<pz2 ; k++ ) 
+                               for ( k=pz1 ; k<pz2 ; k++ )
                                {
                                        if ( (i>=0) && (i<sizeX) && (j>=0) && (j<sizeY) &&(k>=0) && (k<sizeZ) ){
                                                p = (unsigned short*)mimage->GetScalarPointer (i, j, k);
@@ -91,38 +101,38 @@ void AxeVolume::Process()
                                                        if ( rx + ry + rz <= rr )
                                                        {
                                                                *p=255;
-                                                       } 
+                                                       }
                                                } // *p==0
                                        } // inside point
                                } //for k
                        } //for j
                } //for i
        } // for iAxe
-    bbSetOutputOut( mimage ); 
-       
+    bbSetOutputOut( mimage );
+
        printf("EED AxeVolume::Process end \n");
 
 }
 
 
-       //-----------------------------------------------------------------     
+       //-----------------------------------------------------------------
        void AxeVolume::bbUserSetDefaultValues()
        {
                mimage=NULL;
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void AxeVolume::bbUserInitializeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void AxeVolume::bbUserFinalizeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
-       
+
+       //-----------------------------------------------------------------
+
 }
 // EO namespace bbcreaMaracasVisu