4 //-------------------------------------------------------------------------------------------
8 matrixrotation = new matrixRotation();
9 transform = vtkTransform::New();
12 //-------------------------------------------------------------------------------------------
13 CreaImage::~CreaImage()
15 delete matrixrotation;
19 //-------------------------------------------------------------------------------------------
20 void CreaImage::SetvtkImageData(vtkImageData *image)
26 // orgImage->Delete();
28 orgImage = vtkImageData::New();
29 orgImage->ShallowCopy(image);
31 // orgImage->SetSpacing(1,1,1);
37 //-------------------------------------------------------------------------------------------
38 void CreaImage::SetImagePositionPatient(double x,double y,double z)
40 matrixrotation->SetOrigin(x,y,z);
43 //-------------------------------------------------------------------------------------------
44 void CreaImage::SetImageSpacing(double sx, double sy, double sz)
46 matrixrotation->SetSpacing(sx,sy,sz);
49 //-------------------------------------------------------------------------------------------
50 void CreaImage::SetImageOrientation(double v1x,double v1y,double v1z, double v2x,double v2y,double v2z)
52 matrixrotation->SetVector1( v1x , v1y , v1z );
53 matrixrotation->SetVector2( v2x , v2y , v2z );
56 //-------------------------------------------------------------------------------------------
57 void CreaImage::Update()
59 matrixrotation->GetTransformation(transform);
62 //-------------------------------------------------------------------------------------------
63 vtkImageData *CreaImage::GetImage()
68 //-------------------------------------------------------------------------------------------
69 vtkTransform *CreaImage::GetvtkTransform()
74 //-------------------------------------------------------------------------------------------
75 double CreaImage::GetVoxelInIRMUniverse(double x,double y, double z)
85 transform->TransformPoint( pIn , pOut );
88 orgImage->GetExtent(ext);
89 int px=round(pOut[0]);
90 int py=round(pOut[1]);
91 int pz=round(pOut[2]);
92 if ( (px>=ext[0]) && (px<ext[1]) &&
93 (py>=ext[2]) && (py<ext[3]) &&
94 (pz>=ext[4]) && (pz<ext[5]) )
96 unsigned short *p = (unsigned short*) orgImage->GetScalarPointer( px,py,pz );
103 //-------------------------------------------------------------------------------------------
104 double CreaImage::GetVoxelInImageUniverse(double x,double y, double z)
108 orgImage->GetExtent(ext);
112 if ( (px>=ext[0]) && (px<ext[1]) &&
113 (py>=ext[2]) && (py<ext[3]) &&
114 (pz>=ext[4]) && (pz<ext[5]) )
116 unsigned short *p = (unsigned short*) orgImage->GetScalarPointer( px,py,pz );