comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 4956:964bbf5cb365

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Mar 2022 11:48:47 +0100
parents 1610e56cadfb
children 255b02c68908
comparison
equal deleted inserted replaced
4955:1610e56cadfb 4956:964bbf5cb365
1960 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset(); 1960 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset();
1961 1961
1962 Uint16 rows, columns, bitsAllocated, bitPosition; 1962 Uint16 rows, columns, bitsAllocated, bitPosition;
1963 const Sint16* origin = NULL; 1963 const Sint16* origin = NULL;
1964 unsigned long originSize = 0; 1964 unsigned long originSize = 0;
1965 DcmElement* overlay = NULL; 1965 DcmElement* overlayElement = NULL;
1966 Uint8* overlayData = NULL; 1966 Uint8* overlayData = NULL;
1967 1967
1968 if (dataset.findAndGetUint16(DcmTagKey(group, 0x0010), rows).good() && 1968 if (dataset.findAndGetUint16(DcmTagKey(group, 0x0010), rows).good() &&
1969 dataset.findAndGetUint16(DcmTagKey(group, 0x0011), columns).good() && 1969 dataset.findAndGetUint16(DcmTagKey(group, 0x0011), columns).good() &&
1970 dataset.findAndGetSint16Array(DcmTagKey(group, 0x0050), origin, &originSize).good() && 1970 dataset.findAndGetSint16Array(DcmTagKey(group, 0x0050), origin, &originSize).good() &&
1972 originSize == 2 && 1972 originSize == 2 &&
1973 dataset.findAndGetUint16(DcmTagKey(group, 0x0100), bitsAllocated).good() && 1973 dataset.findAndGetUint16(DcmTagKey(group, 0x0100), bitsAllocated).good() &&
1974 bitsAllocated == 1 && 1974 bitsAllocated == 1 &&
1975 dataset.findAndGetUint16(DcmTagKey(group, 0x0102), bitPosition).good() && 1975 dataset.findAndGetUint16(DcmTagKey(group, 0x0102), bitPosition).good() &&
1976 bitPosition == 0 && 1976 bitPosition == 0 &&
1977 dataset.findAndGetElement(DcmTagKey(group, 0x3000), overlay).good() && 1977 dataset.findAndGetElement(DcmTagKey(group, 0x3000), overlayElement).good() &&
1978 overlay != NULL && 1978 overlayElement != NULL &&
1979 overlay->getUint8Array(overlayData).good() && 1979 overlayElement->getUint8Array(overlayData).good() &&
1980 overlayData != NULL) 1980 overlayData != NULL)
1981 { 1981 {
1982 /** 1982 /**
1983 * WARNING - It might seem easier to use 1983 * WARNING - It might seem easier to use
1984 * "dataset.findAndGetUint8Array()" that directly gives the size 1984 * "dataset.findAndGetUint8Array()" that directly gives the size
1990 * The method "getLengthField()" reports the correct number of 1990 * The method "getLengthField()" reports the correct number of
1991 * bytes, even if targeting WebAssembly. 1991 * bytes, even if targeting WebAssembly.
1992 **/ 1992 **/
1993 1993
1994 unsigned int expectedSize = Ceiling(rows * columns, 8); 1994 unsigned int expectedSize = Ceiling(rows * columns, 8);
1995 if (overlay->getLengthField() < expectedSize) 1995 if (overlayElement->getLengthField() < expectedSize)
1996 { 1996 {
1997 throw OrthancException(ErrorCode_CorruptedFile, "Overlay doesn't have a valid number of bits"); 1997 throw OrthancException(ErrorCode_CorruptedFile, "Overlay doesn't have a valid number of bits");
1998 } 1998 }
1999 1999
2000 originX = origin[1]; 2000 originX = origin[1];