Skip to content

Commit

Permalink
Refs #9196. Making helper for special value checking and using it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Mar 17, 2014
1 parent 9f6600b commit b50126d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/Common.h
Expand Up @@ -38,6 +38,8 @@ std::string makeAxisTitle(Dimension_const_sptr dim);
void setAxisLabel(std::string metadataLabel,
std::string labelString,
vtkFieldData *fieldData);
/// Function to check for special values.
bool isSpecial(double value);

}

Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Vates/VatesAPI/src/Common.cpp
Expand Up @@ -5,6 +5,8 @@
#include <vtkFieldData.h>
#include <vtkStringArray.h>

#include <boost/math/special_functions/fpclassify.hpp>

//using namespace Mantid::Geometry;
namespace Mantid
{
Expand All @@ -31,6 +33,10 @@ void setAxisLabel(std::string metadataLabel,
fieldData->AddArray(axisTitle.GetPointer());
}

bool isSpecial(double value)
{
return boost::math::isnan(value) || boost::math::isinf(value);
}

} // VATES
} // Mantid
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDHexFactory.cpp
Expand Up @@ -2,8 +2,8 @@
#include "MantidKernel/CPUTimer.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidVatesAPI/vtkMDHexFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include <vtkCellData.h>
#include <vtkFloatArray.h>
#include <vtkHexahedron.h>
Expand Down Expand Up @@ -100,7 +100,7 @@ namespace Mantid
API::IMDNode * box = boxes[i];
Mantid::signal_t signal_normalized= box->getSignalNormalized();

if (!boost::math::isnan( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
if (!isSpecial( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
{
// Cache the signal and using of it
signalArray[i] = float(signal_normalized);
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDHistoHexFactory.cpp
Expand Up @@ -2,8 +2,8 @@
#include "MantidKernel/CPUTimer.h"
#include "MantidMDEvents/MDHistoWorkspace.h"
#include "MantidVatesAPI/vtkMDHistoHexFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include "MantidAPI/NullCoordTransform.h"
#include "MantidKernel/ReadLock.h"

Expand Down Expand Up @@ -150,7 +150,7 @@ namespace VATES
else
signalScalar = m_workspace->getSignalNormalizedAt(x,y,z);

if (boost::math::isnan( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
if (isSpecial( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
{
// out of range
voxelShown[index] = false;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDHistoLineFactory.cpp
@@ -1,12 +1,12 @@
#include "MantidVatesAPI/vtkMDHistoLineFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkSmartPointer.h"
#include "vtkLine.h"
#include <vector>
#include <boost/math/special_functions/fpclassify.hpp>
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/NullCoordTransform.h"
#include "MantidMDEvents/MDHistoWorkspace.h"
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace Mantid

float signalScalar = static_cast<float>(m_workspace->getSignalNormalizedAt(i));

if (boost::math::isnan( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
if (isSpecial( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
{
//Flagged so that topological and scalar data is not applied.
unstructPoint.isSparse = true;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDHistoQuadFactory.cpp
Expand Up @@ -3,13 +3,13 @@
#include "MantidMDEvents/MDHistoWorkspace.h"
#include "MantidAPI/NullCoordTransform.h"
#include "MantidVatesAPI/vtkMDHistoQuadFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkQuad.h"
#include "vtkSmartPointer.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include <vector>
#include "MantidKernel/ReadLock.h"

Expand Down Expand Up @@ -118,7 +118,7 @@ namespace Mantid
{
index = j + nBinsY*i;
signalScalar = static_cast<float>(m_workspace->getSignalNormalizedAt(i, j));
if (boost::math::isnan( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
if (isSpecial( signalScalar ) || !m_thresholdRange->inRange(signalScalar))
{
// out of range
voxelShown[index] = false;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDLineFactory.cpp
@@ -1,4 +1,5 @@
#include "MantidVatesAPI/vtkMDLineFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
Expand All @@ -10,7 +11,6 @@
#include <vtkFloatArray.h>
#include <vtkLine.h>
#include <vtkCellData.h>
#include <boost/math/special_functions/fpclassify.hpp>
#include "MantidKernel/ReadLock.h"

using namespace Mantid::API;
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace Mantid
progressUpdating.eventRaised(double(iBox)*progressFactor);

Mantid::signal_t signal_normalized= it->getNormalizedSignal();
if (!boost::math::isnan( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
if (!isSpecial( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
{
useBox[iBox] = true;
signals->InsertNextValue(static_cast<float>(signal_normalized));
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Vates/VatesAPI/src/vtkMDQuadFactory.cpp
@@ -1,4 +1,5 @@
#include "MantidVatesAPI/vtkMDQuadFactory.h"
#include "MantidVatesAPI/Common.h"
#include "MantidVatesAPI/ProgressAction.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
Expand All @@ -10,7 +11,6 @@
#include <vtkFloatArray.h>
#include <vtkQuad.h>
#include <vtkCellData.h>
#include <boost/math/special_functions/fpclassify.hpp>
#include "MantidKernel/ReadLock.h"

using namespace Mantid::API;
Expand Down Expand Up @@ -98,7 +98,7 @@ namespace Mantid
progressUpdating.eventRaised(progressFactor * double(iBox));

Mantid::signal_t signal_normalized= it->getNormalizedSignal();
if (!boost::math::isnan( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
if (!isSpecial( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
{
useBox[iBox] = true;
signals->InsertNextValue(static_cast<float>(signal_normalized));
Expand Down

0 comments on commit b50126d

Please sign in to comment.