// Copyright (C) 2002-2003 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ArgumentParser.hpp" #include "held_ptr.hpp" using namespace boost::python; namespace { std::string extract_string(object x) { return extract(x); } bool osgDB_writeObjectFile(osg::Object * obj, std::string filename) { return osgDB::writeObjectFile(*obj, filename); } bool osgDB_writeImageFile(osg::Image * image, std::string filename) { return osgDB::writeImageFile(*image, filename); } bool osgDB_writeNodeFile(osg::Node * node, std::string filename) { return osgDB::writeNodeFile(*node, filename); } osg::Node * osgDB_readNodeFiles(list & files) { std::vector cmdline; for (int i=0; i cmdline; for (int i=0; i < len(cline); i++) { // eat each commandline option std::string str = extract_string(cline.pop(0)); cmdline.push_back(str); } // cline is empty by now // do the actual read // XXX osgDB::readCommandLine(cmdline); std::vector::iterator itr = cmdline.begin(); for(;itr!=cmdline.end();++itr) { // now append the nonused options cline.append(*itr); } } osg::Node * readNodeFiles_1(PyOSG::ArgumentParser& parser) { return osgDB::readNodeFiles(parser.argumentParser()); } osg::Node * readNodeFiles_2(PyOSG::ArgumentParser& parser, bool useObjectCache) { return osgDB::readNodeFiles(parser.argumentParser(), useObjectCache); } } namespace PyOSG { BOOST_PYTHON_FUNCTION_OVERLOADS(readImageFile_overloads, osgDB::readImageFile, 1, 2); BOOST_PYTHON_FUNCTION_OVERLOADS(readNodeFile_overloads, osgDB::readNodeFile, 1, 2); void init_osgDB() { //def("readObjectFile", &osgDB::readObjectFile, return_internal_reference<>()); def("readImageFile", &osgDB::readImageFile, readImageFile_overloads()[return_internal_reference<>()]); def("readNodeFile", &osgDB::readNodeFile, readNodeFile_overloads()[return_internal_reference<>()]); def("readNodeFiles", &osgDB_readNodeFiles, return_internal_reference<>()); def("readNodeFiles", &readNodeFiles_1, return_internal_reference<>()); def("readNodeFiles", &readNodeFiles_2, return_internal_reference<>()); def("writeObjectFile", &osgDB_writeObjectFile); def("writeImageFile", &osgDB_writeImageFile); def("writeNodeFile", &osgDB_writeNodeFile); def("readCommandLine", &osgDB_readCommandLine); } } BOOST_PYTHON_MODULE(osgDB) { PyOSG::init_osgDB(); } #include "module_tail.hpp"