Fix imageData space[2] calc logic.
This commit is contained in:
@@ -282,16 +282,23 @@ void DICOMDirectoryHelper::readImageProperty(ExtendMedicalImageProperties* prope
|
||||
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[1], 1);
|
||||
dataset->findAndGetFloat64(DcmTagKey(0x0020, 0x0032), position[2], 2);
|
||||
double position0[3] ={property->GetPosition()[0], property->GetPosition()[1] , property->GetPosition()[2]};
|
||||
double zNormal[4] = { position[0] - position0[0],
|
||||
position[1] - position0[1],
|
||||
position[2] - position0[2], 1.0};
|
||||
double zVector_real[3] = {
|
||||
position[0] - position0[0],
|
||||
position[1] - position0[1],
|
||||
position[2] - position0[2]
|
||||
};
|
||||
// get slice real distance as space[2]
|
||||
double space2 = sqrt(vtkMath::Distance2BetweenPoints(position, property->GetPosition()));
|
||||
vtkMath::Normalize(zNormal);
|
||||
vtkMath::Normalize(zVector_real);
|
||||
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;
|
||||
double* zVector = property->GetZVector();
|
||||
// if zVector_real is same direction with zVector, the negativeFlag must be true, otherwise will be false.
|
||||
bool negativeFlag = (zVector_real[0] * zVector[0]) < 0
|
||||
|| (zVector_real[1] * zVector[1]) < 0
|
||||
|| (zVector_real[2] * zVector[2]) < 0 ;
|
||||
// the space[2] will decide the z Axis image heap up direction
|
||||
Spacing[2] = negativeFlag?(-1.0*space2):space2;
|
||||
property->SetSpacing(Spacing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user