- Timestamp:
- 10/24/04 16:31:18 (9 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ive/DrawArrayLengths.cpp
r1980 r3525 1 1 /********************************************************************** 2 2 * 3 * FILE:DrawArrayLengths.cpp3 * FILE: DrawArrayLengths.cpp 4 4 * 5 * DESCRIPTION:Read/Write osg::DrawArrayLengths in binary format to disk.5 * DESCRIPTION: Read/Write osg::DrawArrayLengths in binary format to disk. 6 6 * 7 * CREATED BY:Auto generated by iveGenerated8 * and later modified by Rune Schmidt Jensen.7 * CREATED BY: Auto generated by iveGenerated 8 * and later modified by Rune Schmidt Jensen. 9 9 * 10 * HISTORY:Created 20.3.200310 * HISTORY: Created 20.3.2003 11 11 * 12 * Copyright 2003 VR-C12 * Copyright 2003 VR-C 13 13 **********************************************************************/ 14 14 … … 20 20 21 21 void DrawArrayLengths::write(DataOutputStream* out){ 22 // Write DrawArrayLengths's identification.23 out->writeInt(IVEDRAWARRAYLENGTHS);24 // If the osg class is inherited by any other class we should also write this to file.25 osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);26 if(prim){27 ((ive::PrimitiveSet*)(prim))->write(out);28 }29 else30 throw Exception("DrawArrayLengths::write(): Could not cast this osg::DrawArrayLengths to an osg::PrimitiveSet.");22 // Write DrawArrayLengths's identification. 23 out->writeInt(IVEDRAWARRAYLENGTHS); 24 // If the osg class is inherited by any other class we should also write this to file. 25 osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this); 26 if(prim){ 27 ((ive::PrimitiveSet*)(prim))->write(out); 28 } 29 else 30 throw Exception("DrawArrayLengths::write(): Could not cast this osg::DrawArrayLengths to an osg::PrimitiveSet."); 31 31 32 // Write DrawArrayLengths's properties.33 out->writeInt(getFirst());32 // Write DrawArrayLengths's properties. 33 out->writeInt(getFirst()); 34 34 35 // Write array length and its elements.36 out->writeInt(size());37 for(unsigned int i=0; i<size(); i++){38 out->writeInt(((osg::VectorSizei)(*this))[i]);39 }35 // Write array length and its elements. 36 out->writeInt(size()); 37 for(unsigned int i=0; i<size(); i++){ 38 out->writeInt(((osg::VectorSizei)(*this))[i]); 39 } 40 40 41 41 } 42 42 43 43 void DrawArrayLengths::read(DataInputStream* in){ 44 // Read DrawArrayLengths's identification.45 int id = in->peekInt();46 if(id == IVEDRAWARRAYLENGTHS){47 // Code to read DrawArrayLengths's properties.48 id = in->readInt();49 // If the osg class is inherited by any other class we should also read this from file.50 osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this);51 if(prim){52 ((ive::PrimitiveSet*)(prim))->read(in);53 }54 else55 throw Exception("DrawArrayLengths::read(): Could not cast this osg::DrawArrayLengths to an osg::PrimtiveSet.");44 // Read DrawArrayLengths's identification. 45 int id = in->peekInt(); 46 if(id == IVEDRAWARRAYLENGTHS){ 47 // Code to read DrawArrayLengths's properties. 48 id = in->readInt(); 49 // If the osg class is inherited by any other class we should also read this from file. 50 osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this); 51 if(prim){ 52 ((ive::PrimitiveSet*)(prim))->read(in); 53 } 54 else 55 throw Exception("DrawArrayLengths::read(): Could not cast this osg::DrawArrayLengths to an osg::PrimtiveSet."); 56 56 57 // Read properties58 setFirst(in->readInt());59 60 // Read array length and its elements.61 int size = in->readInt();62 for(int i=0; i<size; i++){63 push_back(in->readInt());64 }57 // Read properties 58 setFirst(in->readInt()); 59 60 // Read array length and its elements. 61 int size = in->readInt(); 62 for(int i=0; i<size; i++){ 63 push_back(in->readInt()); 64 } 65 65 66 }67 else{68 throw Exception("DrawArrayLengths::read(): Expected DrawArrayLengths identification.");69 }66 } 67 else{ 68 throw Exception("DrawArrayLengths::read(): Expected DrawArrayLengths identification."); 69 } 70 70 }
