Fixed build warning due to auto_ptr<>

This commit is contained in:
Robert Osfield 2020-01-14 14:57:15 +00:00
parent 2b9c501e18
commit fbe4e1cf2f

View File

@ -845,10 +845,8 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
{ {
FileInfo& fileInfo = ditr->second; FileInfo& fileInfo = ditr->second;
std::auto_ptr<DicomImage> dcmImage(new DicomImage(fileInfo.filename.c_str())); DicomImage dcmImage(fileInfo.filename.c_str());
if (dcmImage.get()) if (dcmImage.getStatus()==EIS_Normal)
{
if (dcmImage->getStatus()==EIS_Normal)
{ {
EP_Representation curr_pixelRep; EP_Representation curr_pixelRep;
@ -858,7 +856,7 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
unsigned int curr_pixelSize; unsigned int curr_pixelSize;
// get the pixel data // get the pixel data
const DiPixel* pixelData = dcmImage->getInterData(); const DiPixel* pixelData = dcmImage.getInterData();
if(!pixelData) if(!pixelData)
{ {
warning()<<"Error: no data in DicomImage object."<<std::endl; warning()<<"Error: no data in DicomImage object."<<std::endl;
@ -870,13 +868,13 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
curr_pixelRep, curr_numPlanes, curr_pixelRep, curr_numPlanes,
curr_dataType, curr_pixelFormat, curr_pixelSize); curr_dataType, curr_pixelFormat, curr_pixelSize);
// dcmImage->getFrameCount() // dcmImage.getFrameCount()
osg::ref_ptr<osg::Image> imageAdapter = new osg::Image; osg::ref_ptr<osg::Image> imageAdapter = new osg::Image;
if (dcmImage->isMonochrome()) if (dcmImage.isMonochrome())
{ {
imageAdapter->setImage(dcmImage->getWidth(), dcmImage->getHeight(), dcmImage->getFrameCount(), imageAdapter->setImage(dcmImage.getWidth(), dcmImage.getHeight(), dcmImage.getFrameCount(),
curr_pixelFormat, curr_pixelFormat,
curr_pixelFormat, curr_pixelFormat,
curr_dataType, curr_dataType,
@ -886,11 +884,11 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
} }
else else
{ {
imageAdapter->allocateImage(dcmImage->getWidth(), dcmImage->getHeight(), dcmImage->getFrameCount(), imageAdapter->allocateImage(dcmImage.getWidth(), dcmImage.getHeight(), dcmImage.getFrameCount(),
curr_pixelFormat, curr_dataType); curr_pixelFormat, curr_dataType);
void* data = imageAdapter->data(0,0,0); void* data = imageAdapter->data(0,0,0);
unsigned long size = dcmImage->createWindowsDIB( data, unsigned long size = dcmImage.createWindowsDIB( data,
imageAdapter->getTotalDataSize(), imageAdapter->getTotalDataSize(),
0, 0,
imageAdapter->getPixelSizeInBits(), imageAdapter->getPixelSizeInBits(),
@ -899,7 +897,7 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
if (size==0) if (size==0)
{ {
info()<<" dcmImage->createWindowsDIB() failed to create required imagery."<<std::endl; info()<<" dcmImage.createWindowsDIB() failed to create required imagery."<<std::endl;
continue; continue;
} }
} }
@ -927,8 +925,8 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
(*matrix)(2,2) = fileInfo.dirZ.z(); (*matrix)(2,2) = fileInfo.dirZ.z();
matrix->preMultScale(osg::Vec3d( matrix->preMultScale(osg::Vec3d(
fileInfo.pixelSize_x * dcmImage->getWidth(), fileInfo.pixelSize_x * dcmImage.getWidth(),
fileInfo.pixelSize_y * dcmImage->getHeight(), fileInfo.pixelSize_y * dcmImage.getHeight(),
averageThickness * totalNumSlices)); averageThickness * totalNumSlices));
(*matrix)(3,0) = fileInfo.position.x(); (*matrix)(3,0) = fileInfo.position.x();
@ -957,7 +955,7 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
image = new osg::Image; image = new osg::Image;
image->setUserData(details.get()); image->setUserData(details.get());
image->setFileName(fileName.c_str()); image->setFileName(fileName.c_str());
image->allocateImage(dcmImage->getWidth(), dcmImage->getHeight(), totalNumSlices, image->allocateImage(dcmImage.getWidth(), dcmImage.getHeight(), totalNumSlices,
pixelFormat, dataType); pixelFormat, dataType);
@ -981,7 +979,7 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
image = new osg::Image; image = new osg::Image;
image->setUserData(previous_image->getUserData()); image->setUserData(previous_image->getUserData());
image->setFileName(fileName.c_str()); image->setFileName(fileName.c_str());
image->allocateImage(dcmImage->getWidth(), dcmImage->getHeight(), totalNumSlices, image->allocateImage(dcmImage.getWidth(), dcmImage.getHeight(), totalNumSlices,
pixelFormat, dataType); pixelFormat, dataType);
osg::copyImage(previous_image.get(), 0,0,0, previous_image->s(), previous_image->t(), imageNum, osg::copyImage(previous_image.get(), 0,0,0, previous_image->s(), previous_image->t(), imageNum,
image.get(), 0, 0, 0, image.get(), 0, 0, 0,
@ -994,14 +992,13 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
image.get(), 0, 0, imageNum, image.get(), 0, 0, imageNum,
false); false);
imageNum += dcmImage->getFrameCount(); imageNum += dcmImage.getFrameCount();
} }
else else
{ {
warning()<<"Error in reading dicom file "<<fileInfo.filename<<", error = "<<DicomImage::getString(dcmImage->getStatus())<<std::endl; warning()<<"Error in reading dicom file "<<fileInfo.filename<<", error = "<<DicomImage::getString(dcmImage.getStatus())<<std::endl;
info()<<" dcmImage->getPhotometricInterpretation()="<<DicomImage::getString(dcmImage->getPhotometricInterpretation())<<std::endl; info()<<" dcmImage.getPhotometricInterpretation()="<<DicomImage::getString(dcmImage.getPhotometricInterpretation())<<std::endl;
info()<<" dcmImage->width="<<dcmImage->getWidth()<<", height="<<dcmImage->getHeight()<<" FrameCount="<< dcmImage->getFrameCount()<<std::endl; info()<<" dcmImage.width="<<dcmImage.getWidth()<<", height="<<dcmImage.getHeight()<<" FrameCount="<< dcmImage.getFrameCount()<<std::endl;
}
} }
} }