From: Eduardo DAVILA Date: Wed, 13 Jun 2018 12:21:10 +0000 (+0200) Subject: #3194 BBTK Feature New Normal - Update surfaceTexture box with new lookuptables X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2ab6bff6c5478054c4fdc9d37304b28151251acb;p=bbtk.git #3194 BBTK Feature New Normal - Update surfaceTexture box with new lookuptables --- diff --git a/packages/vtk/src/bbvtkImageBoundaries.cxx b/packages/vtk/src/bbvtkImageBoundaries.cxx index c74a6ec..b76ce96 100644 --- a/packages/vtk/src/bbvtkImageBoundaries.cxx +++ b/packages/vtk/src/bbvtkImageBoundaries.cxx @@ -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; diff --git a/packages/vtk/src/bbvtkImagePlanes.cxx b/packages/vtk/src/bbvtkImagePlanes.cxx index 92476f5..d3cd9d4 100644 --- a/packages/vtk/src/bbvtkImagePlanes.cxx +++ b/packages/vtk/src/bbvtkImagePlanes.cxx @@ -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 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]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() { } diff --git a/packages/vtk/src/bbvtkImagePlanes.h b/packages/vtk/src/bbvtkImagePlanes.h index 3ff20db..a93a9e4 100644 --- a/packages/vtk/src/bbvtkImagePlanes.h +++ b/packages/vtk/src/bbvtkImagePlanes.h @@ -101,19 +101,19 @@ namespace bbvtk private: class VtkCallbackType; - 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(); + 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); }; diff --git a/packages/vtk/src/bbvtkPolyDataToActor.cxx b/packages/vtk/src/bbvtkPolyDataToActor.cxx index 58852e8..d56af36 100644 --- a/packages/vtk/src/bbvtkPolyDataToActor.cxx +++ b/packages/vtk/src/bbvtkPolyDataToActor.cxx @@ -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 ) { diff --git a/packages/vtk/src/bbvtkSliceImage.cxx b/packages/vtk/src/bbvtkSliceImage.cxx index 2088b48..473b276 100755 --- a/packages/vtk/src/bbvtkSliceImage.cxx +++ b/packages/vtk/src/bbvtkSliceImage.cxx @@ -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); diff --git a/packages/vtk/src/bbvtkSliceImage.h b/packages/vtk/src/bbvtkSliceImage.h index 121a129..500bd36 100755 --- a/packages/vtk/src/bbvtkSliceImage.h +++ b/packages/vtk/src/bbvtkSliceImage.h @@ -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); diff --git a/packages/vtk/src/bbvtkSurfaceTexture.cxx b/packages/vtk/src/bbvtkSurfaceTexture.cxx index 3e0f81a..f0b0be3 100644 --- a/packages/vtk/src/bbvtkSurfaceTexture.cxx +++ b/packages/vtk/src/bbvtkSurfaceTexture.cxx @@ -5,7 +5,7 @@ #include "bbvtkPackage.h" #include - +#include namespace bbvtk { @@ -33,7 +33,6 @@ void SurfaceTexture::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <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; iLookTableGetTableValue(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);