~saiarcot895/ubuntu/trusty/openscenegraph/armhf-support

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgVolume/Volume.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Dachary (OuoU)
  • Date: 2009-03-23 14:08:20 UTC
  • mfrom: (1.1.7 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090323140820-i4j3jozdlhyn4lre
rules prevent lib64 with -D LIB_POSTFIX="" (Closes: #517671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include <osgVolume/Volume>
 
15
#include <OpenThreads/ScopedLock>
 
16
 
 
17
using namespace osgVolume;
 
18
 
 
19
Volume::Volume()
 
20
{
 
21
}
 
22
 
 
23
Volume::Volume(const Volume& ts, const osg::CopyOp& copyop):
 
24
    osg::Group(ts,copyop)
 
25
{
 
26
}
 
27
 
 
28
 
 
29
Volume::~Volume()
 
30
{
 
31
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
32
 
 
33
    for(VolumeTileSet::iterator itr = _volumeTileSet.begin();
 
34
        itr != _volumeTileSet.end();
 
35
        ++itr)
 
36
    {
 
37
        const_cast<VolumeTile*>(*itr)->_volume = 0;
 
38
    }
 
39
    
 
40
    _volumeTileSet.clear();
 
41
    _volumeTileMap.clear();
 
42
}
 
43
 
 
44
void Volume::traverse(osg::NodeVisitor& nv)
 
45
{
 
46
    Group::traverse(nv);
 
47
}
 
48
 
 
49
VolumeTile* Volume::getVolumeTile(const TileID& tileID)
 
50
{
 
51
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
52
 
 
53
    VolumeTileMap::iterator itr = _volumeTileMap.find(tileID);
 
54
    if (itr != _volumeTileMap.end()) return 0;
 
55
    
 
56
    return itr->second;
 
57
}
 
58
 
 
59
const VolumeTile* Volume::getVolumeTile(const TileID& tileID) const
 
60
{
 
61
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
62
 
 
63
    VolumeTileMap::const_iterator itr = _volumeTileMap.find(tileID);
 
64
    if (itr != _volumeTileMap.end()) return 0;
 
65
    
 
66
    return itr->second;
 
67
}
 
68
 
 
69
void Volume::dirtyRegisteredVolumeTiles()
 
70
{
 
71
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
72
 
 
73
    for(VolumeTileSet::iterator itr = _volumeTileSet.begin();
 
74
        itr != _volumeTileSet.end();
 
75
        ++itr)
 
76
    {
 
77
        (const_cast<VolumeTile*>(*itr))->setDirty(true);
 
78
    }
 
79
}
 
80
 
 
81
static unsigned int s_maxNumVolumeTiles = 0;
 
82
void Volume::registerVolumeTile(VolumeTile* volumeTile)
 
83
{
 
84
    if (!volumeTile) return;
 
85
 
 
86
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
87
    
 
88
    if (volumeTile->getTileID().valid())
 
89
    {
 
90
        _volumeTileMap[volumeTile->getTileID()] = volumeTile;
 
91
    }
 
92
    
 
93
    _volumeTileSet.insert(volumeTile);
 
94
 
 
95
    if (_volumeTileSet.size() > s_maxNumVolumeTiles) s_maxNumVolumeTiles = _volumeTileSet.size();
 
96
 
 
97
    // osg::notify(osg::NOTICE)<<"Volume::registerVolumeTile "<<volumeTile<<" total number of VolumeTile "<<_volumeTileSet.size()<<" max = "<<s_maxNumVolumeTiles<<std::endl;
 
98
}
 
99
 
 
100
void Volume::unregisterVolumeTile(VolumeTile* volumeTile)
 
101
{
 
102
    if (!volumeTile) return;
 
103
 
 
104
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
 
105
 
 
106
    if (volumeTile->getTileID().valid())
 
107
    {
 
108
        _volumeTileMap.erase(volumeTile->getTileID());
 
109
    }
 
110
    
 
111
    _volumeTileSet.erase(volumeTile);
 
112
 
 
113
    // osg::notify(osg::NOTICE)<<"Volume::unregisterVolumeTile "<<volumeTile<<" total number of VolumeTile "<<_volumeTileSet.size()<<" max = "<<s_maxNumVolumeTiles<<std::endl;
 
114
}