~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/ive/CompositeLayer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "CompositeLayer.h"
 
16
#include "Layer.h"
 
17
 
 
18
using namespace ive;
 
19
 
 
20
void CompositeLayer::write(DataOutputStream* out)
 
21
{
 
22
    // Write Layer's identification.
 
23
    out->writeInt(IVECOMPOSITELAYER);
 
24
 
 
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);
 
27
    if  (layer)
 
28
        ((ive::Layer*)(layer))->write(out);
 
29
    else
 
30
        throw Exception("CompositeLayer::write(): Could not cast this osgLayer::CompositeLayer to an osgTerrain::Layer.");
 
31
 
 
32
    LayerHelper helper;
 
33
 
 
34
    out->writeUInt(getNumLayers());
 
35
    for(unsigned int i=0; i<getNumLayers(); ++i)
 
36
    {
 
37
        if(getLayer(i))
 
38
        {
 
39
            out->writeBool(true);
 
40
            helper.writeLayer(out, getLayer(i));
 
41
        }
 
42
        else
 
43
        {
 
44
            out->writeBool(false);
 
45
            out->writeString(getFileName(i));
 
46
        }
 
47
    }
 
48
}
 
49
 
 
50
void CompositeLayer::read(DataInputStream* in)
 
51
{
 
52
    // Peek on Layer's identification.
 
53
    int id = in->peekInt();
 
54
    if (id != IVECOMPOSITELAYER)
 
55
        throw Exception("CompositeLayer::read(): Expected CompositeLayer identification.");
 
56
    
 
57
    // Read Layer's identification.
 
58
    id = in->readInt();
 
59
 
 
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);
 
62
    if (layer)
 
63
        ((ive::Layer*)(layer))->read(in);
 
64
    else
 
65
        throw Exception("CompositeLayer::read(): Could not cast this osgLayer::Layer to an osg::Group.");
 
66
 
 
67
    LayerHelper helper;
 
68
 
 
69
    unsigned int numLayers = in->readUInt();
 
70
    for(unsigned int i=0; i<numLayers; ++i)
 
71
    {
 
72
        bool readInlineLayer = in->readBool();
 
73
        if (readInlineLayer)
 
74
        {
 
75
            addLayer(helper.readLayer(in));
 
76
        }
 
77
        else
 
78
        {
 
79
            addLayer(in->readString());
 
80
        }
 
81
    }
 
82
}