diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IMDHistoWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/IMDHistoWorkspace.h index 5da50570e195a3d5e866a35b85f2470a02a5ecc6..e379c3be288307026625200daefa899f5f2ebc28 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IMDHistoWorkspace.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IMDHistoWorkspace.h @@ -79,7 +79,8 @@ namespace API virtual void setCoordinateSystem(const Mantid::API::SpecialCoordinateSystem coordinateSystem) = 0; - boost::shared_ptr<IMDHistoWorkspace> cloneShape() const = 0; + virtual boost::shared_ptr<IMDHistoWorkspace> clone() const = 0; + protected: virtual const std::string toString() const; }; diff --git a/Code/Mantid/Framework/Crystal/src/ConnectedComponentLabeling.cpp b/Code/Mantid/Framework/Crystal/src/ConnectedComponentLabeling.cpp index abca8d2386923e5b2b21b74778324b904df0901d..b039e21d3e9734a68728d1d4066de921cff2990d 100644 --- a/Code/Mantid/Framework/Crystal/src/ConnectedComponentLabeling.cpp +++ b/Code/Mantid/Framework/Crystal/src/ConnectedComponentLabeling.cpp @@ -1,7 +1,6 @@ #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/Logger.h" #include "MantidKernel/V3D.h" -#include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/IMDIterator.h" @@ -74,17 +73,8 @@ namespace Mantid */ boost::shared_ptr<Mantid::API::IMDHistoWorkspace> cloneInputWorkspace(IMDHistoWorkspace_sptr& inWS) { - auto alg = AlgorithmManager::Instance().createUnmanaged("CloneWorkspace"); - alg->initialize(); - alg->setChild(true); - alg->setProperty("InputWorkspace", inWS); - alg->setPropertyValue("OutputWorkspace", "out_ws"); - alg->execute(); - Mantid::API::IMDHistoWorkspace_sptr outWS; - { - Mantid::API::Workspace_sptr temp = alg->getProperty("OutputWorkspace"); - outWS = boost::dynamic_pointer_cast<IMDHistoWorkspace>(temp); - } + IMDHistoWorkspace_sptr outWS = inWS->clone(); + // Initialize to zero. PARALLEL_FOR_NO_WSP_CHECK() for(int i = 0; i < static_cast<int>(outWS->getNPoints()); ++i) @@ -421,13 +411,11 @@ namespace Mantid m_logger.debug("Remove duplicates"); m_logger.debug() << incompleteClusterVec.size() << " clusters to reconstruct" << std::endl; // Now combine clusters and add the resolved clusters to the clusterMap. - SetIds usedOwningClusterIds; for(size_t i = 0; i < incompleteClusterVec.size(); ++i) { const size_t label = incompleteClusterVec[i]->getLabel(); - if(usedOwningClusterIds.find(label) == usedOwningClusterIds.end()) + if(does_contain_key(clusterMap, label)) { - usedOwningClusterIds.insert(label); clusterMap.insert(std::make_pair(label, incompleteClusterVec[i])); } else @@ -500,7 +488,9 @@ namespace Mantid ClusterMap clusters = calculateDisjointTree(ws, strategy,progress); // Create the output workspace from the input workspace + m_logger.debug("Start cloning input workspace"); IMDHistoWorkspace_sptr outWS = cloneInputWorkspace(ws); + m_logger.debug("Finish cloning input workspace"); // Get the keys (label ids) first in order to do the next stage in parallel. VecIndexes keys; diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h index d0cd3edb8679160e7ddc3a0b19f96f87ceba0d8c..31c99fd9567e4f7b00fcb2e72b7f46059c3d48a1 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h @@ -401,8 +401,8 @@ namespace MDEvents /// Get the size of an element in the HistoWorkspace. static size_t sizeOfElement(); - /// Virtual constructor. - boost::shared_ptr<IMDHistoWorkspace> cloneShape() const; + /// Virutal constructor. + boost::shared_ptr<IMDHistoWorkspace> clone() const; private: diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp index 669866466d960a47b8034087c6932a127831dae4..28aee6a966d476da3f126cbb995daa32f662e6d6 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp @@ -11,6 +11,7 @@ #include "MantidAPI/IMDWorkspace.h" #include "MantidAPI/IMDIterator.h" #include <boost/scoped_array.hpp> +#include <boost/make_shared.hpp> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -1308,9 +1309,13 @@ namespace MDEvents return (3 * sizeof(signal_t) ) + sizeof(bool); } - boost::shared_ptr<IMDHistoWorkspace> MDHistoWorkspace::clone() const; + /** + * Clone the workspace. + * @return Deep copy of existing workspace. + */ + boost::shared_ptr<IMDHistoWorkspace> MDHistoWorkspace::clone() const { - return boost::make_ + return boost::shared_ptr<IMDHistoWorkspace>(new MDHistoWorkspace(*this)); } } // namespace Mantid