Added verbode debugging option to dataoutputstream and datainputstream to
help invstigation into crash under OSX when reading .ive files.
This commit is contained in:
@@ -48,7 +48,10 @@
|
||||
using namespace ive;
|
||||
using namespace std;
|
||||
|
||||
DataInputStream::DataInputStream(std::istream* istream){
|
||||
DataInputStream::DataInputStream(std::istream* istream)
|
||||
{
|
||||
_verboseOutput = true;
|
||||
|
||||
_istream = istream;
|
||||
_peeking = false;
|
||||
_peekValue = 0;
|
||||
@@ -70,16 +73,24 @@ DataInputStream::~DataInputStream(){}
|
||||
bool DataInputStream::readBool(){
|
||||
char c;
|
||||
_istream->read(&c, CHARSIZE);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readBool(): Failed to read boolean value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBool() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
return c!=0;
|
||||
}
|
||||
|
||||
char DataInputStream::readChar(){
|
||||
char c;
|
||||
_istream->read(&c, CHARSIZE);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readChar(): Failed to read char value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeChar() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -88,6 +99,9 @@ unsigned short DataInputStream::readUShort(){
|
||||
_istream->read((char*)&s, SHORTSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUShort(): Failed to read unsigned short value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -96,6 +110,9 @@ unsigned int DataInputStream::readUInt(){
|
||||
_istream->read((char*)&s, INTSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUInt(): Failed to read unsigned int value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUInt() ["<<s<<"]"<<std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -108,6 +125,9 @@ int DataInputStream::readInt(){
|
||||
_istream->read((char*)&i, INTSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readInt(): Failed to read int value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeInt() ["<<i<<"]"<<std::endl;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -130,6 +150,9 @@ float DataInputStream::readFloat(){
|
||||
_istream->read((char*)&f, FLOATSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readFloat(): Failed to read float value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloat() ["<<f<<"]"<<std::endl;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -138,6 +161,9 @@ long DataInputStream::readLong(){
|
||||
_istream->read((char*)&l, LONGSIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readLong(): Failed to read long value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeLong() ["<<l<<"]"<<std::endl;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -146,6 +172,9 @@ double DataInputStream::readDouble(){
|
||||
_istream->read((char*)&d, DOUBLESIZE);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readDouble(): Failed to read double value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDouble() ["<<d<<"]"<<std::endl;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -156,6 +185,9 @@ std::string DataInputStream::readString(){
|
||||
_istream->read((char*)s.c_str(), size);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readString(): Failed to read string value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeString() ["<<s<<"]"<<std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -163,44 +195,62 @@ void DataInputStream::readCharArray(char* data, int size){
|
||||
_istream->read(data, size);
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readCharArray(): Failed to read char value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeCharArray() ["<<data<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
osg::Vec2 DataInputStream::readVec2(){
|
||||
osg::Vec2 DataInputStream::readVec2()
|
||||
{
|
||||
osg::Vec2 v;
|
||||
v.x()=readFloat();
|
||||
v.x()=readFloat();
|
||||
v.y()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Vec3 DataInputStream::readVec3(){
|
||||
osg::Vec3 v;
|
||||
v.x()=readFloat();
|
||||
v.x()=readFloat();
|
||||
v.y()=readFloat();
|
||||
v.z()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Vec4 DataInputStream::readVec4(){
|
||||
osg::Vec4 v;
|
||||
v.x()=readFloat();
|
||||
v.x()=readFloat();
|
||||
v.y()=readFloat();
|
||||
v.z()=readFloat();
|
||||
v.w()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::UByte4 DataInputStream::readUByte4(){
|
||||
osg::UByte4 v;
|
||||
v.r()=readChar();
|
||||
v.r()=readChar();
|
||||
v.g()=readChar();
|
||||
v.b()=readChar();
|
||||
v.a()=readChar();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByte4() ["<<v<<"]"<<std::endl;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
osg::Quat DataInputStream::readQuat(){
|
||||
osg::Quat q;
|
||||
q.set(readFloat(), readFloat(), readFloat(), readFloat());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -209,6 +259,9 @@ osg::Quat DataInputStream::readQuat(){
|
||||
|
||||
osg::Geometry::AttributeBinding DataInputStream::readBinding(){
|
||||
char c = readChar();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBinding() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
switch((int)c){
|
||||
case 0: return osg::Geometry::BIND_OFF;
|
||||
case 1: return osg::Geometry::BIND_OVERALL;
|
||||
@@ -221,6 +274,7 @@ osg::Geometry::AttributeBinding DataInputStream::readBinding(){
|
||||
|
||||
osg::Array* DataInputStream::readArray(){
|
||||
char c = readChar();
|
||||
|
||||
switch((int)c){
|
||||
case 0: return readIntArray();
|
||||
case 1: return readUByteArray();
|
||||
@@ -240,13 +294,12 @@ osg::IntArray* DataInputStream::readIntArray(){
|
||||
osg::IntArray* a = new osg::IntArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), INTSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readIntArray(): Failed to read Int array.");
|
||||
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back(readInt());
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -255,13 +308,12 @@ osg::UByteArray* DataInputStream::readUByteArray(){
|
||||
osg::UByteArray* a = new osg::UByteArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), CHARSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUByteArray(): Failed to read UByte array.");
|
||||
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back(readChar());
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeUByteArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -270,13 +322,12 @@ osg::UShortArray* DataInputStream::readUShortArray(){
|
||||
osg::UShortArray* a = new osg::UShortArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), SHORTSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUShortArray(): Failed to read UShort array.");
|
||||
//
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back(readUShort());
|
||||
// }
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShortArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -285,13 +336,12 @@ osg::UIntArray* DataInputStream::readUIntArray(){
|
||||
osg::UIntArray* a = new osg::UIntArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), INTSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUIntArray(): Failed to read UInt array.");
|
||||
//
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back((unsigned int)readInt());
|
||||
// }
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -300,13 +350,12 @@ osg::UByte4Array* DataInputStream::readUByte4Array(){
|
||||
osg::UByte4Array* a = new osg::UByte4Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), INTSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readUbyte4Array(): Failed to read UByte4 array.");
|
||||
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back(readUByte4());
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeUByte4Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -315,13 +364,12 @@ osg::FloatArray* DataInputStream::readFloatArray(){
|
||||
osg::FloatArray* a = new osg::FloatArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readFloatArray(): Failed to read float array.");
|
||||
|
||||
// a->reserve(size);
|
||||
// for(int i =0; i<size;i++){
|
||||
// a->push_back(readFloat());
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -330,12 +378,12 @@ osg::Vec2Array* DataInputStream::readVec2Array(){
|
||||
osg::Vec2Array* a = new osg::Vec2Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*2*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec2Array(): Failed to read Vec2 array.");
|
||||
|
||||
// for(int i = 0; i < size; i++){
|
||||
// (*a)[i] = (readVec2());
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -344,12 +392,13 @@ osg::Vec3Array* DataInputStream::readVec3Array(){
|
||||
osg::Vec3Array* a = new osg::Vec3Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*3*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec3Array(): Failed to read Vec3 array.");
|
||||
|
||||
// for(int i = 0; i < size; i++){
|
||||
// (*a)[i] = readVec3();
|
||||
// }
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -358,14 +407,11 @@ osg::Vec4Array* DataInputStream::readVec4Array(){
|
||||
osg::Vec4Array* a = new osg::Vec4Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*4*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec4Array(): Failed to read Vec4 array.");
|
||||
|
||||
|
||||
// for(int i = 0; i < size; i++){
|
||||
// (*a)[i] = (readVec4());
|
||||
// }
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
@@ -384,6 +430,9 @@ osg::Matrix DataInputStream::readMatrix()
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readMatrix(): Failed to read Matrix array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
@@ -401,6 +450,9 @@ osg::Image* DataInputStream::readImage(std::string filename)
|
||||
// add it to the imageList,
|
||||
_imageMap[filename] = image;
|
||||
// and return image pointer.
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeImage() ["<<image<<"]"<<std::endl;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -422,6 +474,9 @@ osg::StateSet* DataInputStream::readStateSet()
|
||||
// and add it to the stateset map,
|
||||
_statesetMap[id] = stateset;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<id<<"]"<<std::endl;
|
||||
|
||||
return stateset;
|
||||
}
|
||||
|
||||
@@ -490,6 +545,9 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
// and add it to the stateattribute map,
|
||||
_stateAttributeMap[id] = attribute;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<id<<"]"<<std::endl;
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@@ -517,6 +575,9 @@ osg::Drawable* DataInputStream::readDrawable()
|
||||
// and add it to the stateattribute map,
|
||||
_drawableMap[id] = drawable;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<id<<"]"<<std::endl;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@@ -597,5 +658,8 @@ osg::Node* DataInputStream::readNode()
|
||||
// and add it to the stateattribute map,
|
||||
_nodeMap[id] = node;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeNode() ["<<id<<"]"<<std::endl;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
typedef std::map<int,osg::ref_ptr<osg::Drawable> > DrawableMap;
|
||||
typedef std::map<int,osg::ref_ptr<osg::Node> > NodeMap;
|
||||
|
||||
bool _verboseOutput;
|
||||
|
||||
private:
|
||||
std::istream* _istream;
|
||||
|
||||
@@ -47,7 +47,9 @@
|
||||
|
||||
using namespace ive;
|
||||
|
||||
DataOutputStream::DataOutputStream(std::ostream * ostream){
|
||||
DataOutputStream::DataOutputStream(std::ostream * ostream)
|
||||
{
|
||||
_verboseOutput = true;
|
||||
|
||||
_includeImageData= true;
|
||||
_ostream = ostream;
|
||||
@@ -60,56 +62,80 @@ DataOutputStream::~DataOutputStream(){}
|
||||
|
||||
void DataOutputStream::writeBool(bool b)
|
||||
{
|
||||
char c = b;
|
||||
char c = b?1:0;
|
||||
_ostream->write(&c, CHARSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBool() ["<<(int)c<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeChar(char c){
|
||||
_ostream->write(&c, CHARSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeChar() ["<<(int)c<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShort(unsigned short s){
|
||||
_ostream->write((char*)&s, SHORTSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUInt(unsigned int s){
|
||||
_ostream->write((char*)&s, INTSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUInt() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeInt(int i){
|
||||
_ostream->write((char*)&i, INTSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeInt() ["<<i<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloat(float f){
|
||||
_ostream->write((char*)&f, FLOATSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloat() ["<<f<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeLong(long l){
|
||||
_ostream->write((char*)&l, LONGSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeLong() ["<<l<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeDouble(double d){
|
||||
_ostream->write((char*)&d, DOUBLESIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDouble() ["<<d<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeString(const std::string& s){
|
||||
writeInt(s.size());
|
||||
_ostream->write(s.c_str(), s.size());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeString() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeCharArray(const char* data, int size){
|
||||
_ostream->write(data, size);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeCharArray() ["<<data<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2(const osg::Vec2& v){
|
||||
writeFloat(v.x());
|
||||
writeFloat(v.y());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec3(const osg::Vec3& v){
|
||||
writeFloat(v.x());
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.z());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec4(const osg::Vec4& v){
|
||||
@@ -117,6 +143,8 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.z());
|
||||
writeFloat(v.w());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByte4(const osg::UByte4& v){
|
||||
@@ -124,6 +152,8 @@ void DataOutputStream::writeUByte4(const osg::UByte4& v){
|
||||
writeChar(v.g());
|
||||
writeChar(v.b());
|
||||
writeChar(v.a());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByte4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeQuat(const osg::Quat& q){
|
||||
@@ -131,6 +161,8 @@ void DataOutputStream::writeQuat(const osg::Quat& q){
|
||||
writeFloat(q.y());
|
||||
writeFloat(q.z());
|
||||
writeFloat(q.w());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
|
||||
@@ -142,6 +174,8 @@ void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
|
||||
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
|
||||
default: throw Exception("Unknown binding in DataOutputStream::writeBinding()");
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBinding() ["<<b<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeArray(const osg::Array* a){
|
||||
@@ -194,6 +228,8 @@ void DataOutputStream::writeIntArray(const osg::IntArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt(a->index(i));
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByteArray(const osg::UByteArray* a)
|
||||
@@ -203,6 +239,8 @@ void DataOutputStream::writeUByteArray(const osg::UByteArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeChar((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByteArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShortArray(const osg::UShortArray* a)
|
||||
@@ -212,6 +250,8 @@ void DataOutputStream::writeUShortArray(const osg::UShortArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeUShort((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShortArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUIntArray(const osg::UIntArray* a)
|
||||
@@ -221,6 +261,8 @@ void DataOutputStream::writeUIntArray(const osg::UIntArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByte4Array(const osg::UByte4Array* a)
|
||||
@@ -230,6 +272,8 @@ void DataOutputStream::writeUByte4Array(const osg::UByte4Array* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeUByte4((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByte4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloatArray(const osg::FloatArray* a)
|
||||
@@ -239,6 +283,8 @@ void DataOutputStream::writeFloatArray(const osg::FloatArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeFloat((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,6 +295,8 @@ void DataOutputStream::writeVec2Array(const osg::Vec2Array* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec2((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec3Array(const osg::Vec3Array* a)
|
||||
@@ -258,6 +306,8 @@ void DataOutputStream::writeVec3Array(const osg::Vec3Array* a)
|
||||
for(int i = 0; i < size; i++){
|
||||
writeVec3((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec4Array(const osg::Vec4Array* a)
|
||||
@@ -267,6 +317,8 @@ void DataOutputStream::writeVec4Array(const osg::Vec4Array* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec4((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeMatrix(const osg::Matrix& mat)
|
||||
@@ -278,6 +330,8 @@ void DataOutputStream::writeMatrix(const osg::Matrix& mat)
|
||||
writeDouble(mat(r,c));
|
||||
}
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -288,6 +342,8 @@ void DataOutputStream::writeStateSet(const osg::StateSet* stateset)
|
||||
{
|
||||
// Id already exists so just write ID.
|
||||
writeInt(itr->second);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<itr->second<<"]"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -302,7 +358,11 @@ void DataOutputStream::writeStateSet(const osg::StateSet* stateset)
|
||||
|
||||
// write the stateset.
|
||||
((ive::StateSet*)(stateset))->write(this);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<id<<"]"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
@@ -312,6 +372,7 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
{
|
||||
// Id already exists so just write ID.
|
||||
writeInt(itr->second);
|
||||
if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<itr->second<<"]"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -370,6 +431,7 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute)
|
||||
std::string className = attribute->className();
|
||||
throw Exception(std::string("StateSet::write(): Unknown StateAttribute: ").append(className));
|
||||
}
|
||||
if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<id<<"]"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,6 +442,8 @@ void DataOutputStream::writeDrawable(const osg::Drawable* drawable)
|
||||
{
|
||||
// Id already exists so just write ID.
|
||||
writeInt(itr->second);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<itr->second<<"]"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -397,6 +461,7 @@ void DataOutputStream::writeDrawable(const osg::Drawable* drawable)
|
||||
else{
|
||||
throw Exception("Unknown drawable in DataOutputStream::writeDrawable()");
|
||||
}
|
||||
if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<id<<"]"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,6 +472,8 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
{
|
||||
// Id already exists so just write ID.
|
||||
writeInt(itr->second);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeNode() ["<<itr->second<<"]"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -466,5 +533,6 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else
|
||||
throw Exception("Unknown node in Group::write()");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeNode() ["<<id<<"]"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
void setIncludeImageData(bool b) {_includeImageData=b;};
|
||||
bool getIncludeImageData() {return _includeImageData;};
|
||||
|
||||
bool _verboseOutput;
|
||||
|
||||
private:
|
||||
std::ostream* _ostream;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user