]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuAxeVolume.cxx
no message
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuAxeVolume.cxx
index db203c70a8771137b1e8267a18f7fec9446c1eac..1711efe09d9ef16a19ee44e2c28cf78e64cdcc10 100644 (file)
@@ -7,6 +7,9 @@ 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 )
        {
                mimage->Delete();
@@ -18,12 +21,20 @@ 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];
+
+       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();
 
 
@@ -50,67 +61,75 @@ 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];
                px1 = px - r;
                py1 = py - r;
                pz1 = pz - r;
                px2 = px + r;
                py2 = py + r;
                pz2 = pz + r;
+               rr=r*r;
 
-               for ( i=px1 ; i<=px2 ; i++ ) 
+               for ( i=px1 ; i<=px2 ; i++ )
                {
-                       for ( j=py1 ; j<py2 ; j++ ) 
+                       rx      =       i - px;
+                       rx      =       rx*rx;
+                       for ( j=py1 ; j<py2 ; j++ )
                        {
-                               for ( k=pz1 ; k<pz2 ; k++ ) 
+                               ry      =       j - py;
+                               ry      =       ry*ry;
+                               for ( k=pz1 ; k<pz2 ; k++ )
                                {
                                        if ( (i>=0) && (i<sizeX) && (j>=0) && (j<sizeY) &&(k>=0) && (k<sizeZ) ){
-                                               rx      = i - px;
-                                               ry      = j - py;
-                                               rz      = k - pz;
-                                               rr      = rx*rx + ry*ry + rz*rz;
-                                               if ( rx*rx + ry*ry + rz*rz <= r*r )
+                                               p = (unsigned short*)mimage->GetScalarPointer (i, j, k);
+                                               if (*p==0)
                                                {
-                                                       p = (unsigned short*)mimage->GetScalarPointer (i, j, k);
-                                                       *p=255;
-                                               } 
+                                                       rz      =       k - pz;
+                                                       rz      =       rz*rz;
+                                                       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