]> Creatis software - creaMaracasVisu.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 3 May 2011 07:51:48 +0000 (07:51 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 3 May 2011 07:51:48 +0000 (07:51 +0000)
bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx
bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h
bbtk/src/bbmaracasvisuAxeVolume.cxx

index e6e860f5b5d35f27e5ea166e8e605098e3231e3d..8f2a3ce5b96a44cd26d1a401feb3b34d085db377 100644 (file)
@@ -97,26 +97,6 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube)
        sphereActorEnd->SetOrigin( 0,0,0 );
        sphereActorEnd->SetPosition(bbGetInputlstPointX()[i]*spc[0], bbGetInputlstPointY()[i]*spc[1], bbGetInputlstPointZ()[i]*spc[2] );
 
-
-       // color
-       double r,g,b;
-       if ( (iTube*3+1) < (int)(bbGetInputColour().size()) )
-       {
-               r = bbGetInputColour()[0+iTube*3];
-               g = bbGetInputColour()[1+iTube*3];
-               b = bbGetInputColour()[2+iTube*3];
-       } else {
-               r = (rand() % 100) / 100.0;
-               g = (rand() % 100) / 100.0;
-               b = (rand() % 100) / 100.0;
-       }
-    r = bbGetInputColour()[0];
-    g = bbGetInputColour()[1];
-    b = bbGetInputColour()[2];
-
-
-
-
        vtkSmartPointer<vtkTubeFilter> tube = vtkSmartPointer<vtkTubeFilter>::New();
 //EED  vtkTubeFilter *tube = vtkTubeFilter::New();
        tube->SetInput(polyData);
@@ -131,26 +111,11 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube)
 
        //              vtkSmartPointer<vtkActor> actor =vtkSmartPointer<vtkActor>::New();
     vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
-//EED    vtkActor *actor = vtkActor::New();
        actor->SetMapper(mapper);
-       actor->GetProperty()->SetColor( r,g,b );
-       actor->GetProperty()->SetOpacity( bbGetInputOpacity() );
-    sphereActorStart->GetProperty()->SetColor( r,g,b );;
-    sphereActorEnd->GetProperty()->SetColor( r,g,b );;
-       sphereActorStart->GetProperty()->SetOpacity( bbGetInputOpacity() );
-       sphereActorEnd->GetProperty()->SetOpacity( bbGetInputOpacity() );
 
     vecVtkActors.push_back( actor );
-    vecVtkActors.push_back( sphereActorStart );
     vecVtkActors.push_back( sphereActorEnd );
-
-
-       if ( bbGetInputTransform()!=NULL )
-       {
-               actor->SetUserTransform( bbGetInputTransform() );
-               sphereActorStart->SetUserTransform( bbGetInputTransform() );
-               sphereActorEnd->SetUserTransform( bbGetInputTransform() );
-       }
+    vecVtkActors.push_back( sphereActorStart );
 
        // Interface Update    // Interface Update
      if  (bbGetInputRenderer()!=NULL )
@@ -162,6 +127,64 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube)
 }
 
 
+void TubeTreeFilter::SetGraphicProperties()
+{
+       int iTube,sizeLstAxis=bbGetInputlstIndexs().size();
+
+    vtkActor *actorTube;
+    vtkActor *actorSpherEnd;
+    vtkActor *actorSpherStart;
+
+
+    double r,g,b;
+    r = bbGetInputColour()[0];
+    g = bbGetInputColour()[1];
+    b = bbGetInputColour()[2];
+    for (iTube=0 ; iTube<sizeLstAxis; iTube++)
+    {
+        // Get Actor
+        actorTube=vecVtkActors[0+iTube*3];
+        actorSpherEnd=vecVtkActors[1+iTube*3];
+        actorSpherStart=vecVtkActors[2+iTube*3];
+
+        // Set Opacity
+        actorTube->GetProperty()->SetOpacity( bbGetInputOpacity() );
+        actorSpherEnd->GetProperty()->SetOpacity( bbGetInputOpacity() );
+        actorSpherStart->GetProperty()->SetOpacity( bbGetInputOpacity() );
+
+        //Set Colour
+        if ( bbGetInputTransform()!=NULL )
+        {
+            actorTube->SetUserTransform( bbGetInputTransform() );
+            actorSpherEnd->SetUserTransform( bbGetInputTransform() );
+            actorSpherStart->SetUserTransform( bbGetInputTransform() );
+        }
+
+        if (bbGetInputColourLaw()==1)  // One solide colour
+        {
+            //
+        }
+
+        if (bbGetInputColourLaw()==2)  // color for differents tubes
+        {
+            if ( (iTube*3+1) < (int)(bbGetInputColour().size()) )
+            {
+                r = bbGetInputColour()[0+iTube*3];
+                g = bbGetInputColour()[1+iTube*3];
+                b = bbGetInputColour()[2+iTube*3];
+            } else {
+                r = (rand() % 100) / 100.0;
+                g = (rand() % 100) / 100.0;
+                b = (rand() % 100) / 100.0;
+            }
+        }
+
+        actorTube->GetProperty()->SetColor( r,g,b );
+        actorSpherEnd->GetProperty()->SetColor( r,g,b );
+        actorSpherStart->GetProperty()->SetColor( r,g,b );
+    } // for
+}
+
 //=====
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
 //=====
@@ -205,31 +228,9 @@ void TubeTreeFilter::Process()
             bbSetOutputOutTube( vecVtkActors[ bbGetInputiTube()*3 ] );
         } else         {
                 printf("TubeTreeFilter .ERROR. missing index vector...\n");
-        }
-
-       }
-
-    double r,g,b;
-    r = bbGetInputColour()[0];
-    g = bbGetInputColour()[1];
-    b = bbGetInputColour()[2];
-    for (iTube=0 ; iTube<sizeLstAxis; iTube++)
-    {
-        vtkActor *actor1=vecVtkActors[0+iTube*3];
-        vtkActor *actor2=vecVtkActors[1+iTube*3];
-        vtkActor *actor3=vecVtkActors[2+iTube*3];
-
-        actor1->GetProperty()->SetOpacity( bbGetInputOpacity() );
-        actor2->GetProperty()->SetOpacity( bbGetInputOpacity() );
-        actor3->GetProperty()->SetOpacity( bbGetInputOpacity() );
-        if (bbGetInputColourLaw()==1)
-        {
-            actor1->GetProperty()->SetColor( r,g,b );
-            actor2->GetProperty()->SetColor( r,g,b );
-            actor3->GetProperty()->SetColor( r,g,b );
-        }
-    } // for
-
+        }// vector Actor size
+    }
+    SetGraphicProperties();
 
        printf("EED TubeTreeFilter::Process end \n");
 }
index c6ee910bab297eac6829b91d1fa1fe3b18cc4440..d819ed715c76a9ab70c7a887a4b82c27b7dfec7b 100644 (file)
@@ -49,6 +49,7 @@ class bbcreaMaracasVisu_EXPORT TubeTreeFilter
   private:
        std::vector<vtkActor*>          vecVtkActors;
        void DrawOneTube(int iGeneral,int numPoints, int iTube);
+       void SetGraphicProperties();
     int oldLstSize;
 
 //=====
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