X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FTransformDicom3D%2FCreaImage.cxx;fp=lib%2FTransformDicom3D%2FCreaImage.cxx;h=d4fc7428625e2857f7ba4a0bfb1f218a1945a35f;hb=916db8ea8376e6a88a74f2b76b24d6e746041217;hp=0000000000000000000000000000000000000000;hpb=3579beef5bd466705bc0431d7347d1150cdffe97;p=creaImageIO.git diff --git a/lib/TransformDicom3D/CreaImage.cxx b/lib/TransformDicom3D/CreaImage.cxx new file mode 100644 index 0000000..d4fc742 --- /dev/null +++ b/lib/TransformDicom3D/CreaImage.cxx @@ -0,0 +1,121 @@ +#include"Math.h" +#include"CreaImage.h" + +//------------------------------------------------------------------------------------------- +CreaImage::CreaImage() +{ + orgImage = NULL; + matrixrotation = new matrixRotation(); + transform = vtkTransform::New(); +} + +//------------------------------------------------------------------------------------------- +CreaImage::~CreaImage() +{ + delete matrixrotation; + transform->Delete(); +} + +//------------------------------------------------------------------------------------------- +void CreaImage::SetvtkImageData(vtkImageData *image) +{ + if (image!=NULL) + { + if (orgImage!=NULL) + { + // orgImage->Delete(); + } + orgImage = vtkImageData::New(); + orgImage->ShallowCopy(image); + orgImage = image; +// orgImage->SetSpacing(1,1,1); + } else { + orgImage = NULL; + } +} + +//------------------------------------------------------------------------------------------- +void CreaImage::SetImagePositionPatient(double x,double y,double z) +{ + matrixrotation->SetOrigin(x,y,z); +} + +//------------------------------------------------------------------------------------------- +void CreaImage::SetImageSpacing(double sx, double sy, double sz) +{ + matrixrotation->SetSpacing(sx,sy,sz); +} + +//------------------------------------------------------------------------------------------- +void CreaImage::SetImageOrientation(double v1x,double v1y,double v1z, double v2x,double v2y,double v2z) +{ + matrixrotation->SetVector1( v1x , v1y , v1z ); + matrixrotation->SetVector2( v2x , v2y , v2z ); +} + +//------------------------------------------------------------------------------------------- +void CreaImage::Update() +{ + matrixrotation->GetTransformation(transform); +} + +//------------------------------------------------------------------------------------------- +vtkImageData *CreaImage::GetImage() +{ + return orgImage; +} + +//------------------------------------------------------------------------------------------- +vtkTransform *CreaImage::GetvtkTransform() +{ + return transform; +} + +//------------------------------------------------------------------------------------------- +double CreaImage::GetVoxelInIRMUniverse(double x,double y, double z) +{ + double result=0; + double pIn[3]; + double pOut[3]; + + pIn[0]=x; + pIn[1]=y; + pIn[2]=z; + + transform->TransformPoint( pIn , pOut ); + + int ext[6]; + orgImage->GetExtent(ext); + int px=round(pOut[0]); + int py=round(pOut[1]); + int pz=round(pOut[2]); + if ( (px>=ext[0]) && (px=ext[2]) && (py=ext[4]) && (pzGetScalarPointer( px,py,pz ); + result = *p; + } + return result; + +} + +//------------------------------------------------------------------------------------------- +double CreaImage::GetVoxelInImageUniverse(double x,double y, double z) +{ + double result=0; + int ext[6]; + orgImage->GetExtent(ext); + int px=round(x); + int py=round(y); + int pz=round(z); + if ( (px>=ext[0]) && (px=ext[2]) && (py=ext[4]) && (pzGetScalarPointer( px,py,pz ); + result = *p; + } + return result; +} +