From: tbaudier Date: Thu, 19 Nov 2015 14:29:58 +0000 (+0100) Subject: Rigid Registration & Overlay Debug try X-Git-Tag: v1.4.0~83^2~4 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=42df5bd85f2ad8eb5f9323fdf2441c7e36e2129f;p=clitk.git Rigid Registration & Overlay Debug try --- diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 317dc06..0a54a6a 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1072,7 +1072,7 @@ int vvSlicer::GetOrientation() //---------------------------------------------------------------------------- void vvSlicer::UpdateDisplayExtent() -{ //out << __func__ << endl; +{ cout << __func__ << endl; vtkImageData *input = this->GetInput(); if (!input || !this->ImageActor) { @@ -1101,11 +1101,11 @@ void vvSlicer::UpdateDisplayExtent() #else vtkSmartPointer mapperOpenGL= vtkSmartPointer::New(); try { - mapperOpenGL = dynamic_cast(GetImageActor()->GetMapper()); + mapperOpenGL = dynamic_cast(GetImageActor()->GetMapper()); } catch (const std::bad_cast& e) { - std::cerr << e.what() << std::endl; - std::cerr << "Conversion error" << std::endl; - return; + std::cerr << e.what() << std::endl; + std::cerr << "Conversion error" << std::endl; + return; } if (mFirstSetSliceOrientation) { copyExtent(ext, mRegisterExtent); @@ -1118,7 +1118,7 @@ void vvSlicer::UpdateDisplayExtent() w_croppingRegion[ this->SliceOrientation*2+1 ] = this->Slice; mapperOpenGL->SetCroppingRegion(w_croppingRegion); } -#endif +#endif #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) // Fix for bug #1882 @@ -1127,6 +1127,7 @@ void vvSlicer::UpdateDisplayExtent() // Overlay image actor if (mOverlay && mOverlayVisibility) { + //mOverlayMapper->GetOutput()->Print(cout); AdjustResliceToSliceOrientation(mOverlayReslice); int overExtent[6]; this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent); @@ -1592,7 +1593,7 @@ double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, doubl //---------------------------------------------------------------------------- void vvSlicer::Render() -{ //out << __func__ << endl; +{ cout << __func__ << endl; if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) { legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable()); legend->UseOpacityOn(); @@ -1605,6 +1606,7 @@ void vvSlicer::Render() } else legend->SetVisibility(0); if (ca->GetVisibility()) { + std::stringstream worldPos(" "); double pt[3]; mConcatenatedTransform->TransformPoint(mCurrent, pt); @@ -1644,7 +1646,7 @@ void vvSlicer::Render() Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 && Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 && Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) { - + int ix, iy, iz; double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz); @@ -1706,6 +1708,7 @@ void vvSlicer::Render() std::cerr << "Conversion error" << std::endl; return; } + if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 && xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 && yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 && @@ -1736,6 +1739,7 @@ void vvSlicer::Render() #else mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent()); #endif + mOverlayActor->Print(cout); mOverlayMapper->Update(); } if (mFusion && mFusionActor->GetVisibility()) { diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index 5cc862d..c02d7e6 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -19,6 +19,7 @@ // vv #include "vvToolRigidReg.h" #include "vvSlicer.h" +#include // vtk #include @@ -460,6 +461,8 @@ void vvToolRigidReg::ExtentMax(const double pointExtent[8][4], double maxExtent[ void vvToolRigidReg::Render() { //out << __func__ << endl; #if VTK_MAJOR_VERSION > 5 +double translationValues[4], translationValuesUpdate[4]; +mCurrentSlicerManager->GetImage()->GetTransform()[0]->Print(cout); vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix(); vtkMatrix4x4* matrixTranspose = matrix->NewInstance(); for (int i=0; i<3; ++i) { @@ -468,15 +471,21 @@ for (int i=0; i<3; ++i) { matrixTranspose->SetElement(i,j,matrix->GetElement(j,i)); } } -for (int i=0; i<4; ++i) { - matrixTranspose->SetElement(3,i,matrix->GetElement(3,i)); +for (int j=0; j<3; ++j) +{ + translationValues[j] = matrix->GetElement(j,3); +} +translationValues[3] = 0.0; +matrix->MultiplyPoint(translationValues, translationValuesUpdate); +for (int i=0; i<3; ++i) { + matrixTranspose->SetElement(i,3,translationValuesUpdate[i]); } for (int i=0; i<4; ++i) { - matrixTranspose->SetElement(i,3,matrix->GetElement(i,3)); + matrixTranspose->SetElement(3,i,matrix->GetElement(3,i)); } + #endif - for (int i=0; iGetNumberOfSlicers(); i++) - { +for (int i=0; iGetNumberOfSlicers(); i++) { #if VTK_MAJOR_VERSION > 5 double pointExtent[8][4], pointExtentUpdate[8][4]; std::vector w_ext; @@ -517,21 +526,23 @@ for (int i=0; i<4; ++i) { for (int k=0; k<8; ++k) { for (int j=0; j<3; ++j) { - pointExtent[k][j] = mCurrentSlicerManager->GetImage()->GetOrigin()[j] + mCurrentSlicerManager->GetImage()->GetSpacing()[j] * pointExtent[k][j]; + pointExtent[k][j] = mCurrentSlicerManager->GetImage()->GetSpacing()[j] * pointExtent[k][j]; } matrixTranspose->MultiplyPoint(pointExtent[k], pointExtentUpdate[k]); for (int j=0; j<3; ++j) { - pointExtentUpdate[k][j] = (pointExtentUpdate[k][j] - mCurrentSlicerManager->GetImage()->GetOrigin()[j])/mCurrentSlicerManager->GetImage()->GetSpacing()[j]; + pointExtentUpdate[k][j] = (pointExtentUpdate[k][j])/mCurrentSlicerManager->GetImage()->GetSpacing()[j]; + cout << pointExtentUpdate[k][j] << " "; } + cout << endl; + } + double extUpdateTemp[2][3]; + int extUpdate[6]; + ExtentMax(pointExtentUpdate, extUpdateTemp); + for (int j=0; j<3; ++j) { + extUpdate[2*j] = 0; + extUpdate[2*j+1] = itk::Math::Round(extUpdateTemp[1][j] - extUpdateTemp[0][j]); } -double extUpdateTemp[2][3]; -int extUpdate[6]; -ExtentMax(pointExtentUpdate, extUpdateTemp); -for (int j=0; j<3; ++j) { - extUpdate[2*j] = 0; - extUpdate[2*j+1] = itk::Math::Round(extUpdateTemp[1][j] - extUpdateTemp[0][j]); -} mCurrentSlicerManager->GetSlicer(i)->SetRegisterExtent(extUpdate); extUpdate[2*mCurrentSlicerManager->GetSlicer(i)->GetOrientation()] = mCurrentSlicerManager->GetSlicer(i)->GetSlice(); extUpdate[2*mCurrentSlicerManager->GetSlicer(i)->GetOrientation()+1] = mCurrentSlicerManager->GetSlicer(i)->GetSlice(); @@ -544,11 +555,39 @@ for (int j=0; j<3; ++j) { std::cerr << "Conversion error" << std::endl; return; } + cout << extUpdate[0] << " " << extUpdate[1] << " " << extUpdate[2] << " " << extUpdate[3] << " " << extUpdate[4] << " " << extUpdate[5] << endl; mapperOpenGL->SetCroppingRegion(extUpdate); + + if (mCurrentSlicerManager->GetSlicer(i)->GetOverlay() && mCurrentSlicerManager->GetSlicer(i)->GetOverlayActor()->GetVisibility()) { + int extOverlayUpdate[6]; + for (int j=0; j<3; ++j) { + if (0 < extUpdateTemp[0][j]) { + extOverlayUpdate[2*j] = itk::Math::Round(extUpdateTemp[0][j]); + } else { + extOverlayUpdate[2*j] = 0; + } + if (extUpdateTemp[1][j] < w_ext[j]-1) { + extOverlayUpdate[2*j+1] = itk::Math::Round(extUpdateTemp[1][j]); + } else { + extOverlayUpdate[2*j+1] = w_ext[j]-1; + } + } + extOverlayUpdate[2*mCurrentSlicerManager->GetSlicer(i)->GetOrientation()] += mCurrentSlicerManager->GetSlicer(i)->GetSlice(); + extOverlayUpdate[2*mCurrentSlicerManager->GetSlicer(i)->GetOrientation()+1] = extOverlayUpdate[2*mCurrentSlicerManager->GetSlicer(i)->GetOrientation()]; + vtkSmartPointer mapperOpenGL= vtkSmartPointer::New(); + try { + mapperOpenGL = dynamic_cast(mCurrentSlicerManager->GetSlicer(i)->GetOverlayActor()->GetMapper()); + } catch (const std::bad_cast& e) { + std::cerr << e.what() << std::endl; + std::cerr << "Conversion error" << std::endl; + return; + } + mapperOpenGL->SetCroppingRegion(extOverlayUpdate); + } #endif mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); mCurrentSlicerManager->GetSlicer(i)->Render(); - } +} } //------------------------------------------------------------------------------