root/OpenSceneGraph/trunk/include/osgSim/ElevationSlice @ 13041

Revision 13041, 4.6 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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_ELEVATIONSLICE
15#define OSGSIM_ELEVATIONSLICE 1
16
17#include <osgUtil/IntersectionVisitor>
18
19// include so we can get access to the DatabaseCacheReadCallback
20#include <osgSim/LineOfSight>
21
22namespace osgSim {
23
24/** Helper class for setting up and acquiring height above terrain intersections with terrain.
25  * By default assigns a osgSim::DatabaseCacheReadCallback that enables automatic loading
26  * of external PagedLOD tiles to ensure that the highest level of detail is used in intersections.
27  * This automatic loading of tiles is done by the intersection traversal that is done within
28  * the computeIntersections(..) method, so can result in long intersection times when external
29  * tiles have to be loaded.
30  * The external loading of tiles can be disabled by removing the read callback, this is done by
31  * calling the setDatabaseCacheReadCallback(DatabaseCacheReadCallback*) method with a value of 0.*/
32class OSGSIM_EXPORT ElevationSlice
33{
34    public :
35
36
37        ElevationSlice();
38
39        /** Set the start point of the slice.*/
40        void setStartPoint(const osg::Vec3d& startPoint) { _startPoint = startPoint; }
41
42        /** Get the start point of the slice.*/
43        const osg::Vec3d& getStartPoint() const { return _startPoint; }
44
45        /** Set the end point of the slice.*/
46        void setEndPoint(const osg::Vec3d& endPoint) { _endPoint = endPoint; }
47
48        /** Get the end point of the slice.*/
49        const osg::Vec3d& getEndPoint() const { return _endPoint; }
50
51
52        typedef std::vector<osg::Vec3d> Vec3dList;
53
54        /** Get the intersections in the form of a vector of Vec3d. */
55        const Vec3dList& getIntersections() const  { return _intersections; }
56
57        typedef std::pair<double,double> DistanceHeight;
58        typedef std::vector<DistanceHeight> DistanceHeightList;
59
60        /** Get the intersections in the form a vector of pair<double,double> representing distance along the slice and height. */
61        const DistanceHeightList& getDistanceHeightIntersections() const { return _distanceHeightIntersections; }
62
63
64        /** Compute the intersections with the specified scene graph, the results are stored in vectors of Vec3d.
65          * Note, if the topmost node is a CoordinateSystemNode then the input points are assumed to be geocentric,
66          * with the up vector defined by the EllipsoidModel attached to the CoordinateSystemNode.
67          * If the topmost node is not a CoordinateSystemNode then a local coordinates frame is assumed, with a local up vector. */
68        void computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask=0xffffffff);
69
70        /** Compute the vertical distance between the specified scene graph and a single HAT point.*/
71        static Vec3dList computeElevationSlice(osg::Node* scene, const osg::Vec3d& startPoint, const osg::Vec3d& endPoint, osg::Node::NodeMask traversalMask=0xffffffff);
72
73
74        /** Clear the database cache.*/
75        void clearDatabaseCache() { if (_dcrc.valid()) _dcrc->clearDatabaseCache(); }
76
77        /** Set the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.
78          * Note, if you have multiple LineOfSight or ElevationSlice objects in use at one time then you should share a single
79          * DatabaseCacheReadCallback between all of them. */
80        void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);
81
82        /** Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.*/
83        DatabaseCacheReadCallback* getDatabaseCacheReadCallback() { return _dcrc.get(); }
84
85    protected :
86
87
88        osg::Vec3d                              _startPoint;
89        osg::Vec3d                              _endPoint;
90        Vec3dList                               _intersections;
91        DistanceHeightList                      _distanceHeightIntersections;
92
93        osg::ref_ptr<DatabaseCacheReadCallback> _dcrc;
94        osgUtil::IntersectionVisitor            _intersectionVisitor;
95
96
97};
98
99}
100
101#endif
Note: See TracBrowser for help on using the browser.