osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/ExtrudeGeometryFilter

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_EXTRUDE_GEOMETRY_FILTER_H
00021 #define OSGEARTHFEATURES_EXTRUDE_GEOMETRY_FILTER_H 1
00022 
00023 #include <osgEarthFeatures/Common>
00024 #include <osgEarthFeatures/Feature>
00025 #include <osgEarthFeatures/Filter>
00026 #include <osgEarthSymbology/Expression>
00027 #include <osgEarthSymbology/Style>
00028 #include <osg/Geode>
00029 
00030 namespace osgEarth { namespace Features 
00031 {
00032     using namespace osgEarth;
00033     using namespace osgEarth::Symbology;
00034 
00038     class OSGEARTHFEATURES_EXPORT ExtrudeGeometryFilter : public FeaturesToNodeFilter
00039     {
00040     public:
00041         struct HeightCallback : public osg::Referenced
00042         {
00043             virtual float operator()( Feature* input, const FilterContext& cx ) =0;
00044         };
00045 
00046     public:
00047 
00049         ExtrudeGeometryFilter();
00050 
00054         void setStyle( const Style& style );
00055 
00059         osg::Node* push( FeatureList& input, FilterContext& context );
00060 
00061     public: // properties
00062 
00066         void setWallAngleThreshold( float angle_deg ) { _wallAngleThresh_deg = angle_deg; }
00067         
00072         void setFeatureNameExpr( const StringExpression& expr ) { _featureNameExpr = expr; }
00073         const StringExpression& getFeatureNameExpr() const { return _featureNameExpr; }
00074 
00075     protected:
00076 
00077         // a set of geodes indexed by stateset pointer, for pre-sorting geodes based on 
00078         // their texture usage
00079         typedef std::map<osg::StateSet*, osg::ref_ptr<osg::Geode> > SortedGeodeMap;
00080         SortedGeodeMap                 _geodes;
00081         osg::ref_ptr<osg::StateSet>    _noTextureStateSet;
00082 
00083         optional<double>               _maxAngle_deg;
00084         optional<bool>                 _mergeGeometry;
00085         float                          _wallAngleThresh_deg;
00086         float                          _cosWallAngleThresh;
00087         StringExpression               _featureNameExpr;
00088         osg::ref_ptr<HeightCallback>   _heightCallback;
00089         optional<NumericExpression>    _heightOffsetExpr;
00090         optional<NumericExpression>    _heightExpr;
00091 
00092         Style                          _style;
00093         bool                           _styleDirty;
00094 
00095         osg::ref_ptr<const ExtrusionSymbol> _extrusionSymbol;
00096         osg::ref_ptr<const SkinSymbol>      _wallSkinSymbol;
00097         osg::ref_ptr<const PolygonSymbol>   _wallPolygonSymbol;
00098         osg::ref_ptr<const SkinSymbol>      _roofSkinSymbol;
00099         osg::ref_ptr<const PolygonSymbol>   _roofPolygonSymbol;
00100         osg::ref_ptr<const LineSymbol>      _outlineSymbol;
00101         osg::ref_ptr<ResourceLibrary>       _wallResLib;
00102         osg::ref_ptr<ResourceLibrary>       _roofResLib;
00103 
00104         void reset( const FilterContext& context );
00105         
00106         void addDrawable( 
00107             osg::Drawable*     drawable, 
00108             osg::StateSet*     stateSet, 
00109             const std::string& name );
00110         
00111         bool process( 
00112             FeatureList&    input,
00113             FilterContext&   context );
00114 
00115         bool extrudeGeometry(
00116             const Geometry*      input,
00117             double               height,
00118             double               offset,
00119             bool                 uniformHeight,
00120             osg::Geometry*       walls,
00121             osg::Geometry*       top_cap,
00122             osg::Geometry*       bottom_cap,
00123             osg::Geometry*       outline,
00124             const osg::Vec4&     wallColor,
00125             const osg::Vec4&     roofColor,
00126             const osg::Vec4&     outlineColor,
00127             const SkinResource*  wallSkin,
00128             const SkinResource*  roofSkin,
00129             FilterContext&       cx );
00130     };
00131 
00132 } } // namespace osgEarth::Features
00133 
00134 #endif // OSGEARTHFEATURES_BUILD_GEOMETRY_FILTER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines