Fix Reslice Image orientation bug.
This commit is contained in:
@@ -254,13 +254,13 @@ void ResliceImageViewer::SetDefaultSliceOrientation(int orientation) {
|
|||||||
double position[4] = {.0, .0, .0, 1.};
|
double position[4] = {.0, .0, .0, 1.};
|
||||||
double ViewUp[4] = {.0, .0, .0, 1.};
|
double ViewUp[4] = {.0, .0, .0, 1.};
|
||||||
switch (orientation){
|
switch (orientation){
|
||||||
case 1:{
|
case 0:{
|
||||||
position[1] = -1.0;
|
position[0] = 1.0;
|
||||||
ViewUp[2] = 1.0;
|
ViewUp[2] = 1.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0:{
|
case 1:{
|
||||||
position[0] = 1.0;
|
position[1] = -1.0;
|
||||||
ViewUp[2] = 1.0;
|
ViewUp[2] = 1.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -275,6 +275,7 @@ void ResliceImageViewer::SetDefaultSliceOrientation(int orientation) {
|
|||||||
DefaultOrientation = orientation;
|
DefaultOrientation = orientation;
|
||||||
OrientationMatrix->MultiplyPoint(position,position);
|
OrientationMatrix->MultiplyPoint(position,position);
|
||||||
OrientationMatrix->MultiplyPoint(ViewUp,ViewUp);
|
OrientationMatrix->MultiplyPoint(ViewUp,ViewUp);
|
||||||
|
|
||||||
vtkCamera* camera = Renderer->GetActiveCamera();
|
vtkCamera* camera = Renderer->GetActiveCamera();
|
||||||
camera->SetFocalPoint(.0, .0, .0);
|
camera->SetFocalPoint(.0, .0, .0);
|
||||||
camera->SetPosition(position);
|
camera->SetPosition(position);
|
||||||
@@ -284,9 +285,18 @@ void ResliceImageViewer::SetDefaultSliceOrientation(int orientation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResliceImageViewer::SetCoordsTransformMatrix(vtkMatrix4x4 *matrix4X4) {
|
void ResliceImageViewer::SetCoordsTransformMatrix(vtkMatrix4x4 *matrix4X4) {
|
||||||
|
|
||||||
OrientationMatrix->DeepCopy(matrix4X4);
|
OrientationMatrix->DeepCopy(matrix4X4);
|
||||||
|
|
||||||
OrientationMatrix->Invert();
|
OrientationMatrix->Invert();
|
||||||
|
|
||||||
|
//TODO:暂时使用特殊处理解决负向堆叠问题,考虑如何去除特殊处理
|
||||||
|
//默认的横断面Slice 需要考虑奇葩的负向堆叠
|
||||||
|
if (OrientationMatrix->IsIdentity()){
|
||||||
|
double zVec = Mapper->GetInput()->GetSpacing()[2];
|
||||||
|
OrientationMatrix->SetElement(2,2, zVec>0.0?1.0:-1.0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResliceImageViewer::updateHandle(vtkObject* sender, unsigned long eventID, void* callData) {
|
void ResliceImageViewer::updateHandle(vtkObject* sender, unsigned long eventID, void* callData) {
|
||||||
@@ -387,8 +397,14 @@ void ResliceImageViewer::AdjustOrthogonalScale() {
|
|||||||
vtkImageData * data = Mapper->GetInput();
|
vtkImageData * data = Mapper->GetInput();
|
||||||
int index = abs(((int)viewUp[0]) * 0 + ((int)viewUp[1]) * 1 + ((int)viewUp[2]) * 2);
|
int index = abs(((int)viewUp[0]) * 0 + ((int)viewUp[1]) * 1 + ((int)viewUp[2]) * 2);
|
||||||
|
|
||||||
|
double ratio = Renderer->GetTiledAspectRatio();
|
||||||
double pixelScale = data->GetDimensions()[index]*data->GetSpacing()[index];
|
double pixelScale = data->GetDimensions()[index]*data->GetSpacing()[index];
|
||||||
camera->SetParallelScale(pixelScale/2-3);
|
if (ratio<1.0){
|
||||||
|
camera->SetParallelScale(pixelScale/2/ratio+3);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
camera->SetParallelScale(pixelScale/2+3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResliceImageViewer::UpdateDirectionAnnotation() {
|
void ResliceImageViewer::UpdateDirectionAnnotation() {
|
||||||
|
|||||||
@@ -210,20 +210,20 @@ void MPRResliceWindow::setRenderWindowLayout(LayoutType type) {
|
|||||||
|
|
||||||
void MPRResliceWindow::loadData(SeriesImageSet *series) {
|
void MPRResliceWindow::loadData(SeriesImageSet *series) {
|
||||||
mViewerC->SetRenderWindow(mWidgetCoronal->renderWindow());
|
mViewerC->SetRenderWindow(mWidgetCoronal->renderWindow());
|
||||||
mViewerC->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
|
||||||
mViewerC->SetInputData(series->GetData());
|
mViewerC->SetInputData(series->GetData());
|
||||||
|
mViewerC->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
||||||
mViewerC->SetDefaultSliceOrientation(2);
|
mViewerC->SetDefaultSliceOrientation(2);
|
||||||
mViewerC->SetWindowLevel(mWindowLevel);
|
mViewerC->SetWindowLevel(mWindowLevel);
|
||||||
mViewerC->Render();
|
mViewerC->Render();
|
||||||
mViewerS->SetRenderWindow(mWidgetSagittal->renderWindow());
|
mViewerS->SetRenderWindow(mWidgetSagittal->renderWindow());
|
||||||
mViewerS->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
|
||||||
mViewerS->SetInputData(series->GetData());
|
mViewerS->SetInputData(series->GetData());
|
||||||
|
mViewerS->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
||||||
mViewerS->SetDefaultSliceOrientation(1);
|
mViewerS->SetDefaultSliceOrientation(1);
|
||||||
mViewerS->SetWindowLevel(mWindowLevel);
|
mViewerS->SetWindowLevel(mWindowLevel);
|
||||||
mViewerS->Render();
|
mViewerS->Render();
|
||||||
mViewerA->SetRenderWindow(mWidgetAxial->renderWindow());
|
mViewerA->SetRenderWindow(mWidgetAxial->renderWindow());
|
||||||
mViewerA->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
|
||||||
mViewerA->SetInputData(series->GetData());
|
mViewerA->SetInputData(series->GetData());
|
||||||
|
mViewerA->SetCoordsTransformMatrix(series->GetProperty()->GetOrientationMatrix());
|
||||||
mViewerA->SetDefaultSliceOrientation(0);
|
mViewerA->SetDefaultSliceOrientation(0);
|
||||||
mViewerA->SetWindowLevel(mWindowLevel);
|
mViewerA->SetWindowLevel(mWindowLevel);
|
||||||
mViewerA->Render();
|
mViewerA->Render();
|
||||||
|
|||||||
Reference in New Issue
Block a user