openscenegraph
Volume
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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#ifndef OSGVOLUME
15#define OSGVOLUME 1
16
17#include <osg/Group>
18#include <osg/CoordinateSystemNode>
19
20#include <osgVolume/VolumeTile>
21
22namespace osgVolume {
23
24/** Volume provides a framework for loosely coupling 3d image VolumeTile's with volume algorithms.
25 * This allows VolumeTechnique's to be plugged in at runtime.*/
26class OSGVOLUME_EXPORT Volume : public osg::Group
27{
28 public:
29
30 Volume();
31
32 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
33 Volume(const Volume&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
34
35 META_Node(osgVolume, Volume);
36
37 virtual void traverse(osg::NodeVisitor& nv);
38
39 /** Get the VolumeTile for a given VolumeTileID.*/
40 VolumeTile* getVolumeTile(const TileID& tileID);
41
42 /** Get the const VolumeTile for a given VolumeTileID.*/
43 const VolumeTile* getVolumeTile(const TileID& tileID) const;
44
45
46 /** Set the VolumeTechnique prototype that nested VolumeTile should clone if they haven't already been assigned a volume rendering technique. */
47 void setVolumeTechniquePrototype(VolumeTechnique* volumeTechnique) { _volumeTechnique = volumeTechnique; }
48
49 /** Get the VolumeTechnique prototype. */
50 VolumeTechnique* getVolumeTechniquePrototype() { return _volumeTechnique.get(); }
51
52 /** Get the const VolumeTechnique prototype. */
53 const VolumeTechnique* getVolumeTechniquePrototype() const { return _volumeTechnique.get(); }
54
55
56 protected:
57
58 virtual ~Volume();
59
60 friend class VolumeTile;
61
62 void dirtyRegisteredVolumeTiles();
63
64 void registerVolumeTile(VolumeTile* tile);
65 void unregisterVolumeTile(VolumeTile* tile);
66
67 typedef std::map< TileID, VolumeTile* > VolumeTileMap;
68 typedef std::set< VolumeTile* > VolumeTileSet;
69
70 mutable OpenThreads::Mutex _mutex;
71 VolumeTileSet _volumeTileSet;
72 VolumeTileMap _volumeTileMap;
73
74 osg::ref_ptr<VolumeTechnique> _volumeTechnique;
75};
76
77}
78
79#endif