From 4b3375d0842a53375e79e35e0b0e690f485534bf Mon Sep 17 00:00:00 2001 From: trillos Date: Wed, 18 Nov 2009 09:56:20 +0000 Subject: [PATCH] *** empty log message *** --- .../bbPackRecalageImageRecalageProperties.cxx | 8 +- .../src/bbPackRecalageImageSwitcherBox.cxx | 13 +-- .../bbPackRecalagePlaneReorientationBox.cxx | 104 ++++++++++++++++++ .../src/bbPackRecalagePlaneReorientationBox.h | 47 ++++++++ 4 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx create mode 100644 PackRecalage/src/bbPackRecalagePlaneReorientationBox.h diff --git a/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx b/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx index a5781fc..e5863e5 100644 --- a/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx +++ b/PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx @@ -11,6 +11,10 @@ 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); @@ -18,8 +22,8 @@ void ImageRecalageProperties::Process() } else if(image->GetScalarType() == VTK_UNSIGNED_SHORT) { - bbSetOutputColorLevel(25000); - bbSetOutputMidColorLevel(12500); + bbSetOutputColorLevel(500); + bbSetOutputMidColorLevel(250); } else { diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx index bf4afe9..65696f6 100644 --- a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx @@ -14,6 +14,7 @@ namespace bbPackRecalage void MyTimer::Notify() { + //This will be called each time the timer finishes a countdown _box->Change(); _box->bbSignalOutputModification(std::string("Out")); } @@ -23,6 +24,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox); void ImageSwitcherBox::Change() { + //Just changes the images each time the timer finishes a countdown + if(change == false) { bbSetOutputOut(bbGetInputIn2()); @@ -60,14 +63,7 @@ void ImageSwitcherBox::Process() myTimer->Start(time); oldTime = time; } - /* - if(oldTime != time && myTimer !=NULL) - { - myTimer->Stop(); - myTimer->Start(time); - oldTime = time; - }*/ - + if(!_on) { myTimer->Stop(); @@ -86,6 +82,7 @@ void ImageSwitcherBox::Process() } void ImageSwitcherBox::CreateWidget(wxWindow* parent) { + //Creates a simple text widget because it is necesary that a non-empty widget exists for creatingh the thread of the timer. bbSetOutputWidget( new wxStaticText(parent, -1, _T("Image Switcher")) ); } void ImageSwitcherBox::bbUserSetDefaultValues() diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx new file mode 100644 index 0000000..ea921ad --- /dev/null +++ b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx @@ -0,0 +1,104 @@ +#include "bbPackRecalagePlaneReorientationBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,PlaneReorientationBox) +BBTK_BLACK_BOX_IMPLEMENTATION(PlaneReorientationBox,bbtk::AtomicBlackBox); +void PlaneReorientationBox::Process() +{ + if(!bbGetInputInX().empty() && bbGetInputInX().size() == 3 && !bbGetInputInY().empty() && bbGetInputInY().size() == 3 && !bbGetInputInZ().empty() && bbGetInputInZ().size() == 3) + { + /*Unitary Vector in Y*/ + double y[3]; + y[0] = 0; + y[1] = 1; + y[2] = 0; + + /*Unitary Vector in X*/ + double x[3]; + x[0] = 1; + x[1] = 0; + x[2] = 0; + + double normal[3]; + + /*Normal vector without its z factor*/ + double normalZ[3]; + normalZ[0] = normal[0]; + normalZ[1] = normal[1]; + normalZ[2] = 0; + + /*Normal vector without its y factor*/ + double normalY[3]; + normalY[0] = normal[0]; + normalY[1] = 0; + normalY[2] = normal[2]; + + /*Angle for the rotation in Z*/ + double angleZ = acos(vtkMath::Dot(normalZ,y)/vtkMath::Norm(normalZ)); + + /*Angle for the rotation in Y*/ + double angleY = acos(vtkMath::Dot(x,normalY)/vtkMath::Norm(normalY)); + + /*Convert from Radians to Degrees*/ + angleZ = vtkMath::DegreesFromRadians(angleZ); + angleY = vtkMath::DegreesFromRadians(angleY); + 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) + { + transform->RotateWXYZ(angleZ,0,0,1); + } + else + { + transform->RotateWXYZ(angleZ,0,0,-1); + } + if(normal[1]<0) + { + transform->RotateWXYZ(angleY,0,1,0); + } + else + { + if(angleY != 180){transform->RotateWXYZ(angleY,0,-1,0);} + } + //transform->Translate(bbGetInputCenterPoint()[0],bbGetInputCenterPoint()[1],bbGetInputCenterPoint()[2]); + transform->Update(); + + /*Set output and pray to god that it works :P*/ + bbSetOutputOut(transform); + } +} +void PlaneReorientationBox::bbUserSetDefaultValues() +{ + std::vector nullVector; + bbSetInputInX(nullVector); + bbSetInputInY(nullVector); + bbSetInputInZ(nullVector); +} +void PlaneReorientationBox::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +void PlaneReorientationBox::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h new file mode 100644 index 0000000..d81c4d8 --- /dev/null +++ b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h @@ -0,0 +1,47 @@ +#ifndef __bbPackRecalagePlaneReorientationBox_h_INCLUDED__ +#define __bbPackRecalagePlaneReorientationBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "vtkTransform.h" +#include "vtkMath.h" +#include "vtkMatrix4x4.h" +#include "PlaneReorientation.h" +#include + +#include "iostream" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT PlaneReorientationBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(PlaneReorientationBox,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(InX,std::vector); + BBTK_DECLARE_INPUT(InY,std::vector); + BBTK_DECLARE_INPUT(InZ,std::vector); + BBTK_DECLARE_INPUT(labels,std::vector); + BBTK_DECLARE_INPUT(CenterPoint,std::vector); + BBTK_DECLARE_OUTPUT(Out,vtkTransform*); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneReorientationBox,bbtk::AtomicBlackBox); +BBTK_NAME("PlaneReorientationBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Reorientates an image by use of a plane"); +BBTK_CATEGORY("filter"); +BBTK_INPUT(PlaneReorientationBox,InX,"Points in X (for all the three points)",std::vector,""); +BBTK_INPUT(PlaneReorientationBox,InY,"Points in Y (for all the three points)",std::vector,""); +BBTK_INPUT(PlaneReorientationBox,InZ,"Points in Z (for all the three points)",std::vector,""); +BBTK_INPUT(PlaneReorientationBox,labels,"Labels of the points",std::vector,""); +BBTK_INPUT(PlaneReorientationBox,CenterPoint,"CenterPoint",std::vector,""); +BBTK_OUTPUT(PlaneReorientationBox,Out,"Transformation ",vtkTransform*,""); +BBTK_END_DESCRIBE_BLACK_BOX(PlaneReorientationBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalagePlaneNormalBox_h_INCLUDED__ + -- 2.47.1