OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LineOfSight.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 OSGSIM_LINEOFSIGHT
15 #define OSGSIM_LINEOFSIGHT 1
16 
17 #include <osgUtil/IntersectionVisitor>
18 
19 #include <osgSim/Export>
20 
21 namespace osgSim {
22 
24 {
25  public:
27 
28  void setMaximumNumOfFilesToCache(unsigned int maxNumFilesToCache) { _maxNumFilesToCache = maxNumFilesToCache; }
29  unsigned int getMaximumNumOfFilesToCache() const { return _maxNumFilesToCache; }
30 
31  void clearDatabaseCache();
32 
33  void pruneUnusedDatabaseCache();
34 
35  virtual osg::Node* readNodeFile(const std::string& filename);
36 
37  protected:
38 
39  typedef std::map<std::string, osg::ref_ptr<osg::Node> > FileNameSceneMap;
40 
41  unsigned int _maxNumFilesToCache;
43  FileNameSceneMap _filenameSceneMap;
44 };
45 
55 {
56  public :
57 
58  LineOfSight();
59 
61  void clear();
62 
64  unsigned int addLOS(const osg::Vec3d& start, const osg::Vec3d& end);
65 
67  unsigned int getNumLOS() const { return _LOSList.size(); }
68 
70  void setStartPoint(unsigned int i, const osg::Vec3d& start) { _LOSList[i]._start = start; }
71 
73  const osg::Vec3d& getStartPoint(unsigned int i) const { return _LOSList[i]._start; }
74 
76  void setEndPoint(unsigned int i, const osg::Vec3d& end) { _LOSList[i]._end = end; }
77 
79  const osg::Vec3d& getEndPoint(unsigned int i) const { return _LOSList[i]._end; }
80 
81  typedef std::vector<osg::Vec3d> Intersections;
82 
84  const Intersections& getIntersections(unsigned int i) const { return _LOSList[i]._intersections; }
85 
88  void computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask=0xffffffff);
89 
91  static Intersections computeIntersections(osg::Node* scene, const osg::Vec3d& start, const osg::Vec3d& end, osg::Node::NodeMask traversalMask=0xffffffff);
92 
93 
95  void clearDatabaseCache() { if (_dcrc.valid()) _dcrc->clearDatabaseCache(); }
96 
100  void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);
101 
104 
105  protected :
106 
107  struct LOS
108  {
109  LOS(const osg::Vec3d& start, const osg::Vec3d& end):
110  _start(start),
111  _end(end) {}
112 
113 
116  Intersections _intersections;
117  };
118 
119  typedef std::vector<LOS> LOSList;
120  LOSList _LOSList;
121 
124 
125 };
126 
127 }
128 
129 #endif
osgUtil::IntersectionVisitor _intersectionVisitor
Definition: LineOfSight.h:123
#define OSGSIM_EXPORT
Definition: Export.h:38
unsigned int getMaximumNumOfFilesToCache() const
Definition: LineOfSight.h:29
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
LOS(const osg::Vec3d &start, const osg::Vec3d &end)
Definition: LineOfSight.h:109
osg::ref_ptr< DatabaseCacheReadCallback > _dcrc
Definition: LineOfSight.h:122
Intersections _intersections
Definition: LineOfSight.h:116
const Intersections & getIntersections(unsigned int i) const
Definition: LineOfSight.h:84
unsigned int getNumLOS() const
Definition: LineOfSight.h:67
std::vector< osg::Vec3d > Intersections
Definition: LineOfSight.h:81
const osg::Vec3d & getStartPoint(unsigned int i) const
Definition: LineOfSight.h:73
void setStartPoint(unsigned int i, const osg::Vec3d &start)
Definition: LineOfSight.h:70
FileNameSceneMap _filenameSceneMap
Definition: LineOfSight.h:43
std::vector< LOS > LOSList
Definition: LineOfSight.h:119
void setMaximumNumOfFilesToCache(unsigned int maxNumFilesToCache)
Definition: LineOfSight.h:28
DatabaseCacheReadCallback * getDatabaseCacheReadCallback()
Definition: LineOfSight.h:103
std::map< std::string, osg::ref_ptr< osg::Node > > FileNameSceneMap
Definition: LineOfSight.h:39
Definition: Node.h:71
OSGDB_EXPORT osg::Node * readNodeFile(const std::string &filename, const Options *options)
void setEndPoint(unsigned int i, const osg::Vec3d &end)
Definition: LineOfSight.h:76
void clearDatabaseCache()
Definition: LineOfSight.h:95
const osg::Vec3d & getEndPoint(unsigned int i) const
Definition: LineOfSight.h:79
unsigned int NodeMask
Definition: Node.h:352