root/OpenSceneGraph/trunk/src/osgPlugins/ive/DrawElementsUShort.cpp @ 13041

Revision 13041, 2.4 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

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