]> Creatis software - bbtk.git/commitdiff
#3194 BBTK Feature New Normal - Update surfaceTexture box with new lookuptables
authorEduardo DAVILA <davila@localhost.localdomain>
Wed, 13 Jun 2018 12:21:10 +0000 (14:21 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Wed, 13 Jun 2018 12:21:10 +0000 (14:21 +0200)
packages/vtk/src/bbvtkImageBoundaries.cxx
packages/vtk/src/bbvtkImagePlanes.cxx
packages/vtk/src/bbvtkImagePlanes.h
packages/vtk/src/bbvtkPolyDataToActor.cxx
packages/vtk/src/bbvtkSliceImage.cxx
packages/vtk/src/bbvtkSliceImage.h
packages/vtk/src/bbvtkSurfaceTexture.cxx

index c74a6ec2462f96bf76803d200e51c697be995f48..b76ce9624d38023bff3eed9f7fd63dc624a8ae4b 100644 (file)
@@ -41,7 +41,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageBoundaries,bbtk::AtomicBlackBox);
 void ImageBoundaries::Process()
 {
        printf("bbtk:vtk::ImageBoundaries::Process start\n");
-       if (bbGetInputIn()!=NULL){
+       if (bbGetInputIn()!=NULL)
+       {
                int i,j,k;      
                int ext[6];
                double value;
index 92476f5e19b8a01a00719c3c671d8a3063169404..d3cd9d4040fca938bd84fa6ed9446927fb706c20 100644 (file)
@@ -153,13 +153,13 @@ namespace bbvtk
 
    void ImagePlanes::bbUserSetDefaultValues() 
    { 
-     bbSetOutputPlaneX(0);
-     bbSetOutputPlaneY(0);
-     bbSetOutputPlaneZ(0);
-     bbSetOutputImageX(0);
-     bbSetOutputImageY(0);
-     bbSetOutputImageZ(0);
-     bbSetInputIn(0);
+     bbSetOutputPlaneX(NULL);
+     bbSetOutputPlaneY(NULL);
+     bbSetOutputPlaneZ(NULL);
+     bbSetOutputImageX(NULL);
+     bbSetOutputImageY(NULL);
+     bbSetOutputImageZ(NULL);
+     bbSetInputIn(NULL);
      std::vector<double> vect;
      vect.push_back(0);
      vect.push_back(0);
@@ -242,8 +242,10 @@ namespace bbvtk
      //bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput());
 
         if(picker != 0)
+     {
                picker->UnRegister(NULL);
-     
+        }
+
      mVtkCallback = VtkCallbackType::New();
      mVtkCallback->SetBlackBox(this);
      planeWidgetX->AddObserver(vtkCommand::InteractionEvent,mVtkCallback);
@@ -362,27 +364,27 @@ namespace bbvtk
 
                        //Get the corresponding three points out of the vectors
                        double origin[3];
-                       origin[0] = pointsx[0];
-                       origin[1] = pointsy[0];
-                       origin[2] = pointsz[0];
+                       origin[0]                       = pointsx[0];
+                       origin[1]                       = pointsy[0];
+                       origin[2]                       = pointsz[0];
 
                        double point1[3];
-                       point1[0] = pointsx[1];
-                       point1[1] = pointsy[1];
-                       point1[2] = pointsz[1];
+                       point1[0]                       = pointsx[1];
+                       point1[1]                       = pointsy[1];
+                       point1[2]                       = pointsz[1];
                        double point2[3];
-                       point2[0]= pointsx[2];
-                       point2[1]= pointsy[2];
-                       point2[2]= pointsz[2];  
+                       point2[0]                       = pointsx[2];
+                       point2[1]                       = pointsy[2];
+                       point2[2]                       = pointsz[2];   
 
                        //With the three points we create the corresponding X, Y and Z vectors all orthogonal to each other
-                       double* vect1= getNormal(makeVector(origin, point1));
-                       double* vect2= getNormal(makeVector(origin, point2));                           
-                       double* crossp = getCrossProduct(vect1, vect2);
+                       double* vect1           = getNormal(makeVector(origin, point1));
+                       double* vect2           = getNormal(makeVector(origin, point2));                                
+                       double* crossp          = getCrossProduct(vect1, vect2);
 
-                       double *newx = getCrossProduct(vect2, crossp);
+                       double *newx            = getCrossProduct(vect2, crossp);
 
-                       int ext[6],factor=0;
+                       int ext[6],factor       =       0;
                        bbGetInputIn()->GetExtent(ext);
 
                        factor = ext[0]<ext[3]? ext[3] : ext[0];
@@ -402,12 +404,13 @@ namespace bbvtk
                                                                        (origin[2]+vect2[2]*factor)*zSpacing);
                        plane3pts->GetResliceOutput()->Update();
 //To get the slice of image out of the selected volume
-                       if (_imageReslicer==NULL){
+                       if (_imageReslicer==NULL)
+                       {
                                _imageReslicer = vtkImageReslice::New();                                        
                                _imageReslicer->SetOutputDimensionality(2);
                                _transform = vtkTransform::New();
                                _matrix = vtkMatrix4x4::New();  
-                       }
+                       } // if
                        _imageReslicer->SetInterpolationMode( bbGetInputInterpolation() );
                        _imageReslicer->SetInput( bbGetInputIn() );
                        _imageReslicer->SetInformationInput(bbGetInputIn());    
@@ -444,23 +447,24 @@ namespace bbvtk
        } // bbGetInputIn
   }
        
-  void ImagePlanes::updateInteractor(){
-
-       vtkRenderWindowInteractor* interactor = bbGetInputInteractor();
-
-       if(interactor){
-               bbGetOutputPlaneX()->SetInteractor(interactor);
-               bbGetOutputPlaneX()->EnabledOn();
-               bbGetOutputPlaneY()->SetInteractor(interactor);
-               bbGetOutputPlaneY()->EnabledOn();
-               bbGetOutputPlaneZ()->SetInteractor(interactor);
-               bbGetOutputPlaneZ()->EnabledOn();
-               bbGetOutputPlane3Pts()->SetInteractor(interactor);
-               bbGetOutputPlane3Pts()->EnabledOn();
-       }
-  }
+       void ImagePlanes::updateInteractor()
+       {
+               vtkRenderWindowInteractor* interactor = bbGetInputInteractor(); 
+               if(interactor)
+               {
+                       bbGetOutputPlaneX()->SetInteractor(interactor);
+                       bbGetOutputPlaneX()->EnabledOn();
+                       bbGetOutputPlaneY()->SetInteractor(interactor);
+                       bbGetOutputPlaneY()->EnabledOn();
+                       bbGetOutputPlaneZ()->SetInteractor(interactor);
+                       bbGetOutputPlaneZ()->EnabledOn();
+                       bbGetOutputPlane3Pts()->SetInteractor(interactor);
+                       bbGetOutputPlane3Pts()->EnabledOn();
+               } // if
+       }
+
        //-----------------------------------------------------------------     
-  void vtkImageDataPointerRelay::bbUserSetDefaultValues()
+       void vtkImageDataPointerRelay::bbUserSetDefaultValues()
        {
                
        }
index 3ff20db583c93582e5c80adde649ef461fbb1784..a93a9e4a6e7d570afcb797280e00481c849beedc 100644 (file)
@@ -101,19 +101,19 @@ namespace bbvtk
 
   private:
     class VtkCallbackType;
-    VtkCallbackTypemVtkCallback;
-    vtkImageDataimage;
-    vtkImageReslice_imageReslicer;
-
-    vtkTransform_transform;
-    vtkMatrix4x4_matrix;
-
-    doublegetCrossProduct(double* vect0,double* vect1);
-    double getPodoubleProduct(double* vect0,double* vect1);
-    doublegetNormal(double* vect);
-    double getMagnitud(double* vect);
-    doublemakeVector(double podouble0[3], double podouble1[3]);
-    void updateInteractor();
+    VtkCallbackType    *mVtkCallback;
+    vtkImageData       *image;
+    vtkImageReslice    *_imageReslicer;
+
+    vtkTransform       *_transform;
+    vtkMatrix4x4       *_matrix;
+
+    double     *getCrossProduct(double* vect0,double* vect1);
+    double     getPodoubleProduct(double* vect0,double* vect1);
+    double     *getNormal(double* vect);
+    double     getMagnitud(double* vect);
+    double     *makeVector(double podouble0[3], double podouble1[3]);
+    void       updateInteractor();
 
     vtkImagePlaneWidget* GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker);
   };
index 58852e83ed9df71d7b01f60835d83c4e7aff505b..d56af36bab4d4e0a0d3366ca2b0a214c9b4dd952 100644 (file)
@@ -47,6 +47,7 @@
 #include "bbvtkPolyDataToActor.h"
 #include "bbvtkPackage.h"
 
+
 namespace bbvtk
 {
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
@@ -60,7 +61,6 @@ namespace bbvtk
           colour.push_back(1.0);
           colour.push_back(0.5);
           bbSetInputColour(colour);
-
           bbSetInputActive(true);
           bbSetInputIn(NULL);
           bbSetInputRenderer(NULL);
@@ -69,7 +69,6 @@ namespace bbvtk
           bbSetInputRepresentation(2);
           bbSetInputLineWidth(1);
           bbSetInputScalarVisibility(false);
-
           polydatamapper = NULL;
           vtkactor       = NULL;
    }
@@ -110,8 +109,18 @@ namespace bbvtk
 
                if (bbGetInputActive()==true)
                {
-                        polydatamapper->SetInput( bbGetInputIn() );
-                        vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
+                       polydatamapper->SetInput( bbGetInputIn() );
+                       vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
+                       if (bbGetInputRepresentation()==1)
+                       {
+                                vtkactor->GetProperty()->SetAmbient(1);
+                                vtkactor->GetProperty()->SetDiffuse(1);
+                                vtkactor->GetProperty()->SetSpecular(0);
+                       } else {
+printf("EED WARNNING!  PolyDataToActor::DoProcess  which is the default values of Ambient, Diffuse, Specular ? \n");
+                       }
+
+
                         vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
                           
                         vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
@@ -119,6 +128,7 @@ namespace bbvtk
                                                        bbGetInputColour()[2] );
                                  
                         vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
+
                         
                         if ( bbGetInputTransform()!=NULL )
                         {
index 2088b4843ffc1bce5ed8a1f222fbb5de44067203..473b276042177499e0a299de62b7be97cacc0455 100755 (executable)
@@ -34,6 +34,9 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SliceImage)
 BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
 void SliceImage::Process()
 {
+
+printf("EED ********************************** bbtk-box vtk:SliceImage (Deprecated)\n");
+printf("EED **********************************   >> use bbtk-box creaMaracasVisu:SliceImage \n");
        vtkImageData* original = bbGetInputIn();
 
        if (original == NULL)
@@ -70,8 +73,6 @@ void SliceImage::Process()
                final->SetScalarType(scalar_type);
                final->AllocateScalars();
                final->Update();
-
-
        }
 
        bbSetOutputMax(max_z);
index 121a129e950a331ded261465193d1bf89dc14ae2..500bd36418671aebb7db86c59bc9acfa9bc03671 100755 (executable)
@@ -63,7 +63,7 @@ BBTK_AUTHOR("_author_");
 BBTK_DESCRIPTION("_description_");
 BBTK_CATEGORY("__CATEGORY__");
 BBTK_INPUT(SliceImage,In,"3D Image",vtkImageData*,"");
-BBTK_INPUT(SliceImage,Z,"shoice",int,"");
+BBTK_INPUT(SliceImage,Z,"schoice",int,"");
 BBTK_OUTPUT(SliceImage,Out,"2D Slice",vtkImageData*,"");
 BBTK_OUTPUT(SliceImage,Max,"Maximum",int,"");
 BBTK_END_DESCRIBE_BLACK_BOX(SliceImage);
index 3e0f81ac70694ef2f423c9c700611b9aba5b628f..f0b0be3f9e50dbcfc4218734eb219898c3b51d9f 100644 (file)
@@ -5,7 +5,7 @@
 #include "bbvtkPackage.h"
 
 #include <vtkPointData.h>
-
+#include <vtkMath.h>
 
 namespace bbvtk
 {
@@ -33,7 +33,6 @@ void SurfaceTexture::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
   
-printf("EED SurfaceTexture::Process Start\n");
 
        int i;
        double spc[3];
@@ -76,6 +75,72 @@ printf("EED SurfaceTexture::Process Start\n");
                  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();
+
+/*
+  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
+
+               } // type 2
+
+
+               if (bbGetInputColorType()==3)
+               {
+                       int tableSize=13;
+                       colorLookupTable = vtkLookupTable::New();
+                       colorLookupTable->SetNumberOfTableValues(tableSize); 
+                       colorLookupTable->SetTableRange(6,range[1]);
+                       colorLookupTable->Build();
+
+                 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);
+
+                 colorLookupTable->SetTableValue(10,1  ,0.5,0.5,1);
+                 colorLookupTable->SetTableValue(11,0.5,0.5,1  ,1);
+
+               } // type 2
+
+
+
+
        }
 
        bbGetInputMesh()->GetPointData()->SetScalars(colors);