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

Revision 13041, 1.9 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 "VolumeScalarProperty.h"
16#include "Object.h"
17
18#include <osgDB/ReadFile>
19
20using namespace ive;
21
22void VolumeScalarProperty::write(DataOutputStream* out)
23{
24    // Write Layer's identification.
25    out->writeInt(IVEVOLUMESCALARPROPERTY);
26
27    // If the osg class is inherited by any other class we should also write this to file.
28    osg::Object* object = dynamic_cast<osg::Object*>(this);
29    if (object)
30        ((ive::Object*)(object))->write(out);
31    else
32        out_THROW_EXCEPTION("VolumeScalarProperty::write(): Could not cast this osgVolume::ScalarProperty to an osg::Object.");
33
34    out->writeFloat(getValue());
35}
36
37void VolumeScalarProperty::read(DataInputStream* in)
38{
39    // Peek on Layer's identification.
40    int id = in->peekInt();
41    if (id != IVEVOLUMESCALARPROPERTY)
42        in_THROW_EXCEPTION("VolumeScalarProperty::read(): Expected CompositeProperty identification.");
43
44    // Read Layer's identification.
45    id = in->readInt();
46
47    // If the osg class is inherited by any other class we should also read this from file.
48    osg::Object* object = dynamic_cast<osg::Object*>(this);
49    if (object)
50        ((ive::Object*)(object))->read(in);
51    else
52        in_THROW_EXCEPTION("VolumeScalarProperty::write(): Could not cast this osgVolume::ScalarProperty to an osg::Object.");
53
54    setValue(in->readFloat());
55}
Note: See TracBrowser for help on using the browser.