Added .ive reading/writing support for osgVolume::Property classes

This commit is contained in:
Robert Osfield
2009-05-06 13:47:08 +00:00
parent 2b09b0dffa
commit 92afb370e8
20 changed files with 773 additions and 72 deletions

View File

@@ -8,6 +8,7 @@ SET(TARGET_SRC
AlphaFunc.cpp
AnimationPathCallback.cpp
AnimationPath.cpp
AnisotropicLighting.cpp
AutoTransform.cpp
AzimElevationSector.cpp
AzimSector.cpp
@@ -16,15 +17,15 @@ SET(TARGET_SRC
BlendEquation.cpp
BlendFunc.cpp
BlinkSequence.cpp
BumpMapping.cpp
Camera.cpp
CameraView.cpp
Cartoon.cpp
ClipNode.cpp
ClipPlane.cpp
ClusterCullingCallback.cpp
ColorMask.cpp
CompositeLayer.cpp
VolumeCompositeLayer.cpp
SwitchLayer.cpp
ConeSector.cpp
ConvexPlanarOccluder.cpp
ConvexPlanarPolygon.cpp
@@ -41,9 +42,11 @@ SET(TARGET_SRC
DrawElementsUByte.cpp
DrawElementsUInt.cpp
DrawElementsUShort.cpp
Effect.cpp
ElevationSector.cpp
EllipsoidModel.cpp
Exception.cpp
FadeText.cpp
Fog.cpp
FragmentProgram.cpp
FrontFace.cpp
@@ -52,12 +55,10 @@ SET(TARGET_SRC
Group.cpp
HeightFieldLayer.cpp
Image.cpp
ImageSequence.cpp
ImageLayer.cpp
VolumeImageLayer.cpp
ImageSequence.cpp
Impostor.cpp
Layer.cpp
VolumeLayer.cpp
Light.cpp
LightModel.cpp
LightPoint.cpp
@@ -66,7 +67,6 @@ SET(TARGET_SRC
LineStipple.cpp
LineWidth.cpp
Locator.cpp
VolumeLocator.cpp
LOD.cpp
Material.cpp
MatrixTransform.cpp
@@ -89,26 +89,26 @@ SET(TARGET_SRC
ProxyNode.cpp
ReaderWriterIVE.cpp
Scissor.cpp
Scribe.cpp
Sequence.cpp
ShadeModel.cpp
Shader.cpp
ShapeAttributeList.cpp
Shape.cpp
ShapeDrawable.cpp
ShapeAttributeList.cpp
SpecularHighlights.cpp
StateSet.cpp
Stencil.cpp
Switch.cpp
SwitchLayer.cpp
TerrainTile.cpp
Volume.cpp
VolumeTile.cpp
TexEnvCombine.cpp
TexEnv.cpp
TexGen.cpp
TexGenNode.cpp
TexMat.cpp
Text.cpp
FadeText.cpp
Text3D.cpp
Text.cpp
Texture1D.cpp
Texture2D.cpp
Texture3D.cpp
@@ -120,17 +120,22 @@ SET(TARGET_SRC
VertexProgram.cpp
Viewport.cpp
VisibilityGroup.cpp
Effect.cpp
AnisotropicLighting.cpp
BumpMapping.cpp
Cartoon.cpp
Scribe.cpp
SpecularHighlights.cpp
VolumeCompositeLayer.cpp
VolumeCompositeProperty.cpp
VolumeSwitchProperty.cpp
VolumeScalarProperty.cpp
VolumePropertyAdjustmentCallback.cpp
Volume.cpp
VolumeImageLayer.cpp
VolumeLayer.cpp
VolumeLocator.cpp
VolumeTile.cpp
)
SET(TARGET_H
AlphaFunc.h
AnimationPathCallback.h
AnimationPath.h
AnisotropicLighting.h
AutoTransform.h
AzimElevationSector.h
AzimSector.h
@@ -138,15 +143,15 @@ SET(TARGET_H
BlendColor.h
BlendFunc.h
BlinkSequence.h
BumpMapping.h
Camera.h
CameraView.h
Cartoon.h
ClipNode.h
ClipPlane.h
ClusterCullingCallback.h
ColorMask.h
VolumeCompositeLayer.h
CompositeLayer.h
SwitchLayer.h
ConeSector.h
ConvexPlanarOccluder.h
ConvexPlanarPolygon.h
@@ -164,9 +169,11 @@ SET(TARGET_H
DrawElementsUByte.h
DrawElementsUInt.h
DrawElementsUShort.h
Effect.h
ElevationSector.h
EllipsoidModel.h
Exception.h
FadeText.h
Fog.h
FragmentProgram.h
FrontFace.h
@@ -175,13 +182,11 @@ SET(TARGET_H
Group.h
HeightFieldLayer.h
Image.h
ImageSequence.h
ImageLayer.h
VolumeImageLayer.h
ImageSequence.h
Impostor.h
IveVersion.h
Layer.h
VolumeLayer.h
Light.h
LightModel.h
LightPoint.h
@@ -190,7 +195,6 @@ SET(TARGET_H
LineStipple.h
LineWidth.h
Locator.h
VolumeLocator.h
LOD.h
Material.h
MatrixTransform.h
@@ -212,26 +216,26 @@ SET(TARGET_H
ProxyNode.h
ReadWrite.h
Scissor.h
Scribe.h
Sequence.h
ShadeModel.h
Shader.h
ShapeAttributeList.h
ShapeDrawable.h
Shape.h
ShapeAttributeList.h
SpecularHighlights.h
StateSet.h
Stencil.h
Switch.h
SwitchLayer.h
TerrainTile.h
Volume.h
VolumeTile.h
TexEnvCombine.h
TexEnv.h
TexGen.h
TexGenNode.h
TexMat.h
Text.h
FadeText.h
Text3D.h
Text.h
Texture1D.h
Texture2D.h
Texture3D.h
@@ -243,12 +247,16 @@ SET(TARGET_H
VertexProgram.h
Viewport.h
VisibilityGroup.h
Effect.h
AnisotropicLighting.h
BumpMapping.h
Cartoon.h
Scribe.h
SpecularHighlights.h
VolumeCompositeLayer.h
VolumeCompositeProperty.h
VolumeSwitchProperty.h
VolumeScalarProperty.h
VolumePropertyAdjustmentCallback.h
Volume.h
VolumeImageLayer.h
VolumeLayer.h
VolumeLocator.h
VolumeTile.h
)
SET(TARGET_ADDED_LIBRARIES osgSim osgFX osgText osgTerrain osgVolume)

View File

@@ -101,6 +101,10 @@
#include "VolumeImageLayer.h"
#include "VolumeCompositeLayer.h"
#include "VolumeLocator.h"
#include "VolumeCompositeProperty.h"
#include "VolumeSwitchProperty.h"
#include "VolumeScalarProperty.h"
#include "VolumeTransferFunctionProperty.h"
#include "Geometry.h"
#include "ShapeDrawable.h"
@@ -1821,6 +1825,32 @@ osgTerrain::Layer* DataInputStream::readLayer()
return layer;
}
osgTerrain::Locator* DataInputStream::readLocator()
{
// Read locator unique ID.
int id = readInt();
if (id<0) return 0;
// See if stateset is already in the list.
LocatorMap::iterator itr= _locatorMap.find(id);
if (itr!=_locatorMap.end()) return itr->second.get();
// Locator is not in list.
// Create a new locator,
osgTerrain::Locator* locator = new osgTerrain::Locator();
// read its properties from stream
((ive::Locator*)(locator))->read(this);
// and add it to the locator map,
_locatorMap[id] = locator;
if (_verboseOutput) std::cout<<"read/writeLocator() ["<<id<<"]"<<std::endl;
return locator;
}
osgVolume::Layer* DataInputStream::readVolumeLayer()
{
// Read node unique ID.
@@ -1860,35 +1890,9 @@ osgVolume::Layer* DataInputStream::readVolumeLayer()
return layer;
}
osgTerrain::Locator* DataInputStream::readLocator()
{
// Read statesets unique ID.
int id = readInt();
if (id<0) return 0;
// See if stateset is already in the list.
LocatorMap::iterator itr= _locatorMap.find(id);
if (itr!=_locatorMap.end()) return itr->second.get();
// Locator is not in list.
// Create a new locator,
osgTerrain::Locator* locator = new osgTerrain::Locator();
// read its properties from stream
((ive::Locator*)(locator))->read(this);
// and add it to the locator map,
_locatorMap[id] = locator;
if (_verboseOutput) std::cout<<"read/writeLocator() ["<<id<<"]"<<std::endl;
return locator;
}
osgVolume::Locator* DataInputStream::readVolumeLocator()
{
// Read statesets unique ID.
// Read locator unique ID.
int id = readInt();
if (id<0) return 0;
@@ -1911,6 +1915,80 @@ osgVolume::Locator* DataInputStream::readVolumeLocator()
return locator;
}
osgVolume::Property* DataInputStream::readVolumeProperty()
{
// Read property unique ID.
int id = readInt();
if (id<0) return 0;
// See if stateset is already in the list.
VolumePropertyMap::iterator itr= _volumePropertyMap.find(id);
if (itr!=_volumePropertyMap.end()) return itr->second.get();
int layerid = peekInt();
osgVolume::Property* property = 0;
if (layerid==IVEVOLUMECOMPOSITEPROPERTY)
{
property = new osgVolume::CompositeProperty;
((ive::VolumeCompositeProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMESWITCHPROPERTY)
{
property = new osgVolume::SwitchProperty;
((ive::VolumeSwitchProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMETRANSFERFUNCTIONPROPERTY)
{
property = new osgVolume::TransferFunctionProperty;
((ive::VolumeTransferFunctionProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMEMAXIMUMINTENSITYPROPERTY)
{
property = new osgVolume::MaximumIntensityProjectionProperty;
readInt();
}
else if (layerid==IVEVOLUMELIGHTINGPROPERTY)
{
property = new osgVolume::LightingProperty;
readInt();
}
else if (layerid==IVEVOLUMEISOSURFACEPROPERTY)
{
property = new osgVolume::IsoSurfaceProperty;
readInt();
((ive::VolumeScalarProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMEALPHAFUNCPROPERTY)
{
property = new osgVolume::AlphaFuncProperty;
readInt();
((ive::VolumeScalarProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMESAMPLEDENSITYPROPERTY)
{
property = new osgVolume::SampleDensityProperty;
readInt();
((ive::VolumeScalarProperty*)(property))->read(this);
}
else if (layerid==IVEVOLUMETRANSPARENCYPROPERTY)
{
property = new osgVolume::TransparencyProperty;
readInt();
((ive::VolumeScalarProperty*)(property))->read(this);
}
else{
throw Exception("Unknown layer identification in DataInputStream::readVolumeProperty()");
}
// and add it to the locator map,
_volumePropertyMap[id] = property;
if (_verboseOutput) std::cout<<"read/writeVolumeProperty() ["<<id<<"]"<<std::endl;
return property;
}
osg::Object* DataInputStream::readObject()
{
int id = readInt();

View File

@@ -106,6 +106,7 @@ public:
osgVolume::Layer* readVolumeLayer();
osgVolume::Locator* readVolumeLocator();
osgVolume::Property* readVolumeProperty();
osg::Object* readObject();
@@ -126,6 +127,7 @@ public:
typedef std::map<int,osg::ref_ptr<osgTerrain::Locator> > LocatorMap;
typedef std::map<int,osg::ref_ptr<osgVolume::Layer> > VolumeLayerMap;
typedef std::map<int,osg::ref_ptr<osgVolume::Locator> > VolumeLocatorMap;
typedef std::map<int,osg::ref_ptr<osgVolume::Property> > VolumePropertyMap;
bool _verboseOutput;
std::istream* _istream;
@@ -153,6 +155,7 @@ private:
LocatorMap _locatorMap;
VolumeLayerMap _volumeLayerMap;
VolumeLocatorMap _volumeLocatorMap;
VolumePropertyMap _volumePropertyMap;
bool _loadExternalReferenceFiles;

View File

@@ -115,6 +115,10 @@
#include "VolumeImageLayer.h"
#include "VolumeCompositeLayer.h"
#include "VolumeLocator.h"
#include "VolumeCompositeProperty.h"
#include "VolumeSwitchProperty.h"
#include "VolumeScalarProperty.h"
#include "VolumeTransferFunctionProperty.h"
#include <osg/Notify>
#include <osg/io_utils>
@@ -1708,6 +1712,84 @@ void DataOutputStream::writeVolumeLocator(const osgVolume::Locator* locator)
}
}
void DataOutputStream::writeVolumeProperty(const osgVolume::Property* property)
{
if (property==0)
{
writeInt(-1);
return;
}
VolumePropertyMap::iterator itr = _volumePropertyMap.find(property);
if (itr!=_volumePropertyMap.end())
{
// Id already exists so just write ID.
writeInt(itr->second);
if (_verboseOutput) std::cout<<"read/writeVolumeLocator() ["<<itr->second<<"]"<<std::endl;
}
else
{
// id doesn't exist so create a new ID and
// register the locator.
int id = _volumePropertyMap.size();
_volumePropertyMap[property] = id;
// write the id.
writeInt(id);
// write the propery
if (dynamic_cast<const osgVolume::SwitchProperty*>(property))
{
((ive::VolumeSwitchProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::CompositeProperty*>(property))
{
((ive::VolumeCompositeProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::TransferFunctionProperty*>(property))
{
((ive::VolumeTransferFunctionProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::MaximumIntensityProjectionProperty*>(property))
{
writeInt(IVEVOLUMEMAXIMUMINTENSITYPROPERTY);
}
else if (dynamic_cast<const osgVolume::LightingProperty*>(property))
{
writeInt(IVEVOLUMELIGHTINGPROPERTY);
}
else if (dynamic_cast<const osgVolume::IsoSurfaceProperty*>(property))
{
writeInt(IVEVOLUMEISOSURFACEPROPERTY);
((ive::VolumeScalarProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::AlphaFuncProperty*>(property))
{
writeInt(IVEVOLUMEALPHAFUNCPROPERTY);
((ive::VolumeScalarProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::SampleDensityProperty*>(property))
{
writeInt(IVEVOLUMESAMPLEDENSITYPROPERTY);
((ive::VolumeScalarProperty*)(property))->write(this);
}
else if (dynamic_cast<const osgVolume::TransparencyProperty*>(property))
{
writeInt(IVEVOLUMETRANSPARENCYPROPERTY);
((ive::VolumeScalarProperty*)(property))->write(this);
}
else
{
throw Exception("Unknown layer in DataOutputStream::writVolumeProperty()");
}
if (_verboseOutput) std::cout<<"read/writeVolumeProperty() ["<<id<<"]"<<std::endl;
}
}
void DataOutputStream::writeObject(const osg::Object* object)
{
const osg::Node* node = dynamic_cast<const osg::Node*>(object);

View File

@@ -106,6 +106,7 @@ public:
void writeVolumeLayer(const osgVolume::Layer* layer);
void writeVolumeLocator(const osgVolume::Locator* locator);
void writeVolumeProperty(const osgVolume::Property* propety);
void writeObject(const osg::Object* object);
@@ -157,6 +158,7 @@ private:
typedef std::map<const osgTerrain::Locator*,int> LocatorMap;
typedef std::map<const osgVolume::Layer*,int> VolumeLayerMap;
typedef std::map<const osgVolume::Locator*,int> VolumeLocatorMap;
typedef std::map<const osgVolume::Property*,int> VolumePropertyMap;
StateSetMap _stateSetMap;
StateAttributeMap _stateAttributeMap;
@@ -169,6 +171,7 @@ private:
LocatorMap _locatorMap;
VolumeLayerMap _volumeLayerMap;
VolumeLocatorMap _volumeLocatorMap;
VolumePropertyMap _volumePropertyMap;
std::string _writeDirectory;
bool _includeExternalReferences;

View File

@@ -47,8 +47,9 @@
#define VERSION_0036 36
#define VERSION_0037 37
#define VERSION_0038 38
#define VERSION_0039 39
#define VERSION VERSION_0038
#define VERSION VERSION_0039
/* The BYTE_SEX tag is used to check the endian
of the IVE file being read in. The IVE format

View File

@@ -19,6 +19,7 @@
#include "StateSet.h"
#include "AnimationPathCallback.h"
#include "ClusterCullingCallback.h"
#include "VolumePropertyAdjustmentCallback.h"
using namespace ive;
@@ -76,6 +77,17 @@ void Node::write(DataOutputStream* out){
}
}
if (out->getVersion() >= VERSION_0039)
{
osgVolume::PropertyAdjustmentCallback* pac = dynamic_cast<osgVolume::PropertyAdjustmentCallback*>(getEventCallback());
out->writeBool(pac!=0);
if(pac)
{
((ive::VolumePropertyAdjustmentCallback*)pac)->write(out);
}
}
if (out->getVersion() >= VERSION_0010)
{
const osg::BoundingSphere& bs = getInitialBound();
@@ -141,7 +153,26 @@ void Node::read(DataInputStream* in){
setCullCallback(ccc);
}
}
if (in->getVersion() >= VERSION_0039)
{
if(in->readBool())
{
int pacID = in->peekInt();
if (pacID==IVEVOLUMEPROPERTYADJUSTMENTCALLBACK)
{
osgVolume::PropertyAdjustmentCallback* pac = new osgVolume::PropertyAdjustmentCallback();
((ive::VolumePropertyAdjustmentCallback*)(pac))->read(in);
setEventCallback(pac);
}
else
{
throw Exception("Unknown event callback identification in Node::read()");
}
}
}
if (in->getVersion() >= VERSION_0010)
{
if (in->readBool())

View File

@@ -141,15 +141,27 @@ namespace ive {
#define IVETERRAIN 0x0020000A
// osgVolume classes
#define IVEVOLUMETILE 0x00300001
#define IVEVOLUMELOCATOR 0x00300002
#define IVEVOLUMELAYER 0x00300003
#define IVEVOLUMEIMAGELAYER 0x00300004
#define IVEVOLUMECOMPOSITELAYER 0x00300005
#define IVEVOLUMETECHNIQUE 0x00300008
#define IVEVOLUMERAYTRACEDTECHNIQUE 0x00300009
#define IVEVOLUMEFIXEDPIPELINETECHNIQUE 0x00300009
#define IVEVOLUME 0x0030000A
#define IVEVOLUMETILE 0x00300001
#define IVEVOLUMELOCATOR 0x00300002
#define IVEVOLUMELAYER 0x00300003
#define IVEVOLUMEIMAGELAYER 0x00300004
#define IVEVOLUMECOMPOSITELAYER 0x00300005
#define IVEVOLUMETECHNIQUE 0x00300008
#define IVEVOLUMERAYTRACEDTECHNIQUE 0x00300009
#define IVEVOLUMEFIXEDPIPELINETECHNIQUE 0x00300009
#define IVEVOLUME 0x0030000A
#define IVEVOLUMEPROPERTY 0x00300010
#define IVEVOLUMECOMPOSITEPROPERTY 0x00300011
#define IVEVOLUMESCALARPROPERTY 0x00300012
#define IVEVOLUMEALPHAFUNCPROPERTY 0x00300013
#define IVEVOLUMEISOSURFACEPROPERTY 0x00300014
#define IVEVOLUMESWITCHPROPERTY 0x00300015
#define IVEVOLUMETRANSFERFUNCTIONPROPERTY 0x00300016
#define IVEVOLUMEMAXIMUMINTENSITYPROPERTY 0x00300017
#define IVEVOLUMELIGHTINGPROPERTY 0x00300018
#define IVEVOLUMESAMPLEDENSITYPROPERTY 0x00300019
#define IVEVOLUMETRANSPARENCYPROPERTY 0x0030001A
#define IVEVOLUMEPROPERTYADJUSTMENTCALLBACK 0x0030001B
// osgFX classes
#define IVEMULTITEXTURECONTROL 0x01000001

View File

@@ -0,0 +1,64 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include "Exception.h"
#include "VolumeCompositeProperty.h"
#include "Object.h"
#include <osgDB/ReadFile>
using namespace ive;
void VolumeCompositeProperty::write(DataOutputStream* out)
{
// Write Layer's identification.
out->writeInt(IVEVOLUMECOMPOSITEPROPERTY);
// If the osg class is inherited by any other class we should also write this to file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->write(out);
else
throw Exception("VolumeCompositeProperty::write(): Could not cast this osgVolume::CompositeProperty to an osg::Object.");
out->writeUInt(getNumProperties());
for(unsigned int i=0; i<getNumProperties(); ++i)
{
out->writeVolumeProperty(getProperty(i));
}
}
void VolumeCompositeProperty::read(DataInputStream* in)
{
// Peek on Layer's identification.
int id = in->peekInt();
if (id != IVEVOLUMECOMPOSITEPROPERTY)
throw Exception("VolumeCompositeProperty::read(): Expected CompositeProperty identification.");
// Read Layer's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->read(in);
else
throw Exception("VolumeCompositeProperty::write(): Could not cast this osgVolume::CompositeProperty to an osg::Object.");
unsigned int numProperties = in->readUInt();
for(unsigned int i=0; i<numProperties; ++i)
{
addProperty(in->readVolumeProperty());
}
}

View File

@@ -0,0 +1,33 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef IVE_VOLUMECOMPOSITEPROPERTY_H
#define IVE_VOLUMECOMPOSITEPROPERTY_H 1
#include <osgVolume/Property>
#include "ReadWrite.h"
namespace ive
{
class VolumeCompositeProperty : public osgVolume::CompositeProperty, public ReadWrite
{
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -36,6 +36,7 @@ void VolumeLayer::write(DataOutputStream* out)
throw Exception("VolumeLayer::write(): Could not cast this osgVolume::Layer to an osg::Object.");
out->writeVolumeLocator(getLocator());
out->writeVolumeProperty(getProperty());
}
void VolumeLayer::read(DataInputStream* in)
@@ -56,6 +57,7 @@ void VolumeLayer::read(DataInputStream* in)
throw Exception("VolumeLayer::read(): Could not cast this osgVolume::Layer to an osg::Object.");
setLocator(in->readVolumeLocator());
setProperty(in->readVolumeProperty());
}

View File

@@ -0,0 +1,33 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef IVE_VOLUMELAYER
#define IVE_VOLUMELAYER 1
#include <osgVolume/Layer>
#include "ReadWrite.h"
namespace ive
{
class VolumeLayer : public osgVolume::Layer, public ReadWrite
{
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -0,0 +1,73 @@
/**********************************************************************
*
* FILE: VolumePropertyAdjustmentCallback.cpp
*
* DESCRIPTION: Read/Write osg::VolumePropertyAdjustmentCallback in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerate
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 25.3.2003
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "VolumePropertyAdjustmentCallback.h"
#include "Object.h"
using namespace ive;
void VolumePropertyAdjustmentCallback::write(DataOutputStream* out)
{
// Write VolumePropertyAdjustmentCallback's identification.
out->writeInt(IVEVOLUMEPROPERTYADJUSTMENTCALLBACK);
// If the osg class is inherited by any other class we should also write this to file.
osg::Object* obj = dynamic_cast<osg::Object*>(this);
if(obj)
{
((ive::Object*)(obj))->write(out);
}
else
throw Exception("VolumePropertyAdjustmentCallback::write(): Could not cast this osg::VolumePropertyAdjustmentCallback to an osg::Object.");
// Write VolumePropertyAdjustmentCallback's properties.
out->writeInt(getKeyEventCyclesForward());
out->writeInt(getKeyEventCyclesBackward());
out->writeInt(getKeyEventActivatesTransparencyAdjustment());
out->writeInt(getKeyEventActivatesSampleAdjustment());
out->writeInt(getKeyEventActivatesAlphaFuncAdjustment());
}
void VolumePropertyAdjustmentCallback::read(DataInputStream* in)
{
// Peek on VolumePropertyAdjustmentCallback's identification.
int id = in->peekInt();
if(id == IVEVOLUMEPROPERTYADJUSTMENTCALLBACK)
{
// Read VolumePropertyAdjustmentCallback's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Object* obj = dynamic_cast<osg::Object*>(this);
if(obj)
{
((ive::Object*)(obj))->read(in);
}
else
throw Exception("VolumePropertyAdjustmentCallback::read(): Could not cast this osg::VolumePropertyAdjustmentCallback to an osg::Object.");
// Read VolumePropertyAdjustmentCallback's properties
setKeyEventCycleForward(in->readInt());
setKeyEventCycleBackward(in->readInt());
setKeyEventActivatesTransparencyAdjustment(in->readInt());
setKeyEventActivatesSampleDensityAdjustment(in->readInt());
setKeyEventActivatesAlphaFuncAdjustment(in->readInt());
}
else
{
throw Exception("VolumePropertyAdjustmentCallback::read(): Expected VolumePropertyAdjustmentCallback identification.");
}
}

View File

@@ -0,0 +1,15 @@
#ifndef IVE_PROPERTYADJUSTMENTCALLBACK_H
#define IVE_PROPERTYADJUSTMENTCALLBACK_H 1
#include <osgVolume/VolumeTile>
#include "ReadWrite.h"
namespace ive{
class VolumePropertyAdjustmentCallback : public osgVolume::PropertyAdjustmentCallback, public ReadWrite {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -0,0 +1,55 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include "Exception.h"
#include "VolumeScalarProperty.h"
#include "Object.h"
#include <osgDB/ReadFile>
using namespace ive;
void VolumeScalarProperty::write(DataOutputStream* out)
{
// Write Layer's identification.
out->writeInt(IVEVOLUMESCALARPROPERTY);
// If the osg class is inherited by any other class we should also write this to file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->write(out);
else
throw Exception("VolumeScalarProperty::write(): Could not cast this osgVolume::ScalarProperty to an osg::Object.");
out->writeFloat(getValue());
}
void VolumeScalarProperty::read(DataInputStream* in)
{
// Peek on Layer's identification.
int id = in->peekInt();
if (id != IVEVOLUMESCALARPROPERTY)
throw Exception("VolumeScalarProperty::read(): Expected CompositeProperty identification.");
// Read Layer's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->read(in);
else
throw Exception("VolumeScalarProperty::write(): Could not cast this osgVolume::ScalarProperty to an osg::Object.");
setValue(in->readFloat());
}

View File

@@ -0,0 +1,33 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef IVE_VOLUMESCALARPROPERTY_H
#define IVE_VOLUMESCALARPROPERTY_H 1
#include <osgVolume/Property>
#include "ReadWrite.h"
namespace ive
{
class VolumeScalarProperty : public osgVolume::ScalarProperty, public ReadWrite
{
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -0,0 +1,55 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include "Exception.h"
#include "VolumeSwitchProperty.h"
#include "VolumeCompositeProperty.h"
#include <osgDB/ReadFile>
using namespace ive;
void VolumeSwitchProperty::write(DataOutputStream* out)
{
// Write Layer's identification.
out->writeInt(IVEVOLUMESWITCHPROPERTY);
// If the osg class is inherited by any other class we should also write this to file.
osgVolume::CompositeProperty* cp = dynamic_cast<osgVolume::CompositeProperty*>(this);
if (cp)
((ive::VolumeCompositeProperty*)(cp))->write(out);
else
throw Exception("VolumeImageLayer::write(): Could not cast this osgVolume::SwitchProperty to an osgVolume::CompositeProperty.");
out->writeUInt(getActiveProperty());
}
void VolumeSwitchProperty::read(DataInputStream* in)
{
// Peek on Layer's identification.
int id = in->peekInt();
if (id != IVEVOLUMESWITCHPROPERTY)
throw Exception("VolumeSwitchProperty::read(): Expected CompositeProperty identification.");
// Read Layer's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osgVolume::CompositeProperty* cp = dynamic_cast<osgVolume::CompositeProperty*>(this);
if (cp)
((ive::VolumeCompositeProperty*)(cp))->read(in);
else
throw Exception("VolumeImageLayer::read(): Could not cast this osgVolume::SwitchProperty to an osgVolume::CompositeProperty.");
setActiveProperty(in->readUInt());
}

View File

@@ -0,0 +1,33 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef IVE_VOLUMESWITCHPROPERTY_H
#define IVE_VOLUMESWITCHPROPERTY_H 1
#include <osgVolume/Property>
#include "ReadWrite.h"
namespace ive
{
class VolumeSwitchProperty : public osgVolume::SwitchProperty, public ReadWrite
{
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -0,0 +1,54 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include "Exception.h"
#include "VolumeTransferFunctionProperty.h"
#include <osgDB/ReadFile>
using namespace ive;
void VolumeTransferFunctionProperty::write(DataOutputStream* out)
{
// Write Layer's identification.
out->writeInt(IVEVOLUMETRANSFERFUNCTIONPROPERTY);
// If the osg class is inherited by any other class we should also write this to file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->write(out);
else
throw Exception("VolumeTransferFunctionProperty::write(): Could not cast this osgVolume::TransferFunctionProperty to an osg::Object.");
// out->writeFloat(getValue());
}
void VolumeTransferFunctionProperty::read(DataInputStream* in)
{
// Peek on Layer's identification.
int id = in->peekInt();
if (id != IVEVOLUMETRANSFERFUNCTIONPROPERTY)
throw Exception("VolumeTransferFunctionProperty::read(): Expected CompositeProperty identification.");
// Read Layer's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Object* object = dynamic_cast<osg::Object*>(this);
if (object)
((ive::Object*)(object))->read(in);
else
throw Exception("VolumeTransferFunctionProperty::write(): Could not cast this osgVolume::TransferFunctionProperty to an osg::Object.");
// setValue(in->readFloat());
}

View File

@@ -0,0 +1,33 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef IVE_VOLUMETRANSHERFUNCTIONRPROPERTY_H
#define IVE_VOLUMETRANSHERFUNCTIONRPROPERTY_H 1
#include <osgVolume/Property>
#include "ReadWrite.h"
namespace ive
{
class VolumeTransferFunctionProperty : public osgVolume::TransferFunctionProperty, public ReadWrite
{
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif