From 6b67320190872fb4978dc17cf7897eb6c88b017b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 17 Mar 2011 17:33:02 +0000 Subject: [PATCH] Added support for new SampleDensityWhenMovingProperty into .p3d format, with it default to 0.02. One can override this value via the sampleDensityWhenMoving="value" property in the volume tag, i.e. CardiacCT To switch the feature off set the value to 0, i.e. CardiacCT --- include/osgPresentation/SlideShowConstructor | 4 +++- src/osgPlugins/p3d/ReaderWriterP3D.cpp | 1 + src/osgPresentation/SlideShowConstructor.cpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/osgPresentation/SlideShowConstructor b/include/osgPresentation/SlideShowConstructor index 93a8b0e82..b94e7766a 100644 --- a/include/osgPresentation/SlideShowConstructor +++ b/include/osgPresentation/SlideShowConstructor @@ -267,7 +267,8 @@ public: region_in_pixel_coords(false), alphaValue(1.0), cutoffValue(0.1), - sampleDensityValue(0.005) + sampleDensityValue(0.005), + sampleDensityWhenMovingValue(0.02) { region[0] = region[1] = region[2] = 0.0f; region[3] = region[4] = region[5] = 1.0f; @@ -282,6 +283,7 @@ public: float alphaValue; float cutoffValue; float sampleDensityValue; + float sampleDensityWhenMovingValue; }; diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index e2f29a2b4..a01282f56 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -1004,6 +1004,7 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons if (getProperty(cur, "cutoff", volumeData.cutoffValue)) {} if (getProperty(cur, "region", 6, volumeData.region)) {} if (getProperty(cur, "sampleDensity", volumeData.sampleDensityValue)) {} + if (getProperty(cur, "sampleDensityWhenMoving", volumeData.sampleDensityWhenMovingValue)) {} // check for any transfer function required std::string transferFunctionFile; diff --git a/src/osgPresentation/SlideShowConstructor.cpp b/src/osgPresentation/SlideShowConstructor.cpp index 237c33306..cbb99bdaa 100644 --- a/src/osgPresentation/SlideShowConstructor.cpp +++ b/src/osgPresentation/SlideShowConstructor.cpp @@ -1811,6 +1811,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position osgVolume::AlphaFuncProperty* ap = new osgVolume::AlphaFuncProperty(volumeData.cutoffValue); osgVolume::TransparencyProperty* tp = new osgVolume::TransparencyProperty(volumeData.alphaValue); osgVolume::SampleDensityProperty* sd = new osgVolume::SampleDensityProperty(volumeData.sampleDensityValue); + osgVolume::SampleDensityWhenMovingProperty* sdm = (volumeData.sampleDensityWhenMovingValue > 0.0f) ? (new osgVolume::SampleDensityWhenMovingProperty(volumeData.sampleDensityWhenMovingValue)) : 0; osgVolume::TransferFunctionProperty* tfp = volumeData.transferFunction.valid() ? new osgVolume::TransferFunctionProperty(volumeData.transferFunction.get()) : 0; { @@ -1819,6 +1820,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position cp->addProperty(ap); cp->addProperty(sd); cp->addProperty(tp); + if (sdm) cp->addProperty(sdm); if (tfp) cp->addProperty(tfp); sp->addProperty(cp);