diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 74c8c15f4..667a6a278 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -35,8 +35,9 @@ #define VERSION_0024 24 #define VERSION_0025 25 #define VERSION_0026 26 +#define VERSION_0027 27 -#define VERSION VERSION_0026 +#define VERSION VERSION_0027 /* The BYTE_SEX tag is used to check the endian of the IVE file being read in. The IVE format diff --git a/src/osgPlugins/ive/Layer.cpp b/src/osgPlugins/ive/Layer.cpp index 4c238a694..73aa79b8c 100644 --- a/src/osgPlugins/ive/Layer.cpp +++ b/src/osgPlugins/ive/Layer.cpp @@ -50,6 +50,11 @@ void Layer::write(DataOutputStream* out) out->writeUInt(getMinLevel()); out->writeUInt(getMaxLevel()); + + if (out->getVersion() >= VERSION_0027) + { + writeValidDataOperator(out,getValidDataOperator()); + } } void Layer::read(DataInputStream* in) @@ -83,6 +88,10 @@ void Layer::read(DataInputStream* in) setMinLevel(in->readUInt()); setMaxLevel(in->readUInt()); + if (in->getVersion() >= VERSION_0027) + { + setValidDataOperator(readValidDataOperator(in)); + } } void LayerHelper::writeLayer(DataOutputStream* out, osgTerrain::Layer* layer) @@ -196,3 +205,56 @@ osgTerrain::Locator* LayerHelper::readLocator(DataInputStream* in) return locator; } + +void Layer::writeValidDataOperator(DataOutputStream* out, osgTerrain::ValidDataOperator* validDataOperator) +{ + if (validDataOperator) + { + out->writeBool(true); + osgTerrain::ValidRange* validRange = dynamic_cast(validDataOperator); + if (validRange) + { + out->writeInt(IVEVALIDRANGE); + out->writeFloat(validRange->getMinValue()); + out->writeFloat(validRange->getMaxValue()); + } + else + { + osgTerrain::NoDataValue* noDataValue = dynamic_cast(validDataOperator); + if (noDataValue) + { + out->writeInt(IVENODATAVALUE); + out->writeFloat(noDataValue->getValue()); + } + } + } + else + { + out->writeBool(false); + } +} + +osgTerrain::ValidDataOperator* Layer::readValidDataOperator(DataInputStream* in) +{ + bool hasOperator = in->readBool(); + if (!hasOperator) return 0; + + int id = in->peekInt(); + if (id==IVEVALIDRANGE) + { + id = in->readInt(); + float minValue = in->readFloat(); + float maxValue = in->readFloat(); + return new osgTerrain::ValidRange(minValue,maxValue); + } + else if (id==IVENODATAVALUE) + { + id = in->readInt(); + float value = in->readFloat(); + return new osgTerrain::NoDataValue(value); + } + else + { + return 0; + } +} diff --git a/src/osgPlugins/ive/Layer.h b/src/osgPlugins/ive/Layer.h index f85189015..2ba6f1ac5 100644 --- a/src/osgPlugins/ive/Layer.h +++ b/src/osgPlugins/ive/Layer.h @@ -36,10 +36,14 @@ class LayerHelper class Layer : public osgTerrain::Layer, public ReadWrite { public: - void write(DataOutputStream* out); - void read(DataInputStream* in); + void write(DataOutputStream* out); + void read(DataInputStream* in); + + void writeValidDataOperator(DataOutputStream* out, osgTerrain::ValidDataOperator* validDataOperator); + osgTerrain::ValidDataOperator* readValidDataOperator(DataInputStream* in); }; + } #endif diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index 8306f7281..c15b5ac3e 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -130,6 +130,9 @@ namespace ive { #define IVEPROXYLAYER 0x00200007 #define IVETERRAINTECHNIQUE 0x00200008 #define IVEGEOMETRYTECHNIQUE 0x00200009 +#define IVEVALIDDATAOPERATOR 0x0020000A +#define IVEVALIDRANGE 0x0020000B +#define IVENODATAVALUE 0x0020000C //#define IVETERRAIN 0x0020000A // osgFX classes