Introduced osgVolume::Property, CompositePropery and TransferFunctionPropety classes

This commit is contained in:
Robert Osfield
2009-01-14 15:16:29 +00:00
parent c21eef7afb
commit d87ec7cb18
26 changed files with 625 additions and 111 deletions

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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
@@ -14,13 +14,10 @@
#ifndef OSGVOLUME_LAYER
#define OSGVOLUME_LAYER 1
#include <osg/Object>
#include <osg/Image>
#include <osg/Shape>
#include <osg/Array>
#include <osg/TransferFunction>
#include <osgVolume/Locator>
#include <osgVolume/Property>
namespace osgVolume {
@@ -67,15 +64,14 @@ class OSGVOLUME_EXPORT Layer : public osg::Object
virtual const osg::Image* getImage() const { return 0; }
/** Set the optional transfer function that maps the imagery pixels to new colours.
* Transfer function may be implemented on the GPU or via pre-processing step. */
void setTransferFunction(osg::TransferFunction* tf) { _transferFunction = tf; }
/** Set the Property (or Properties via the CompositeProperty) that informs the VolumeTechnique how this layer should be rendered.*/
void setProperty(Property* property) { _property = property; }
/** Get the transfer function.*/
osg::TransferFunction* getTransferFunction() { return _transferFunction.get(); }
/** Get the Property that informs the VolumeTechnique how this layer should be rendered.*/
Property* getProperty() { return _property.get(); }
/** Get the const transfer function.*/
const osg::TransferFunction* getTransferFunction() const { return _transferFunction.get(); }
/** Get the const Property that informs the VolumeTechnique how this layer should be rendered.*/
const Property* getProperty() const { return _property.get(); }
/** increment the modified count."*/
@@ -99,7 +95,7 @@ class OSGVOLUME_EXPORT Layer : public osg::Object
osg::Texture::FilterMode _minFilter;
osg::Texture::FilterMode _magFilter;
osg::ref_ptr<osg::TransferFunction> _transferFunction;
osg::ref_ptr<Property> _property;
};

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -0,0 +1,95 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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 OSGVOLUME_PROPERTY
#define OSGVOLUME_PROPERTY 1
#include <osg/TransferFunction>
#include <osgVolume/Export>
namespace osgVolume {
class OSGVOLUME_EXPORT Property : public osg::Object
{
public:
Property();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
Property(const Property&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, Property);
protected:
virtual ~Property();
};
class OSGVOLUME_EXPORT CompositeProperty : public Property
{
public:
CompositeProperty();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
CompositeProperty(const CompositeProperty& compositeProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, CompositeProperty);
void clear();
typedef std::vector< osg::ref_ptr<Property> > Properties;
void setProperty(unsigned int i, Property* property) { if (i>=_properties.size()) _properties.resize(i+1); _properties[i] = property; }
Property* getProperty(unsigned int i) { return i<_properties.size() ? _properties[i].get() : 0; }
const Property* getProperty(unsigned int i) const { return i<_properties.size() ? _properties[i].get() : 0; }
void addProperty(Property* property) { _properties.push_back(property); }
void removeProperty(unsigned int i) { _properties.erase(_properties.begin()+i); }
unsigned int getNumProperties() const { return _properties.size(); }
protected:
virtual ~CompositeProperty() {}
Properties _properties;
};
class OSGVOLUME_EXPORT TransferFunctionProperty : public Property
{
public:
TransferFunctionProperty(osg::TransferFunction* tf = 0);
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
TransferFunctionProperty(const TransferFunctionProperty& tfProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, TransferFunctionProperty);
protected:
virtual ~TransferFunctionProperty() {}
osg::ref_ptr<osg::TransferFunction> _tf;
};
}
#endif

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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
@@ -115,13 +115,9 @@ class OSGVOLUME_EXPORT VolumeTile : public osg::Group
const Locator* getLocator() const { return _locator.get(); }
void setLayer(unsigned int i, Layer* layer);
Layer* getLayer(unsigned int i) { return i<_layers.size() ? _layers[i].get() : 0; }
const Layer* getImage(unsigned int i) const { return i<_layers.size() ? _layers[i].get() : 0; }
void addLayer(Layer* layer) { if (layer) _layers.push_back(layer); }
unsigned int getNumLayers() { return _layers.size(); }
void setLayer(Layer* layer) { _layer = layer; }
Layer* getLayer() { return _layer.get(); }
const Layer* getImage() const { return _layer.get(); }
/** Set the VolumeTechnique*/
@@ -160,8 +156,7 @@ class OSGVOLUME_EXPORT VolumeTile : public osg::Group
osg::ref_ptr<Locator> _locator;
typedef std::vector< osg::ref_ptr<Layer> > Layers;
Layers _layers;
osg::ref_ptr<Layer> _layer;
};
}