diff --git a/src/osgPlugins/ive/DrawElementsUByte.cpp b/src/osgPlugins/ive/DrawElementsUByte.cpp new file mode 100644 index 000000000..f52c3ee62 --- /dev/null +++ b/src/osgPlugins/ive/DrawElementsUByte.cpp @@ -0,0 +1,64 @@ +/********************************************************************** + * + * FILE: DrawElementsUByte.cpp + * + * DESCRIPTION: Read/Write osg::DrawElementsUByte in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerated + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 20.3.2003 + * + * Copyright 2003 VR-C + **********************************************************************/ + +#include "Exception.h" +#include "DrawElementsUByte.h" +#include "PrimitiveSet.h" + +using namespace ive; + +void DrawElementsUByte::write(DataOutputStream* out){ + // Write DrawElementsUByte's identification. + out->writeInt(IVEDRAWELEMENTSUBYTE); + + // If the osg class is inherited by any other class we should also write this to file. + osg::PrimitiveSet* prim = dynamic_cast(this); + if(prim){ + ((ive::PrimitiveSet*)(prim))->write(out); + } + else + throw Exception("DrawElementsUByte::write(): Could not cast this osg::DrawElementsUByte to an osg::PrimitiveSet."); + // Write DrawElementsUByte's properties. + + // Write array length and its elements. + out->writeInt(size()); + for(unsigned int i=0; iwriteUChar(((osg::VectorUByte)(*this))[i]); + } +} + +void DrawElementsUByte::read(DataInputStream* in){ + // Read DrawElementsUByte's identification. + int id = in->peekInt(); + if(id == IVEDRAWELEMENTSUBYTE){ + // Code to read DrawElementsUByte's properties. + id = in->readInt(); + // If the osg class is inherited by any other class we should also read this from file. + osg::PrimitiveSet* prim = dynamic_cast(this); + if(prim){ + ((ive::PrimitiveSet*)(prim))->read(in); + } + else + throw Exception("DrawElementsUByte::read(): Could not cast this osg::DrawElementsUByte to an osg::PrimtiveSet."); + + // Read array length and its elements. + int size = in->readInt(); + for(int i=0; ireadUChar()); + } + } + else{ + throw Exception("DrawElementsUByte::read(): Expected DrawElementsUByte identification."); + } +} diff --git a/src/osgPlugins/ive/DrawElementsUByte.h b/src/osgPlugins/ive/DrawElementsUByte.h new file mode 100644 index 000000000..d6e1ebeda --- /dev/null +++ b/src/osgPlugins/ive/DrawElementsUByte.h @@ -0,0 +1,15 @@ +#ifndef IVE_DRAWELEMENTSUBYTE +#define IVE_DRAWELEMENTSUBYTE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class DrawElementsUByte : public osg::DrawElementsUByte, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif