Fix single file load bug.
This commit is contained in:
@@ -223,7 +223,6 @@ void DICOMDirectoryHelper::readImageProperty(ExtendMedicalImageProperties* prope
|
|||||||
const std::vector<std::string>& files = property->GetFileNames();
|
const std::vector<std::string>& files = property->GetFileNames();
|
||||||
DcmFileFormat file1;
|
DcmFileFormat file1;
|
||||||
// read success!
|
// read success!
|
||||||
std::cout<<files.at(0)<<std::endl;
|
|
||||||
if (file1.loadFile(files.at(0)).good()) {
|
if (file1.loadFile(files.at(0)).good()) {
|
||||||
DcmDataset *dataset = file1.getDataset();
|
DcmDataset *dataset = file1.getDataset();
|
||||||
|
|
||||||
@@ -276,39 +275,48 @@ void DICOMDirectoryHelper::readImageProperty(ExtendMedicalImageProperties* prope
|
|||||||
|
|
||||||
vtkMatrix4x4::Invert(matrix, property->GetWorldToModelMatrix() );
|
vtkMatrix4x4::Invert(matrix, property->GetWorldToModelMatrix() );
|
||||||
matrix = property->GetWorldToModelMatrix();
|
matrix = property->GetWorldToModelMatrix();
|
||||||
DcmFileFormat file2;
|
|
||||||
std::cout<<files.at(1)<<std::endl;
|
|
||||||
|
|
||||||
// read success!
|
if (files.size()>1){
|
||||||
if (file2.loadFile(files.at(1)).good()) {
|
DcmFileFormat file2;
|
||||||
DcmDataset *dataset = file2.getDataset();
|
// read success!
|
||||||
std::string SeriesUID;
|
if (file2.loadFile(files.at(1)).good()) {
|
||||||
dataset->findAndGetOFString(DcmTagKey(0x0020, 0x000e), SeriesUID);
|
DcmDataset *dataset = file2.getDataset();
|
||||||
std::string SeriesDes;
|
std::string SeriesUID;
|
||||||
dataset->findAndGetOFString(DcmTagKey(0x0008, 0x103e), SeriesDes);
|
dataset->findAndGetOFString(DcmTagKey(0x0020, 0x000e), SeriesUID);
|
||||||
long SeriesNumber = 0;
|
std::string SeriesDes;
|
||||||
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0011), SeriesNumber);
|
dataset->findAndGetOFString(DcmTagKey(0x0008, 0x103e), SeriesDes);
|
||||||
long AcquisitionNumber = 0;
|
long SeriesNumber = 0;
|
||||||
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0012), AcquisitionNumber);
|
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0011), SeriesNumber);
|
||||||
long InstanceNumber = 0;
|
long AcquisitionNumber = 0;
|
||||||
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0013), InstanceNumber);
|
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0012), AcquisitionNumber);
|
||||||
double position[3] = {.0, .0, .0};
|
long InstanceNumber = 0;
|
||||||
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[0], 0);
|
dataset->findAndGetSint32(DcmTagKey(0x0020, 0x0013), InstanceNumber);
|
||||||
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[1], 1);
|
double position[3] = {.0, .0, .0};
|
||||||
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[2], 2);
|
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[0], 0);
|
||||||
double position0[3] ={property->GetPosition()[0], property->GetPosition()[1] , property->GetPosition()[2]};
|
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[1], 1);
|
||||||
double zNormal[4] = { position[0] - position0[0],
|
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[2], 2);
|
||||||
position[1] - position0[1],
|
double position0[3] ={property->GetPosition()[0], property->GetPosition()[1] , property->GetPosition()[2]};
|
||||||
position[2] - position0[2], 1.0};
|
double zNormal[4] = { position[0] - position0[0],
|
||||||
double space2 = sqrt(vtkMath::Distance2BetweenPoints(position, property->GetPosition()));
|
position[1] - position0[1],
|
||||||
vtkMath::Normalize(zNormal);
|
position[2] - position0[2], 1.0};
|
||||||
|
double space2 = sqrt(vtkMath::Distance2BetweenPoints(position, property->GetPosition()));
|
||||||
|
vtkMath::Normalize(zNormal);
|
||||||
|
double Spacing[3] = {.0, .0, .0};
|
||||||
|
property->GetSpacing(Spacing);
|
||||||
|
double zNormal2[4] = {.0,.0,.0,1.0};
|
||||||
|
matrix->MultiplyPoint(zNormal, zNormal2);
|
||||||
|
Spacing[2] = zNormal2[2]<0?(-1.0*space2):space2;
|
||||||
|
property->SetSpacing(Spacing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
double Spacing[3] = {.0, .0, .0};
|
double Spacing[3] = {.0, .0, .0};
|
||||||
property->GetSpacing(Spacing);
|
property->GetSpacing(Spacing);
|
||||||
double zNormal2[4] = {.0,.0,.0,1.0};
|
Spacing[2] = 1.0;
|
||||||
matrix->MultiplyPoint(zNormal, zNormal2);
|
|
||||||
Spacing[2] = zNormal2[2]<0?(-1.0*space2):space2;
|
|
||||||
property->SetSpacing(Spacing);
|
property->SetSpacing(Spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user