1 /**********************************************************************
2  *
3  *    FILE:            DrawArrays.cpp
4  *
5  *    DESCRIPTION:    Read/Write osg::DrawArrays in binary format to disk.
6  *
7  *    CREATED BY:        Auto generated by iveGenerated
8  *                    and later modified by Rune Schmidt Jensen.
9  *
10  *    HISTORY:        Created 18.3.2003
11  *
12  *    Copyright 2003 VR-C
13  **********************************************************************/
14 
15 #include "Exception.h"
16 #include "DrawArrays.h"
17 #include "PrimitiveSet.h"
18 
19 using namespace ive;
20 
write(DataOutputStream * out)21 void DrawArrays::write(DataOutputStream* out){
22     // Write DrawArrays's identification.
23     out->writeInt(IVEDRAWARRAYS);
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         out_THROW_EXCEPTION("DrawArrays::write(): Could not cast this osg::DrawArrays to an osg::PrimitiveSet.");
31 
32 
33     // Write DrawArrays's properties.
34     out->writeInt(getFirst());
35     out->writeInt(getCount());
36 }
37 
read(DataInputStream * in)38 void DrawArrays::read(DataInputStream* in){
39     // Read DrawArrays's identification.
40     int id = in->peekInt();
41     if(id == IVEDRAWARRAYS){
42         // Code to read DrawArrays's properties.
43         id = in->readInt();
44         // If the osg class is inherited by any other class we should also read this from file.
45         osg::PrimitiveSet*  prim = dynamic_cast<osg::PrimitiveSet*>(this);
46         if(prim){
47             ((ive::PrimitiveSet*)(prim))->read(in);
48         }
49         else
50             in_THROW_EXCEPTION("DrawArrays::read(): Could not cast this osg::DrawArrays to an osg::PrimitiveSet.");
51 
52 
53         // Read DrawArrays properties
54         setFirst(in->readInt());
55         setCount(in->readInt());
56     }
57     else{
58         in_THROW_EXCEPTION("DrawArrays::read(): Expected DrawArrays identification.");
59     }
60 }
61