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

Revision 13041, 2.8 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/**********************************************************************
2 *
3 *    FILE:            Image.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Image 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 "ImageSequence.h"
17#include "Object.h"
18
19#include <osg/Notify>
20
21using namespace ive;
22
23void ImageSequence::write(DataOutputStream* out)
24{
25    // Write ImageSequence's identification.
26    out->writeInt(IVEIMAGESEQUENCE);
27    // If the osg class is inherited by any other class we should also write this to file.
28    osg::Object*  obj = dynamic_cast<osg::Object*>(this);
29    if(obj){
30        ((ive::Object*)(obj))->write(out);
31    }
32    else
33        out_THROW_EXCEPTION("ImageSequence::write(): Could not cast this osg::ImageSequence to an osg::Object.");
34    // Write ImageSequence's properties.
35
36
37    out->writeInt(getMode());
38    out->writeDouble(getLength());
39
40    out->writeUInt(getFileNames().size());
41    for(FileNames::iterator itr = getFileNames().begin();
42        itr != getFileNames().end();
43        ++itr)
44    {
45        out->writeString(*itr);
46    }
47
48    if (getFileNames().empty())
49    {
50        out->writeUInt(getImages().size());
51        for(Images::iterator itr = getImages().begin();
52            itr != getImages().end();
53            ++itr)
54        {
55            out->writeImage(itr->get());
56        }
57    }
58
59}
60
61void ImageSequence::read(DataInputStream* in)
62{
63    // Peek ImageSequence's identification.
64    int id = in->peekInt();
65    if(id == IVEIMAGESEQUENCE){
66        // Read ImageSequence's identification.
67        id = in->readInt();
68        // If the osg class is inherited by any other class we should also read this from file.
69        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
70        if(obj){
71            ((ive::Object*)(obj))->read(in);
72        }
73        else
74            in_THROW_EXCEPTION("ImageSequence::read(): Could not cast this osg::ImageSequence to an osg::Object.");
75        // Read ImageSequence's properties.
76
77
78        setMode((osg::ImageSequence::Mode)(in->readInt()));
79        setLength(in->readDouble());
80
81        unsigned int numFileNames = in->readUInt();
82        if (numFileNames>0)
83        {
84            for(unsigned int i=0; i<numFileNames; ++i)
85            {
86                addImageFile(in->readString());
87            }
88        }
89        else
90        {
91            unsigned int numImages = in->readUInt();
92            for(unsigned int i=0; i<numImages; ++i)
93            {
94                addImage(in->readImage());
95            }
96        }
97
98    }
99    else{
100        in_THROW_EXCEPTION("ImageSequence::read(): Expected ImageSequence identification.");
101    }
102}
Note: See TracBrowser for help on using the browser.