Completed support for automatic detection of plugin features.

Cleaned up debug out of various plugins to ensure a clean osgconv --formats.
This commit is contained in:
Robert Osfield
2009-03-10 17:27:39 +00:00
parent 3ec2da76e8
commit a0a06c8b2a
9 changed files with 88 additions and 50 deletions

View File

@@ -63,8 +63,27 @@ void ReaderWriter::supportsOption(const std::string& fmt, const std::string& des
ReaderWriter::Features ReaderWriter::supportedFeatures() const
{
Features features = FEATURE_ALL;
return features;
int features = FEATURE_NONE;
std::string dummyFilename;
if (readObject(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_OBJECT;
if (readImage(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_IMAGE;
if (readHeightField(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_HEIGHT_FIELD;
if (readShader(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_SHADER;
if (readNode(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_NODE;
osg::ref_ptr<osg::Image> image = new osg::Image;
osg::ref_ptr<osg::HeightField> hf = new osg::HeightField;
osg::ref_ptr<osg::Shader> shader = new osg::Shader;
osg::ref_ptr<osg::Node> node = new osg::Node;
if (writeObject(*image, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_OBJECT;
if (writeImage(*image,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_IMAGE;
if (writeHeightField(*hf,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_HEIGHT_FIELD;
if (writeShader(*shader,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_SHADER;
if (writeNode(*node, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_NODE;
return Features(features);
}
ReaderWriter::FeatureList ReaderWriter::featureAsString(ReaderWriter::Features feature)

View File

@@ -429,9 +429,9 @@ class FLTReaderWriter : public ReaderWriter
{
if ( fileName.empty() )
{
osg::notify( osg::FATAL ) << "fltexp: writeNode: empty file name" << std::endl;
return WriteResult::FILE_NOT_HANDLED;
}
std::string ext = osgDB::getLowerCaseFileExtension( fileName );
if ( !acceptsExtension(ext) )
return WriteResult::FILE_NOT_HANDLED;

View File

@@ -58,6 +58,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
if (file.empty()) return ReadResult::FILE_NOT_FOUND;
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"gdal"))
{
return readObject(osgDB::getNameLessExtension(file),options);
@@ -81,6 +83,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal"))
{
return readImage(osgDB::getNameLessExtension(fileName),options);
@@ -92,6 +96,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal"))
{
return readHeightField(osgDB::getNameLessExtension(fileName),options);

View File

@@ -25,7 +25,7 @@ class ReaderWriterUBrowser : public osgDB::ReaderWriter
ReaderWriterUBrowser()
{
osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl;
osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl;
supportsExtension("gecko","browser image");
supportsExtension("browser","browser image");
@@ -41,7 +41,7 @@ class ReaderWriterUBrowser : public osgDB::ReaderWriter
osgWidget::BrowserManager::instance()->setApplication(previousManager->getApplication());
}
osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl;
osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl;
}
virtual ~ReaderWriterUBrowser()

View File

@@ -46,19 +46,22 @@ UBrowserManager::UBrowserManager():
_nativeWindowHandle(0),
_previousButtonMask(0)
{
osg::notify(osg::NOTICE)<<"UBrowserManager::UBrowserManager()"<<std::endl;
osg::notify(osg::INFO)<<"UBrowserManager::UBrowserManager()"<<std::endl;
}
UBrowserManager::~UBrowserManager()
{
_thread->setDone(true);
while(_thread->isRunning())
if (_thread.valid())
{
OpenThreads::Thread::YieldCurrentThread();
}
_thread->setDone(true);
_thread = 0;
while(_thread->isRunning())
{
OpenThreads::Thread::YieldCurrentThread();
}
_thread = 0;
}
}
osgWidget::BrowserImage* UBrowserManager::createBrowserImage(const std::string& url, int width, int height)

View File

@@ -109,7 +109,9 @@ public:
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
osg::notify(osg::NOTICE)<<"OGR::readNode("<<file<<")"<<std::endl;
osg::notify(osg::INFO)<<"OGR::readNode("<<file<<")"<<std::endl;
if (file.empty()) return ReadResult::FILE_NOT_FOUND;
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"ogr"))
{

View File

@@ -84,12 +84,14 @@ private:
class CreateStlVisitor : public osg::NodeVisitor {
public:
CreateStlVisitor( std::string const & fout, const osgDB::ReaderWriter::Options* options = 0): osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ), counter(0), m_fout(fout), m_options(options) {
if (options && (options->getOptionString() == "separateFiles")) {
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;
CreateStlVisitor( std::string const & fout, const osgDB::ReaderWriter::Options* options = 0): osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ), counter(0), m_fout(fout), m_options(options)
{
if (options && (options->getOptionString() == "separateFiles"))
{
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;
} else {
m_f = new std::ofstream(m_fout.c_str());
*m_f << "solid " << counter << std::endl;
m_f = new std::ofstream(m_fout.c_str());
*m_f << "solid " << counter << std::endl;
}
};
@@ -448,16 +450,20 @@ bool ReaderWriterSTL::ReaderObject::readStlBinary(FILE* fp)
return true;
}
osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fout, const Options* opts) const {
std::string ext = osgDB::getLowerCaseFileExtension(fout);
if (ext != "stl" ){
osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fileName, const Options* opts) const
{
if (fileName.empty()) return WriteResult::FILE_NOT_HANDLED;
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
if (ext != "stl" )
{
// sta - extension implies STL-Binary...
osg::notify(osg::FATAL) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl;
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl;
return WriteResult::FILE_NOT_HANDLED;
}
try {
CreateStlVisitor createStlVisitor( fout, opts );
CreateStlVisitor createStlVisitor( fileName, opts );
const_cast<osg::Node&>(node).accept( createStlVisitor );
} catch(...) {
return WriteResult::ERROR_IN_WRITING_FILE;

View File

@@ -30,12 +30,12 @@ osg::ref_ptr<BrowserManager>& BrowserManager::instance()
BrowserManager::BrowserManager()
{
osg::notify(osg::NOTICE)<<"Constructing base BrowserManager"<<std::endl;
osg::notify(osg::INFO)<<"Constructing base BrowserManager"<<std::endl;
}
BrowserManager::~BrowserManager()
{
osg::notify(osg::NOTICE)<<"Destructing base BrowserManager"<<std::endl;
osg::notify(osg::INFO)<<"Destructing base BrowserManager"<<std::endl;
}
void BrowserManager::init(const std::string& application)
@@ -45,7 +45,7 @@ void BrowserManager::init(const std::string& application)
BrowserImage* BrowserManager::createBrowserImage(const std::string& url, int width, int height)
{
osg::notify(osg::NOTICE)<<"Cannot created browser"<<std::endl;
osg::notify(osg::NOTICE)<<"Cannot create browser"<<std::endl;
return 0;
}