1 #include "bbPackRecalagePlaneReorientationBox.h"
2 #include "bbPackRecalagePackage.h"
3 namespace bbPackRecalage
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,PlaneReorientationBox)
7 BBTK_BLACK_BOX_IMPLEMENTATION(PlaneReorientationBox,bbtk::AtomicBlackBox);
8 void PlaneReorientationBox::Process()
10 if(!bbGetInputInX().empty() && bbGetInputInX().size() == 3 && !bbGetInputInY().empty() && bbGetInputInY().size() == 3 && !bbGetInputInZ().empty() && bbGetInputInZ().size() == 3)
12 /*Unitary Vector in Y*/
18 /*Unitary Vector in X*/
26 /*Normal vector without its z factor*/
28 normalZ[0] = normal[0];
29 normalZ[1] = normal[1];
32 /*Normal vector without its y factor*/
34 normalY[0] = normal[0];
36 normalY[2] = normal[2];
38 /*Angle for the rotation in Z*/
39 double angleZ = acos(vtkMath::Dot(normalZ,y)/vtkMath::Norm(normalZ));
41 /*Angle for the rotation in Y*/
42 double angleY = acos(vtkMath::Dot(x,normalY)/vtkMath::Norm(normalY));
44 /*Convert from Radians to Degrees*/
45 angleZ = vtkMath::DegreesFromRadians(angleZ);
46 angleY = vtkMath::DegreesFromRadians(angleY);
47 std::cout << "Angle for Z: " << angleZ << std::endl;
48 std::cout << "Angle for Y: " << angleY << std::endl;
50 vtkTransform *transform = vtkTransform::New();
51 transform->Identity();
54 transform->RotateWXYZ(angleZ,0,0,1);
58 transform->RotateWXYZ(angleZ,0,0,-1);
62 transform->RotateWXYZ(angleY,0,1,0);
66 if(angleY != 180){transform->RotateWXYZ(angleY,0,-1,0);}
68 //transform->Translate(bbGetInputCenterPoint()[0],bbGetInputCenterPoint()[1],bbGetInputCenterPoint()[2]);
71 /*Set output and pray to god that it works :P*/
72 bbSetOutputOut(transform);
75 void PlaneReorientationBox::bbUserSetDefaultValues()
77 std::vector<int> nullVector;
78 bbSetInputInX(nullVector);
79 bbSetInputInY(nullVector);
80 bbSetInputInZ(nullVector);
82 void PlaneReorientationBox::bbUserInitializeProcessing()
85 // THE INITIALIZATION METHOD BODY :
87 // but this is where you should allocate the internal/output pointers
92 void PlaneReorientationBox::bbUserFinalizeProcessing()
95 // THE FINALIZATION METHOD BODY :
97 // but this is where you should desallocate the internal/output pointers
102 // EO namespace bbPackRecalage