Hi,
I'm working again on my serializer problem and I don't unterstand why my binary
stream is as long as my ascii stream. binary should be smaller as ascii I
suppose
My Testcode code is:
Code:
// Writing object to stream
std::stringstream myOstream;
std::string extension = "osgb";
bool compressed = true;
osgDB::ReaderWriter* rw =
osgDB::Registry::instance()->getReaderWriterForExtension(extension.c_str());
if ( rw )
{
osgDB::ReaderWriter::WriteResult wr;
if (extension == "osgb")
{
if (compressed)
wr = rw->writeObject( *test, myOstream, new
osgDB::Options("Compressor=zlib") );
else
wr = rw->writeObject( *test, myOstream );
}
if (extension == "osgt")
{
if (compressed)
wr = rw->writeObject( *test, myOstream, new
osgDB::Options("Ascii Compressor=zlib") );
else
wr = rw->writeObject( *test, myOstream, new
osgDB::Options("Ascii") );
}
if (extension == "osgx")
{
if (compressed)
wr = rw->writeObject( *test, myOstream, new
osgDB::Options("XML Compressor=zlib") );
else
wr = rw->writeObject( *test, myOstream, new
osgDB::Options("XML") );
}
if (!wr.success() ) OSG_NOTIFY( osg::WARN ) << "ERROR: Save
failed: " << wr.message() << std::endl;
}
else
OSG_NOTIFY( osg::WARN ) << "error getting readerWriter for
osgt" << std::endl;
// Get size.
stringbuf *pbuf;
pbuf = myOstream.rdbuf();
OSG_NOTIFY( osg::WARN ) << "PBUF Bytes available: " << pbuf->in_avail()
<< std::endl;
OSG_NOTIFY( osg::ALWAYS ) << "STRING Bytes available: " <<
myOstream.str().length() << std::endl;
OSG_NOTIFY( osg::ALWAYS ) << "STRING content: " << myOstream.str() <<
std::endl;
//Reading Stream to node
if ( rw )
{
osgDB::ReaderWriter::ReadResult rr = rw->readObject( myOstream
);
osg::ref_ptr<osgVisual::dataIO_transportContainer> test2 =
dynamic_cast<osgVisual::dataIO_transportContainer*>(rr.takeObject());
if (test2)
{
OSG_NOTIFY( osg::WARN ) << "TEST::FrameID is: " <<
test->getFrameID() << std::endl;
}
else
OSG_NOTIFY( osg::WARN ) << "Error converting stream to
Node" << std::endl;
}
My Question is: What is the real stream size:
The value pbuf->in_avail() or the value myOstream.str().length()?
Because it always differs up to 60 bytes.
My stream sizes ( myOstream.str().length() ) of my object ot transfer are:
xml: 739 bytes
ASCII: 389 bytes
binaryy uncompressed: 353 bytes
binary compressed: 176 bytes
Can anyone give me a hint what the problem in my serializer / stream usage,
that causes my binary stream to be as large as my ascii stream?
Thank you very much!
Cheers,
Torben
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26454#26454
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org