~ubuntu-branches/debian/sid/osgearth/sid

« back to all changes in this revision

Viewing changes to src/osgEarthFeatures/BufferFilter

  • Committer: Bazaar Package Importer
  • Author(s): Pirmin Kalberer
  • Date: 2011-07-14 22:13:36 UTC
  • Revision ID: james.westby@ubuntu.com-20110714221336-94igk9rskxveh794
Tags: upstream-2.0+dfsg
ImportĀ upstreamĀ versionĀ 2.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-c++-*- */
 
2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 
3
 * Copyright 2008-2010 Pelican Mapping
 
4
 * http://osgearth.org
 
5
 *
 
6
 * osgEarth is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 
18
 */
 
19
 
 
20
#ifndef OSGEARTHFEATURES_BUFFER_FILTER_H
 
21
#define OSGEARTHFEATURES_BUFFER_FILTER_H 1
 
22
 
 
23
#include <osgEarthFeatures/Common>
 
24
#include <osgEarthFeatures/Feature>
 
25
#include <osgEarthFeatures/Filter>
 
26
#include <osgEarthSymbology/Style>
 
27
#include <osgEarthSymbology/GeometrySymbol>
 
28
#include <osg/Geode>
 
29
 
 
30
namespace osgEarth { namespace Features
 
31
{
 
32
    using namespace osgEarth;
 
33
    using namespace osgEarth::Symbology;
 
34
 
 
35
    /**
 
36
     * The buffer geometry operation takes each input vector shape and applies
 
37
     * morphological dilation or erosion to it.
 
38
     * (see http://en.wikipedia.org/wiki/Morphological_image_processing)
 
39
     *
 
40
     * The buffer distance determines which operation to use:
 
41
     *
 
42
     * A positive distance dilates the shape (expands it).
 
43
     * A negative distance erodes the shape (shrinks it). 
 
44
     *
 
45
     * Note: buffering always converts the input vector data into polygons. 
 
46
     */
 
47
    class OSGEARTHFEATURES_EXPORT BufferFilter : public FeatureFilter
 
48
    {
 
49
    public:
 
50
        // Call this determine whether this filter is available. This filter uses
 
51
        // the GEOS library, so you must compile osgEarth against GEOS for this 
 
52
        // filter to be available.
 
53
        static bool isSupported();
 
54
 
 
55
    public:
 
56
        BufferFilter();
 
57
        BufferFilter( const BufferFilter& rhs );
 
58
 
 
59
    public:
 
60
        // how far to buffer; positive to dialate, negative to erode
 
61
        optional<double>& distance() { return _distance; }
 
62
        const optional<double>& distance() const { return _distance; }
 
63
 
 
64
        // for ENDCAP_ROUND, controls the tessellation detail for corners, 
 
65
        // measured in the number of segments to create per 90 degrees
 
66
        int numQuadrantSegments() const { return _numQuadSegs; }
 
67
        int& numQuadrantSegments() { return _numQuadSegs; }
 
68
 
 
69
        // tessellation style of buffered corners and line ends
 
70
        const Stroke::LineCapStyle& capStyle() const { return _capStyle; }
 
71
        Stroke::LineCapStyle& capStyle() { return _capStyle; }
 
72
 
 
73
    public:
 
74
        virtual FilterContext push( FeatureList& input, const FilterContext& context );
 
75
 
 
76
    protected:
 
77
        optional<double> _distance;
 
78
        int _numQuadSegs;
 
79
        Stroke::LineCapStyle _capStyle;
 
80
 
 
81
        bool push( Feature* input, const FilterContext& context );
 
82
    };
 
83
 
 
84
} } // namespace osgEarth::Features
 
85
 
 
86
#endif // OSGEARTHFEATURES_BUFFER_FILTER_H