From: Eduardo DAVILA Date: Mon, 1 Feb 2016 14:28:09 +0000 (+0100) Subject: #2810 crea RigidRegistration Bug New Normal - update Transform3D3PointsBox X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=creaRigidRegistration.git;a=commitdiff_plain;h=7051738fb1c92724bd6d15907edc4d517527a3b2 #2810 crea RigidRegistration Bug New Normal - update Transform3D3PointsBox --- diff --git a/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg b/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg index 558f148..fb522a5 100644 --- a/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg +++ b/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/davila/Creatis/All/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg +# - /tmpEED/creaTools/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbg # ---------------------------------- APP_START diff --git a/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs b/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs index 7c2773a..240f050 100644 --- a/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs +++ b/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/All/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs +# - /tmpEED/creaTools/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget_base_3Dp_B.bbs # ---------------------------------- include std @@ -17,41 +17,41 @@ description "creatisRecalage" category "example" -new ImageConvolution convol1 +new PackRecalage:ImageConvolution convol1 -new SliceImage Box02 +new creaMaracasVisu:SliceImage Box02 set Box02.TypeOrientation "0" -new ImageConvolution Box03 +new PackRecalage:ImageConvolution Box03 -new SliceImage Box04 +new creaMaracasVisu:SliceImage Box04 set Box04.TypeOrientation "1" -new ImageConvolution Box05 +new PackRecalage:ImageConvolution Box05 -new SliceImage Box06 +new creaMaracasVisu:SliceImage Box06 set Box06.TypeOrientation "2" -new AddImageToVector Box07 +new PackRecalage:AddImageToVector Box07 -new vtkImageDataPointerRelay Box08 +new vtk:vtkImageDataPointerRelay Box08 -new MagicBox Box09 +new std:MagicBox Box09 -new MagicBox Box10 +new std:MagicBox Box10 -new MagicBox Box11 +new std:MagicBox Box11 -new GetVectorIntElement Box12 +new std:GetVectorIntElement Box12 set Box12.I "2" -new GetVectorIntElement Box13 +new std:GetVectorIntElement Box13 set Box13.I "1" -new GetVectorIntElement Box14 +new std:GetVectorIntElement Box14 set Box14.I "0" -new MagicBox Box15 +new std:MagicBox Box15 connect Box02.Out convol1.In @@ -89,5 +89,6 @@ input Point Box15.In " " # Complex output ports output Out Box07.Out " " +message endefine diff --git a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx index d5c2467..219da2b 100644 --- a/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx +++ b/PackRecalage/src/bbPackRecalageTransform3D3PointsBox.cxx @@ -186,18 +186,18 @@ void Transform3D3PointsBox::Process() //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]; + A2N[1] = A2[1]*newMatrix[1][0] + A2[1]*newMatrix[1][1] + A2[1]*newMatrix[1][2]; + A2N[2] = A2[2]*newMatrix[2][0] + A2[2]*newMatrix[2][1] + A2[2]*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]; + B2N[1] = B2[1]*newMatrix[1][0] + B2[1]*newMatrix[1][1] + B2[1]*newMatrix[1][2]; + B2N[2] = B2[2]*newMatrix[2][0] + B2[2]*newMatrix[2][1] + B2[2]*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]; + O2N[1] = O2[1]*newMatrix[1][0] + O2[1]*newMatrix[1][1] + O2[1]*newMatrix[1][2]; + O2N[2] = O2[2]*newMatrix[2][0] + O2[2]*newMatrix[2][1] + O2[2]*newMatrix[2][2]; /////////////////////////////////////////////////////////////////////////////// //Creation of the two planes for the second transformation @@ -235,6 +235,22 @@ void Transform3D3PointsBox::Process() transformer->SetSecondAngle(-anglePlanes); + + double * vector2B; + vector2B = planes->makeVector(O2, B2); + double mag1= planes->getMagnitud(vector1B); + double mag2= planes->getMagnitud(vector2B); + transformer->SetScale(mag1/mag2); + + +/* + double * vector2B; + vector2B = planes->makeVector(O2, B2); + double mag1= planes->getMagnitud(vector1); + double mag2= planes->getMagnitud(vector2); + transformer->SetScale(mag2/mag1); +*/ + // The calculation of the transformations are made transformer->Run(); diff --git a/lib/Transformer3D.cxx b/lib/Transformer3D.cxx index b107bb3..f948f7d 100644 --- a/lib/Transformer3D.cxx +++ b/lib/Transformer3D.cxx @@ -121,6 +121,14 @@ void Transformer3D::SetSecondAngle(double angle) } +void Transformer3D::SetScale(double scale) +{ + _scale=scale; +} + + + + /* GETS THE RESULTANT TRANSFORM */ @@ -135,14 +143,9 @@ vtkTransform *Transformer3D::GetResult() vtkTransform *Transformer3D::GetFirstResult() { _transform->Identity(); - _transform->Translate(-_firstPoint[0], -_firstPoint[1], -_firstPoint[2]); - _transform->RotateWXYZ(_angle, _rotationAxis[0], _rotationAxis[1], _rotationAxis[2]); - _transform->Translate(_secondPoint[0], _secondPoint[1], _secondPoint[2]); - - _transform->Update(); return _transform; } @@ -154,20 +157,17 @@ void Transformer3D::Run() { //Cleans the transformation matrix _transform->Identity(); - //Make all transformations in postmultiply mode _transform->PostMultiply(); - //Acomodate in 0,0,0 according to the first point of the second vector _transform->Translate(-_secondPoint[0], -_secondPoint[1], -_secondPoint[2]); - _transform->RotateWXYZ(_angle, _rotationAxis[0], _rotationAxis[1], _rotationAxis[2]); - _transform->RotateWXYZ(_secondAngle, _secondRotationAxis[0], _secondRotationAxis[1], _secondRotationAxis[2]); - +printf("EED Transformer3D::Run %f %f\n", _angle, _secondAngle); + _transform->Scale(_scale,_scale,_scale); //Acommodate according to the first point of the first vector _transform->Translate(_firstPoint[0], _firstPoint[1], _firstPoint[2]); - _transform->Inverse(); _transform->Update(); } + diff --git a/lib/Transformer3D.h b/lib/Transformer3D.h index a5f882f..3879509 100644 --- a/lib/Transformer3D.h +++ b/lib/Transformer3D.h @@ -42,11 +42,13 @@ public: void SetSecondRotationAxis(double* axis); void SetAngle(double angle); void SetSecondAngle(double angle); + void SetScale(double scale); void Run(); vtkTransform *GetResult(); vtkTransform *GetFirstResult(); private: + double _scale; double _rotationAxis[3]; double _secondRotationAxis[3]; double _firstPoint[3];