]> Creatis software - bbtk.git/commitdiff
#3301 BBTK Bug New Normal - SurfaceTexture
authorEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Thu, 12 Sep 2019 15:05:53 +0000 (17:05 +0200)
committerEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Thu, 12 Sep 2019 15:05:53 +0000 (17:05 +0200)
packages/vtk/src/bbvtkPolyDataToActor.cxx
packages/vtk/src/bbvtkSurfaceTexture.cxx

index a0c875812132921a89eb7b11362a1b5e5f07ffce..18a442c7464e8ee87e0878792674b6660bd3f623 100644 (file)
@@ -106,8 +106,10 @@ namespace bbvtk
        
 //---------------------------------------------------------------------
 
-       void PolyDataToActor::DoProcess()
-       {
+void PolyDataToActor::DoProcess()
+{
+
+printf("EED PolyDataToActor::DoProcess Start\n");
 
 printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
 printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
@@ -200,7 +202,10 @@ printf("EED WARNNING!  PolyDataToActor::DoProcess  which is the default values o
                           bbGetInputRenderer()->RemoveActor( vtkactor );
                         }  // actorAdded
                } // Active
-       }
+
+printf("EED PolyDataToActor::DoProcess End\n");
+
+}
 
 
 
index 2d5c86d3c9f7887632eb06d3754f5a504b414860..c6d9bbf50401c270884b3591906920aad15ecd9f 100644 (file)
@@ -17,6 +17,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(SurfaceTexture,bbtk::AtomicBlackBox);
 //===== 
 void SurfaceTexture::Process()
 {
+printf("EED SurfaceTexture:Process() Start\n");
 
 // THE MAIN PROCESSING METHOD BODY
 //   Here we simply set the input 'In' value to the output 'Out'
@@ -34,177 +35,187 @@ void SurfaceTexture::Process()
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
   
 
+
        int     i;
        double  spc[3];
        double  range[2];
        int     ext[6];
-       bbGetInputImage()->GetSpacing(spc);
-       bbGetInputImage()->GetScalarRange(range);
-
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-       bbGetInputImage()->GetWholeExtent(ext);
-#else
-       bbGetInputImage()->GetExtent(ext);
-#endif
-
-       int maxX = ext[1]-ext[0]+1;
-       int maxY = ext[3]-ext[2]+1;
-       int maxZ = ext[5]-ext[4]+1;
-       
-       if (firsttime==true)
+
+       if ((bbGetInputImage()!=NULL) && (bbGetInputMesh()!=NULL))
        {
-               firsttime=false;
-               // Generate the colors for each point based on the color map
-               colors = vtkUnsignedCharArray::New(); 
-               colors->SetNumberOfComponents(3);
-               colors->SetName("Colors");
-               
-               // Create the color map
-               if (bbGetInputColorType()==1)
-               {
-                       colorLookupTableWL      = vtkWindowLevelLookupTable::New();
-                       colorLookupTableWL->InverseVideoOn();
-                       colorLookupTable        = colorLookupTableWL;
-               } else {
-                       colorLookupTable = vtkLookupTable::New();
-               }
-               colorLookupTable->SetTableRange(range[0],range[1]);
-               colorLookupTable->Build();
-               double rgba1[4];
-               double rgba2[4];
-               for (int iLookTable = 0; iLookTable<128; iLookTable++)
-               {
-                 colorLookupTable->GetTableValue(      iLookTable, rgba1);
-                 colorLookupTable->GetTableValue(256-1-iLookTable, rgba2);
 
-                 colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
-                 colorLookupTable->SetTableValue(      iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
-               } // for iLookTable
 
-//EED 2018-06-8 ***********************ARDS Projet***********************************************
-               if (bbGetInputColorType()==2)
-               {
-                       int tableSize=256;
-                       colorLookupTable = vtkLookupTable::New();
-//                     colorLookupTable->SetNumberOfTableValues(tableSize); 
-                       colorLookupTable->SetTableRange(range[0],range[1]);
-//                     colorLookupTable->SetTableRange(0,11);
-                       colorLookupTable->Build();
+               bbGetInputImage()->GetSpacing(spc);
+               bbGetInputImage()->GetScalarRange(range);
 
-/*
-  for (unsigned int i = 0; i < tableSize; ++i)
-    {
-    colorLookupTable->SetTableValue(i,
-                       vtkMath::Random(.25, 1.0),
-                       vtkMath::Random(.25, 1.0),
-                       vtkMath::Random(.25, 1.0),
-                       1.0);
-    }
-*/
+       //EED 2017-01-01 Migration VTK7
+       #if VTK_MAJOR_VERSION <= 5
+               bbGetInputImage()->GetWholeExtent(ext);
+       #else
+               bbGetInputImage()->GetExtent(ext);
+       #endif
 
+               int maxX = ext[1]-ext[0]+1;
+               int maxY = ext[3]-ext[2]+1;
+               int maxZ = ext[5]-ext[4]+1;
+               
+               if (firsttime==true)
+               {
+                       firsttime=false;
+                       // Generate the colors for each point based on the color map
+                       colors = vtkUnsignedCharArray::New(); 
+                       colors->SetNumberOfComponents(3);
+                       colors->SetName("Colors");
+                       
+                       // Create the color map
+                       if (bbGetInputColorType()==1)
+                       {
+                               colorLookupTableWL      = vtkWindowLevelLookupTable::New();
+                               colorLookupTableWL->InverseVideoOn();
+                               colorLookupTable        = colorLookupTableWL;
+                       } else {
+                               colorLookupTable = vtkLookupTable::New();
+                       }
+                       colorLookupTable->SetTableRange(range[0],range[1]);
+                       colorLookupTable->Build();
                        double rgba1[4];
                        double rgba2[4];
-                       int i,j;
-                       for (int iLookTable = 0; iLookTable<tableSize*3; iLookTable++)
+                       for (int iLookTable = 0; iLookTable<128; iLookTable++)
                        {
-                               i=rand() % tableSize;
-                               j=rand() % tableSize;
-                               colorLookupTable->GetTableValue(i, rgba1);
-                               colorLookupTable->GetTableValue(j, rgba2);
+                         colorLookupTable->GetTableValue(      iLookTable, rgba1);
+                         colorLookupTable->GetTableValue(256-1-iLookTable, rgba2);
 
-                         colorLookupTable->SetTableValue(j, rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
-                         colorLookupTable->SetTableValue(i, rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
+                         colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
+                         colorLookupTable->SetTableValue(      iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
                        } // for iLookTable
 
-               } // type 2
+       //EED 2018-06-8 ***********************ARDS Projet***********************************************
+                       if (bbGetInputColorType()==2)
+                       {
+                               int tableSize=256;
+                               colorLookupTable = vtkLookupTable::New();
+       //                      colorLookupTable->SetNumberOfTableValues(tableSize); 
+                               colorLookupTable->SetTableRange(range[0],range[1]);
+       //                      colorLookupTable->SetTableRange(0,11);
+                               colorLookupTable->Build();
+
+       /*
+         for (unsigned int i = 0; i < tableSize; ++i)
+               {
+               colorLookupTable->SetTableValue(i,
+                                  vtkMath::Random(.25, 1.0),
+                                  vtkMath::Random(.25, 1.0),
+                                  vtkMath::Random(.25, 1.0),
+                                  1.0);
+               }
+       */
+
+                               double rgba1[4];
+                               double rgba2[4];
+                               int i,j;
+                               for (int iLookTable = 0; iLookTable<tableSize*3; iLookTable++)
+                               {
+                                       i=rand() % tableSize;
+                                       j=rand() % tableSize;
+                                       colorLookupTable->GetTableValue(i, rgba1);
+                                       colorLookupTable->GetTableValue(j, rgba2);
 
+                                 colorLookupTable->SetTableValue(j, rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
+                                 colorLookupTable->SetTableValue(i, rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
+                               } // for iLookTable
 
-               if (bbGetInputColorType()==3)
-               {
-                       int tableSize=13;
-                       colorLookupTable = vtkLookupTable::New();
-                       colorLookupTable->SetNumberOfTableValues(tableSize); 
-                       colorLookupTable->SetTableRange(6,range[1]);
-                       colorLookupTable->Build();
+                       } // type 2
 
-                 colorLookupTable->SetTableValue(0, 1  ,1      ,1      ,1);
-                 colorLookupTable->SetTableValue(1, 1  ,0      ,0      ,1);
-                 colorLookupTable->SetTableValue(2, 0  ,1      ,0      ,1);
-                 colorLookupTable->SetTableValue(3, 0  ,0      ,1      ,1);
-                 colorLookupTable->SetTableValue(4, 0  ,1      ,1      ,1);
-                 colorLookupTable->SetTableValue(5, 1  ,1      ,0      ,1);
-                 colorLookupTable->SetTableValue(6, 1  ,0      ,1      ,1);
 
-                 colorLookupTable->SetTableValue(7, 0.5,1      ,1      ,1);
-                 colorLookupTable->SetTableValue(8, 1  ,0.5,1  ,1);
-                 colorLookupTable->SetTableValue(9, 1  ,1      ,0.5,1);
+                       if (bbGetInputColorType()==3)
+                       {
+                               int tableSize=13;
+                               colorLookupTable = vtkLookupTable::New();
+                               colorLookupTable->SetNumberOfTableValues(tableSize); 
+                               colorLookupTable->SetTableRange(6,range[1]);
+                               colorLookupTable->Build();
 
-                 colorLookupTable->SetTableValue(10,1  ,0.5,0.5,1);
-                 colorLookupTable->SetTableValue(11,0.5,0.5,1  ,1);
+                         colorLookupTable->SetTableValue(0, 1  ,1      ,1      ,1);
+                         colorLookupTable->SetTableValue(1, 1  ,0      ,0      ,1);
+                         colorLookupTable->SetTableValue(2, 0  ,1      ,0      ,1);
+                         colorLookupTable->SetTableValue(3, 0  ,0      ,1      ,1);
+                         colorLookupTable->SetTableValue(4, 0  ,1      ,1      ,1);
+                         colorLookupTable->SetTableValue(5, 1  ,1      ,0      ,1);
+                         colorLookupTable->SetTableValue(6, 1  ,0      ,1      ,1);
 
-               } // type 3
+                         colorLookupTable->SetTableValue(7, 0.5,1      ,1      ,1);
+                         colorLookupTable->SetTableValue(8, 1  ,0.5,1  ,1);
+                         colorLookupTable->SetTableValue(9, 1  ,1      ,0.5,1);
 
+                         colorLookupTable->SetTableValue(10,1  ,0.5,0.5,1);
+                         colorLookupTable->SetTableValue(11,0.5,0.5,1  ,1);
 
-               
+                       } // type 3
 
-       }  // firsttime
 
+                       
 
-       bbGetInputMesh()->GetPointData()->SetScalars(colors);
+               }  // firsttime
 
-       if (bbGetInputColorType()==1)
-       {
-               colorLookupTableWL->SetLevel( bbGetInputColorLevel() );
-               colorLookupTableWL->SetWindow( bbGetInputColorWindow() );
-       }       
 
+               bbGetInputMesh()->GetPointData()->SetScalars(colors);
 
-       if (bbGetInputExternalLookupTable()!=NULL) 
-       {
-               generalLookupTable = bbGetInputExternalLookupTable();
-       } else {
-               generalLookupTable = colorLookupTable;
-       }
-               
-    int missingpoints = bbGetInputMesh()->GetNumberOfPoints() - colors->GetDataSize()/colors->GetNumberOfComponents();
-       for(i = 0; i < missingpoints; i++)
-    {
-               colors->InsertNextTuple3(0,0,0);
-       }       
+               if (bbGetInputColorType()==1)
+               {
+                       colorLookupTableWL->SetLevel( bbGetInputColorLevel() );
+                       colorLookupTableWL->SetWindow( bbGetInputColorWindow() );
+               }       
 
-       if (bbGetInputTransform()!=NULL)
-       {
-               bbGetInputTransform()->Update();
-       }
-       
-       double gl; 
-       double p1[3];
-       double p2[3];
-       double dcolor[3];
-       for(i = 0; i < bbGetInputMesh()->GetNumberOfPoints(); i++)
-    {
-               if (bbGetInputTransform()!=NULL)
+
+               if (bbGetInputExternalLookupTable()!=NULL) 
                {
-                       bbGetInputMesh()->GetPoint(i,p1);
-                       bbGetInputTransform()->TransformPoint(p1,p2);
+                       generalLookupTable = bbGetInputExternalLookupTable();
                } else {
-                       bbGetInputMesh()->GetPoint(i,p2);
+                       generalLookupTable = colorLookupTable;
                }
-               p2[0] = p2[0]/spc[0];
-               p2[1] = p2[1]/spc[1];
-               p2[2] = p2[2]/spc[2];   
-               
-               if ( (p2[0]>=0) && (p2[0]<maxX) && (p2[1]>=0) && (p2[1]<maxY) &&(p2[2]>=0) && (p2[2]<maxZ)  )
+                       
+               int missingpoints = bbGetInputMesh()->GetNumberOfPoints() - colors->GetDataSize()/colors->GetNumberOfComponents();
+               for(i = 0; i < missingpoints; i++)
                {
-                  gl =  bbGetInputImage()->GetScalarComponentAsDouble(round(p2[0]), round(p2[1]), round(p2[2]),0);
-               } else {
-                       gl=0;
+                       colors->InsertNextTuple3(0,0,0);
+               }       
+
+               if (bbGetInputTransform()!=NULL)
+               {
+                       bbGetInputTransform()->Update();
                }
-               generalLookupTable->GetColor(gl, dcolor);
-               colors->SetTuple3(i,255*dcolor[0],255*dcolor[1],255*dcolor[2]);         
-       } // for i
-       bbGetInputMesh()->Modified();   
+               
+               double gl; 
+               double p1[3];
+               double p2[3];
+               double dcolor[3];
+               for(i = 0; i < bbGetInputMesh()->GetNumberOfPoints(); i++)
+               {
+                       if (bbGetInputTransform()!=NULL)
+                       {
+                               bbGetInputMesh()->GetPoint(i,p1);
+                               bbGetInputTransform()->TransformPoint(p1,p2);
+                       } else {
+                               bbGetInputMesh()->GetPoint(i,p2);
+                       }
+                       p2[0] = p2[0]/spc[0];
+                       p2[1] = p2[1]/spc[1];
+                       p2[2] = p2[2]/spc[2];   
+                       
+                       if ( (p2[0]>=0) && (p2[0]<maxX) && (p2[1]>=0) && (p2[1]<maxY) &&(p2[2]>=0) && (p2[2]<maxZ)  )
+                       {
+                          gl =  bbGetInputImage()->GetScalarComponentAsDouble(round(p2[0]), round(p2[1]), round(p2[2]),0);
+                       } else {
+                               gl=0;
+                       }
+                       generalLookupTable->GetColor(gl, dcolor);
+                       colors->SetTuple3(i,255*dcolor[0],255*dcolor[1],255*dcolor[2]);         
+               } // for i
+               bbGetInputMesh()->Modified();   
+
+       } // if Image && Mesh
+printf("EED SurfaceTexture:Process() End\n");
+
 
 }
 //=====