#include #include #include #include #include #include #include #include #include #include #include bool TransferFunction1D_readLocalData(osg::Object &obj, osgDB::Input &fr); bool TransferFunction1D_writeLocalData(const osg::Object &obj, osgDB::Output &fw); osgDB::RegisterDotOsgWrapperProxy TransferFunction1D_Proxy ( new osg::TransferFunction1D, "TransferFunction1D", "Object TransferFunction1D", TransferFunction1D_readLocalData, TransferFunction1D_writeLocalData ); bool TransferFunction1D_readLocalData(osg::Object& obj, osgDB::Input &fr) { osg::TransferFunction1D& tf = static_cast(obj); bool itrAdvanced = false; unsigned int numCells; if (fr.read("NumberImageCells ",numCells)) { tf.allocate(numCells); itrAdvanced = true; } if (fr.matchSequence("Colours {")) { int entry = fr[0].getNoNestedBrackets(); fr += 2; float v; osg::Vec4 color; osg::TransferFunction1D::ColorMap colorMap; while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { if (fr.read(v, color.r(), color.g(), color.b(), color.a())) { colorMap[v] = color; } else { ++fr; } } tf.assign(colorMap); itrAdvanced = true; } return itrAdvanced; } bool TransferFunction1D_writeLocalData(const osg::Object& obj, osgDB::Output& fw) { const osg::TransferFunction1D& tf = static_cast(obj); const osg::TransferFunction1D::ColorMap& colorMap = tf.getColorMap(); fw.indent()<<"NumberImageCells "<second; fw.indent()<first<<" "<