root/OpenSceneGraph/trunk/src/osgPlugins/ive/PolygonStipple.cpp @ 9961

Revision 9961, 1.9 kB (checked in by robert, 6 years ago)

From Luc Frauciel, You'll find attached a modification in ive plugin for POLYGONSTIPPLE read/write.

Line 
1/**********************************************************************
2 *
3 *    FILE:           PolygonStipple.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::PolygonStipple in binary format to disk.
6 *
7 *    CREATED BY:     Copied from LineStipple
8 *                    and modified by Luc Frauciel
9 *
10 *    HISTORY:        Created 21.3.2009
11 *
12 *    Copyright 2008 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "PolygonStipple.h"
17#include "Object.h"
18
19using namespace ive;
20
21void PolygonStipple::write(DataOutputStream* out){
22    // Write CullFace's identification.
23    out->writeInt(IVEPOLYGONSTIPPLE);
24    // If the osg class is inherited by any other class we should also write this to file.
25    osg::Object* obj = dynamic_cast<osg::Object*>(this);
26    if (obj) {
27        ((ive::Object*)(obj))->write(out);
28    }
29    else
30        throw Exception("PolygonStipple::write(): Could not cast this osg::PolygonStipple to an osg::Object.");
31    // Write PolygonStipple's properties.
32    out->writeUByteArray(new osg::UByteArray(128,const_cast<GLubyte*>(getMask())));
33}
34
35void PolygonStipple::read(DataInputStream* in){
36    // Peek on LineStipple's identification.
37    int id = in->peekInt();
38    if (id == IVEPOLYGONSTIPPLE) {
39        // Read PolygonStipple's identification.
40        id = in->readInt();
41        // If the osg class is inherited by any other class we should also read this from file.
42        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
43        if (obj) {
44            ((ive::Object*)(obj))->read(in);
45        }
46        else
47            throw Exception("PolygonStipple::read(): Could not cast this osg::PolygonStipple to an osg::Object.");
48        // Read PolygonStipple's properties
49        setMask((GLubyte *)in->readUByteArray()->getDataPointer());
50    }
51    else{
52        throw Exception("PolygonStipple::read(): Expected PolygonStipple identification.");
53    }
54}
Note: See TracBrowser for help on using the browser.