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

Revision 13041, 2.4 kB (checked in by robert, 2 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 "VolumeImageLayer.h"
16#include "VolumeLayer.h"
17
18#include <osgDB/ReadFile>
19
20using namespace ive;
21
22void VolumeImageLayer::write(DataOutputStream* out)
23{
24    // Write Layer's identification.
25    out->writeInt(IVEVOLUMEIMAGELAYER);
26
27    // If the osg class is inherited by any other class we should also write this to file.
28    osgVolume::Layer*  layer = dynamic_cast<osgVolume::Layer*>(this);
29    if  (layer)
30        ((ive::VolumeLayer*)(layer))->write(out);
31    else
32        out_THROW_EXCEPTION("VolumeImageLayer::write(): Could not cast this osgVolume::ImageLayer to an osgVolume::Layer.");
33
34
35    IncludeImageMode imMode = out->getIncludeImageMode(getImage());
36
37    if (getFileName().empty() && imMode==IMAGE_REFERENCE_FILE) imMode = IMAGE_INCLUDE_DATA;
38
39    out->writeChar(imMode);
40    out->writeImage(imMode,getImage());
41
42}
43
44void VolumeImageLayer::read(DataInputStream* in)
45{
46    // Peek on Layer's identification.
47    int id = in->peekInt();
48    if (id != IVEVOLUMEIMAGELAYER)
49        in_THROW_EXCEPTION("VolumeImageLayer::read(): Expected ImageLayer identification.");
50
51    // Read Layer's identification.
52    id = in->readInt();
53
54    // If the osg class is inherited by any other class we should also read this from file.
55    osgVolume::Layer*  layer = dynamic_cast<osgVolume::Layer*>(this);
56    if (layer)
57        ((ive::VolumeLayer*)(layer))->read(in);
58    else
59        in_THROW_EXCEPTION("ImageLayer::read(): Could not cast this osgVolume::Layer to an osg::Group.");
60
61    // Should we read image data from stream
62    IncludeImageMode includeImg = (IncludeImageMode)in->readChar();
63
64    if (includeImg==IMAGE_REFERENCE_FILE)
65    {
66        setFileName(in->readString());
67    }
68    else
69    {
70        setImage(in->readImage(includeImg));
71    }
72}
Note: See TracBrowser for help on using the browser.