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

Revision 13041, 2.8 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:            BlinkSequence.cpp
4 *
5 *    DESCRIPTION:    Read/Write osgSim::BlinkSequence in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerator
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 5.9.2003
11 *
12 **********************************************************************/
13
14#include "Exception.h"
15#include "BlinkSequence.h"
16#include "Object.h"
17
18using namespace ive;
19
20void BlinkSequence::write(DataOutputStream* out){
21    // Write BlinkSequence's identification.
22    out->writeInt(IVEBLINKSEQUENCE);
23    // If the osgSim class is inherited by any other class we should also write this to file.
24    osg::Object*  obj = dynamic_cast<osg::Object*>(this);
25    if(obj){
26        ((ive::Object*)(obj))->write(out);
27    }
28    else
29        out_THROW_EXCEPTION("BlinkSequence::write(): Could not cast this osgSim::BlinkSequence to an osg::Object.");
30
31    // Write BlinkSequence's properties.
32
33    // Write out pulse data.
34    unsigned int size = getNumPulses();
35    out->writeInt(size);
36    for(unsigned int i=0; i<size; i++){
37        double length;
38        osg::Vec4 color;
39        getPulse(i, length, color);
40        out->writeDouble(length);
41        out->writeVec4(color);
42    }
43    // Write out phase shift.
44    out->writeDouble(getPhaseShift());
45    // Write out SequenceGroup.
46    if( getSequenceGroup() )
47        out->writeDouble(getSequenceGroup()->_baseTime);
48    else
49        out->writeDouble( 0.0 );
50
51}
52
53void BlinkSequence::read(DataInputStream* in){
54    // Peek on BlinkSequence's identification.
55    int id = in->peekInt();
56    if(id == IVEBLINKSEQUENCE){
57        // Read BlinkSequence's identification.
58        id = in->readInt();
59        // If the osgSim class is inherited by any other class we should also read this from file.
60        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
61        if(obj){
62            ((ive::Object*)(obj))->read(in);
63        }
64        else
65            in_THROW_EXCEPTION("BlinkSequence::read(): Could not cast this osgSim::BlinkSequence to an osg::Object.");
66        // Read BlinkSequence's properties
67
68        // Read in pulse data.
69        unsigned int size = in->readInt();
70        for(unsigned int i=0; i<size; i++){
71            double length = in->readDouble();
72            osg::Vec4 color = in->readVec4();
73            addPulse(length,color);
74        }
75        // Read in phase shift.
76        setPhaseShift(in->readDouble());
77
78        // Read in SequenceGroup
79        double baseTime = in->readDouble();
80        if (baseTime!=0.0) setSequenceGroup(new osgSim::SequenceGroup(baseTime));
81
82    }
83    else{
84        in_THROW_EXCEPTION("BlinkSequence::read(): Expected BlinkSequence identification.");
85    }
86}
Note: See TracBrowser for help on using the browser.