From 9b19eddeb433012634bb6ecc208d2c3ccea445e8 Mon Sep 17 00:00:00 2001 From: trillos Date: Wed, 2 Dec 2009 13:12:35 +0000 Subject: [PATCH] Renamed Recalage Boxes --- .../bbPackRecalageTransform3D1PointBox.cxx | 57 ++++ .../src/bbPackRecalageTransform3D1PointBox.h | 68 +++++ .../bbPackRecalageTransform3D2PointsBox.cxx | 166 ++++++++++++ .../src/bbPackRecalageTransform3D2PointsBox.h | 79 ++++++ .../bbPackRecalageTransform3D3PointsBox.cxx | 254 ++++++++++++++++++ .../src/bbPackRecalageTransform3D3PointsBox.h | 75 ++++++ 6 files changed, 699 insertions(+) create mode 100644 PackRecalage/src/bbPackRecalageTransform3D1PointBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageTransform3D1PointBox.h create mode 100644 PackRecalage/src/bbPackRecalageTransform3D2PointsBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageTransform3D2PointsBox.h create mode 100644 PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageTransform3D3PointsBox.h diff --git a/PackRecalage/src/bbPackRecalageTransform3D1PointBox.cxx b/PackRecalage/src/bbPackRecalageTransform3D1PointBox.cxx new file mode 100644 index 0000000..f15b01a --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D1PointBox.cxx @@ -0,0 +1,57 @@ +#include "bbPackRecalageTransform3D1PointBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transform3D1PointBox) +BBTK_BLACK_BOX_IMPLEMENTATION(Transform3D1PointBox,bbtk::AtomicBlackBox); +void Transform3D1PointBox::Process() +{ + if(!bbGetInputCenterPoint().empty()) + { + // The inputs are set in the library transformer + transformer->SetCenterPoint( bbGetInputCenterPoint() ); + transformer->SetAngleX( bbGetInputAngleX() ); + transformer->SetAngleY( bbGetInputAngleY() ); + transformer->SetAngleZ( bbGetInputAngleZ() ); + transformer->SetScaleX( bbGetInputScaleX() ); + transformer->SetScaleY( bbGetInputScaleY() ); + transformer->SetScaleZ( bbGetInputScaleZ() ); + + // The calculation of the transformations are made + transformer->Run(); + // We get the results of transformer and set it as result of this box + bbSetOutputOut( transformer->GetResult() ); + } + else + { + bbSetOutputOut( NULL ); + } +} +void Transform3D1PointBox::bbUserSetDefaultValues() +{ + //We initialize the points with an empty vector, the angle in 0 and the scales in 1 + std::vector nuevo(3,0); + nuevo.push_back(0); + bbSetInputCenterPoint(nuevo); + bbSetInputAngleX(0); + bbSetInputAngleY(0); + bbSetInputAngleZ(0); + bbSetInputScaleX(100); + bbSetInputScaleY(100); + bbSetInputScaleZ(100); + bbSetOutputOut(NULL); +} +void Transform3D1PointBox::bbUserInitializeProcessing() +{ + //We initialize the transformer + transformer = new Transformer3D1Point(); +} +void Transform3D1PointBox::bbUserFinalizeProcessing() +{ + delete transformer; +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageTransform3D1PointBox.h b/PackRecalage/src/bbPackRecalageTransform3D1PointBox.h new file mode 100644 index 0000000..cbfc3f0 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D1PointBox.h @@ -0,0 +1,68 @@ +#ifndef __bbPackRecalageTransform3D1PointBox_h_INCLUDED__ +#define __bbPackRecalageTransform3D1PointBox_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkTransform.h" +#include "Transformer3D1Point.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT Transform3D1PointBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Transform3D1PointBox,bbtk::AtomicBlackBox); + + /*Center Point of the transformation*/ + BBTK_DECLARE_INPUT(CenterPoint,std::vector); + + /*Scalation to be done in the x axis*/ + BBTK_DECLARE_INPUT(AngleX,double); + + /*Scalation to be done in the y axis*/ + BBTK_DECLARE_INPUT(AngleY,double); + + /*Scalation to be done in the z axis*/ + BBTK_DECLARE_INPUT(AngleZ,double); + + /*Scalation to be done in the x axis*/ + BBTK_DECLARE_INPUT(ScaleX,double); + + /*Scalation to be done in the y axis*/ + BBTK_DECLARE_INPUT(ScaleY,double); + + /*Scalation to be done in the z axis*/ + BBTK_DECLARE_INPUT(ScaleZ,double); + + /*Resultant vtkTransform*/ + BBTK_DECLARE_OUTPUT(Out, vtkTransform*); + + /*Class in charge of making the transformations*/ + Transformer3D1Point *transformer; + + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform3D1PointBox,bbtk::AtomicBlackBox); +BBTK_NAME("Transform3D1PointBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Recalage3D version 1 (one point for translation, three rotation angles and xyz manual scaling)"); +BBTK_CATEGORY("filter"); +BBTK_INPUT(Transform3D1PointBox,CenterPoint,"CenterPoint",std::vector,""); +BBTK_INPUT(Transform3D1PointBox,AngleX,"Angle for rotating on X",double,""); +BBTK_INPUT(Transform3D1PointBox,AngleY,"Angle for rotating on Y",double,""); +BBTK_INPUT(Transform3D1PointBox,AngleZ,"Angle for rotating on Z",double,""); +BBTK_INPUT(Transform3D1PointBox,ScaleX,"Scale on X",double,""); +BBTK_INPUT(Transform3D1PointBox,ScaleY,"Scale on Y",double,""); +BBTK_INPUT(Transform3D1PointBox,ScaleZ,"Scale on Z",double,""); +BBTK_OUTPUT(Transform3D1PointBox,Out,"Transformation ",vtkTransform*,""); +BBTK_END_DESCRIBE_BLACK_BOX(Transform3D1PointBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageRecalage3DV1_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.cxx b/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.cxx new file mode 100644 index 0000000..92510f1 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.cxx @@ -0,0 +1,166 @@ +#include "bbPackRecalageTransform3D2PointsBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transform3D2PointsBox) +BBTK_BLACK_BOX_IMPLEMENTATION(Transform3D2PointsBox,bbtk::AtomicBlackBox); +void Transform3D2PointsBox::Process() +{ + if(!bbGetInputInX1().empty() && bbGetInputInX1().size() >= 2 && !bbGetInputInX2().empty() && bbGetInputInX2().size() >= 2) + { + double A1[3]; + double O1[3]; + + double A2[3]; + double O2[3]; + + //In case there is an order in the points + if(!bbGetInputLabels1().empty() && !bbGetInputLabels2().empty() && bbGetInputLabels1()[0].compare("1") == 0 && bbGetInputLabels1()[1].compare("2") == 0 && bbGetInputLabels2()[0].compare("1") == 0 && bbGetInputLabels2()[1].compare("2") == 0) + { + int i; + for(i = 0; i < 2; i++) + { + if(bbGetInputLabels1()[i].compare("1") == 0) + { + O1[0] = bbGetInputInX1()[i]; + O1[1] = bbGetInputInY1()[i]; + O1[2] = bbGetInputInZ1()[i]; + } + else if(bbGetInputLabels1()[i].compare("2") == 0) + { + A1[0] = bbGetInputInX1()[i]; + A1[1] = bbGetInputInY1()[i]; + A1[2] = bbGetInputInZ1()[i]; + } + } + for(i = 0; i < 2; i++) + { + if(bbGetInputLabels2()[i].compare("1") == 0) + { + O2[0] = bbGetInputInX2()[i]; + O2[1] = bbGetInputInY2()[i]; + O2[2] = bbGetInputInZ2()[i]; + } + else if(bbGetInputLabels2()[i].compare("2") == 0) + { + A2[0] = bbGetInputInX2()[i]; + A2[1] = bbGetInputInY2()[i]; + A2[2] = bbGetInputInZ2()[i]; + } + } + } + else + { + O1[0] = bbGetInputInX1()[0]; + O1[1] = bbGetInputInY1()[0]; + O1[2] = bbGetInputInZ1()[0]; + + A1[0] = bbGetInputInX1()[1]; + A1[1] = bbGetInputInY1()[1]; + A1[2] = bbGetInputInZ1()[1]; + + O2[0] = bbGetInputInX2()[0]; + O2[1] = bbGetInputInY2()[0]; + O2[2] = bbGetInputInZ2()[0]; + + A2[0] = bbGetInputInX2()[1]; + A2[1] = bbGetInputInY2()[1]; + A2[2] = bbGetInputInZ2()[1]; + } + + //Create the new center point + double * centerPoint; + centerPoint = new double[3]; + + centerPoint[0] = O2[0]; + centerPoint[1] = O2[1]; + centerPoint[2] = O2[2]; + + transformer->SetFirstTranslation(centerPoint); + + centerPoint[0] = O1[0]; + centerPoint[1] = O1[1]; + centerPoint[2] = O1[2]; + + transformer->SetSecondTranslation(centerPoint); + + //Create the first vector + double* vector1; + vector1 = planes->makeVector(O1, A1); + + //create the second vector + double* vector2; + vector2 = planes->makeVector(O2, A2); + + //The rotation axis + double* axis = planes->getCrossProduct(vector2, vector1); + + //Normalize the axis + axis = planes->getNormal(axis); + + //Normalize the 2 vectors for calculating the dot product + vector1 = planes->getNormal(vector1); + vector2 = planes->getNormal(vector2); + + //Dot product + double angle = planes->getDotProduct(vector2, vector1); + + //Convert the dot product to radians + angle = acos(angle); + + //Convert from Radians to Degrees (necesary for the transformation) + angle = vtkMath::DegreesFromRadians(angle); + + //Set the cross product and dot product of the first rotation + transformer->SetRotationAxis(axis); + transformer->SetAngle(angle); + + //Sets the second rotation axis (defined by the first vector) and the second angle as input + transformer->SetSecondRotationAxis(vector1); + transformer->SetSecondAngle(bbGetInputSecondAngle()); + + // The calculation of the transformations are made + transformer->Run(); + + // We get the results of transformer and set it as result of this box + bbSetOutputOut( transformer->GetResult() ); + } + else + { + bbSetOutputOut( NULL ); + } +} +void Transform3D2PointsBox::bbUserSetDefaultValues() +{ + std::vector empty; + std::vector emptyString; + bbSetInputInX1(empty); + bbSetInputInY1(empty); + bbSetInputInZ1(empty); + bbSetInputInX2(empty); + bbSetInputInY2(empty); + bbSetInputInZ2(empty); + bbSetInputLabels1(emptyString); + bbSetInputLabels2(emptyString); + bbSetInputSecondAngle(0); + bbSetOutputOut(NULL); +} +void Transform3D2PointsBox::bbUserInitializeProcessing() +{ + //We initialize the transformer + transformer=new Transformer3D(); + + //We initialize the plane operator + planes=new PlanesOperations(); +} +void Transform3D2PointsBox::bbUserFinalizeProcessing() +{ + //We delete the transformer + delete transformer; + + //We delete the plane operator + delete planes; +} +} +// EO namespace bbPackRecalage \ No newline at end of file diff --git a/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.h b/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.h new file mode 100644 index 0000000..b8551bc --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D2PointsBox.h @@ -0,0 +1,79 @@ +#ifndef __bbPackRecalageTransform3D2PointsBox_h_INCLUDED__ +#define __bbPackRecalageTransform3D2PointsBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "Transformer3D.h" +#include "vtkLinearTransform.h" +#include "vtkMath.h" +#include "PlanesOperations.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT Transform3D2PointsBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Transform3D2PointsBox,bbtk::AtomicBlackBox); + + /*Points in X*/ + BBTK_DECLARE_INPUT(InX1,std::vector); + + /*Points in Y*/ + BBTK_DECLARE_INPUT(InY1,std::vector); + + /*Points in Z*/ + BBTK_DECLARE_INPUT(InZ1,std::vector); + + /*Points in X*/ + BBTK_DECLARE_INPUT(InX2,std::vector); + + /*Points in Y*/ + BBTK_DECLARE_INPUT(InY2,std::vector); + + /*Points in Z*/ + BBTK_DECLARE_INPUT(InZ2,std::vector); + + /*Labels of points*/ + BBTK_DECLARE_INPUT(Labels1,std::vector); + /*Labels of points*/ + BBTK_DECLARE_INPUT(Labels2,std::vector); + + /*Second angle*/ + BBTK_DECLARE_INPUT(SecondAngle,double); + + /*Resultant vtkTransform*/ + BBTK_DECLARE_OUTPUT(Out, vtkTransform*); + + BBTK_PROCESS(Process); + void Process(); + + /*Class in charge of making the transformations*/ + Transformer3D *transformer; + + /*Class that does the vector operations*/ + PlanesOperations *planes; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform3D2PointsBox,bbtk::AtomicBlackBox); +BBTK_NAME("Transform3D2PointsBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Box useful for creating matrixes for 3D transformations defined by 2 points"); +BBTK_CATEGORY("image"); +BBTK_INPUT(Transform3D2PointsBox,InX1,"Points in X (first image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,InY1,"Points in Y (first image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,InZ1,"Points in Z (first image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,InX2,"Points in X (second image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,InY2,"Points in Y (second image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,InZ2,"Points in Z (second image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,SecondAngle,"Rotation to be done in second axis",double,""); +BBTK_INPUT(Transform3D2PointsBox,Labels1,"Labels of the points (first image)",std::vector,""); +BBTK_INPUT(Transform3D2PointsBox,Labels2,"Labels of the points (second image)",std::vector,""); +BBTK_OUTPUT(Transform3D2PointsBox,Out,"Transformation Matrix",vtkTransform*,""); +BBTK_END_DESCRIBE_BLACK_BOX(Transform3D2PointsBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageTransform3DBox_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx new file mode 100644 index 0000000..9156f13 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx @@ -0,0 +1,254 @@ +#include "bbPackRecalageTransform3D3PointsBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transform3D3PointsBox) +BBTK_BLACK_BOX_IMPLEMENTATION(Transform3D3PointsBox,bbtk::AtomicBlackBox); +void Transform3D3PointsBox::Process() +{ + if(!bbGetInputInX1().empty() && bbGetInputInX1().size() >= 3 && !bbGetInputInX2().empty() && bbGetInputInX2().size() >= 3) + { + double A1[3]; + double B1[3]; + double O1[3]; + + double A2[3]; + double B2[3]; + double O2[3]; + + //In case there is an order in the points + if(!bbGetInputLabels1().empty() && !bbGetInputLabels2().empty() && bbGetInputLabels1()[0].compare("1") == 0 && bbGetInputLabels1()[1].compare("2") == 0 && bbGetInputLabels1()[2].compare("3") == 0) + { + int i; + for(i = 0; i < 3; i++) + { + if(bbGetInputLabels1()[i].compare("1") == 0) + { + O1[0] = bbGetInputInX1()[i]; + O1[1] = bbGetInputInY1()[i]; + O1[2] = bbGetInputInZ1()[i]; + } + else if(bbGetInputLabels1()[i].compare("2") == 0) + { + A1[0] = bbGetInputInX1()[i]; + A1[1] = bbGetInputInY1()[i]; + A1[2] = bbGetInputInZ1()[i]; + } + else if(bbGetInputLabels1()[i].compare("3") == 0) + { + B1[0] = bbGetInputInX1()[i]; + B1[1] = bbGetInputInY1()[i]; + B1[2] = bbGetInputInZ1()[i]; + } + } + for(i = 0; i < 3; i++) + { + if(bbGetInputLabels2()[i].compare("1") == 0) + { + O2[0] = bbGetInputInX2()[i]; + O2[1] = bbGetInputInY2()[i]; + O2[2] = bbGetInputInZ2()[i]; + } + else if(bbGetInputLabels2()[i].compare("2") == 0) + { + A2[0] = bbGetInputInX2()[i]; + A2[1] = bbGetInputInY2()[i]; + A2[2] = bbGetInputInZ2()[i]; + } + else if(bbGetInputLabels2()[i].compare("3") == 0) + { + B2[0] = bbGetInputInX2()[i]; + B2[1] = bbGetInputInY2()[i]; + B2[2] = bbGetInputInZ2()[i]; + } + } + } + else + { + O1[0] = bbGetInputInX1()[0]; + O1[1] = bbGetInputInY1()[0]; + O1[2] = bbGetInputInZ1()[0]; + + A1[0] = bbGetInputInX1()[1]; + A1[1] = bbGetInputInY1()[1]; + A1[2] = bbGetInputInZ1()[1]; + + B1[0] = bbGetInputInX1()[2]; + B1[1] = bbGetInputInY1()[2]; + B1[2] = bbGetInputInZ1()[2]; + + O2[0] = bbGetInputInX2()[0]; + O2[1] = bbGetInputInY2()[0]; + O2[2] = bbGetInputInZ2()[0]; + + A2[0] = bbGetInputInX2()[1]; + A2[1] = bbGetInputInY2()[1]; + A2[2] = bbGetInputInZ2()[1]; + + B2[0] = bbGetInputInX2()[2]; + B2[1] = bbGetInputInY2()[2]; + B2[2] = bbGetInputInZ2()[2]; + } + + //Create the new center point + double * centerPoint; + centerPoint[0] = O2[0]; + centerPoint[1] = O2[1]; + centerPoint[2] = O2[2]; + + transformer->SetSecondTranslation(centerPoint); + + centerPoint[0] = O1[0]; + centerPoint[1] = O1[1]; + centerPoint[2] = O1[2]; + + transformer->SetFirstTranslation(centerPoint); + + //Create the first vector + double* vector1; + vector1 = planes->makeVector(O1, A1); + + //create the second vector + double* vector2; + vector2 = planes->makeVector(O2, A2); + + //The rotation axis + double* axis = planes->getCrossProduct(vector2, vector1); + + //Normalize the axis + axis = planes->getNormal(axis); + + //Normalize the 2 vectors for calculating the dot product + double* vector1N = planes->getNormal(vector1); + double* vector2N = planes->getNormal(vector2); + + //Dot product + double angle = planes->getDotProduct(vector2N, vector1N); + + //Convert the dot product to radians + angle = acos(angle); + + //Convert from Radians to Degrees (necesary for the transformation) + angle = vtkMath::DegreesFromRadians(angle); + + //Set the cross product and dot product of the first rotation + transformer->SetRotationAxis(axis); + transformer->SetAngle(angle); + + //Sets the second rotation axis (defined by the first vector) and the second angle as input + transformer->SetSecondRotationAxis(vector1); + + /////////////////////////////// + //Second Rotation calculations start now (adjust the angle between the planes) + ///////////////////////////////// + + //Obtain the resultant transformation without moving the image first + vtkMatrix4x4* matrix = transformer->GetFirstResult()->GetMatrix(); + + double newMatrix[3][3]; + + int i,j; + for(i = 0; i < 3; i ++) + { + for(j = 0; j < 3; j ++) + { + newMatrix[i][j] = matrix->GetElement(i,j); + } + } + + //Calculates the new position of the points after the first transformation + double A2N[3]; + A2N[0] = A2[0]*newMatrix[0][0] + A2[0]*newMatrix[0][1] + A2[0]*newMatrix[0][2]; + A2N[1] = A2[1]*newMatrix[1][0] + A2[0]*newMatrix[1][1] + A2[0]*newMatrix[1][2]; + A2N[2] = A2[2]*newMatrix[2][0] + A2[0]*newMatrix[2][1] + A2[0]*newMatrix[2][2]; + + double B2N[3]; + B2N[0] = B2[0]*newMatrix[0][0] + B2[0]*newMatrix[0][1] + B2[0]*newMatrix[0][2]; + B2N[1] = B2[1]*newMatrix[1][0] + B2[0]*newMatrix[1][1] + B2[0]*newMatrix[1][2]; + B2N[2] = B2[2]*newMatrix[2][0] + B2[0]*newMatrix[2][1] + B2[0]*newMatrix[2][2]; + + double O2N[3]; + O2N[0] = O2[0]*newMatrix[0][0] + O2[0]*newMatrix[0][1] + O2[0]*newMatrix[0][2]; + O2N[1] = O2[1]*newMatrix[1][0] + O2[0]*newMatrix[1][1] + O2[0]*newMatrix[1][2]; + O2N[2] = O2[2]*newMatrix[2][0] + O2[0]*newMatrix[2][1] + O2[0]*newMatrix[2][2]; + + /////////////////////////////////////////////////////////////////////////////// + //Creation of the two planes for the second transformation + /////////////////////////////////////////////////////////////////////////////// + + double * vector1A; + vector1A = planes->makeVector(O1, A1); + + double * vector1B; + vector1B = planes->makeVector(O1, B1); + + double * vector2AN; + vector2AN = planes->makeVector(O2N, A2N); + + double * vector2BN; + vector2BN = planes->makeVector(O2N, B2N); + + //Normal Plane 1 + double* crossPlaneA = planes->getCrossProduct(vector1A, vector1B); + + //Normal Plane 2 + double* crossPlaneB = planes->getCrossProduct(vector2AN, vector2BN); + + //Normalize the vectors + crossPlaneA = planes->getNormal(crossPlaneA); + crossPlaneB = planes->getNormal(crossPlaneB); + + //Angle between the planes + double anglePlanes = planes->getDotProduct(crossPlaneB, crossPlaneA); + + //Make necessary changes to the angle + anglePlanes = acos(anglePlanes); + + anglePlanes = vtkMath::DegreesFromRadians(anglePlanes); + + transformer->SetSecondAngle(-anglePlanes); + + // The calculation of the transformations are made + transformer->Run(); + + // We get the results of transformer and set it as result of this box + bbSetOutputOut( transformer->GetResult() ); + } + else + { + bbSetOutputOut( NULL ); + } +} +void Transform3D3PointsBox::bbUserSetDefaultValues() +{ + std::vector empty; + std::vector emptyString; + bbSetInputInX1(empty); + bbSetInputInY1(empty); + bbSetInputInZ1(empty); + bbSetInputInX2(empty); + bbSetInputInY2(empty); + bbSetInputInZ2(empty); + bbSetInputLabels1(emptyString); + bbSetInputLabels2(emptyString); + bbSetOutputOut(NULL); +} +void Transform3D3PointsBox::bbUserInitializeProcessing() +{ + //We initialize the transformer + transformer=new Transformer3D(); + + //We initialize the plane operator + planes=new PlanesOperations(); +} +void Transform3D3PointsBox::bbUserFinalizeProcessing() +{ + //We delete the transformer + delete transformer; + + //We delete the plane operator + delete planes; +} +} +// EO namespace bbPackRecalage \ No newline at end of file diff --git a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.h b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.h new file mode 100644 index 0000000..6de4e20 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.h @@ -0,0 +1,75 @@ +#ifndef __bbPackRecalageTransform3D3PointsBox_h_INCLUDED__ +#define __bbPackRecalageTransform3D3PointsBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "Transformer3D.h" +#include "vtkLinearTransform.h" +#include "vtkMath.h" +#include "PlanesOperations.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT Transform3D3PointsBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Transform3D3PointsBox,bbtk::AtomicBlackBox); + + /*Points in X*/ + BBTK_DECLARE_INPUT(InX1,std::vector); + + /*Points in Y*/ + BBTK_DECLARE_INPUT(InY1,std::vector); + + /*Points in Z*/ + BBTK_DECLARE_INPUT(InZ1,std::vector); + + /*Points in X*/ + BBTK_DECLARE_INPUT(InX2,std::vector); + + /*Points in Y*/ + BBTK_DECLARE_INPUT(InY2,std::vector); + + /*Points in Z*/ + BBTK_DECLARE_INPUT(InZ2,std::vector); + + /*Labels of points*/ + BBTK_DECLARE_INPUT(Labels1,std::vector); + /*Labels of points*/ + BBTK_DECLARE_INPUT(Labels2,std::vector); + + /*Resultant vtkTransform*/ + BBTK_DECLARE_OUTPUT(Out, vtkTransform*); + + BBTK_PROCESS(Process); + void Process(); + + /*Class in charge of making the transformations*/ + Transformer3D *transformer; + + /*Class that does the vector operations*/ + PlanesOperations *planes; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform3D3PointsBox,bbtk::AtomicBlackBox); +BBTK_NAME("Transform3D3PointsBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Box useful for creating matrixes for 3D transformations (3 points version)"); +BBTK_CATEGORY("image"); +BBTK_INPUT(Transform3D3PointsBox,InX1,"Points in X (first image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,InY1,"Points in Y (first image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,InZ1,"Points in Z (first image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,InX2,"Points in X (second image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,InY2,"Points in Y (second image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,InZ2,"Points in Z (second image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,Labels1,"Labels of the points (first image)",std::vector,""); +BBTK_INPUT(Transform3D3PointsBox,Labels2,"Labels of the points (second image)",std::vector,""); +BBTK_OUTPUT(Transform3D3PointsBox,Out,"Transformation Matrix",vtkTransform*,""); +BBTK_END_DESCRIBE_BLACK_BOX(Transform3D3PointsBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageTransform3DBox_h_INCLUDED__ + -- 2.45.0