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

Revision 13041, 1.9 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/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#include "Exception.h"
15#include "SwitchLayer.h"
16#include "CompositeLayer.h"
17
18using namespace ive;
19
20void SwitchLayer::write(DataOutputStream* out)
21{
22    // Write Layer's identification.
23    out->writeInt(IVESWITCHLAYER);
24
25    // If the osg class is inherited by any other class we should also write this to file.
26    osgTerrain::CompositeLayer*  layer = dynamic_cast<osgTerrain::CompositeLayer*>(this);
27    if  (layer)
28        ((ive::CompositeLayer*)(layer))->write(out);
29    else
30        out_THROW_EXCEPTION("SwitchLayer::write(): Could not cast this osgLayer::SwitchLayer to an osgTerrain::Layer.");
31
32
33    out->writeInt(getActiveLayer());
34}
35
36void SwitchLayer::read(DataInputStream* in)
37{
38    // Peek on Layer's identification.
39    int id = in->peekInt();
40    if (id != IVESWITCHLAYER)
41        in_THROW_EXCEPTION("SwitchLayer::read(): Expected SwitchLayer identification.");
42
43    // Read Layer's identification.
44    id = in->readInt();
45
46    // If the osg class is inherited by any other class we should also read this from file.
47    osgTerrain::CompositeLayer*  layer = dynamic_cast<osgTerrain::CompositeLayer*>(this);
48    if (layer)
49        ((ive::CompositeLayer*)(layer))->read(in);
50    else
51        in_THROW_EXCEPTION("SwitchLayer::read(): Could not cast this osgLayer::Layer to an osg::Group.");
52
53    setActiveLayer(in->readInt());
54}
Note: See TracBrowser for help on using the browser.