root/OpenSceneGraph/trunk/src/osgPlugins/ive/DrawElementsUByte.cpp @ 7648

Revision 7648, 2.1 kB (checked in by robert, 7 years ago)

From Roland Smeenk, "Attached you will find a large set of small typo fixes (mainly in the comments)."

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            DrawElementsUByte.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::DrawElementsUByte 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 "DrawElementsUByte.h"
17#include "PrimitiveSet.h"
18
19using namespace ive;
20
21void DrawElementsUByte::write(DataOutputStream* out){
22    // Write DrawElementsUByte's identification.
23    out->writeInt(IVEDRAWELEMENTSUBYTE);
24
25    // If the osg class is inherited by any other class we should also write this to file.
26    osg::PrimitiveSet*  prim = dynamic_cast<osg::PrimitiveSet*>(this);
27    if(prim){
28        ((ive::PrimitiveSet*)(prim))->write(out);
29    }
30    else
31        throw Exception("DrawElementsUByte::write(): Could not cast this osg::DrawElementsUByte to an osg::PrimitiveSet.");
32    // Write DrawElementsUByte's properties.
33
34    // Write array length and its elements.
35    out->writeInt(size());
36    out->writeCharArray((const char*)&front(), size() * CHARSIZE);
37}
38
39void DrawElementsUByte::read(DataInputStream* in){
40    // Read DrawElementsUByte's identification.
41    int id = in->peekInt();
42    if(id == IVEDRAWELEMENTSUBYTE){
43        // Code to read DrawElementsUByte's properties.
44        id = in->readInt();
45        // If the osg class is inherited by any other class we should also read this from file.
46        osg::PrimitiveSet*  prim = dynamic_cast<osg::PrimitiveSet*>(this);
47        if(prim){
48            ((ive::PrimitiveSet*)(prim))->read(in);
49        }
50        else
51            throw Exception("DrawElementsUByte::read(): Could not cast this osg::DrawElementsUByte to an osg::PrimitiveSet.");
52
53        // Read array length and its elements.
54        int size = in->readInt();
55        resize(size);
56        in->readCharArray((char*)&front(), size * CHARSIZE);
57
58    }
59    else{
60        throw Exception("DrawElementsUByte::read(): Expected DrawElementsUByte identification.");
61    }
62}
Note: See TracBrowser for help on using the browser.