diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h index 22ada223228ef70c1266fb561d6ecde2ca7ec11d..7e1e3a7288daf6cc5f01c11d7fc66a8c721622d9 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h @@ -64,146 +64,12 @@ namespace Mantid /// Get those dimensions which have not been collapsed. virtual Mantid::Geometry::VecIMDDimension_const_sptr getNonIntegratedDimensions() const = 0; - /// Get the signal at the specified index. - virtual signal_t getSignalAt(size_t index1) const - { - return getPoint(index1).getSignal(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getSignalAt(size_t index1, size_t index2) const - { - return getCell(index1,index2).getSignal(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getSignalAt(size_t index1, size_t index2, size_t index3) const - { - return getCell(index1,index2,index3).getSignal(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getSignalAt(size_t index1, size_t index2, size_t index3, size_t index4) const - { - return getCell(index1,index2,index3,index4).getSignal(); - } - - - /// Get the error of the signal at the specified index. - virtual signal_t getErrorAt(size_t index) const - { - return getPoint(index).getError(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getErrorAt(size_t index1, size_t index2) const - { - return getCell(index1,index2).getError(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getErrorAt(size_t index1, size_t index2, size_t index3) const - { - return getCell(index1,index2,index3).getError(); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t) - virtual signal_t getErrorAt(size_t index1, size_t index2, size_t index3, size_t index4) const - { - return getCell(index1,index2,index3,index4).getError(); - } - - - /// Get the signal at the specified index, normalized by cell volume - virtual signal_t getSignalNormalizedAt(size_t index) const - { UNUSED_ARG(index); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); UNUSED_ARG(index4); - throw std::runtime_error("Not implemented yet."); - } - - - /// Get the error of the signal at the specified index, normalized by cell volume - virtual signal_t getErrorNormalizedAt(size_t index) const - { UNUSED_ARG(index); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); - throw std::runtime_error("Not implemented yet."); - } - - /// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume - virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const - { UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); UNUSED_ARG(index4); - throw std::runtime_error("Not implemented yet."); - } - - - - - /// Return a vector containing a copy of the signal data in the workspace. TODO: Make this more efficient if needed. - virtual std::vector<signal_t> getSignalDataVector() const - { - throw std::runtime_error("Not implemented yet."); - } - - /// Return a vector containing a copy of the signal data in the workspace. TODO: Make this more efficient if needed. - virtual std::vector<signal_t> getErrorDataVector() const - { - throw std::runtime_error("Not implemented yet."); - } - - - - /// Get the point at the specified index. virtual const Mantid::Geometry::SignalAggregate& getPoint(size_t index) const = 0; - // TODO: JZ : As far as I can tell, these getCell() calls are relatively unused, and may perhaps be replaced by getSignal() calls - /// Get the cell at the specified index/increment. virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment) const = 0; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const = 0; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const = 0; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const = 0; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const = 0; - - /// Horace sytle implementations need to have access to the underlying file. - virtual std::string getWSLocation() const = 0; - /// Creates a new iterator pointing to the first cell in the workspace virtual IMDIterator* createIterator() const; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h index f60c9c1369412c7d841f1c35cb441fe6f688d49e..b054db3ca50f18064b9981d54a945433e9bc031d 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h @@ -271,21 +271,11 @@ namespace Mantid virtual const Mantid::Geometry::SignalAggregate& getPoint(size_t index) const; /// Get the cell at the specified index/increment. virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment) const; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const; /// Dimension id for x-dimension. static const std::string xDimensionId; /// Dimensin id for y-dimension. static const std::string yDimensionId; /// Getter for collapsed dimensions. - /// Provide the location of the underlying file. - virtual std::string getWSLocation() const; Mantid::Geometry::VecIMDDimension_const_sptr getNonIntegratedDimensions() const { throw std::runtime_error("Not yet implemented"); diff --git a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp index 906e1f60decb35ce8dce3ffce4f89b6cb010a8ac..e2d67182aacdc55433af5b297755b67dc7672b1a 100644 --- a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp +++ b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp @@ -1261,7 +1261,7 @@ namespace Mantid virtual size_t getNBins() const {return m_axis.length();} /// Change the extents and number of bins - virtual void setRange(size_t nBins, double min, double max){throw std::runtime_error("Not implemented");} + virtual void setRange(size_t /*nBins*/, double /*min*/, double /*max*/){throw std::runtime_error("Not implemented");} /// Get coordinate for index; virtual double getX(size_t ind)const {return m_axis(ind);} @@ -1327,46 +1327,6 @@ namespace Mantid return this->getPoint(dim1Increment); } - const Mantid::Geometry::SignalAggregate& MatrixWorkspace::getCell(size_t dim1Increment, size_t dim2Increment) const - { - if (dim1Increment >= this->dataX(0).size()) - { - throw std::range_error("MatrixWorkspace::getCell, increment out of range"); - } - if (dim2Increment >= this->dataX(0).size()) - { - throw std::range_error("MatrixWorkspace::getCell, increment out of range"); - } - - return getPointImp(dim1Increment, dim2Increment); - } - - const Mantid::Geometry::SignalAggregate& MatrixWorkspace::getCell(size_t, size_t, size_t) const - { - throw std::logic_error("Cannot access higher dimensions"); - } - - const Mantid::Geometry::SignalAggregate& MatrixWorkspace::getCell(size_t, size_t, size_t, size_t) const - { - throw std::logic_error("Cannot access higher dimensions"); - } - - const Mantid::Geometry::SignalAggregate& MatrixWorkspace::getCell(...) const - { - throw std::logic_error("Cannot access higher dimensions"); - } - - std::string MatrixWorkspace::getWSLocation() const - { - throw std::logic_error("Cannot access the workspace location on a MatrixWS"); - } - - - - - - - //-------------------------------------------------------------------------------------------- /** Save the spectra detector map to an open NeXus file. diff --git a/Code/Mantid/Framework/API/test/IMDWorkspaceTest.h b/Code/Mantid/Framework/API/test/IMDWorkspaceTest.h index 817fbf83d20ae25d8b77b3c8b96b3cf41baf6a07..b9dda45d85d29d70dd0f69f52e62ac8c9d7edee1 100644 --- a/Code/Mantid/Framework/API/test/IMDWorkspaceTest.h +++ b/Code/Mantid/Framework/API/test/IMDWorkspaceTest.h @@ -114,14 +114,6 @@ public: TSM_ASSERT_EQUALS("The expected number of points have not been returned.", 25, matrixWS.getNPoints()); } - void testGetCellElipsisParameterVersion() - { - WorkspaceTester matrixWS; - TSM_ASSERT_THROWS("Cannot access higher dimensions should throw logic error.", matrixWS.getCell(1, 1, 1), std::logic_error); - TSM_ASSERT_THROWS("Cannot access higher dimensions should throw logic error.", matrixWS.getCell(1, 1, 1, 1), std::logic_error); - TSM_ASSERT_THROWS("Cannot access higher dimensions should throw logic error.", matrixWS.getCell(1, 1, 1, 1, 1, 1, 1, 1, 1), std::logic_error); - } - void testGetHistogramIndex() { MatrixWSIndexCalculator indexCalculator(5); @@ -178,10 +170,6 @@ public: TSM_ASSERT_EQUALS("The v3 y-value is incorrect.", 2, vertexes.at(3).getY()); } - void testGetWSLocationThrows() - { - TSM_ASSERT_THROWS("Getting the workspace location should not be possible.", workspace.getWSLocation(), std::logic_error); - } }; diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CobaltSWDTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CobaltSWDTest.h index 38ec92bf2b3649f36d52c251d84550cb859ea9d1..0816af334049fb04d24b8f999091298650fbe3bb 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/CobaltSWDTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/CobaltSWDTest.h @@ -156,26 +156,6 @@ public: return(m_mdcells.at(dim1Increment)); }; - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not implemented"); - } - virtual boost::shared_ptr<const Mantid::Geometry::IMDDimension> getDimension(std::string id) const { // only one dimension in this mock up @@ -187,10 +167,7 @@ public: /// return number of dimensions in MD workspace virtual size_t getNumDims()const{return 4;} virtual size_t getMemorySize() const {return 0;}; - virtual std::string getWSLocation() const - { - throw std::runtime_error("Not implemented"); - } + virtual std::string getGeometryXML() const { throw std::runtime_error("Not implemented"); diff --git a/Code/Mantid/Framework/MDAlgorithms/test/QuadEnBackgroundTest.h b/Code/Mantid/Framework/MDAlgorithms/test/QuadEnBackgroundTest.h index bcfc6caad22aad28a0ed14793908bab29cfd2fc4..d17641d2b1d14ae7ccb4998bf7e4d68a6d584344 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/QuadEnBackgroundTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/QuadEnBackgroundTest.h @@ -153,26 +153,6 @@ public: return(m_mdcells.at(dim1Increment)); }; - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not implemented"); - } - virtual boost::shared_ptr<const Mantid::Geometry::IMDDimension> getDimension(std::string id) const { // only one dimension in this mock up @@ -184,10 +164,7 @@ public: /// return number of dimensions in MD workspace virtual size_t getNumDims()const{return 4;} virtual size_t getMemorySize() const {return 0;}; - virtual std::string getWSLocation() const - { - throw std::runtime_error("Not implemented"); - } + virtual std::string getGeometryXML() const { throw std::runtime_error("Not implemented"); diff --git a/Code/Mantid/Framework/MDAlgorithms/test/SimulateMDDataTest.h b/Code/Mantid/Framework/MDAlgorithms/test/SimulateMDDataTest.h index 11830cbe9640f40737e817db19008bb3870f2083..819381ef850f295f59030e02139db954a8f25cbe 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/SimulateMDDataTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/SimulateMDDataTest.h @@ -67,26 +67,6 @@ public: return(m_mdcells.at(dim1Increment)); }; - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t , size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t , size_t , size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not implemented"); - } - Mantid::Geometry::VecIMDDimension_const_sptr getNonIntegratedDimensions() const { throw std::runtime_error("Not implemented"); @@ -96,10 +76,7 @@ public: virtual const std::string id() const {return "TestIMDDWorkspace";} /// Get the footprint in memory in bytes - return 0 for now virtual size_t getMemorySize() const {return 0;}; - virtual std::string getWSLocation() const - { - throw std::runtime_error("Not implemented"); - } + virtual std::string getGeometryXML() const { throw std::runtime_error("Not implemented"); diff --git a/Code/Mantid/Framework/MDAlgorithms/test/TobyFitSimulateTest.h b/Code/Mantid/Framework/MDAlgorithms/test/TobyFitSimulateTest.h index f5ef059ccd8b8453593efa2cdf101b98f5cf7582..706f44488f69c7b6e77bf4a5f8807a0d5107c1c7 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/TobyFitSimulateTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/TobyFitSimulateTest.h @@ -69,26 +69,6 @@ public: return(m_mdcells.at(dim1Increment)); }; - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t , size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t ,size_t , size_t , size_t ) const - { - throw std::runtime_error("Not implemented"); - } - - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not implemented"); - } - Mantid::Geometry::VecIMDDimension_const_sptr getNonIntegratedDimensions() const { throw std::runtime_error("Not implemented"); @@ -98,10 +78,7 @@ public: virtual const std::string id() const {return "TestIMDDWorkspace";} /// Get the footprint in memory in bytes - return 0 for now virtual size_t getMemorySize() const {return 0;}; - virtual std::string getWSLocation() const - { - throw std::runtime_error("Not implemented"); - } + virtual std::string getGeometryXML() const { throw std::runtime_error("Not implemented"); diff --git a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDFitWorkspace.h b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDFitWorkspace.h index a671ed60965b85b0e94895bc23b7ef64160f498e..dea39eee8272314e43ccc19473c6ee97ad510011 100644 --- a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDFitWorkspace.h +++ b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MDFitWorkspace.h @@ -100,21 +100,6 @@ namespace Mantid /// Get the cell at the specified index/increment. virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment) const; - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const; - - /// Get the cell at the specified index/increment. - virtual const Mantid::Geometry::SignalAggregate& getCell(...) const; - - /// Get the location of the workspace on disk, supports Horace implementation of rebinning. - virtual std::string getWSLocation() const{return "";} - /// Get the geometry xml. virtual std::string getGeometryXML() const{return "";} diff --git a/Code/Mantid/Framework/MDDataObjects/src/MDFitWorkspace.cpp b/Code/Mantid/Framework/MDDataObjects/src/MDFitWorkspace.cpp index 9e4b15c4c8327ddd50df08c3aa364cb4a57ea876..4eb1376dea470c4ec2674ddfeb5e646ae11156b9 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MDFitWorkspace.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MDFitWorkspace.cpp @@ -136,96 +136,6 @@ namespace Mantid{ return m_cells[dim1Increment]; } - const Mantid::Geometry::SignalAggregate& MDFitWorkspace::getCell(size_t dim1Increment, size_t dim2Increment) const - { - UNUSED_ARG(dim1Increment); - UNUSED_ARG(dim2Increment); - //if (m_dimensions.size() != 2) - //{ - // throw std::runtime_error("MDFitWorkspace is not two dimensional"); - //} - int singleDimensionIndex = 0;//m_indexCalculator->calculateSingleDimensionIndex - return m_cells[singleDimensionIndex]; - } - - const Mantid::Geometry::SignalAggregate& MDFitWorkspace::getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const - { - UNUSED_ARG(dim1Increment); - UNUSED_ARG(dim2Increment); - UNUSED_ARG(dim3Increment); - - //MD_image_point point = m_spMDImage->getPoint(dim1Increment, dim2Increment, dim3Increment); - //MDGeometryOld const * const geometry = m_spMDImage->getGeometry(); - //IMDDimension_sptr xDimension = geometry->getXDimension(); - //IMDDimension_sptr yDimension = geometry->getYDimension(); - //IMDDimension_sptr zDimension = geometry->getZDimension(); - - ////The cell map is agnostic of the dimensionality. Request needs to be forulated into a single dimensional form. - //MDFitWorkspaceIndexCalculator calculator(3); - //calculator.setDimensionSize(0, xDimension->getNBins()); - //calculator.setDimensionSize(1, yDimension->getNBins()); - //calculator.setDimensionSize(2, zDimension->getNBins()); - //size_t indexes[] = {dim1Increment, dim2Increment, dim3Increment}; - //VecIndexes vecIndexes(3); - //std::copy(indexes, indexes+3, vecIndexes.begin()); - //size_t singleDimensionIndex = calculator.calculateSingleDimensionIndex(vecIndexes); - - //if(singleDimensionIndex > calculator.getIndexUpperBounds()) - //{ - // throw std::range_error("Requested cell is out of range."); - //} - //if(true == newCellRequired(singleDimensionIndex, point)) - //{ - // VecCoordinate vertexes = createPolyhedron(dim1Increment, dim2Increment, dim3Increment, xDimension, yDimension, zDimension); - // m_mdCellMap[singleDimensionIndex] = Mantid::Geometry::MDCell(point.s, point.err, vertexes); - //} - int singleDimensionIndex = 0;//m_indexCalculator->calculateSingleDimensionIndex - return m_cells[singleDimensionIndex]; - } - - const Mantid::Geometry::SignalAggregate& MDFitWorkspace::getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const - { - UNUSED_ARG(dim1Increment); - UNUSED_ARG(dim2Increment); - UNUSED_ARG(dim3Increment); - UNUSED_ARG(dim4Increment); - - //MD_image_point point = m_spMDImage->getPoint(dim1Increment, dim2Increment, dim3Increment, dim4Increment); - //MDGeometryOld const * const geometry = m_spMDImage->getGeometry(); - //IMDDimension_sptr xDimension = geometry->getXDimension(); - //IMDDimension_sptr yDimension = geometry->getYDimension(); - //IMDDimension_sptr zDimension = geometry->getZDimension(); - //IMDDimension_sptr tDimension = geometry->getZDimension(); - - ////The cell map is agnostic of the dimensionality. Request needs to be forulated into a single dimensional form. - //MDFitWorkspaceIndexCalculator calculator(4); - //calculator.setDimensionSize(0, xDimension->getNBins()); - //calculator.setDimensionSize(1, yDimension->getNBins()); - //calculator.setDimensionSize(2, zDimension->getNBins()); - //calculator.setDimensionSize(3, tDimension->getNBins()); - //size_t indexes[] = {dim1Increment, dim2Increment, dim3Increment, dim4Increment}; - //VecIndexes vecIndexes(4); - //std::copy(indexes, indexes+4, vecIndexes.begin()); - //size_t singleDimensionIndex = calculator.calculateSingleDimensionIndex(vecIndexes); - - //if(singleDimensionIndex > calculator.getIndexUpperBounds()) - //{ - // throw std::range_error("Requested cell is out of range."); - //} - //if(true == newCellRequired(singleDimensionIndex, point)) - //{ - // VecCoordinate vertexes = create4DPolyhedron(dim1Increment, dim2Increment, dim3Increment, dim4Increment, xDimension, yDimension, zDimension, tDimension); - // m_mdCellMap[singleDimensionIndex] = Mantid::Geometry::MDCell(point.s, point.err, vertexes); - //} - int singleDimensionIndex = 0;//m_indexCalculator->calculateSingleDimensionIndex - return m_cells[singleDimensionIndex]; - } - - const Mantid::Geometry::SignalAggregate& MDFitWorkspace::getCell(...) const - { - throw std::runtime_error("Not implemented"); - } - /** * Implementation of IMDDimension to work with MDFitWorkspace */ diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h index 242a22ad8de0c6162f5c57bdc41e4eed79d78630..fa66d64c8c97eeea6179f76f96c172593f401055 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h @@ -230,40 +230,6 @@ namespace MDEvents throw Mantid::Kernel::Exception::NotImplementedError("Not yet!"); } - /// Get the cell at the specified index/increment. - const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment) const - { - (void) dim1Increment; (void) dim2Increment; // Avoid compiler warning - throw Mantid::Kernel::Exception::NotImplementedError("Not yet!"); - } - - /// Get the cell at the specified index/increment. - const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment) const - { - (void) dim1Increment; (void) dim2Increment; (void) dim3Increment; // Avoid compiler warning - throw Mantid::Kernel::Exception::NotImplementedError("Not yet!"); - } - - /// Get the cell at the specified index/increment. - const Mantid::Geometry::SignalAggregate& getCell(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment) const - { - (void) dim1Increment; (void) // -------------------------------------------------------------------------------------------- - dim2Increment; (void) dim3Increment; (void) dim4Increment; // Avoid compiler warning - throw Mantid::Kernel::Exception::NotImplementedError("Not yet!"); - } - - /// Get the cell at the specified index/increment. - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw Mantid::Kernel::Exception::NotImplementedError("MDHistoWorkspace does not support more than 4 dimensions!"); - } - - /// Horace sytle implementations need to have access to the underlying file. - std::string getWSLocation() const - { - return ""; - } - //====================================================================================== //================= END METHODS THAT WON'T GET IMPLEMENTED PROBABLY ===================== //====================================================================================== diff --git a/Code/Mantid/Framework/MDEvents/scripts/mayavi_mdew_view.py b/Code/Mantid/Framework/MDEvents/scripts/mayavi_mdew_view.py deleted file mode 100644 index 863a7f1ccefd2ccf666b5f1e0cdfdbd84ef4f08a..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/MDEvents/scripts/mayavi_mdew_view.py +++ /dev/null @@ -1,82 +0,0 @@ -""" Experimental script for visualizing MDEventWorkspace -using Mayavi. - -@author Janik Zikovsky""" - -#This line has to be first for some reason. -from enthought.mayavi import mlab - -import os -import sys -sys.path.append("/home/8oz/Code/Mantid/Code/Mantid/bin") -from MantidFramework import mtd -mtd.initialise() -from mantidsimple import * -import time -import numpy as np - -LoadEventNexus(Filename="CNCS_7860_event.nxs",OutputWorkspace="nxs",SingleBankPixelsOnly="0",Precount="1") -eew = mtd["nxs"] -ew = eew._getHeldObject() - -###################################################################### -#Python Script Generated by Algorithm History Display -###################################################################### -if 1: - LoadEventNexus(Filename="/home/8oz/data/TOPAZ_2511_event.nxs",OutputWorkspace="nxs",SingleBankPixelsOnly="0",Precount="1") - eew = mtd["nxs"] - ew = eew._getHeldObject() - - - -ConvertToDiffractionMDWorkspace(InputWorkspace="nxs",OutputWorkspace="nxs_md") -aa = mtd["nxs_md"] -a = aa._getHeldObject() - -# How it gets binned -xbins = 100 -ybins = 100 -zbins = 100 -min = -6 -max = +6 -x = "Qx, %f, %f, %d" % (min,max,xbins) -y = "Qy, %f, %f, %d" % (min,max,ybins) -z = "Qz, %f, %f, %d" % (min,max,zbins) -start = time.time() -alg = BinToMDHistoWorkspace(InputWorkspace="nxs_md", OutputWorkspace="nxs_mdhisto", DimX=x, DimY=y, DimZ=z, DimT="NONE,0,10,1") -print time.time()-start, " secs to bin." - -bb = mtd["nxs_mdhisto"] -b = bb._getHeldObject() - -data = b.getSignalDataVector() -data = np.array(data) -data = data.reshape( (xbins, ybins, zbins) ) -f = open("tempdata.dat", 'w') -data.tofile(f) -f.close() - -logdata = np.log10(data); - - -mlab.contour3d(logdata, contours=[0,1,2,3], transparent=True) - -mlab.contour3d(data, contours=[1, 100], transparent=True) - -for i in xrange(4): - mlab.figure(i) - contour_val = 10**i - mlab.gcf().name = "Threshold = %f" % contour_val - mlab.contour3d(data, contours=[ contour_val ]) - -mlab.show() - -# -####################################################################### -##Python Script Generated by Algorithm History Display -####################################################################### -#LoadEventNexus(Filename="/home/8oz/data/TOPAZ_2511_event.nxs",OutputWorkspace="top_2511",SingleBankPixelsOnly="0",Precount="1") -#CompressEvents(InputWorkspace="top_2511",OutputWorkspace="top_2511",Tolerance="0.050000000000000003") -# -#ConvertToDiffractionMDWorkspace(InputWorkspace="top_2511",OutputWorkspace="mdew") -#BinToMDHistoWorkspace(InputWorkspace="top_2511_md",DimX="Qx,-10,10,50",DimY="Qy,-10,10,50",DimZ="Qz,-10,10,50",DimT="NONE,0,10,1",OutputWorkspace="top_histo") diff --git a/Code/Mantid/Framework/MDEvents/scripts/mdevents_optimize.py b/Code/Mantid/Framework/MDEvents/scripts/mdevents_optimize.py index f3df71a9afe0bf8ee50ad254dc0193dbb22cc558..59b48f13da568f7f885b779a95d26350105867b2 100644 --- a/Code/Mantid/Framework/MDEvents/scripts/mdevents_optimize.py +++ b/Code/Mantid/Framework/MDEvents/scripts/mdevents_optimize.py @@ -167,22 +167,3 @@ plot_results(results, "SplitInto", "FineBinTime", "SplitThreshold") show() - -# -#bb = mtd["mdhisto"] -#b = bb._getHeldObject() -# -#data = b.getSignalDataVector() -#data = np.array(data) -#data = data.reshape( (xbins, ybins, zbins) ) -#f = open("tempdata.dat") -#data.tofile(f) -#f.close() -# -# -#for i in xrange(4): -# mlab.figure(i) -# contour_val = 10**i -# mlab.gcf().name = "Threshold = %f" % contour_val -# mlab.contour3d(data, contours=[ contour_val ]) - diff --git a/Code/Mantid/Framework/MDEvents/test/BinToMDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/BinToMDHistoWorkspaceTest.h index ce467c021d0d9ff7dcc0a17cb23a24baebe12754..fb83bb6c536df35445055f3c38cd143541966ddf 100644 --- a/Code/Mantid/Framework/MDEvents/test/BinToMDHistoWorkspaceTest.h +++ b/Code/Mantid/Framework/MDEvents/test/BinToMDHistoWorkspaceTest.h @@ -26,6 +26,7 @@ #include <iostream> #include "MantidKernel/Strings.h" #include "MantidKernel/VMD.h" +#include "MantidMDEvents/MDHistoWorkspace.h" using namespace Mantid::MDEvents; using namespace Mantid::API; @@ -131,8 +132,8 @@ public: TS_ASSERT( alg.isExecuted() ); - IMDWorkspace_sptr out ; - TS_ASSERT_THROWS_NOTHING( out = boost::dynamic_pointer_cast<IMDWorkspace>( + MDHistoWorkspace_sptr out ; + TS_ASSERT_THROWS_NOTHING( out = boost::dynamic_pointer_cast<MDHistoWorkspace>( AnalysisDataService::Instance().retrieve("BinToMDHistoWorkspaceTest_ws")); ) TS_ASSERT(out); if(!out) return; @@ -342,8 +343,8 @@ public: TS_ASSERT( alg.isExecuted() ); - IMDWorkspace_sptr out ; - TS_ASSERT_THROWS_NOTHING( out = boost::dynamic_pointer_cast<IMDWorkspace>( + MDHistoWorkspace_sptr out ; + TS_ASSERT_THROWS_NOTHING( out = boost::dynamic_pointer_cast<MDHistoWorkspace>( AnalysisDataService::Instance().retrieve("BinToMDHistoWorkspaceTest_ws")); ) TS_ASSERT(out); if(!out) return; diff --git a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h index f74ddf8567b2e9584dfa161d0f7ac4d5b4ef5295..aaa387f0529379fea268a6cb57cb45bc34814e66 100644 --- a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h +++ b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h @@ -37,7 +37,6 @@ public: // Methods that are not implemented TS_ASSERT_THROWS_ANYTHING( ws.getCell(1) ); - TS_ASSERT_THROWS_ANYTHING( ws.getCell(1,2,3,4) ); TS_ASSERT_THROWS_ANYTHING( ws.getPoint(1) ); // The values are cleared at the start diff --git a/Code/Mantid/Framework/PythonAPI/src/api_exports.cpp b/Code/Mantid/Framework/PythonAPI/src/api_exports.cpp index 05bfc82ea07a5859ecd90767fba1b229271d0708..1d6bd0934da95309493fcd2b47ba0042461bfb43 100644 --- a/Code/Mantid/Framework/PythonAPI/src/api_exports.cpp +++ b/Code/Mantid/Framework/PythonAPI/src/api_exports.cpp @@ -310,8 +310,6 @@ using namespace boost::python; .def("getNPoints", &IMDWorkspace::getNPoints) .def("getNumDims", &IMDWorkspace::getNumDims) .def("getDimensionNum", &IMDWorkspace::getDimensionNum ) - .def("getSignalDataVector", &IMDWorkspace::getSignalDataVector) - .def("getErrorDataVector", &IMDWorkspace::getErrorDataVector) ; } diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/RebinningKnowledgeSerializer.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/RebinningKnowledgeSerializer.h index e3d0f43152d9c048b576cbe62daf0c4009504acc..40ff06158f11edb55b9f008dab6dac5871d35b0c 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/RebinningKnowledgeSerializer.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/RebinningKnowledgeSerializer.h @@ -61,7 +61,6 @@ private: boost::shared_ptr<const Mantid::Geometry::MDImplicitFunction> m_spFunction; std::string m_wsLocationXML; std::string m_wsNameXML; - std::string m_wsLocation; std::string m_wsName; std::string m_geomXML; LocationPolicy m_locationPolicy; @@ -78,18 +77,12 @@ public: /// Set the workspace name to apply. void setWorkspaceName(std::string wsName); - /// Set the location to apply. - void setWorkspaceLocation(std::string wsLocation); - /// Set the geometry xml to apply. void setGeometryXML(std::string geomXML); /// Create the xml string correponding to the set values. std::string createXMLString() const; - /// Get the underlying workspace location. - const std::string& getWorkspaceLocation() const; - /// Get the underlying workspace name. const std::string& getWorkspaceName() const; diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkStructuredGridFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkStructuredGridFactory.h index 8ae40c9bc9144ea9994a28f57d59683cc421f2b3..d9f9c59f213d8ad6e27d984ce81f91f6e95fa205 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkStructuredGridFactory.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkStructuredGridFactory.h @@ -27,12 +27,13 @@ File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -#include <vtkStructuredGrid.h> +#include "MantidAPI/IMDWorkspace.h" +#include "MantidMDEvents/MDHistoWorkspace.h" +#include "MantidVatesAPI/vtkDataSetFactory.h" +#include <vtkCellData.h> #include <vtkFloatArray.h> #include <vtkPoints.h> -#include <vtkCellData.h> -#include "MantidVatesAPI/vtkDataSetFactory.h" -#include "MantidAPI/IMDWorkspace.h" +#include <vtkStructuredGrid.h> namespace Mantid { @@ -86,7 +87,7 @@ private: /// Private constructor for use by constructional static member vtkStructuredGridFactory(); - Mantid::API::IMDWorkspace_sptr m_workspace; + Mantid::MDEvents::MDHistoWorkspace_sptr m_workspace; std::string m_scalarName; double m_timeValue; bool m_meshOnly; diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingHexahedronFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingHexahedronFactory.h index 5e1336f6da749b48edfb8e79d4f453d7f278b428..7eb1d3dc58335f129a5ae689c00aab1807a8343c 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingHexahedronFactory.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingHexahedronFactory.h @@ -35,6 +35,7 @@ #include <vtkFloatArray.h> #include <vtkCellData.h> #include <vtkHexahedron.h> +#include "MantidMDEvents/MDHistoWorkspace.h" namespace Mantid { @@ -83,7 +84,7 @@ protected: void validateDimensionsPresent() const; /// Image from which to draw. - Mantid::API::IMDWorkspace_sptr m_workspace; + Mantid::MDEvents::MDHistoWorkspace_sptr m_workspace; /// Name of the scalar to provide on mesh. std::string m_scalarName; diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingLineFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingLineFactory.h index f8f781c1fadd0374f6df8ca09741e270d1d9fd6a..0f4fb62a5aff97d58468f7a73a8cc579ae63fecf 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingLineFactory.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingLineFactory.h @@ -6,6 +6,7 @@ #include "MantidAPI/IMDWorkspace.h" #include "vtkUnstructuredGrid.h" #include "MantidVatesAPI/ThresholdRange.h" +#include "MantidMDEvents/MDHistoWorkspace.h" namespace Mantid { @@ -75,7 +76,7 @@ namespace Mantid private: - Mantid::API::IMDWorkspace_sptr m_workspace; + Mantid::MDEvents::MDHistoWorkspace_sptr m_workspace; std::string m_scalarName; @@ -85,4 +86,4 @@ namespace Mantid } } -#endif \ No newline at end of file +#endif diff --git a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingQuadFactory.h b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingQuadFactory.h index 505f1cd85df1bcc62d49b016071dd4d5f787e9b2..ae11f99af445e783d63db6eeb82675691efd6ece 100644 --- a/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingQuadFactory.h +++ b/Code/Mantid/Vates/VatesAPI/inc/MantidVatesAPI/vtkThresholdingQuadFactory.h @@ -6,6 +6,7 @@ #include "MantidVatesAPI/ThresholdRange.h" #include "MantidAPI/IMDWorkspace.h" #include "vtkUnstructuredGrid.h" +#include "MantidMDEvents/MDHistoWorkspace.h" namespace Mantid { @@ -77,8 +78,7 @@ however, some visualisation frameworks won't be able to treat these factories in virtual void validate() const; private: - - Mantid::API::IMDWorkspace_sptr m_workspace; + Mantid::MDEvents::MDHistoWorkspace_sptr m_workspace; std::string m_scalarName; @@ -88,4 +88,4 @@ however, some visualisation frameworks won't be able to treat these factories in } } -#endif \ No newline at end of file +#endif diff --git a/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp b/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp index 31e407e852e7571c964754790e03e3eec4bb1c47..01102294deafba98fea2824cf1e3c82e34ad69d3 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MedianAndBelowThresholdRange.cpp @@ -42,7 +42,7 @@ namespace Mantid size_t pos = 0; signal_t accumulated_signal = 0; - try +// try { Mantid::API::IMDIterator* it = m_workspace->createIterator(); while(it->next()) @@ -54,17 +54,17 @@ namespace Mantid } m_max = accumulated_signal / static_cast<signal_t>(it->getDataSize()); } - catch(Kernel::Exception::NotImplementedError&) // Really don't want to do this, but some IMDWorkspace don't implement createIterator! - { - uint64_t size = m_workspace->getNPoints(); - for(uint64_t i = 0; i < size; i++) - { - signal = m_workspace->getSignalAt(i); - accumulated_signal += signal; - m_min = signal < m_min ? signal : m_min; - } - m_max = accumulated_signal / static_cast<signal_t>(size); - } +// catch(Kernel::Exception::NotImplementedError&) // Really don't want to do this, but some IMDWorkspace don't implement createIterator! +// { +// uint64_t size = m_workspace->getNPoints(); +// for(uint64_t i = 0; i < size; i++) +// { +// signal = m_workspace->getSignalAt(i); +// accumulated_signal += signal; +// m_min = signal < m_min ? signal : m_min; +// } +// m_max = accumulated_signal / static_cast<signal_t>(size); +// } m_isCalculated = true; } @@ -134,4 +134,4 @@ namespace Mantid return signal != 0 && signal < m_max; } } -} \ No newline at end of file +} diff --git a/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp index cf68b5b5205cacfc1a5f75ade627ebfbea6db19c..c9a0d6cd0e4c76b21e7111e1dd05262f0a4f5a2e 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MultiDimensionalDbPresenter.cpp @@ -119,7 +119,6 @@ vtkDataSet* MultiDimensionalDbPresenter::getMesh(RebinningKnowledgeSerializer& s //Serialize metadata serializer.setWorkspaceName(m_workspace->getName()); - serializer.setWorkspaceLocation(m_workspace->getWSLocation()); serializer.setGeometryXML(m_workspace->getGeometryXML()); std::string xmlString = serializer.createXMLString(); diff --git a/Code/Mantid/Vates/VatesAPI/src/RebinningKnowledgeSerializer.cpp b/Code/Mantid/Vates/VatesAPI/src/RebinningKnowledgeSerializer.cpp index 45bc107a2f2f8e350b22af79103cf549036f9caa..2baa97a315f93b9f724d2c7dbc9501092ca2936a 100644 --- a/Code/Mantid/Vates/VatesAPI/src/RebinningKnowledgeSerializer.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/RebinningKnowledgeSerializer.cpp @@ -17,7 +17,6 @@ RebinningKnowledgeSerializer::RebinningKnowledgeSerializer(LocationPolicy locati m_spFunction(), m_wsLocationXML(""), m_wsNameXML(""), - m_wsLocation(""), m_wsName(""), m_geomXML(""), m_locationPolicy(locationPolicy) @@ -34,8 +33,7 @@ void RebinningKnowledgeSerializer::setWorkspace(boost::shared_ptr<const Mantid:: { this->m_wsNameXML = MDGeometryXMLDefinitions::workspaceNameXMLTagStart() + workspace->getName() + MDGeometryXMLDefinitions::workspaceNameXMLTagEnd(); - this->m_wsLocation = workspace->getWSLocation(); - this->m_wsLocationXML = MDGeometryXMLDefinitions::workspaceLocationXMLTagStart() + this->m_wsLocation + MDGeometryXMLDefinitions::workspaceLocationXMLTagEnd(); + this->m_wsLocationXML = MDGeometryXMLDefinitions::workspaceLocationXMLTagStart() + "" + MDGeometryXMLDefinitions::workspaceLocationXMLTagEnd(); this->m_geomXML = workspace->getGeometryXML(); } @@ -45,13 +43,6 @@ void RebinningKnowledgeSerializer::setWorkspaceName(std::string wsName) this->m_wsNameXML = std::string(MDGeometryXMLDefinitions::workspaceNameXMLTagStart() + wsName + MDGeometryXMLDefinitions::workspaceNameXMLTagEnd()); } -void RebinningKnowledgeSerializer::setWorkspaceLocation(std::string wsLocation) -{ - - this->m_wsLocation = wsLocation; - this->m_wsLocationXML = std::string(MDGeometryXMLDefinitions::workspaceLocationXMLTagStart() + wsLocation + MDGeometryXMLDefinitions::workspaceLocationXMLTagEnd() ); -} - void RebinningKnowledgeSerializer::setGeometryXML(std::string geomXML) { this->m_geomXML = geomXML; @@ -65,13 +56,13 @@ std::string RebinningKnowledgeSerializer::createXMLString() const { throw std::runtime_error("No geometry provided on workspace."); } - if(LocationMandatory == this->m_locationPolicy) //Only if it is stated that a location must be provided, do we apply the checking. - { - if(this->m_wsLocationXML == (MDGeometryXMLDefinitions::workspaceLocationXMLTagStart() + MDGeometryXMLDefinitions::workspaceLocationXMLTagEnd())) - { - throw std::runtime_error("No workspace location provided on workspace."); - } - } +// if(LocationMandatory == this->m_locationPolicy) //Only if it is stated that a location must be provided, do we apply the checking. +// { +// if(this->m_wsLocationXML == (MDGeometryXMLDefinitions::workspaceLocationXMLTagStart() + MDGeometryXMLDefinitions::workspaceLocationXMLTagEnd())) +// { +// throw std::runtime_error("No workspace location provided on workspace."); +// } +// } if(this->m_wsNameXML == (MDGeometryXMLDefinitions::workspaceNameXMLTagStart() + MDGeometryXMLDefinitions::workspaceNameXMLTagEnd())) { throw std::runtime_error("No workspace name provided on workspace."); @@ -89,11 +80,6 @@ std::string RebinningKnowledgeSerializer::createXMLString() const } } -const std::string& RebinningKnowledgeSerializer::getWorkspaceLocation() const -{ - return this->m_wsLocation; -} - const std::string& RebinningKnowledgeSerializer::getWorkspaceName() const { return this->m_wsName; @@ -111,7 +97,7 @@ const std::string& RebinningKnowledgeSerializer::getWorkspaceGeometry() const bool RebinningKnowledgeSerializer::hasGeometryInfo() const { - return !m_geomXML.empty() && !m_wsLocation.empty() && !m_wsName.empty(); + return !m_geomXML.empty() && !m_wsName.empty(); } diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkStructuredGridFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkStructuredGridFactory.cpp index 09fda14344caf265f4bd86823b32bc5ff02fbd2a..63a8606765b5552181c223faad1c000bb0a21299 100644 --- a/Code/Mantid/Vates/VatesAPI/src/vtkStructuredGridFactory.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/vtkStructuredGridFactory.cpp @@ -2,8 +2,10 @@ #include "MantidVatesAPI/TimeStepToTimeStep.h" #include "MantidVatesAPI/TimeToTimeStep.h" #include "MantidAPI/IMDWorkspace.h" +#include "MantidMDEvents/MDHistoWorkspace.h" using Mantid::API::IMDWorkspace; +using Mantid::MDEvents::MDHistoWorkspace; namespace Mantid { @@ -54,7 +56,7 @@ namespace VATES template<typename TimeMapper> void vtkStructuredGridFactory<TimeMapper>::initialize(Mantid::API::Workspace_sptr workspace) { - m_workspace = boost::dynamic_pointer_cast<IMDWorkspace>(workspace); + m_workspace = boost::dynamic_pointer_cast<MDHistoWorkspace>(workspace); validate(); double tMax = m_workspace->getTDimension()->getMaximum(); diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingHexahedronFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingHexahedronFactory.cpp index d2965fcd5d9227a65498770c3a155dae84a6fe71..cff4e9782d00f87322253e8257235208d8cfeb2b 100644 --- a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingHexahedronFactory.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingHexahedronFactory.cpp @@ -51,7 +51,7 @@ namespace VATES void vtkThresholdingHexahedronFactory::initialize(Mantid::API::Workspace_sptr workspace) { - m_workspace = boost::dynamic_pointer_cast<IMDWorkspace>(workspace); + m_workspace = boost::dynamic_pointer_cast<MDHistoWorkspace>(workspace); // Check that a workspace has been provided. validateWsNotNull(); // When the workspace can not be handled by this type, take action in the form of delegation. diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingLineFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingLineFactory.cpp index ebecef69468237ce09faf94feee8111dbcc5bb28..28f942565e57da113ffd7d96bc2a484718426042 100644 --- a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingLineFactory.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingLineFactory.cpp @@ -10,8 +10,10 @@ #include <boost/math/special_functions/fpclassify.hpp> #include "MantidAPI/IMDWorkspace.h" #include "MantidVatesAPI/NullCoordTransform.h" +#include "MantidMDEvents/MDHistoWorkspace.h" using Mantid::API::IMDWorkspace; +using Mantid::MDEvents::MDHistoWorkspace; namespace Mantid { @@ -155,7 +157,7 @@ namespace Mantid void vtkThresholdingLineFactory::initialize(Mantid::API::Workspace_sptr wspace_sptr) { - m_workspace = boost::dynamic_pointer_cast<IMDWorkspace>(wspace_sptr); + m_workspace = boost::dynamic_pointer_cast<MDHistoWorkspace>(wspace_sptr); validate(); // When the workspace can not be handled by this type, take action in the form of delegation. size_t nonIntegratedSize = m_workspace->getNonIntegratedDimensions().size(); diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingQuadFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingQuadFactory.cpp index fdfd48c2df592c762d4297ac11e5df214d864502..58e2ba8c2273d27bbbfa18847d1458252dc20285 100644 --- a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingQuadFactory.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingQuadFactory.cpp @@ -11,9 +11,11 @@ #include "MantidAPI/IMDWorkspace.h" #include "MantidKernel/CPUTimer.h" #include "MantidVatesAPI/NullCoordTransform.h" +#include "MantidMDEvents/MDHistoWorkspace.h" using Mantid::API::IMDWorkspace; using Mantid::Kernel::CPUTimer; +using Mantid::MDEvents::MDHistoWorkspace; namespace Mantid { @@ -213,7 +215,7 @@ namespace Mantid void vtkThresholdingQuadFactory::initialize(Mantid::API::Workspace_sptr wspace_sptr) { - m_workspace = boost::dynamic_pointer_cast<IMDWorkspace>(wspace_sptr); + m_workspace = boost::dynamic_pointer_cast<MDHistoWorkspace>(wspace_sptr); validate(); // When the workspace can not be handled by this type, take action in the form of delegation. const size_t nonIntegratedSize = m_workspace->getNonIntegratedDimensions().size(); diff --git a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingUnstructuredGridFactory.cpp b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingUnstructuredGridFactory.cpp index 3eb778c9ff250a4fbf346978b0eddccbf0d1eaeb..65570317a453d7d434994044ae0d5bc9cca24fdf 100644 --- a/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingUnstructuredGridFactory.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/vtkThresholdingUnstructuredGridFactory.cpp @@ -57,7 +57,7 @@ namespace VATES template<typename TimeMapper> void vtkThresholdingUnstructuredGridFactory<TimeMapper>::initialize(Mantid::API::Workspace_sptr workspace) { - m_workspace = boost::dynamic_pointer_cast<IMDWorkspace>(workspace); + m_workspace = boost::dynamic_pointer_cast<MDHistoWorkspace>(workspace); // Check that a workspace has been provided. validateWsNotNull(); // When the workspace can not be handled by this type, take action in the form of delegation. diff --git a/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h b/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h index e375db2bbb0ec7ca90be7e45365fecf511771f72..c7c994bd26190b7f3fcd03e87b0e0b1e9911ee52 100644 --- a/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/GaussianThresholdRangeTest.h @@ -88,13 +88,7 @@ namespace GaussianThresholdRangeTestHelpers MOCK_CONST_METHOD0(getMemorySize, size_t()); MOCK_CONST_METHOD1(getPoint,const Mantid::Geometry::SignalAggregate&(size_t index)); MOCK_CONST_METHOD1(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment)); - MOCK_CONST_METHOD2(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment)); - MOCK_CONST_METHOD3(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment)); - MOCK_CONST_METHOD4(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment)); - - MOCK_CONST_METHOD0(getWSLocation,std::string()); MOCK_CONST_METHOD0(getGeometryXML,std::string()); - MOCK_CONST_METHOD0(getXDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); MOCK_CONST_METHOD0(getYDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); MOCK_CONST_METHOD0(getZDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); @@ -111,10 +105,6 @@ namespace GaussianThresholdRangeTestHelpers return new FakeIterator(this, m_nCells); } - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not Implemented"); - } virtual ~MockIMDWorkspace() {} }; diff --git a/Code/Mantid/Vates/VatesAPI/test/MedianAndBelowThresholdRangeTest.h b/Code/Mantid/Vates/VatesAPI/test/MedianAndBelowThresholdRangeTest.h index a330112eb852b7cbc3e8c081cbe34191c17a5ece..f5590cc1646c35ffcf684edcc2a41aefdd1997b0 100644 --- a/Code/Mantid/Vates/VatesAPI/test/MedianAndBelowThresholdRangeTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/MedianAndBelowThresholdRangeTest.h @@ -88,13 +88,7 @@ namespace MedianAndBelowThresholdRangeTestHelpers MOCK_CONST_METHOD0(getMemorySize, size_t()); MOCK_CONST_METHOD1(getPoint,const Mantid::Geometry::SignalAggregate&(size_t index)); MOCK_CONST_METHOD1(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment)); - MOCK_CONST_METHOD2(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment)); - MOCK_CONST_METHOD3(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment)); - MOCK_CONST_METHOD4(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment)); - - MOCK_CONST_METHOD0(getWSLocation,std::string()); MOCK_CONST_METHOD0(getGeometryXML,std::string()); - MOCK_CONST_METHOD0(getXDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); MOCK_CONST_METHOD0(getYDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); MOCK_CONST_METHOD0(getZDimension,boost::shared_ptr<const Mantid::Geometry::IMDDimension>()); @@ -111,11 +105,6 @@ namespace MedianAndBelowThresholdRangeTestHelpers return new FakeIterator(this, m_nCells); } - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not Implemented"); - } - virtual ~MockIMDWorkspace() {} }; } diff --git a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h index fbdeb579e2434c6c39fd8d6e406b30c52c3732e0..2bf8a12e756667c661ed1743bb4db5b0e9a68f0b 100644 --- a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h +++ b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h @@ -136,13 +136,7 @@ public: MOCK_CONST_METHOD0(getMemorySize, size_t()); MOCK_CONST_METHOD1(getPoint,const Mantid::Geometry::SignalAggregate&(size_t index)); MOCK_CONST_METHOD1(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment)); - MOCK_CONST_METHOD2(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment)); - MOCK_CONST_METHOD3(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment)); - MOCK_CONST_METHOD4(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment)); - - MOCK_CONST_METHOD0(getWSLocation,std::string()); MOCK_CONST_METHOD0(getGeometryXML,std::string()); - MOCK_CONST_METHOD0(getNPoints, uint64_t()); MOCK_CONST_METHOD1(getSignalNormalizedAt, Mantid::signal_t(size_t index1)); MOCK_CONST_METHOD2(getSignalNormalizedAt, double(size_t index1, size_t index2)); @@ -155,16 +149,10 @@ public: return new FakeIterator(this); } - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not Implemented"); - } - virtual ~MockIMDWorkspace() {} }; - //================================================================================================= /// Mock to allow the behaviour of the chain of responsibility to be tested. class MockvtkDataSetFactory : public Mantid::VATES::vtkDataSetFactory @@ -268,7 +256,18 @@ class FakeProgressAction : public Mantid::VATES::ProgressAction Mantid::MDEvents::MDHistoWorkspace_sptr getFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10) { Mantid::MDEvents::MDHistoWorkspace * ws; - if (numDims == 3) + if (numDims ==1) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)) ); + } + else if (numDims == 2) + { + ws = new Mantid::MDEvents::MDHistoWorkspace( + MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), + MDHistoDimension_sptr(new MDHistoDimension("y","y","m", 0.0, 10.0, numBins)) ); + } + else if (numDims == 3) { ws = new Mantid::MDEvents::MDHistoWorkspace( MDHistoDimension_sptr(new MDHistoDimension("x","x","m", 0.0, 10.0, numBins)), diff --git a/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h b/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h index 403edb18d3b7904bf5c09c909225d9c1269fd13f..89f278ea2b3ef95e919d4cc8118bd1f8fb4e2810 100644 --- a/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/RebinningKnowledgeSerializerTest.h @@ -41,16 +41,9 @@ private: MOCK_CONST_METHOD0(getMemorySize, size_t()); MOCK_CONST_METHOD1(getPoint,const Mantid::Geometry::SignalAggregate&(size_t index)); MOCK_CONST_METHOD1(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment)); - MOCK_CONST_METHOD2(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment)); - MOCK_CONST_METHOD3(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment)); - MOCK_CONST_METHOD4(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment)); MOCK_CONST_METHOD0(getNonIntegratedDimensions, Mantid::Geometry::VecIMDDimension_const_sptr()); - MOCK_CONST_METHOD0(getWSLocation,std::string()); MOCK_CONST_METHOD0(getGeometryXML,std::string()); - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not Implemented"); - } + virtual uint64_t getNPoints() const { throw std::runtime_error("Not Implemented"); @@ -85,7 +78,6 @@ void testNoImplicitFunctionThrows() MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; pWorkspace->setName("someName"); EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1); boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); generator.setWorkspace(workspace); TSM_ASSERT_THROWS("Cannot generate the xml without the implicitFunction", generator.createXMLString(), std::runtime_error); @@ -97,7 +89,6 @@ void testNoGeometryXMLThrows() MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; pWorkspace->setName("someName"); EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("")); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1).WillRepeatedly(testing::Return("../somelocation/somefile.sqw")); boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); RebinningKnowledgeSerializer generator; generator.setImplicitFunction(impFunction); @@ -106,28 +97,11 @@ void testNoGeometryXMLThrows() TSM_ASSERT_THROWS("Cannot create the xml without geometry xml", generator.createXMLString(), std::runtime_error); } -void testNoLocationThrows() -{ - Mantid::Geometry::MDImplicitFunction_sptr impFunction(new MockImplicitFunction); - MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; - pWorkspace->setName("someName"); - EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1).WillRepeatedly(testing::Return("")); - boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); - RebinningKnowledgeSerializer generator; - generator.setImplicitFunction(impFunction); - generator.setWorkspace(workspace); - - TSM_ASSERT_THROWS("Cannot create the xml without the workspace location", generator.createXMLString(), - std::runtime_error); -} - void testNoLocationDoesNotThrow() { MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; pWorkspace->setName("someName"); EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1).WillRepeatedly(testing::Return("")); Mantid::API::IMDWorkspace_sptr workspace(pWorkspace); MockImplicitFunction* pImpFunction = new MockImplicitFunction; @@ -147,7 +121,6 @@ void testNoNameThrows() Mantid::Geometry::MDImplicitFunction_sptr impFunction(new MockImplicitFunction); MockIMDWorkspace* pWorkspace = new MockIMDWorkspace; EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1).WillRepeatedly(testing::Return("..../somelocation/somefile.sqw")); boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); RebinningKnowledgeSerializer generator; generator.setImplicitFunction(impFunction); @@ -164,7 +137,6 @@ void testCreateXMLWithWorkspace() //Uses the workspace setter. MockIMDWorkspace* pWorkspace = new MockIMDWorkspace("name"); EXPECT_CALL(*pWorkspace, getGeometryXML()).Times(1).WillRepeatedly(testing::Return("<DimensionSet/>")); - EXPECT_CALL(*pWorkspace, getWSLocation()).Times(1).WillRepeatedly(testing::Return("location")); boost::shared_ptr<const Mantid::API::IMDWorkspace> workspace(pWorkspace); Mantid::Geometry::MDImplicitFunction_sptr impFunction(pImpFunction); @@ -176,7 +148,7 @@ void testCreateXMLWithWorkspace() //Uses the workspace setter. std::string xml = generator.createXMLString(); - TSM_ASSERT_EQUALS("The xml has been created, but is incorrect.", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><MDWorkspaceLocation>location</MDWorkspaceLocation><DimensionSet/><ImplicitFunction/></MDInstruction>" ,xml) + TSM_ASSERT_EQUALS("The xml has been created, but is incorrect.", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><MDWorkspaceLocation></MDWorkspaceLocation><DimensionSet/><ImplicitFunction/></MDInstruction>" ,xml) } void testCreateXMLWithComponents() //Uses individual setters for geometry, location and name. @@ -189,12 +161,11 @@ void testCreateXMLWithComponents() //Uses individual setters for geometry, locat //Apply setters. generator.setImplicitFunction(impFunction); generator.setWorkspaceName("name"); - generator.setWorkspaceLocation("location"); generator.setGeometryXML("<DimensionSet/>"); std::string xml = generator.createXMLString(); - TSM_ASSERT_EQUALS("The xml has been created, but is incorrect.", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><MDWorkspaceLocation>location</MDWorkspaceLocation><DimensionSet/><ImplicitFunction/></MDInstruction>" ,xml) + TSM_ASSERT_EQUALS("The xml has been created, but is incorrect.", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><DimensionSet/><ImplicitFunction/></MDInstruction>" ,xml) } void testCreateXMLWithoutFunction() @@ -202,18 +173,16 @@ void testCreateXMLWithoutFunction() RebinningKnowledgeSerializer generator; //Apply setters. generator.setWorkspaceName("name"); - generator.setWorkspaceLocation("location"); generator.setGeometryXML("<DimensionSet/>"); std::string xml = generator.createXMLString(); - TSM_ASSERT_EQUALS("The xml has been created without a function incorrectly", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><MDWorkspaceLocation>location</MDWorkspaceLocation><DimensionSet/></MDInstruction>", xml); + TSM_ASSERT_EQUALS("The xml has been created without a function incorrectly", "<MDInstruction><MDWorkspaceName>name</MDWorkspaceName><DimensionSet/></MDInstruction>", xml); } void testGetGeometryXML() { RebinningKnowledgeSerializer generator; generator.setWorkspaceName("name"); - generator.setWorkspaceLocation("location"); std::string dimensionXMLString = "<DimensionSet/>"; generator.setGeometryXML(dimensionXMLString); @@ -236,7 +205,6 @@ void testHasGeometryInfoWithoutGeometry() { //Note that functions do not apply to this test set. RebinningKnowledgeSerializer withoutGeometry; - withoutGeometry.setWorkspaceLocation("-"); withoutGeometry.setWorkspaceName("-"); TSM_ASSERT_EQUALS("No Geometry provided. ::hasGeometryInfo() should return false.", false, withoutGeometry.hasGeometryInfo()); } @@ -245,24 +213,14 @@ void testHasGeometryInfoWithoutWSName() { RebinningKnowledgeSerializer withoutWSName; withoutWSName.setGeometryXML("-"); - withoutWSName.setWorkspaceLocation("-"); TSM_ASSERT_EQUALS("No WS name provided. ::hasGeometryInfo() should return false.", false, withoutWSName.hasGeometryInfo()); } -void testHasGeometryInfoWithoutWSLocation() -{ - RebinningKnowledgeSerializer withoutWSLocation; - withoutWSLocation.setGeometryXML("-"); - withoutWSLocation.setWorkspaceName("-"); - TSM_ASSERT_EQUALS("No WS location provided. ::hasGeometryInfo() should return false.", false, withoutWSLocation.hasGeometryInfo()); -} - void testHasGeometryAndWSInfo() { RebinningKnowledgeSerializer withFullGeometryAndWSInfo; withFullGeometryAndWSInfo.setGeometryXML("-"); withFullGeometryAndWSInfo.setWorkspaceName("-"); - withFullGeometryAndWSInfo.setWorkspaceLocation("-"); TSM_ASSERT_EQUALS("All geometry and ws information has been provided. ::hasGeometryInfo() should return true.", true, withFullGeometryAndWSInfo.hasGeometryInfo()); } diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h index 99334f8483b2b2a46a7bc139573a97f51b5aae8c..d2a7cb48b7179941f9e13e187cd33fb6e8a9d223 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkStructuredGridFactoryTest.h @@ -6,66 +6,11 @@ #include <cxxtest/TestSuite.h> #include "MantidVatesAPI/vtkStructuredGridFactory.h" #include "MantidVatesAPI/TimeStepToTimeStep.h" +#include "MockObjects.h" +#include "MantidMDEvents/MDHistoWorkspace.h" using namespace Mantid; - -//===================================================================================== -// Test Helpers Types -//===================================================================================== -namespace vtkStructuredGridFactoryTestHelpers -{ - ///Helper class. Concrete instance of IMDDimension. - class FakeIMDDimension: public Mantid::Geometry::IMDDimension - { - private: - std::string m_id; - const unsigned int m_nbins; - public: - FakeIMDDimension(std::string id, unsigned int nbins=10) : m_id(id), m_nbins(nbins) {} - std::string getName() const {throw std::runtime_error("Not implemented");} - std::string getUnits() const {throw std::runtime_error("Not implemented");} - std::string getDimensionId() const {return m_id;} - double getMaximum() const {return 10;} - double getMinimum() const {return 0;} - size_t getNBins() const {return m_nbins;} - std::string toXMLString() const {throw std::runtime_error("Not implemented");} - double getX(size_t) const {throw std::runtime_error("Not implemented");} - void setRange(size_t, double, double) {} - virtual ~FakeIMDDimension() - { - } - }; - - /// Mock IMDDimension. - class MockIMDWorkspace: public Mantid::API::IMDWorkspace - { - public: - - MOCK_CONST_METHOD0(id, const std::string()); - MOCK_CONST_METHOD0(getMemorySize, size_t()); - MOCK_CONST_METHOD1(getPoint,const Mantid::Geometry::SignalAggregate&(size_t index)); - MOCK_CONST_METHOD1(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment)); - MOCK_CONST_METHOD2(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment)); - MOCK_CONST_METHOD3(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment)); - MOCK_CONST_METHOD4(getCell,const Mantid::Geometry::SignalAggregate&(size_t dim1Increment, size_t dim2Increment, size_t dim3Increment, size_t dim4Increment)); - - MOCK_CONST_METHOD0(getWSLocation,std::string()); - MOCK_CONST_METHOD0(getGeometryXML,std::string()); - - MOCK_CONST_METHOD0(getNPoints, uint64_t()); - MOCK_CONST_METHOD4(getSignalAt, signal_t(size_t index1, size_t index2, size_t index3, size_t index4)); - MOCK_CONST_METHOD0(getNonIntegratedDimensions, Mantid::Geometry::VecIMDDimension_const_sptr()); - - const Mantid::Geometry::SignalAggregate& getCell(...) const - { - throw std::runtime_error("Not Implemented"); - } - - virtual ~MockIMDWorkspace() {} - }; -} - -using namespace vtkStructuredGridFactoryTestHelpers; +using namespace Mantid::MDEvents; //===================================================================================== // Functional Tests @@ -81,14 +26,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("t")); - EXPECT_CALL(*pMockWs, getSignalAt(_, _, _, _)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factoryA = @@ -112,14 +50,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getSignalAt(_, _, _, _)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("t")); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factoryA = @@ -147,14 +78,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getSignalAt(_, _, _, _)).Times(0); //Shouldn't access getSignal At - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("t")); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -166,7 +90,6 @@ public: int predictedNPoints = (10 + 1) * (10 + 1) * (10 + 1); TSM_ASSERT_EQUALS("Wrong number of points generated", predictedNPoints, product->GetNumberOfPoints()); - TSM_ASSERT("This is not a mesh-only product.", testing::Mock::VerifyAndClearExpectations(pMockWs)); product->Delete(); } @@ -176,12 +99,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("y")); - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("t")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -198,14 +116,7 @@ public: using namespace testing; TimeStepToTimeStep timeMapper; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getSignalAt(_, _, _, _)).WillRepeatedly(Return(1)); //Shouldn't access getSignal At - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - pMockWs->addDimension(new FakeIMDDimension("z")); - pMockWs->addDimension(new FakeIMDDimension("t")); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = @@ -266,7 +177,7 @@ public: class vtkStructuredGridFactoryTestPerformance : public CxxTest::TestSuite { public: - MockIMDWorkspace* pMockWs; + Mantid::API::IMDWorkspace_sptr ws_sptr; void setUp() { @@ -274,12 +185,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - //20 by 20 by 20 by 20 workspace. - pMockWs = new MockIMDWorkspace; - pMockWs->addDimension(new FakeIMDDimension("x", 100)); - pMockWs->addDimension(new FakeIMDDimension("y", 100)); - pMockWs->addDimension(new FakeIMDDimension("z", 100)); - pMockWs->addDimension(new FakeIMDDimension("t", 100)); + // 4D, 100 bins per side + ws_sptr = getFakeMDHistoWorkspace(1.0, 4, 100); } void testGenerateVTKDataSet() @@ -288,7 +195,6 @@ public: using namespace Mantid::Geometry; using namespace testing; - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); //Constructional method ensures that factory is only suitable for providing mesh information. vtkStructuredGridFactory<TimeStepToTimeStep> factory = diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h index 0c995558c77ba3718ab5966b9a3037a3da8eb839..c9ffb0853fa22471e9fe6b877c583a8aeac14a30 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingHexahedronFactoryTest.h @@ -111,15 +111,12 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(1).WillOnce(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); - //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); @@ -128,7 +125,6 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite factory.initialize(ws_sptr); - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -139,10 +135,7 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(1).WillOnce(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); @@ -150,23 +143,21 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite TSM_ASSERT_THROWS("Should have thrown an execption given that no successor was available.", factory.initialize(ws_sptr), std::runtime_error); } - void testCreateDeleagates() + void testCreateDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization using namespace Mantid::VATES; using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(2).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. + //2 dimensions on the workspace. + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, create()).Times(1); //expect it then to call create on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingHexahedronFactory factory (ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); @@ -177,7 +168,6 @@ class vtkThresholdingHexahedronFactoryTest: public CxxTest::TestSuite factory.initialize(ws_sptr); factory.create(); // should be called on successor. - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h index 154b60be4cc5a1f54c53ed412a403a35650abf3b..f61ad5cf62510c9bc237ab5b0811fdd51794f616 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingLineFactoryTest.h @@ -59,13 +59,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(1))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall between the minimum 0 and maximum 2. vtkThresholdingLineFactory inside(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 2)), "signal"); @@ -81,13 +75,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(1))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall above and outside the minimum 0 and maximum 0.5. vtkThresholdingLineFactory above(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 0.5)), "signal"); @@ -103,13 +91,7 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(1))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall below and outside the minimum 1.5 and maximum 2. vtkThresholdingLineFactory below(ThresholdRange_scptr(new UserDefinedThresholdRange(1.5, 2)), "signal"); @@ -122,30 +104,25 @@ public: void testInitializationDelegates() { - //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization + //If the workspace provided is not a 1D imdworkspace, it should call the successor's initalization using namespace Mantid::VATES; using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillOnce(Return(VecIMDDimension_const_sptr(3))); //3 dimensions on the workspace. + // 3 dimensions on the workspace + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); - //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingLineFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)), "signal"); //Successor is provided. factory.SetSuccessor(pMockFactorySuccessor); - factory.initialize(ws_sptr); - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -156,10 +133,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillOnce(Return(VecIMDDimension_const_sptr(3))); //3 dimensions on the workspace. - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + // 3 dimensions on the workspace + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingLineFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)),"signal"); @@ -167,24 +142,21 @@ public: TSM_ASSERT_THROWS("Should have thrown an execption given that no successor was available.", factory.initialize(ws_sptr), std::runtime_error); } - void testCreateDeleagates() + void testCreateDelegates() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization using namespace Mantid::VATES; using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(2).WillRepeatedly(Return(VecIMDDimension_const_sptr(3))); //3 dimensions on the workspace. + // 3 dimensions on the workspace + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 3); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, create()).Times(1); //expect it then to call create on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); - //Constructional method ensures that factory is only suitable for providing mesh information. vtkThresholdingLineFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 10000)),"signal"); @@ -194,7 +166,6 @@ public: factory.initialize(ws_sptr); factory.create(); // should be called on successor. - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -223,12 +194,7 @@ public: using namespace testing; //1D Workspace with 2000 points - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->addDimension(new FakeIMDDimension("x", 2000)); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(1))); - - m_ws_sptr = Mantid::API::IMDWorkspace_sptr(pMockWs); + m_ws_sptr = getFakeMDHistoWorkspace(1.0, 1, 2000); } void testGenerateVTKDataSet() diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h index e8648d36a1d3e9c252904e00f4ed662fc69600c1..a48e58a45bae4efd499e9652d975eb4463518e0b 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingQuadFactoryTest.h @@ -62,14 +62,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_,_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + // WS with 2 dimensions + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall between the minimum 0 and maximum 2. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 2); @@ -86,14 +80,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_,_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + // WS with 2 dimensions + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall above and outside the minimum 0 and maximum 0.5. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 0.5); @@ -111,14 +99,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - pMockWs->addDimension(new FakeIMDDimension("x")); - pMockWs->addDimension(new FakeIMDDimension("y")); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_,_)).Times(AtLeast(1)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + // WS with 2 dimensions + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); //Thresholds have been set such that the signal values (hard-coded to 1, see above) will fall below and outside the minimum 1.5 and maximum 2. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(1.5, 2); @@ -139,15 +121,13 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillOnce(Return(VecIMDDimension_const_sptr(1)));; //1 dimensions on the workspace. + // WS with 1 dimension + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); - //Constructional method ensures that factory is only suitable for providing mesh information. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 1); vtkThresholdingQuadFactory factory(ThresholdRange_scptr(pRange), "signal"); @@ -157,7 +137,6 @@ public: factory.initialize(ws_sptr); - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -168,10 +147,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillOnce(Return(VecIMDDimension_const_sptr(1))); //1 dimensions on the workspace. - - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); + // WS with 1 dimension + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); //Constructional method ensures that factory is only suitable for providing mesh information. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 1); @@ -180,24 +157,21 @@ public: TSM_ASSERT_THROWS("Should have thrown an execption given that no successor was available.", factory.initialize(ws_sptr), std::runtime_error); } - void testCreateDeleagates() + void testCreateDelegates() { //If the workspace provided is not a 2D imdworkspace, it should call the successor's initalization using namespace Mantid::VATES; using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(2).WillRepeatedly(Return(VecIMDDimension_const_sptr(1))); //1 dimensions on the workspace. + // WS with 1 dimension + Mantid::API::IMDWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 1); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, create()).Times(1); //expect it then to call create on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); - //Constructional method ensures that factory is only suitable for providing mesh information. UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 1); vtkThresholdingQuadFactory factory(ThresholdRange_scptr(pRange), "signal"); @@ -208,7 +182,6 @@ public: factory.initialize(ws_sptr); factory.create(); // should be called on successor. - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -238,13 +211,8 @@ public: using namespace Mantid::Geometry; using namespace testing; - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->addDimension(new FakeIMDDimension("x", 100)); - pMockWs->addDimension(new FakeIMDDimension("y", 100)); - EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_,_)).WillRepeatedly(Return(1)); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); - - m_ws_sptr = Mantid::API::IMDWorkspace_sptr(pMockWs); + // WS with 2 dimension, 100x100 + m_ws_sptr = getFakeMDHistoWorkspace(1.0, 2, 100); m_ws_sptr->setTransformFromOriginal(new NullCoordTransform); } diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h index 0073944e5fd7e7a915218ca311e0863e6ad5fd78..9fcb41884e2451d9571dd1089aec9f1c61e1569d 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkThresholdingUnstructuredGridFactoryTest.h @@ -9,9 +9,14 @@ #include "MantidVatesAPI/UserDefinedThresholdRange.h" #include "MockObjects.h" #include "MantidMDEvents/MDHistoWorkspace.h" +#include "MantidAPI/IMDWorkspace.h" using namespace Mantid; using namespace Mantid::MDEvents; +using namespace Mantid::VATES; +using namespace Mantid::API; +using namespace Mantid::Geometry; +using namespace testing; //===================================================================================== // Functional Tests @@ -23,25 +28,9 @@ public: void testThresholds() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // Workspace with value 1.0 everywhere MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); ws_sptr->setTransformFromOriginal(new NullCoordTransform); -// MockIMDWorkspace* pMockWs = new MockIMDWorkspace; -// EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_, _, _, _)).Times(AtLeast(1)).WillRepeatedly(Return(1)); -// EXPECT_CALL(*pMockWs, getXDimension()).Times(9).WillRepeatedly(Return(IMDDimension_const_sptr( -// new FakeIMDDimension("x")))); -// EXPECT_CALL(*pMockWs, getYDimension()).Times(9).WillRepeatedly(Return(IMDDimension_const_sptr( -// new FakeIMDDimension("y")))); -// EXPECT_CALL(*pMockWs, getZDimension()).Times(9).WillRepeatedly(Return(IMDDimension_const_sptr( -// new FakeIMDDimension("z")))); -// EXPECT_CALL(*pMockWs, getTDimension()).Times(AtLeast(1)).WillRepeatedly(Return(IMDDimension_const_sptr( -// new FakeIMDDimension("t")))); -// EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(6).WillRepeatedly(Return(VecIMDDimension_const_sptr(4))); -// Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); //Set up so that only cells with signal values == 1 should not be filtered out by thresholding. @@ -64,10 +53,6 @@ public: void testSignalAspects() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - // Workspace with value 1.0 everywhere MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 4); ws_sptr->setTransformFromOriginal(new NullCoordTransform); @@ -89,8 +74,6 @@ public: void testIsValidThrowsWhenNoWorkspace() { - using namespace Mantid::VATES; - using namespace Mantid::API; IMDWorkspace* nullWorkspace = NULL; Mantid::API::IMDWorkspace_sptr ws_sptr(nullWorkspace); @@ -102,7 +85,6 @@ public: void testCreateMeshOnlyThrows() { - using namespace Mantid::VATES; UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); vtkThresholdingUnstructuredGridFactory<TimeStepToTimeStep> factory(ThresholdRange_scptr(pRange), "signal", 1); TS_ASSERT_THROWS(factory.createMeshOnly() , std::runtime_error); @@ -110,7 +92,6 @@ public: void testCreateScalarArrayThrows() { - using namespace Mantid::VATES; UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); vtkThresholdingUnstructuredGridFactory<TimeStepToTimeStep> factory(ThresholdRange_scptr(pRange), "signal", 1); TS_ASSERT_THROWS(factory.createScalarArray() , std::runtime_error); @@ -118,7 +99,6 @@ public: void testCreateWithoutInitializeThrows() { - using namespace Mantid::VATES; UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); vtkThresholdingUnstructuredGridFactory<TimeStepToTimeStep> factory(ThresholdRange_scptr(pRange), "signal", 1); TS_ASSERT_THROWS(factory.create(), std::runtime_error); @@ -127,18 +107,13 @@ public: void testInitializationDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(1).WillOnce(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. + // 2D workspace + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); //Constructional method ensures that factory is only suitable for providing mesh information. @@ -150,21 +125,15 @@ public: factory.initialize(ws_sptr); - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } void testInitializationDelegatesThrows() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization. If there is no successor an exception should be thrown. - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(1).WillOnce(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. + // 2D workspace + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); //Constructional method ensures that factory is only suitable for providing mesh information. @@ -174,23 +143,17 @@ public: TSM_ASSERT_THROWS("Should have thrown an execption given that no successor was available.", factory.initialize(ws_sptr), std::runtime_error); } - void testCreateDeleagates() + void testCreateDelegates() { //If the workspace provided is not a 4D imdworkspace, it should call the successor's initalization - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - - MockIMDWorkspace* pMockWs = new MockIMDWorkspace; - pMockWs->setTransformFromOriginal(new NullCoordTransform); - EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).Times(2).WillRepeatedly(Return(VecIMDDimension_const_sptr(2))); //2 dimensions on the workspace. + // 2D workspace + MDHistoWorkspace_sptr ws_sptr = getFakeMDHistoWorkspace(1.0, 2); MockvtkDataSetFactory* pMockFactorySuccessor = new MockvtkDataSetFactory; EXPECT_CALL(*pMockFactorySuccessor, initialize(_)).Times(1); //expect it then to call initialize on the successor. EXPECT_CALL(*pMockFactorySuccessor, create()).Times(1); //expect it then to call create on the successor. EXPECT_CALL(*pMockFactorySuccessor, getFactoryTypeName()).WillOnce(testing::Return("TypeA")); - Mantid::API::IMDWorkspace_sptr ws_sptr(pMockWs); UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100); //Constructional method ensures that factory is only suitable for providing mesh information. @@ -203,7 +166,6 @@ public: factory.initialize(ws_sptr); factory.create(); // should be called on successor. - TSM_ASSERT("Workspace not used as expected", Mock::VerifyAndClearExpectations(pMockWs)); TSM_ASSERT("successor factory not used as expected.", Mock::VerifyAndClearExpectations(pMockFactorySuccessor)); } @@ -233,27 +195,13 @@ public: void setUp() { - using namespace Mantid::VATES; - using namespace Mantid::Geometry; - using namespace testing; - //Create a 4D workspace 50 ^ 4 m_ws_sptr = getFakeMDHistoWorkspace(1.0, 4, 50); m_ws_sptr->setTransformFromOriginal(new NullCoordTransform); - -// MockIMDWorkspace* pMockWs = new MockIMDWorkspace; -// EXPECT_CALL(*pMockWs, getSignalNormalizedAt(_, _, _, _)).Times(AtLeast(1)).WillRepeatedly(Return(1)); -// EXPECT_CALL(*pMockWs, getXDimension()).WillRepeatedly(Return(IMDDimension_const_sptr(new FakeIMDDimension("x", 20)))); -// EXPECT_CALL(*pMockWs, getYDimension()).WillRepeatedly(Return(IMDDimension_const_sptr(new FakeIMDDimension("y", 20)))); -// EXPECT_CALL(*pMockWs, getZDimension()).WillRepeatedly(Return(IMDDimension_const_sptr(new FakeIMDDimension("z", 20)))); -// EXPECT_CALL(*pMockWs, getTDimension()).WillRepeatedly(Return(IMDDimension_const_sptr(new FakeIMDDimension("t", 20)))); -// EXPECT_CALL(*pMockWs, getNonIntegratedDimensions()).WillRepeatedly(Return(VecIMDDimension_const_sptr(4))); -// m_ws_sptr = Mantid::API::IMDWorkspace_sptr(pMockWs); } void testGenerateVTKDataSet() { - using namespace Mantid::VATES; UserDefinedThresholdRange* pRange = new UserDefinedThresholdRange(0, 100000); vtkThresholdingUnstructuredGridFactory<TimeStepToTimeStep> factory(ThresholdRange_scptr(pRange), "signal", 0); factory.initialize(m_ws_sptr);