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

@@ -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);