root/OpenSceneGraph/trunk/src/osgPlugins/ive/DrawArrayLengths.cpp @ 3525

Revision 3525, 2.3 kB (checked in by robert, 10 years ago)

fixes to tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            DrawArrayLengths.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::DrawArrayLengths 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 20.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "DrawArrayLengths.h"
17#include "PrimitiveSet.h"
18
19using namespace ive;
20
21void 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    else
30        throw Exception("DrawArrayLengths::write(): Could not cast this osg::DrawArrayLengths to an osg::PrimitiveSet.");
31
32    // Write DrawArrayLengths's properties.
33    out->writeInt(getFirst());
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    }
40
41}
42
43void 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        else
55            throw Exception("DrawArrayLengths::read(): Could not cast this osg::DrawArrayLengths to an osg::PrimtiveSet.");
56
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
66    }
67    else{
68        throw Exception("DrawArrayLengths::read(): Expected DrawArrayLengths identification.");
69    }
70}
Note: See TracBrowser for help on using the browser.