Added optional usage of DCMTK in the dicom plugin

This commit is contained in:
Robert Osfield
2008-09-15 19:59:12 +00:00
parent c7b66322be
commit d07f3d5662
6 changed files with 477 additions and 60 deletions

View File

@@ -437,6 +437,7 @@ osg::Image* createTexture3D(ImageList& imageList, ProcessRow& processRow,
osg::Image* image = itr->get();
GLenum pixelFormat = image->getPixelFormat();
if (pixelFormat==GL_ALPHA ||
pixelFormat==GL_INTENSITY ||
pixelFormat==GL_LUMINANCE ||
pixelFormat==GL_LUMINANCE_ALPHA ||
pixelFormat==GL_RGB ||
@@ -519,6 +520,7 @@ osg::Image* createTexture3D(ImageList& imageList, ProcessRow& processRow,
GLenum pixelFormat = image->getPixelFormat();
if (pixelFormat==GL_ALPHA ||
pixelFormat==GL_LUMINANCE ||
pixelFormat==GL_INTENSITY ||
pixelFormat==GL_LUMINANCE_ALPHA ||
pixelFormat==GL_RGB ||
pixelFormat==GL_RGBA)
@@ -1849,54 +1851,59 @@ int main( int argc, char **argv )
if (!arguments.isOption(pos))
{
std::string filename = arguments[pos];
osgDB::FileType fileType = osgDB::fileType(filename);
if (fileType == osgDB::FILE_NOT_FOUND)
if (osgDB::getLowerCaseFileExtension(filename)=="dicom")
{
filename = osgDB::findDataFile(filename);
fileType = osgDB::fileType(filename);
}
if (fileType == osgDB::DIRECTORY)
{
osgDB::DirectoryContents contents = osgDB::getDirectoryContents(filename);
std::sort(contents.begin(), contents.end());
ImageList imageList;
for(osgDB::DirectoryContents::iterator itr = contents.begin();
itr != contents.end();
++itr)
{
std::string localFile = filename + "/" + *itr;
std::cout<<"contents = "<<localFile<<std::endl;
if (osgDB::fileType(localFile) == osgDB::REGULAR_FILE)
{
// not an option so assume string is a filename.
osg::Image *image = osgDB::readImageFile(localFile);
if(image)
{
imageList.push_back(image);
}
}
}
// pack the textures into a single texture.
ProcessRow processRow;
image_3d = createTexture3D(imageList, processRow, numComponentsDesired, s_maximumTextureSize, t_maximumTextureSize, r_maximumTextureSize, resizeToPowerOfTwo);
}
else if (fileType == osgDB::REGULAR_FILE)
{
// not an option so assume string is a filename.
image_3d = osgDB::readImageFile( filename );
}
else
{
osg::notify(osg::NOTICE)<<"Error: could not find file: "<<filename<<std::endl;
return 1;
}
osgDB::FileType fileType = osgDB::fileType(filename);
if (fileType == osgDB::FILE_NOT_FOUND)
{
filename = osgDB::findDataFile(filename);
fileType = osgDB::fileType(filename);
}
if (fileType == osgDB::DIRECTORY)
{
osgDB::DirectoryContents contents = osgDB::getDirectoryContents(filename);
std::sort(contents.begin(), contents.end());
ImageList imageList;
for(osgDB::DirectoryContents::iterator itr = contents.begin();
itr != contents.end();
++itr)
{
std::string localFile = filename + "/" + *itr;
std::cout<<"contents = "<<localFile<<std::endl;
if (osgDB::fileType(localFile) == osgDB::REGULAR_FILE)
{
// not an option so assume string is a filename.
osg::Image *image = osgDB::readImageFile(localFile);
if(image)
{
imageList.push_back(image);
}
}
}
// pack the textures into a single texture.
ProcessRow processRow;
image_3d = createTexture3D(imageList, processRow, numComponentsDesired, s_maximumTextureSize, t_maximumTextureSize, r_maximumTextureSize, resizeToPowerOfTwo);
}
else if (fileType == osgDB::REGULAR_FILE)
{
// not an option so assume string is a filename.
image_3d = osgDB::readImageFile( filename );
}
else
{
osg::notify(osg::NOTICE)<<"Error: could not find file: "<<filename<<std::endl;
return 1;
}
}
}
}