From 92afb370e8415bc8fad39ba3442e09fec69f0262 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 6 May 2009 13:47:08 +0000 Subject: [PATCH] Added .ive reading/writing support for osgVolume::Property classes --- src/osgPlugins/ive/CMakeLists.txt | 76 +++++----- src/osgPlugins/ive/DataInputStream.cpp | 132 ++++++++++++++---- src/osgPlugins/ive/DataInputStream.h | 3 + src/osgPlugins/ive/DataOutputStream.cpp | 82 +++++++++++ src/osgPlugins/ive/DataOutputStream.h | 3 + src/osgPlugins/ive/IveVersion.h | 3 +- src/osgPlugins/ive/Node.cpp | 33 ++++- src/osgPlugins/ive/ReadWrite.h | 30 ++-- .../ive/VolumeCompositeProperty.cpp | 64 +++++++++ src/osgPlugins/ive/VolumeCompositeProperty.h | 33 +++++ src/osgPlugins/ive/VolumeLayer.cpp | 2 + src/osgPlugins/ive/VolumeProperty.h | 33 +++++ .../ive/VolumePropertyAdjustmentCallback.cpp | 73 ++++++++++ .../ive/VolumePropertyAdjustmentCallback.h | 15 ++ src/osgPlugins/ive/VolumeScalarProperty.cpp | 55 ++++++++ src/osgPlugins/ive/VolumeScalarProperty.h | 33 +++++ src/osgPlugins/ive/VolumeSwitchProperty.cpp | 55 ++++++++ src/osgPlugins/ive/VolumeSwitchProperty.h | 33 +++++ .../ive/VolumeTransferFunctionProperty.cpp | 54 +++++++ .../ive/VolumeTransferFunctionProperty.h | 33 +++++ 20 files changed, 773 insertions(+), 72 deletions(-) create mode 100644 src/osgPlugins/ive/VolumeCompositeProperty.cpp create mode 100644 src/osgPlugins/ive/VolumeCompositeProperty.h create mode 100644 src/osgPlugins/ive/VolumeProperty.h create mode 100644 src/osgPlugins/ive/VolumePropertyAdjustmentCallback.cpp create mode 100644 src/osgPlugins/ive/VolumePropertyAdjustmentCallback.h create mode 100644 src/osgPlugins/ive/VolumeScalarProperty.cpp create mode 100644 src/osgPlugins/ive/VolumeScalarProperty.h create mode 100644 src/osgPlugins/ive/VolumeSwitchProperty.cpp create mode 100644 src/osgPlugins/ive/VolumeSwitchProperty.h create mode 100644 src/osgPlugins/ive/VolumeTransferFunctionProperty.cpp create mode 100644 src/osgPlugins/ive/VolumeTransferFunctionProperty.h diff --git a/src/osgPlugins/ive/CMakeLists.txt b/src/osgPlugins/ive/CMakeLists.txt index d7bbe3674..cd173b48b 100644 --- a/src/osgPlugins/ive/CMakeLists.txt +++ b/src/osgPlugins/ive/CMakeLists.txt @@ -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) diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 8fa82050d..79590a5ca 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -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() ["<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() ["<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() ["< > LocatorMap; typedef std::map > VolumeLayerMap; typedef std::map > VolumeLocatorMap; + typedef std::map > VolumePropertyMap; bool _verboseOutput; std::istream* _istream; @@ -153,6 +155,7 @@ private: LocatorMap _locatorMap; VolumeLayerMap _volumeLayerMap; VolumeLocatorMap _volumeLocatorMap; + VolumePropertyMap _volumePropertyMap; bool _loadExternalReferenceFiles; diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 4c0522eee..06ce0f3e9 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -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 #include @@ -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() ["<second<<"]"<(property)) + { + ((ive::VolumeSwitchProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + ((ive::VolumeCompositeProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + ((ive::VolumeTransferFunctionProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMEMAXIMUMINTENSITYPROPERTY); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMELIGHTINGPROPERTY); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMEISOSURFACEPROPERTY); + ((ive::VolumeScalarProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMEALPHAFUNCPROPERTY); + ((ive::VolumeScalarProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMESAMPLEDENSITYPROPERTY); + ((ive::VolumeScalarProperty*)(property))->write(this); + } + else if (dynamic_cast(property)) + { + writeInt(IVEVOLUMETRANSPARENCYPROPERTY); + ((ive::VolumeScalarProperty*)(property))->write(this); + } + else + { + throw Exception("Unknown layer in DataOutputStream::writVolumeProperty()"); + } + + if (_verboseOutput) std::cout<<"read/writeVolumeProperty() ["<(object); diff --git a/src/osgPlugins/ive/DataOutputStream.h b/src/osgPlugins/ive/DataOutputStream.h index a10265382..ccc12c876 100644 --- a/src/osgPlugins/ive/DataOutputStream.h +++ b/src/osgPlugins/ive/DataOutputStream.h @@ -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 LocatorMap; typedef std::map VolumeLayerMap; typedef std::map VolumeLocatorMap; + typedef std::map VolumePropertyMap; StateSetMap _stateSetMap; StateAttributeMap _stateAttributeMap; @@ -169,6 +171,7 @@ private: LocatorMap _locatorMap; VolumeLayerMap _volumeLayerMap; VolumeLocatorMap _volumeLocatorMap; + VolumePropertyMap _volumePropertyMap; std::string _writeDirectory; bool _includeExternalReferences; diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 0b3b73ec1..454390c42 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -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 diff --git a/src/osgPlugins/ive/Node.cpp b/src/osgPlugins/ive/Node.cpp index 4425d2b6e..6b209d796 100644 --- a/src/osgPlugins/ive/Node.cpp +++ b/src/osgPlugins/ive/Node.cpp @@ -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(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()) diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index 87cdc153d..8c425a211 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -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 diff --git a/src/osgPlugins/ive/VolumeCompositeProperty.cpp b/src/osgPlugins/ive/VolumeCompositeProperty.cpp new file mode 100644 index 000000000..f742b86be --- /dev/null +++ b/src/osgPlugins/ive/VolumeCompositeProperty.cpp @@ -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 + +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(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; iwriteVolumeProperty(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(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; ireadVolumeProperty()); + } +} diff --git a/src/osgPlugins/ive/VolumeCompositeProperty.h b/src/osgPlugins/ive/VolumeCompositeProperty.h new file mode 100644 index 000000000..8bc6ddbbb --- /dev/null +++ b/src/osgPlugins/ive/VolumeCompositeProperty.h @@ -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 + +#include "ReadWrite.h" + +namespace ive +{ + +class VolumeCompositeProperty : public osgVolume::CompositeProperty, public ReadWrite +{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; + +} + +#endif diff --git a/src/osgPlugins/ive/VolumeLayer.cpp b/src/osgPlugins/ive/VolumeLayer.cpp index 9d0540b0c..66e3999b7 100644 --- a/src/osgPlugins/ive/VolumeLayer.cpp +++ b/src/osgPlugins/ive/VolumeLayer.cpp @@ -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()); } diff --git a/src/osgPlugins/ive/VolumeProperty.h b/src/osgPlugins/ive/VolumeProperty.h new file mode 100644 index 000000000..e8db0b8cc --- /dev/null +++ b/src/osgPlugins/ive/VolumeProperty.h @@ -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 +#include "ReadWrite.h" + +namespace ive +{ + +class VolumeLayer : public osgVolume::Layer, public ReadWrite +{ + public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; + + +} + +#endif diff --git a/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.cpp b/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.cpp new file mode 100644 index 000000000..5e2697471 --- /dev/null +++ b/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.cpp @@ -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(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(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."); + } +} diff --git a/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.h b/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.h new file mode 100644 index 000000000..f3c839b18 --- /dev/null +++ b/src/osgPlugins/ive/VolumePropertyAdjustmentCallback.h @@ -0,0 +1,15 @@ +#ifndef IVE_PROPERTYADJUSTMENTCALLBACK_H +#define IVE_PROPERTYADJUSTMENTCALLBACK_H 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class VolumePropertyAdjustmentCallback : public osgVolume::PropertyAdjustmentCallback, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/VolumeScalarProperty.cpp b/src/osgPlugins/ive/VolumeScalarProperty.cpp new file mode 100644 index 000000000..ad8b5b0ef --- /dev/null +++ b/src/osgPlugins/ive/VolumeScalarProperty.cpp @@ -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 + +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(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(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()); +} diff --git a/src/osgPlugins/ive/VolumeScalarProperty.h b/src/osgPlugins/ive/VolumeScalarProperty.h new file mode 100644 index 000000000..75394b9d9 --- /dev/null +++ b/src/osgPlugins/ive/VolumeScalarProperty.h @@ -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 + +#include "ReadWrite.h" + +namespace ive +{ + +class VolumeScalarProperty : public osgVolume::ScalarProperty, public ReadWrite +{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; + +} + +#endif diff --git a/src/osgPlugins/ive/VolumeSwitchProperty.cpp b/src/osgPlugins/ive/VolumeSwitchProperty.cpp new file mode 100644 index 000000000..8d789612e --- /dev/null +++ b/src/osgPlugins/ive/VolumeSwitchProperty.cpp @@ -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 + +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(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(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()); +} diff --git a/src/osgPlugins/ive/VolumeSwitchProperty.h b/src/osgPlugins/ive/VolumeSwitchProperty.h new file mode 100644 index 000000000..043a2e441 --- /dev/null +++ b/src/osgPlugins/ive/VolumeSwitchProperty.h @@ -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 + +#include "ReadWrite.h" + +namespace ive +{ + +class VolumeSwitchProperty : public osgVolume::SwitchProperty, public ReadWrite +{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; + +} + +#endif diff --git a/src/osgPlugins/ive/VolumeTransferFunctionProperty.cpp b/src/osgPlugins/ive/VolumeTransferFunctionProperty.cpp new file mode 100644 index 000000000..590fc7ed9 --- /dev/null +++ b/src/osgPlugins/ive/VolumeTransferFunctionProperty.cpp @@ -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 + +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(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(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()); +} diff --git a/src/osgPlugins/ive/VolumeTransferFunctionProperty.h b/src/osgPlugins/ive/VolumeTransferFunctionProperty.h new file mode 100644 index 000000000..073d6731a --- /dev/null +++ b/src/osgPlugins/ive/VolumeTransferFunctionProperty.h @@ -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 + +#include "ReadWrite.h" + +namespace ive +{ + +class VolumeTransferFunctionProperty : public osgVolume::TransferFunctionProperty, public ReadWrite +{ +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; + +} + +#endif