Volume 2.7 KB

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