// 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 using namespace boost::python; namespace PyOSG { void init_ReadFile(); void init_WriteFile(); void init_Registry(); } using namespace PyOSG; namespace { #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4927) // FIXME #endif std::string extract_string(object x) { std::string s = extract(x); return s; } #if defined(_MSC_VER) #pragma warning(pop) #endif 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); } #if 0 void osgDB_readCommandLine(list & cline) { std::vector 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 osgDB::readCommandLine(cmdline); std::vector::iterator itr = cmdline.begin(); for(;itr!=cmdline.end();++itr) { // now append the nonused options cline.append(*itr); } } #endif osg::Node * readNodeFiles_1(osg::ArgumentParser& parser) { return osgDB::readNodeFiles(parser); } osg::Node * readNodeFiles_2(osg::ArgumentParser& parser, const osgDB::ReaderWriter::Options * options) { return osgDB::readNodeFiles(parser, options); } osg::Node * readNodeFiles_3(list & files) { std::vector cmdline; for (int i=0; i()); def("readImageFile", (osg::Image *(*)(const std::string&)) &osgDB::readImageFile, return_internal_reference<>()); def("readNodeFile", (osg::Node*(*)(const std::string& filename)) &osgDB::readNodeFile, return_internal_reference<>()); def("readNodeFiles", &readNodeFiles_1, return_internal_reference<>()); def("readNodeFiles", &readNodeFiles_2, return_internal_reference<>()); def("readNodeFiles", &readNodeFiles_3, return_internal_reference<>()); def("writeObjectFile", &osgDB_writeObjectFile); def("writeImageFile", &osgDB_writeImageFile); def("writeNodeFile", &osgDB_writeNodeFile); // def("readCommandLine", &osgDB_readCommandLine); def("findDataFile", (std::string (*)(const std::string&,osgDB::CaseSensitivity)) &osgDB::findDataFile); def("findDataFile", &findDataFile_1); #if defined WIN32 osgDB::getLibraryFilePathList().push_back("Bin/osgDB/"); osgDB::getLibraryFilePathList().push_back("DLLs/osgDB/"); #endif } } BOOST_PYTHON_MODULE(osgDB) { PyOSG::init_osgDB(); } #include "module_tail.hpp"