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

Revision 7648, 2.3 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:            DrawElementsUInt.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::DrawElementsUInt in binary format to disk.
6 *
7 *    CREATED BY:        Copied from DrawElementsUShort.cpp by Marco Jez
8 *                   
9 *
10 *    HISTORY:        Created 20.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "DrawElementsUInt.h"
17#include "PrimitiveSet.h"
18#include <osg/Endian>
19
20using namespace ive;
21
22void DrawElementsUInt::write(DataOutputStream* out){
23    // Write DrawElementsUInt's identification.
24    out->writeInt(IVEDRAWELEMENTSUINT);
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        throw Exception("DrawElementsUInt::write(): Could not cast this osg::DrawElementsUInt to an osg::PrimitiveSet.");
33    // Write DrawElementsUInt's properties.
34
35    // Write array length and its elements.
36    out->writeInt(size());
37    out->writeCharArray((const char*)&front(), size() * INTSIZE);
38}
39
40void DrawElementsUInt::read(DataInputStream* in)
41{
42    // Read DrawElementsUInt's identification.
43    int id = in->peekInt();
44    if(id == IVEDRAWELEMENTSUINT){
45        // Code to read DrawElementsUInt's properties.
46        id = in->readInt();
47        // If the osg class is inherited by any other class we should also read this from file.
48        osg::PrimitiveSet*  prim = dynamic_cast<osg::PrimitiveSet*>(this);
49        if(prim){
50            ((ive::PrimitiveSet*)(prim))->read(in);
51        }
52        else
53            throw Exception("DrawElementsUInt::read(): Could not cast this osg::DrawElementsUInt to an osg::PrimitiveSet.");
54
55        // Read array length and its elements.
56        int size = in->readInt();
57        resize(size);
58        in->readCharArray((char*)&front(), size * INTSIZE);
59
60        if (in->_byteswap)
61        {
62           for (int i = 0 ; i < size ; i++ )
63           {
64                osg::swapBytes4((char*)&((*this)[i])) ;
65           }
66        }       
67    }
68    else{
69        throw Exception("DrawElementsUInt::read(): Expected DrawElementsUInt identification.");
70    }
71}
Note: See TracBrowser for help on using the browser.