vtkSmartPointer<vtkDICOMReader> DICOMreader = vtkSmartPointer<vtkDICOMReader>::New();
DICOMreader->SetDataByteOrderToLittleEndian();
DICOMreader->SetMemoryRowOrderToTopDown();
DICOMreader->SortingOn(); //图像排序
DICOMreader->SetFileNames(sortedFiles);
DICOMreader->Update();
ImageProperties = vtkSmartPointer<vtkMedicalImageProperties>::New();
ImageProperties->DeepCopy(DICOMreader->GetMedicalImageProperties());
PatientMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
PatientMatrix->DeepCopy(DICOMreader->GetPatientMatrix());
m_imageData = vtkSmartPointer<vtkImageData>::New();
m_imageData->DeepCopy(DICOMreader->GetOutput());
m_imageData->SetSpacing(mSpacing);
m_imageData->SetOrigin(ImagePositionPatient[0], ImagePositionPatient[1], ImagePositionPatient[2]);
for (int i = 0; i < 3; ++i) {
auto rep = vtkResliceCursorLineRepresentation::SafeDownCast(
mResliceViewer[i]->GetResliceCursorWidget()->GetRepresentation());
rep->GetResliceCursorActor()->
GetCursorAlgorithm()->SetReslicePlaneNormal(i);
mResliceViewer[i]->GetRenderer()->AddViewProp(cornerActor[i]);
mResliceViewer[i]->GetRenderer()->AddViewProp(slicerActor[i]);
mResliceViewer[i]->SetColorLevel(300);
mResliceViewer[i]->SetColorWindow(1500);
mResliceViewer[i]->SetInputData(dicomLoader->GetImageData());
mResliceViewer[i]->SetSliceOrientation(i);
mResliceViewer[i]->SetResliceModeToAxisAligned();
}
for (int i = 0; i < 3; ++i) {
mPlaneWidget[i]->RestrictPlaneToVolumeOn();
mPlaneWidget[i]->TextureInterpolateOff();
mPlaneWidget[i]->SetResliceInterpolateToLinear();
mPlaneWidget[i]->SetInputData(dicomLoader->GetImageData());
mPlaneWidget[i]->SetPlaneOrientation(i);
mPlaneWidget[i]->SetSliceIndex(imgDimens[i] / 2);
mPlaneWidget[i]->DisplayTextOff();
mPlaneWidget[i]->SetWindowLevel(1500, 300);
mPlaneWidget[i]->On();
mPlaneWidget[i]->InteractionOn();
}
for (int i = 0; i < 3; ++i) {
// Make them all share the same color map.
mResliceViewer[i]->SetLookupTable(mResliceViewer[0]->GetLookupTable());
mPlaneWidget[i]->GetColorMap()->SetLookupTable(mResliceViewer[0]->GetLookupTable());
mPlaneWidget[i]->SetColorMap(mResliceViewer[i]->GetResliceCursorWidget()
->GetResliceCursorRepresentation()->GetColorMap());
mResliceViewer[i]->GetRenderer()->ResetCamera();
mResliceViewer[i]->SetSlice((imgDimens[i] / 2) );
auto index = std::to_string(mResliceViewer[i]->GetSlice() +1 );
slicerActor[i]->SetText(vtkCornerAnnotation::LowerRight, index.c_str());
callback[i]->SetAnnotation(slicerActor[i]);
mResliceViewer[i]->AddObserver(vtkResliceImageViewer::SliceChangedEvent, callback[i]);
mResliceViewer[i]->GetRenderer()->ResetCamera();
mResliceRenderWin[i]->Render();
}
mPlaneRender->AddViewProp(cornerActor[3]);
mPlaneRender->ResetCamera();
mPlaneRenderWin->Render();
}
Log Info
GetPixelSpacing#: 0.625,0.625,1.25
imagePaiteintOritaint#: -150.2,-160,-212.75
imageOrientationPatient#: 1,0,0,
imageOrientationPatient#: 0,1,0
Begin patientMatrix#
1.000000, 0.000000, 0.000000, -150.200000
0.000000, 1.000000, 0.000000, -160.000000
0.000000, 0.000000, 1.000000, -212.750000
0.000000, 0.000000, 0.000000, 1.000000
#End patientMatrix