]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx
creaButtonContainer & creaPanelButtonContainer: Updates in doxygen documentation...
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuDrawAxisTree3D.cxx
index 79e256866eec7bbcffb0488464e5df65a426310a..0e2d99d9005851634c62277576d6264860e5b470 100644 (file)
@@ -23,15 +23,17 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
        vecVtkPolyDataMaper.push_back( polydatamapper );
        vecVtkActors.push_back( vtkactor );
 
-//     vtkImageData* img = bbGetInputImage();  
+//     vtkImageData* img = bbGetInputImage();
        unsigned int i,size;
-       double spc[3];  
+       double spc[3];
 //     img->GetSpacing(spc);
        spc[0]=1;
        spc[1]=1;
        spc[2]=1;
 
-       if(!bbGetInputlstPointX().empty()){
+       int lstpointsXsize =bbGetInputlstPointX().size();
+
+       if( lstpointsXsize>0 ){
                vtkPoints* allPoints            = vtkPoints::New( );
                vtkCellArray* allTopology       = vtkCellArray::New( );
                allTopology->InsertNextCell( numPoints );
@@ -41,16 +43,16 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
                {
                        //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
                        //hay parĀ·metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
-                       allPoints->InsertNextPoint( bbGetInputlstPointX()[i]*spc[0],  
-                                                                               bbGetInputlstPointY()[i]*spc[1], 
+                       allPoints->InsertNextPoint( bbGetInputlstPointX()[i]*spc[0],
+                                                                               bbGetInputlstPointY()[i]*spc[1],
                                                                                bbGetInputlstPointZ()[i]*spc[2] );
-                       printf("DrawAxisTree3D::DrawOneAxis point  %d -> %f, %f, %f \n", i,  bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] );
+//                     printf("DrawAxisTree3D::DrawOneAxis point  %d -> %f, %f, %f \n", i,  bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] );
                        allTopology->InsertCellPoint( i-iGeneral );
                } // rof
                polydata->SetPoints( allPoints );
                polydata->SetLines( allTopology );
                allPoints->Delete();
-               allTopology->Delete();  
+               allTopology->Delete();
        }
 
        // color
@@ -59,12 +61,9 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
        if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) )
        {
                        r = bbGetInputColour()[0+iAxis*3];
-                       g = bbGetInputColour()[1+iAxis*3]; 
+                       g = bbGetInputColour()[1+iAxis*3];
                        b = bbGetInputColour()[2+iAxis*3];
        } else {
-//                     r = bbGetInputColour()[0];
-//                     g = bbGetInputColour()[1]; 
-//                     b = bbGetInputColour()[2];
                        r = (rand() % 100) / 100.0;
                        g = (rand() % 100) / 100.0;
                        b = (rand() % 100) / 100.0;
@@ -72,6 +71,7 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
 
        vtkactor->GetProperty()->SetColor( r,g,b );
        vtkactor->GetProperty()->SetLineWidth( 0.5 );
+       vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
 
        if ( bbGetInputTransform()!=NULL )
        {
@@ -88,44 +88,64 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
 
 void DrawAxisTree3D::Process()
 {
-        int iActor,sizeActors = vecVtkActors.size();
-        for (iActor=0 ; iActor<sizeActors; iActor++)
-        {
-               if (bbGetInputRenderer()!=NULL )
-               {
-                       bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
-                       vecVtkPolyData[iActor]->Delete();
-                       vecVtkPolyDataMaper[iActor]->Delete();
-                       vecVtkActors[iActor]->Delete();
-               }
-        }
-     vecVtkPolyData.clear();
-     vecVtkPolyDataMaper.clear();
-        vecVtkActors.clear();
-
+       printf("EED DrawAxisTree3D::Process start \n");
 
        int iGeneral=0;
        int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
+    int iActor,sizeActors = vecVtkActors.size();
        int numPoints;
-       for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
-       {
-               numPoints = bbGetInputlstIndexs()[iAxis];
-               DrawOneAxis(iGeneral,numPoints,iAxis);
-               iGeneral = iGeneral+numPoints;
-               
-               if ((iAxis % 1)==0)
-               {
-                       printf("EED  DrawAxisTree3D::Process  %d/%d\n", iAxis,sizeLstAxis );
-               }
-       }
 
-
-       bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
+    if (oldLstSize!=sizeLstAxis)
+        {
+        oldLstSize=sizeLstAxis;
+         for (iActor=0 ; iActor<sizeActors; iActor++)
+         {
+            if (bbGetInputRenderer()!=NULL )
+            {
+                bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
+                vecVtkPolyData[iActor]->Delete();
+                vecVtkPolyDataMaper[iActor]->Delete();
+                vecVtkActors[iActor]->Delete();
+            }
+         }
+         vecVtkPolyData.clear();
+         vecVtkPolyDataMaper.clear();
+         vecVtkActors.clear();
+
+        for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
+        {
+            numPoints = bbGetInputlstIndexs()[iAxis];
+            DrawOneAxis(iGeneral,numPoints,iAxis);
+            iGeneral = iGeneral+numPoints;
+
+    //         if ((iAxis % 1)==0)
+    //         {
+    //                 printf("EED  DrawAxisTree3D::Process  %d/%d\n", iAxis,sizeLstAxis );
+    //         }
+
+        }
+
+        if ( bbGetInputiAxis() < (int)(vecVtkActors.size()-1) )
+        {
+            bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
+        } else         {
+            printf("TubeTreeFilter .ERROR. missing index vector...\n");
+        }
+
+    } else {// if oldLstSize
+        for (iActor=0 ; iActor<sizeActors; iActor++)
+        {
+            vecVtkActors[iActor]->GetProperty()->SetOpacity( bbGetInputOpacity() );
+        }
+    }
+
+       printf("EED DrawAxisTree3D::Process end \n");
 
 }
 
 void DrawAxisTree3D::bbUserSetDefaultValues()
-{ 
+{
+    oldLstSize=-1;
         bbSetInputiAxis(0);
      std::vector<double> colour;
         // 1- red
@@ -144,32 +164,34 @@ void DrawAxisTree3D::bbUserSetDefaultValues()
      colour.push_back(0.0);
      colour.push_back(1.0);
      colour.push_back(0.0);
-        // 5- 
+        // 5-
      colour.push_back(0.0);
      colour.push_back(1.0);
      colour.push_back(1.0);
 
-        // 6- 
+        // 6-
      colour.push_back(0.5);
      colour.push_back(0.5);
      colour.push_back(0.5);
 
      bbSetInputColour(colour);
+     bbSetInputOpacity(1);
+     bbSetInputColourLaw(1);
 
 }
 
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void DrawAxisTree3D::bbUserInitializeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void DrawAxisTree3D::bbUserFinalizeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
 
 }
 // EO namespace bbcreaMaracasVisu