X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkImagePlanes.cxx;h=9f61f6ea0efc81d02221ef80ab3d25cd10549369;hb=2e1f522c4615a3a0f71575ece9e053860883eeec;hp=24d9f36a6243a5d205e6dfe44e76beb7cfc963ad;hpb=5566eb4dec92fe8915fd68824a4ce56ea0529f81;p=bbtk.git diff --git a/packages/vtk/src/bbvtkImagePlanes.cxx b/packages/vtk/src/bbvtkImagePlanes.cxx index 24d9f36..9f61f6e 100644 --- a/packages/vtk/src/bbvtkImagePlanes.cxx +++ b/packages/vtk/src/bbvtkImagePlanes.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbvtkImagePlanes.cxx,v $ Language: C++ - Date: $Date: 2009/07/02 07:17:33 $ - Version: $Revision: 1.29 $ + Date: $Date: 2009/09/01 13:59:48 $ + Version: $Revision: 1.30 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -137,7 +137,7 @@ namespace bbvtk }; //================================================================ - //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.29 $"); + //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.30 $"); //================================================================ @@ -330,6 +330,7 @@ void ImagePlanes::Process() if(pointsx.size()==pointsy.size() && pointsx.size()==pointsz.size()&&pointsx.size()>=3){ + //Get the corresponding three points out of the vectors double origin[3]; origin[0] = pointsx[0]; origin[1] = pointsy[0]; @@ -344,6 +345,7 @@ void ImagePlanes::Process() point2[1]= pointsy[2]; point2[2]= pointsz[2]; + //With the three points we create the corresponding X, Y and Z vectors all orthogonal to each other double* vect1= getNormal(makeVector(origin, point1)); double* vect2= getNormal(makeVector(origin, point2)); double* crossp = getCrossProduct(vect1, vect2); @@ -356,7 +358,7 @@ void ImagePlanes::Process() factor = ext[0]SetInput(bbGetInputIn()); double xSpacing, ySpacing, zSpacing; @@ -369,7 +371,7 @@ void ImagePlanes::Process() (origin[1]+vect2[1]*factor)*ySpacing, (origin[2]+vect2[2]*factor)*zSpacing); plane3pts->GetResliceOutput()->Update(); - +//To get the slice of image out of the selected volume if (_imageReslicer==NULL){ _imageReslicer = vtkImageReslice::New(); _imageReslicer->SetOutputDimensionality(2); @@ -379,9 +381,10 @@ void ImagePlanes::Process() } _imageReslicer->SetInput( bbGetInputIn() ); _imageReslicer->SetInformationInput(bbGetInputIn()); - _imageReslicer->SetResliceAxesDirectionCosines(newx[0],newx[1],newx[2], - vect2[0],vect2[1],vect2[2], - crossp[0],crossp[1],crossp[2]); + //fill out the information with the created vectors and using the spacing of the image + _imageReslicer->SetResliceAxesDirectionCosines(newx[0]*xSpacing,newx[1]*xSpacing,newx[2]*xSpacing, + vect2[0]*ySpacing,vect2[1]*ySpacing,vect2[2]*ySpacing, + crossp[0]*zSpacing,crossp[1]*zSpacing,crossp[2]*zSpacing); _imageReslicer->SetResliceAxesOrigin(origin[0]*xSpacing,origin[1]*ySpacing,origin[2]*zSpacing); _imageReslicer->GetOutput()->Update(); _imageReslicer->GetOutput()->UpdateInformation(); @@ -393,22 +396,23 @@ void ImagePlanes::Process() _matrix->Identity(); - _matrix->SetElement(0,0,newx[0]); - _matrix->SetElement(1,0,newx[1]); - _matrix->SetElement(2,0,newx[2]); - _matrix->SetElement(0,1,vect2[0]); - _matrix->SetElement(1,1,vect2[1]); - _matrix->SetElement(2,1,vect2[2]); - _matrix->SetElement(0,2,crossp[0]); - _matrix->SetElement(1,2,crossp[1]); - _matrix->SetElement(2,2,crossp[2]); - _matrix->SetElement(0,3,origin[0]); - _matrix->SetElement(1,3,origin[1]); - _matrix->SetElement(2,3,origin[2]); + _matrix->SetElement(0,0,newx[0]*xSpacing); + _matrix->SetElement(1,0,newx[1]*xSpacing); + _matrix->SetElement(2,0,newx[2]*xSpacing); + _matrix->SetElement(0,1,vect2[0]*ySpacing); + _matrix->SetElement(1,1,vect2[1]*ySpacing); + _matrix->SetElement(2,1,vect2[2]*ySpacing); + _matrix->SetElement(0,2,crossp[0]*zSpacing); + _matrix->SetElement(1,2,crossp[1]*zSpacing); + _matrix->SetElement(2,2,crossp[2]*zSpacing); + _matrix->SetElement(0,3,origin[0]*xSpacing); + _matrix->SetElement(1,3,origin[1]*ySpacing); + _matrix->SetElement(2,3,origin[2]*zSpacing); _transform->SetMatrix(_matrix); + //set the transformation out to be used by other bbBoxes bbSetOutputTransform3Pts((vtkLinearTransform*)_transform);