#include "bbTransform3DdicomRotateDICOM.h" #include "bbTransform3DdicomPackage.h" #include #include #include "matrixRotation.h" namespace bbTransform3Ddicom { BBTK_ADD_BLACK_BOX_TO_PACKAGE(Transform3Ddicom,RotateDICOM) BBTK_BLACK_BOX_IMPLEMENTATION(RotateDICOM,bbtk::AtomicBlackBox); void RotateDICOM::Process() { vtkTransform* transform1 = vtkTransform::New(); matrixRotation matrot1; if (bbGetInputSpacing1().size()==3) { matrot1.SetSpacing( bbGetInputSpacing1()[0],bbGetInputSpacing1()[1] ,bbGetInputSpacing1()[2] ); } if (bbGetInputPosition1().size()==3) { matrot1.SetOrigin( bbGetInputPosition1()[0],bbGetInputPosition1()[1] ,bbGetInputPosition1()[2] ); } if ((bbGetInputOrientation1Vec1().size()==3) && (bbGetInputOrientation1Vec2().size()==3) ) { matrot1.SetVector1( bbGetInputOrientation1Vec1()[0],bbGetInputOrientation1Vec1()[1] ,bbGetInputOrientation1Vec1()[2] ); matrot1.SetVector2( bbGetInputOrientation1Vec2()[0],bbGetInputOrientation1Vec2()[1] ,bbGetInputOrientation1Vec2()[2] ); } if ((bbGetInputOrientation1Vec12().size()==6) ) { matrot1.SetVector1( bbGetInputOrientation1Vec12()[0],bbGetInputOrientation1Vec12()[1] ,bbGetInputOrientation1Vec12()[2] ); matrot1.SetVector2( bbGetInputOrientation1Vec12()[3],bbGetInputOrientation1Vec12()[4] ,bbGetInputOrientation1Vec12()[5] ); } matrot1.GetTransformation(transform1); matrixRotation matrot2; if (bbGetInputSpacing2().size()==3) { matrot2.SetSpacing( bbGetInputSpacing2()[0],bbGetInputSpacing2()[1] ,bbGetInputSpacing2()[2] ); } if (bbGetInputPosition2().size()==3) { matrot2.SetOrigin( bbGetInputPosition2()[0],bbGetInputPosition2()[1] ,bbGetInputPosition2()[2] ); } if ((bbGetInputOrientation2Vec1().size()==3) && (bbGetInputOrientation2Vec2().size()==3) ) { matrot2.SetVector1( bbGetInputOrientation2Vec1()[0],bbGetInputOrientation2Vec1()[1] ,bbGetInputOrientation2Vec1()[2] ); matrot2.SetVector2( bbGetInputOrientation2Vec2()[0],bbGetInputOrientation2Vec2()[1] ,bbGetInputOrientation2Vec2()[2] ); } if ((bbGetInputOrientation2Vec12().size()==6) ) { matrot2.SetVector1( bbGetInputOrientation2Vec12()[0],bbGetInputOrientation2Vec12()[1] ,bbGetInputOrientation2Vec12()[2] ); matrot2.SetVector2( bbGetInputOrientation2Vec12()[3],bbGetInputOrientation2Vec12()[4] ,bbGetInputOrientation2Vec12()[5] ); } vtkTransform* transform2 = (vtkTransform*)bbGetOutputOut(); transform2->PostMultiply (); matrot2.GetTransformation(transform2); vtkMatrix4x4 *invers1 = vtkMatrix4x4::New(); transform1->GetInverse(invers1); transform2->Concatenate(invers1); bbSetOutputOut( transform2 ); transform1->Delete(); } /* void RotateDICOM::bbUserConstructor() { std::vector spacing; spacing.push_back(1.0); spacing.push_back(1.0); spacing.push_back(1.0); bbSetInputSpacing1(spacing); bbSetInputSpacing2(spacing); std::vector position; position.push_back(0.0); position.push_back(0.0); position.push_back(0.0); bbSetInputPosition1(position); bbSetInputPosition2(position); std::vector orientationVec1; orientationVec1.push_back(1.0); orientationVec1.push_back(0.0); orientationVec1.push_back(0.0); bbSetInputOrientation1Vec1(orientationVec1); bbSetInputOrientation2Vec1(orientationVec1); std::vector orientationVec2; orientationVec2.push_back(0.0); orientationVec2.push_back(1.0); orientationVec2.push_back(0.0); bbSetInputOrientation1Vec2(orientationVec2); bbSetInputOrientation2Vec2(orientationVec2); bbSetOutputOut( vtkTransform::New() ); } void RotateDICOM::bbUserCopyConstructor(bbtk::BlackBox::Pointer) { } void RotateDICOM::bbUserDestructor() { vtkTransform* transform = (vtkTransform*)bbGetOutputOut(); if (transform!=NULL) { transform->Delete(); } } */ //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void RotateDICOM::bbUserSetDefaultValues() { std::vector spacing; spacing.push_back(1.0); spacing.push_back(1.0); spacing.push_back(1.0); bbSetInputSpacing1(spacing); bbSetInputSpacing2(spacing); std::vector position; position.push_back(0.0); position.push_back(0.0); position.push_back(0.0); bbSetInputPosition1(position); bbSetInputPosition2(position); std::vector orientationVec1; orientationVec1.push_back(1.0); orientationVec1.push_back(0.0); orientationVec1.push_back(0.0); bbSetInputOrientation1Vec1(orientationVec1); bbSetInputOrientation2Vec1(orientationVec1); std::vector orientationVec2; orientationVec2.push_back(0.0); orientationVec2.push_back(1.0); orientationVec2.push_back(0.0); bbSetInputOrientation1Vec2(orientationVec2); bbSetInputOrientation2Vec2(orientationVec2); bbSetOutputOut( vtkTransform::New() ); } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void RotateDICOM::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void RotateDICOM::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any vtkTransform* transform = (vtkTransform*)bbGetOutputOut(); if (transform!=NULL) { transform->Delete(); } } } // EO namespace bbTransform3Ddicom