/usr/include/osgEarthFeatures/ExtrudeGeometryFilter is in libosgearth-dev 2.7.0+dfsg-2+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHFEATURES_EXTRUDE_GEOMETRY_FILTER_H
#define OSGEARTHFEATURES_EXTRUDE_GEOMETRY_FILTER_H 1
#include <osgEarthFeatures/Common>
#include <osgEarthFeatures/Feature>
#include <osgEarthFeatures/Filter>
#include <osgEarthSymbology/Expression>
#include <osgEarthSymbology/Style>
#include <osg/Geode>
#include <vector>
#include <list>
namespace osgEarth { namespace Features
{
using namespace osgEarth;
using namespace osgEarth::Symbology;
class FeatureSourceIndex;
/**
* Extrudes footprint geometry into 3D geometry
*/
class OSGEARTHFEATURES_EXPORT ExtrudeGeometryFilter : public FeaturesToNodeFilter
{
public:
struct HeightCallback : public osg::Referenced
{
virtual float operator()( Feature* input, const FilterContext& cx ) =0;
};
public:
/** Constructs a new filter that will extrude footprints */
ExtrudeGeometryFilter();
virtual ~ExtrudeGeometryFilter() { }
/**
* Sets the style that will govern the geometry generation.
*/
void setStyle( const Style& style );
/**
* Pushes a list of features through the filter.
*/
osg::Node* push( FeatureList& input, FilterContext& context );
public: // properties
/**
* Sets the maximum wall angle that doesn't require a new normal vector
*/
void setWallAngleThreshold( float angle_deg ) { _wallAngleThresh_deg = angle_deg; }
/**
* Sets whether to render a bottom top. Useful for creating stencil volumes.
*/
void setMakeStencilVolume( bool value ) { _makeStencilVolume = value; }
/**
* Sets the expression to evaluate when setting a feature name.
* NOTE: setting this forces geometry-merging to OFF
*/
void setFeatureNameExpr( const StringExpression& expr ) { _featureNameExpr = expr; }
const StringExpression& getFeatureNameExpr() const { return _featureNameExpr; }
/**
* Whether or not to use vertex buffer objects
*/
optional<bool>& useVertexBufferObjects() { return _useVertexBufferObjects;}
const optional<bool>& useVertexBufferObjects() const { return _useVertexBufferObjects;}
/**
* Whether or not to use TextureArrays for the wall and roof skins
*/
optional<bool>& useTextureArrays() { return _useTextureArrays;}
const optional<bool>& useTextureArrays() const { return _useTextureArrays;}
protected:
// A Corner is one vertex in the source geometry, extrude from base to roof.
struct Corner
{
osg::Vec3d base, roof;
float roofTexU, roofTexV;
double offsetX;
float wallTexHeightAdjusted;
bool isFromSource;
float cosAngle;
float height;
};
typedef std::list<Corner> Corners; // use a list to prevent iterator invalidation
// A Face joins to Corners.
struct Face
{
Corner left;
Corner right;
double widthM;
};
typedef std::vector<Face> Faces;
// An Elevation is a series of related Faces.
struct Elevation
{
Faces faces;
double texHeightAdjustedM;
unsigned getNumPoints() const {
return faces.size() * 6;
}
};
typedef std::vector<Elevation> Elevations;
// A Structure is a collection of related Elevations.
struct Structure
{
Elevations elevations;
bool isPolygon;
osg::Vec3d baseCentroid;
float verticalOffset;
unsigned getNumPoints() const {
unsigned c = 0;
for(Elevations::const_iterator e = elevations.begin(); e != elevations.end(); ++e ) {
c += e->getNumPoints();
}
return c;
}
};
// a set of geodes indexed by stateset pointer, for pre-sorting geodes based on
// their texture usage
typedef std::map<osg::StateSet*, osg::ref_ptr<osg::Geode> > SortedGeodeMap;
SortedGeodeMap _geodes;
osg::ref_ptr<osg::StateSet> _noTextureStateSet;
optional<double> _maxAngle_deg;
optional<bool> _mergeGeometry;
float _wallAngleThresh_deg;
float _cosWallAngleThresh;
StringExpression _featureNameExpr;
osg::ref_ptr<HeightCallback> _heightCallback;
optional<NumericExpression> _heightExpr;
bool _makeStencilVolume;
optional<bool> _useVertexBufferObjects;
Style _style;
bool _styleDirty;
optional<bool> _useTextureArrays;
bool _gpuClamping;
osg::ref_ptr<const ExtrusionSymbol> _extrusionSymbol;
osg::ref_ptr<const SkinSymbol> _wallSkinSymbol;
osg::ref_ptr<const PolygonSymbol> _wallPolygonSymbol;
osg::ref_ptr<const SkinSymbol> _roofSkinSymbol;
osg::ref_ptr<const PolygonSymbol> _roofPolygonSymbol;
osg::ref_ptr<const LineSymbol> _outlineSymbol;
osg::ref_ptr<ResourceLibrary> _wallResLib;
osg::ref_ptr<ResourceLibrary> _roofResLib;
void reset( const FilterContext& context );
void addDrawable(
osg::Drawable* drawable,
osg::StateSet* stateSet,
const std::string& name,
Feature* feature,
FeatureIndexBuilder* index);
bool process(
FeatureList& input,
FilterContext& context );
bool buildStructure(const Geometry* input,
double height,
bool flatten,
float verticalOffset,
const SkinResource* wallSkin,
const SkinResource* roofSkin,
Structure& out_structure,
FilterContext& cx );
bool buildWallGeometry(const Structure& structure,
osg::Geometry* walls,
const osg::Vec4& wallColor,
const osg::Vec4& wallBaseColor,
const SkinResource* wallSkin);
bool buildRoofGeometry(const Structure& structure,
osg::Geometry* roof,
const osg::Vec4& roofColor,
const SkinResource* roofSkin);
bool buildOutlineGeometry(const Structure& structure,
osg::Geometry* outline,
const osg::Vec4& outlineColor,
float minCreaseAngleDeg);
};
} } // namespace osgEarth::Features
#endif // OSGEARTHFEATURES_BUILD_GEOMETRY_FILTER_H
|