Newer
Older
Gigg, Martyn Anthony
committed
//--------------------------------
// Includes
//--------------------------------
#include "MantidDataHandling/CreateSampleShape.h"
#include "MantidGeometry/ShapeFactory.h"
#include "MantidAPI/MatrixWorkspace.h"
Gigg, Martyn Anthony
committed
#include "MantidAPI/Sample.h"
Gigg, Martyn Anthony
committed
namespace Mantid
{
namespace DataHandling
{
// Register the algorithm into the AlgorithmFactory
Gigg, Martyn Anthony
committed
DECLARE_ALGORITHM(CreateSampleShape)
Gigg, Martyn Anthony
committed
}
}
using namespace Mantid::DataHandling;
Gigg, Martyn Anthony
committed
using namespace Mantid::API;
Gigg, Martyn Anthony
committed
// 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;
Gigg, Martyn Anthony
committed
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","",Direction::Input));
Gigg, Martyn Anthony
committed
declareProperty("ShapeXML","",new MandatoryValidator<std::string>());
}
/**
* Execute the algorithm
*/
void CreateSampleShape::exec()
Gigg, Martyn Anthony
committed
{
// 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);