From 3707df370a2c5b61006233977fb91c5652e0ffea Mon Sep 17 00:00:00 2001 From: trillos Date: Wed, 2 Dec 2009 13:10:41 +0000 Subject: [PATCH] *** empty log message *** --- CMakeLists.txt | 8 +++ PackRecalage/CMakeLists.txt | 3 +- .../src/bbPackRecalageCalculateVectorBox.cxx | 15 +++--- .../src/bbPackRecalageCalculateVectorBox.h | 4 +- .../src/bbPackRecalageCheckBoardBox.cxx | 22 ++++---- .../src/bbPackRecalageImageConvolution.cxx | 10 +--- .../bbPackRecalageImageRecalageProperties.cxx | 14 ++---- .../src/bbPackRecalageImageSubstraction.cxx | 10 ++-- .../bbPackRecalagePlaneReorientationBox.cxx | 50 ++++++++++++------- .../src/bbPackRecalagePlaneReorientationBox.h | 3 ++ .../src/bbPackRecalageReSlicerBox.cxx | 23 ++++++--- .../src/bbPackRecalageTransform2DBox.h | 6 +-- lib/Convolution.cxx | 2 +- 13 files changed, 94 insertions(+), 76 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8623c5c..c81b8a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,14 @@ IF (crea_FOUND) ENDIF(crea_FOUND) #================================== +#================================== +# Find creaMaracasVisu (to use the lib) +#FIND_PACKAGE(creaMaracasVisu REQUIRED) +#IF (creaMaracasVisu_FOUND) + #INCLUDE(${creaMaracasVisu_USE_FILE}) +#ENDIF(creaMaracasVisu_FOUND) +#================================== + #================================== # Do not allow to build inside the source tree CREA_PREVENT_IN_SOURCE_BUILD() diff --git a/PackRecalage/CMakeLists.txt b/PackRecalage/CMakeLists.txt index f2ba084..940b7ed 100644 --- a/PackRecalage/CMakeLists.txt +++ b/PackRecalage/CMakeLists.txt @@ -122,7 +122,8 @@ SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS SET(${BBTK_PACKAGE_NAME}_LIBS # LIST HERE THE ADDITIONAL LIBS TO LINK AGAINST # EXCEPT : the same libs than for INCLUDE_DIRS - TransformLib + TransformLib + #${creaMaracasVisu_LIBRARIES} ) #=========================================================================== diff --git a/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx b/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx index ae3c166..acc9925 100644 --- a/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx +++ b/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx @@ -9,25 +9,24 @@ namespace bbPackRecalage BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,CalculateVectorBox) BBTK_BLACK_BOX_IMPLEMENTATION(CalculateVectorBox,bbtk::AtomicBlackBox); void CalculateVectorBox::Process() -{ - +{ if(!bbGetInputPointsX1().empty() && !bbGetInputPointsX2().empty()) { //Checks that all the vector points are defined if(bbGetInputPointsX1()[1] != NULL && bbGetInputPointsX2()[1] != NULL) { - _vector->SetData(bbGetInputPointsX1(), bbGetInputPointsX2(), bbGetInputPointsY1(), bbGetInputPointsY2(), bbGetInputPointsZ1(), bbGetInputPointsZ2()); - _vector->Run(); + //_vector->SetData(bbGetInputPointsX1(), bbGetInputPointsX2(), bbGetInputPointsY1(), bbGetInputPointsY2(), bbGetInputPointsZ1(), bbGetInputPointsZ2()); + //_vector->Run(); - bbSetOutputOrigin(_vector->GetOrigin()); - bbSetOutputOriginReslicer(_vector->GetOriginReslicer()); - bbSetOutputOutAngle(_vector->GetAngle()); + //bbSetOutputOrigin(_vector->GetOrigin()); + //bbSetOutputOriginReslicer(_vector->GetOriginReslicer()); + //bbSetOutputOutAngle(_vector->GetAngle()); } } } void CalculateVectorBox::bbUserSetDefaultValues() { - _vector = new VectorMath(); + _vector = new PlanesOperations(); std::vector nullVector; bbSetInputPointsX1(nullVector); bbSetInputPointsX2(nullVector); diff --git a/PackRecalage/src/bbPackRecalageCalculateVectorBox.h b/PackRecalage/src/bbPackRecalageCalculateVectorBox.h index 0e0a8de..485612e 100644 --- a/PackRecalage/src/bbPackRecalageCalculateVectorBox.h +++ b/PackRecalage/src/bbPackRecalageCalculateVectorBox.h @@ -4,7 +4,7 @@ #include "bbtkAtomicBlackBox.h" #include "iostream" -#include "VectorMath.h" +#include "PlanesOperations.h" namespace bbPackRecalage { @@ -64,7 +64,7 @@ class bbPackRecalage_EXPORT CalculateVectorBox private: - VectorMath *_vector; + PlanesOperations *_vector; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(CalculateVectorBox,bbtk::AtomicBlackBox); diff --git a/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx b/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx index 6502daf..895a72c 100644 --- a/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx +++ b/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx @@ -8,22 +8,24 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,CheckBoardBox) BBTK_BLACK_BOX_IMPLEMENTATION(CheckBoardBox,bbtk::AtomicBlackBox); void CheckBoardBox::Process() { - + // THE MAIN PROCESSING METHOD BODY checkboard->setInputImage1(bbGetInputIn1()); checkboard->setInputImage2(bbGetInputIn2()); - checkboard->setRows(bbGetInputRows()); - checkboard->setCols(bbGetInputCols()); - checkboard->calculateImage(); - bbSetOutputOut(checkboard->getFilteredImage()); - //bbSetOutputOut(bbGetInputIn1()); - + if(bbGetInputIn1() != NULL && bbGetInputIn2() != NULL) + { + checkboard->setRows(bbGetInputRows()); + checkboard->setCols(bbGetInputCols()); + checkboard->calculateImage(); + bbSetOutputOut(checkboard->getFilteredImage()); + } + else + { + bbSetOutputOut(NULL); + } } void CheckBoardBox::bbUserSetDefaultValues() { - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 bbSetInputIn1(NULL); bbSetInputIn2(NULL); bbSetInputRows(0); diff --git a/PackRecalage/src/bbPackRecalageImageConvolution.cxx b/PackRecalage/src/bbPackRecalageImageConvolution.cxx index c37aa3d..d4ce2be 100644 --- a/PackRecalage/src/bbPackRecalageImageConvolution.cxx +++ b/PackRecalage/src/bbPackRecalageImageConvolution.cxx @@ -32,14 +32,6 @@ void ImageConvolution::bbUserInitializeProcessing() void ImageConvolution::bbUserFinalizeProcessing() { delete convolution; - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - } } -// EO namespace bbPackRecalage - - +// EO namespace bbPackRecalage \ No newline at end of file diff --git a/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx b/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx index e5863e5..586af76 100644 --- a/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx +++ b/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx @@ -11,24 +11,16 @@ void ImageRecalageProperties::Process() if(image != NULL) { bbSetOutputLengthZ((int)image->GetDimensions()[2] - 1); - std::cout << "image scalar size: " << image->GetScalarSize() << std::endl; - std::cout << "image scalar max: " << image->GetScalarTypeMax() << std::endl; - std::cout << "image scalar min: " << image->GetScalarTypeMin() << std::endl; - std::cout << "image scalar type: " << image->GetScalarType() << std::endl; + if(image->GetScalarType() == VTK_DOUBLE) { bbSetOutputColorLevel(50); bbSetOutputMidColorLevel(25); } - else if(image->GetScalarType() == VTK_UNSIGNED_SHORT) - { - bbSetOutputColorLevel(500); - bbSetOutputMidColorLevel(250); - } else { - bbSetOutputColorLevel(500); - bbSetOutputMidColorLevel(250); + bbSetOutputColorLevel(255); + bbSetOutputMidColorLevel(127.5); } } } diff --git a/PackRecalage/src/bbPackRecalageImageSubstraction.cxx b/PackRecalage/src/bbPackRecalageImageSubstraction.cxx index 46864cc..fc286d7 100644 --- a/PackRecalage/src/bbPackRecalageImageSubstraction.cxx +++ b/PackRecalage/src/bbPackRecalageImageSubstraction.cxx @@ -35,12 +35,10 @@ void ImageSubstraction::bbUserInitializeProcessing() } void ImageSubstraction::bbUserFinalizeProcessing() { - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - + if(subImage!=NULL) + { + delete subImage; + } } } // EO namespace bbCreaRecalage diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx index ea921ad..1e86790 100644 --- a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx +++ b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx @@ -9,6 +9,30 @@ void PlaneReorientationBox::Process() { if(!bbGetInputInX().empty() && bbGetInputInX().size() == 3 && !bbGetInputInY().empty() && bbGetInputInY().size() == 3 && !bbGetInputInZ().empty() && bbGetInputInZ().size() == 3) { + double a[3]; + + /*First Vector*/ + a[0] = bbGetInputInX()[1]-bbGetInputInX()[0]; + a[1] = bbGetInputInY()[1]-bbGetInputInY()[0]; + a[2] = bbGetInputInZ()[1]-bbGetInputInZ()[0]; + + double b[3]; + + /*Second Vector*/ + b[0] = bbGetInputInX()[2]-bbGetInputInX()[0]; + b[1] = bbGetInputInY()[2]-bbGetInputInY()[0]; + b[2] = bbGetInputInZ()[2]-bbGetInputInZ()[0]; + + double normal[3]; + + normal[0]=(a[1]*b[2])-(a[2]*b[1]); + normal[1]=(a[2]*b[0])-(a[0]*b[2]); + normal[2]=(a[0]*b[1])-(a[1]*b[0]); + + vtkMath::Normalize(normal); + + std::cout << "Normal axis : " << "X: " << normal[0] << " Y: " << normal[1] << " Z: " << normal[2] << std::endl; + /*Unitary Vector in Y*/ double y[3]; y[0] = 0; @@ -19,9 +43,7 @@ void PlaneReorientationBox::Process() double x[3]; x[0] = 1; x[1] = 0; - x[2] = 0; - - double normal[3]; + x[2] = 0; /*Normal vector without its z factor*/ double normalZ[3]; @@ -47,7 +69,6 @@ void PlaneReorientationBox::Process() std::cout << "Angle for Z: " << angleZ << std::endl; std::cout << "Angle for Y: " << angleY << std::endl; - vtkTransform *transform = vtkTransform::New(); transform->Identity(); if(normal[0] < 0) { @@ -71,6 +92,12 @@ void PlaneReorientationBox::Process() /*Set output and pray to god that it works :P*/ bbSetOutputOut(transform); } + else + { + transform->Identity(); + transform->Update(); + bbSetOutputOut(transform); + } } void PlaneReorientationBox::bbUserSetDefaultValues() { @@ -81,22 +108,11 @@ void PlaneReorientationBox::bbUserSetDefaultValues() } void PlaneReorientationBox::bbUserInitializeProcessing() { - -// THE INITIALIZATION METHOD BODY : -// Here does nothing -// but this is where you should allocate the internal/output pointers -// if any - - + transform = vtkTransform::New(); } void PlaneReorientationBox::bbUserFinalizeProcessing() { - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - + transform->Delete(); } } // EO namespace bbPackRecalage diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h index d81c4d8..076b5af 100644 --- a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h +++ b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h @@ -26,6 +26,9 @@ class bbPackRecalage_EXPORT PlaneReorientationBox BBTK_DECLARE_OUTPUT(Out,vtkTransform*); BBTK_PROCESS(Process); void Process(); + + private: + vtkTransform *transform; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneReorientationBox,bbtk::AtomicBlackBox); diff --git a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx index c30ee0f..f00d13b 100644 --- a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx +++ b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx @@ -8,16 +8,24 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ReSlicerBox) BBTK_BLACK_BOX_IMPLEMENTATION(ReSlicerBox,bbtk::AtomicBlackBox); void ReSlicerBox::Process() { + std::cout << "NTU ReSlicerBox : entered 1" << std::endl; - if(!bbGetInputOrigin().empty()) + if(!bbGetInputOrigin().empty() && bbGetInputTransform() != NULL) { + std::cout << "NTU ReSlicerBox : entered 2" << std::endl; + image = vtkImageChangeInformation::New(); image->SetInput( bbGetInputIn() ); image->SetOutputSpacing( 1,1,1 ); + + std::cout << "NTU ReSlicerBox : entered 3" << std::endl; + if(bbGetInputCentered()) { image->CenterImageOn(); } + + std::cout << "NTU ReSlicerBox : entered 4" << std::endl; slicer =vtkImageReslice::New(); slicer->SetInput( image->GetOutput() ); @@ -30,6 +38,8 @@ void ReSlicerBox::Process() } slicer->Update(); + std::cout << "NTU ReSlicerBox : entered 5" << std::endl; + imageResult = vtkImageChangeInformation::New(); imageResult->SetInput( slicer->GetOutput() ); double spc[3]; @@ -43,6 +53,8 @@ void ReSlicerBox::Process() { bbSetOutputOut( bbGetInputIn() ); } + + std::cout << "NTU ReSlicerBox : out" << std::endl; } void ReSlicerBox::bbUserSetDefaultValues() @@ -50,7 +62,7 @@ void ReSlicerBox::bbUserSetDefaultValues() std::vector empty; bbSetInputOrigin(empty); bbSetInputIn(NULL); - bbSetInputTransform(vtkTransform::New()); + bbSetInputTransform(NULL); bbSetOutputOut(NULL); bbSetInputCentered(false); bbSetInputInterpolate(false); @@ -68,12 +80,7 @@ void ReSlicerBox::bbUserInitializeProcessing() imageResult = vtkImageChangeInformation::New(); } void ReSlicerBox::bbUserFinalizeProcessing() -{ - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any +{ image->Delete(); slicer->Delete(); imageResult->Delete(); diff --git a/PackRecalage/src/bbPackRecalageTransform2DBox.h b/PackRecalage/src/bbPackRecalageTransform2DBox.h index d8ee00b..3d9dbbb 100644 --- a/PackRecalage/src/bbPackRecalageTransform2DBox.h +++ b/PackRecalage/src/bbPackRecalageTransform2DBox.h @@ -22,14 +22,14 @@ class bbPackRecalage_EXPORT Transform2DBox BBTK_DECLARE_INPUT(Angle,double); - /*Scalation to be done int the x axis*/ + /*Scalation to be done in the x axis*/ BBTK_DECLARE_INPUT(ScaleX,double); - /*Scalation to be done int the y axis*/ + /*Scalation to be done in the y axis*/ BBTK_DECLARE_INPUT(ScaleY,double); - /*Scalation to be done int the z axis*/ + /*Scalation to be done in the z axis*/ BBTK_DECLARE_INPUT(ScaleZ,double); /*Resultant vtkTransform*/ diff --git a/lib/Convolution.cxx b/lib/Convolution.cxx index 450df87..02bf600 100644 --- a/lib/Convolution.cxx +++ b/lib/Convolution.cxx @@ -50,7 +50,7 @@ void Convolution::Run() _convolve->SetKernel3x3(kernel); _convolve->Update(); _cast->SetInput(_convolve->GetOutput()); - _cast->SetOutputScalarTypeToDouble(); + //_cast->SetOutputScalarTypeToDouble(); _cast->Update(); } else -- 2.45.0