diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Projection.h b/Code/Mantid/Framework/API/inc/MantidAPI/Projection.h index 75ae9f2b755f3b51dec6e8a546277b58bec7a89c..0a5f5c3eaf339b2ff068f7ea24b3ad6cf315c3cd 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/Projection.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/Projection.h @@ -55,7 +55,7 @@ public: /// Three dimensional value constructor Projection(const V3D &u, const V3D &v, const V3D &w); /// Construct from an ITableWorkspace - Projection(ITableWorkspace_const_sptr ws); + Projection(const ITableWorkspace &ws); /// Copy constructor Projection(const Projection &other); /// Assignment operator diff --git a/Code/Mantid/Framework/API/src/Projection.cpp b/Code/Mantid/Framework/API/src/Projection.cpp index ca8067e85d21f62a00cf63e4295e888e2b875ad7..8212fdf37242cbc2036cc777b76dbe62cba42cc0 100644 --- a/Code/Mantid/Framework/API/src/Projection.cpp +++ b/Code/Mantid/Framework/API/src/Projection.cpp @@ -40,24 +40,20 @@ Projection::Projection(const V3D &u, const V3D &v, const V3D &w) { } } -Projection::Projection(ITableWorkspace_const_sptr ws) { - if (!ws) - throw std::runtime_error( - "Null ITableWorkspace given to Projection constructor"); - - if (ws->columnCount() != 4) +Projection::Projection(const ITableWorkspace &ws) { + if (ws.columnCount() != 4) throw std::runtime_error( "4 columns must be provided to create a projection"); - const size_t numRows = ws->rowCount(); + const size_t numRows = ws.rowCount(); if (numRows != 3) throw std::runtime_error("3 rows must be provided to create a projection"); for (size_t i = 0; i < numRows; i++) { - const std::string name = ws->getColumn("name")->cell<std::string>(i); - const std::string valueStr = ws->getColumn("value")->cell<std::string>(i); - const double offset = ws->getColumn("offset")->cell<double>(i); - const std::string unitStr = ws->getColumn("type")->cell<std::string>(i); + const std::string name = ws.getColumn("name")->cell<std::string>(i); + const std::string valueStr = ws.getColumn("value")->cell<std::string>(i); + const double offset = ws.getColumn("offset")->cell<double>(i); + const std::string unitStr = ws.getColumn("type")->cell<std::string>(i); //Check the name size_t index; diff --git a/Code/Mantid/Framework/API/test/ProjectionTest.h b/Code/Mantid/Framework/API/test/ProjectionTest.h index efdf874f6d3d39d2352fedc203e6f86bd164057e..28245715cad5a2741684467de82fa6858accfd98 100644 --- a/Code/Mantid/Framework/API/test/ProjectionTest.h +++ b/Code/Mantid/Framework/API/test/ProjectionTest.h @@ -138,22 +138,10 @@ public: TS_ASSERT_EQUALS(p.W(), w); } - void test_construct_null_workspace() { - try { - auto p = boost::make_shared<Projection>(ITableWorkspace_sptr()); - TS_FAIL("Projection constructor should have thrown exception"); - } catch(std::runtime_error& e) { - TS_ASSERT_EQUALS(e.what(), - std::string("Null ITableWorkspace given to Projection constructor")) - } catch(...) { - TS_FAIL("Projection constructor threw unexpected exception"); - } - } - void test_construct_bad_workspace_columns() { - auto proj = ITableWorkspace_sptr(new DimensionedTable(0,0)); + const DimensionedTable table(0,0); try { - auto p = boost::make_shared<Projection>(proj); + auto p = boost::make_shared<Projection>(table); TS_FAIL("Projection constructor should have thrown exception"); } catch(std::runtime_error& e) { TS_ASSERT_EQUALS(e.what(), @@ -164,9 +152,9 @@ public: } void test_construct_bad_workspace_no_rows() { - auto proj = ITableWorkspace_sptr(new DimensionedTable(4,0)); + const DimensionedTable table(4,0); try { - auto p = boost::make_shared<Projection>(proj); + auto p = boost::make_shared<Projection>(table); TS_FAIL("Projection constructor should have thrown exception"); } catch(std::runtime_error& e) { TS_ASSERT_EQUALS(e.what(), @@ -177,9 +165,9 @@ public: } void test_construct_bad_workspace_too_many_rows() { - auto proj = ITableWorkspace_sptr(new DimensionedTable(4,4)); + const DimensionedTable table(4,4); try { - auto p = boost::make_shared<Projection>(proj); + auto p = boost::make_shared<Projection>(table); TS_FAIL("Projection constructor should have thrown exception"); } catch(std::runtime_error& e) { TS_ASSERT_EQUALS(e.what(), @@ -190,9 +178,9 @@ public: } void test_construct_good_workspace() { - auto proj = ITableWorkspace_sptr(new GoodTable()); + const GoodTable table; Projection_sptr p; - TS_ASSERT_THROWS_NOTHING(p = boost::make_shared<Projection>(proj)); + TS_ASSERT_THROWS_NOTHING(p = boost::make_shared<Projection>(table)); TS_ASSERT_EQUALS(p->U(), V3D(1, 1, 0)); TS_ASSERT_EQUALS(p->V(), V3D(-1, 1, 0)); diff --git a/Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp index b7b6fac651591e1ff5d276e4240bcc6078ada901..3acef97437ba3a95d5f8d131bc388df7a2fa726c 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp @@ -243,7 +243,7 @@ void CutMD::exec() { // Check Projection format Projection projection; if (projectionWS) - projection = Projection(projectionWS); + projection = Projection(*projectionWS); // Check PBin properties for (size_t i = 0; i < 5; ++i) {