Skip to content
Snippets Groups Projects
CreateSampleShape.cpp 1.32 KiB
Newer Older
//--------------------------------
// Includes
//--------------------------------
#include "MantidDataHandling/CreateSampleShape.h"
#include "MantidGeometry/ShapeFactory.h"
#include "MantidAPI/MatrixWorkspace.h"

namespace Mantid
{
namespace DataHandling
{
  // Register the algorithm into the AlgorithmFactory

// Get a reference to the logger. It is used to print out information, warning and error messages
Mantid::Kernel::Logger& CreateSampleShape::g_log = Mantid::Kernel::Logger::get("CreateSampleShape");

/**
 * Initialize the algorithm
 */
void CreateSampleShape::init()
{
  using namespace Mantid::Kernel;
  declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","",Direction::Input));
  declareProperty("ShapeXML","",new MandatoryValidator<std::string>());
}

/**
 * Execute the algorithm
 */
void CreateSampleShape::exec()
{  
  // Get the input workspace
  const MatrixWorkspace_sptr workspace = getProperty("InputWorkspace");
  // Get the XML definition
  std::string shapeXML = getProperty("ShapeXML");
  Geometry::ShapeFactory sFactory;
  boost::shared_ptr<Geometry::Object> shape_sptr = sFactory.createShape(shapeXML);

  workspace->getSample()->setGeometry(shape_sptr);