osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/FeatureGeometryIndex

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00020 #ifndef OSGEARTHFEATURES_FEATURE_GEOMETRY_INDEX_H
00021 #define OSGEARTHFEATURES_FEATURE_GEOMETRY_INDEX_H 1
00022 
00023 #include <osgEarthFeatures/Common>
00024 #include <osgEarthFeatures/Feature>
00025 #include <osg/Geode>
00026 #include <osg/Geometry>
00027 #include <osg/PrimitiveSet>
00028 #include <map>
00029 #include <vector>
00030 
00031 namespace osgEarth { namespace Features
00032 {
00036     struct FeatureGeometryRecord
00037     {
00038         typedef std::vector< osg::ref_ptr<osg::PrimitiveSet> > PrimitiveSetVector;
00039         typedef std::map< osg::ref_ptr<osg::Geometry>, PrimitiveSetVector > GeomPrimSetMap;
00040 
00041         osg::ref_ptr<osg::Geode> _geode;
00042         GeomPrimSetMap           _primSetsByGeometry;
00043     };
00044 
00052     class OSGEARTHFEATURES_EXPORT FeatureGeometryQuery
00053     {
00054     public:
00055         FeatureGeometryQuery( osg::Node* graph );
00056 
00061         bool find( FeatureID fid, FeatureGeometryRecord& output ) const;
00062 
00063     protected:
00064         osg::ref_ptr<osg::Node> _graph;
00065     };
00066 
00076     class OSGEARTHFEATURES_EXPORT FeatureGeometryIndex : public osg::Referenced
00077     {
00078     public:
00079         typedef std::map< FeatureID, FeatureGeometryRecord > FeatureRecords;
00080 
00081     public:
00083         const FeatureGeometryRecord* get( FeatureID fid ) const;
00084 
00086         const FeatureRecords& getRecords() const { return _records; }
00087 
00088     private:
00089         FeatureRecords _records;
00090         friend class FeatureGeometryIndexBuilder;
00091         FeatureGeometryIndex();
00092     };
00093 
00100     class OSGEARTHFEATURES_EXPORT FeatureGeometryIndexBuilder
00101     {
00102     public:
00103         FeatureGeometryIndexBuilder();
00104 
00108         void add( FeatureID id, osg::PrimitiveSet* primSet );
00109 
00113         FeatureGeometryIndex* createIndex( osg::Node* graph );
00114 
00115 
00116     public:
00117         typedef std::map< osg::PrimitiveSet*, FeatureID > PrimSetFeatureIdMap;
00118 
00119     protected:
00120         PrimSetFeatureIdMap _primSetIds;
00121     };
00122 
00123 } } // osgEarth::Features
00124 
00125 #endif // OSGEARTHFEATURES_FEATURE_GEOMETRY_INDEX_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines