Fix DICOM Spacing 2 sign bug.
This commit is contained in:
@@ -302,7 +302,7 @@ void DICOMHeaderHelper::ArrangeSeriesProperty() {
|
|||||||
//sort every image set with world coordinate position
|
//sort every image set with world coordinate position
|
||||||
std::sort(item.second.begin() + beginOffset, item.second.begin() + splitIndex[j],
|
std::sort(item.second.begin() + beginOffset, item.second.begin() + splitIndex[j],
|
||||||
[](auto v1, auto v2) {
|
[](auto v1, auto v2) {
|
||||||
return v1.image_position > v2.image_position;
|
return v1.image_position < v2.image_position;
|
||||||
});
|
});
|
||||||
auto p = createProperty(item.second, splitIndex[j], beginOffset);
|
auto p = createProperty(item.second, splitIndex[j], beginOffset);
|
||||||
p->SetImageSetNumber(imageSetNumber);
|
p->SetImageSetNumber(imageSetNumber);
|
||||||
@@ -314,12 +314,14 @@ void DICOMHeaderHelper::ArrangeSeriesProperty() {
|
|||||||
//sort the last image set
|
//sort the last image set
|
||||||
std::sort(item.second.begin() + beginOffset, item.second.end(),
|
std::sort(item.second.begin() + beginOffset, item.second.end(),
|
||||||
[](auto v1, auto v2) {
|
[](auto v1, auto v2) {
|
||||||
return v1.image_position > v2.image_position;
|
return v1.image_position < v2.image_position;
|
||||||
});
|
});
|
||||||
auto p = createProperty(item.second, item.second.size(), beginOffset);
|
auto p = createProperty(item.second, item.second.size(), beginOffset);
|
||||||
p->SetImageSetNumber(imageSetNumber);
|
if (p){
|
||||||
p->GenerateUniqueID();
|
p->SetImageSetNumber(imageSetNumber);
|
||||||
if (p)seriesProperties.push_back(p);
|
p->GenerateUniqueID();
|
||||||
|
seriesProperties.push_back(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +431,7 @@ ExtendMedicalImageProperties* DICOMHeaderHelper::createProperty(const std::vecto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property->SetSpacing(header.Spacing[0],header.Spacing[1],-thickness);
|
property->SetSpacing(header.Spacing[0],header.Spacing[1],thickness);
|
||||||
|
|
||||||
// read data allocate reference param
|
// read data allocate reference param
|
||||||
unsigned short bitsAllocated= 1;
|
unsigned short bitsAllocated= 1;
|
||||||
@@ -470,7 +472,6 @@ ExtendMedicalImageProperties* DICOMHeaderHelper::createProperty(const std::vecto
|
|||||||
property->SetRescaleOffset(RescaleOffset);
|
property->SetRescaleOffset(RescaleOffset);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf( " file:%s load error!\r\b", header.FilePath.c_str() );
|
|
||||||
property->Delete();
|
property->Delete();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -478,8 +479,8 @@ ExtendMedicalImageProperties* DICOMHeaderHelper::createProperty(const std::vecto
|
|||||||
// try to use real world slice origin point distance to instead thickness
|
// try to use real world slice origin point distance to instead thickness
|
||||||
const DICOMFileHeader& header2 = headerList[beginOffset+1];
|
const DICOMFileHeader& header2 = headerList[beginOffset+1];
|
||||||
double spacing2 = sqrt(vtkMath::Distance2BetweenPoints(header.Position,header2.Position));
|
double spacing2 = sqrt(vtkMath::Distance2BetweenPoints(header.Position,header2.Position));
|
||||||
if((int)spacing2 != 0){
|
if(spacing2 > .0){
|
||||||
property->SetSpacing(property->GetSpacing()[0],property->GetSpacing()[1],-spacing2);
|
property->SetSpacing(property->GetSpacing()[0],property->GetSpacing()[1],spacing2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return property;
|
return property;
|
||||||
|
|||||||
@@ -235,8 +235,6 @@ void DICOMImageViewer::SetInputData(vtkImageData *in) {
|
|||||||
this->RemoveFusionData();
|
this->RemoveFusionData();
|
||||||
this->ActiveRuler();
|
this->ActiveRuler();
|
||||||
this-> ActiveReferenceLine();
|
this-> ActiveReferenceLine();
|
||||||
double zVec = in->GetSpacing()[2];
|
|
||||||
defaultProjection[2][2] = zVec>0.0?1.0:-1.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DICOMImageViewer::SetInputConnection(vtkAlgorithmOutput *input) {
|
void DICOMImageViewer::SetInputConnection(vtkAlgorithmOutput *input) {
|
||||||
|
|||||||
@@ -297,14 +297,6 @@ 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user