diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h b/Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h index ab6bc02b5589e50a8fb7b320f5a5515e14c97e3a..4d4d141d99d28b62afeea5e5fca0d4692d473019 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h @@ -7,6 +7,9 @@ #include "MantidAPI/DllConfig.h" #include "MantidAPI/IFitFunction.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidGeometry/MDGeometry/MDTypes.h" +#include "MantidKernel/VMD.h" +#include <vector> namespace Mantid { @@ -46,18 +49,71 @@ class IMDWorkspace; class MANTID_API_DLL IMDIterator { public: + + //=============================== REMOVE THESE SOON ================================================== /// Get the size of the data (number of entries that will be iterated through) - virtual size_t getDataSize() const = 0; + virtual size_t getDataSize() const + { throw std::runtime_error("IMDIterator: Not Implemented."); } /// Get the i-th coordinate of the current cell - virtual double getCoordinate(std::size_t i) const = 0; + virtual double getCoordinate(std::size_t i) const + { UNUSED_ARG(i); throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Return the current data pointer (index) into the MDWorkspace + virtual size_t getPointer() const + { throw std::runtime_error("IMDIterator: Not Implemented."); } + //=============================== END REMOVE THESE SOON ================================================== + /// Advance to the next cell. If the current cell is the last one in the workspace /// do nothing and return false. - virtual bool next() = 0; + virtual bool next() + { throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Returns the normalized signal for this box + virtual signal_t getNormalizedSignal() const + { throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Returns the normalized error for this box + virtual signal_t getNormalizedError() const + { throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Return a list of vertexes defining the volume pointed to + virtual coord_t * getVertexesArray(size_t & numVertices) const + { UNUSED_ARG(numVertices); throw std::runtime_error("IMDIterator: Not Implemented."); } + + + /// Returns the number of events/points contained in this box + virtual size_t getNumEvents() const + { throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// For a given event/point in this box, return the run index + virtual uint16_t getInnerRunIndex(size_t index) const + { UNUSED_ARG(index); throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// For a given event/point in this box, return the detector ID + virtual int32_t getInnerDetectorID(size_t index) const + { UNUSED_ARG(index); throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Returns the position of a given event for a given dimension + virtual size_t getInnerPosition(size_t index, size_t dimension) const + { UNUSED_ARG(index); UNUSED_ARG(dimension); throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Returns the signal of a given event + virtual signal_t getInnerSignal(size_t index) + { UNUSED_ARG(index); throw std::runtime_error("IMDIterator: Not Implemented."); } + + /// Returns the error of a given event + virtual signal_t getInnerError(size_t index) + { UNUSED_ARG(index); throw std::runtime_error("IMDIterator: Not Implemented."); } + + + //======================================================================================= + +// /// Return a list of vertexes defining the volume pointed to +// virtual std::vector<Mantid::Kernel::VMD> getVertexes() const +// { UNUSED_ARG(index); throw std::runtime_error("IMDIterator: Not Implemented."); } - /// Return the current data pointer (index) into the MDWorkspace - virtual size_t getPointer() const = 0; }; diff --git a/Code/Mantid/Framework/DataObjects/src/EventList.cpp b/Code/Mantid/Framework/DataObjects/src/EventList.cpp index 1a94443090a3c06850904d3cc4295a464772e097..1833f1d42fa9976da4f2fb85f08b8364ff6e2ab4 100644 --- a/Code/Mantid/Framework/DataObjects/src/EventList.cpp +++ b/Code/Mantid/Framework/DataObjects/src/EventList.cpp @@ -2618,9 +2618,14 @@ namespace DataObjects * NOTE: no unit checks are made (or possible to make) to compare the units of X and tof() in the EventList. * * The formula used for calculating the error on the neutron weight is: - * \f[ \sigma_{AB}^2 = B^2 \sigma_A^2 + A^2 \sigma_B ^ 2 \f] - * ... where A is the weight, and B is the scalar multiplier for the histogram bin that A is in, - * \f$\sigma_X \f$ is the variance of the given variable: + * \f[ \sigma_{f}^2 = B^2 \sigma_A^2 + A^2 \sigma_B ^ 2 \f] + * + * where: + * * A is the weight of the event + * * B is the weight of the BIN that the event falls in + * * \sigma_A is the error (not squared) of the weight of the event + * * \sigma_B is the error (not squared) of the bin B + * * f is the resulting weight of the multiplied event * * @param X: bins of the multiplying histogram. * @param Y: value to multiply the weights. @@ -2753,7 +2758,17 @@ namespace DataObjects /** Divide the weights in this event list by a histogram. * The event list switches to WeightedEvent's if needed. * NOTE: no unit checks are made (or possible to make) to compare the units of X and tof() in the EventList. - * This calls multiply(X,Y,E, divide=true) to do division there. + * + * The formula used for calculating the error on the neutron weight is: + * \f[ \sigma_{f}^2 = (A / B)^2 * (\sigma_A^2 / A^2 + \sigma_B^2 / B^2) \f] + * + * where: + * * A is the weight of the event + * * B is the weight of the BIN that the event falls in + * * \sigma_A is the error (not squared) of the weight of the event + * * \sigma_B is the error (not squared) of the bin B + * * f is the resulting weight of the divided event + * * * @param X: bins of the multiplying histogram. * @param Y: value to multiply the weights. diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/Utils.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/Utils.h index f2504006dbf8d769b9564d5ebd17204dbfdb49da..3eeadd965097d03265790e47936b2d796da09592 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/Utils.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/Utils.h @@ -39,8 +39,6 @@ namespace Utils namespace NestedForLoop { - //TODO: Separate these into a namespace like NestedForLoop:: - //------------------------------------------------------------------------------------------------ /** Set up a nested for loop by setting an array of counters. * diff --git a/Code/Mantid/Framework/MDDataObjects/CMakeLists.txt b/Code/Mantid/Framework/MDDataObjects/CMakeLists.txt index 920a8dca218ccd2e5d635d65ae396aa1e95d1bfb..13f7f39a0b3815dfa93e659c250403a26df526c6 100644 --- a/Code/Mantid/Framework/MDDataObjects/CMakeLists.txt +++ b/Code/Mantid/Framework/MDDataObjects/CMakeLists.txt @@ -3,7 +3,6 @@ set ( SRC_FILES # test helpers src/MDFitWorkspace.cpp src/MDIndexCalculator.cpp - src/MDWorkspaceIterator.cpp ) set ( SRC_UNITY_IGNORE_FILES ) @@ -14,7 +13,6 @@ set ( INC_FILES inc/MDDataObjects/DllExport.h inc/MDDataObjects/MDFitWorkspace.h inc/MDDataObjects/MDIndexCalculator.h - inc/MDDataObjects/MDWorkspaceIterator.h ) # Test files. Other source files required. @@ -25,7 +23,6 @@ set ( TEST_FILES set ( GMOCK_TEST_FILES test/MDIndexCalculatorTest.h - test/MDWorkspaceIteratorTest.h ) if(UNITY_BUILD) diff --git a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDWorkspaceIterator.h b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDWorkspaceIterator.h deleted file mode 100644 index 1fa91c50eee0b8fd814e9b53b65c5d84b2a3759a..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDWorkspaceIterator.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MD_WORKSPACE_ITERATOR_H -#define MD_WORKSPACE_ITERATOR_H - -#include "MantidAPI/IMDIterator.h" -#include "MDDataObjects/MDIndexCalculator.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" -#include <vector> - -namespace Mantid -{ - namespace MDDataObjects - { - /** Concrete implementation of IMDIterator for use with MDWorkspaces. Based closely upon Roman Tolchenov's implementation - used in MDFitWorkspace. - - @author Owen Arnold, Tessella Support Services plc - @date 03/05/2011 - - Copyright © 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. - Code Documentation is available at: <http://doxygen.mantidproject.org> - */ - class DLLExport MDWorkspaceIterator : public Mantid::API::IMDIterator - { - - public: - - MDWorkspaceIterator(const MDWorkspaceIndexCalculator& indexCalculator, std::vector<Mantid::Geometry::IMDDimension_sptr> dimensions); - - ~MDWorkspaceIterator(); - - /// Get the size of the data - virtual size_t getDataSize() const; - - /// Get the i-th coordinate of the current cell - virtual double getCoordinate(size_t i) const; - - /// Advance to the next cell. If the current cell is the last one in the workspace - /// do nothing and return false. - virtual bool next(); - - ///< return the current data pointer (index) - virtual size_t getPointer() const; - - private: - - const MDWorkspaceIndexCalculator m_indexCalculator; - size_t m_cur_pointer; - size_t m_end_pointer; - std::vector<size_t> m_index; - std::vector<boost::shared_ptr<Mantid::Geometry::IMDDimension> > m_dimensions; - - }; - } -} - -#endif diff --git a/Code/Mantid/Framework/MDDataObjects/src/MDWorkspaceIterator.cpp b/Code/Mantid/Framework/MDDataObjects/src/MDWorkspaceIterator.cpp deleted file mode 100644 index 0002f45314fe784aa0538bd826c8fd7eec17bbb3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDDataObjects/src/MDWorkspaceIterator.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "MDDataObjects/MDWorkspaceIterator.h" -namespace Mantid -{ - namespace MDDataObjects - { - - MDWorkspaceIterator::MDWorkspaceIterator(const MDWorkspaceIndexCalculator& indexCalculator, - - const std::vector<Mantid::Geometry::IMDDimension_sptr> dimensions): - - m_indexCalculator(indexCalculator),m_cur_pointer(),m_end_pointer(indexCalculator.getIndexUpperBounds()), m_dimensions(dimensions) - { - m_index.resize(indexCalculator.getNDimensions()); - indexCalculator.calculateDimensionIndexes(m_cur_pointer,m_index); - } - - MDWorkspaceIterator::~MDWorkspaceIterator() - { - - } - - size_t MDWorkspaceIterator::getDataSize()const - { - return m_indexCalculator.getIndexUpperBounds() + 1; - } - - double MDWorkspaceIterator::getCoordinate(size_t i)const - { - return m_dimensions[i]->getX(m_index[i]); - } - - bool MDWorkspaceIterator::next() - { - if (m_cur_pointer < m_end_pointer) - { - ++m_cur_pointer; - m_indexCalculator.calculateDimensionIndexes(m_cur_pointer,m_index); - return true; - } - return false; - } - - size_t MDWorkspaceIterator::getPointer()const - { - return m_cur_pointer; - } - - } -} diff --git a/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceIteratorTest.h b/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceIteratorTest.h deleted file mode 100644 index 63ac049da730f68b170cf34d066d9b528dbcfa44..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceIteratorTest.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef MDWORKSPACE_ITERATOR_TEST_H -#define MDWORKSPACE_ITERATOR_TEST_H - -#include <cxxtest/TestSuite.h> -#include "gtest/gtest.h" -#include "gmock/gmock.h" -#include "MDDataObjects/MDIndexCalculator.h" -#include "MDDataObjects/MDWorkspaceIterator.h" - -using Mantid::Geometry::IMDDimension_sptr; -using Mantid::MDDataObjects::MDWorkspaceIndexCalculator; -using Mantid::MDDataObjects::MDWorkspaceIterator; -using namespace testing; - -class MDWorkspaceIteratorTest : public CxxTest::TestSuite -{ - -private: - - /// Mock IMDDimension allows tests to specify exact expected behavior of dependency. - class MockIMDDimension : public Mantid::Geometry::IMDDimension { - public: - MOCK_CONST_METHOD0(getName, - std::string()); - MOCK_CONST_METHOD0(getUnits, - std::string()); - MOCK_CONST_METHOD0(getDimensionId, - std::string()); - MOCK_CONST_METHOD0(getMaximum, - double()); - MOCK_CONST_METHOD0(getMinimum, - double()); - MOCK_CONST_METHOD0(getNBins, - size_t()); - MOCK_CONST_METHOD0(toXMLString, - std::string()); - MOCK_CONST_METHOD1(getX, - double(size_t ind)); - MOCK_METHOD3(setRange, - void(size_t nBins, double min, double max)); - }; - -public: - typedef std::vector<IMDDimension_sptr> IMDDimension_sptr_vec; - - void testGetCoordinate() - { - int dimensionality = 2; - MockIMDDimension* pDimensionX = new MockIMDDimension(); - MockIMDDimension* pDimensionY = new MockIMDDimension(); - - EXPECT_CALL(*pDimensionX, getX(_)).Times(1); - EXPECT_CALL(*pDimensionY, getX(_)).Times(1); - IMDDimension_sptr_vec dimensions(dimensionality); - dimensions[0] = IMDDimension_sptr(pDimensionX); - dimensions[1] = IMDDimension_sptr(pDimensionY); - - MDWorkspaceIndexCalculator calculator(dimensionality, 10, 10); - MDWorkspaceIterator iterator(calculator, dimensions); - iterator.getCoordinate(0); // Of the 1st dimension should get the 2nd coordinate. - iterator.getCoordinate(1); // Of the 2nd dimension should get the 2nd coordinate. - TSM_ASSERT("Extracting coordinates has not utilized dimension x as expected.", Mock::VerifyAndClearExpectations(pDimensionX)); - TSM_ASSERT("Extracting coordinates has not utilized dimension y as expected.", Mock::VerifyAndClearExpectations(pDimensionY)); - } - - void testNext() - { - int dimensionality = 1; - MockIMDDimension* pDimensionX = new MockIMDDimension(); - - IMDDimension_sptr_vec dimensions(dimensionality); - dimensions[0] = IMDDimension_sptr(pDimensionX); - - MDWorkspaceIndexCalculator calculator(dimensionality, 3); // 100 cells. - MDWorkspaceIterator iterator(calculator, dimensions); - size_t valuePointerA = iterator.getPointer(); - iterator.next(); - size_t valuePointerB = iterator.getPointer(); - iterator.next(); - size_t valuePointerC = iterator.getPointer(); - - TS_ASSERT_EQUALS(0, valuePointerA); - TS_ASSERT_EQUALS(1, valuePointerB); - TS_ASSERT_EQUALS(2, valuePointerC); - TS_ASSERT_EQUALS(false, iterator.next()); - } - - void testLooping() - { - int dimensionality = 2; - MockIMDDimension* pDimensionX = new MockIMDDimension(); - MockIMDDimension* pDimensionY = new MockIMDDimension(); - - IMDDimension_sptr_vec dimensions(dimensionality); - dimensions[0] = IMDDimension_sptr(pDimensionX); - dimensions[1] = IMDDimension_sptr(pDimensionY); - - MDWorkspaceIndexCalculator calculator(dimensionality, 10, 10); // 100 cells. - MDWorkspaceIterator iterator(calculator, dimensions); - size_t valuePointer(0); - while(iterator.next()) - { - valuePointer = iterator.getPointer(); - } - // 0 to 100. expected value is 99 - TSM_ASSERT_EQUALS("Pointer does not have expected value after looping through entire workspace.", 99, valuePointer ); - } - - void testGetDataSize() - { - int dimensionality = 3; - MockIMDDimension* pDimensionX = new MockIMDDimension(); - MockIMDDimension* pDimensionY = new MockIMDDimension(); - MockIMDDimension* pDimensionZ = new MockIMDDimension(); - - IMDDimension_sptr_vec dimensions(dimensionality); - dimensions[0] = IMDDimension_sptr(pDimensionX); - dimensions[1] = IMDDimension_sptr(pDimensionY); - dimensions[2] = IMDDimension_sptr(pDimensionZ); - - MDWorkspaceIndexCalculator calculator(dimensionality, 10, 10, 10); // 1000 cells. - MDWorkspaceIterator iterator(calculator, dimensions); - - TSM_ASSERT_EQUALS("Incorrect data size calculated", 1000, iterator.getDataSize()); - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDEvents/CMakeLists.txt b/Code/Mantid/Framework/MDEvents/CMakeLists.txt index 1cd3f87b0dc89d277fa869d462a166a4ff44de68..1f633a8478cb13f75c9029ff0498d134c6d7255d 100644 --- a/Code/Mantid/Framework/MDEvents/CMakeLists.txt +++ b/Code/Mantid/Framework/MDEvents/CMakeLists.txt @@ -26,6 +26,7 @@ set ( SRC_FILES src/MDEventWorkspace.cpp src/MDGridBox.cpp src/MDHistoWorkspace.cpp + src/MDHistoWorkspaceIterator.cpp src/MDLeanEvent.cpp src/MergeMD.cpp src/OneStepMDEW.cpp @@ -74,6 +75,7 @@ set ( INC_FILES inc/MantidMDEvents/MDEventWorkspace.h inc/MantidMDEvents/MDGridBox.h inc/MantidMDEvents/MDHistoWorkspace.h + inc/MantidMDEvents/MDHistoWorkspaceIterator.h inc/MantidMDEvents/MDLeanEvent.h inc/MantidMDEvents/MergeMD.h inc/MantidMDEvents/OneStepMDEW.h @@ -111,6 +113,7 @@ set ( TEST_FILES test/MDEventTest.h test/MDEventWorkspaceTest.h test/MDGridBoxTest.h + test/MDHistoWorkspaceIteratorTest.h test/MDHistoWorkspaceTest.h test/MDLeanEventTest.h test/MergeMDTest.h diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h index fa66d64c8c97eeea6179f76f96c172593f401055..6f68a8c3c55a318314dcc114da8947cb470c971a 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h @@ -85,6 +85,7 @@ namespace MDEvents void applyImplicitFunction(Mantid::Geometry::MDImplicitFunction * function, signal_t signal, signal_t error); + coord_t * getVertexesArray(size_t linearIndex, size_t & numVertices) const; /// Sets the signal at the specified index. @@ -238,6 +239,9 @@ namespace MDEvents private: + + void initVertexesArray(); + /// Number of dimensions in this workspace size_t numDimensions; @@ -256,6 +260,17 @@ namespace MDEvents /// Inverse of the volume of EACH cell coord_t m_inverseVolume; + /// Pre-calculated vertexes array for the 0th box + coord_t * m_vertexesArray; + + /// Vector of the length of the box in each dimension + coord_t * m_boxLength; + + /// For converting to/from linear index to tdimensions + size_t * m_indexMaker; + /// Max index into each dimension + size_t * m_indexMax; + }; /// A shared pointer to a MDHistoWorkspace diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspaceIterator.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspaceIterator.h new file mode 100644 index 0000000000000000000000000000000000000000..13b84ad658e8b335ea640e0c5b3fd989b37c169d --- /dev/null +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspaceIterator.h @@ -0,0 +1,82 @@ +#ifndef MANTID_MDEVENTS_MDHISTOWORKSPACEITERATOR_H_ +#define MANTID_MDEVENTS_MDHISTOWORKSPACEITERATOR_H_ + +#include "MantidKernel/System.h" +#include "MantidAPI/IMDIterator.h" +#include "MantidMDEvents/MDHistoWorkspace.h" + + +namespace Mantid +{ +namespace MDEvents +{ + + /** An implementation of IMDIterator that iterates through + a MDHistoWorkspace. + + @author Janik Zikovsky + @date 2011-10-06 + + Copyright © 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> + Code Documentation is available at: <http://doxygen.mantidproject.org> + */ + class DLLExport MDHistoWorkspaceIterator : public Mantid::API::IMDIterator + { + public: + MDHistoWorkspaceIterator(MDHistoWorkspace_sptr workspace); + ~MDHistoWorkspaceIterator(); + + virtual bool next(); + + virtual signal_t getNormalizedSignal() const; + + virtual signal_t getNormalizedError() const; + + virtual coord_t * getVertexesArray(size_t & numVertices) const; + + virtual size_t getNumEvents() const; + + virtual uint16_t getInnerRunIndex(size_t index) const; + + virtual int32_t getInnerDetectorID(size_t index) const; + + virtual size_t getInnerPosition(size_t index, size_t dimension) const; + + virtual signal_t getInnerSignal(size_t index) const; + + virtual signal_t getInnerError(size_t index) const; + + protected: + /// The MDHistoWorkspace being iterated. + MDHistoWorkspace_sptr m_ws; + + /// The linear position/index into the MDHistoWorkspace. + uint64_t m_pos; + + /// The maximum linear index in the workspace + uint64_t m_max; + + }; + + +} // namespace MDEvents +} // namespace Mantid + +#endif /* MANTID_MDEVENTS_MDHISTOWORKSPACEITERATOR_H_ */ diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp index d0c3200239ca701ceac48d8b6654c3d0d2e21b3b..c4e40020adba7b213393d937a191d9221ad1f03c 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp @@ -1,10 +1,9 @@ -#include "MantidMDEvents/MDHistoWorkspace.h" -#include "MantidKernel/System.h" +#include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h" +#include "MantidKernel/System.h" #include "MantidKernel/Utils.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidMDEvents/MDHistoWorkspace.h" -using Mantid::Kernel::Utils::NestedForLoop::SetUp; using namespace Mantid::Kernel; using Mantid::Geometry::IMDDimension_sptr; using Mantid::Geometry::IMDDimension; @@ -42,6 +41,20 @@ namespace MDEvents this->init(dimensions); } + //---------------------------------------------------------------------------------------------- + /** Destructor + */ + MDHistoWorkspace::~MDHistoWorkspace() + { + delete [] m_signals; + delete [] m_errors; + delete [] indexMultiplier; + delete [] m_vertexesArray; + delete [] m_boxLength; + delete [] m_indexMaker; + delete [] m_indexMax; + } + //---------------------------------------------------------------------------------------------- /** Constructor helper method * @param dimensions :: vector of MDHistoDimension; no limit to how many. @@ -87,6 +100,9 @@ namespace MDEvents for (size_t i=0; i < numDimensions; ++i) volume *= dimensions[i]->getBinWidth(); m_inverseVolume = 1.0 / volume; + + // Continue with the vertexes array + this->initVertexesArray(); } @@ -136,14 +152,88 @@ namespace MDEvents } //---------------------------------------------------------------------------------------------- - /** Destructor - */ - MDHistoWorkspace::~MDHistoWorkspace() + /** After initialization, call this to initialize the vertexes array + * to the vertexes of the 0th box. + * Will be used by getVertexesArray() + * */ + void MDHistoWorkspace::initVertexesArray() { - delete [] m_signals; - delete [] m_errors; - delete [] indexMultiplier; + size_t nd = numDimensions; + // How many vertices does one box have? 2^nd, or bitwise shift left 1 by nd bits + size_t numVertices = 1 << numDimensions; + + // Allocate the array of the right size + m_vertexesArray = new coord_t[nd*numVertices]; + + // For each vertex, increase an integeer + for (size_t i=0; i<numVertices; ++i) + { + // Start point index in the output array; + size_t outIndex = i * nd; + + // Coordinates of the vertex + for (size_t d=0; d<nd; d++) + { + // Use a bit mask to look at each bit of the integer we are iterating through. + size_t mask = 1 << d; + if ((i & mask) > 0) + { + // Bit is 1, use the max of the dimension + m_vertexesArray[outIndex + d] = m_dimensions[d]->getX(1); + } + else + { + // Bit is 0, use the min of the dimension + m_vertexesArray[outIndex + d] = m_dimensions[d]->getX(0); + } + } // (for each dimension) + } + + // Now set the m_boxLength + m_boxLength = new coord_t[nd]; + for (size_t d=0; d<nd; d++) + m_boxLength[d] = m_dimensions[d]->getX(1) - m_dimensions[d]->getX(0); + + // The index calculator + m_indexMax = new size_t[numDimensions]; + for (size_t d=0; d<nd; d++) + m_indexMax[d] = m_dimensions[d]->getNBins(); + m_indexMaker = new size_t[numDimensions]; + Utils::NestedForLoop::SetUpIndexMaker(numDimensions, m_indexMaker, m_indexMax); + } + + //---------------------------------------------------------------------------------------------- + /** For the volume at the given linear index, + * Return the vertices of every corner of the box, as + * a bare array of length numVertices * nd + * + * @param linearIndex :: index into the workspace. Same as for getSignalAt(index) + * @param[out] numVertices :: returns the number of vertices in the array. + * @return the bare array. This should be deleted by the caller! + * */ + coord_t * MDHistoWorkspace::getVertexesArray(size_t linearIndex, size_t & numVertices) const + { + // How many vertices does one box have? 2^nd, or bitwise shift left 1 by nd bits + numVertices = 1 << numDimensions; + + // Index into each dimension. Built from the linearIndex. + size_t dimIndexes[10]; + Utils::NestedForLoop::GetIndicesFromLinearIndex(numDimensions, linearIndex, m_indexMaker, m_indexMax, dimIndexes); + + // The output vertexes coordinates + coord_t * out = new coord_t[numDimensions * numVertices]; + for (size_t i=0; i<numVertices; ++i) + { + size_t outIndex = i * numDimensions; + // Offset the 0th box by the position of this linear index, in each dimension + for (size_t d=0; d<numDimensions; d++) + out[outIndex+d] = m_vertexesArray[outIndex+d] + m_boxLength[d] * coord_t(dimIndexes[d]); + } + + return out; } + + //---------------------------------------------------------------------------------------------- /** Return the memory used, in bytes */ diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ec3985a408b29469d83d66c265b9a6b316e9245 --- /dev/null +++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp @@ -0,0 +1,113 @@ +#include "MantidMDEvents/MDHistoWorkspaceIterator.h" +#include "MantidKernel/System.h" + +using namespace Mantid::Kernel; +using namespace Mantid::API; + +namespace Mantid +{ +namespace MDEvents +{ + + + //---------------------------------------------------------------------------------------------- + /** Constructor + * + * @param workspace :: MDHistoWorkspace_sptr being iterated + * @return + */ + MDHistoWorkspaceIterator::MDHistoWorkspaceIterator(MDHistoWorkspace_sptr workspace) + : m_ws(workspace), m_pos(0) + { + if (!m_ws) + throw std::invalid_argument("MDHistoWorkspaceIterator::ctor(): NULL workspace given."); + m_max = m_ws->getNPoints(); + } + + //---------------------------------------------------------------------------------------------- + /** Destructor + */ + MDHistoWorkspaceIterator::~MDHistoWorkspaceIterator() + { + } + + + + //---------------------------------------------------------------------------------------------- + /// Advance to the next cell. If the current cell is the last one in the workspace + /// do nothing and return false. + /// @return true if you can continue iterating + bool MDHistoWorkspaceIterator::next() + { + return (++m_pos < m_max); + } + + //---------------------------------------------------------------------------------------------- + /// Returns the normalized signal for this box + signal_t MDHistoWorkspaceIterator::getNormalizedSignal() const + { + return m_ws->getSignalNormalizedAt(m_pos); + } + + /// Returns the normalized error for this box + signal_t MDHistoWorkspaceIterator::getNormalizedError() const + { + return m_ws->getErrorNormalizedAt(m_pos); + } + + //---------------------------------------------------------------------------------------------- + /// Return a list of vertexes defining the volume pointed to + coord_t * MDHistoWorkspaceIterator::getVertexesArray(size_t & numVertices) const + { + // The MDHistoWorkspace takes care of this + return m_ws->getVertexesArray(m_pos, numVertices); + } + + + //---------------------------------------------------------------------------------------------- + /// Returns the number of events/points contained in this box + size_t MDHistoWorkspaceIterator::getNumEvents() const + { + // There are no events contained - this is a binned workspace + return 0; + } + + //---------------------------------------------------------------------------------------------- + /// For a given event/point in this box, return the run index + uint16_t MDHistoWorkspaceIterator::getInnerRunIndex(size_t index) const + { + UNUSED_ARG(index); + throw std::runtime_error("MDHistoWorkspaceIterator: No events are contained, so it is not possible to return inner run index."); + } + + /// For a given event/point in this box, return the detector ID + int32_t MDHistoWorkspaceIterator::getInnerDetectorID(size_t index) const + { + UNUSED_ARG(index); + throw std::runtime_error("MDHistoWorkspaceIterator: No events are contained, so it is not possible to return inner detector ID."); + } + + /// Returns the position of a given event for a given dimension + size_t MDHistoWorkspaceIterator::getInnerPosition(size_t index, size_t dimension) const + { + UNUSED_ARG(index); UNUSED_ARG(dimension); + throw std::runtime_error("MDHistoWorkspaceIterator: No events are contained, so it is not possible to return inner position."); + } + + /// Returns the signal of a given event + signal_t MDHistoWorkspaceIterator::getInnerSignal(size_t index) const + { + UNUSED_ARG(index); + throw std::runtime_error("MDHistoWorkspaceIterator: No events are contained, so it is not possible to return inner signal."); + } + + /// Returns the error of a given event + signal_t MDHistoWorkspaceIterator::getInnerError(size_t index) const + { + UNUSED_ARG(index); + throw std::runtime_error("MDHistoWorkspaceIterator: No events are contained, so it is not possible to return inner error."); + } + +} // namespace Mantid +} // namespace MDEvents + diff --git a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceIteratorTest.h b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceIteratorTest.h new file mode 100644 index 0000000000000000000000000000000000000000..c03f02c016f81973e020abf2d9522c2c9ca55217 --- /dev/null +++ b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceIteratorTest.h @@ -0,0 +1,34 @@ +#ifndef MANTID_MDEVENTS_MDHISTOWORKSPACEITERATORTEST_H_ +#define MANTID_MDEVENTS_MDHISTOWORKSPACEITERATORTEST_H_ + +#include <cxxtest/TestSuite.h> +#include "MantidKernel/Timer.h" +#include "MantidKernel/System.h" +#include <iostream> +#include <iomanip> + +#include "MantidMDEvents/MDHistoWorkspaceIterator.h" + +using namespace Mantid; +using namespace Mantid::MDEvents; +using namespace Mantid::API; + +class MDHistoWorkspaceIteratorTest : public CxxTest::TestSuite +{ +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static MDHistoWorkspaceIteratorTest *createSuite() { return new MDHistoWorkspaceIteratorTest(); } + static void destroySuite( MDHistoWorkspaceIteratorTest *suite ) { delete suite; } + + + void test_Something() + { + } + + +}; + + +#endif /* MANTID_MDEVENTS_MDHISTOWORKSPACEITERATORTEST_H_ */ + diff --git a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h index aaa387f0529379fea268a6cb57cb45bc34814e66..90eb565d7700d11bbc5dee2fdec2d8fcfc6fd35a 100644 --- a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h +++ b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h @@ -146,6 +146,68 @@ public: } + //--------------------------------------------------------------------------------------------------- + void test_getVertexesArray_1D() + { + MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", "m", -10, 10, 5)); + MDHistoWorkspace ws(dimX); + coord_t * v; + size_t numVertices; + v = ws.getVertexesArray(0,numVertices); + TS_ASSERT_EQUALS( numVertices, 2 ); + TS_ASSERT_DELTA( v[0], -10.0, 1e-5); + TS_ASSERT_DELTA( v[1], -6.0, 1e-5); + + v = ws.getVertexesArray(4,numVertices); + TS_ASSERT_DELTA( v[0], 6.0, 1e-5); + TS_ASSERT_DELTA( v[1], 10.0, 1e-5); + } + + //--------------------------------------------------------------------------------------------------- + void test_getVertexesArray_2D() + { + MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", "m", -10, 10, 5)); + MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", "m", -10, 10, 5)); + MDHistoWorkspace ws(dimX, dimY); + coord_t * v; + size_t numVertices, i; + + v = ws.getVertexesArray(0,numVertices); + TS_ASSERT_EQUALS( numVertices, 4 ); + i = 0*2; + TS_ASSERT_DELTA( v[i+0], -10.0, 1e-5); + TS_ASSERT_DELTA( v[i+1], -10.0, 1e-5); + i = 3*2; + TS_ASSERT_DELTA( v[i+0], -6.0, 1e-5); + TS_ASSERT_DELTA( v[i+1], -6.0, 1e-5); + // The opposite corner + v = ws.getVertexesArray(24,numVertices); + i = 0*2; + TS_ASSERT_DELTA( v[i+0], 6.0, 1e-5); + TS_ASSERT_DELTA( v[i+1], 6.0, 1e-5); + i = 3*2; + TS_ASSERT_DELTA( v[i+0], 10.0, 1e-5); + TS_ASSERT_DELTA( v[i+1], 10.0, 1e-5); + } + + //--------------------------------------------------------------------------------------------------- + void test_getVertexesArray_3D() + { + MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", "m", -10, 10, 5)); + MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", "m", -9, 10, 5)); + MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", "m", -8, 10, 5)); + MDHistoWorkspace ws(dimX, dimY, dimZ); + coord_t * v; + size_t numVertices, i; + + v = ws.getVertexesArray(0,numVertices); + TS_ASSERT_EQUALS( numVertices, 8 ); + i = 0; + TS_ASSERT_DELTA( v[i+0], -10.0, 1e-5); + TS_ASSERT_DELTA( v[i+1], -9.0, 1e-5); + TS_ASSERT_DELTA( v[i+2], -8.0, 1e-5); + } + //--------------------------------------------------------------------------------------------------- /** Test for a possible seg-fault if nx != ny etc. */ diff --git a/Code/Mantid/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Code/Mantid/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index c1a2092390a6225abf97b9e573e3c03fe9942a36..99525678d9bfa66af36da66c3078aa1220da362e 100644 --- a/Code/Mantid/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Code/Mantid/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -42,6 +42,9 @@ namespace MDEventsTestHelper */ DLL_TESTHELPERS Mantid::MDEvents::MDEventWorkspace3Lean::sptr makeFileBackedMDEW(std::string wsName, bool fileBacked); + /// Make a fake n-dimensional MDHistoWorkspace + DLL_TESTHELPERS Mantid::MDEvents::MDHistoWorkspace_sptr makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10); + //------------------------------------------------------------------------------------- /** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc. diff --git a/Code/Mantid/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Code/Mantid/Framework/TestHelpers/src/MDEventsTestHelper.cpp index e8748a3402ad54cc66f99f8bac7d2b0538e65993..1bd1e141d5727815226325f4e4f104c0fd137518 100644 --- a/Code/Mantid/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Code/Mantid/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -12,6 +12,7 @@ #include "MantidTestHelpers/MDEventsTestHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidAPI/FrameworkManager.h" +#include "MantidGeometry/MDGeometry/MDHistoDimension.h" using Mantid::DataObjects::EventWorkspace_sptr; @@ -19,6 +20,8 @@ using Mantid::Kernel::DateAndTime; using Mantid::DataHandling::LoadInstrument; using Mantid::DataObjects::EventWorkspace; using Mantid::API::FrameworkManager; +using Mantid::Geometry::MDHistoDimension_sptr; +using Mantid::Geometry::MDHistoDimension; namespace Mantid { @@ -192,6 +195,49 @@ namespace MDEventsTestHelper + /** Creates a fake MDHistoWorkspace + * + * @param signal :: signal and error squared in every point + * @param numDims :: number of dimensions to create. They will range from 0 to 10 + * @param numBins :: bins in each dimensions + * @return the MDHisto + */ + Mantid::MDEvents::MDHistoWorkspace_sptr makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins) + { + Mantid::MDEvents::MDHistoWorkspace * ws; + if (numDims ==1) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)) ); + } + else if (numDims == 2) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)) ); + } + else if (numDims == 3) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("z","z","m", 0.0, 10.0, numBins)) ); + } + else if (numDims == 4) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("z","z","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("t","z","m", 0.0, 10.0, numBins)) + ); + } + Mantid::MDEvents::MDHistoWorkspace_sptr ws_sptr(ws); + ws_sptr->setTo(signal, signal); + return ws_sptr; + } + + } // namespace } } diff --git a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h index 2bf8a12e756667c661ed1743bb4db5b0e9a68f0b..13c15923995ffdcfabec7d952afe173a22d9e212 100644 --- a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h +++ b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h @@ -253,41 +253,6 @@ class FakeProgressAction : public Mantid::VATES::ProgressAction } }; -Mantid::MDEvents::MDHistoWorkspace_sptr getFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10) -{ - Mantid::MDEvents::MDHistoWorkspace * ws; - if (numDims ==1) - { - ws = new Mantid::MDEvents::MDHistoWorkspace( - MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)) ); - } - else if (numDims == 2) - { - ws = new Mantid::MDEvents::MDHistoWorkspace( - MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)) ); - } - else if (numDims == 3) - { - ws = new Mantid::MDEvents::MDHistoWorkspace( - MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("z","z","m", 0.0, 10.0, numBins)) ); - } - else if (numDims == 4) - { - ws = new Mantid::MDEvents::MDHistoWorkspace( - MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("z","z","m", 0.0, 10.0, numBins)), - MDHistoDimension_sptr(new MDHistoDimension("t","z","m", 0.0, 10.0, numBins)) - ); - } - Mantid::MDEvents::MDHistoWorkspace_sptr ws_sptr(ws); - ws_sptr->setTo(signal, signal); - return ws_sptr; -} - vtkFieldData* createFieldDataWithCharArray(std::string testData) { vtkFieldData* fieldData = vtkFieldData::New(); diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h index d2a7cb48b7179941f9e13e187cd33fb6e8a9d223..d5ebf3b7e0ca3fbaf7aebb1d1364ef4178d395f1 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h @@ -8,9 +8,16 @@ #include "MantidVatesAPI/TimeStepToTimeStep.h" #include "MockObjects.h" #include "MantidMDEvents/MDHistoWorkspace.h" +#include "MantidTestHelpers/MDEventsTestHelper.h" using namespace Mantid; +using namespace Mantid::API; +using namespace Mantid::Geometry; using namespace Mantid::MDEvents; +using namespace Mantid::VATES; +using namespace testing; +using Mantid::MDEvents::MDEventsTestHelper::makeFakeMDHistoWorkspace; + //===================================================================================== // Functional Tests @@ -22,11 +29,7 @@ public: void testCopy() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factoryA = @@ -46,11 +49,7 @@ public: void testAssignment() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factoryA = @@ -74,11 +73,7 @@ public: void testMeshOnly() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -95,11 +90,7 @@ public: void testMeshOnlyCausesThrow() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -111,12 +102,9 @@ public: void testSignalAspects() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; TimeStepToTimeStep timeMapper; - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -134,9 +122,6 @@ public: void testIsValidThrowsWhenNoWorkspace() { - using namespace Mantid::VATES; - using namespace Mantid::API; - IMDWorkspace* nullWorkspace = NULL; Mantid::API::IMDWorkspace_sptr ws_sptr(nullWorkspace); @@ -147,11 +132,6 @@ public: void testIsValidThrowsWhenNoTDimension() { - using namespace Mantid::VATES; - using namespace Mantid::API; - using namespace Mantid::Geometry; - using namespace testing; - IMDDimension* nullDimension = NULL; MockIMDWorkspace* pMockWs = new MockIMDWorkspace; pMockWs->addDimension(nullDimension); @@ -164,7 +144,6 @@ public: void testTypeName() { - using namespace Mantid::VATES; vtkStructuredGridFactory<TimeStepToTimeStep> factory("signal", 1); TS_ASSERT_EQUALS("vtkStructuredGridFactory", factory.getFactoryTypeName()); } @@ -181,21 +160,12 @@ public: void setUp() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // 4D, 100 bins per side - ws_sptr = getFakeMDHistoWorkspace(1.0, 4, 100); + ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4, 100); } void testGenerateVTKDataSet() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = vtkStructuredGridFactory<TimeStepToTimeStep>::constructAsMeshOnly(); diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h index c9ffb0853fa22471e9fe6b877c583a8aeac14a30..b3326a22f570cbd702085471e0d0ed2243a8b5ca 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h @@ -2,6 +2,7 @@ #define VTK_THRESHOLDING_HEXAHEDRON_FACTORY_TEST_H_ #include "MantidMDEvents/MDHistoWorkspace.h" +#include "MantidTestHelpers/MDEventsTestHelper.h" #include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MantidVatesAPI/vtkThresholdingHexahedronFactory.h" #include "MockObjects.h" @@ -10,7 +11,11 @@ #include <gtest/gtest.h> using namespace Mantid; +using namespace Mantid::API; using namespace Mantid::MDEvents; +using namespace Mantid::VATES; +using namespace Mantid::Geometry; +using namespace testing; //===================================================================================== // Functional Tests @@ -22,12 +27,8 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testThresholds() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // Workspace with value 1.0 everywhere - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3); ws_sptr->setTransformFromOriginal(new NullCoordTransform); vtkThresholdingHexahedronFactory inside(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 2)), "signal"); @@ -49,12 +50,8 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testSignalAspects() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // Workspace with value 1.0 everywhere - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3); ws_sptr->setTransformFromOriginal(new NullCoordTransform); //Constructional method ensures that factory is only suitable for providing mesh information. @@ -72,9 +69,6 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testIsValidThrowsWhenNoWorkspace() { - using namespace Mantid::VATES; - using namespace Mantid::API; - IMDWorkspace* nullWorkspace = NULL; Mantid::API::IMDWorkspace_sptr ws_sptr(nullWorkspace); @@ -85,21 +79,18 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testCreateMeshOnlyThrows() { - using namespace Mantid::VATES; vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); TS_ASSERT_THROWS(factory.createMeshOnly() , std::runtime_error); } void testCreateScalarArrayThrows() { - using namespace Mantid::VATES; vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); TS_ASSERT_THROWS(factory.createScalarArray() , std::runtime_error); } void testCreateWithoutInitializeThrows() { - using namespace Mantid::VATES; vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); TS_ASSERT_THROWS(factory.create(), std::runtime_error); } @@ -107,11 +98,7 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testInitializationDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -131,11 +118,7 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testInitializationDelegatesThrows() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization. If there is no successor an exception should be thrown. - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); @@ -146,12 +129,8 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite void testCreateDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - //2 dimensions on the workspace. - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -193,12 +172,8 @@ public: void setUp() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - //Create the workspace. 20 bins in each dimension. - m_ws_sptr = getFakeMDHistoWorkspace(1.0, 3, 100); + m_ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3, 100); m_ws_sptr->setTransformFromOriginal(new NullCoordTransform); // MockIMDWorkspace* pMockWs = new MockIMDWorkspace; @@ -215,8 +190,6 @@ public: void testGenerateHexahedronVtkDataSet() { - using namespace Mantid::VATES; - //Create the factory. vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); factory.initialize(m_ws_sptr); diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h index f61ad5cf62510c9bc237ab5b0811fdd51794f616..9625c038d1adcfd80f23b539057dfda15dd19207 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h @@ -1,18 +1,23 @@ #ifndef VTK_THRESHOLDING_LINE_FACTORY_TEST_H #define VTK_THRESHOLDING_LINE_FACTORY_TEST_H -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> #include "MantidAPI/IMDIterator.h" -#include "MantidVatesAPI/vtkThresholdingLineFactory.h" -#include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MantidGeometry/MDGeometry/MDPoint.h" +#include "MantidTestHelpers/MDEventsTestHelper.h" +#include "MantidVatesAPI/UserDefinedThresholdRange.h" +#include "MantidVatesAPI/vtkThresholdingLineFactory.h" #include "MDDataObjects/MDIndexCalculator.h" #include "MockObjects.h" +#include <cxxtest/TestSuite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> using namespace Mantid; +using namespace Mantid::MDEvents; +using namespace Mantid::API; +using namespace Mantid::Geometry; using namespace Mantid::VATES; +using namespace testing; //===================================================================================== @@ -37,9 +42,6 @@ public: void testIsValidThrowsWhenNoWorkspace() { - using namespace Mantid::VATES; - using namespace Mantid::API; - IMDWorkspace* nullWorkspace = NULL; Mantid::API::IMDWorkspace_sptr ws_sptr(nullWorkspace); @@ -56,10 +58,7 @@ public: void testInsideThresholds() { - using namespace Mantid::Geometry; - using namespace testing; - - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall between the minimum 0 and maximum 2. vtkThresholdingLineFactory inside(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 2)), "signal"); @@ -75,7 +74,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall above and outside the minimum 0 and maximum 0.5. vtkThresholdingLineFactory above(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 0.5)), "signal"); @@ -88,10 +87,7 @@ public: void testBelowThreshold() { - using namespace Mantid::Geometry; - using namespace testing; - - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall below and outside the minimum 1.5 and maximum 2. vtkThresholdingLineFactory below(ThresholdRange_scptr(new UserDefinedThresholdRange(1.5, 2)), "signal"); @@ -105,12 +101,8 @@ public: void testInitializationDelegates() { //If the workspace provided is not a 1D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // 3 dimensions on the workspace - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -129,12 +121,8 @@ public: void testInitializationDelegatesThrows() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization. If there is no successor an exception should be thrown. - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // 3 dimensions on the workspace - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3); //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingLineFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)),"signal"); @@ -145,12 +133,8 @@ public: void testCreateDelegates() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // 3 dimensions on the workspace - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 3); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -171,7 +155,6 @@ public: void testTypeName() { - using namespace Mantid::VATES; vtkThresholdingLineFactory factory (ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)),"signal"); TS_ASSERT_EQUALS("vtkThresholdingLineFactory", factory.getFactoryTypeName()); } @@ -190,11 +173,8 @@ public: void setUp() { - using namespace Mantid::Geometry; - using namespace testing; - //1D Workspace with 2000 points - m_ws_sptr = getFakeMDHistoWorkspace(1.0, 1, 2000); + m_ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1, 2000); } void testGenerateVTKDataSet() diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h index a48e58a45bae4efd499e9652d975eb4463518e0b..ec3f50fbcc8df784dfbd925fa2aee34ce8358965 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h @@ -1,18 +1,24 @@ #ifndef VTK_THRESHOLDING_QUAD_FACTORY_TEST_H #define VTK_THRESHOLDING_QUAD_FACTORY_TEST_H -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> #include "MantidAPI/IMDIterator.h" -#include "MantidVatesAPI/vtkThresholdingQuadFactory.h" -#include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MantidGeometry/MDGeometry/MDPoint.h" +#include "MantidTestHelpers/MDEventsTestHelper.h" +#include "MantidVatesAPI/UserDefinedThresholdRange.h" +#include "MantidVatesAPI/vtkThresholdingQuadFactory.h" #include "MDDataObjects/MDIndexCalculator.h" #include "MockObjects.h" +#include <cxxtest/TestSuite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> using namespace Mantid; +using namespace Mantid::MDEvents; +using namespace Mantid::API; +using namespace Mantid::Geometry; using namespace Mantid::VATES; +using namespace testing; +using Mantid::MDEvents::MDEventsTestHelper::makeFakeMDHistoWorkspace; //===================================================================================== @@ -59,11 +65,8 @@ public: void testInsideThresholds() { - using namespace Mantid::Geometry; - using namespace testing; - // WS with 2 dimensions - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall between the minimum 0 and maximum 2. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 2); @@ -77,11 +80,8 @@ public: void testAboveThreshold() { - using namespace Mantid::Geometry; - using namespace testing; - // WS with 2 dimensions - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall above and outside the minimum 0 and maximum 0.5. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 0.5); @@ -96,11 +96,8 @@ public: void testBelowThreshold() { - using namespace Mantid::Geometry; - using namespace testing; - // WS with 2 dimensions - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall below and outside the minimum 1.5 and maximum 2. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(1.5, 2); @@ -117,12 +114,8 @@ public: void testInitializationDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // WS with 1 dimension - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); @@ -143,12 +136,8 @@ public: void testInitializationDelegatesThrows() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization. If there is no successor an exception should be thrown. - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // WS with 1 dimension - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); //Constructional method ensures that factory is only suitable for providing mesh information. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 1); @@ -160,12 +149,8 @@ public: void testCreateDelegates() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // WS with 1 dimension - Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); + Mantid::API::IMDWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -188,7 +173,6 @@ public: void testTypeName() { - using namespace Mantid::VATES; UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 1); vtkThresholdingQuadFactory factory(ThresholdRange_scptr(pRange), "signal"); TS_ASSERT_EQUALS("vtkThresholdingQuadFactory", factory.getFactoryTypeName()); @@ -208,11 +192,8 @@ public: void setUp() { - using namespace Mantid::Geometry; - using namespace testing; - // WS with 2 dimension, 100x100 - m_ws_sptr = getFakeMDHistoWorkspace(1.0, 2, 100); + m_ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2, 100); m_ws_sptr->setTransformFromOriginal(new NullCoordTransform); } diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h index 9fcb41884e2451d9571dd1089aec9f1c61e1569d..dcb331880e69adb8e9208181236bb3c17e82051f 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h @@ -1,15 +1,16 @@ #ifndef VTK_THRESHOLDING_UNSTRUCTURED_GRID_FACTORY_TEST_H_ #define VTK_THRESHOLDING_UNSTRUCTURED_GRID_FACTORY_TEST_H_ -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> -#include "MantidVatesAPI/vtkThresholdingUnstructuredGridFactory.h" +#include "MantidAPI/IMDWorkspace.h" +#include "MantidMDEvents/MDHistoWorkspace.h" +#include "MantidTestHelpers/MDEventsTestHelper.h" #include "MantidVatesAPI/TimeStepToTimeStep.h" #include "MantidVatesAPI/UserDefinedThresholdRange.h" +#include "MantidVatesAPI/vtkThresholdingUnstructuredGridFactory.h" #include "MockObjects.h" -#include "MantidMDEvents/MDHistoWorkspace.h" -#include "MantidAPI/IMDWorkspace.h" +#include <cxxtest/TestSuite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> using namespace Mantid; using namespace Mantid::MDEvents; @@ -29,7 +30,7 @@ public: void testThresholds() { // Workspace with value 1.0 everywhere - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); ws_sptr->setTransformFromOriginal(new NullCoordTransform); //Set up so that only cells with signal values == 1 should not be filtered out by thresholding. @@ -54,7 +55,7 @@ public: void testSignalAspects() { // Workspace with value 1.0 everywhere - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4); ws_sptr->setTransformFromOriginal(new NullCoordTransform); UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); @@ -108,7 +109,7 @@ public: { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization // 2D workspace - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -132,7 +133,7 @@ public: { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization. If there is no successor an exception should be thrown. // 2D workspace - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); @@ -147,7 +148,7 @@ public: { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization // 2D workspace - MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); + MDHistoWorkspace_sptr ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. @@ -196,7 +197,7 @@ public: void setUp() { //Create a 4D workspace 50 ^ 4 - m_ws_sptr = getFakeMDHistoWorkspace(1.0, 4, 50); + m_ws_sptr = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 4, 50); m_ws_sptr->setTransformFromOriginal(new NullCoordTransform); }