Skip to content

Commit

Permalink
refs #8992. Use number of transformations to original.
Browse files Browse the repository at this point in the history
ConvertMDHistoToMatrixWorkspace should not count original workspaces. I've also refactored this code so that I'm not having to work with raw pointers.
  • Loading branch information
OwenArnold committed Feb 19, 2014
1 parent 589556d commit b65e614
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -18,6 +18,15 @@ Creates a single spectrum Workspace2D with X,Y, and E copied from an first non-i
#include <boost/type_traits.hpp>
#include <sstream>

namespace
{
struct null_deleter
{
void operator()(void const *) const
{ // Do nothing
}
};
}

namespace Mantid
{
Expand Down Expand Up @@ -124,13 +133,13 @@ void ConvertMDHistoToMatrixWorkspace::exec()
outputWorkspace->dataY(0).assign(Y.begin(),Y.end());
outputWorkspace->dataE(0).assign(E.begin(),E.end());

const size_t numberOriginal = inputWorkspace->numOriginalWorkspaces();
NullCoordTransform nullTransform(inputWorkspace->getNumDims());
CoordTransform* transform = &nullTransform;
if(numberOriginal > 0)
const size_t numberTransformsToOriginal = inputWorkspace->getNumberTransformsToOriginal();

boost::shared_ptr<CoordTransform> transform = boost::make_shared<NullCoordTransform>(inputWorkspace->getNumDims());
if(numberTransformsToOriginal > 0)
{
const size_t index = numberOriginal -1;
transform = inputWorkspace->getTransformToOriginal(index);
const size_t indexToLastTransform = numberTransformsToOriginal - 1 ;
transform = boost::shared_ptr<CoordTransform>(inputWorkspace->getTransformToOriginal(indexToLastTransform), null_deleter());
}

assert(X.size() == outputWorkspace->dataX(0).size());
Expand Down

0 comments on commit b65e614

Please sign in to comment.