1
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
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.
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.
14
#include "Exception.h"
15
#include "CompositeLayer.h"
20
void CompositeLayer::write(DataOutputStream* out)
22
// Write Layer's identification.
23
out->writeInt(IVECOMPOSITELAYER);
25
// If the osg class is inherited by any other class we should also write this to file.
26
osgTerrain::Layer* layer = dynamic_cast<osgTerrain::Layer*>(this);
28
((ive::Layer*)(layer))->write(out);
30
throw Exception("CompositeLayer::write(): Could not cast this osgLayer::CompositeLayer to an osgTerrain::Layer.");
34
out->writeUInt(getNumLayers());
35
for(unsigned int i=0; i<getNumLayers(); ++i)
40
helper.writeLayer(out, getLayer(i));
44
out->writeBool(false);
45
out->writeString(getFileName(i));
50
void CompositeLayer::read(DataInputStream* in)
52
// Peek on Layer's identification.
53
int id = in->peekInt();
54
if (id != IVECOMPOSITELAYER)
55
throw Exception("CompositeLayer::read(): Expected CompositeLayer identification.");
57
// Read Layer's identification.
60
// If the osg class is inherited by any other class we should also read this from file.
61
osgTerrain::Layer* layer = dynamic_cast<osgTerrain::Layer*>(this);
63
((ive::Layer*)(layer))->read(in);
65
throw Exception("CompositeLayer::read(): Could not cast this osgLayer::Layer to an osg::Group.");
69
unsigned int numLayers = in->readUInt();
70
for(unsigned int i=0; i<numLayers; ++i)
72
bool readInlineLayer = in->readBool();
75
addLayer(helper.readLayer(in));
79
addLayer(in->readString());