diff --git a/Code/Mantid/Framework/Algorithms/src/CropWorkspace.cpp b/Code/Mantid/Framework/Algorithms/src/CropWorkspace.cpp index 3a2fdbc021e5a200f6fbb6d69f70134b7d7d89c8..bd456ad236df9a89f1c61c647e600037734f3768 100644 --- a/Code/Mantid/Framework/Algorithms/src/CropWorkspace.cpp +++ b/Code/Mantid/Framework/Algorithms/src/CropWorkspace.cpp @@ -270,7 +270,16 @@ void CropWorkspace::execEvent() std::set<detid_t>& dets = eventW->getEventList(i).getDetectorIDs(); std::set<detid_t>::iterator k; for (k = dets.begin(); k != dets.end(); ++k) + { outEL.addDetectorID(*k); + } + // Spectrum number + ISpectrum * inSpec = m_inputWorkspace->getSpectrum(i); + ISpectrum * outSpec = outputWorkspace->getSpectrum(j); + if( inSpec && outSpec ) + { + outSpec->setSpectrumNo(inSpec->getSpectrumNo()); + } if (!m_commonBoundaries) // If the X axis is NOT common, then keep the initial X axis, just clear the events @@ -302,6 +311,9 @@ void CropWorkspace::execEvent() } PARALLEL_CHECK_INTERUPT_REGION + if( m_inputWorkspace->axes() > 1 && m_inputWorkspace->getAxis(1)->isSpectra() ) + // Backwards compatability while the spectra axis is still here + outputWorkspace->generateSpectraMap(); setProperty("OutputWorkspace", boost::dynamic_pointer_cast<MatrixWorkspace>(outputWorkspace)); } diff --git a/Code/Mantid/Framework/Algorithms/src/ExtractSingleSpectrum.cpp b/Code/Mantid/Framework/Algorithms/src/ExtractSingleSpectrum.cpp index 3e07f4d83b4647891a8fea8a829ec69ad00a2d22..1f6087e33881ead22d4858d29afa7b9599ef8278 100644 --- a/Code/Mantid/Framework/Algorithms/src/ExtractSingleSpectrum.cpp +++ b/Code/Mantid/Framework/Algorithms/src/ExtractSingleSpectrum.cpp @@ -36,52 +36,22 @@ void ExtractSingleSpectrum::init() void ExtractSingleSpectrum::exec() { // Get hold of the input workspace - MatrixWorkspace_const_sptr inputWorkspace = getProperty("InputWorkspace"); - // Get the desired spectrum number and check it's in range - const int desiredSpectrum = getProperty("WorkspaceIndex"); - if ( desiredSpectrum >= static_cast<int>(inputWorkspace->getNumberHistograms()) ) + MatrixWorkspace_sptr inputWorkspace = getProperty("InputWorkspace"); + const int indexToExtract = getProperty("WorkspaceIndex"); + const size_t numHist = inputWorkspace->getNumberHistograms(); + if( static_cast<size_t>(indexToExtract) >= numHist ) { - g_log.error("WorkspaceIndex is greater than the number of entries in this workspace."); - throw Exception::IndexError(desiredSpectrum,inputWorkspace->getNumberHistograms(),this->name()); + throw Exception::IndexError(indexToExtract,inputWorkspace->getNumberHistograms(),this->name()); } - // Now create a single spectrum workspace for the output - MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(inputWorkspace,1,inputWorkspace->readX(0).size(),inputWorkspace->blocksize()); - - progress(0.5); - // Copy in the data and spectrum number of the appropriate spectrum - outputWorkspace->dataX(0) = inputWorkspace->readX(desiredSpectrum); - outputWorkspace->dataY(0) = inputWorkspace->readY(desiredSpectrum); - outputWorkspace->dataE(0) = inputWorkspace->readE(desiredSpectrum); - // If Axis 1 on the original is a spectra axis copy over the correct spectrum number - const Axis * axisOne = inputWorkspace->getAxis(1); - if( axisOne->isSpectra() ) - { - const specid_t outSpecNo = inputWorkspace->getAxis(1)->spectraNo(desiredSpectrum); - outputWorkspace->getAxis(1)->spectraNo(0) = outSpecNo; - ISpectrum* outSpec = outputWorkspace->getSpectrum(0); - // Also set the spectrum number to the group number - outSpec->setSpectrumNo(outSpecNo); - outSpec->clearDetectorIDs(); - const ISpectrum* inSpec = inputWorkspace->getSpectrum(desiredSpectrum); - // Add the detectors for this spectrum to the output workspace's spectra-detector map - outSpec->addDetectorIDs( inSpec->getDetectorIDs() ); - } - else - { - if( axisOne->isNumeric() ) - { - outputWorkspace->getAxis(1)->setValue(0, axisOne->operator()(desiredSpectrum)); - } - else - { - TextAxis *txtAxis = dynamic_cast<TextAxis*>(outputWorkspace->getAxis(1)); - txtAxis->setLabel(0, axisOne->label(desiredSpectrum)); - } - } + // Let crop do the rest + IAlgorithm_sptr cropper = this->createSubAlgorithm("CropWorkspace", 0.0, 1.0); + cropper->setProperty("InputWorkspace", inputWorkspace); + cropper->setProperty("StartWorkspaceIndex", indexToExtract); + cropper->setProperty("EndWorkspaceIndex", indexToExtract); + cropper->executeAsSubAlg(); - setProperty("OutputWorkspace",outputWorkspace); - progress(1.0); + setProperty<MatrixWorkspace_sptr>("OutputWorkspace", cropper->getProperty("OutputWorkspace")); } } // namespace Algorithms diff --git a/Code/Mantid/Framework/Algorithms/test/ExtractSingleSpectrumTest.h b/Code/Mantid/Framework/Algorithms/test/ExtractSingleSpectrumTest.h index 9e187f089efd4bd5a64db74d2ffc00de7c94e9b6..d7afc8541ffa54d5aa3a442635bc3644e4ec6e43 100644 --- a/Code/Mantid/Framework/Algorithms/test/ExtractSingleSpectrumTest.h +++ b/Code/Mantid/Framework/Algorithms/test/ExtractSingleSpectrumTest.h @@ -1,7 +1,7 @@ #ifndef EXTRACTSINGLESPECTRUMTEST_H_ #define EXTRACTSINGLESPECTRUMTEST_H_ -#include "CropWorkspaceTest.h" // Use the test lable functionality as it should do the same thing +#include "CropWorkspaceTest.h" // Use the test label functionality as it should do the same thing #include "MantidAlgorithms/ExtractSingleSpectrum.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -12,34 +12,35 @@ class ExtractSingleSpectrumTest : public CxxTest::TestSuite public: void testName() { - TS_ASSERT_EQUALS( extractor.name(), "ExtractSingleSpectrum" ) + IAlgorithm *nameTester = createExtractSingleSpectrum(); + TS_ASSERT_EQUALS( nameTester->name(), "ExtractSingleSpectrum" ); } void testVersion() { - TS_ASSERT_EQUALS( extractor.version(), 1 ) + IAlgorithm *versionTester = createExtractSingleSpectrum(); + TS_ASSERT_EQUALS( versionTester->version(), 1 ); } void testCategory() { - TS_ASSERT_EQUALS( extractor.category(), "General" ) + IAlgorithm *catTester = createExtractSingleSpectrum(); + TS_ASSERT_EQUALS( catTester->category(), "General" ); } void testInit() { - TS_ASSERT_THROWS_NOTHING( extractor.initialize() ) - TS_ASSERT( extractor.isInitialized() ) - - TS_ASSERT_EQUALS( extractor.getProperties().size(), 3 ) + IAlgorithm *initTester = createExtractSingleSpectrum(); + TS_ASSERT_THROWS_NOTHING( initTester->initialize() ); + TS_ASSERT( initTester->isInitialized() ); + TS_ASSERT_EQUALS( initTester->getProperties().size(), 3 ); } void testExec() { using namespace Mantid::API; - const int nbins(5); MatrixWorkspace_sptr inputWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(5,nbins); - const int wsIndex = 2; for (int i=0; i<nbins+1; ++i) { @@ -50,23 +51,12 @@ public: inputWS->dataE(wsIndex)[i] = 7; } } - inputWS->getAxis(1)->spectraNo(wsIndex) = wsIndex; - AnalysisDataService::Instance().add("input",inputWS); - - TS_ASSERT_THROWS_NOTHING( extractor.setPropertyValue("InputWorkspace","input") ) - TS_ASSERT_THROWS_NOTHING( extractor.setPropertyValue("OutputWorkspace","output") ) - TS_ASSERT_THROWS_NOTHING( extractor.setProperty("WorkspaceIndex",wsIndex) ) - - TS_ASSERT_THROWS_NOTHING( extractor.execute() ) - TS_ASSERT( extractor.isExecuted() ) - - Workspace_const_sptr output; - TS_ASSERT_THROWS_NOTHING( output = AnalysisDataService::Instance().retrieve("output"); ) - MatrixWorkspace_const_sptr outputWS; - TS_ASSERT( outputWS = boost::dynamic_pointer_cast<const MatrixWorkspace>(output) ) - TS_ASSERT_EQUALS( outputWS->blocksize(), 5 ) - TS_ASSERT_EQUALS( outputWS->readX(0).size(), nbins+1) - TS_ASSERT_EQUALS( outputWS->getAxis(1)->spectraNo(0), wsIndex ) + MatrixWorkspace_sptr outputWS = runAlgorithm(inputWS, wsIndex); + + TS_ASSERT(outputWS); + TS_ASSERT_EQUALS( outputWS->blocksize(), 5 ); + TS_ASSERT_EQUALS( outputWS->readX(0).size(), nbins+1); + TS_ASSERT_EQUALS( outputWS->getAxis(1)->spectraNo(0), wsIndex + 1); for (int j=0; j<nbins+1; ++j) { TS_ASSERT_EQUALS( outputWS->readX(0)[j], j ); @@ -76,36 +66,81 @@ public: TS_ASSERT_EQUALS( outputWS->readE(0)[j], 7 ); } } + do_Spectrum_Tests(outputWS, 3, 3); + } + void test_Input_With_TextAxis() + { + Algorithm *extractorWithText = new ExtractSingleSpectrum; + extractorWithText->initialize(); + extractorWithText->setPropertyValue("WorkspaceIndex", "1"); + CropWorkspaceTest::doTestWithTextAxis(extractorWithText); //Takes ownership + } + + void test_Input_With_Event_Workspace() + { + // Create and input event workspace + const int eventsPerPixel(25); + const int numPixels(10); + EventWorkspace_sptr eventWS = WorkspaceCreationHelper::CreateEventWorkspace(numPixels,50,eventsPerPixel,0.0, 1.0, 1/*EventPattern=1*/); + TS_ASSERT(eventWS); + const int wsIndex(4); + MatrixWorkspace_sptr output = runAlgorithm(eventWS, wsIndex); + + EventWorkspace_sptr outputWS = boost::dynamic_pointer_cast<EventWorkspace>(output); + TSM_ASSERT("Output should be an event workspace",outputWS); + const size_t numEvents = outputWS->getNumberEvents(); + TS_ASSERT_EQUALS(numEvents, eventsPerPixel); + do_Spectrum_Tests(outputWS, 4, 4); + TS_ASSERT_EQUALS(eventWS->blocksize(), 50); + TS_ASSERT_DELTA(outputWS->getEventList(0).getTofMin(), 4.5, 1e-08); + TS_ASSERT_DELTA(outputWS->getEventList(0).getTofMax(), 28.5, 1e-08); + } + +private: + + ExtractSingleSpectrum * createExtractSingleSpectrum() + { + return new ExtractSingleSpectrum(); + } + + MatrixWorkspace_sptr runAlgorithm(MatrixWorkspace_sptr inputWS, const int index) + { + Algorithm *extractor = createExtractSingleSpectrum(); + extractor->initialize(); + extractor->setChild(true); // Don't add the output to the ADS, then we don't have to clear it + TS_ASSERT_THROWS_NOTHING(extractor->setProperty("InputWorkspace",inputWS)); + TS_ASSERT_THROWS_NOTHING(extractor->setPropertyValue("OutputWorkspace","child_algorithm")); + TS_ASSERT_THROWS_NOTHING(extractor->setProperty("WorkspaceIndex",index)); + TS_ASSERT_THROWS_NOTHING(extractor->execute()); + TS_ASSERT(extractor->isExecuted()); + if(!extractor->isExecuted()) + { + TS_FAIL("Error running algorithm"); + } + return extractor->getProperty("OutputWorkspace"); + } + + void do_Spectrum_Tests(MatrixWorkspace_sptr outputWS, const specid_t specID, const detid_t detID) + { + TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); const Mantid::API::ISpectrum *spectrum(NULL); TS_ASSERT_THROWS_NOTHING(spectrum = outputWS->getSpectrum(0)); if( spectrum ) { + TS_ASSERT_EQUALS(spectrum->getSpectrumNo(), specID); std::set<detid_t> detids = spectrum->getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); const detid_t id = *(detids.begin()); - TS_ASSERT_EQUALS(id, 3); + TS_ASSERT_EQUALS(id, detID); } else { TS_FAIL("No spectra/detectors associated with extracted histogram."); } - - AnalysisDataService::Instance().remove("input"); - AnalysisDataService::Instance().remove("output"); } - void test_Input_With_TextAxis() - { - Algorithm *extractor = new ExtractSingleSpectrum; - extractor->initialize(); - extractor->setPropertyValue("WorkspaceIndex", "1"); - CropWorkspaceTest::doTestWithTextAxis(extractor); //Takes ownership - } - -private: - Mantid::Algorithms::ExtractSingleSpectrum extractor; }; #endif /*EXTRACTSINGLESPECTRUMTEST_H_*/ diff --git a/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt b/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt index faffae6c278154d8c2bff7c05b501495bd837c8f..86cf4710a03cc9b35e82628c3e5ba9f91dc8bbc7 100644 --- a/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt @@ -1,9 +1,5 @@ # GLOBs should be replaced with explicit listings set ( SRC_FILES - src/BoxFunctionBuilder.cpp - src/BoxImplicitFunction.cpp - src/BoxImplicitFunctionParser.cpp - src/BoxInterpreter.cpp src/CobaltSpinWaveDSHO.cpp src/CompositeFunctionBuilder.cpp src/CompositeImplicitFunction.cpp @@ -14,30 +10,19 @@ set ( SRC_FILES src/IDynamicRebinning.cpp src/InvalidParameter.cpp src/InvalidParameterParser.cpp - src/MDParameterParserDeclarations.cpp - src/NormalParameter.cpp src/NullImplicitFunction.cpp - src/PlaneFunctionBuilder.cpp - src/PlaneImplicitFunction.cpp - src/PlaneImplicitFunctionParser.cpp - src/PlaneInterpreter.cpp src/QuadEnBackground.cpp src/RunParam.cpp src/SimulateMDD.cpp src/SimulateResolution.cpp src/TobyFitSimulate.cpp src/Vector3DParameterParser.cpp - src/VectorMathematics.cpp ) #set ( SRC_UNITY_IGNORE_FILES src/IDynamicRebinning.cpp #) set ( INC_FILES - inc/MantidMDAlgorithms/BoxFunctionBuilder.h - inc/MantidMDAlgorithms/BoxImplicitFunction.h - inc/MantidMDAlgorithms/BoxImplicitFunctionParser.h - inc/MantidMDAlgorithms/BoxInterpreter.h inc/MantidMDAlgorithms/CobaltSpinWaveDSHO.h inc/MantidMDAlgorithms/CompositeFunctionBuilder.h inc/MantidMDAlgorithms/CompositeImplicitFunction.h @@ -45,30 +30,17 @@ set ( INC_FILES inc/MantidMDAlgorithms/ConvertToQ3DdE.h inc/MantidMDAlgorithms/ConvertToQNDany.h # inc/MantidMDAlgorithms/CreateMDFitWorkspace.h - inc/MantidMDAlgorithms/DepthParameter.h - inc/MantidMDAlgorithms/HeightParameter.h inc/MantidMDAlgorithms/IDynamicRebinning.h inc/MantidMDAlgorithms/InvalidParameter.h inc/MantidMDAlgorithms/InvalidParameterParser.h - inc/MantidMDAlgorithms/MDParameterParserDeclarations.h - inc/MantidMDAlgorithms/NormalParameter.h inc/MantidMDAlgorithms/NullImplicitFunction.h - inc/MantidMDAlgorithms/OriginParameter.h - inc/MantidMDAlgorithms/PerpendicularParameter.h - inc/MantidMDAlgorithms/PlaneFunctionBuilder.h - inc/MantidMDAlgorithms/PlaneImplicitFunction.h - inc/MantidMDAlgorithms/PlaneImplicitFunctionParser.h - inc/MantidMDAlgorithms/PlaneInterpreter.h inc/MantidMDAlgorithms/QuadEnBackground.h inc/MantidMDAlgorithms/RunParam.h inc/MantidMDAlgorithms/SimulateMDD.h inc/MantidMDAlgorithms/SimulateResolution.h inc/MantidMDAlgorithms/TobyFitSimulate.h - inc/MantidMDAlgorithms/UpParameter.h inc/MantidMDAlgorithms/Vector3DParameter.h inc/MantidMDAlgorithms/Vector3DParameterParser.h - inc/MantidMDAlgorithms/VectorMathematics.h - inc/MantidMDAlgorithms/WidthParameter.h ) # Test files. Other source files required. @@ -77,43 +49,19 @@ set ( TEST_FILES #test/CobaltSWDTest.h #test/CreateMDFitWorkspaceTest.h #test/QuadEnBackgroundTest.h - test/BoxImplicitFunctionTest.h test/ConvertToQ3DdETest.h test/ConvertToQNDanyTest.h - test/DepthParameterTest.h - test/HeightParameterTest.h test/InvalidParameterParserTest.h test/InvalidParameterTest.h - test/NormalParameterTest.h - test/OriginParameterTest.h - test/PlaneFunctionBuilderTest.h - test/PlaneImplicitFunctionTest.h test/RunParamTest.h test/SimulateMDDTest.h test/TobyFitSimulateTest.h - test/VectorMathematicsTest.h - test/WidthParameterTest.h ) set ( GMOCK_TEST_FILES - test/BoxBuilderTest.h - test/BoxImplicitFunctionParserTest.h - test/BoxInterpreterTest.h test/CompositeBuilderTest.h - test/CompositeImplicitFunctionParserTest.h test/CompositeImplicitFunctionTest.h - test/DepthParameterParserTest.h - test/HeightParameterParserTest.h - test/NormalParameterParserTest.h test/NullImplicitFunctionTest.h - test/OriginParameterParserTest.h - test/PerpendicularParameterParserTest.h - test/PerpendicularParameterTest.h - test/PlaneImplicitFunctionParserTest.h - test/PlaneInterpreterTest.h - test/WidthParameterParserTest.h - test/UpParameterParserTest.h - test/UpParameterTest.h ) if(UNITY_BUILD) diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxFunctionBuilder.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxFunctionBuilder.h deleted file mode 100644 index 4aa3634ca0e87b63c1848320ea335ccd84f4ff28..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxFunctionBuilder.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef BOX_FUNCTONBUILDER_H_ -#define BOX_FUNCTONBUILDER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include <memory> -#include "MantidKernel/System.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include "MantidAPI/ImplicitFunctionBuilder.h" - -namespace Mantid -{ - - namespace MDAlgorithms - { - /** - - This class is the abstract type for building BoxImplicitFunctions - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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 BoxFunctionBuilder : public Mantid::API::ImplicitFunctionBuilder - { - private: - mutable OriginParameter m_origin; ///< Origin of the box - mutable WidthParameter m_width; ///< Size for the box width - mutable HeightParameter m_height; ///< Size for the box height - mutable DepthParameter m_depth; ///< Size for the box depth - public: - BoxFunctionBuilder(); - - /// Set the box origin - void addOriginParameter(const OriginParameter& parameter); - /// Set the box depth - void addDepthParameter(const DepthParameter& depthParam); - /// Set the box width - void addWidthParameter(const WidthParameter& widthParam); - /// Set the box height - void addHeightParameter(const HeightParameter& heightParam); - /// Create an implicit function instance - Mantid::Geometry::MDImplicitFunction* create() const; - ~BoxFunctionBuilder(); - }; - - } -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunction.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunction.h deleted file mode 100644 index 5a6600016a1d5507d589e4465f058fd08f92ae89..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunction.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef MANTID_MDALGORITHMS_BOX3DIMPLICITFUNCTION_H_ -#define MANTID_MDALGORITHMS_BOX3DIMPLICITFUNCTION_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include "MantidKernel/System.h" -#include "MantidMDAlgorithms/WidthParameter.h" -#include "MantidMDAlgorithms/DepthParameter.h" -#include "MantidMDAlgorithms/HeightParameter.h" -#include "MantidMDAlgorithms/OriginParameter.h" -#include "MantidGeometry/MDGeometry/MDBoxImplicitFunction.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - This class represents a box for making slices orthogonal to the cartesian axes set. - This is a specialization of the MDBoxImplicitFunction for 3 dimensions. - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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 BoxImplicitFunction : public Mantid::Geometry::MDBoxImplicitFunction - { - public: - /** - * Object constructor - * @param width the value for the width of the box - * @param height the value for the height of the box - * @param depth the value for the depth of the box - * @param origin the value for the origin of the box - */ - BoxImplicitFunction(WidthParameter& width, HeightParameter& height, DepthParameter& depth, OriginParameter& origin); - /// Object destructor - ~BoxImplicitFunction(); - std::string getName() const; - std::string toXMLString() const; - /// Return the maximum extent of the x direction - double getUpperX() const; - /// Return the mimimum extent of the x direction - double getLowerX() const; - /// Return the maximum extent of the y direction - double getUpperY() const; - /// Return the mimimum extent of the y direction - double getLowerY() const; - /// Return the maximum extent of the z direction - double getUpperZ() const; - /// Return the mimimum extent of the z direction - double getLowerZ() const; - /** - * Equality operator overload - * @param other the object to test against - * @return true if objects are equal - */ - bool operator==(const BoxImplicitFunction &other) const; - /** - * Non-equality operator overload - * @param other the object to test against - * @return true if objects are not equal - */ - bool operator!=(const BoxImplicitFunction &other) const; - - /// Return the function name - static std::string functionName() - { - return "BoxImplicitFunction"; - } - - private: - //from raw inputs. - OriginParameter m_origin; ///< Origin of box - HeightParameter m_height; ///< Height of box - WidthParameter m_width; ///< Width of box - DepthParameter m_depth; ///< Depth of box - - // Bounds of the box - std::vector<coord_t> min; ///< Minimum extents on all axes - std::vector<coord_t> max; ///< Maximum extents on all axes - - }; - } -} - - -#endif /* MANTID_MDALGORITHMS_BOX3DIMPLICITFUNCTION_H_ */ diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunctionParser.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunctionParser.h deleted file mode 100644 index 142cc164ba8ca14d8ac66f111955105c1aa937c7..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxImplicitFunctionParser.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef MANTID_ALGORITHMS_BOX_IMPLICITFUNCTION_PARSER_H_ -#define MANTID_ALGORITHMS_BOX_IMPLICITFUNCTION_PARSER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include "MantidKernel/System.h" -#include <boost/shared_ptr.hpp> -#include "MantidMDAlgorithms/BoxFunctionBuilder.h" -#include "MantidAPI/ImplicitFunctionParser.h" -#include "MantidAPI/ImplicitFunctionParameterParser.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - This class to parse plane type functions and generate the associated builders. - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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 BoxImplicitFunctionParser : public Mantid::API::ImplicitFunctionParser - { - - public: - /// Default constructor - BoxImplicitFunctionParser(); - - /** - * Create a function builder from a text-based representation. - * @param functionElement text representation of function - * @return the builder for the requested function - */ - Mantid::API::ImplicitFunctionBuilder* createFunctionBuilder(Poco::XML::Element* functionElement); - - /** - * Set the successor translation class. - * @param parser the successor translator - */ - void setSuccessorParser(Mantid::API::ImplicitFunctionParser* parser); - - /** - * Set the parameter translation class. - * @param parser the parameter translator - */ - void setParameterParser(Mantid::API::ImplicitFunctionParameterParser* parser); - - /** - * Create a box function builder from a text-based representation. - * @param functionElement text representation of builder - * @return a concrete box builder - */ - BoxFunctionBuilder* parseBoxFunction(Poco::XML::Element* functionElement); - - /// Default destructor - ~BoxImplicitFunctionParser(); - }; - } -} - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxInterpreter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxInterpreter.h deleted file mode 100644 index 7765d914398173012bb512a3c7ca4d42c25efa7c..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxInterpreter.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MD_MANTID_ALGORITHMS_BOX_INTERPRETER -#define MD_MANTID_ALGORITHMS_BOX_INTERPRETER - -#include "MantidKernel/System.h" -#include <boost/smart_ptr.hpp> -#include <vector> -#include <functional> - -namespace Mantid -{ -//Forward declaration. -namespace Geometry -{ -class MDImplicitFunction; -} - -namespace MDAlgorithms -{ -//Forward declaration. -class CompositeImplicitFunction; -class BoxImplicitFunction; - - -typedef std::vector<boost::shared_ptr<Mantid::MDAlgorithms::BoxImplicitFunction> > boxVector; - -typedef std::vector<boost::shared_ptr<Mantid::Geometry::MDImplicitFunction> > functionVector; - -/** A helper class to determine inner surface box boundaries from a composite set of implicit functions - - @author Owen Arnold, Tessella plc - @date 21/01/2011 - - 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 BoxInterpreter: public std::unary_function<Mantid::Geometry::MDImplicitFunction*, std::vector<double> > -{ -private: - /// Recursively walk the composite tree and extract flattened vector of BoxImplicit functions. - boxVector walkTree(CompositeImplicitFunction* compFunc) const; -public: - - /// Act as Functor. - std::vector<double> operator()(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; - - /// Explicit call to Functor execution. - std::vector<double> Execute(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; - - /// Get all the boxes extractable from the implicit function. - boxVector getAllBoxes(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; -}; -} - -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DepthParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DepthParameter.h deleted file mode 100644 index e2ae114f205b3c0eef47d2aeedc22384bdcffbe3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DepthParameter.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DEPTH_PARAMETER_H_ -#define DEPTH_PARAMETER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/SingleValueParameter.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - - DepthParameter. Wraps a vector expressing origin location. - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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> - */ - DECLARE_SINGLE_VALUE_PARAMETER(DepthParameter, double); - } -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/HeightParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/HeightParameter.h deleted file mode 100644 index b38dafb8a54eae47cd5116fb1fc9509f547a2c96..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/HeightParameter.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HeightParameter_H_ -#define HeightParameter_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/SingleValueParameter.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - - HeightParameter. Wraps a vector expressing origin location. - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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> - */ - DECLARE_SINGLE_VALUE_PARAMETER(HeightParameter, double); - } -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDParameterParserDeclarations.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDParameterParserDeclarations.h deleted file mode 100644 index 2da51b9d4235776aee29946d9f8a3d01b545e4aa..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDParameterParserDeclarations.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MD_ALGORITHMS_MD_PARAMETER_PARSER_DECLARATIONS_H -#define MD_ALGORITHMS_MD_PARAMETER_PARSER_DECLARATIONS_H - -#include "MantidAPI/SingleValueParameterParser.h" -#include "MantidMDAlgorithms/DepthParameter.h" -#include "MantidMDAlgorithms/HeightParameter.h" -#include "MantidMDAlgorithms/WidthParameter.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /// Typedef for Width Parameter Parser. - typedef API::SingleValueParameterParser<WidthParameter> WidthParameterParser; - - /// Typedef for Height Parameter Parser. - typedef API::SingleValueParameterParser<HeightParameter> HeightParameterParser; - - /// Typedef for Depth Parameter Parser. - typedef API::SingleValueParameterParser<DepthParameter> DepthParameterParser; - } -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NormalParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NormalParameter.h deleted file mode 100644 index 134424a0eb3855781b9d222287ec2da7aaa91df3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NormalParameter.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef NORMALPARAMETER_H -#define NORMALPARAMETER_H - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidMDAlgorithms/Vector3DParameter.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ -/** - - Implementation of a parameter expressing normal vector information. - - @author Owen Arnold, Tessella plc - @date 01/10/2010 - - Copyright © 2010 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 NormalParameter: public Vector3DParameter<NormalParameter, double> -{ - -private: - - double magnitude() const; - -public: - - typedef Vector3DParameter<NormalParameter, double> SuperType; - - NormalParameter(double n1, double n2, double n3); - - NormalParameter(); - - std::string getName() const; - - NormalParameter reflect() const; - - NormalParameter* clone() const; - - ~NormalParameter(); - - NormalParameter asUnitVector() const; - - bool isUnitVector() const; - - /* - Getter for the parameter name associated with this type. - @return the parameter name. - */ - static std::string parameterName() - { - return "NormalParameter"; - } - -}; -} -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OriginParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OriginParameter.h deleted file mode 100644 index a168e681c84e6f79e0145eeb0b2bb34099d3b5c8..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OriginParameter.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef ORIGINPARAMETER_H_ -#define ORIGINPARAMETER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidMDAlgorithms/Vector3DParameter.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - - OriginParameter. Wraps a vector expressing origin location. - - @author Owen Arnold, Tessella plc - @date 01/10/2010 - - Copyright © 2010 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> - */ - - DECLARE_3D_VECTOR_PARAMETER(OriginParameter, double); - } -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PerpendicularParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PerpendicularParameter.h deleted file mode 100644 index 0055d5850b6fc351f3f3fef6835ce5e38244e759..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PerpendicularParameter.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MANTID_MDALGORITHMS_PERPENDICULARPARAMETER -#define MANTID_MDALGORITHMS_PERPENDICULARPARAMETER - -#include "MantidMDAlgorithms/Vector3DParameter.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ - -/** - PerpendicularParameter defines a spatial vector as the cross product of a normal vector and the up vector. - - @author Owen Arnold, Tessella plc - @date 01/02/2011 - - Copyright © 2010 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> - */ - -DECLARE_3D_VECTOR_PARAMETER(PerpendicularParameter, double); - -} -} -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneFunctionBuilder.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneFunctionBuilder.h deleted file mode 100644 index 06f46846b3f253fe4db45113d77a8328ee54931c..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneFunctionBuilder.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef PLANEFUNCTONBUILDER_H_ -#define PLANEFUNCTONBUILDER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include <memory> -#include "MantidKernel/System.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include "MantidAPI/ImplicitFunctionBuilder.h" -#include "MantidAPI/ImplicitFunctionParameter.h" -#include "MantidMDAlgorithms/NormalParameter.h" -#include "MantidMDAlgorithms/OriginParameter.h" - -namespace Mantid -{ - - namespace MDAlgorithms - { - /** - - This class is for building PlaneImplicitFunction - - @author Owen Arnold, Tessella plc - @date 01/10/2010 - - Copyright © 2010 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 PlaneFunctionBuilder : public Mantid::API::ImplicitFunctionBuilder - { - private: - mutable OriginParameter m_origin; - mutable NormalParameter m_normal; - mutable WidthParameter m_width; - public: - PlaneFunctionBuilder(); - void addNormalParameter(const NormalParameter& parameter); - void addOriginParameter(const OriginParameter& parameter); - void addWidthParameter(const WidthParameter& width); - Mantid::Geometry::MDImplicitFunction* create() const; - ~PlaneFunctionBuilder(); - }; - - } -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunction.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunction.h deleted file mode 100644 index 44a36a1ae3ee5402b1608ce20d2ff0465a238017..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunction.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef MANTID_ALGORITHMS_PlaneImplicitFunction_H_ -#define MANTID_ALGORITHMS_PlaneImplicitFunction_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include <gsl/gsl_blas.h> -#include "MantidKernel/System.h" -#include "MantidKernel/Matrix.h" -#include "MantidMDAlgorithms/OriginParameter.h" -#include "MantidMDAlgorithms/NormalParameter.h" -#include "MantidMDAlgorithms/WidthParameter.h" -#include "MantidMDAlgorithms/UpParameter.h" -#include "MantidMDAlgorithms/PerpendicularParameter.h" -#include "MantidMDAlgorithms/VectorMathematics.h" -#include "MantidGeometry/MDGeometry/MDImplicitFunction.h" - -namespace Mantid -{ - - namespace MDAlgorithms - { - /** - - This class represents a plane implicit function defined in 3 dimensions, - used for communicating and implementing an operation against a MDWorkspace. - - @author Owen Arnold, Tessella plc - @date 01/10/2010 - - Copyright © 2010 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 PlaneImplicitFunction : public Mantid::Geometry::MDImplicitFunction - { - public: - PlaneImplicitFunction(NormalParameter& normal, OriginParameter& origin, WidthParameter& width); - ~PlaneImplicitFunction(); - std::string getName() const; - std::string toXMLString() const; - double getOriginX() const; - double getOriginY() const; - double getOriginZ() const; - double getNormalX() const; - double getNormalY() const; - double getNormalZ() const; - double getWidth() const; - bool operator==(const PlaneImplicitFunction &other) const; - bool operator!=(const PlaneImplicitFunction &other) const; - static std::string functionName() - { - return "PlaneImplicitFunction"; - } - - private: - - /// Plane Origin - OriginParameter m_origin; - /// Plane Normal - NormalParameter m_normal; - /// Plane Width - WidthParameter m_width; - - /// Calculate the width applied to the normal direction resolved into the specified axis. - inline double calculateNormContributionAlongAxisComponent(const Mantid::Kernel::V3D& axis) const; - /// Get the effective normal vector to use in calculation. - inline NormalParameter calculateEffectiveNormal(const OriginParameter& forwardOrigin) const; - - }; - } -} - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunctionParser.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunctionParser.h deleted file mode 100644 index aa9cd4fb0d92c7500a81d115a06ad7d266739344..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneImplicitFunctionParser.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef MANTID_ALGORITHMS_PLANEIMPLICITFUNCTION_PARSER_H_ -#define MANTID_ALGORITHMS_PLANEIMPLICITFUNCTION_PARSER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include "MantidKernel/System.h" -#include <boost/shared_ptr.hpp> -#include "MantidMDAlgorithms/PlaneFunctionBuilder.h" -#include "MantidAPI/ImplicitFunctionParser.h" -#include "MantidAPI/ImplicitFunctionParameterParser.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - This class to parse plane type functions and generate the associated builders. - - @author Owen Arnold, Tessella plc - @date 01/10/2010 - - Copyright © 2010 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 PlaneImplicitFunctionParser : public Mantid::API::ImplicitFunctionParser - { - - public: - PlaneImplicitFunctionParser(); - - Mantid::API::ImplicitFunctionBuilder* createFunctionBuilder(Poco::XML::Element* functionElement); - - void setSuccessorParser(Mantid::API::ImplicitFunctionParser* parser); - - void setParameterParser(Mantid::API::ImplicitFunctionParameterParser* parser); - - PlaneFunctionBuilder* parsePlaneFunction(Poco::XML::Element* functionElement); - - ~PlaneImplicitFunctionParser(); - }; - } -} - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneInterpreter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneInterpreter.h deleted file mode 100644 index f41c59e93db513a63ee46b7fe212f58c8dc3c3fc..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlaneInterpreter.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef MD_MANTID_ALGORITHMS_PLANE_INTERPRETER -#define MD_MANTID_ALGORITHMS_PLANE_INTERPRETER - -/** A helper class to find and determine planes defined in composite implicit functions. - - @author Owen Arnold, Tessella plc - @date 21/01/2011 - - 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> - */ - -#include "MantidKernel/System.h" -#include <boost/smart_ptr.hpp> -#include <vector> -#include <functional> - -namespace Mantid -{ -//Forward declaration. -namespace Geometry -{ -class MDImplicitFunction; -} - -namespace MDAlgorithms -{ - -//Forward declaration. -class CompositeImplicitFunction; -class PlaneImplicitFunction; - -typedef std::vector<boost::shared_ptr<Mantid::MDAlgorithms::PlaneImplicitFunction> > planeVector; - -class DLLExport PlaneInterpreter: public std::unary_function<Mantid::Geometry::MDImplicitFunction*, std::vector<double> > -{ -private: - /// Recursively walk the composite tree and extract flattened vector of BoxImplicit functions. - planeVector walkTree(CompositeImplicitFunction* compFunc) const; - - /// Construct and return a default rotation matrix. - std::vector<double> defaultRotationMatrix() const; - -public: - - typedef std::vector<boost::shared_ptr<Mantid::Geometry::MDImplicitFunction> > functionVector; - - /// Act as Functor. - std::vector<double> operator()(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; - - /// Explicit call to Functor execution. - std::vector<double> Execute(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; - - /// Extract planes from implicit function into a flattened vector. - planeVector getAllPlanes(Mantid::Geometry::MDImplicitFunction* implicitFunction) const; -}; -} - -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/UpParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/UpParameter.h deleted file mode 100644 index 72ed32f86fed23290ab4c68df5cc6bae4d5c0343..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/UpParameter.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef MANTID_MDALGORITHMS_UPPARAMETER_H_ -#define MANTID_MDALGORITHMS_UPPARAMETER_H_ - -#include "MantidMDAlgorithms/Vector3DParameter.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ - -/** -Defines a spatial vector perpendicular to a normal vector, in the 'up' direction. - -@author Owen Arnold, Tessella plc -@date 01/02/2011 - -Copyright © 2010 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> -*/ - - DECLARE_3D_VECTOR_PARAMETER(UpParameter, double); - -} -} - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Vector3DParameterParser.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Vector3DParameterParser.h index 09f0e76b1297cc04a9b29f0391200a04c79b8263..9bc38924bdb567067d2d6ac8e3ab883fabcea147 100644 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Vector3DParameterParser.h +++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Vector3DParameterParser.h @@ -7,10 +7,10 @@ #include "MantidKernel/System.h" #include "MantidAPI/ImplicitFunctionParameterParser.h" -#include "MantidMDAlgorithms/UpParameter.h" -#include "MantidMDAlgorithms/PerpendicularParameter.h" -#include "MantidMDAlgorithms/NormalParameter.h" -#include "MantidMDAlgorithms/OriginParameter.h" +//#include "MantidMDAlgorithms/UpParameter.h" +//#include "MantidMDAlgorithms/PerpendicularParameter.h" +//#include "MantidMDAlgorithms/NormalParameter.h" +//#include "MantidMDAlgorithms/OriginParameter.h" #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> @@ -130,16 +130,16 @@ Vector3DParameterParser<VectorValueParameterType>::~Vector3DParameterParser() //Declare types based on this template. /// Parses Origin Parameters -typedef Vector3DParameterParser<OriginParameter> OriginParameterParser; +//typedef Vector3DParameterParser<OriginParameter> OriginParameterParser; /// Parses Normal Parameters -typedef Vector3DParameterParser<NormalParameter> NormalParameterParser; +//typedef Vector3DParameterParser<NormalParameter> NormalParameterParser; /// Parses Up Parameters -typedef Vector3DParameterParser<UpParameter> UpParameterParser; +//typedef Vector3DParameterParser<UpParameter> UpParameterParser; /// Parses Perpendicular Parameters -typedef Vector3DParameterParser<PerpendicularParameter> PerpendicularParameterParser; +//typedef Vector3DParameterParser<PerpendicularParameter> PerpendicularParameterParser; } } diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/VectorMathematics.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/VectorMathematics.h deleted file mode 100644 index 101f95209b4bc33ece013c76cbefdcea97383b48..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/VectorMathematics.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MANTID_ALGORITHMS_VECTORMATHEMATICS -#define MANTID_ALGORITHMS_VECTORMATHEMATICS - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <vector> -#include <cmath> -#include "MantidKernel/V3D.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ -/** - - Grouping of static methods used to perform vector mathematics required for MDAlgorithm support. - - Convenience functions wrap V3D mathematical functions without the need to create temporaries. - - @author Owen Arnold, Tessella plc - @date 19/10/2010 - - Copyright © 2010 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> - */ -//TODO: consider replacing with something more Mantid generic. - - -DLLExport double dotProduct(Mantid::Kernel::V3D a, Mantid::Kernel::V3D b); - -DLLExport double dotProduct(double a1, double a2, double a3, double b1, double b2, double b3); - -DLLExport Mantid::Kernel::V3D crossProduct(Mantid::Kernel::V3D a, Mantid::Kernel::V3D b); - -DLLExport Mantid::Kernel::V3D crossProduct(double a1, double a2, double a3, double b1, double b2, - double b3); - -DLLExport double absolute(double a1, double a2, double a3); - -} -} - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WidthParameter.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WidthParameter.h deleted file mode 100644 index a1957a99bf9874ebfbacfc927d258b2c5522de56..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WidthParameter.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef WIDTHPARAMETER_H_ -#define WIDTHPARAMETER_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/SingleValueParameter.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - /** - - WidthParameter. Wraps a vector expressing origin location. - - @author Owen Arnold, Tessella plc - @date 09/12/2010 - - Copyright © 2010 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> - */ - DECLARE_SINGLE_VALUE_PARAMETER(WidthParameter, double); - } -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Framework/MDAlgorithms/src/BoxFunctionBuilder.cpp b/Code/Mantid/Framework/MDAlgorithms/src/BoxFunctionBuilder.cpp deleted file mode 100644 index 524fd25a1ecc9ba3d0be0cd877b5c1653d359f81..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/BoxFunctionBuilder.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "MantidMDAlgorithms/BoxFunctionBuilder.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - using namespace Mantid::API; - - BoxFunctionBuilder::BoxFunctionBuilder() - { - } - - void BoxFunctionBuilder::addOriginParameter(const OriginParameter& originParam) - { - this->m_origin = originParam; - } - - void BoxFunctionBuilder::addWidthParameter(const WidthParameter& widthParam) - { - this->m_width = widthParam; - } - - void BoxFunctionBuilder::addHeightParameter(const HeightParameter& heightParam) - { - this->m_height = heightParam; - } - - void BoxFunctionBuilder::addDepthParameter(const DepthParameter& depthParam) - { - this->m_depth = depthParam; - } - - Mantid::Geometry::MDImplicitFunction* BoxFunctionBuilder::create() const - { - //check that builder parameters are valid. - if(!m_origin.isValid()) - { - std::string message = "Invalid origin parameter on BoxFunctionBuilder"; - throw std::invalid_argument(message); - } - if(!m_depth.isValid()) - { - std::string message = "Invalid depth parameter passed to BoxFunctionBuilder"; - throw std::invalid_argument(message); - } - if(!m_width.isValid()) - { - std::string message = "Invalid width parameter passed to BoxFunctionBuilder"; - throw std::invalid_argument(message); - } - if(!m_height.isValid()) - { - std::string message = "Invalid height parameter passed to BoxFunctionBuilder"; - throw std::invalid_argument(message); - } - - //implement construction. - return new Mantid::MDAlgorithms::BoxImplicitFunction(m_width, m_height, m_depth, m_origin); - - } - - BoxFunctionBuilder::~BoxFunctionBuilder() - { - } - } - - -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunction.cpp b/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunction.cpp deleted file mode 100644 index b958b08898f0714212f7469a4ecc97c9704c4497..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunction.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include <boost/algorithm/string.hpp> -#include <boost/format.hpp> -#include <cmath> -#include <vector> - -namespace Mantid -{ - namespace MDAlgorithms - { - - BoxImplicitFunction::BoxImplicitFunction(WidthParameter& width, HeightParameter& height, DepthParameter& depth, OriginParameter& origin) - : MDBoxImplicitFunction() - { - //Parameters describing box implicit function. - m_origin = origin; - m_depth = depth; - m_height = height; - m_width = width; - - //calculate cached values. Used for faster evaluation routine. - min.resize(3); - max.resize(3); - - //xbounds - max[0] = origin.getX() + width.getValue()/2; - min[0] = origin.getX() - width.getValue()/2; - //ybounds. - max[1] = origin.getY() + height.getValue()/2; - min[1] = origin.getY() - height.getValue()/2; - //zbounds - max[2] = origin.getZ() + depth.getValue()/2; - min[2] = origin.getZ() - depth.getValue()/2; - - this->construct(min,max); - } - - - bool BoxImplicitFunction::operator==(const BoxImplicitFunction &other) const - { - return - this->m_width == other.m_width && - this->m_height == other.m_height && - this->m_depth == other.m_depth && - this->m_origin == other.m_origin; - } - - bool BoxImplicitFunction::operator!=(const BoxImplicitFunction &other) const - { - return !(*this == other); - } - - std::string BoxImplicitFunction::getName() const - { - return functionName(); - } - - double BoxImplicitFunction::getUpperX() const - { - return this->max[0]; - } - - double BoxImplicitFunction::getLowerX() const - { - return this->min[0]; - } - - double BoxImplicitFunction::getUpperY() const - { - return this->max[1]; - } - - double BoxImplicitFunction::getLowerY() const - { - return this->min[1]; - } - - double BoxImplicitFunction::getUpperZ() const - { - return this->max[2]; - } - - double BoxImplicitFunction::getLowerZ() const - { - return this->min[2]; - } - - std::string BoxImplicitFunction::toXMLString() const - { - using namespace Poco::XML; - - AutoPtr<Document> pDoc = new Document; - AutoPtr<Element> functionElement = pDoc->createElement("Function"); - pDoc->appendChild(functionElement); - AutoPtr<Element> typeElement = pDoc->createElement("Type"); - AutoPtr<Text> typeText = pDoc->createTextNode(this->getName()); - typeElement->appendChild(typeText); - functionElement->appendChild(typeElement); - - AutoPtr<Element> paramListElement = pDoc->createElement("ParameterList"); - - AutoPtr<Text> formatText = pDoc->createTextNode("%s%s%s%s"); - paramListElement->appendChild(formatText); - functionElement->appendChild(paramListElement); - - std::stringstream xmlstream; - - DOMWriter writer; - writer.writeNode(xmlstream, pDoc); - - std::string formattedXMLString = boost::str(boost::format(xmlstream.str().c_str()) - % m_width.toXMLString().c_str() % m_height.toXMLString() % m_depth.toXMLString() % m_origin.toXMLString().c_str()); - return formattedXMLString; - } - - BoxImplicitFunction::~BoxImplicitFunction() - { - } - - } -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunctionParser.cpp b/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunctionParser.cpp deleted file mode 100644 index a96a661f480f8eda8e762d55c5f3bb1aea0bab66..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/BoxImplicitFunctionParser.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/BoxImplicitFunctionParser.h" -#include "MantidAPI/ImplicitFunctionParserFactory.h" -#include "MantidMDAlgorithms/InvalidParameterParser.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - - DECLARE_IMPLICIT_FUNCTION_PARSER(BoxImplicitFunctionParser); - - BoxImplicitFunctionParser::BoxImplicitFunctionParser() : ImplicitFunctionParser(new InvalidParameterParser) - { - } - - API::ImplicitFunctionBuilder* BoxImplicitFunctionParser::createFunctionBuilder(Poco::XML::Element* functionElement) - { - API::ImplicitFunctionBuilder* functionBuilder; - if("Function" != functionElement->localName()) - { - std::string message = "This is not a function element: " + functionElement->localName(); - throw std::invalid_argument(message); - } - - std::string type = functionElement->getChildElement("Type")->innerText(); - if(BoxImplicitFunction::functionName() != type) // If this parser does not match the xml, try the successor chain. - { - if(0 == m_successor.get()) - { - std::string message = "There is no successor function parser here for type: " + type; - throw std::runtime_error(message); - } - functionBuilder = m_successor->createFunctionBuilder(functionElement); - } - else // Parse the xml here. - { - functionBuilder = parseBoxFunction(functionElement); - } - return functionBuilder; - } - - void BoxImplicitFunctionParser::setSuccessorParser(ImplicitFunctionParser* parser) - { - ImplicitFunctionParser::SuccessorType temp(parser); - this->m_successor.swap(temp); - } - - BoxFunctionBuilder * BoxImplicitFunctionParser::parseBoxFunction(Poco::XML::Element* functionElement) - { - using namespace Poco::XML; - BoxFunctionBuilder* functionBuilder = new BoxFunctionBuilder; - NodeList* parameterList = functionElement->getChildElement("ParameterList")->childNodes(); - - //Loop through the parameter list looking for known parameter, required, which can then be parsed. - for(unsigned int i = 0; i < parameterList->length(); i++) - { - - Element* parameterElement = dynamic_cast<Element*>(parameterList->item(i)); - - std::string namee= parameterElement->localName(); - - boost::scoped_ptr<API::ImplicitFunctionParameter> parameter(this->parseParameter(parameterElement)); - if(WidthParameter::parameterName() == parameter->getName()) - { - WidthParameter* pCurr = dynamic_cast<WidthParameter*>(parameter.get()); - WidthParameter width(pCurr->getValue()); - functionBuilder->addWidthParameter(width); - } - else if(HeightParameter::parameterName() == parameter->getName()) - { - HeightParameter* pCurr = dynamic_cast<HeightParameter*>(parameter.get()); - HeightParameter height(pCurr->getValue()); - functionBuilder->addHeightParameter(height); - } - else if(DepthParameter::parameterName() == parameter->getName()) - { - DepthParameter* pCurr = dynamic_cast<DepthParameter*>(parameter.get()); - DepthParameter depth(pCurr->getValue()); - functionBuilder->addDepthParameter(depth); - } - else if(OriginParameter::parameterName() == parameter->getName()) - { - OriginParameter* pCurr = dynamic_cast<OriginParameter*>(parameter.get()); - OriginParameter origin(pCurr->getX(), pCurr->getY(), pCurr->getZ()); - functionBuilder->addOriginParameter(origin); - } - else - { - std::string message = "The parameter cannot be processed or is unrecognised: " + parameter->getName(); - message += ". The parameter cannot be processed or is unrecognised: " + (dynamic_cast<InvalidParameter*>(parameter.get()))->getValue(); - throw std::invalid_argument(message); - } - - } - - return functionBuilder; //convert to raw pointer and cancel smart management. - } - - BoxImplicitFunctionParser::~BoxImplicitFunctionParser() - { - } - - void BoxImplicitFunctionParser::setParameterParser(Mantid::API::ImplicitFunctionParameterParser* parser) - { - Mantid::API::ImplicitFunctionParameterParser::SuccessorType temp(parser); - this->m_paramParserRoot.swap(temp); - } - } -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/BoxInterpreter.cpp b/Code/Mantid/Framework/MDAlgorithms/src/BoxInterpreter.cpp deleted file mode 100644 index 7bfef987be7f713ba998c6b8f9bf1add9d6b6dc1..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/BoxInterpreter.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "MantidMDAlgorithms/BoxInterpreter.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include "MantidMDAlgorithms/CompositeImplicitFunction.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ - -boxVector BoxInterpreter::walkTree(CompositeImplicitFunction* compFunc) const -{ - using namespace Mantid::API; - boxVector flattenedboxes; - functionVector nestedFuncs = compFunc->getFunctions(); - for (unsigned int i = 0; i < nestedFuncs.size(); i++) - { - if (CompositeImplicitFunction::functionName() == nestedFuncs[i]->getName()) - { - CompositeImplicitFunction* compFunc = - dynamic_cast<Mantid::MDAlgorithms::CompositeImplicitFunction*> (nestedFuncs[i].get()); - - boxVector boxes = walkTree(compFunc); //recursive walk - flattenedboxes.insert(flattenedboxes.end(), boxes.begin(), boxes.end()); - } - else if (BoxImplicitFunction::functionName() == nestedFuncs[i]->getName()) - { - boost::shared_ptr<BoxImplicitFunction> spBox = - boost::dynamic_pointer_cast<BoxImplicitFunction>(nestedFuncs[i]); - - flattenedboxes.push_back(spBox); - } - } - return flattenedboxes; - -} - -std::vector<double> BoxInterpreter::operator()(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - return Execute(implicitFunction); -} - -std::vector<double> BoxInterpreter::Execute(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - std::vector<double> endBox(6, 0); - Mantid::MDAlgorithms::CompositeImplicitFunction* compFunction = - dynamic_cast<Mantid::MDAlgorithms::CompositeImplicitFunction*> (implicitFunction); - - boxVector flattenedboxes; - if (compFunction != NULL) - { - //Flatten out box functions - flattenedboxes = walkTree(compFunction); - - boost::shared_ptr<BoxImplicitFunction> box = flattenedboxes[0]; - double minX = box->getLowerX(); - double minY = box->getLowerY(); - double minZ = box->getLowerZ(); - double maxX = box->getUpperX(); - double maxY = box->getUpperY(); - double maxZ = box->getUpperZ(); - for (unsigned int i = 0; i < flattenedboxes.size(); i++) - { - box = flattenedboxes[i]; - minX = minX > box->getLowerX() ? minX : box->getLowerX(); - minY = minY > box->getLowerY() ? minY : box->getLowerY(); - minZ = minZ > box->getLowerZ() ? minZ : box->getLowerZ(); - maxX = maxX < box->getUpperX() ? maxX : box->getUpperX(); - maxY = maxY < box->getUpperY() ? maxY : box->getUpperY(); - maxZ = maxZ < box->getUpperZ() ? maxZ : box->getUpperZ(); - } - - endBox[0] = minX; - endBox[1] = maxX; - endBox[2] = minY; - endBox[3] = maxY; - endBox[4] = minZ; - endBox[5] = maxZ; - } - - return endBox; -} - - -boxVector BoxInterpreter::getAllBoxes(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - Mantid::MDAlgorithms::CompositeImplicitFunction* compFunction = - dynamic_cast<Mantid::MDAlgorithms::CompositeImplicitFunction*> (implicitFunction); - - boxVector flattenedboxes; - if (compFunction != NULL) - { - //Flatten out box functions - flattenedboxes = walkTree(compFunction); - } - return flattenedboxes; -} - -} -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/MDParameterParserDeclarations.cpp b/Code/Mantid/Framework/MDAlgorithms/src/MDParameterParserDeclarations.cpp deleted file mode 100644 index 1c5815eb987c4eac4495f94bdadfd9854c3f1359..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/MDParameterParserDeclarations.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "MantidMDAlgorithms/MDParameterParserDeclarations.h" -#include "MantidAPI/ImplicitFunctionParameterParserFactory.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(HeightParameterParser) - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(WidthParameterParser) - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(DepthParameterParser) - } -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/NormalParameter.cpp b/Code/Mantid/Framework/MDAlgorithms/src/NormalParameter.cpp deleted file mode 100644 index 4d519d860bd93899c26b53ac7c0a627af361ba27..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/NormalParameter.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "MantidMDAlgorithms/NormalParameter.h" -#include <cmath> -#include <boost/algorithm/string.hpp> -#include <boost/format.hpp> - -namespace Mantid -{ - namespace MDAlgorithms - { - - NormalParameter::NormalParameter(double n1, double n2, double n3) : SuperType(n1, n2, n3) - { - } - - NormalParameter::NormalParameter() - { - } - - NormalParameter* NormalParameter::clone() const - { - return new NormalParameter(m_vector[0], m_vector[1], m_vector[2]); - } - - NormalParameter::~NormalParameter() - { - } - - NormalParameter NormalParameter::reflect() const - { - return NormalParameter(-m_vector[0], -m_vector[1], -m_vector[2]); - } - - NormalParameter NormalParameter::asUnitVector() const - { - double mag = magnitude(); - return NormalParameter(m_vector[0]/mag, m_vector[1]/mag, m_vector[2]/mag); - } - - bool NormalParameter::isUnitVector() const - { - return 1 == magnitude(); - } - - double NormalParameter::magnitude() const - { - return std::sqrt(m_vector[0]*m_vector[0] + m_vector[1]*m_vector[1] + m_vector[2]*m_vector[2]); - } - - std::string NormalParameter::getName() const - { - return NormalParameter::parameterName(); - } - - } - -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PlaneFunctionBuilder.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PlaneFunctionBuilder.cpp deleted file mode 100644 index 79b2493f6d432ce20a06107020e56a840330db23..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/PlaneFunctionBuilder.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "MantidMDAlgorithms/PlaneFunctionBuilder.h" -#include "MantidMDAlgorithms/InvalidParameter.h" -#include "MantidMDAlgorithms/OriginParameter.h" -#include "MantidMDAlgorithms/NormalParameter.h" -#include <exception> - -namespace Mantid -{ - namespace MDAlgorithms - { - using namespace Mantid::API; - - PlaneFunctionBuilder::PlaneFunctionBuilder() - { - } - - void PlaneFunctionBuilder::addNormalParameter(const NormalParameter& parameter) - { - - this->m_normal = NormalParameter(parameter); - } - - void PlaneFunctionBuilder::addOriginParameter(const OriginParameter& parameter) - { - - this->m_origin = OriginParameter(parameter); - } - - void PlaneFunctionBuilder::addWidthParameter(const WidthParameter& width) - { - this->m_width = WidthParameter(width); - } - - Mantid::Geometry::MDImplicitFunction* PlaneFunctionBuilder::create() const - { - //check that builder parameters are valid. - if(!m_origin.isValid()) - { - std::string message = "Invalid origin parameter on PlaneFunctionBuilder"; - throw std::invalid_argument(message); - } - if(!m_normal.isValid()) - { - std::string message = "Invalid normal parameter passed to PlaneFunctionBuilder"; - throw std::invalid_argument(message); - } - if(!m_width.isValid()) - { - std::string message = "Invalid width parameter passed to PlaneFunctionBuilder"; - throw std::invalid_argument(message); - } - //implement construction. - NormalParameter& refNormal = m_normal; - OriginParameter& refOrigin = m_origin; - WidthParameter& refWidth = m_width; - PlaneImplicitFunction* func = new Mantid::MDAlgorithms::PlaneImplicitFunction(refNormal, refOrigin, refWidth); - return func; - } - - - PlaneFunctionBuilder::~PlaneFunctionBuilder() - { - } - } - - -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunction.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunction.cpp deleted file mode 100644 index 6eeb1cf29aecde4fcac1647c4e11e7dd9b8d984b..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunction.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "MantidGeometry/MDGeometry/MDPlane.h" -#include "MantidKernel/V3D.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include <boost/algorithm/string.hpp> -#include <boost/format.hpp> -#include <cmath> -#include <vector> - -using namespace Mantid::Geometry; - -namespace Mantid -{ -namespace MDAlgorithms -{ - -PlaneImplicitFunction::PlaneImplicitFunction(NormalParameter& normal, OriginParameter& origin, WidthParameter& width) : - m_origin(origin), - m_normal(normal), - m_width(width) -{ - //Create virtual planes separated by (absolute) width from from actual origin. Origins are key. - using Mantid::Kernel::V3D; - const V3D xAxis(1, 0, 0); - const V3D yAxis(0, 1, 0); - const V3D zAxis(0, 0, 1); - - const double deltaX = calculateNormContributionAlongAxisComponent(xAxis); - const double deltaY = calculateNormContributionAlongAxisComponent(yAxis); - const double deltaZ = calculateNormContributionAlongAxisComponent(zAxis); - - /// Cached calculation forward origin - OriginParameter m_calculationForwardOrigin; - OriginParameter m_calculationBackwardOrigin; - NormalParameter m_calculationNormal; - - //Virtual forward origin (+width/2 separated along normal) - m_calculationForwardOrigin = OriginParameter(m_origin.getX() + deltaX, m_origin.getY() + deltaY, m_origin.getZ() + deltaZ); - - //invert the normal if the normals are defined in such a way that the origin does not appear in the bounded region of the forward plane. - m_calculationNormal = calculateEffectiveNormal(m_calculationForwardOrigin); - - //Virtual backward origin (-width/2 separated along normal) - m_calculationBackwardOrigin = OriginParameter (m_origin.getX() - deltaX, m_origin.getY() - deltaY, m_origin.getZ() - deltaZ); - - // OK, now we build the MDPlanes that represent these 3D planes - - // TODO: Handle mapping to the nd dimensions of the MDEventWorkspace - size_t nd=3; - - std::vector<coord_t> normalForward(nd,0); - std::vector<coord_t> pointForward(nd,0); - std::vector<coord_t> normalBackward(nd,0); - std::vector<coord_t> pointBackward(nd,0); - - // Create the normal and origin - for (size_t d=0; d<nd; d++) - { - normalForward[d] = -m_calculationNormal[int(d)]; - normalBackward[d] = m_calculationNormal[int(d)]; - pointForward[d] = m_calculationForwardOrigin[int(d)]; - pointBackward[d] = m_calculationBackwardOrigin[int(d)]; - } - - // Make the planes - MDPlane planeForward(normalForward, pointForward); - MDPlane planeBackward(normalBackward, pointBackward); - - // Add the 2 planes to the MDImplicitFunction. - this->addPlane(planeForward); - this->addPlane(planeBackward); - -} - -inline double PlaneImplicitFunction::calculateNormContributionAlongAxisComponent(const Mantid::Kernel::V3D& axis) const -{ - using Mantid::Kernel::V3D; - - NormalParameter normalUnit =m_normal.asUnitVector(); - const V3D normal(normalUnit.getX(), normalUnit.getY(), normalUnit.getZ()); - - const double hyp = m_width.getValue()/2; - - //Simple trigonometry. Essentially calculates adjacent along axis specified. - return hyp*dotProduct(normal, axis); -} - -inline NormalParameter PlaneImplicitFunction::calculateEffectiveNormal(const OriginParameter& forwardOrigin) const -{ - //Figure out whether the origin is bounded by the forward plane. - bool planesOutwardLooking = dotProduct(m_origin.getX() - forwardOrigin.getX(), m_origin.getY() - forwardOrigin.getY(), m_origin.getZ() - - forwardOrigin.getZ(), m_normal.getX(), m_normal.getY(), m_normal.getZ()) <= 0; - //Fix orientation if necessary. - if(planesOutwardLooking) - { - return m_normal; - } - else // Inward looking virtual planes. - { - return m_normal.reflect(); - } -} - -bool PlaneImplicitFunction::operator==(const PlaneImplicitFunction &other) const -{ - return this->m_normal == other.m_normal - && this->m_origin == other.m_origin - && this->m_width == other.m_width; -} - -bool PlaneImplicitFunction::operator!=(const PlaneImplicitFunction &other) const -{ - return !(*this == other); -} - -std::string PlaneImplicitFunction::getName() const -{ - return functionName(); -} - -double PlaneImplicitFunction::getOriginX() const -{ - return this->m_origin.getX(); -} - -double PlaneImplicitFunction::getOriginY() const -{ - return this->m_origin.getY(); -} - -double PlaneImplicitFunction::getOriginZ() const -{ - return this->m_origin.getZ(); -} - -double PlaneImplicitFunction::getNormalX() const -{ - return this->m_normal.getX(); -} - -double PlaneImplicitFunction::getNormalY() const -{ - return this->m_normal.getY(); -} - -double PlaneImplicitFunction::getNormalZ() const -{ - return this->m_normal.getZ(); -} - -double PlaneImplicitFunction::getWidth() const -{ - return this->m_width.getValue(); -} - -std::string PlaneImplicitFunction::toXMLString() const -{ - using namespace Poco::XML; - - AutoPtr<Document> pDoc = new Document; - AutoPtr<Element> functionElement = pDoc->createElement("Function"); - pDoc->appendChild(functionElement); - AutoPtr<Element> typeElement = pDoc->createElement("Type"); - AutoPtr<Text> typeText = pDoc->createTextNode(this->getName()); - typeElement->appendChild(typeText); - functionElement->appendChild(typeElement); - - AutoPtr<Element> paramListElement = pDoc->createElement("ParameterList"); - - AutoPtr<Text> formatText = pDoc->createTextNode("%s%s%s"); - paramListElement->appendChild(formatText); - functionElement->appendChild(paramListElement); - - std::stringstream xmlstream; - - DOMWriter writer; - writer.writeNode(xmlstream, pDoc); - - std::string formattedXMLString = boost::str(boost::format(xmlstream.str().c_str()) - % m_normal.toXMLString().c_str() % m_origin.toXMLString().c_str() % m_width.toXMLString()); - return formattedXMLString; -} - - - -PlaneImplicitFunction::~PlaneImplicitFunction() -{ -} - -} - -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunctionParser.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunctionParser.cpp deleted file mode 100644 index 44592585d480dcd69c23ccce838eab5da0764f2b..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/PlaneImplicitFunctionParser.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include <boost/interprocess/smart_ptr/unique_ptr.hpp> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/PlaneImplicitFunctionParser.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include "MantidAPI/ImplicitFunctionParserFactory.h" -#include "MantidMDAlgorithms/InvalidParameterParser.h" - -namespace Mantid -{ - namespace MDAlgorithms - { - - DECLARE_IMPLICIT_FUNCTION_PARSER(PlaneImplicitFunctionParser); - - PlaneImplicitFunctionParser::PlaneImplicitFunctionParser() : ImplicitFunctionParser(new InvalidParameterParser) - { - } - - API::ImplicitFunctionBuilder* PlaneImplicitFunctionParser::createFunctionBuilder(Poco::XML::Element* functionElement) - { - API::ImplicitFunctionBuilder* functionBuilder; - if("Function" != functionElement->localName()) - { - std::string message = "This is not a function element: " + functionElement->localName(); - throw std::invalid_argument(message); - } - - std::string type = functionElement->getChildElement("Type")->innerText(); - if(PlaneImplicitFunction::functionName() != type) - { - if(0 == m_successor.get()) - { - std::string message = "There is no successor function parser here for type: " + type; - throw std::runtime_error(message); - } - functionBuilder = m_successor->createFunctionBuilder(functionElement); - } - else - { - functionBuilder = parsePlaneFunction(functionElement); - } - return functionBuilder; - } - - void PlaneImplicitFunctionParser::setSuccessorParser(ImplicitFunctionParser* parser) - { - ImplicitFunctionParser::SuccessorType temp(parser); - this->m_successor.swap(temp); - } - - PlaneFunctionBuilder * PlaneImplicitFunctionParser::parsePlaneFunction(Poco::XML::Element* functionElement) - { - using namespace Poco::XML; - boost::interprocess::unique_ptr<PlaneFunctionBuilder, Mantid::API::DeleterPolicy<PlaneFunctionBuilder> > functionBuilder(new PlaneFunctionBuilder); - NodeList* parameterList = functionElement->getChildElement("ParameterList")->childNodes(); - - //Loop through all parameters and attempt to identify those that are known to belong to this implicit function type. - for(unsigned int i = 0; i < parameterList->length(); i++) - { - Element* parameterElement = dynamic_cast<Element*>(parameterList->item(i)); - boost::scoped_ptr<API::ImplicitFunctionParameter> parameter(this->parseParameter(parameterElement)); - if(NormalParameter::parameterName() == parameter->getName()) - { - NormalParameter* pCurr = dynamic_cast<NormalParameter*>(parameter.get()); - NormalParameter normal(pCurr->getX(), pCurr->getY(), pCurr->getZ()); - functionBuilder->addNormalParameter(normal); - } - else if(OriginParameter::parameterName() == parameter->getName()) - { - OriginParameter* pCurr = dynamic_cast<OriginParameter*>(parameter.get()); - OriginParameter origin(pCurr->getX(), pCurr->getY(), pCurr->getZ()); - functionBuilder->addOriginParameter(origin); - } - else if(WidthParameter::parameterName() == parameter->getName()) - { - WidthParameter* pCurr = dynamic_cast<WidthParameter*>(parameter.get()); - WidthParameter width(pCurr->getValue()); - functionBuilder->addWidthParameter(width); - } - else - { - std::string message = "The parameter cannot be processed or is unrecognised: " + parameter->getName(); - message += ". The parameter cannot be processed or is unrecognised: " + (dynamic_cast<InvalidParameter*>(parameter.get()))->getValue(); - throw std::invalid_argument(message); - } - - } - - return functionBuilder.release(); //convert to raw pointer and cancel smart management. - } - - PlaneImplicitFunctionParser::~PlaneImplicitFunctionParser() - { - } - - void PlaneImplicitFunctionParser::setParameterParser(Mantid::API::ImplicitFunctionParameterParser* parser) - { - Mantid::API::ImplicitFunctionParameterParser::SuccessorType temp(parser); - this->m_paramParserRoot.swap(temp); - } - } -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PlaneInterpreter.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PlaneInterpreter.cpp deleted file mode 100644 index 23c8ea6e008c5337043857737289340072a05ade..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/PlaneInterpreter.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "MantidMDAlgorithms/PlaneInterpreter.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include "MantidMDAlgorithms/CompositeImplicitFunction.h" - -namespace Mantid -{ -namespace MDAlgorithms -{ - -planeVector PlaneInterpreter::walkTree(CompositeImplicitFunction* compFunc) const -{ - using namespace Mantid::API; - planeVector flattenedboxes; - functionVector nestedFuncs = compFunc->getFunctions(); - for (unsigned int i = 0; i < nestedFuncs.size(); i++) - { - if (CompositeImplicitFunction::functionName() == nestedFuncs[i]->getName()) - { - CompositeImplicitFunction* composite = dynamic_cast<CompositeImplicitFunction*>(nestedFuncs[i].get()); - planeVector boxes = walkTree(composite); //recursive walk - flattenedboxes.insert(flattenedboxes.end(), boxes.begin(), boxes.end()); - } - else if (PlaneImplicitFunction::functionName() == nestedFuncs[i]->getName()) - { - boost::shared_ptr<PlaneImplicitFunction> spPlane = - boost::static_pointer_cast<PlaneImplicitFunction, Mantid::Geometry::MDImplicitFunction>(nestedFuncs[i]); - flattenedboxes.push_back(spPlane); - } - } - return flattenedboxes; -} - -std::vector<double> PlaneInterpreter::defaultRotationMatrix() const -{ - std::vector<double> identityMatrix(9, 0); - identityMatrix[0] = 1; - identityMatrix[4] = 1; - identityMatrix[8] = 1; - return identityMatrix; -} - -std::vector<double> PlaneInterpreter::operator()(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - return Execute(implicitFunction); -} - -std::vector<double> PlaneInterpreter::Execute(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - //A rotation matrix is by default an identity matrix. - std::vector<double> rotationMatrix = defaultRotationMatrix(); - - CompositeImplicitFunction* compFunction = - dynamic_cast<Mantid::MDAlgorithms::CompositeImplicitFunction*> (implicitFunction); - - if (compFunction != NULL) - { - //Flatten out box functions - planeVector flattenedPlanes = walkTree(compFunction); - - size_t size = flattenedPlanes.size(); - - //Only if there are any plane functions at all, get the last plane's rotation matrix. - if (size > 0) - { - //Use the last defined plane. - boost::shared_ptr<PlaneImplicitFunction> planeFunction = flattenedPlanes[size - 1]; - } - } - - return rotationMatrix; -} - -planeVector PlaneInterpreter::getAllPlanes(Mantid::Geometry::MDImplicitFunction* implicitFunction) const -{ - CompositeImplicitFunction* compFunction = - dynamic_cast<Mantid::MDAlgorithms::CompositeImplicitFunction*> (implicitFunction); - - planeVector flattenedPlanes; - if (compFunction != NULL) - { - //Flatten out box functions - flattenedPlanes = walkTree(compFunction); - } - return flattenedPlanes; -} - - -} -} diff --git a/Code/Mantid/Framework/MDAlgorithms/src/Vector3DParameterParser.cpp b/Code/Mantid/Framework/MDAlgorithms/src/Vector3DParameterParser.cpp index f04693a51af7d61cafa398a65a50d7dec7a68a7f..c540cb944b5668a409555e6b0ad4bd9c23d00d6c 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/Vector3DParameterParser.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/Vector3DParameterParser.cpp @@ -5,9 +5,9 @@ namespace Mantid { namespace MDAlgorithms { - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(NormalParameterParser) - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(OriginParameterParser) - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(UpParameterParser) - DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(PerpendicularParameterParser) + //DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(NormalParameterParser) + //DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(OriginParameterParser) + //DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(UpParameterParser) + //DECLARE_IMPLICIT_FUNCTION_PARAMETER_PARSER(PerpendicularParameterParser) } } diff --git a/Code/Mantid/Framework/MDAlgorithms/src/VectorMathematics.cpp b/Code/Mantid/Framework/MDAlgorithms/src/VectorMathematics.cpp deleted file mode 100644 index fe1cd078ec6ee6c4693f4535b634ab310c5535d3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/src/VectorMathematics.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "MantidMDAlgorithms/VectorMathematics.h" -namespace Mantid -{ -namespace MDAlgorithms -{ - -double dotProduct(Mantid::Kernel::V3D a, Mantid::Kernel::V3D b) -{ - using Mantid::Kernel::V3D; - return a.scalar_prod(b); -} - -double dotProduct(double a1, double a2, double a3, double b1, double b2, double b3) -{ - using Mantid::Kernel::V3D; - V3D a(a1, a2, a3); - V3D b(b1, b2, b3); - return a.scalar_prod(b); -} - -Mantid::Kernel::V3D crossProduct(Mantid::Kernel::V3D a, Mantid::Kernel::V3D b) -{ - using Mantid::Kernel::V3D; - return a.cross_prod(b); -} - -Mantid::Kernel::V3D crossProduct(double a1, double a2, double a3, double b1, double b2, - double b3) -{ - using Mantid::Kernel::V3D; - V3D a(a1, a2, a3); - V3D b(b1, b2, b3); - return a.cross_prod(b); -} - -double absolute(double a1, double a2, double a3) -{ - return sqrt((a1 * a1) + (a2 * a2) + (a3 * a3)); -} - -} -} diff --git a/Code/Mantid/Framework/MDAlgorithms/test/BoxBuilderTest.h b/Code/Mantid/Framework/MDAlgorithms/test/BoxBuilderTest.h deleted file mode 100644 index 6fca6b1ccbd71c474c23a86bc3c5e229df6f406b..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/BoxBuilderTest.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef BOX_FUNCTION_BUILDER_TEST_H_ -#define BOX_FUNCTION_BUILDER_TEST_H_ - -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/BoxFunctionBuilder.h" - -using namespace Mantid::MDAlgorithms; - -class BoxBuilderTest : public CxxTest::TestSuite -{ - - -public: - - void testCreateInvalidOriginThrows() - { - BoxFunctionBuilder builder; - builder.addWidthParameter(WidthParameter(1)); - builder.addHeightParameter(HeightParameter(1)); - builder.addDepthParameter(DepthParameter(1)); - TSM_ASSERT_THROWS("Building without a valid origin is not possible.", builder.create(), std::invalid_argument); - } - - void testCreateInvalidWidthThrows() - { - BoxFunctionBuilder builder; - builder.addHeightParameter(HeightParameter(1)); - builder.addDepthParameter(DepthParameter(1)); - builder.addOriginParameter(OriginParameter(1, 1, 1)); - TSM_ASSERT_THROWS("Building without a valid width is not possible.", builder.create(), std::invalid_argument); - } - - void testCreateInvalidDepthThrows() - { - BoxFunctionBuilder builder; - builder.addWidthParameter(WidthParameter(1)); - builder.addHeightParameter(HeightParameter(1)); - builder.addOriginParameter(OriginParameter(1, 1, 1)); - TSM_ASSERT_THROWS("Building without a valid depth is not possible.", builder.create(), std::invalid_argument); - } - - void testCreateInvalidHeightThrows() - { - BoxFunctionBuilder builder; - builder.addWidthParameter(WidthParameter(1)); - builder.addDepthParameter(DepthParameter(1)); - builder.addOriginParameter(OriginParameter(1, 1, 1)); - TSM_ASSERT_THROWS("Building without a valid height is not possible.", builder.create(), std::invalid_argument); - } - - void testCreate() - { - BoxFunctionBuilder builder; - builder.addWidthParameter(WidthParameter(1)); - builder.addHeightParameter(HeightParameter(2)); - builder.addDepthParameter(DepthParameter(3)); - builder.addOriginParameter(OriginParameter(4, 5, 6)); - Mantid::Geometry::MDImplicitFunction_sptr impFunction(builder.create()); - - BoxImplicitFunction* boxFunction = dynamic_cast<BoxImplicitFunction*>(impFunction.get()); - TSM_ASSERT("The function generated is not a boxFunction", boxFunction != NULL); - TSM_ASSERT_EQUALS("Box function has not been generated by builder correctly", 4.5 ,boxFunction->getUpperX()); - TSM_ASSERT_EQUALS("Box function has not been generated by builder correctly", 6 ,boxFunction->getUpperY()); - TSM_ASSERT_EQUALS("Box function has not been generated by builder correctly", 7.5 ,boxFunction->getUpperZ()); - } - -}; - - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionParserTest.h deleted file mode 100644 index 51931456741358022a74e23cd598e0b41872db12..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionParserTest.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef TEST_BOX_FUNCTION_PARSER_H_ -#define TEST_BOX_FUNCTION_PARSER_H_ - -#include "FunctionParserTest.h" -#include <vector> -#include <memory> -#include <boost/scoped_ptr.hpp> - -#include "MantidMDAlgorithms/BoxImplicitFunctionParser.h" -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -using namespace Mantid::MDAlgorithms; - -class BoxImplicitFunctionParserTest : public CxxTest::TestSuite, FunctionParserTest -{ - -public: - - void testBadXMLSchemaThrows(void) - { - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><X><Type>BoxImplicitFunction</Type><ParameterList></ParameterList></X>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - BoxImplicitFunctionParser functionParser; - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as Function element was expected, but not found.", functionParser.createFunctionBuilder(pRootElem), std::invalid_argument ); - } - - void testNoSuccessorFunctionParserThrows(void) - { - using namespace Mantid::MDAlgorithms; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>UnknownFunction</Type><ParameterList></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - BoxImplicitFunctionParser functionParser; - TSM_ASSERT_THROWS("There is no successor parser setup for the PlaneFunctionParser", functionParser.createFunctionBuilder(pRootElem), std::runtime_error ); - } - - void testCallsFunctionParserChain() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>OtherFunctionType</Type><ParameterList></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - MockFunctionParser* mockFuncParser = new MockFunctionParser(constructRootParameterParser()); - EXPECT_CALL(*mockFuncParser, createFunctionBuilder(testing::_)) - .Times(1); - - BoxImplicitFunctionParser functionParser; - functionParser.setSuccessorParser(mockFuncParser); - ImplicitFunctionBuilder* builder = functionParser.createFunctionBuilder(pRootElem); - delete builder; - - TSM_ASSERT("Incorrect calling of nested successor function parsers", testing::Mock::VerifyAndClearExpectations(mockFuncParser)) - } - - void testParseBoxFunction(void) - { - using namespace Mantid::API; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>BoxImplicitFunction</Type><ParameterList><Parameter><Type>WidthParameter</Type><Value>1</Value></Parameter><Parameter><Type>HeightParameter</Type><Value>2</Value></Parameter><Parameter><Type>DepthParameter</Type><Value>3</Value></Parameter><Parameter><Type>OriginParameter</Type><Value>4, 5, 6</Value></Parameter></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - BoxImplicitFunctionParser functionParser; - - - MockParameterParser* paramParser = new MockParameterParser; - EXPECT_CALL(*paramParser, createParameter(testing::_)) - .WillOnce(testing::Return(new WidthParameter(1))) - .WillOnce(testing::Return(new HeightParameter(2))) - .WillOnce(testing::Return(new DepthParameter(3))) - .WillOnce(testing::Return(new OriginParameter(4, 5, 6))) - ; - - functionParser.setParameterParser(paramParser); - - - ImplicitFunctionBuilder* implicitFunctionBuilder = functionParser.createFunctionBuilder(pRootElem); - Mantid::Geometry::MDImplicitFunction_sptr impFunction(implicitFunctionBuilder->create()); - - BoxImplicitFunction* boxFunction = dynamic_cast<BoxImplicitFunction*>(impFunction.get()); - TSM_ASSERT("A box implicit function should have been created from the xml.", boxFunction != NULL); - } - - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionTest.h b/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionTest.h deleted file mode 100644 index 0f22dc66ad6c4ac4e5020a7b76665a57b1f151d0..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/BoxImplicitFunctionTest.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef MANTID_MDALGORITHMS_BoxImplicitFunctionTEST_H_ -#define MANTID_MDALGORITHMS_BoxImplicitFunctionTEST_H_ - -#include "MantidKernel/System.h" -#include "MantidKernel/Timer.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include <boost/scoped_ptr.hpp> -#include <cxxtest/TestSuite.h> -#include <iomanip> -#include <iostream> - -using namespace Mantid; -using namespace Mantid::MDAlgorithms; -using namespace Mantid::API; - -//===================================================================================== -// Functional Tests -//===================================================================================== -class BoxImplicitFunctionTest : public CxxTest::TestSuite -{ -public: - - //Helper method to construct a valid vanilla box implicit function. - BoxImplicitFunction* constructBoxImplicitFunction() - { - OriginParameter origin(1, 2, 3); //Non-orthogonal normal used so that getters can be properly verified - WidthParameter width(5); - HeightParameter height(4); - DepthParameter depth(6); - return new BoxImplicitFunction(width, height, depth, origin); - } - - void testBoxImplicitFunctionConstruction(void) - { - boost::scoped_ptr<BoxImplicitFunction> box(constructBoxImplicitFunction()); - - TSM_ASSERT_EQUALS("Upper x component not wired-up correctly", 3.5, box->getUpperX()); - TSM_ASSERT_EQUALS("Lower x component not wired-up correctly", -1.5, box->getLowerX()); - TSM_ASSERT_EQUALS("Upper y component not wired-up correctly", 4, box->getUpperY()); - TSM_ASSERT_EQUALS("Lower y component not wired-up correctly", 0, box->getLowerY()); - TSM_ASSERT_EQUALS("Upper z component not wired-up correctly", 6, box->getUpperZ()); - TSM_ASSERT_EQUALS("Lower z component not wired-up correctly", 0, box->getLowerZ()); - } - - bool do_test(boost::scoped_ptr<BoxImplicitFunction> & box, double x, double y, double z) - { - Mantid::coord_t coords[3] = {x,y,z}; - return box->isPointContained(coords); - } - - void testEvaluateSeveralPoints() - { - boost::scoped_ptr<BoxImplicitFunction> box(constructBoxImplicitFunction()); - TSM_ASSERT("The point should have been found to be inside the region bounded by the box.", do_test(box, 0.5,0.5,0.5)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, 10,0,0)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, -10,0,0)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, 0,-10,0)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, 0,10,0)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, 0,0,-10)); - TSM_ASSERT("The point should not have been found to be inside the region bounded by the box.", !do_test(box, 0,0,10)); - } - - void testToXML() - { - boost::scoped_ptr<BoxImplicitFunction> box(constructBoxImplicitFunction()); - //string comparison on generated xml. - TSM_ASSERT_EQUALS("The xml generated by this function did not match the expected schema.", "<Function><Type>BoxImplicitFunction</Type><ParameterList><Parameter><Type>WidthParameter</Type><Value>5.0000</Value></Parameter><Parameter><Type>HeightParameter</Type><Value>4.0000</Value></Parameter><Parameter><Type>DepthParameter</Type><Value>6.0000</Value></Parameter><Parameter><Type>OriginParameter</Type><Value>1.0000, 2.0000, 3.0000</Value></Parameter></ParameterList></Function>", box->toXMLString()); - } - - void testEqual() - { - OriginParameter o(4, 5, 6); - WidthParameter width(1); - HeightParameter height(2); - DepthParameter depth(3); - BoxImplicitFunction A(width, height, depth, o); - BoxImplicitFunction B(width, height, depth, o); - TSM_ASSERT_EQUALS("These two objects should be considered equal.", A, B); - } - - void testNotEqual() - { - OriginParameter originA(4, 5, 6); - OriginParameter originB(4, 5, 2); //differs - WidthParameter widthA(1); - WidthParameter widthB(2); //differs - HeightParameter heightA(2); - HeightParameter heightB(3); //differs - DepthParameter depthA(3); - DepthParameter depthB(4); //differs - BoxImplicitFunction A(widthA, heightA, depthA, originA); //base-line to compare to. - BoxImplicitFunction B(widthB, heightA, depthA, originA); - BoxImplicitFunction C(widthA, heightB, depthA, originA); - BoxImplicitFunction D(widthA, heightA, depthB, originA); - BoxImplicitFunction E(widthA, heightA, depthA, originB); - - TSM_ASSERT_DIFFERS("These two objects should NOT be considered equal.", A, B); - TSM_ASSERT_DIFFERS("These two objects should NOT be considered equal.", A, C); - TSM_ASSERT_DIFFERS("These two objects should NOT be considered equal.", A, D); - TSM_ASSERT_DIFFERS("These two objects should NOT be considered equal.", A, E); - } - - -}; - - -#endif /* MANTID_MDALGORITHMS_BoxImplicitFunctionTEST_H_ */ - diff --git a/Code/Mantid/Framework/MDAlgorithms/test/BoxInterpreterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/BoxInterpreterTest.h deleted file mode 100644 index 77c5a7c247d4e3be0f7226ef22e7d803553c2bfb..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/BoxInterpreterTest.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef BOX_FUNCTION_INTERPRETER_TEST_H_ -#define BOX_FUNCTION_INTERPRETER_TEST_H_ - -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> -#include <boost/shared_ptr.hpp> -#include <MantidMDAlgorithms/BoxInterpreter.h> -#include <MantidMDAlgorithms/PlaneImplicitFunction.h> -#include <MantidMDAlgorithms/CompositeImplicitFunction.h> -#include <MantidMDAlgorithms/BoxImplicitFunction.h> - -using namespace Mantid::MDAlgorithms; - -class BoxInterpreterTest : public CxxTest::TestSuite -{ - - -public: - - void testFindsNothing() - { - class FakeImplicitFunction : public Mantid::Geometry::MDImplicitFunction - { - virtual std::string getName() const {return "FakeImplicitFunction";} - }; - - - FakeImplicitFunction fakeFunction; - BoxInterpreter boxInterpreter; - std::vector<double> box = boxInterpreter(&fakeFunction); - TSM_ASSERT_EQUALS("The box min x should be zero.", 0, box[0]); - TSM_ASSERT_EQUALS("The box max x should be zero.", 0, box[1]); - TSM_ASSERT_EQUALS("The box min y should be zero.", 0, box[2]); - TSM_ASSERT_EQUALS("The box max y should be zero.", 0, box[3]); - TSM_ASSERT_EQUALS("The box min z should be zero.", 0, box[4]); - TSM_ASSERT_EQUALS("The box max z should be zero.", 0, box[5]); - } - - void testFindsInnerSurfaces() - { - OriginParameter originOne(0,0,0); - WidthParameter widthOne(1); - HeightParameter heightOne(4); - DepthParameter depthOne(5); - BoxImplicitFunction* boxOne = new BoxImplicitFunction(widthOne, heightOne, depthOne, originOne); - - OriginParameter originTwo(0,0,0); - WidthParameter widthTwo(2); - HeightParameter heightTwo(3); - DepthParameter depthTwo(6); - BoxImplicitFunction* boxTwo = new BoxImplicitFunction(widthTwo, heightTwo, depthTwo, originTwo); - - CompositeImplicitFunction* innerComposite = new CompositeImplicitFunction; - innerComposite->addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxTwo)); - - CompositeImplicitFunction topComposite; - topComposite.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxOne)); - topComposite.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(innerComposite)); - - BoxInterpreter boxInterpreter; - std::vector<double> box = boxInterpreter(&topComposite); - - TSM_ASSERT_EQUALS("The box min x is incorrect", -0.5, box[0]); //From box1 - TSM_ASSERT_EQUALS("The box max x is incorrect", 0.5, box[1]); //From box1 - TSM_ASSERT_EQUALS("The box min y is incorrect", -1.5, box[2]); //From box2 - TSM_ASSERT_EQUALS("The box max y is incorrect", 1.5, box[3]); //From box2 - TSM_ASSERT_EQUALS("The box min z is incorrect", -2.5, box[4]); //From box1 - TSM_ASSERT_EQUALS("The box max z is incorrect", 2.5, box[5]); //From box1 - - } - - void testGetAllBoxes() - { - OriginParameter originOne(0, 0, 0); - WidthParameter widthOne(1); - HeightParameter heightOne(4); - DepthParameter depthOne(5); - BoxImplicitFunction* boxOne = new BoxImplicitFunction(widthOne, heightOne, depthOne, originOne); - - OriginParameter originTwo(0, 0, 0); - WidthParameter widthTwo(2); - HeightParameter heightTwo(3); - DepthParameter depthTwo(6); - BoxImplicitFunction* boxTwo = new BoxImplicitFunction(widthTwo, heightTwo, depthTwo, originTwo); - - CompositeImplicitFunction compositeFunction; - compositeFunction.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxOne)); - compositeFunction.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxTwo)); - - BoxInterpreter interpreter; - boxVector boxes = interpreter.getAllBoxes(&compositeFunction); - - TSM_ASSERT_EQUALS("Wrong number of boxes returned.", 2, boxes.size()); - } - - - -}; - - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionParserTest.h index 90eb7b8525a47ae25f4b315d002d7d362fb4a230..46603ce5fcc89688395eb3140e40f5ae2a78d9e7 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionParserTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionParserTest.h @@ -8,7 +8,7 @@ #include "MantidMDAlgorithms/InvalidParameterParser.h" #include "MantidMDAlgorithms/CompositeImplicitFunctionParser.h" -#include "MantidMDAlgorithms/PlaneImplicitFunctionParser.h" +//#include "MantidMDAlgorithms/PlaneImplicitFunctionParser.h" #include "MantidMDAlgorithms/CompositeImplicitFunction.h" #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> @@ -74,46 +74,46 @@ public: // TSM_ASSERT("Incorrect calling of nested successor function parsers", testing::Mock::VerifyAndClearExpectations(mockFuncParser)) // } - void testParseCompositeFunction(void) - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - Poco::XML::DOMParser pParser; - std::string xmlToParse = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + - "<Function>" + - "<Type>CompositeImplicitFunction</Type>" + - "<Function>" + - "<Type>PlaneImplicitFunction</Type>" + - "<ParameterList>" + - "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>" + - "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>" + - "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>" + - "</ParameterList>" + - "</Function>" + - "<Function>" + - "<Type>PlaneImplicitFunction</Type>" + - "<ParameterList>" + - "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>" + - "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>" + - "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>" + - "</ParameterList>" + - "</Function>" + - "</Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); + //void testParseCompositeFunction(void) + //{ + // using namespace Mantid::MDAlgorithms; + // using namespace Mantid::API; + // Poco::XML::DOMParser pParser; + // std::string xmlToParse = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + + // "<Function>" + + // "<Type>CompositeImplicitFunction</Type>" + + // "<Function>" + + // "<Type>PlaneImplicitFunction</Type>" + + // "<ParameterList>" + + // "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>" + + // "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>" + + // "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>" + + // "</ParameterList>" + + // "</Function>" + + // "<Function>" + + // "<Type>PlaneImplicitFunction</Type>" + + // "<ParameterList>" + + // "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>" + + // "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>" + + // "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>" + + // "</ParameterList>" + + // "</Function>" + + // "</Function>"; + // Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); + // Poco::XML::Element* pRootElem = pDoc->documentElement(); - CompositeImplicitFunctionParser functionParser; - ImplicitFunctionParser* planeParser = new PlaneImplicitFunctionParser; - planeParser->setParameterParser(constructRootParameterParser()); - functionParser.setSuccessorParser(planeParser); - ImplicitFunctionBuilder* implicitFunctionBuilder = functionParser.createFunctionBuilder(pRootElem); - Mantid::Geometry::MDImplicitFunction_sptr impFunction(implicitFunctionBuilder->create()); + // CompositeImplicitFunctionParser functionParser; + // ImplicitFunctionParser* planeParser = new PlaneImplicitFunctionParser; + // planeParser->setParameterParser(constructRootParameterParser()); + // functionParser.setSuccessorParser(planeParser); + // ImplicitFunctionBuilder* implicitFunctionBuilder = functionParser.createFunctionBuilder(pRootElem); + // Mantid::Geometry::MDImplicitFunction_sptr impFunction(implicitFunctionBuilder->create()); - CompositeImplicitFunction* compositeFunction = dynamic_cast<CompositeImplicitFunction*>(impFunction.get()); + // CompositeImplicitFunction* compositeFunction = dynamic_cast<CompositeImplicitFunction*>(impFunction.get()); - TSM_ASSERT("A composite implicit function should have been created from the xml.", compositeFunction != NULL); - TSM_ASSERT_EQUALS("The composite does not contain the expected number of next-level nested functions.", 2, compositeFunction->getNFunctions()) - } + // TSM_ASSERT("A composite implicit function should have been created from the xml.", compositeFunction != NULL); + // TSM_ASSERT_EQUALS("The composite does not contain the expected number of next-level nested functions.", 2, compositeFunction->getNFunctions()) + //} }; diff --git a/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterParserTest.h deleted file mode 100644 index 1af79b77c9d664d74e7df0783b37e3e9e4e3f6fd..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterParserTest.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef TEST_DEPTH_PARAMETER_PARSER_H_ -#define TEST_DEPTH_PARAMETER_PARSER_H_ - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidMDAlgorithms/MDParameterParserDeclarations.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -using namespace Mantid::MDAlgorithms; - -class DepthParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - - void testParseDepthParameterFragment() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>DepthParameter</Type><Value>3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - DepthParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - DepthParameter* pDepthParam = dynamic_cast<DepthParameter*>(iparam); - TSM_ASSERT("The paramter generated should be an DepthParamter", NULL != pDepthParam); - TSM_ASSERT_EQUALS("Numeric value has not been parsed correctly", 3, pDepthParam->getValue() ); - } - - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>UnknownParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - DepthParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - TSM_ASSERT("Chain of responsiblity did not execute as expected for OriginParameter type.", testing::Mock::VerifyAndClearExpectations(successor)); - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an origin parameter can be used to create a new one using the parser. - DepthParameter originalDepth(2); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalDepth.toXMLString()); - - DepthParameterParser depthParser; - DepthParameter* synthDepth = dynamic_cast<DepthParameter*>(depthParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. values do not match", originalDepth.getValue() , synthDepth->getValue()); - - delete synthDepth; - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterTest.h deleted file mode 100644 index 846a6800b3556baa9628447fe2b07854ed780b8e..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/DepthParameterTest.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef TEST_DEPTH_PARAMETER_H_ -#define TEST_DEPTH_PARAMETER_H_ - -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "SingleValueParameterBaseTest.h" -#include "MantidMDAlgorithms/DepthParameter.h" - -using namespace Mantid::MDAlgorithms; - -typedef SingleValueParameterTests<DepthParameter> SVPTDepth; -class DepthParameterTest : public CxxTest::TestSuite, public SVPTDepth -{ -public: - - void testGetName() - { - SVPTDepth::testGetName("DepthParameter"); - } - - void testIsValid() - { - SVPTDepth::testIsValid(); - } - - void testIsNotValid() - { - SVPTDepth::testIsNotValid(); - } - - void testAssigment() - { - SVPTDepth::testAssigment(); - } - - void testClone() - { - SVPTDepth::testClone(); - } - - void testCopy() - { - SVPTDepth::testCopy(); - } - - void testToXML() - { - SVPTDepth::testToXML(); - } - - void testEqual() - { - SVPTDepth::testEqual(); - } - - void testNotEqual() - { - SVPTDepth::testNotEqual(); - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterParserTest.h deleted file mode 100644 index 36efc06668958def89d7b17beddba379a0ed3d02..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterParserTest.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef TEST_HEIGHT_PARAMETER_PARSER_H_ -#define TEST_HEIGHT_PARAMETER_PARSER_H_ - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidMDAlgorithms/MDParameterParserDeclarations.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -using namespace Mantid::MDAlgorithms; - -class HeightParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - - void testParseHeightParameterFragment() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>HeightParameter</Type><Value>3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - HeightParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - HeightParameter* pHeightParam = dynamic_cast<HeightParameter*>(iparam); - TSM_ASSERT("The paramter generated should be an HeightParamter", NULL != pHeightParam); - TSM_ASSERT_EQUALS("Numeric value has not been parsed correctly", 3, pHeightParam->getValue() ); - } - - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>UnknownParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - HeightParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - TSM_ASSERT("Chain of responsiblity did not execute as expected for OriginParameter type.", testing::Mock::VerifyAndClearExpectations(successor)); - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an origin parameter can be used to create a new one using the parser. - HeightParameter originalHeight(2); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalHeight.toXMLString()); - - HeightParameterParser heightParser; - HeightParameter* synthHeight = dynamic_cast<HeightParameter*>(heightParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. values do not match", originalHeight.getValue() , synthHeight->getValue()); - - delete synthHeight; - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterTest.h deleted file mode 100644 index 247bfe8cd96050d9688aab7956df4d7cc3a43e1d..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/HeightParameterTest.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef TEST_HEIGHT_PARAMETER_H_ -#define TEST_HEIGHT_PARAMETER_H_ - -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "SingleValueParameterBaseTest.h" -#include "MantidMDAlgorithms/HeightParameter.h" - -using namespace Mantid::MDAlgorithms; - -typedef SingleValueParameterTests<HeightParameter> SVPTHeight; -class HeightParameterTest : public CxxTest::TestSuite, public SVPTHeight -{ -public: - - void testGetName() - { - SVPTHeight::testGetName("HeightParameter"); - } - - void testIsValid() - { - SVPTHeight::testIsValid(); - } - - void testIsNotValid() - { - SVPTHeight::testIsNotValid(); - } - - void testAssigment() - { - SVPTHeight::testAssigment(); - } - - void testClone() - { - SVPTHeight::testClone(); - } - - void testCopy() - { - SVPTHeight::testCopy(); - } - - void testToXML() - { - SVPTHeight::testToXML(); - } - - void testEqual() - { - SVPTHeight::testEqual(); - } - - void testNotEqual() - { - SVPTHeight::testNotEqual(); - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterParserTest.h deleted file mode 100644 index 24bfdc577dd9d961419fb0277bbf4909cf052fe1..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterParserTest.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef TEST_NORMAL_PARAMETER_PARSER_H_ -#define TEST_NORMAL_PARAMETER_PARSER_H_ - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/Vector3DParameterParser.h" -#include "MantidMDAlgorithms/NormalParameter.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -class NormalParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Testable sub-class - class ExposedNormalParameterParser : public Mantid::MDAlgorithms::NormalParameterParser - { - public: //Make protected method on base public. - Mantid::MDAlgorithms::NormalParameter* exposedParseNormalParameterValue(std::string value) - { - return this->parseVectorParameter(value); - } - }; - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - void testParseNormalParameterValue() - { - using namespace Mantid::MDAlgorithms; - ExposedNormalParameterParser parser; - NormalParameter* normalParameter = parser.exposedParseNormalParameterValue("1, 2, 3"); - TSM_ASSERT_EQUALS("The NormalParameter x value has not been parsed correctly.", 1, normalParameter->getX()); - TSM_ASSERT_EQUALS("The NormalParameter y value has not been parsed correctly.", 2, normalParameter->getY()); - TSM_ASSERT_EQUALS("The NormalParameter z value has not been parsed correctly.", 3, normalParameter->getZ()); - delete normalParameter; - } - - void testParseNormalParameterValueIncompleteThrows() - { - using namespace Mantid::MDAlgorithms; - ExposedNormalParameterParser parser; - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as only two of three normal components are provided.", parser.exposedParseNormalParameterValue("1, 2"), std::invalid_argument ); - } - - void testParseNormalParameterFragment() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>NormalParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - NormalParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - NormalParameter* pNormalParam = dynamic_cast<NormalParameter*>(iparam); - boost::scoped_ptr<NormalParameter> nparam(pNormalParam); - TSM_ASSERT("The paramter generated should be an NormalParamter", NULL != pNormalParam); - } - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>Unknown</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - NormalParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - UNUSED_ARG(iparam); - TSM_ASSERT("Chain of responsiblity did not execute as expected for NormalParameter type.", testing::Mock::VerifyAndClearExpectations(successor)); - delete iparam; - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an normal parameter can be used to create a new one using the parser. - using namespace Mantid::MDAlgorithms; - NormalParameter originalNormal(1, 2, 3); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalNormal.toXMLString()); - - NormalParameterParser normalParser; - NormalParameter* synthNormal = dynamic_cast<NormalParameter*>(normalParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. x-values do not match", originalNormal.getX() , synthNormal->getX()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. y-values do not match", originalNormal.getY() , synthNormal->getY()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. z-values do not match", originalNormal.getZ() , synthNormal->getZ()); - - delete synthNormal; - } -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterTest.h deleted file mode 100644 index 94ce2c990276cf2648eb7736a85076b36e315c60..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/NormalParameterTest.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef TEST_NORMAL_PARAMETER_H_ -#define TEST_NORMAL_PARAMETER_H_ - -#include <cxxtest/TestSuite.h> -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/NormalParameter.h" - -class NormalParameterTest: public CxxTest::TestSuite -{ -public: - - void testCreate() - { - - Mantid::MDAlgorithms::NormalParameter normal(0, 1, 2); - TSM_ASSERT_EQUALS("NormalParameter getX() is not wired-up correctly.", 0, normal.getX()); - TSM_ASSERT_EQUALS("NormalParameter getY() is not wired-up correctly.", 1, normal.getY()); - TSM_ASSERT_EQUALS("NormalParameter getZ() is not wired-up correctly.", 2, normal.getZ()); - } - - void testIsValid() - { - Mantid::MDAlgorithms::NormalParameter normal(0, 0, 0); - TSM_ASSERT_EQUALS("The NormalParameter should be valid.", true, normal.isValid()); - } - - void testAssigment() - { - using namespace Mantid::MDAlgorithms; - NormalParameter A(0, 1, 2); - NormalParameter B; - A = B; - TSM_ASSERT_EQUALS("Assigned NormalParameter getX() is not correct.", 0, A.getX()); - TSM_ASSERT_EQUALS("Assigned NormalParameter getY() is not correct.", 0, A.getY()); - TSM_ASSERT_EQUALS("Assigned NormalParameter getZ() is not correct.", 0, A.getZ()); - TSM_ASSERT_EQUALS("Assigned NormalParameter isValid() is not correct.", false, A.isValid()); - } - - void testDefaultInvalid() - { - Mantid::MDAlgorithms::NormalParameter normal; - TSM_ASSERT_EQUALS("Should be invalid!", false, normal.isValid()); - } - - void testIsNotValid() - { - Mantid::MDAlgorithms::NormalParameter normal(0, 0, 0); - TSM_ASSERT_EQUALS("NormalParameter constructed via parameterless constructor should be invalid.", - true, normal.isValid()); - } - - void testClone() - { - Mantid::MDAlgorithms::NormalParameter original(0, 1, 2); - boost::scoped_ptr<Mantid::MDAlgorithms::NormalParameter> cloned(original.clone()); - - TSM_ASSERT_EQUALS("Cloned NormalParameter getX() is not same as original.", 0, cloned->getX()); - TSM_ASSERT_EQUALS("Cloned NormalParameter getY() is not same as original.", 1, cloned->getY()); - TSM_ASSERT_EQUALS("Cloned NormalParameter getZ() is not same as original.", 2, cloned->getZ()); - TSM_ASSERT_EQUALS("Cloned NormalParameter isValid() is not same as original.", original.isValid(), - cloned->isValid()); - } - - void testCopy() - { - Mantid::MDAlgorithms::NormalParameter original(0, 1, 2); - Mantid::MDAlgorithms::NormalParameter copy(original); - TSM_ASSERT_EQUALS("Copied NormalParameter getX() is not same as original.", 0, copy.getX()); - TSM_ASSERT_EQUALS("Copied NormalParameter getY() is not same as original.", 1, copy.getY()); - TSM_ASSERT_EQUALS("Copied NormalParameter getZ() is not same as original.", 2, copy.getZ()); - TSM_ASSERT_EQUALS("Copied NormalParameter isValid() is not same as original.", original.isValid(), - copy.isValid()); - } - - void testGetNameFunctionsEquivalent() - { - Mantid::MDAlgorithms::NormalParameter normal(0, 0, 0); -TSM_ASSERT_EQUALS ("The static name and the dynamic name of the NormalParameter do not match.", normal.getName(), Mantid::MDAlgorithms::NormalParameter::parameterName()) -} - -void testReflect() -{ - Mantid::MDAlgorithms::NormalParameter normal(1, 2, 3); - Mantid::MDAlgorithms::NormalParameter reflected = normal.reflect(); - - TSM_ASSERT_EQUALS("Reflected normal x value is not negative of original.", -1, reflected.getX() ); - TSM_ASSERT_EQUALS("Reflected normal y value is not negative of original.", -2, reflected.getY() ); - TSM_ASSERT_EQUALS("Reflected normal z value is not negative of original.", -3, reflected.getZ() ); -} - -void testEqual() -{ - using namespace Mantid::MDAlgorithms; - NormalParameter A(1, 2, 3); - NormalParameter B(1, 2, 3); - - TSM_ASSERT_EQUALS("The two Normal instances are not considered equal, but should be.", A, B); -} - -void testNotEqual() -{ - //Test unequal combinations - using namespace Mantid::MDAlgorithms; - NormalParameter A(1, 2, 3); - NormalParameter B(0, 2, 3); - NormalParameter C(1, 0, 3); - NormalParameter D(1, 2, 0); - TSM_ASSERT_DIFFERS("The two Normal instances are considered equal, but should not be.", A, B); - TSM_ASSERT_DIFFERS("The two Normal instances are considered equal, but should not be.", A, C); - TSM_ASSERT_DIFFERS("The two Normal instances are considered equal, but should not be.", A, D); -} - -void testIsUnitVector() -{ - using namespace Mantid::MDAlgorithms; - NormalParameter notUnit(1, 2, 3); - NormalParameter unit(0, 1, 0); - TSM_ASSERT("This is not a unit vector", !notUnit.isUnitVector()); - TSM_ASSERT("This is a unit vector", unit.isUnitVector()); -} - - -void testAsUnitVector() -{ - using namespace Mantid::MDAlgorithms; - NormalParameter A(2, 0, 0); - NormalParameter B = A.asUnitVector(); - TSM_ASSERT("This is not a unit vector", !A.isUnitVector()); - TSM_ASSERT("This is a unit vector", B.isUnitVector()); - TSM_ASSERT_EQUALS("x component incorrect", 1, B.getX()); - TSM_ASSERT_EQUALS("y component incorrect", 0, B.getY()); - TSM_ASSERT_EQUALS("z component incorrect", 0, B.getZ()); -} - -void testArrayTypeAccess() -{ - Mantid::MDAlgorithms::NormalParameter normal(1, 2, 3); - TSM_ASSERT_EQUALS("Wrong componenet returned", 1, normal[0]); - TSM_ASSERT_EQUALS("Wrong componenet returned", 2, normal[1]); - TSM_ASSERT_EQUALS("Wrong componenet returned", 3, normal[2]); -} - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterParserTest.h deleted file mode 100644 index 0e3696825ce8fd48aef076516037b1769240a22a..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterParserTest.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef TEST_ORIGIN_PARAMETER_PARSER_H_ -#define TEST_ORIGIN_PARAMETER_PARSER_H_ - -#include <cxxtest/TestSuite.h> -#include <vector> -#include <boost/scoped_ptr.hpp> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidMDAlgorithms/Vector3DParameterParser.h" -#include "MantidMDAlgorithms/OriginParameter.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -class OriginParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Testable sub-class - class ExposedOriginParameterParser : public Mantid::MDAlgorithms::OriginParameterParser - { - public: //Make protected method on base public. - Mantid::MDAlgorithms::OriginParameter* exposedParseOriginParameterValue(std::string value) - { - return this->parseVectorParameter(value); - } - }; - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - void testParseOriginParameterValue() - { - using namespace Mantid::MDAlgorithms; - ExposedOriginParameterParser parser; - OriginParameter* originParameter = parser.exposedParseOriginParameterValue("1, 2, 3"); - TSM_ASSERT_EQUALS("The OriginParameter x value has not been parsed correctly.", 1, originParameter->getX()); - TSM_ASSERT_EQUALS("The OriginParameter y value has not been parsed correctly.", 2, originParameter->getY()); - TSM_ASSERT_EQUALS("The OriginParameter z value has not been parsed correctly.", 3, originParameter->getZ()); - delete originParameter; - } - - void testParseOriginParameterValueIncompleteThrows() - { - ExposedOriginParameterParser parser; - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as only two of three origin components are provided.", parser.exposedParseOriginParameterValue("1, 2"), std::invalid_argument ); - } - - void testParseOriginParameterFragment() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - OriginParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - OriginParameter* pOriginParam = dynamic_cast<OriginParameter*>(iparam); - boost::scoped_ptr<OriginParameter> oparam(pOriginParam); - TSM_ASSERT("The paramter generated should be an OriginParamter", NULL != pOriginParam); - } - - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>UnknownParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - OriginParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - - TSM_ASSERT("Chain of responsiblity did not execute as expected for OriginParameter type.", testing::Mock::VerifyAndClearExpectations(successor)) - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an origin parameter can be used to create a new one using the parser. - using namespace Mantid::MDAlgorithms; - OriginParameter originalOrigin(1, 2, 3); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalOrigin.toXMLString()); - - OriginParameterParser originParser; - OriginParameter* synthOrigin = dynamic_cast<OriginParameter*>(originParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. x-values do not match", originalOrigin.getX() , synthOrigin->getX()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. y-values do not match", originalOrigin.getY() , synthOrigin->getY()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. z-values do not match", originalOrigin.getZ() , synthOrigin->getZ()); - - delete synthOrigin; - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterTest.h deleted file mode 100644 index b1317e4f666942febc1d80ffc8a83fb7ba857f45..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/OriginParameterTest.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef TEST_ORIGIN_PARAMETER_H_ -#define TEST_ORIGIN_PARAMETER_H_ - -#include <cxxtest/TestSuite.h> -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/OriginParameter.h" - -class OriginParameterTest : public CxxTest::TestSuite -{ -public: - - void testCreate() - { - - Mantid::MDAlgorithms::OriginParameter origin(0, 1, 2); - TSM_ASSERT_EQUALS("OriginParameter getX() is not wired-up correctly.", 0, origin.getX() ); - TSM_ASSERT_EQUALS("OriginParameter getY() is not wired-up correctly.", 1, origin.getY() ); - TSM_ASSERT_EQUALS("OriginParameter getZ() is not wired-up correctly.", 2, origin.getZ() ); - } - - void testIsValid() - { - Mantid::MDAlgorithms::OriginParameter origin(0, 0, 0); - TSM_ASSERT_EQUALS("The OriginParameter should be valid.", true, origin.isValid()); - } - - - void testDefaultInvalid() - { - Mantid::MDAlgorithms::OriginParameter origin; - TSM_ASSERT_EQUALS("Should be invalid!", false, origin.isValid() ); - } - - void testAssigment() - { - using namespace Mantid::MDAlgorithms; - OriginParameter A(0, 1, 2); - OriginParameter B; - A = B; - TSM_ASSERT_EQUALS("Assigned OriginParameter getX() is not correct.", 0, A.getX() ); - TSM_ASSERT_EQUALS("Assigned OriginParameter getY() is not correct.", 0, A.getY() ); - TSM_ASSERT_EQUALS("Assigned OriginParameter getZ() is not correct.", 0, A.getZ() ); - TSM_ASSERT_EQUALS("Assigned OriginParameter isValid() is not same as original.", B.isValid(), A.isValid() ); - } - - void testClone() - { - Mantid::MDAlgorithms::OriginParameter original(0, 1, 2); - boost::scoped_ptr<Mantid::MDAlgorithms::OriginParameter> cloned(original.clone()); - - TSM_ASSERT_EQUALS("Cloned OriginParameter getX() is not same as original.", 0, cloned->getX() ); - TSM_ASSERT_EQUALS("Cloned OriginParameter getY() is not same as original.", 1, cloned->getY() ); - TSM_ASSERT_EQUALS("Cloned OriginParameter getZ() is not same as original.", 2, cloned->getZ() ); - TSM_ASSERT_EQUALS("Cloned OriginParameter isValid() is not same as original.", original.isValid(), cloned->isValid() ); - } - - void testCopy() - { - Mantid::MDAlgorithms::OriginParameter original(0, 1, 2); - Mantid::MDAlgorithms::OriginParameter copy(original); - TSM_ASSERT_EQUALS("Copied OriginParameter getX() is not same as original.", 0, copy.getX() ); - TSM_ASSERT_EQUALS("Copied OriginParameter getY() is not same as original.", 1, copy.getY() ); - TSM_ASSERT_EQUALS("Copied OriginParameter getZ() is not same as original.", 2, copy.getZ() ); - TSM_ASSERT_EQUALS("Copied OriginParameter isValid() is not same as original.", original.isValid(), copy.isValid() ); - } - - void testGetNameFunctionsEquivalent() - { - Mantid::MDAlgorithms::OriginParameter origin(0, 0, 0); - TSM_ASSERT_EQUALS("The static name and the dynamic name of the OriginParameter do not match.", origin.getName(), Mantid::MDAlgorithms::OriginParameter::parameterName()); - } - - void testToXML() - { - Mantid::MDAlgorithms::OriginParameter origin(1, 2, 3); - TSM_ASSERT_EQUALS("The generated xml for the OriginParameter does not match the specification.", "<Parameter><Type>OriginParameter</Type><Value>1.0000, 2.0000, 3.0000</Value></Parameter>", origin.toXMLString()); - } - - void testEqual() - { - using namespace Mantid::MDAlgorithms; - OriginParameter A(1, 2, 3); - OriginParameter B(1, 2, 3); - - TSM_ASSERT_EQUALS("The two origin instances are not considered equal, but should be.", A, B); - } - - void testNotEqual() - { - //Test unequal combinations - using namespace Mantid::MDAlgorithms; - OriginParameter A(1, 2, 3); - OriginParameter B(0, 2, 3); - OriginParameter C(1, 0, 3); - OriginParameter D(1, 2, 0); - TSM_ASSERT_DIFFERS("The two origin instances are considered equal, but should not be.", A, B); - TSM_ASSERT_DIFFERS("The two origin instances are considered equal, but should not be.", A, C); - TSM_ASSERT_DIFFERS("The two origin instances are considered equal, but should not be.", A, D); - } - - void testArrayTypeAccess() - { - Mantid::MDAlgorithms::OriginParameter origin(1, 2, 3); - TSM_ASSERT_EQUALS("Wrong componenet returned", 1, origin[0]); - TSM_ASSERT_EQUALS("Wrong componenet returned", 2, origin[1]); - TSM_ASSERT_EQUALS("Wrong componenet returned", 3, origin[2]); - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterParserTest.h deleted file mode 100644 index 5bc621427af27d849b41a0563ae26eecde6189c5..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterParserTest.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef TEST_PERPENDICULAR_PARAMETER_PARSER_H -#define TEST_PERPENDICULAR_PARAMETER_PARSER_H - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/Vector3DParameterParser.h" -#include "MantidMDAlgorithms/PerpendicularParameter.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -class PerpendicularParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Testable sub-class - class ExposedPerpendicularParameterParser : public Mantid::MDAlgorithms::PerpendicularParameterParser - { - public: //Make protected method on base public. - Mantid::MDAlgorithms::PerpendicularParameter* exposedParsePerpendicularParameterValue(std::string value) - { - return this->parseVectorParameter(value); - } - }; - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - void testParsePerpendicularParameterValue() - { - using namespace Mantid::MDAlgorithms; - ExposedPerpendicularParameterParser parser; - PerpendicularParameter* perpendicularParameter = parser.exposedParsePerpendicularParameterValue("1, 2, 3"); - TSM_ASSERT_EQUALS("The PerpendicularParameter x value has not been parsed correctly.", 1, perpendicularParameter->getX()); - TSM_ASSERT_EQUALS("The PerpendicularParameter y value has not been parsed correctly.", 2, perpendicularParameter->getY()); - TSM_ASSERT_EQUALS("The PerpendicularParameter z value has not been parsed correctly.", 3, perpendicularParameter->getZ()); - delete perpendicularParameter; - } - - void testParsePerpendicularParameterValueIncompleteThrows() - { - using namespace Mantid::MDAlgorithms; - ExposedPerpendicularParameterParser parser; - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as only two of the three components are provided.", parser.exposedParsePerpendicularParameterValue("1, 2"), std::invalid_argument ); - } - - void testParsePerpendicularParameterFragment() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>PerpendicularParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - PerpendicularParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - PerpendicularParameter* pNormalParam = dynamic_cast<PerpendicularParameter*>(iparam); - boost::scoped_ptr<PerpendicularParameter> nparam(pNormalParam); - TSM_ASSERT("The paramter generated should be an PerpendicularParamter", NULL != pNormalParam); - } - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>Unknown</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - PerpendicularParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - - TSM_ASSERT("Chain of responsiblity did not execute as expected for PerpendicularParameter type.", testing::Mock::VerifyAndClearExpectations(successor)) - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an normal parameter can be used to create a new one using the parser. - using namespace Mantid::MDAlgorithms; - PerpendicularParameter originalPerpendicular(1, 2, 3); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalPerpendicular.toXMLString()); - - PerpendicularParameterParser perpendicularParser; - PerpendicularParameter* synthPerpendicular = dynamic_cast<PerpendicularParameter*>(perpendicularParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. x-values do not match", originalPerpendicular.getX() , synthPerpendicular->getX()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. y-values do not match", originalPerpendicular.getY() , synthPerpendicular->getY()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. z-values do not match", originalPerpendicular.getZ() , synthPerpendicular->getZ()); - - delete synthPerpendicular; - } -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterTest.h deleted file mode 100644 index 36cd34858a26c9ca4ab63dfa9d8f5666d8e5c8f3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PerpendicularParameterTest.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef PERPENDICULAR_PARAMETER_TEST_H_ -#define PERPENDICULAR_PARAMETER_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/PerpendicularParameter.h" - -class PerpendicularParameterTest: public CxxTest::TestSuite -{ -public: - - void testAsImplicitFunctionParameter() - { - using Mantid::MDAlgorithms::PerpendicularParameter; - using Mantid::API::ImplicitFunctionParameter; - //Ensure that CRTP does not interfere with base/derived behaviour. - PerpendicularParameter perpendicular(0, 1, 2); - ImplicitFunctionParameter& param = perpendicular; - - //Verify polymoric usage using clone method implementation. - boost::scoped_ptr<ImplicitFunctionParameter> cloned(param.clone()); - TSM_ASSERT_EQUALS("Clone not working via base type", PerpendicularParameter::parameterName(), cloned->getName()) - } - - void testCreate() - { - - Mantid::MDAlgorithms::PerpendicularParameter perpendicular(0, 1, 2); - TSM_ASSERT_EQUALS("PerpendicularParameter getX() is not wired-up correctly.", 0, perpendicular.getX() ); - TSM_ASSERT_EQUALS("PerpendicularParameter getY() is not wired-up correctly.", 1, perpendicular.getY() ); - TSM_ASSERT_EQUALS("PerpendicularParameter getZ() is not wired-up correctly.", 2, perpendicular.getZ() ); - } - - void testIsValid() - { - Mantid::MDAlgorithms::PerpendicularParameter perpendicular(0, 0, 0); - TSM_ASSERT_EQUALS("The PerpendicularParameter should be valid.", true, perpendicular.isValid()); - } - - - void testDefaultInvalid() - { - Mantid::MDAlgorithms::PerpendicularParameter perpendicular; - TSM_ASSERT_EQUALS("Should be invalid!", false, perpendicular.isValid() ); - } - - void testAssigment() - { - using namespace Mantid::MDAlgorithms; - PerpendicularParameter A(0, 1, 2); - PerpendicularParameter B; - B = A; - TSM_ASSERT_EQUALS("Assigned PerpendicularParameter getX() is not correct.", 0, B.getX() ); - TSM_ASSERT_EQUALS("Assigned PerpendicularParameter getY() is not correct.", 1, B.getY() ); - TSM_ASSERT_EQUALS("Assigned PerpendicularParameter getZ() is not correct.", 2, B.getZ() ); - TSM_ASSERT_EQUALS("Assigned PerpendicularParameter isValid() is not same as original.", B.isValid(), A.isValid() ); - } - - void testClone() - { - Mantid::MDAlgorithms::PerpendicularParameter original(0, 1, 2); - boost::scoped_ptr<Mantid::MDAlgorithms::PerpendicularParameter> cloned(original.clone()); - - TSM_ASSERT_EQUALS("Cloned PerpendicularParameter getX() is not same as original.", 0, cloned->getX() ); - TSM_ASSERT_EQUALS("Cloned PerpendicularParameter getY() is not same as original.", 1, cloned->getY() ); - TSM_ASSERT_EQUALS("Cloned PerpendicularParameter getZ() is not same as original.", 2, cloned->getZ() ); - TSM_ASSERT_EQUALS("Cloned PerpendicularParameter isValid() is not same as original.", original.isValid(), cloned->isValid() ); - } - - void testCopy() - { - Mantid::MDAlgorithms::PerpendicularParameter original(0, 1, 2); - Mantid::MDAlgorithms::PerpendicularParameter copy(original); - TSM_ASSERT_EQUALS("Copied PerpendicularParameter getX() is not same as original.", 0, copy.getX() ); - TSM_ASSERT_EQUALS("Copied PerpendicularParameter getY() is not same as original.", 1, copy.getY() ); - TSM_ASSERT_EQUALS("Copied PerpendicularParameter getZ() is not same as original.", 2, copy.getZ() ); - TSM_ASSERT_EQUALS("Copied PerpendicularParameter isValid() is not same as original.", original.isValid(), copy.isValid() ); - } - - void testGetNameFunctionsEquivalent() - { - Mantid::MDAlgorithms::PerpendicularParameter perpendicular(0, 0, 0); - TSM_ASSERT_EQUALS("The static name and the dynamic name of the PerpendicularParameter do not match.", perpendicular.getName(), Mantid::MDAlgorithms::PerpendicularParameter::parameterName()); - } - - void testToXML() - { - Mantid::MDAlgorithms::PerpendicularParameter perpendicular(1, 2, 3); - TSM_ASSERT_EQUALS("The generated xml for the PerpendicularParameter does not match the specification.", "<Parameter><Type>PerpendicularParameter</Type><Value>1.0000, 2.0000, 3.0000</Value></Parameter>", perpendicular.toXMLString()); - } - - void testEqual() - { - using namespace Mantid::MDAlgorithms; - PerpendicularParameter A(1, 2, 3); - PerpendicularParameter B(1, 2, 3); - - TSM_ASSERT_EQUALS("The two perpendicular instances are not considered equal, but should be.", A, B); - } - - void testNotEqual() - { - //Test unequal combinations - using namespace Mantid::MDAlgorithms; - PerpendicularParameter A(1, 2, 3); - PerpendicularParameter B(0, 2, 3); - PerpendicularParameter C(1, 0, 3); - PerpendicularParameter D(1, 2, 0); - TSM_ASSERT_DIFFERS("The two perpendicular instances are considered equal, but should not be.", A, B); - TSM_ASSERT_DIFFERS("The two perpendicular instances are considered equal, but should not be.", A, C); - TSM_ASSERT_DIFFERS("The two perpendicular instances are considered equal, but should not be.", A, D); - } -}; -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PlaneFunctionBuilderTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PlaneFunctionBuilderTest.h deleted file mode 100644 index 1f036d6dfa0b7ea7022fbc93b4650cbc0a73648f..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PlaneFunctionBuilderTest.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef PLANE_FUNCTION_BUILDER_TEST_H_ -#define PLANE_FUNCTION_BUILDER_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/PlaneFunctionBuilder.h" -#include "MantidMDAlgorithms/NormalParameter.h" -#include "MantidMDAlgorithms/OriginParameter.h" -#include "MantidMDAlgorithms/InvalidParameter.h" - -class PlaneFunctionBuilderTest: public CxxTest::TestSuite -{ -public: - - void testCreate() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - PlaneFunctionBuilder builder; - OriginParameter o(1, 2, 3); - NormalParameter n(4, 5, 6); - WidthParameter width(10); - - builder.addOriginParameter(o); - builder.addNormalParameter(n); - builder.addWidthParameter(width); - - Mantid::Geometry::MDImplicitFunction_sptr impFunc(builder.create()); - PlaneImplicitFunction * planeFunc = dynamic_cast<PlaneImplicitFunction*> (impFunc.get()); - - TSM_ASSERT("The function generated by the builder is not a plane function type.", NULL != planeFunc); - TSM_ASSERT_EQUALS("Origin x value not passed/built in correctly.", 1, planeFunc->getOriginX()); - TSM_ASSERT_EQUALS("Origin y value not passed/built in correctly.", 2, planeFunc->getOriginY()); - TSM_ASSERT_EQUALS("Origin z value not passed/built in correctly.", 3, planeFunc->getOriginZ()); - TSM_ASSERT_EQUALS("Normal x value not passed/built in correctly.", 4, planeFunc->getNormalX()); - TSM_ASSERT_EQUALS("Normal y value not passed/built in correctly.", 5, planeFunc->getNormalY()); - TSM_ASSERT_EQUALS("Normal z value not passed/built in correctly.", 6, planeFunc->getNormalZ()); - TSM_ASSERT_EQUALS("Width value not passed/built in correctly.", 10, planeFunc->getWidth()); - - } - - void testCreateWithoutNormalThrows() - { - using namespace Mantid::MDAlgorithms; - - PlaneFunctionBuilder builder; - OriginParameter origin(0, 0, 0); - WidthParameter width(0); - builder.addOriginParameter(origin); - builder.addWidthParameter(width); - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as normal parameter is missing.", - builder.create(), std::invalid_argument); - } - - void testCreateWithoutOriginThrows() - { - using namespace Mantid::MDAlgorithms; - - PlaneFunctionBuilder builder; - NormalParameter normal(4, 5, 6); - WidthParameter width(0); - builder.addNormalParameter(normal); - builder.addWidthParameter(width); - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as origin parameter is missing.", - builder.create(), std::invalid_argument); - } - - void testCreateWithoutWidthThrows() - { - using namespace Mantid::MDAlgorithms; - - PlaneFunctionBuilder builder; - NormalParameter normal(4, 5, 6); - OriginParameter origin(0, 0, 0); - builder.addOriginParameter(origin); - builder.addNormalParameter(normal); - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as width parameter is missing.", - builder.create(), std::invalid_argument); - } - - - //If the origin parameter is provided more than once, the latest values should be adopted. - void testOverwriteOrigin() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - PlaneFunctionBuilder builder; - - OriginParameter origin1(1, 2, 3); - OriginParameter origin2(4, 5, 6); - NormalParameter normal(0, 0, 0); - WidthParameter width(0); - builder.addOriginParameter(origin1); - //Overwrite origin - builder.addOriginParameter(origin2); - builder.addNormalParameter(normal); - builder.addWidthParameter(width); - Mantid::Geometry::MDImplicitFunction_sptr impFunc(builder.create()); - PlaneImplicitFunction * planeFunc = dynamic_cast<PlaneImplicitFunction*> (impFunc.get()); - - TSM_ASSERT_EQUALS("Origin x value not overwritten with newer value.", 4, planeFunc->getOriginX()); - TSM_ASSERT_EQUALS("Origin y value not overwritten with newer value.", 5, planeFunc->getOriginY()); - TSM_ASSERT_EQUALS("Origin z value not overwritten with newer value.", 6, planeFunc->getOriginZ()); - } - - //If the normal parameter is provided more than once, the latest values should be adopted. - void testOverwiteNormal() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - PlaneFunctionBuilder builder; - - OriginParameter origin(1, 2, 3); - NormalParameter normal1(1, 2, 3); - NormalParameter normal2(4, 5, 6); - WidthParameter width(0); - builder.addNormalParameter(normal1); - //Overwrite normal - builder.addNormalParameter(normal2); - builder.addOriginParameter(origin); - builder.addWidthParameter(width); - Mantid::Geometry::MDImplicitFunction_sptr impFunc(builder.create()); - PlaneImplicitFunction * planeFunc = dynamic_cast<PlaneImplicitFunction*> (impFunc.get()); - - TSM_ASSERT("The function generated by the builder is not a plane function type.", NULL != planeFunc); - TSM_ASSERT_EQUALS("Normal x value not passed/built in correctly.", 4, planeFunc->getNormalX()); - TSM_ASSERT_EQUALS("Normal y value not passed/built in correctly.", 5, planeFunc->getNormalY()); - TSM_ASSERT_EQUALS("Normal z value not passed/built in correctly.", 6, planeFunc->getNormalZ()); - } - - void testOverwiteWidth() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - PlaneFunctionBuilder builder; - - OriginParameter origin(1, 2, 3); - NormalParameter normal(1, 2, 3); - WidthParameter width1(0); - WidthParameter width2(1); - - builder.addNormalParameter(normal); - builder.addOriginParameter(origin); - //Add width - builder.addWidthParameter(width1); - //Overwrite width - builder.addWidthParameter(width2); - Mantid::Geometry::MDImplicitFunction_sptr impFunc(builder.create()); - PlaneImplicitFunction * planeFunc = dynamic_cast<PlaneImplicitFunction*> (impFunc.get()); - - TSM_ASSERT("The function generated by the builder is not a plane function type.", NULL != planeFunc); - TSM_ASSERT_EQUALS("Width value not passed/built in correctly.", 1, planeFunc->getWidth()); - } -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionParserTest.h deleted file mode 100644 index 92671593e5ca462a7c08fad5957b3e5bd6e9798d..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionParserTest.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef TEST_PLANE_IMPLICIT_FUNCTION_PARSERS_H_ -#define TEST_PLANE_IMPLICIT_FUNCTION_PARSERS_H_ - - -#include <vector> -#include <memory> -#include "FunctionParserTest.h" - -#include "MantidMDAlgorithms/PlaneImplicitFunctionParser.h" -#include "MantidMDAlgorithms/Vector3DParameterParser.h" -#include "MantidMDAlgorithms/InvalidParameterParser.h" -#include "MantidMDAlgorithms/PlaneFunctionBuilder.h" -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - - -class PlaneImplicitFunctionParserTest : public CxxTest::TestSuite, FunctionParserTest -{ -private: - - class ExposedPlaneFunctionParser : public Mantid::MDAlgorithms::PlaneImplicitFunctionParser - { - public: - Mantid::MDAlgorithms::PlaneFunctionBuilder* exposedParsePlaneFunction(Poco::XML::Element* functionElement) - { - return this->parsePlaneFunction(functionElement); - } - MOCK_METHOD1(createFunctionBuilder, Mantid::API::ImplicitFunctionBuilder*(Poco::XML::Element* functionElement)); - }; - -public: - - void testCallsParameterParserChain() - { - using namespace Mantid::MDAlgorithms; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>PlaneImplicitFunction</Type><ParameterList><Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter><Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter><Parameter><Type>WidthParameter</Type><Value>1</Value></Parameter></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - MockParameterParser* paramParser = new MockParameterParser; - EXPECT_CALL(*paramParser, createParameter(testing::_)) - .WillOnce(testing::Return(new OriginParameter(0, 0, 0))) - .WillOnce(testing::Return(new NormalParameter(0, 0, 0))) - .WillOnce(testing::Return(new WidthParameter(1))); - - PlaneImplicitFunctionParser functionParser; - functionParser.setParameterParser(paramParser); - Mantid::API::ImplicitFunctionBuilder* builder = functionParser.createFunctionBuilder(pRootElem); - delete builder; - - TSM_ASSERT("Incorrect calling of nested matched parameter parsers!", testing::Mock::VerifyAndClearExpectations(paramParser)) - } - - void testCallsFunctionParserChain() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>X</Type><ParameterList></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - MockFunctionParser* mockFuncParser = new MockFunctionParser(constructRootParameterParser()); - EXPECT_CALL(*mockFuncParser, createFunctionBuilder(testing::_)) - .Times(1); - - PlaneImplicitFunctionParser functionParser; - functionParser.setParameterParser(constructRootParameterParser()); - functionParser.setSuccessorParser(mockFuncParser); - ImplicitFunctionBuilder* builder = functionParser.createFunctionBuilder(pRootElem); - delete builder; - - TSM_ASSERT("Incorrect calling of nested successor function parsers", testing::Mock::VerifyAndClearExpectations(mockFuncParser)) - } - - void testParsePlaneFunction(void) - { - using namespace Mantid::MDAlgorithms; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + - "<Function>" + - "<Type>PlaneImplicitFunction</Type>"+ - "<ParameterList>"+ - "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>"+ - "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>"+ - "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>"+ - "</ParameterList>"+ - "</Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - ExposedPlaneFunctionParser functionParser; - functionParser.setParameterParser(constructRootParameterParser()); - PlaneFunctionBuilder* planeBuilder = functionParser.exposedParsePlaneFunction(pRootElem); - Mantid::Geometry::MDImplicitFunction_sptr impFunction(planeBuilder->create()); - - PlaneImplicitFunction* planeFunction = dynamic_cast<PlaneImplicitFunction*>(impFunction.get()); - - TSM_ASSERT("A plane implicit function should have been created from the xml.", planeFunction != NULL); - - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of origin parameter parser to give the correct ox value.", 1, planeFunction->getOriginX()); - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of origin parameter parser to give the correct oy value.", 2, planeFunction->getOriginY()); - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of origin parameter parser to give the correct oz value.", 3, planeFunction->getOriginZ()); - - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of normal parameter parser to give the correct nx value.", -1, planeFunction->getNormalX()); - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of normal parameter parser to give the correct ny value.", -2, planeFunction->getNormalY()); - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of normal parameter parser to give the correct nz value.", -3, planeFunction->getNormalZ()); - - TSM_ASSERT_EQUALS("The plane parser did not direct the parsing of width parameter parser to give the correct nx value.", 7, planeFunction->getWidth()); - } - - void testBadXMLSchemaThrows(void) - { - using namespace Mantid::MDAlgorithms; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + - "<X>" + //Valid XML, but invalid schema - "<Type>PlaneImplicitFunction</Type>"+ - "<ParameterList>"+ - "<Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter>"+ - "<Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter>"+ - "<Parameter><Type>WidthParameter</Type><Value>7</Value></Parameter>"+ - "</ParameterList>"+ - "</X>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - PlaneImplicitFunctionParser functionParser; - functionParser.setParameterParser(constructRootParameterParser()); - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as Function element was expected, but not found.", functionParser.createFunctionBuilder(pRootElem), std::invalid_argument ); - } - - void testNoSuccessorFunctionParserThrows(void) - { - using namespace Mantid::MDAlgorithms; - - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Function><Type>OtherImplicitFunction</Type><ParameterList><Parameter><Type>NormalParameter</Type><Value>-1, -2, -3</Value></Parameter><Parameter><Type>OriginParameter</Type><Value>1, 2, 3</Value></Parameter></ParameterList></Function>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - PlaneImplicitFunctionParser functionParser; - functionParser.setParameterParser(constructRootParameterParser()); - TSM_ASSERT_THROWS("There is no successor parser setup for the PlaneImplicitFunctionParser", functionParser.createFunctionBuilder(pRootElem), std::runtime_error ); - } - - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionTest.h deleted file mode 100644 index 56dca3d3e8d89232cf78de5d47c03c92a3b9948b..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PlaneImplicitFunctionTest.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef MANTID_MDALGORITHMS_MDPLANEIMPLICITFUNCTIONTEST_H_ -#define MANTID_MDALGORITHMS_MDPLANEIMPLICITFUNCTIONTEST_H_ - -#include <cxxtest/TestSuite.h> -#include <cmath> -#include <vector> -#include <MantidKernel/Matrix.h> -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include <boost/shared_ptr.hpp> - - -using namespace Mantid::MDAlgorithms; - - -//===================================================================================== -// Functional Tests -//===================================================================================== -class PlaneImplicitFunctionTest: public CxxTest::TestSuite -{ -private: - - Mantid::MDAlgorithms::NormalParameter normal; - Mantid::MDAlgorithms::OriginParameter origin; - Mantid::MDAlgorithms::WidthParameter width; - const double PI; - -public: - // This pair of boilerplate methods prevent the suite being created statically - // This means the constructor isn't called when running other tests - static PlaneImplicitFunctionTest *createSuite() { return new PlaneImplicitFunctionTest(); } - static void destroySuite( PlaneImplicitFunctionTest *suite ) { delete suite; } - - PlaneImplicitFunctionTest() : - normal(1, 1, 1), origin(2, 3, 4), width(2), PI(3.14159265) - { - } - - void testPlaneImplicitFunctionConstruction(void) - { - NormalParameter normalParam(1, 0, 0); - - PlaneImplicitFunction plane(normalParam, origin, width); - TSM_ASSERT_EQUALS("Normal x component not wired-up correctly", 1, plane.getNormalX()); - TSM_ASSERT_EQUALS("Normal y component not wired-up correctly", 0, plane.getNormalY()); - TSM_ASSERT_EQUALS("Normal z component not wired-up correctly", 0, plane.getNormalZ()); - TSM_ASSERT_EQUALS("Origin x component not wired-up correctly", 2, plane.getOriginX()); - TSM_ASSERT_EQUALS("Origin y component not wired-up correctly", 3, plane.getOriginY()); - TSM_ASSERT_EQUALS("Origin z component not wired-up correctly", 4, plane.getOriginZ()); - TSM_ASSERT_EQUALS("Width component not wired-up correctly", 2, plane.getWidth()); - - } - - /** Perform the test with a standard plane */ - bool do_test(double x, double y, double z) - { - NormalParameter tNormal(1, 2, 3); - OriginParameter tOrigin(0, 0, 0); - WidthParameter tWidth(std::sqrt((1 * 1) + (2 * 2.0) + (3 * 3)) * 2.0); // Width set up so that points 1,2,3 and -1,-2,-3 are within boundary - PlaneImplicitFunction plane(tNormal, tOrigin, tWidth); - Mantid::coord_t coords[3] = {x,y,z}; - return plane.isPointContained(coords); - } - - void testEvaluateInsidePointReflectNormal() //Test that plane automatically relects normals where necessary. - { - NormalParameter tNormal(1, 2, 3); - NormalParameter rNormal = tNormal.reflect(); - OriginParameter tOrigin(0, 0, 0); - WidthParameter tWidth(std::sqrt((1 * 1) + (2 * 2.0) + (3 * 3)) * 2.0); // Width set up so that points 1,2,3 and -1,-2,-3 are within boundary - - PlaneImplicitFunction plane(rNormal, tOrigin, tWidth); - - Mantid::coord_t coords[3] = {0.999,2,3}; - TSM_ASSERT("The point should have been found to be inside the region bounded by the plane after the normal was reflected.", plane.isPointContained(coords)); - } - - void testEvaluatePointOutsideForwardPlane() - { - TSM_ASSERT("The point should have been found to be outside the region bounded by the plane.", !do_test(1.001,2.001,3.001)); - } - - void testEvaluatePointOutsideBackwardPlane() - { - TSM_ASSERT("The point should have been found to be outside the region bounded by the plane.", !do_test(-1.001,-2.001,-3.001)); - } - - void testEvaluateOnPlanePointDecreaseX() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be inside the region bounded by the plane after an incremental decrease in the point x-value.", - do_test(0.999,2,3)); - } - - void testEvaluateOnPlanePointIncreaseX() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be outside the region bounded by the plane after an incremental increase in the point x-value.", - !do_test(1.001,2,3)); - } - - void testEvaluateOnPlanePointDecreaseY() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be inside the region bounded by the plane after an incremental decrease in the point y-value.", - do_test(1,1.999,3)); - } - - void testEvaluateOnPlanePointIncreaseY() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be outside the region bounded by the plane after an incremental increase in the point y-value.", - !do_test(1,2.001,3)); - } - - void testEvaluateOnPlanePointDecreaseZ() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be inside the region bounded by the plane after an incremental decrease in the point z-value.", - do_test(1,2,2.999)); - } - - void testEvaluateOnPlanePointIncreaseZ() - { - TSM_ASSERT("The point (while on the plane origin) should have been found to be outside the region bounded by the plane after an incremental increase in the point z-value.", - !do_test(1,2,3.001)); - } - - - void testToXML() - { - NormalParameter tNormal(1, 0, 0); - OriginParameter tOrigin(0, 0, 0); - WidthParameter tWidth(3); - PlaneImplicitFunction plane(tNormal, tOrigin, tWidth); - TSM_ASSERT_EQUALS("The xml generated by this function did not match the expected schema.", "<Function><Type>PlaneImplicitFunction</Type><ParameterList><Parameter><Type>NormalParameter</Type><Value>1.0000, 0.0000, 0.0000</Value></Parameter><Parameter><Type>OriginParameter</Type><Value>0.0000, 0.0000, 0.0000</Value></Parameter><Parameter><Type>WidthParameter</Type><Value>3.0000</Value></Parameter></ParameterList></Function>", plane.toXMLString()); - } - - void testEqual() - { - NormalParameter n(1, 2, 3); - OriginParameter o(4, 5, 6); - WidthParameter width(10); - PlaneImplicitFunction A(n, o, width); - PlaneImplicitFunction B(n, o, width); - TSM_ASSERT_EQUALS("These two objects should be considered equal.", A, B); - } - - void testNotEqual() - { - NormalParameter n1(1, 2, 3); - OriginParameter o1(4, 5, 6); - WidthParameter width1(10); - NormalParameter n2(0, 0, 0); - OriginParameter o2(0, 0, 0); - WidthParameter width2(0); - PlaneImplicitFunction A(n1, o1, width1); //Base comparison - PlaneImplicitFunction B(n2, o1, width1); //Differ normal only - PlaneImplicitFunction C(n1, o2, width1); //Differ origin only - PlaneImplicitFunction D(n1, o1, width2); //Differ width only - TSM_ASSERT_DIFFERS("These two objects should not be considered equal.", A, B); - TSM_ASSERT_DIFFERS("These two objects should not be considered equal.", A, C); - TSM_ASSERT_DIFFERS("These two objects should not be considered equal.", A, D); - } - - -}; - -#endif /* MANTID_MDALGORITHMS_MDPLANEIMPLICITFUNCTIONTEST_H_ */ diff --git a/Code/Mantid/Framework/MDAlgorithms/test/PlaneInterpreterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/PlaneInterpreterTest.h deleted file mode 100644 index 0530ef9b2a28108fcf2e46ec51e4018f4a0313d6..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/PlaneInterpreterTest.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef PLANE_FUNCTION_INTERPRETER_TEST_H_ -#define PLANE_FUNCTION_INTERPRETER_TEST_H_ - -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include <cxxtest/TestSuite.h> -#include <boost/shared_ptr.hpp> -#include <MantidKernel/Matrix.h> -#include <MantidMDAlgorithms/NormalParameter.h> -#include <MantidMDAlgorithms/OriginParameter.h> -#include <MantidMDAlgorithms/PlaneInterpreter.h> -#include <MantidMDAlgorithms/PlaneImplicitFunction.h> -#include <MantidMDAlgorithms/CompositeImplicitFunction.h> -#include <gsl/gsl_blas.h> - -using namespace Mantid::MDAlgorithms; -using Mantid::Kernel::V3D; - -class PlaneInterpreterTest: public CxxTest::TestSuite -{ - -private: - - // Mock type to represent other implicit functions. - class MockImplicitFunction: public Mantid::Geometry::MDImplicitFunction - { - public: - MOCK_METHOD1(isPointContained, bool(const Mantid::coord_t* pPoint)); - MOCK_METHOD1(isPointContained, bool(const std::vector<Mantid::coord_t>&)); - // Unhide base class methods (avoids Intel compiler warning) - using MDImplicitFunction::isPointContained; - MOCK_CONST_METHOD0(getName, std::string()); - MOCK_CONST_METHOD0(toXMLString, std::string()); - ~MockImplicitFunction() - { - } - }; - - // Helper method to determine wheter a given vector represents an identity matrix. - bool isIdentityMatrix(std::vector<double> rotationMatrix) - { - double identityArry[] ={1, 0, 0, 0, 1, 0, 0, 0, 1}; - std::vector<double> identityVector(identityArry, identityArry + sizeof(identityArry)/sizeof(*identityArry)); - - return rotationMatrix == identityVector; - } - -public: - - void testNoCompositeGivesDefault() - { - MockImplicitFunction mockFunction; - EXPECT_CALL(mockFunction, getName()).Times(0); // Should never get this far. as no composite available. - - PlaneInterpreter interpreter; - std::vector<double> rotationMatrix = interpreter(&mockFunction); - TSM_ASSERT_EQUALS("An identity matrix was expected.", true, isIdentityMatrix(rotationMatrix)); - } - - void testNoPlanesGivesDefault() - { - CompositeImplicitFunction compositeFunction; - MockImplicitFunction* mockFunction = new MockImplicitFunction; - EXPECT_CALL(*mockFunction, getName()).Times(2).WillRepeatedly(testing::Return("MockFunction")); - - boost::shared_ptr<MockImplicitFunction> spMockFunction(mockFunction); - compositeFunction.addFunction(spMockFunction); - - PlaneInterpreter interpreter; - std::vector<double> rotationMatrix = interpreter(&compositeFunction); - TSM_ASSERT_EQUALS("An identity matrix was expected.", true, isIdentityMatrix(rotationMatrix)); - } - - void testGetAllPlanes() - { - CompositeImplicitFunction compositeFunction; - NormalParameter normalA(1, 0, 0); - NormalParameter normalB(1, 1, 1); - OriginParameter origin(0, 0, 0); - WidthParameter width(3); - boost::shared_ptr<PlaneImplicitFunction> functionA(new PlaneImplicitFunction(normalA, origin, - width)); - boost::shared_ptr<PlaneImplicitFunction> functionB(new PlaneImplicitFunction(normalB, origin, - width)); - MockImplicitFunction* mock_function = new MockImplicitFunction(); - EXPECT_CALL(*mock_function, getName()).Times(2).WillRepeatedly(testing::Return("Mock_Function")); - boost::shared_ptr<MockImplicitFunction> functionC(mock_function); - compositeFunction.addFunction(functionA); // Is a plane (counted) - compositeFunction.addFunction(functionB); // Is a plane (counted) - compositeFunction.addFunction(functionC); // Not a plane (not counted) - PlaneInterpreter interpreter; - planeVector planes = interpreter.getAllPlanes(&compositeFunction); - - TSM_ASSERT_EQUALS("There should have been exactly two planes in the product vector.", 2, planes.size()); - TSM_ASSERT("Mock function has not been used as expected.", testing::Mock::VerifyAndClear(mock_function)); - } - -}; - - - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/UpParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/UpParameterParserTest.h deleted file mode 100644 index b0899125c2d68210c9d3a2f2dd51f1720ac64b11..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/UpParameterParserTest.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef TEST_UP_PARAMETER_PARSER_H -#define TEST_UP_PARAMETER_PARSER_H - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <vector> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/Vector3DParameterParser.h" -#include "MantidMDAlgorithms/UpParameter.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> - -class UpParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Testable sub-class - class ExposedUpParameterParser : public Mantid::MDAlgorithms::UpParameterParser - { - public: //Make protected method on base public. - Mantid::MDAlgorithms::UpParameter* exposedParseUpParameterValue(std::string value) - { - return this->parseVectorParameter(value); - } - }; - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - void testParseUpParameterValue() - { - using namespace Mantid::MDAlgorithms; - ExposedUpParameterParser parser; - UpParameter* UpParameter = parser.exposedParseUpParameterValue("1, 2, 3"); - TSM_ASSERT_EQUALS("The UpParameter x value has not been parsed correctly.", 1, UpParameter->getX()); - TSM_ASSERT_EQUALS("The UpParameter y value has not been parsed correctly.", 2, UpParameter->getY()); - TSM_ASSERT_EQUALS("The UpParameter z value has not been parsed correctly.", 3, UpParameter->getZ()); - delete UpParameter; - } - - void testParseUpParameterValueIncompleteThrows() - { - using namespace Mantid::MDAlgorithms; - ExposedUpParameterParser parser; - TSM_ASSERT_THROWS("Should have thrown invalid_argument exception as only two of the three components are provided.", parser.exposedParseUpParameterValue("1, 2"), std::invalid_argument ); - } - - void testParseUpParameterFragment() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>UpParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - UpParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - UpParameter* pNormalParam = dynamic_cast<UpParameter*>(iparam); - boost::scoped_ptr<UpParameter> nparam(pNormalParam); - TSM_ASSERT("The paramter generated should be an PerpendicularParamter", NULL != pNormalParam); - } - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - using namespace Poco::XML; - - DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>Unknown</Type><Value>1, 2, 3</Value></Parameter>"; - Document* pDoc = pParser.parseString(xmlToParse); - Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - UpParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - - TSM_ASSERT("Chain of responsibility did not execute as expected for UpParameter type.", testing::Mock::VerifyAndClearExpectations(successor)) - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an normal parameter can be used to create a new one using the parser. - using namespace Mantid::MDAlgorithms; - UpParameter originalUp(1, 2, 3); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalUp.toXMLString()); - - UpParameterParser perpendicularParser; - UpParameter* synthUp = dynamic_cast<UpParameter*>(perpendicularParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. x-values do not match", originalUp.getX() , synthUp->getX()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. y-values do not match", originalUp.getY() , synthUp->getY()); - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. z-values do not match", originalUp.getZ() , synthUp->getZ()); - - delete synthUp; - } -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/UpParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/UpParameterTest.h deleted file mode 100644 index f071201677bed1962290426b935d2ed2a021add3..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/UpParameterTest.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef _PARAMETER_TEST_H_ -#define _PARAMETER_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "MantidMDAlgorithms/UpParameter.h" -#include "MantidMDAlgorithms/Vector3DParameter.h" - -class UpParameterTest: public CxxTest::TestSuite -{ -public: - - void testAsImplicitFunctionUpParameter() - { - using Mantid::MDAlgorithms::UpParameter; - using Mantid::API::ImplicitFunctionParameter; - //Ensure that CRTP does not interfere with base/derived behaviour. - UpParameter up(0, 1, 2); - ImplicitFunctionParameter& param = up; - - //Verify polymoric usage using clone method implementation. - boost::scoped_ptr<ImplicitFunctionParameter> cloned(param.clone()); - TSM_ASSERT_EQUALS("Clone not working via base type", UpParameter::parameterName(), cloned->getName()) - } - - void testCreate() - { - - Mantid::MDAlgorithms::UpParameter up(0, 1, 2); - TSM_ASSERT_EQUALS("UpParameter getX() is not wired- correctly.", 0, up.getX() ); - TSM_ASSERT_EQUALS("UpParameter getY() is not wired- correctly.", 1, up.getY() ); - TSM_ASSERT_EQUALS("UpParameter getZ() is not wired- correctly.", 2, up.getZ() ); - } - - void testIsValid() - { - Mantid::MDAlgorithms::UpParameter up(0, 0, 0); - TSM_ASSERT_EQUALS("The UpParameter should be valid.", true, up.isValid()); - } - - - void testDefaultInvalid() - { - Mantid::MDAlgorithms::UpParameter up; - TSM_ASSERT_EQUALS("Should be invalid!", false, up.isValid() ); - } - - void testAssigment() - { - using namespace Mantid::MDAlgorithms; - UpParameter A(0, 1, 2); - UpParameter B; - B = A; - TSM_ASSERT_EQUALS("Assigned UpParameter getX() is not correct.", 0, B.getX() ); - TSM_ASSERT_EQUALS("Assigned UpParameter getY() is not correct.", 1, B.getY() ); - TSM_ASSERT_EQUALS("Assigned UpParameter getZ() is not correct.", 2, B.getZ() ); - TSM_ASSERT_EQUALS("Assigned UpParameter isValid() is not same as original.", B.isValid(), A.isValid() ); - } - - void testClone() - { - Mantid::MDAlgorithms::UpParameter original(0, 1, 2); - boost::scoped_ptr<Mantid::MDAlgorithms::UpParameter> cloned(original.clone()); - - TSM_ASSERT_EQUALS("Cloned UpParameter getX() is not same as original.", 0, cloned->getX() ); - TSM_ASSERT_EQUALS("Cloned UpParameter getY() is not same as original.", 1, cloned->getY() ); - TSM_ASSERT_EQUALS("Cloned UpParameter getZ() is not same as original.", 2, cloned->getZ() ); - TSM_ASSERT_EQUALS("Cloned UpParameter isValid() is not same as original.", original.isValid(), cloned->isValid() ); - } - - void testCopy() - { - Mantid::MDAlgorithms::UpParameter original(0, 1, 2); - Mantid::MDAlgorithms::UpParameter copy(original); - TSM_ASSERT_EQUALS("Copied UpParameter getX() is not same as original.", 0, copy.getX() ); - TSM_ASSERT_EQUALS("Copied UpParameter getY() is not same as original.", 1, copy.getY() ); - TSM_ASSERT_EQUALS("Copied UpParameter getZ() is not same as original.", 2, copy.getZ() ); - TSM_ASSERT_EQUALS("Copied UpParameter isValid() is not same as original.", original.isValid(), copy.isValid() ); - } - - void testGetNameFunctionsEquivalent() - { - Mantid::MDAlgorithms::UpParameter up(0, 0, 0); - TSM_ASSERT_EQUALS("The static name and the dynamic name of the UpParameter do not match.", up.getName(), Mantid::MDAlgorithms::UpParameter::parameterName()); - } - - void testToXML() - { - Mantid::MDAlgorithms::UpParameter up(1, 2, 3); - TSM_ASSERT_EQUALS("The generated xml for the UpParameter does not match the specification.", "<Parameter><Type>UpParameter</Type><Value>1.0000, 2.0000, 3.0000</Value></Parameter>", up.toXMLString()); - } - - void testEqual() - { - using namespace Mantid::MDAlgorithms; - UpParameter A(1, 2, 3); - UpParameter B(1, 2, 3); - - TSM_ASSERT_EQUALS("The two up instances are not considered equal, but should be.", A, B); - } - - void testNotEqual() - { - //Test unequal combinations - using namespace Mantid::MDAlgorithms; - UpParameter A(1, 2, 3); - UpParameter B(0, 2, 3); - UpParameter C(1, 0, 3); - UpParameter D(1, 2, 0); - TSM_ASSERT_DIFFERS("The two up instances are considered equal, but should not be.", A, B); - TSM_ASSERT_DIFFERS("The two up instances are considered equal, but should not be.", A, C); - TSM_ASSERT_DIFFERS("The two up instances are considered equal, but should not be.", A, D); - } -}; - - - -#endif - diff --git a/Code/Mantid/Framework/MDAlgorithms/test/VectorMathematicsTest.h b/Code/Mantid/Framework/MDAlgorithms/test/VectorMathematicsTest.h deleted file mode 100644 index a246829a484e33603ca5853d86c96b5a6d4ad987..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/VectorMathematicsTest.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef VECTOR_MATHEMATICS_TEST_H_ -#define VECTOR_MATHEMATICS_TEST_H_ - -#include "MantidKernel/V3D.h" -#include "MantidMDAlgorithms/VectorMathematics.h" - -using namespace Mantid::MDAlgorithms; - -class VectorMathematicsTest : public CxxTest::TestSuite -{ - -public: - - void testDotProductOrthogonal(void) - { - //a.b = 0 if a and b are orthogonal. - double a1 = 0; - double a2 = 1; - double a3 = 0; - double b1 = 1; - double b2 = 0; - double b3 = 0; - double result = dotProduct(a1, a2, a3, b1, b2, b3); - TSM_ASSERT_EQUALS("The calculated dot product is incorrect", 0, result); - } - - void testDotProductParallel(void) - { - //a.b = 1 if a and b are parallel. - double a1 = 1; - double a2 = 0; - double a3 = 0; - double b1 = 1; - double b2 = 0; - double b3 = 0; - double result = dotProduct(a1, a2, a3, b1, b2, b3); - TSM_ASSERT_EQUALS("The calculated dot product is incorrect", 1, result); - } - - void testCrossProductOrthogonal(void) - { - using Mantid::Kernel::V3D; - double a1 = 1; - double a2 = 0; - double a3 = 0; - double b1 = 0; - double b2 = 1; - double b3 = 0; - V3D result = crossProduct(a1, a2, a3, b1, b2, b3); - TSM_ASSERT_EQUALS("The calculated x component of the cross product is incorrect", 0, result.X()); - TSM_ASSERT_EQUALS("The calculated y component of the cross product is incorrect", 0, result.Y()); - TSM_ASSERT_EQUALS("The calculated z component of the cross product is incorrect", 1, result.Z()); - } - - void testCrossProductParallel(void) - { - using Mantid::Kernel::V3D; - double a1 = 1; - double a2 = 0; - double a3 = 0; - double b1 = 1; - double b2 = 0; - double b3 = 0; - V3D result = crossProduct(a1, a2, a3, b1, b2, b3); - TSM_ASSERT_EQUALS("The calculated x component of the cross product is incorrect", 0, result.X()); - TSM_ASSERT_EQUALS("The calculated y component of the cross product is incorrect", 0, result.Y()); - TSM_ASSERT_EQUALS("The calculated z component of the cross product is incorrect", 0, result.Z()); - } - - void testAbsolute(void) - { - double a = 0; - double b = 3; - double c = 4; - TSM_ASSERT_EQUALS("The magnitude value has been calculated incorrectly", 5, absolute(a, b, c)); - } - - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterParserTest.h b/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterParserTest.h deleted file mode 100644 index 7b0cf14c3fdfe27a64087b66454d9d9114ef9211..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterParserTest.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef TEST_WIDTH_PARAMETER_PARSER_H_ -#define TEST_WIDTH_PARAMETER_PARSER_H_ - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidMDAlgorithms/MDParameterParserDeclarations.h" - -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/DOM/NodeIterator.h> -#include <Poco/DOM/NodeFilter.h> -#include <Poco/File.h> -#include <Poco/Path.h> -using namespace Mantid::MDAlgorithms; -class WidthParameterParserTest : public CxxTest::TestSuite -{ -private: - - //Mock class - class SuccessorParameterParser : public Mantid::API::ImplicitFunctionParameterParser - { - public: - MOCK_METHOD1(createParameter, Mantid::API::ImplicitFunctionParameter*(Poco::XML::Element* parameterElement)); - MOCK_METHOD1(setSuccessorParser, void(Mantid::API::ImplicitFunctionParameterParser* parameterParser)); - }; - -public: - - - void testParseWidthParameterFragment() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>WidthParameter</Type><Value>3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - WidthParameterParser parser; - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - WidthParameter* pWidthParam = dynamic_cast<WidthParameter*>(iparam); - TSM_ASSERT("The paramter generated should be an WidthParamter", NULL != pWidthParam); - TSM_ASSERT_EQUALS("Numeric value has not been parsed correctly", 3, pWidthParam->getValue() ); - } - - void testChainOfResponsibility() - { - using namespace Mantid::MDAlgorithms; - Poco::XML::DOMParser pParser; - std::string xmlToParse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Parameter><Type>UnknownParameter</Type><Value>1, 2, 3</Value></Parameter>"; - Poco::XML::Document* pDoc = pParser.parseString(xmlToParse); - Poco::XML::Element* pRootElem = pDoc->documentElement(); - - SuccessorParameterParser* successor = new SuccessorParameterParser; - EXPECT_CALL(*successor, createParameter(testing::_)).Times(1); - - WidthParameterParser parser; - - parser.setSuccessorParser(successor); - Mantid::API::ImplicitFunctionParameter* iparam = parser.createParameter(pRootElem); - delete iparam; - TSM_ASSERT("Chain of responsiblity did not execute as expected for OriginParameter type.", testing::Mock::VerifyAndClearExpectations(successor)); - } - - void testCanParseXMLOutput() - { - //Circular check that xml given by an origin parameter can be used to create a new one using the parser. - WidthParameter originalWidth(2); - - Poco::XML::DOMParser pParser; - Poco::XML::Document* pDoc = pParser.parseString(originalWidth.toXMLString()); - - WidthParameterParser widthParser; - WidthParameter* synthWidth = dynamic_cast<WidthParameter*>(widthParser.createParameter(pDoc->documentElement())); - - TSM_ASSERT_EQUALS("Formats used for xml parsing and xml output are not synchronised. values do not match", originalWidth.getValue() , synthWidth->getValue()); - - delete synthWidth; - } - -}; - -#endif diff --git a/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterTest.h b/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterTest.h deleted file mode 100644 index a68812d23d98b7603c97c5d09c76b33fb147c6d4..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDAlgorithms/test/WidthParameterTest.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef TEST_WIDTH_PARAMETER_H_ -#define TEST_WIDTH_PARAMETER_H_ - -#include <cxxtest/TestSuite.h> -#include <boost/scoped_ptr.hpp> -#include "SingleValueParameterBaseTest.h" -#include "MantidMDAlgorithms/WidthParameter.h" - -using namespace Mantid::MDAlgorithms; -typedef SingleValueParameterTests<WidthParameter> SVPTWidth; -class WidthParameterTest : public CxxTest::TestSuite, public SVPTWidth -{ -public: - - void testGetName() - { - SVPTWidth::testGetName("WidthParameter"); - } - - void testIsValid() - { - SVPTWidth::testIsValid(); - } - - void testIsNotValid() - { - SVPTWidth::testIsNotValid(); - } - - void testAssigment() - { - SVPTWidth::testAssigment(); - } - - void testClone() - { - SVPTWidth::testClone(); - } - - void testCopy() - { - SVPTWidth::testCopy(); - } - - void testToXML() - { - SVPTWidth::testToXML(); - } - - void testEqual() - { - SVPTWidth::testEqual(); - } - - void testNotEqual() - { - SVPTWidth::testNotEqual(); - } - -}; - -#endif diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/CMakeLists.txt b/Code/Mantid/Framework/WorkflowAlgorithms/CMakeLists.txt index dbe735a09d21a06cac31157717c6774cd7af4b10..d4d63684bf5b6a120c61c84f4c0bb39e7e10c8d9 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/WorkflowAlgorithms/CMakeLists.txt @@ -10,6 +10,7 @@ set ( SRC_FILES src/EQSANSSensitivityCorrection.cpp src/EQSANSDarkCurrentSubtraction.cpp src/HFIRDarkCurrentSubtraction.cpp + src/SetupHFIRReduction.cpp ) set ( SRC_UNITY_IGNORE_FILES @@ -27,6 +28,7 @@ set ( INC_FILES inc/MantidWorkflowAlgorithms/EQSANSSensitivityCorrection.h inc/MantidWorkflowAlgorithms/EQSANSDarkCurrentSubtraction.h inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h + inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h ) set ( TEST_FILES diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSLoad.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSLoad.h index 6b91c3998d08764ec02e9727cf42bf8b72bc87da..3594b53b3427d69b403b3e1a761c5e7b61d31f8d 100755 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSLoad.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSLoad.h @@ -21,30 +21,22 @@ namespace WorkflowAlgorithms Subtract dark current for EQSANS. - Required Properties: - <UL> - <LI> Filename - The name of the input event Nexus file to load </LI> - <LI> OutputWorkspace - Then name of the output EventWorkspace </LI> - </UL> - - Optional Properties: - <UL> - <LI> UseConfigBeam - If true, the beam center defined in the configuration file will be used</LI> - <LI> BeamCenterX - Beam position in X pixel coordinates (used only if UseConfigBeam is false)</LI> - <LI> BeamCenterY - Beam position in Y pixel coordinates (used only if UseConfigBeam is false)</LI> - <LI> UseConfigTOFCuts - If true, the edges of the TOF distribution will be cut according to the configuration file</LI> - <LI> UseConfigMask - If true, the masking information found in the configuration file will be used</LI> - <LI> UseConfig - If true, the best configuration file found will be used)</LI> - <LI> CorrectForFlightPath - If true, the TOF will be modified for the true flight path from the sample to the detector pixel</LI> - <LI> SampleDetectorDistance - Sample to detector distance to use (overrides meta data), in mm</LI> - <LI> SampleDetectorDistanceOffset - Offset to the sample to detector distance (use only when using the distance found in the meta data), in mm</LI> - </UL> - - Output Property: - <UL> - <LI> OutputMessage - Human readable output message </LI> - </UL> + 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> diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ReductionTableHandler.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ReductionTableHandler.h index 8640810c70baee7c35439b849ea9d335ced7f021..f7ab14cf5aeedf68017aef12c395fb8229a4a55e 100755 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ReductionTableHandler.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ReductionTableHandler.h @@ -17,9 +17,6 @@ namespace Mantid namespace WorkflowAlgorithms { /** - @author Mathieu Doucet - @date 12/10/2011 - Copyright © 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory This file is part of Mantid. @@ -57,11 +54,11 @@ namespace WorkflowAlgorithms API::MatrixWorkspace_sptr findWorkspaceEntry(const std::string& key); /// Add a string entry with a given key - void addEntry(const std::string& key, const std::string& value); + void addEntry(const std::string& key, const std::string& value, bool replace=false); /// Add an integer entry with a given key - void addEntry(const std::string& key, const int& value); + void addEntry(const std::string& key, const int& value, bool replace=false); /// Add a double entry with a given key - void addEntry(const std::string& key, const double& value); + void addEntry(const std::string& key, const double& value, bool replace=false); /// Find a file path for the given string static std::string findFileEntry(const std::string& name, const std::string& hint=""); @@ -77,6 +74,7 @@ namespace WorkflowAlgorithms static const int INTENTRY_COL = 2; /// Column number of double entries static const int DOUBLEENTRY_COL = 3; + Kernel::Logger& g_log; }; } } diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSensitivityCorrection.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSensitivityCorrection.h index 191e9ee18fc0c569b4c47edacbea3cd00c1cdcff..d69bbb074a00c7c726cdfd90f19756cb74c4b17b 100755 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSensitivityCorrection.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSensitivityCorrection.h @@ -18,9 +18,6 @@ namespace WorkflowAlgorithms Sensitivity correction for SANS - @author Mathieu Doucet - @date 12/10/2011 - Copyright © 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory This file is part of Mantid. diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h new file mode 100755 index 0000000000000000000000000000000000000000..4d7ba453a94127d5e016b782e9111d6833ce5e2f --- /dev/null +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h @@ -0,0 +1,68 @@ +#ifndef MANTID_ALGORITHMS_SETUPHFIRREDUCTION_H_ +#define MANTID_ALGORITHMS_SETUPHFIRREDUCTION_H_ + +//---------------------------------------------------------------------- +// Includes +//---------------------------------------------------------------------- +#include "MantidAPI/Algorithm.h" +#include "MantidDataObjects/EventWorkspace.h" +#include "MantidAPI/MatrixWorkspace.h" + +namespace Mantid +{ +namespace WorkflowAlgorithms +{ +/** + + Set up the reduction options for HFIR reduction. + + 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 SetupHFIRReduction : public API::Algorithm +{ +public: + /// Constructor + SetupHFIRReduction() : API::Algorithm() {} + /// Virtual destructor + virtual ~SetupHFIRReduction() {} + /// Algorithm's name + virtual const std::string name() const { return "SetupHFIRReduction"; } + /// Algorithm's version + virtual int version() const { return (1); } + /// Algorithm's category for identification + virtual const std::string category() const { return "Workflow\\SANS"; } + +private: + + /// Sets documentation strings for this algorithm + virtual void initDocs(); + /// Initialisation code + void init(); + /// Execution code + void exec(); + +}; + +} // namespace Algorithms +} // namespace Mantid + +#endif /*MANTID_ALGORITHMS_SETUPHFIRREDUCTION_H_*/ diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/ReductionTableHandler.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/ReductionTableHandler.cpp index b2364a4159d217d4adac255fa158731b2c0bc16b..ba287ff4d920c80d7c7253963e101aab26062347 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/ReductionTableHandler.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/ReductionTableHandler.cpp @@ -43,7 +43,7 @@ namespace WorkflowAlgorithms using namespace API; using namespace DataObjects; - ReductionTableHandler::ReductionTableHandler(TableWorkspace_sptr tableWS) + ReductionTableHandler::ReductionTableHandler(TableWorkspace_sptr tableWS) : g_log(Kernel::Logger::get("Algorithm")) { if(tableWS) m_reductionTable = tableWS; @@ -51,7 +51,7 @@ namespace WorkflowAlgorithms createTable(); } - ReductionTableHandler::ReductionTableHandler() + ReductionTableHandler::ReductionTableHandler() : g_log(Kernel::Logger::get("Algorithm")) { createTable(); } @@ -133,20 +133,47 @@ namespace WorkflowAlgorithms return pointer; } - void ReductionTableHandler::addEntry(const std::string& key, const std::string& value) + void ReductionTableHandler::addEntry(const std::string& key, const std::string& value, bool replace) { + try + { + int row = 0; + m_reductionTable->find(key, row, 0); + if (replace) m_reductionTable->removeRow(row); + else g_log.error() << "Entry " << key << "already exists: " << m_reductionTable->String(row, STRINGENTRY_COL) + << std::endl << " adding: " << value << std::endl; + } catch(std::out_of_range&) {} + TableRow row = m_reductionTable->appendRow(); row << key << value << EMPTY_INT() << EMPTY_DBL(); } - void ReductionTableHandler::addEntry(const std::string& key, const int& value) + void ReductionTableHandler::addEntry(const std::string& key, const int& value, bool replace) { + try + { + int row = 0; + m_reductionTable->find(key, row, 0); + if (replace) m_reductionTable->removeRow(row); + else g_log.error() << "Entry " << key << "already exists: " << m_reductionTable->Int(row, INTENTRY_COL) + << std::endl << " adding: " << value << std::endl; + } catch(std::out_of_range&) {} + TableRow row = m_reductionTable->appendRow(); row << key << "" << value << EMPTY_DBL(); } - void ReductionTableHandler::addEntry(const std::string& key, const double& value) + void ReductionTableHandler::addEntry(const std::string& key, const double& value, bool replace) { + try + { + int row = 0; + m_reductionTable->find(key, row, 0); + if (replace) m_reductionTable->removeRow(row); + else g_log.error() << "Entry " << key << "already exists: " << m_reductionTable->Double(row, DOUBLEENTRY_COL) + << std::endl << " adding: " << value << std::endl; + } catch(std::out_of_range&) {} + TableRow row = m_reductionTable->appendRow(); row << key << "" << EMPTY_INT() << value; } diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp index 86ea8474d991e0bb09f9725d21c7a2222aae320f..ad9a232ac029bcf0d85dc1758181e7ad3bb8ba6c 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/SANSSensitivityCorrection.cpp @@ -172,9 +172,25 @@ void SANSSensitivityCorrection::exec() } } else if (darkCurrentFile.size()>0) { - g_log.error() << "No dark current algorithm provided to load [" - << getPropertyValue("DarkCurrentFile") << "]: skipped!" << std::endl; - dark_result = " No dark current algorithm provided: skipped\n"; + // We need to subtract the dark current for the flood field but no dark + // current subtraction was set for the sample! Use the default dark + // current algorithm if we can find it. + dark_current = reductionHandler.findStringEntry("DefaultDarkCurrentAlgorithm"); + if (dark_current.size()>0) + { + IAlgorithm_sptr darkAlg = Algorithm::fromString(dark_current); + darkAlg->setChild(true); + darkAlg->setProperty("InputWorkspace", rawFloodWS); + darkAlg->setProperty("OutputWorkspace", rawFloodWS); + darkAlg->setProperty("Filename", darkCurrentFile); + darkAlg->execute(); + if (darkAlg->existsProperty("OutputMessage")) dark_result = darkAlg->getPropertyValue("OutputMessage"); + } else { + // We are running out of options + g_log.error() << "No dark current algorithm provided to load [" + << getPropertyValue("DarkCurrentFile") << "]: skipped!" << std::endl; + dark_result = " No dark current algorithm provided: skipped\n"; + } } m_output_message += " |" + Poco::replace(dark_result, "\n", "\n |") + "\n"; diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..567a73e865570998c78beb353f247fb6e2ffe14d --- /dev/null +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------- +// Includes +//---------------------------------------------------------------------- +#include "MantidWorkflowAlgorithms/SetupHFIRReduction.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidWorkflowAlgorithms/ReductionTableHandler.h" + +namespace Mantid +{ +namespace WorkflowAlgorithms +{ + +// Register the algorithm into the AlgorithmFactory +DECLARE_ALGORITHM(SetupHFIRReduction) + +/// Sets documentation strings for this algorithm +void SetupHFIRReduction::initDocs() +{ + this->setWikiSummary("Set up HFIR SANS reduction options."); + this->setOptionalMessage("Set up HFIR SANS reduction options."); +} + +using namespace Kernel; +using namespace API; +using namespace Geometry; +using namespace DataObjects; + +void SetupHFIRReduction::init() +{ + declareProperty("OutputMessage","",Direction::Output); + declareProperty(new WorkspaceProperty<TableWorkspace>("ReductionTableWorkspace","", Direction::Output, true)); +} + +void SetupHFIRReduction::exec() +{ + TableWorkspace_sptr reductionTable = getProperty("ReductionTableWorkspace"); + const std::string reductionTableName = getPropertyValue("ReductionTableWorkspace"); + + ReductionTableHandler reductionHandler(reductionTable); + if (!reductionTable && reductionTableName.size()>0) + setProperty("ReductionTableWorkspace", reductionHandler.getTable()); + + // Store name of the instrument + reductionHandler.addEntry("InstrumentName", "BIOSANS", true); + + // Store dark current algorithm algorithm + IAlgorithm_sptr darkAlg = createSubAlgorithm("HFIRDarkCurrentSubtraction"); + darkAlg->setProperty("OutputDarkCurrentWorkspace", ""); + darkAlg->setPropertyValue("ReductionTableWorkspace", reductionTableName); + reductionHandler.addEntry("DefaultDarkCurrentAlgorithm", darkAlg->toString()); + + setPropertyValue("OutputMessage", "HFIR reduction options set"); +} + +} // namespace WorkflowAlgorithms +} // namespace Mantid + diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp index 224e80bb6aafaa1509e95d4851e0292657faad57..61df8ff3782499b50f8824707431ad02dbc901fc 100644 --- a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp +++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp @@ -16305,6 +16305,7 @@ QMessageBox::critical(this, tr("MantidPlot") + " - " + tr("Error"),//Mantid #endif } /**This searches for the graph with a selected name and then attaches the fitFunctionBrowser to it +* This also disables the fitFunctionBrowser from all the other graphs. * * @param fpb The fit property browser from the custom interface * @param nameOfPlot A string variable containing the name of the graph we want to fit. @@ -16314,6 +16315,7 @@ void ApplicationWindow::runConnectFitting(MantidQt::MantidWidgets::FitPropertyBr { // Loop through all multilayer (i.e. plots) windows displayed in Mantidplot // and apply pickpickertool to relevant plot + // Search and delete any current peak picker tools first QList<MdiSubWindow *> windows = windowsList(); foreach (MdiSubWindow *w, windows) { @@ -16335,7 +16337,17 @@ void ApplicationWindow::runConnectFitting(MantidQt::MantidWidgets::FitPropertyBr g->disableTools(); } } - else // if (w->objectName() == nameOfPlot) + } + } + } + // now check for graphs to add the peak picker tool to. + foreach (MdiSubWindow *w, windows) + { + if (w->isA("MultiLayer")) + { + MultiLayer *plot = (MultiLayer *)w; + { + if (w->objectName() == nameOfPlot) { QList<Graph *> layers = plot->layersList(); if (layers.size() > 1) // Check to see if more than one graph with the same name on the layer diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp index 5e4902cb15e93642013d79a15333dc033ad0dae9..d60f59b3736125f05445f58c32e9773e7d3b2b60 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp @@ -828,7 +828,7 @@ Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<i } t->setHeaderColType(); - Mantid::API::Axis *spectraAxis = ws->getAxis(1); + //Mantid::API::Axis *spectraAxis = ws->getAxis(1); Mantid::Geometry::IObjComponent_const_sptr sample = ws->getInstrument()->getSample(); QList<double> col_values; // List of double valued data for one row for( size_t row = 0; row < nrows; ++row ) @@ -838,15 +838,15 @@ Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<i Mantid::specid_t currentSpec; try { - currentSpec = spectraAxis->spectraNo(ws_index); + currentSpec = ws->getSpectrum(ws_index)->getSpectrumNo(); } - catch(std::domain_error) + catch(std::range_error&) {//if there is no spectra number information in the workspace display the spectra numbers as -1 currentSpec = -1; } int detID = 0; - bool isMon = false; + bool isMon = false; double R(0.0), Theta(0.0), Phi(0.0); try { diff --git a/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp b/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp index 92dd470b7c2b102031ce69220130d1dd7308574d..38cebb9370cde3d9b69eac07cdae707839dfc2e9 100644 --- a/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp +++ b/Code/Mantid/MantidQt/CustomDialogs/src/LoadDialog.cpp @@ -299,7 +299,7 @@ namespace MantidQt } } nameLbl->setBuddy(inputWidget); - QHBoxLayout *widgetLayout = new QHBoxLayout(); + widgetLayout = new QHBoxLayout(); widgetLayout->addWidget(nameLbl); widgetLayout->addWidget(inputWidget); propertyLayout->addLayout(widgetLayout); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/MuonAnalysis.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/MuonAnalysis.h index 9ff93104414116aac120ac53861861ddaac1976a..79df5e78525e91fdc51ee377bcf601c82adc187c 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/MuonAnalysis.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/MuonAnalysis.h @@ -241,9 +241,12 @@ private: /// name of workspace std::string m_workspace_name; - // name of the loaded data + /// name of the loaded data QString m_currentDataName; + /// boolean to tell whether the fit property browser has been assigned + bool m_assigned; + /// which group table row has the user last clicked on int m_groupTableRowInFocus; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp index fae209184a77ccb9a10a1dc6f50bf71ba23f8893..24f28f08697b740576201aa9d6f08146a4c2694c 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp @@ -74,7 +74,7 @@ Logger& MuonAnalysis::g_log = Logger::get("MuonAnalysis"); //---------------------- ///Constructor MuonAnalysis::MuonAnalysis(QWidget *parent) : - UserSubWindow(parent), m_last_dir(), m_workspace_name("MuonAnalysis"), m_currentDataName(""), m_groupTableRowInFocus(0), m_pairTableRowInFocus(0), + UserSubWindow(parent), m_last_dir(), m_workspace_name("MuonAnalysis"), m_currentDataName(""), m_assigned(false), m_groupTableRowInFocus(0), m_pairTableRowInFocus(0), m_tabNumber(0), m_groupNames(), m_groupingTempFilename("tempMuonAnalysisGrouping.xml"), m_settingsGroup("CustomInterfaces/MuonAnalysis/") { } @@ -2777,8 +2777,10 @@ void MuonAnalysis::changeTab(int tabNumber) // If data analysis tab is chosen by user, assign peak picker tool to the current data if not done so already. if (tabNumber == 3) { + m_assigned = false; // Update the peak picker tool with the current workspace. m_uiForm.fitBrowser->updatePPTool(m_currentDataName); + } else { @@ -2797,8 +2799,9 @@ void MuonAnalysis::changeTab(int tabNumber) */ void MuonAnalysis::assignPeakPickerTool(const QString & workspaceName) { - if (m_tabNumber == 3) + if ((m_tabNumber == 3 && !m_assigned) || (m_tabNumber == 3 && m_currentDataName != workspaceName)) { + m_assigned = true; m_currentDataName = workspaceName; emit fittingRequested(m_uiForm.fitBrowser, workspaceName); } diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.cxx b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.cxx index c3d9a54a634c1846d127bbc594c5688ee97dfb41..62f4d768687f143aedf84e42506c014eabf3d2d4 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.cxx +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.cxx @@ -16,9 +16,6 @@ #include "MantidKernel/Exception.h" #include "MantidAPI/IMDEventWorkspace.h" #include "MantidVatesAPI/ADSWorkspaceProvider.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include "MantidMDAlgorithms/NullImplicitFunction.h" #include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" #include "MantidVatesAPI/EscalatingRebinningActionManager.h" #include "MantidVatesAPI/RebinningCutterXMLDefinitions.h" @@ -26,12 +23,10 @@ #include "MantidVatesAPI/vtkThresholdingHexahedronFactory.h" #include "MantidVatesAPI/vtkThresholdingQuadFactory.h" #include "MantidVatesAPI/vtkThresholdingLineFactory.h" -#include "MantidVatesAPI/vtkProxyFactory.h" #include "MantidVatesAPI/TimeToTimeStep.h" #include "MantidVatesAPI/FilteringUpdateProgressAction.h" #include "MantidVatesAPI/Common.h" #include "MantidVatesAPI/vtkDataSetToGeometry.h" -#include "MantidVatesAPI/GaussianThresholdRange.h" #include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MantidVatesAPI/NoThresholdRange.h" #include "MantidVatesAPI/IgnoreZerosThresholdRange.h" diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.h b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.h index 7572a1e3d8895109bf7e0fcf7bd9414b1eec3acf..b2836987dc64a08a978e919e3ff55fd8e2f3afed 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.h +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/MDEWRebinningCutterOperator/vtkMDEWRebinningCutter.h @@ -38,11 +38,6 @@ namespace Mantid { - namespace MDAlgorithms - { - //Forward declaration - class BoxImplicitFunction; - } namespace VATES { class MDRebinningPresenter; diff --git a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/RebinningTransformOperator/vtkRebinningTransformOperator.cxx b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/RebinningTransformOperator/vtkRebinningTransformOperator.cxx index 941db1e50b117b3e55a488bb36381e3e54d07981..24300b733dbe049083b3bc1ea06de332e286de2c 100644 --- a/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/RebinningTransformOperator/vtkRebinningTransformOperator.cxx +++ b/Code/Mantid/Vates/ParaviewPlugins/ParaViewFilters/RebinningTransformOperator/vtkRebinningTransformOperator.cxx @@ -14,8 +14,6 @@ #include "MantidKernel/Exception.h" #include "MantidAPI/IMDEventWorkspace.h" #include "MantidVatesAPI/ADSWorkspaceProvider.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" #include "MantidMDAlgorithms/NullImplicitFunction.h" #include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" #include "MantidVatesAPI/EscalatingRebinningActionManager.h" @@ -24,12 +22,10 @@ #include "MantidVatesAPI/vtkThresholdingHexahedronFactory.h" #include "MantidVatesAPI/vtkThresholdingQuadFactory.h" #include "MantidVatesAPI/vtkThresholdingLineFactory.h" -#include "MantidVatesAPI/vtkProxyFactory.h" #include "MantidVatesAPI/TimeToTimeStep.h" #include "MantidVatesAPI/FilteringUpdateProgressAction.h" #include "MantidVatesAPI/Common.h" #include "MantidVatesAPI/vtkDataSetToGeometry.h" -#include "MantidVatesAPI/GaussianThresholdRange.h" #include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MantidVatesAPI/NoThresholdRange.h" #include "MantidVatesAPI/IgnoreZerosThresholdRange.h" diff --git a/Code/Mantid/Vates/VatesAPI/CMakeLists.txt b/Code/Mantid/Vates/VatesAPI/CMakeLists.txt index 1dd6ccf0285aefb0f84ed2dc0d95646a1c8e751c..c23a94a6bd5daca091f869dd7d65a3fd07e0475b 100644 --- a/Code/Mantid/Vates/VatesAPI/CMakeLists.txt +++ b/Code/Mantid/Vates/VatesAPI/CMakeLists.txt @@ -11,7 +11,6 @@ src/DimensionPresenter.cpp src/EscalatingRebinningActionManager.cpp src/EventNexusLoadingPresenter.cpp src/FieldDataToMetadata.cpp -src/GaussianThresholdRange.cpp src/IgnoreZerosThresholdRange.cpp src/IMDDimensionComparitor.cpp src/MDEWEventNexusLoadingPresenter.cpp @@ -20,7 +19,6 @@ src/MDEWLoadingPresenter.cpp src/MDEWInMemoryLoadingPresenter.cpp src/MedianAndBelowThresholdRange.cpp src/MetadataToFieldData.cpp -src/MultiDimensionalDbPresenter.cpp src/NoThresholdRange.cpp src/NullCoordTransform.cpp src/NullRebinningPresenter.cpp @@ -36,11 +34,9 @@ src/vtkDataSetToGeometry.cpp src/vtkDataSetToImplicitFunction.cpp src/vtkDataSetToWsName.cpp src/vtkDataSetToWsLocation.cpp -src/vtkClipperDataSetFactory.cpp src/vtkSplatterPlotFactory.cpp src/vtkMDEWHexahedronFactory.cpp src/vtkPeakMarkerFactory.cpp -src/vtkProxyFactory.cpp src/vtkStructuredGridFactory.cpp src/vtkThresholdingHexahedronFactory.cpp src/vtkThresholdingLineFactory.cpp @@ -60,7 +56,6 @@ inc/MantidVatesAPI/EscalatingRebinningActionManager.h inc/MantidVatesAPI/EventNexusLoadingPresenter.h inc/MantidVatesAPI/FieldDataToMetadata.h inc/MantidVatesAPI/FilteringUpdateProgressAction.h -inc/MantidVatesAPI/GaussianThresholdRange.h inc/MantidVatesAPI/GeometryPresenter.h inc/MantidVatesAPI/GeometryView.h inc/MantidVatesAPI/MDEWEventNexusLoadingPresenter.h @@ -78,7 +73,6 @@ inc/MantidVatesAPI/NullCoordTransform.h inc/MantidVatesAPI/IgnoreZerosThresholdRange.h inc/MantidVatesAPI/IMDDimensionComparitor.h inc/MantidVatesAPI/MetadataToFieldData.h -inc/MantidVatesAPI/MultiDimensionalDbPresenter.h inc/MantidVatesAPI/NoThresholdRange.h inc/MantidVatesAPI/NullRebinningPresenter.h inc/MantidVatesAPI/ProgressAction.h @@ -96,11 +90,9 @@ inc/MantidVatesAPI/vtkDataSetToGeometry.h inc/MantidVatesAPI/vtkDataSetToImplicitFunction.h inc/MantidVatesAPI/vtkDataSetToWsName.h inc/MantidVatesAPI/vtkDataSetToWsLocation.h -inc/MantidVatesAPI/vtkClipperDataSetFactory.h inc/MantidVatesAPI/vtkMDEWHexahedronFactory.h inc/MantidVatesAPI/vtkSplatterPlotFactory.h inc/MantidVatesAPI/vtkPeakMarkerFactory.h -inc/MantidVatesAPI/vtkProxyFactory.h inc/MantidVatesAPI/vtkStructuredGridFactory.h inc/MantidVatesAPI/vtkThresholdingHexahedronFactory.h inc/MantidVatesAPI/vtkThresholdingLineFactory.h @@ -118,12 +110,10 @@ test/DimensionPresenterTest.h test/EscalatingRebinningActionManagerTest.h test/EventNexusLoadingPresenterTest.h test/vtkDataSetFactoryTest.h -test/vtkClipperDataSetFactoryTest.h test/vtkDataSetToGeometryTest.h test/vtkMDEWHexahedronFactoryTest.h test/vtkSplatterPlotFactoryTest.h test/vtkPeakMarkerFactoryTest.h -test/vtkProxyFactoryTest.h test/vtkStructuredGridFactoryTest.h test/vtkThresholdingUnstructuredGridFactoryTest.h test/vtkThresholdingHexahedronFactoryTest.h @@ -145,7 +135,6 @@ test/SynchronisingGeometryPresenterTest.h test/TimeStepToTimeStepTest.h test/TimeToTimeStepTest.h test/UserDefinedThresholdRangeTest.h -test/GaussianThresholdRangeTest.h test/MedianAndBelowThresholdRangeTest.h test/NoThresholdRangeTest.h test/IgnoreZerosThresholdRangeTest.h diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GaussianThresholdRange.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GaussianThresholdRange.h deleted file mode 100644 index 1d1197ca58e749005eaae93431fc09cefc745088..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/GaussianThresholdRange.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef MANTID_PARAVIEW_GAUSSIAN_THRESHOLD_RANGE -#define MANTID_PARAVIEW_GAUSSIAN_THRESHOLD_RANGE - -#include "MantidKernel/System.h" -#include "MantidVatesAPI/ThresholdRange.h" -#include "MantidAPI/IMDWorkspace.h" - -/** Caclulates range values based on the distribution of signal values in the workspace. - - @author Owen Arnold, Tessella plc - @date 30/06/2011 - - Copyright © 2010 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> - */ - -namespace Mantid -{ -namespace VATES -{ -class DLLExport GaussianThresholdRange : public ThresholdRange -{ - -public: - - GaussianThresholdRange(Mantid::API::IMDWorkspace_sptr workspace, double preferred_nStd = 1, size_t sampleSize = 100); - - GaussianThresholdRange(double preferred_nStd = 1, size_t sampleSize = 100); - - virtual void setWorkspace(Mantid::API::Workspace_sptr workspace); - - virtual void calculate(); - - virtual bool hasCalculated() const; - - virtual signal_t getMinimum() const; - - virtual signal_t getMaximum() const; - - virtual GaussianThresholdRange* clone() const; - - virtual ~GaussianThresholdRange(); - - virtual bool inRange(const signal_t& signal); - -private: - - void calculateAsNormalDistrib(std::vector<signal_t>& raw_values, size_t size, signal_t max_signal, signal_t min_signal, signal_t accumulated_signal); - - Mantid::API::IMDWorkspace_sptr m_workspace; - - signal_t m_min; - - signal_t m_max; - - bool m_isCalculated; - - signal_t m_preferred_nStd; - - size_t m_sampleSize; - -}; -} -} - -#endif \ No newline at end of file diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MDEWRebinningPresenter.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MDEWRebinningPresenter.h index 3d01a803ed3af12f9b5aeaf1644bfd98da05b55c..320923ec218c2ac4370a41b541d192781e33c9e6 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MDEWRebinningPresenter.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MDEWRebinningPresenter.h @@ -2,10 +2,9 @@ #define MDEW_REBINNING_PRESENTER_H #include "MantidVatesAPI/MDRebinningPresenter.h" - +#include "MantidGeometry/MDGeometry/MDImplicitFunction.h" #include "MantidVatesAPI/RebinningKnowledgeSerializer.h" #include "MantidVatesAPI/vtkDataSetToGeometry.h" -#include "MantidMDAlgorithms/PlaneImplicitFunction.h" #include <boost/scoped_ptr.hpp> class vtkPlane; @@ -72,7 +71,6 @@ namespace Mantid private: - Mantid::Geometry::MDImplicitFunction_sptr constructPlaneFromVTKPlane(vtkPlane* plane, Mantid::MDAlgorithms::WidthParameter& width); void persistReductionKnowledge(vtkDataSet* out_ds, const RebinningKnowledgeSerializer& xmlGenerator, const char* id); std::string extractFormattedPropertyFromDimension(Mantid::Geometry::IMDDimension_sptr dimension) const; std::string extractFormattedPropertyFromDimension(const Mantid::Kernel::VMD& basis, double length, Mantid::Geometry::IMDDimension_sptr dimension) const; diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MultiDimensionalDbPresenter.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MultiDimensionalDbPresenter.h deleted file mode 100644 index 78a035e6d787a9c41587bc4eb6cd6bf422a40e49..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/MultiDimensionalDbPresenter.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef MULTIDIMENSIONAL_DBPRESENTER_H_ -#define MULTIDIMENSIONAL_DBPRESENTER_H_ - -#include <vtkStructuredGrid.h> -#include <vtkFieldData.h> -#include "MantidAPI/IMDWorkspace.h" -#include "MantidVatesAPI/RebinningKnowledgeSerializer.h" -#include "MantidVatesAPI/ProgressAction.h" -#include "MantidVatesAPI/Common.h" - -#include <Poco/ActiveMethod.h> -#include <Poco/NotificationCenter.h> -#include <Poco/Notification.h> -#include <Poco/NObserver.h> -#include <MantidAPI/Algorithm.h> - -namespace Mantid -{ -namespace VATES -{ -/** - - Applies indirection between visualisation framework and Mantid. This type drives data loading operations. - - @author Owen Arnold, Tessella plc - @date 21/12/2010 - - Copyright © 2010 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> - */ - -typedef std::vector<int> VecExtents; - -class vtkDataSetFactory; -class DLLExport MultiDimensionalDbPresenter -{ - -private: - - // Flag indicates successful execution. - bool m_isExecuted; - - // Rebinned dataset in form of MDWorkspace. - Mantid::API::IMDWorkspace_sptr m_workspace; - - //Verify that execution has occured otherwise should not be able to access scalar data or mesh. - void verifyExecution() const; - -protected: - - /*Interrogates the AnalysisDataService instance to find the workspace with the expected id. - Seam method. supports testability given that the AnalysisDataService is a singleton and therefore very hard to fake/mock.*/ - virtual void extractWorkspaceImplementation(const std::string& wsId); - -public: - - /// Constructor loads data. - MultiDimensionalDbPresenter(); - - // Performs the rebinning. - void execute(API::Algorithm& algorithm, const std::string wsId); - - // Performs the rebinning, provides progress updating - void execute(API::Algorithm& algorithm, const std::string wsId, Mantid::VATES::ProgressAction& eventHandler); - - /// Gets the vtk mesh; - vtkDataSet* getMesh(RebinningKnowledgeSerializer& serializer, vtkDataSetFactory& vtkFactory) const; - - /// Gets the vtk scalar data for the mesh. Generated scalar data is provided with the specified name. - vtkDataArray* getScalarDataFromTimeBin(vtkDataSetFactory& vtkFactory) const; - - /// Gets the vtk scalar data for the mesh. Generated scalar data is provided with a specified name. - vtkDataArray* getScalarDataFromTime(vtkDataSetFactory& vtkFactory) const; - - /// Gets the number of timesteps in the workspace. - size_t getNumberOfTimesteps() const; - - /// Get the actual timestep values to use. - std::vector<double> getTimesteps() const; - - /// Get the actual cycle values to use. - std::vector<int> getCycles() const; - - /// Get x axis name so that it may be applied to labels. - std::string getXAxisName() const; - - /// Get y axis name so that it may be applied to labels. - std::string getYAxisName() const; - - /// Get z axis name so that it may be applied to labels. - std::string getZAxisName() const; - - /// Destructor - ~MultiDimensionalDbPresenter(); - - /// Get extents - VecExtents getExtents() const; - - /// Get the dimension from the image with the id. - Mantid::VATES::Dimension_const_sptr getDimensionFromWorkspace(const std::string& id) - { - return m_workspace->getDimensionNamed(id); - } -}; -} -} - - -#endif /* MULTIDIMENSIONALDB_PRESENTER_H_ */ diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkClipperDataSetFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkClipperDataSetFactory.h deleted file mode 100644 index 779e644679fcc94f6be01e5967bbbda53970f766..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkClipperDataSetFactory.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef MANTID_VATES_VTKCLIPPERDATASETFACTORY_H -#define MANTID_VATES_VTKCLIPPERDATASETFACTORY_H - -#include "MantidGeometry/MDGeometry/MDImplicitFunction.h" -#include "MantidVatesAPI/vtkDataSetFactory.h" -#include "MantidVatesAPI/Clipper.h" -#include "MantidAPI/IMDWorkspace.h" -#include <boost/scoped_ptr.hpp> -#include <boost/shared_ptr.hpp> - -namespace Mantid -{ -namespace VATES -{ - -/** Factory method implementation. This is an effective vtkAlgorithm in that it uses clipping functions to slice a vtkDataSet based on a provided implicit function. - - @author Owen Arnold, Tessella plc - @date 07/02/2010 - - Copyright © 2010 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 vtkClipperDataSetFactory : public vtkDataSetFactory -{ -public: - /// Constructor - vtkClipperDataSetFactory(Mantid::Geometry::MDImplicitFunction_sptr implicitFunction, vtkDataSet* dataSet, Clipper* clipper); - - /// Destructor - virtual ~vtkClipperDataSetFactory(); - - /// Factory Method. - virtual vtkDataSet* create() const; - - /// Initialize the factory. - virtual void initialize(Mantid::API::Workspace_sptr workspace); - - vtkDataSet* createMeshOnly() const; - - vtkFloatArray* createScalarArray() const; - - void validate() const - { - } - - virtual std::string getFactoryTypeName() const - { - return "vtkClipperDataSetFactory"; - } - -private: - - /// Disabled copy constructor. - vtkClipperDataSetFactory(const vtkClipperDataSetFactory&); - - /// Disabled assignment operator. - vtkClipperDataSetFactory& operator=(const vtkClipperDataSetFactory&); - - /// Function describing clipping. - Mantid::Geometry::MDImplicitFunction_sptr m_implicitFunction; - - /// Dataset on which to apply clipping. - vtkDataSet* m_dataset; - - boost::scoped_ptr<Clipper> m_clipper; -}; - -} -} - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkProxyFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkProxyFactory.h deleted file mode 100644 index cf1c046236b530bc4d7a477110747f41cbc933ff..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkProxyFactory.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef MANTID_VATES_VTKPROXYFACTORY_H_ -#define MANTID_VATES_VTKPROXYFACTORY_H_ - -#include <boost/shared_ptr.hpp> -#include "MantidVatesAPI/vtkDataSetFactory.h" -#include "MantidAPI/IMDWorkspace.h" - -namespace Mantid -{ -namespace VATES -{ - -/** Proxy Factory. This type acts as a proxy for a previously generated vtkDataSet. Makes core code invarient - * to the requirement to occasionally cache datasets rather than generate them from scratch. - - @author Owen Arnold, Tessella plc - @date 04/02/2011 - - 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 vtkProxyFactory : public vtkDataSetFactory -{ - -public: - - /// Constructor accepting product. - vtkProxyFactory(vtkDataSet* product); - - vtkProxyFactory(const vtkProxyFactory& other); - - vtkProxyFactory& operator=(const vtkProxyFactory& other); - - /// Destructor - virtual ~vtkProxyFactory(); - - /// Factory Method. Returns internal product reference. - virtual vtkDataSet* create() const; - - /// Initialize the current instance with a workspace. - virtual void initialize(Mantid::API::Workspace_sptr workspace); - - vtkDataSet* createMeshOnly() const; - - vtkFloatArray* createScalarArray() const; - - void validate() const{} - - virtual std::string getFactoryTypeName() const - { - return "vtkProxyFactory"; - } - -private: - - //Neither create nor destroy. - vtkDataSet* m_product; - -}; - -} -} - - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/src/GaussianThresholdRange.cpp b/Code/Mantid/Vates/VatesAPI/src/GaussianThresholdRange.cpp deleted file mode 100644 index 4dbfe130e2627a990318c9ddf0d94ed976d241d5..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/src/GaussianThresholdRange.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "MantidVatesAPI/GaussianThresholdRange.h" -#include "MantidAPI/IMDIterator.h" -#include <cmath> - - -namespace Mantid -{ - namespace VATES - { - - /** - Constructor - @parameter workspace : Input workspace to analyse - @parameter preferred_nStd : number of standard deviations to use when extracting upper and lower signal values. - @parameter sampleSize : How many cells to consider in the analysis. - */ - GaussianThresholdRange::GaussianThresholdRange(Mantid::API::IMDWorkspace_sptr workspace, signal_t preferred_nStd, size_t sampleSize) : m_workspace(workspace), m_min(0), m_max(0), m_isCalculated(false), m_preferred_nStd(preferred_nStd), m_sampleSize(sampleSize) - { - } - - /** - Constructor - @parameter preferred_nStd : number of standard deviations to use when extracting upper and lower signal values. - @parameter sampleSize : How many cells to consider in the analysis. - */ - GaussianThresholdRange::GaussianThresholdRange(signal_t preferred_nStd, size_t sampleSize) : m_min(0), m_max(0), m_isCalculated(false), m_preferred_nStd(preferred_nStd), m_sampleSize(sampleSize) - { - } - - ///Destructor - GaussianThresholdRange::~GaussianThresholdRange() - { - } - - /** - Assumes a normal, completely symetrical distribution and calculates max and min values based on this. - @parameter raw_values : collection of cell/signal values to analyse. - @parameter size : Number of cells/signals being analysed. - @parameter max_signal : Maximum signal value. - @parameter min_signal : Minimum signal value - @parameter accumulated_signal : sum of all signal values. - */ - void GaussianThresholdRange::calculateAsNormalDistrib(std::vector<signal_t>& raw_values, size_t size, signal_t max_signal, signal_t min_signal, signal_t accumulated_signal) - { - - signal_t mean = accumulated_signal / static_cast<signal_t>( size ); - signal_t sum_sq_diff = 0; - for(size_t i = 0; i < size; i++) - { - sum_sq_diff += (raw_values[i] - mean) * (raw_values[i] - mean); - } - signal_t sdev = std::sqrt(sum_sq_diff/ static_cast<signal_t>( size )); - signal_t distribution_center = (max_signal - min_signal) / 2; - signal_t proposed_max = distribution_center + min_signal + (sdev * m_preferred_nStd); - signal_t proposed_min = distribution_center + min_signal - (sdev * m_preferred_nStd); - - //If there is a tight distribution, and n * sigma gives a greater range than just using min_max, we need to correct. - m_max = proposed_max > max_signal ? max_signal : proposed_max; - m_min = proposed_min < min_signal ? min_signal : proposed_min; - - } - - /** - Overriden calculate method. Directs calculation of max and min values based on a normal distribution. - */ - void GaussianThresholdRange::calculate() - { - if(NULL == m_workspace.get()) - { - throw std::logic_error("The workspace has not been set."); - } - Mantid::API::IMDIterator* it = m_workspace->createIterator(); - std::vector<signal_t> raw_values; - signal_t signal = 0; - signal_t accumulated_signal = 0; - signal_t max_signal = it->getNormalizedSignal(); - signal_t min_signal = max_signal; - size_t size = 0; - size_t nSkips = 1; - if(m_sampleSize > 0) - { - size_t interval = it->getDataSize()/m_sampleSize; //Integer division - nSkips = interval > 0 ? interval : 1; //nSkips = 1 minimum - } - do - { - signal = it->getNormalizedSignal(); - if(signal != 0) //Cells with zero signal values are not considered in the analysis. - { - accumulated_signal += signal; - raw_values.push_back(signal); - max_signal = signal > max_signal ? signal : max_signal; - min_signal = signal < min_signal ? signal : min_signal; - size++; - } - } while (it->next(nSkips)); - - calculateAsNormalDistrib(raw_values, size, max_signal, min_signal, accumulated_signal); - m_isCalculated = true; - delete it; - } - - /** - Indicates wheter execution has occured or not. - @return : true if ::calculate() has been called previously, otherwise false. - */ - bool GaussianThresholdRange::hasCalculated() const - { - return m_isCalculated; - } - - /** - Getter for the calculated minimum value. - */ - signal_t GaussianThresholdRange::getMinimum() const - { - if(!m_isCalculated) - { - throw std::runtime_error("Cannot call ::getMinimum() without first calling ::calculate()"); - } - return m_min; - } - - /** - Getter for the calculated maximum value. - */ - signal_t GaussianThresholdRange::getMaximum() const - { - if(!m_isCalculated) - { - throw std::runtime_error("Cannot call ::getMaximum() without first calling ::calculate()"); - } - return m_max; - } - - /** - Virtual constructor clone method. - @return clone as GaussianThresholdRange*. - */ - GaussianThresholdRange* GaussianThresholdRange::clone() const - { - return new GaussianThresholdRange(this->m_workspace, m_preferred_nStd, m_sampleSize); - } - - /** - Setter for IMDWorkspace. - @parameter: workspace : The workspace to extract ranges from. - */ - void GaussianThresholdRange::setWorkspace(Mantid::API::Workspace_sptr workspace) - { - m_isCalculated = false; - m_workspace = boost::shared_dynamic_cast<Mantid::API::IMDWorkspace>(workspace); - if(!workspace) - { - throw std::logic_error("GaussianThresholdRange only works for IMDWorkspaces"); - } - } - - /** - Determine whether the signal is withing range. - @parameter signal value - @return true if the signal is in the range defined by this object. - */ - bool GaussianThresholdRange::inRange(const signal_t& signal) - { - return signal >= m_min && signal <= m_max; - } - } -} diff --git a/Code/Mantid/Vates/VatesAPI/src/MDEWRebinningPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/MDEWRebinningPresenter.cpp index f4747ca60214ab569ca7761c0ecd8eed6b28a98a..6d1fd1eda944c135aa76f34d5e5b3b7acf232fc4 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MDEWRebinningPresenter.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MDEWRebinningPresenter.cpp @@ -103,20 +103,6 @@ namespace Mantid delete m_view; } - /** - Constructs a PlaneImplicitFunction from a vtkPlane - @param plane: vtkPlane - @param width: plane width - */ - Mantid::Geometry::MDImplicitFunction_sptr MDEWRebinningPresenter::constructPlaneFromVTKPlane(vtkPlane* plane, Mantid::MDAlgorithms::WidthParameter& width) - { - double* pOrigin = plane->GetOrigin(); - double* pNormal = plane->GetNormal(); - Mantid::MDAlgorithms::OriginParameter origin(pOrigin[0], pOrigin[1], pOrigin[2]); - Mantid::MDAlgorithms::NormalParameter normal(pNormal[0], pNormal[1], pNormal[2]); - return Mantid::Geometry::MDImplicitFunction_sptr(new Mantid::MDAlgorithms::PlaneImplicitFunction(normal, origin, width)); - } - /* Records and accumulates function knowledge so that it can be seralized to xml later. */ diff --git a/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp b/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp index 3660cae4c6625275b482dc3b47348a34d9fbd265..ba22800085fc9a193e57e40e3e7b5e234712bcf8 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp @@ -88,7 +88,7 @@ namespace Mantid /** Virtual constructor clone method. - @return clone as GaussianThresholdRange*. + @return clone as MedianAndBelowThresholdRange*. */ MedianAndBelowThresholdRange* MedianAndBelowThresholdRange::clone() const { diff --git a/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp deleted file mode 100644 index c9a0d6cd0e4c76b21e7111e1dd05262f0a4f5a2e..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include "MantidVatesAPI/MultiDimensionalDbPresenter.h" -#include "MantidVatesAPI/RebinningCutterXMLDefinitions.h" -#include "MantidVatesAPI/RebinningKnowledgeSerializer.h" -#include "MantidVatesAPI/vtkStructuredGridFactory.h" -#include "MantidVatesAPI/MetadataToFieldData.h" -#include "MantidAPI/Algorithm.h" - -#include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/WorkspaceFactory.h" -#include <vtkFloatArray.h> -#include <vtkFieldData.h> -#include <boost/shared_ptr.hpp> -#include <vtkCharArray.h> - -namespace Mantid -{ -namespace API -{ - //Forward declaration. - class Algorithm; -} - -namespace VATES -{ -MultiDimensionalDbPresenter::MultiDimensionalDbPresenter() : m_isExecuted(false) -{ - -} - -void MultiDimensionalDbPresenter::execute(API::Algorithm& algorithm, const std::string wsId, Mantid::VATES::ProgressAction& eventHandler) -{ - using namespace Mantid::API; - - if(true == algorithm.isInitialized()) - { - Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(eventHandler, &ProgressAction::handler); - - algorithm.addObserver(observer); - - //Create and then access a workspace in the ads. - algorithm.execute(); - - algorithm.removeObserver(observer); - - extractWorkspaceImplementation(wsId); - m_isExecuted = true; - } - else - { - throw std::invalid_argument("The algorithm parameter passed to this reader was not initalized"); - } -} - -void MultiDimensionalDbPresenter::execute(API::Algorithm& algorithm, const std::string wsId) -{ - using namespace Mantid::API; - - if(true == algorithm.isInitialized()) - { - //Create and then access a workspace in the ads. - algorithm.execute(); - extractWorkspaceImplementation(wsId); - m_isExecuted = true; - } - else - { - throw std::invalid_argument("The algorithm parameter passed to this reader was not initalized"); - } -} - -void MultiDimensionalDbPresenter::extractWorkspaceImplementation(const std::string& wsId) -{ - using namespace Mantid::API; - Workspace_sptr result=AnalysisDataService::Instance().retrieve(wsId); - IMDWorkspace_sptr inputWS = boost::dynamic_pointer_cast<IMDWorkspace>(result); - this->m_workspace = inputWS; -} - -void MultiDimensionalDbPresenter::verifyExecution() const -{ - if(!this->m_isExecuted) - { - throw std::runtime_error("Cannot get mesh or get variables until rebinning has occured via ::execute()"); - } -} - -std::string MultiDimensionalDbPresenter::getXAxisName() const -{ - //Sanity check. Must run execution successfully first. - verifyExecution(); - - return m_workspace->getXDimension()->getDimensionId(); -} - -std::string MultiDimensionalDbPresenter::getYAxisName() const -{ - //Sanity check. Must run execution successfully first. - verifyExecution(); - - return m_workspace->getYDimension()->getDimensionId(); -} - -std::string MultiDimensionalDbPresenter::getZAxisName() const -{ - //Sanity check. Must run execution successfully first. - verifyExecution(); - - return m_workspace->getZDimension()->getDimensionId(); -} - -vtkDataSet* MultiDimensionalDbPresenter::getMesh(RebinningKnowledgeSerializer& serializer, vtkDataSetFactory& factory) const -{ - //Sanity check. Must run execution successfully first. - verifyExecution(); - - factory.initialize(m_workspace); - vtkDataSet* visualDataSet = factory.create(); - vtkFieldData* outputFD = vtkFieldData::New(); - - //Serialize metadata - serializer.setWorkspaceName(m_workspace->getName()); - serializer.setGeometryXML(m_workspace->getGeometryXML()); - std::string xmlString = serializer.createXMLString(); - - //Add metadata to dataset. - MetadataToFieldData convert; - convert(outputFD, xmlString, XMLDefinitions::metaDataId().c_str()); - visualDataSet->SetFieldData(outputFD); - outputFD->Delete(); - return visualDataSet; -} - -VecExtents MultiDimensionalDbPresenter::getExtents() const -{ - VecExtents extents; - extents.push_back(0); - extents.push_back(static_cast<int>( m_workspace->getXDimension()->getNBins() )); - extents.push_back(0); - extents.push_back(static_cast<int>( m_workspace->getYDimension()->getNBins() )); - extents.push_back(0); - extents.push_back(static_cast<int>( m_workspace->getZDimension()->getNBins() )); - return extents; -} - -size_t MultiDimensionalDbPresenter::getNumberOfTimesteps() const -{ - verifyExecution(); - return m_workspace->getTDimension()->getNBins(); -} - -std::vector<int> MultiDimensionalDbPresenter::getCycles() const -{ - verifyExecution(); - std::vector<int> cycles(m_workspace->getTDimension()->getNBins()); - for(unsigned int i=0; i < cycles.size(); i++) - { - cycles[i] = i; - } - return cycles; -} - -std::vector<double> MultiDimensionalDbPresenter::getTimesteps() const -{ - using namespace Mantid::Geometry; - verifyExecution(); - boost::shared_ptr<const IMDDimension> tDimension = m_workspace->getTDimension(); - const double increment = (tDimension->getMaximum() - tDimension->getMinimum())/ static_cast<double>(tDimension->getNBins()); - std::vector<double> times(tDimension->getNBins()); - for(unsigned int i=0; i < tDimension->getNBins(); i++) - { - times[i] = tDimension->getMinimum() + (i*increment); - } - return times; -} - -vtkDataArray* MultiDimensionalDbPresenter::getScalarDataFromTimeBin(vtkDataSetFactory& vtkFactory) const -{ - verifyExecution(); - - vtkFactory.initialize(m_workspace); - return vtkFactory.createScalarArray(); -} - -vtkDataArray* MultiDimensionalDbPresenter::getScalarDataFromTime(vtkDataSetFactory& vtkFactory) const -{ - verifyExecution(); - - vtkFactory.initialize(m_workspace); - return vtkFactory.createScalarArray(); -} - -MultiDimensionalDbPresenter::~MultiDimensionalDbPresenter() -{ -} - -} -} - diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkClipperDataSetFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkClipperDataSetFactory.cpp deleted file mode 100644 index 470b10bf3d8fc06c08b5fc6ba9220c3cf9ebcd62..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/src/vtkClipperDataSetFactory.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "MantidVatesAPI/vtkClipperDataSetFactory.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include "MantidMDAlgorithms/BoxInterpreter.h" -#include "vtkUnstructuredGrid.h" -#include "vtkBox.h" - -namespace Mantid -{ -namespace VATES -{ -/// Constructor -vtkClipperDataSetFactory::vtkClipperDataSetFactory( - Mantid::Geometry::MDImplicitFunction_sptr implicitFunction, - vtkDataSet* dataset, Clipper* clipper) : - m_implicitFunction(implicitFunction), m_dataset(dataset), m_clipper(clipper) -{ -} - -vtkClipperDataSetFactory::~vtkClipperDataSetFactory() -{ -} - -void vtkClipperDataSetFactory::initialize(Mantid::API::Workspace_sptr) -{ - throw std::runtime_error("initialize with a workspace does not apply for this type of factory."); -} - -vtkDataSet* vtkClipperDataSetFactory::create() const -{ - using namespace Mantid::MDAlgorithms; - - BoxInterpreter interpreter; - boxVector boxFunctions = interpreter.getAllBoxes(m_implicitFunction.get()); - vtkUnstructuredGrid* output = vtkUnstructuredGrid::New(); - - boxVector::const_iterator it = boxFunctions.begin(); - - for (; it != boxFunctions.end(); ++it) - { - boost::shared_ptr<BoxImplicitFunction> boxFunction = *it; - vtkBox* box = vtkBox::New(); - box->SetBounds( - boxFunction->getLowerX(), - boxFunction->getUpperX(), - boxFunction->getLowerY(), - boxFunction->getUpperY(), - boxFunction->getLowerZ(), - boxFunction->getUpperZ()); - - m_clipper->SetInput(m_dataset); - m_clipper->SetClipFunction(box); - m_clipper->SetInsideOut(true); - m_clipper->SetRemoveWholeCells(true); - m_clipper->SetOutput(output); - m_clipper->Update(); - box->Delete(); - } - return output; -} - -vtkDataSet* vtkClipperDataSetFactory::createMeshOnly() const -{ - throw std::runtime_error("::createMeshOnly() does not apply for this type of factory."); -} - -vtkFloatArray* vtkClipperDataSetFactory::createScalarArray() const -{ - throw std::runtime_error("::createScalarArray() does not apply for this type of factory."); -} - -} -} diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkProxyFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkProxyFactory.cpp deleted file mode 100644 index 0e399f5db823920d254b04c4100bbe9b8aacda90..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/src/vtkProxyFactory.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "MantidVatesAPI/vtkProxyFactory.h" - -namespace Mantid -{ -namespace VATES -{ - -vtkProxyFactory::vtkProxyFactory(vtkDataSet* product) : m_product(product) -{ -} - -vtkProxyFactory::~vtkProxyFactory() -{ -} - -vtkProxyFactory::vtkProxyFactory(const vtkProxyFactory& other) : m_product(other.m_product) -{ -} - -vtkProxyFactory& vtkProxyFactory::operator=(const vtkProxyFactory& other) -{ - if(&other != this) - { - //this->m_product->Delete(); - this->m_product = other.m_product; - } - return *this; -} - -void vtkProxyFactory::initialize(Mantid::API::Workspace_sptr) -{ - throw std::runtime_error("initialize with a workspace does not apply for this type of factory."); -} - -vtkDataSet* vtkProxyFactory::create() const -{ - //Essentially do nothing other than return the cached product. - return this->m_product; -} - -vtkDataSet* vtkProxyFactory::createMeshOnly() const -{ - throw std::runtime_error("::createMeshOnly() does not apply for this type of factory."); -} - -vtkFloatArray* vtkProxyFactory::createScalarArray() const -{ - throw std::runtime_error("::createScalarArray() does not apply for this type of factory."); -} - - -} -} diff --git a/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h b/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h deleted file mode 100644 index 2d83333342c7b66afeafb654596114526f9b4ef2..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef GAUSSIAN_THRESHOLD_RANGE_TEST_H_ -#define GAUSSIAN_THRESHOLD_RANGE_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidVatesAPI/GaussianThresholdRange.h" -#include "MantidAPI/IMDIterator.h" -#include "MantidTestHelpers/MDEventsTestHelper.h" -#include "MantidMDEvents/MDHistoWorkspace.h" - -using namespace Mantid; -using namespace Mantid::MDEvents; -using namespace testing; - -//===================================================================================== -// Functional tests -//===================================================================================== -class GaussianThresholdRangeTest: public CxxTest::TestSuite -{ -private: - - // Fake workspace - MDHistoWorkspace_sptr sptrWs; - -public : - - void setUp() - { - // Fake workspace with 8 cells - sptrWs = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1, 8, 8.0); - //Set up a standard set of values for subsequent tests. Note that the following set gives a standard deviation of +/-2 - sptrWs->setSignalAt(0,2.0); - sptrWs->setSignalAt(1,4); - sptrWs->setSignalAt(2,4); - sptrWs->setSignalAt(3,4); - sptrWs->setSignalAt(4,5); - sptrWs->setSignalAt(5,5); - sptrWs->setSignalAt(6,7); - sptrWs->setSignalAt(7,9); - } - - void testWithDefaultSamplingApplied() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 1, 0); //1stdDev, 0 skips - gaussianCalculator.calculate(); - TS_ASSERT_DELTA( sptrWs->getSignalNormalizedAt(0), 2.0, 1e-5); - - TS_ASSERT(gaussianCalculator.hasCalculated()); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 + 2, gaussianCalculator.getMaximum()); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 - 2, gaussianCalculator.getMinimum()); - - //Boundary Value Analysis - signal_t just_above_upper_boundary = 7.5001; - signal_t just_below_lower_boundary = 3.4999; - signal_t on_lower_boundary = 3.5; - signal_t on_upper_boundary = 7.5; - signal_t just_below_upper_boundary = 7.4999; - signal_t just_above_lower_boundary = 3.5001; - TS_ASSERT_EQUALS(false, gaussianCalculator.inRange(just_above_upper_boundary)); - TS_ASSERT_EQUALS(false, gaussianCalculator.inRange(just_below_lower_boundary)); - TS_ASSERT_EQUALS(true, gaussianCalculator.inRange(on_lower_boundary)); - TS_ASSERT_EQUALS(true, gaussianCalculator.inRange(on_upper_boundary)); - TS_ASSERT_EQUALS(true, gaussianCalculator.inRange(just_below_upper_boundary)); - TS_ASSERT_EQUALS(true, gaussianCalculator.inRange(just_above_lower_boundary)); - } - - void testWithHalfStdDev() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 0.5, 0); //Half stdDev, 0 skips - gaussianCalculator.calculate(); - - TSM_ASSERT_EQUALS("Should be 0.5*sigma standard deviations from central value.", 3.5 + 2 + 1, gaussianCalculator.getMaximum()); - TSM_ASSERT_EQUALS("Should be 0.5*sigma standard deviations from central value.", 3.5 + 2 - 1, gaussianCalculator.getMinimum()); - } - - void testWithEveryOtherCellSampled() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 1, 4); //1stdDev, skip every other cell. - gaussianCalculator.calculate(); - } - - void testGetMaxWithoutCalculatingThrows() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 1, 1); - TSM_ASSERT("Should indicate not calculated.", !gaussianCalculator.hasCalculated()); - TSM_ASSERT_THROWS("Should throw if :getMaximum() is requested without first calculating.", gaussianCalculator.getMaximum(), std::runtime_error); - } - - void testGetMinWithoutCalculatingThrows() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 1, 1); - TSM_ASSERT("Should indicate not calculated.", !gaussianCalculator.hasCalculated()); - TSM_ASSERT_THROWS("Should throw if :getMaximum() is requested without first calculating.", gaussianCalculator.getMinimum(), std::runtime_error); - } - - void testSaturateIfTooManyStdevs() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 10, 0); //Ten stdDevs, 0 skips - gaussianCalculator.calculate(); - TSM_ASSERT_EQUALS("Should have saturated to min signal.", 9, gaussianCalculator.getMaximum()); - TSM_ASSERT_EQUALS("Should have saturated to max signal.", 2, gaussianCalculator.getMinimum()); - } - - void testSettWorkspaceOnObject() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(1, 0); //1stdDev, 0 skips - gaussianCalculator.setWorkspace(sptrWs); - gaussianCalculator.calculate(); - TS_ASSERT(gaussianCalculator.hasCalculated()); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 + 2, gaussianCalculator.getMaximum()); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 - 2, gaussianCalculator.getMinimum()); - } - - void testCalculateWithoutWorkspaceThrows() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator; //No workspace provided! - TSM_ASSERT_THROWS("Calling calculate without a workspace should throw", gaussianCalculator.calculate(), std::logic_error); - } - - void testSetWorkspaceResetsCalculation() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 1, 0); //1stdDev, 0 skips - gaussianCalculator.calculate(); - gaussianCalculator.setWorkspace(sptrWs); - TSM_ASSERT("Setting a workspace should mark object as uncalculated.", !gaussianCalculator.hasCalculated()); - } - - void testIgnoreEmptyCells() - { - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs); - gaussianCalculator.calculate(); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 + 2, gaussianCalculator.getMaximum()); - TSM_ASSERT_EQUALS("Should be 1*sigma standard deviations from central value.", 3.5 + 2 - 2, gaussianCalculator.getMinimum()); - } - -}; - -//===================================================================================== -// Performance tests -//===================================================================================== -class GaussianThresholdRangeTestPerformance : public CxxTest::TestSuite -{ -public: - - void testAnalyseLargeWorkspaceSampleEveryTen() - { - const size_t workspaceSize = 10000000; //Ten million cells - Mantid::API::IMDWorkspace_sptr sptrWs = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1, workspaceSize); - - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 10, 10); //Ten stdDevs, 10 skips - gaussianCalculator.calculate(); - - gaussianCalculator.getMaximum(); - gaussianCalculator.getMinimum(); - } - - void testAnalyseLargeWorkspaceSampleEveryTenThousand() - { - const size_t workspaceSize = 10000000; //Ten million cells - Mantid::API::IMDWorkspace_sptr sptrWs = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 1, workspaceSize); - - Mantid::VATES::GaussianThresholdRange gaussianCalculator(sptrWs, 10, 10000); //Ten stdDevs, 10'000 skips - gaussianCalculator.calculate(); - - gaussianCalculator.getMaximum(); - gaussianCalculator.getMinimum(); - } - -}; - -#endif diff --git a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h index c38cee6e1ec430cfdd8e0de090c2a5a2e8a5bdb9..08ecc73c645dab8a9eef6a699d7e1ba24cea0fd9 100644 --- a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h +++ b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h @@ -271,56 +271,6 @@ class FakeProgressAction : public Mantid::VATES::ProgressAction "<MDWorkspaceName>Input</MDWorkspaceName>" + "<MDWorkspaceLocation>test_horace_reader.sqw</MDWorkspaceLocation>" + constrctGeometryOnlyXML(xDimensionIdMapping, yDimensionIdMapping, zDimensionIdMapping, tDimensionIdMapping) + - "<Function>" + - "<Type>CompositeImplicitFunction</Type>" + - "<ParameterList/>" + - "<Function>" + - "<Type>BoxImplicitFunction</Type>" + - "<ParameterList>" + - "<Parameter>" + - "<Type>HeightParameter</Type>" + - "<Value>6</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>WidthParameter</Type>" + - "<Value>1.5</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>DepthParameter</Type>" + - "<Value>6</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>OriginParameter</Type>" + - "<Value>0, 0, 0</Value>" + - "</Parameter>" + - "</ParameterList>" + - "</Function>" + - "<Function>" + - "<Type>CompositeImplicitFunction</Type>" + - "<ParameterList/>" + - "<Function>" + - "<Type>BoxImplicitFunction</Type>" + - "<ParameterList>" + - "<Parameter>" + - "<Type>WidthParameter</Type>" + - "<Value>4</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>HeightParameter</Type>" + - "<Value>1.5</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>DepthParameter</Type>" + - "<Value>6</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>OriginParameter</Type>" + - "<Value>0, 0, 0</Value>" + - "</Parameter>" + - "</ParameterList>" + - "</Function>" + - "</Function>" + - "</Function>" + "</MDInstruction>"; } diff --git a/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h b/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h index e0696842be0aa368b0c880d4c914eca22651980c..b98228b0dd5a86576f723576cc56adcdcb341d9a 100644 --- a/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h @@ -73,7 +73,6 @@ void testNoLocationDoesNotThrow() { MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; pWorkspace->setName("someName"); - EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); Mantid::API::IMDWorkspace_sptr workspace(pWorkspace); MockImplicitFunction* pImpFunction = new MockImplicitFunction; @@ -83,7 +82,6 @@ void testNoLocationDoesNotThrow() RebinningKnowledgeSerializer generator(LocationNotRequired); //Location is not required. generator.setImplicitFunction(impFunction); generator.setWorkspace(workspace); - generator.setImplicitFunction(impFunction); TSM_ASSERT_THROWS_NOTHING("The location is not mandatory, should not throw", generator.createXMLString()); } @@ -92,7 +90,6 @@ void testNoNameThrows() { Mantid::Geometry::MDImplicitFunction_sptr impFunction(new MockImplicitFunction); MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; - EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); RebinningKnowledgeSerializer generator; generator.setImplicitFunction(impFunction); diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkClipperDataSetFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkClipperDataSetFactoryTest.h deleted file mode 100644 index b280997391bdb7e60765f264591ef117f85a4782..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/test/vtkClipperDataSetFactoryTest.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef VTK_CLIPPER_DATASETFACTORY_TEST_H -#define VTK_CLIPPER_DATASETFACTORY_TEST_H - -#include <cxxtest/TestSuite.h> -#include <gmock/gmock.h> -#include <gtest/gtest.h> -#include "MantidVatesAPI/vtkClipperDataSetFactory.h" -#include "MantidMDAlgorithms/CompositeImplicitFunction.h" -#include "MantidGeometry/MDGeometry/MDImplicitFunction.h" -#include "MantidMDAlgorithms/BoxImplicitFunction.h" -#include "vtkRectilinearGrid.h" - -class vtkClipperDataSetFactoryTest: public CxxTest::TestSuite -{ -private: - -class MockClipper: public Mantid::VATES::Clipper - { - public: - MOCK_METHOD1(SetInput, void(vtkDataSet* in_ds)); - MOCK_METHOD1(SetClipFunction, void(vtkImplicitFunction* func)); - MOCK_METHOD1(SetInsideOut, void(bool insideout)); - MOCK_METHOD1(SetRemoveWholeCells, void(bool removeWholeCells)); - MOCK_METHOD1(SetOutput, void(vtkUnstructuredGrid* out_ds)); - MOCK_METHOD0(Update, void()); - MOCK_METHOD0(Delete,void()); - MOCK_METHOD0(GetOutput, vtkDataSet*()); - MOCK_METHOD0(die, void()); - virtual ~MockClipper() - { - die(); - } - }; - - class vtkMockRectilinearGrid: public vtkRectilinearGrid - { - public: - static vtkMockRectilinearGrid* New() - { - vtkMockRectilinearGrid* newProduct = new vtkMockRectilinearGrid(); - return newProduct; - } - MOCK_METHOD0(die, void()); - virtual void Delete() - { - die(); - vtkRectilinearGrid::Delete(); - } - - }; - - // Mock type to represent other implicit functions. - class MockImplicitFunction: public Mantid::Geometry::MDImplicitFunction - { - public: - MOCK_METHOD1(isPointContained, bool(const Mantid::coord_t* pPoint)); - MOCK_METHOD1(isPointContained, bool(const std::vector<Mantid::coord_t>&)); - MOCK_CONST_METHOD0(getName, std::string()); - MOCK_CONST_METHOD0(toXMLString, std::string()); - MOCK_METHOD0(die, void()); - ~MockImplicitFunction() - { - die(); - } - }; - -public: - - void testCleansUp() - { - using Mantid::VATES::vtkClipperDataSetFactory; - using namespace Mantid::API; - - MockImplicitFunction* mockFunction = new MockImplicitFunction; - vtkMockRectilinearGrid* mockGrid = vtkMockRectilinearGrid::New(); - MockClipper* mockClipper = new MockClipper; - EXPECT_CALL(*mockFunction, die()).Times(1); - EXPECT_CALL(*mockGrid, die()).Times(1); //VisIT framework expects that input datasets are not destroyed. - EXPECT_CALL(*mockClipper, die()).Times(1); - { - vtkClipperDataSetFactory factory(Mantid::Geometry::MDImplicitFunction_sptr(mockFunction), mockGrid, mockClipper); - } - - mockGrid->Delete(); //Clean up in test scenario - - TSM_ASSERT("RAII not correct on accepted implicit function", testing::Mock::VerifyAndClearExpectations(mockFunction)); - TSM_ASSERT("RAII not correct on accepted vtkDataSet", testing::Mock::VerifyAndClearExpectations(mockGrid)); - TSM_ASSERT("RAII not correct on accepted vtkDataSet", testing::Mock::VerifyAndClearExpectations(mockClipper)); - } - - void testAppliesCuts() - { - using namespace Mantid::MDAlgorithms; - using namespace Mantid::API; - - OriginParameter originOne(0, 0, 0); - WidthParameter widthOne(1); - HeightParameter heightOne(4); - DepthParameter depthOne(5); - BoxImplicitFunction* boxOne = new BoxImplicitFunction(widthOne, heightOne, depthOne, originOne); - - OriginParameter originTwo(0, 0, 0); - WidthParameter widthTwo(2); - HeightParameter heightTwo(3); - DepthParameter depthTwo(6); - BoxImplicitFunction* boxTwo = new BoxImplicitFunction(widthTwo, heightTwo, depthTwo, originTwo); - - CompositeImplicitFunction* compositeFunction = new CompositeImplicitFunction; - compositeFunction->addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxOne)); - compositeFunction->addFunction(Mantid::Geometry::MDImplicitFunction_sptr(boxTwo)); - - - MockClipper* mockClipper = new MockClipper; - EXPECT_CALL(*mockClipper, SetInput(testing::_)).Times(2); - EXPECT_CALL(*mockClipper, SetClipFunction(testing::_)).Times(2); - EXPECT_CALL(*mockClipper, SetInsideOut(true)).Times(2); - EXPECT_CALL(*mockClipper, SetRemoveWholeCells(true)).Times(2); - EXPECT_CALL(*mockClipper, SetOutput(testing::_)).Times(2); - EXPECT_CALL(*mockClipper, Update()).Times(2); - EXPECT_CALL(*mockClipper, die()).Times(1); - - { - Mantid::VATES::vtkClipperDataSetFactory factory(Mantid::Geometry::MDImplicitFunction_sptr(compositeFunction), vtkRectilinearGrid::New(), mockClipper); - factory.create(); - } - - - TSM_ASSERT("Clipper not used correctly.", testing::Mock::VerifyAndClearExpectations(mockClipper)); - } -}; -#endif diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToImplicitFunctionTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToImplicitFunctionTest.h index 465802d16175bb762cf9d88a6021a268faedfbdf..7e7bc242a36b733ebd521ff4660b3984bb9fd7a4 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToImplicitFunctionTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToImplicitFunctionTest.h @@ -17,32 +17,6 @@ using namespace Mantid::VATES; class vtkDataSetToImplicitFunctionTest : public CxxTest::TestSuite { -private: - - // Helper method. Create xml. Notice this is a subset of the full xml-schema, see Architectural design document. - static std::string constructXML() - { - return std::string("<MDInstruction>") + - "<Function>" + - "<Type>PlaneImplicitFunction</Type>" + - "<ParameterList>" + - "<Parameter>" + - "<Type>NormalParameter</Type>" + - "<Value>1, -1, 1</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>OriginParameter</Type>" + - "<Value>0, 1, 0</Value>" + - "</Parameter>" + - "<Parameter>" + - "<Type>WidthParameter</Type>" + - "<Value>1</Value>" + - "</Parameter>" + - "</ParameterList>" + - "</Function>" + - "</MDInstruction>"; - } - public: void testThrowIfvtkDataSetNull() @@ -51,18 +25,18 @@ public: TS_ASSERT_THROWS(vtkDataSetToImplicitFunction temp(nullArg), std::runtime_error); } - void testExecution() - { - vtkStructuredGrid* ds = vtkStructuredGrid::New(); - ds->SetFieldData(createFieldDataWithCharArray(constructXML())); + //void testExecution() + //{ + // vtkStructuredGrid* ds = vtkStructuredGrid::New(); + // ds->SetFieldData(createFieldDataWithCharArray(constructXML())); - vtkDataSetToImplicitFunction extractor(ds); - Mantid::Geometry::MDImplicitFunction* func = NULL; - TS_ASSERT_THROWS_NOTHING(func = extractor.execute()); - TS_ASSERT_EQUALS("PlaneImplicitFunction", func->getName()); - ds->Delete(); - delete func; - } + // vtkDataSetToImplicitFunction extractor(ds); + // Mantid::Geometry::MDImplicitFunction* func = NULL; + // TS_ASSERT_THROWS_NOTHING(func = extractor.execute()); + // TS_ASSERT_EQUALS("PlaneImplicitFunction", func->getName()); + // ds->Delete(); + // delete func; + //} void testNoImplcitFunction() { @@ -80,11 +54,11 @@ public: void testStaticUsage() { vtkStructuredGrid* ds = vtkStructuredGrid::New(); - ds->SetFieldData(createFieldDataWithCharArray(constructXML())); + ds->SetFieldData(createFieldDataWithCharArray("<MDInstruction/>")); Mantid::Geometry::MDImplicitFunction* func = NULL; TS_ASSERT_THROWS_NOTHING(func = vtkDataSetToImplicitFunction::exec(ds)); - TS_ASSERT_EQUALS("PlaneImplicitFunction", func->getName()); + TS_ASSERT_EQUALS("NullImplicitFunction", func->getName()); ds->Delete(); delete func; } diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkProxyFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkProxyFactoryTest.h deleted file mode 100644 index f13e7d21ba218000c163f289955476aac3df149b..0000000000000000000000000000000000000000 --- a/Code/Mantid/Vates/VatesAPI/test/vtkProxyFactoryTest.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VTK_PROXY_FACTORY_TEST_H_ -#define VTK_PROXY_FACTORY_TEST_H_ - -#include <cxxtest/TestSuite.h> -#include <vtkRectilinearGrid.h> -#include "MantidVatesAPI/vtkProxyFactory.h" - -class vtkProxyFactoryTest: public CxxTest::TestSuite -{ -public: - - void testCreation() - { - using Mantid::VATES::vtkProxyFactory; - - vtkRectilinearGrid* A = vtkRectilinearGrid::New(); - vtkProxyFactory factory(A); - vtkDataSet* B = factory.create(); - - TSM_ASSERT_EQUALS("The construction parameter and product should both be of the same type", A->GetClassName(), B->GetClassName()); - TSM_ASSERT_EQUALS("The construction parameter and product should point to the same memory location", A, B); - B->Delete(); - } - - void testCopy() - { - using Mantid::VATES::vtkProxyFactory; - - vtkRectilinearGrid* inputProduct = vtkRectilinearGrid::New(); - vtkProxyFactory factoryA(inputProduct); - vtkProxyFactory copyFactory(factoryA); - vtkDataSet* productA = factoryA.create(); - vtkDataSet* productB = copyFactory.create(); - - TSM_ASSERT_EQUALS("The vtkDataSet from the original factory and copy should point to the same memory location", productA, productB); - productA->Delete(); - } - - void testAssignment() - { - using Mantid::VATES::vtkProxyFactory; - - vtkRectilinearGrid* inputProductA = vtkRectilinearGrid::New(); - vtkRectilinearGrid* inputProductB = vtkRectilinearGrid::New(); - vtkProxyFactory factoryA(inputProductA); - vtkProxyFactory factoryB(inputProductB); - - factoryA = factoryB; - vtkDataSet* productA = factoryA.create(); - vtkDataSet* productB = factoryB.create(); - - TSM_ASSERT_EQUALS("The vtkDataSet from the original factory and copy should point to the same memory location", productA, productB); - TSM_ASSERT_EQUALS("The vtkDataSet produced by both factories should correspond to the rhs factories constructor argument", productA, inputProductB); - - inputProductA->Delete(); - inputProductB->Delete(); - } - - void testTypeName() - { - vtkRectilinearGrid* inputProduct = vtkRectilinearGrid::New(); - Mantid::VATES::vtkProxyFactory factory(inputProduct); - TS_ASSERT_EQUALS("vtkProxyFactory", factory.getFactoryTypeName()); - inputProduct->Delete(); - } - -}; - -#endif diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py index 2a264d3f0d9f0a8f9742cdbd4c5c513194317e6d..9ae528dbc51a7a397c5fd2ed997102c63f431a37 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py @@ -148,51 +148,37 @@ class Detector(BaseScriptElement): # Get Mantid version mtd_version = BaseScriptElement.getMantidBuildVersion(dom) - # Sensitivity correction - take care of backward compatibility - if mtd_version!=0 and mtd_version<BaseScriptElement.UPDATE_1_CHANGESET_CUTOFF: - element_list = dom.getElementsByTagName("Instrument") - if len(element_list)>0: - instrument_dom = element_list[0] - self.sensitivity_corr = BaseScriptElement.getBoolElement(instrument_dom, "sensitivity_corr", - default = Detector.sensitivity_corr) - self.sensitivity_data = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_data") - self.sensitivity_dark = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_dark") - self.min_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_min", - default=Detector.min_sensitivity) - self.max_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_max", - default=Detector.max_sensitivity) - self.use_sample_beam_center = True - else: - element_list = dom.getElementsByTagName("Sensitivity") - if len(element_list)>0: - instrument_dom = element_list[0] - self.sensitivity_corr = BaseScriptElement.getBoolElement(instrument_dom, "sensitivity_corr", - default = Detector.sensitivity_corr) - self.sensitivity_data = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_data") - self.sensitivity_dark = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_dark") - self.use_sample_dark = BaseScriptElement.getBoolElement(instrument_dom, "use_sample_dark", - default = Detector.use_sample_dark) - self.min_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_min", - default=Detector.min_sensitivity) - self.max_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_max", - default=Detector.max_sensitivity) - self.use_sample_beam_center = BaseScriptElement.getBoolElement(instrument_dom, "use_sample_beam_center", - default = Detector.use_sample_beam_center) - - beam_center_list = instrument_dom.getElementsByTagName("FloodBeamFinder") - if len(beam_center_list)>0: - beam_finder_dom = beam_center_list[0] - self.flood_x_position = BaseScriptElement.getFloatElement(beam_finder_dom, "x", - default=Detector.flood_x_position) - self.flood_y_position = BaseScriptElement.getFloatElement(beam_finder_dom, "y", - default=Detector.flood_y_position) - self.flood_use_finder = BaseScriptElement.getBoolElement(beam_finder_dom, "use_finder", - default = Detector.flood_use_finder) - self.flood_beam_file = BaseScriptElement.getStringElement(beam_finder_dom, "beam_file") - self.flood_beam_radius = BaseScriptElement.getFloatElement(beam_finder_dom, "beam_radius", - default=Detector.flood_beam_radius) - self.flood_use_direct_beam = BaseScriptElement.getBoolElement(beam_finder_dom, "use_direct_beam", - default = Detector.flood_use_direct_beam) + # Sensitivity correction + element_list = dom.getElementsByTagName("Sensitivity") + if len(element_list)>0: + instrument_dom = element_list[0] + self.sensitivity_corr = BaseScriptElement.getBoolElement(instrument_dom, "sensitivity_corr", + default = Detector.sensitivity_corr) + self.sensitivity_data = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_data") + self.sensitivity_dark = BaseScriptElement.getStringElement(instrument_dom, "sensitivity_dark") + self.use_sample_dark = BaseScriptElement.getBoolElement(instrument_dom, "use_sample_dark", + default = Detector.use_sample_dark) + self.min_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_min", + default=Detector.min_sensitivity) + self.max_sensitivity = BaseScriptElement.getFloatElement(instrument_dom, "sensitivity_max", + default=Detector.max_sensitivity) + self.use_sample_beam_center = BaseScriptElement.getBoolElement(instrument_dom, "use_sample_beam_center", + default = Detector.use_sample_beam_center) + + beam_center_list = instrument_dom.getElementsByTagName("FloodBeamFinder") + if len(beam_center_list)>0: + beam_finder_dom = beam_center_list[0] + self.flood_x_position = BaseScriptElement.getFloatElement(beam_finder_dom, "x", + default=Detector.flood_x_position) + self.flood_y_position = BaseScriptElement.getFloatElement(beam_finder_dom, "y", + default=Detector.flood_y_position) + self.flood_use_finder = BaseScriptElement.getBoolElement(beam_finder_dom, "use_finder", + default = Detector.flood_use_finder) + self.flood_beam_file = BaseScriptElement.getStringElement(beam_finder_dom, "beam_file") + self.flood_beam_radius = BaseScriptElement.getFloatElement(beam_finder_dom, "beam_radius", + default=Detector.flood_beam_radius) + self.flood_use_direct_beam = BaseScriptElement.getBoolElement(beam_finder_dom, "use_direct_beam", + default = Detector.flood_use_direct_beam) element_list = dom.getElementsByTagName("BeamFinder") if len(element_list)>0: diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py index 0bd7395b09e4be64b700b1081fa882ae96617a29..862f441e49a2f20bbd272f5cca86ea3fe716d8bf 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py @@ -240,17 +240,10 @@ class ReductionOptions(BaseScriptElement): self.output_directory = BaseScriptElement.getStringElement(instrument_dom, "OutputDirectory", default = ReductionOptions.output_directory) - # Dark current - take care of backward compatibility - if mtd_version!=0 and mtd_version<BaseScriptElement.UPDATE_1_CHANGESET_CUTOFF: - bck_entries = dom.getElementsByTagName("Background") - if len(bck_entries)>0: - self.dark_current_corr = BaseScriptElement.getBoolElement(bck_entries[0], "dark_current_corr", - default = ReductionOptions.dark_current_corr) - self.dark_current_data = BaseScriptElement.getStringElement(bck_entries[0], "dark_current_file") - else: - self.dark_current_corr = BaseScriptElement.getBoolElement(instrument_dom, "dark_current_corr", - default = ReductionOptions.dark_current_corr) - self.dark_current_data = BaseScriptElement.getStringElement(instrument_dom, "dark_current_data") + # Dark current + self.dark_current_corr = BaseScriptElement.getBoolElement(instrument_dom, "dark_current_corr", + default = ReductionOptions.dark_current_corr) + self.dark_current_data = BaseScriptElement.getStringElement(instrument_dom, "dark_current_data") self.n_q_bins = BaseScriptElement.getIntElement(instrument_dom, "n_q_bins", default=ReductionOptions.n_q_bins) @@ -262,36 +255,30 @@ class ReductionOptions(BaseScriptElement): self.normalization = BaseScriptElement.getIntElement(instrument_dom, "normalization", default=ReductionOptions.normalization) - # Mask - take care of backward compatibility - if mtd_version!=0 and mtd_version<BaseScriptElement.UPDATE_1_CHANGESET_CUTOFF: - self.top = BaseScriptElement.getIntElement(instrument_dom, "mask_top", default=ReductionOptions.top) - self.bottom = BaseScriptElement.getIntElement(instrument_dom, "mask_bottom", default=ReductionOptions.bottom) - self.right = BaseScriptElement.getIntElement(instrument_dom, "mask_right", default=ReductionOptions.right) - self.left = BaseScriptElement.getIntElement(instrument_dom, "mask_left", default=ReductionOptions.left) - else: - element_list = dom.getElementsByTagName("Mask") - if len(element_list)>0: - mask_dom = element_list[0] - self.top = BaseScriptElement.getIntElement(mask_dom, "mask_top", default=ReductionOptions.top) - self.bottom = BaseScriptElement.getIntElement(mask_dom, "mask_bottom", default=ReductionOptions.bottom) - self.right = BaseScriptElement.getIntElement(mask_dom, "mask_right", default=ReductionOptions.right) - self.left = BaseScriptElement.getIntElement(mask_dom, "mask_left", default=ReductionOptions.left) - - self.shapes = [] - shapes_dom_list = mask_dom.getElementsByTagName("Shapes") - if len(shapes_dom_list)>0: - shapes_dom = shapes_dom_list[0] - for item in shapes_dom.getElementsByTagName("rect"): - x_min = float(item.getAttribute("x_min")) - x_max = float(item.getAttribute("x_max")) - y_min = float(item.getAttribute("y_min")) - y_max = float(item.getAttribute("y_max")) - self.shapes.append(ReductionOptions.RectangleMask(x_min, x_max, y_min, y_max)) - - self.detector_ids = BaseScriptElement.getIntList(mask_dom, "DetectorIDs", default=[]) - self.mask_file = BaseScriptElement.getStringElement(mask_dom, "mask_file") - self.use_mask_file = BaseScriptElement.getBoolElement(mask_dom, "use_mask_file", - default = ReductionOptions.use_mask_file) + # Mask + element_list = dom.getElementsByTagName("Mask") + if len(element_list)>0: + mask_dom = element_list[0] + self.top = BaseScriptElement.getIntElement(mask_dom, "mask_top", default=ReductionOptions.top) + self.bottom = BaseScriptElement.getIntElement(mask_dom, "mask_bottom", default=ReductionOptions.bottom) + self.right = BaseScriptElement.getIntElement(mask_dom, "mask_right", default=ReductionOptions.right) + self.left = BaseScriptElement.getIntElement(mask_dom, "mask_left", default=ReductionOptions.left) + + self.shapes = [] + shapes_dom_list = mask_dom.getElementsByTagName("Shapes") + if len(shapes_dom_list)>0: + shapes_dom = shapes_dom_list[0] + for item in shapes_dom.getElementsByTagName("rect"): + x_min = float(item.getAttribute("x_min")) + x_max = float(item.getAttribute("x_max")) + y_min = float(item.getAttribute("y_min")) + y_max = float(item.getAttribute("y_max")) + self.shapes.append(ReductionOptions.RectangleMask(x_min, x_max, y_min, y_max)) + + self.detector_ids = BaseScriptElement.getIntList(mask_dom, "DetectorIDs", default=[]) + self.mask_file = BaseScriptElement.getStringElement(mask_dom, "mask_file") + self.use_mask_file = BaseScriptElement.getBoolElement(mask_dom, "use_mask_file", + default = ReductionOptions.use_mask_file) # Absolute scaling element_list = dom.getElementsByTagName("AbsScale") diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py index 066243fc917eaa63d73f846787b9a80f3674246e..6f076e84fff25c69c6cc305e07b209a53973867d 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py @@ -259,11 +259,8 @@ class SampleData(BaseScriptElement): self.calculation_method = method break - # Data file section - take care of backward compatibility - if mtd_version!=0 and mtd_version<BaseScriptElement.UPDATE_1_CHANGESET_CUTOFF: - element_list = dom.getElementsByTagName("Instrument") - else: - element_list = dom.getElementsByTagName("SampleData") + # Data file section + element_list = dom.getElementsByTagName("SampleData") if len(element_list)>0: sample_data_dom = element_list[0] self.data_files = BaseScriptElement.getStringList(sample_data_dom, "data_file") diff --git a/Code/Mantid/scripts/reduction/instruments/sans/hfir_command_interface.py b/Code/Mantid/scripts/reduction/instruments/sans/hfir_command_interface.py index 0ac59d32fa0dfe76bafc7b45c2fe4e3a6ed3a82f..738afc2b4569948771862cd320d93aee5db39490 100644 --- a/Code/Mantid/scripts/reduction/instruments/sans/hfir_command_interface.py +++ b/Code/Mantid/scripts/reduction/instruments/sans/hfir_command_interface.py @@ -189,24 +189,32 @@ def SampleWidth(width): def HFIRSANS(): Clear(SANSReducer) ReductionSingleton().set_instrument(hfir_instrument.HFIRSANS("GPSANS")) + ReductionSingleton().set_reduction(mantidsimple.SetupHFIRReduction, + ReductionTableWorkspace=ReductionSingleton().get_reduction_table_name()) SolidAngle() AzimuthalAverage() def BIOSANS(): Clear(SANSReducer) ReductionSingleton().set_instrument(hfir_instrument.HFIRSANS("BIOSANS")) + ReductionSingleton().set_reduction(mantidsimple.SetupHFIRReduction, + ReductionTableWorkspace=ReductionSingleton().get_reduction_table_name()) SolidAngle() AzimuthalAverage() def HFIRDEV(): Clear(SANSReducer) ReductionSingleton().set_instrument(hfir_instrument.HFIRSANS("BIOSANS")) + ReductionSingleton().set_reduction(mantidsimple.SetupHFIRReduction, + ReductionTableWorkspace=ReductionSingleton().get_reduction_table_name()) SolidAngle() AzimuthalAverage() def GPSANS(): Clear(SANSReducer) ReductionSingleton().set_instrument(hfir_instrument.HFIRSANS("GPSANS")) + ReductionSingleton().set_reduction(mantidsimple.SetupHFIRReduction, + ReductionTableWorkspace=ReductionSingleton().get_reduction_table_name()) SolidAngle() AzimuthalAverage() diff --git a/Code/Mantid/scripts/reduction/instruments/sans/sans_reducer.py b/Code/Mantid/scripts/reduction/instruments/sans/sans_reducer.py index 05228065701eed2cbbfbd5e95bccdb639bea1aed..ad5353405b9753392598d36e0adb88a7dcb32841 100644 --- a/Code/Mantid/scripts/reduction/instruments/sans/sans_reducer.py +++ b/Code/Mantid/scripts/reduction/instruments/sans/sans_reducer.py @@ -9,7 +9,7 @@ from reduction import validate_step import sans_reduction_steps import hfir_load import absolute_scale -from mantidsimple import * +import mantidsimple import warnings import inspect @@ -26,6 +26,9 @@ class SANSReducer(Reducer): NORMALIZATION_TIME = 1 NORMALIZATION_MONITOR = 0 + ## Reduction setup + _reduction_setup = None + ## Beam center finder ReductionStep object _beam_finder = None @@ -88,10 +91,10 @@ class SANSReducer(Reducer): self._mask = sans_reduction_steps.Mask() # Default dark current subtracter class - self._dark_current_subtracter_class = HFIRDarkCurrentSubtraction + self._dark_current_subtracter_class = mantidsimple.HFIRDarkCurrentSubtraction # Resolution calculator - self._resolution_calculator = ReactorSANSResolution + self._resolution_calculator = mantidsimple.ReactorSANSResolution # Sample geometry correction self.geometry_correcter = None @@ -117,6 +120,10 @@ class SANSReducer(Reducer): def get_normalizer(self): return self._normalizer + @validate_step + def set_reduction(self, setup_algorithm): + self._reduction_setup = setup_algorithm + @validate_step def set_geometry_correcter(self, correcter): """ @@ -292,6 +299,10 @@ class SANSReducer(Reducer): if self.instrument is None: raise RuntimeError, "SANSReducer: trying to run a reduction with no instrument specified" + if self._reduction_setup is not None: + result = self._reduction_setup.execute(self) + self.log_text += "%s\n" % str(result) + if self._beam_finder is not None: result = self._beam_finder.execute(self) self.log_text += "%s\n" % str(result) diff --git a/Code/Mantid/scripts/reduction/instruments/sans/sans_reduction_steps.py b/Code/Mantid/scripts/reduction/instruments/sans/sans_reduction_steps.py index 1fb512fbb26ddf985254d8231ae46c287eb03b5a..02126a34bc893ee0760cc9ba79e92f8cc89fa575 100644 --- a/Code/Mantid/scripts/reduction/instruments/sans/sans_reduction_steps.py +++ b/Code/Mantid/scripts/reduction/instruments/sans/sans_reduction_steps.py @@ -713,7 +713,7 @@ class SensitivityCorrection(ReductionStep): return output_str - def _workflow_alg(self, reducer, workspace): + def _execute_new(self, reducer, workspace): center_x = None center_y = None # Find the beam center if we need to @@ -739,7 +739,6 @@ class SensitivityCorrection(ReductionStep): return l.getPropertyValue("OutputMessage") def execute(self, reducer, workspace): - #return self._workflow_alg(reducer, workspace) # If the sensitivity correction workspace exists, just apply it. # Otherwise create it. #TODO: check that the workspaces have the same binning!