| 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 OSGTERRAIN_VALIDDATAOPERATOR |
|---|
| 15 | #define OSGTERRAIN_VALIDDATAOPERATOR 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Referenced> |
|---|
| 18 | #include <osg/Vec2> |
|---|
| 19 | #include <osg/Vec3> |
|---|
| 20 | #include <osg/Vec4> |
|---|
| 21 | #include <osgTerrain/Export> |
|---|
| 22 | |
|---|
| 23 | namespace osgTerrain { |
|---|
| 24 | |
|---|
| 25 | struct ValidDataOperator : public osg::Referenced |
|---|
| 26 | { |
|---|
| 27 | virtual bool operator() (float /*value*/) const { return true; } |
|---|
| 28 | virtual bool operator() (const osg::Vec2& value) const { return operator()(value.x()) && operator()(value.y()) ; } |
|---|
| 29 | virtual bool operator() (const osg::Vec3& value) const { return operator()(value.x()) && operator()(value.y()) && operator()(value.z()); } |
|---|
| 30 | virtual bool operator() (const osg::Vec4& value) const { return operator()(value.x()) && operator()(value.y()) && operator()(value.z()) && operator()(value.w()); } |
|---|
| 31 | }; |
|---|
| 32 | |
|---|
| 33 | struct ValidRange : public ValidDataOperator |
|---|
| 34 | { |
|---|
| 35 | ValidRange(float minValue, float maxValue): |
|---|
| 36 | _minValue(minValue), |
|---|
| 37 | _maxValue(maxValue) {} |
|---|
| 38 | |
|---|
| 39 | void setRange(float minValue, float maxValue) |
|---|
| 40 | { |
|---|
| 41 | _minValue = minValue; |
|---|
| 42 | _maxValue = maxValue; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | void setMinValue(float minValue) { _minValue = minValue; } |
|---|
| 46 | float getMinValue() const { return _minValue; } |
|---|
| 47 | |
|---|
| 48 | void setMaxValue(float maxValue) { _maxValue = maxValue; } |
|---|
| 49 | float getMaxValue() const { return _maxValue; } |
|---|
| 50 | |
|---|
| 51 | virtual bool operator() (float value) const { return value>=_minValue && value<=_maxValue; } |
|---|
| 52 | |
|---|
| 53 | float _minValue, _maxValue; |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | struct NoDataValue : public ValidDataOperator |
|---|
| 58 | { |
|---|
| 59 | NoDataValue(float value): |
|---|
| 60 | _value(value) {} |
|---|
| 61 | |
|---|
| 62 | void setNoDataValue(float value) { _value = value; } |
|---|
| 63 | float getValue() const { return _value; } |
|---|
| 64 | |
|---|
| 65 | virtual bool operator() (float value) const { return value!=_value; } |
|---|
| 66 | |
|---|
| 67 | float _value; |
|---|
| 68 | }; |
|---|
| 69 | |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | #endif |
|---|
| 73 | |
|---|
| 74 | |
|---|