Example #1
0
  /** Set the workspace
   * @param ws :: A shared pointer to a workspace.
   */
  void IFunctionMD::setWorkspace(boost::shared_ptr<const Workspace> ws)
  {
    try
    {
      IMDWorkspace_const_sptr workspace = boost::dynamic_pointer_cast<const IMDWorkspace>(ws);
      if (!workspace)
      {
        throw std::invalid_argument("Workspace has a wrong type (not a IMDWorkspace)");
      }

      if (m_dimensionIndexMap.empty())
      {
        useAllDimensions(workspace);
      }

      m_dimensions.resize(m_dimensionIndexMap.size());
      std::map<std::string,size_t>::const_iterator it = m_dimensionIndexMap.begin();
      std::map<std::string,size_t>::const_iterator end = m_dimensionIndexMap.end();
      for(; it != end; ++it)
      {
        boost::shared_ptr<const Mantid::Geometry::IMDDimension> dim = workspace->getDimensionWithId(it->first);
        if (!dim)
        {
          throw std::invalid_argument("Dimension "+it->first+" dos not exist in workspace "+ws->getName());
        }
        m_dimensions[it->second] = dim;
      }

    }
    catch(std::exception&)
    {
      throw;
    }

  }