Commit f2dadc47 authored by Federico Montesino Pouzols's avatar Federico Montesino Pouzols
Browse files

Merge remote-tracking branch 'origin/master' into 15246_reduce_recursive_includes_in_Algorithm.h

Fixed conflicts with last few days changes in master, especially with InstrumentWidget files that
have been moved and revamped, re #15246.
parents ad814ae0 7888407a
......@@ -90,7 +90,7 @@ void LoadRawBin0::exec() {
m_total_specs = calculateWorkspaceSize();
// no real X values for bin 0,so initialize this to zero
boost::shared_ptr<MantidVec> channelsVec(new MantidVec(1, 0));
auto channelsVec = boost::make_shared<MantidVec>(1, 0);
m_timeChannelsVec.push_back(channelsVec);
double histTotal = static_cast<double>(m_total_specs * m_numberOfPeriods);
......
......@@ -112,7 +112,7 @@ void LoadSPE::exec() {
if (comment[4] == 'Q' || comment[4] == 'q') {
phiAxis->unit() = UnitFactory::Instance().create("MomentumTransfer");
} else {
phiAxis->unit() = boost::shared_ptr<Unit>(new Units::Phi);
phiAxis->unit() = boost::make_shared<Units::Phi>();
}
// Read in phi grid
......
......@@ -96,7 +96,7 @@ private:
Mantid::API::IAlgorithm_sptr
createAlgorithm(const std::string &workspace = "",
const std::string &model = "") {
auto alg = boost::shared_ptr<CreateChopperModel>(new CreateChopperModel);
auto alg = boost::make_shared<CreateChopperModel>();
alg->setRethrows(true);
alg->initialize();
......
......@@ -8,6 +8,7 @@
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidAPI/FrameworkManager.h"
#include <boost/make_shared.hpp>
using namespace Mantid::Geometry;
using Mantid::DataObjects::Workspace2D_sptr;
......
......@@ -159,7 +159,7 @@ public:
// Check running algorithm for same XML file leads to same instrument object
// being attached
boost::shared_ptr<Instrument> instr(new Instrument());
boost::shared_ptr<Instrument> instr = boost::make_shared<Instrument>();
output->setInstrument(instr);
TS_ASSERT_EQUALS(output->getInstrument()->baseInstrument(), instr);
LoadInstrument loadAgain;
......
......@@ -34,7 +34,7 @@ public:
// The instrument
Instrument_sptr instr = boost::make_shared<Instrument>();
instr->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Left, "")));
boost::make_shared<ReferenceFrame>(Y, Z, Left, ""));
// The source
ObjComponent *source = new ObjComponent("source");
......@@ -73,7 +73,7 @@ public:
// The instrument
Instrument_sptr instr = boost::make_shared<Instrument>();
instr->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Left, "")));
boost::make_shared<ReferenceFrame>(Y, Z, Left, ""));
// The source
ObjComponent *source = new ObjComponent("source");
......@@ -112,7 +112,7 @@ public:
// The instrument
Instrument_sptr instr = boost::make_shared<Instrument>();
instr->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Right, "")));
boost::make_shared<ReferenceFrame>(Y, Z, Right, ""));
// The source
ObjComponent *source = new ObjComponent("source");
......@@ -151,7 +151,7 @@ public:
// The instrument
Instrument_sptr instr = boost::make_shared<Instrument>();
instr->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Right, "")));
boost::make_shared<ReferenceFrame>(Y, Z, Right, ""));
// The source
ObjComponent *source = new ObjComponent("source");
......
......@@ -68,7 +68,8 @@ public:
// checks that this is done ok
void testParsing() {
IComponent *comp(NULL);
boost::shared_ptr<Interpolation> interpolation(new Interpolation);
boost::shared_ptr<Interpolation> interpolation =
boost::make_shared<Interpolation>();
std::vector<std::string> constraint;
std::string penaltyFactor;
std::string fitFunc;
......
......@@ -502,7 +502,7 @@ TMDE(void MDGridBox)::getBoxes(std::vector<API::IMDNode *> &outBoxes,
for (size_t p = 0; p < numPlanes; p++) {
// Save whether this vertex is contained by this plane
vertexContained[p * numVertices + linearVertexIndex] =
function->getPlane(p).isPointBounded(vertexCoord);
function->getPlane(p).isPointInside(vertexCoord);
}
}
......
......@@ -170,9 +170,8 @@ public:
double angle = 0.1;
// Build the basis vectors, a 0.1 rad rotation along +Z
std::vector<VMD> bases;
bases.push_back(VMD(cos(angle), sin(angle), 0.0));
bases.push_back(VMD(-sin(angle), cos(angle), 0.0));
std::vector<VMD> bases{{cos(angle), sin(angle), 0.0},
{-sin(angle), cos(angle), 0.0}};
// Scaling is 1.0
VMD scale(1.0, 1.0);
// Build it
......@@ -199,7 +198,7 @@ public:
// Checks for failure to build
// //-----------------------------------------------------------------------------------------------
bases.push_back(VMD(1, 2, 3));
bases.emplace_back(1, 2, 3);
TSM_ASSERT_THROWS_ANYTHING("Too many bases throws",
ct.buildOrthogonal(origin, bases, scale));
bases.resize(2);
......@@ -220,9 +219,8 @@ public:
double angle = 0.1;
// Build the basis vectors, a 0.1 rad rotation along +Z
std::vector<VMD> bases;
bases.push_back(VMD(cos(angle), sin(angle), 0.0));
bases.push_back(VMD(-sin(angle), cos(angle), 0.0));
std::vector<VMD> bases{{cos(angle), sin(angle), 0.0},
{-sin(angle), cos(angle), 0.0}};
// Scaling
VMD scale(2.0, 3.0);
// Build it
......@@ -328,16 +326,14 @@ public:
void test_combineTransformations_affine_affine() {
CoordTransformAffine ct1(2, 2);
double angle = 0.1;
std::vector<VMD> bases1;
bases1.push_back(VMD(cos(angle), sin(angle)));
bases1.push_back(VMD(-sin(angle), cos(angle)));
std::vector<VMD> bases1{{cos(angle), sin(angle)},
{-sin(angle), cos(angle)}};
ct1.buildOrthogonal(VMD(3.0, 4.0), bases1, VMD(5.5, -6.7));
CoordTransformAffine ct2(2, 2);
angle = +0.34;
std::vector<VMD> bases2;
bases2.push_back(VMD(cos(angle), sin(angle)));
bases2.push_back(VMD(-sin(angle), cos(angle)));
std::vector<VMD> bases2{{cos(angle), sin(angle)},
{-sin(angle), cos(angle)}};
ct2.buildOrthogonal(VMD(8.0, -9.0), bases2, VMD(0.34, 12.5));
// And test
do_test_combined(&ct1, &ct2);
......@@ -348,9 +344,8 @@ public:
void test_combineTransformations_affine_aligned() {
CoordTransformAffine ct1(2, 2);
double angle = 0.1;
std::vector<VMD> bases1;
bases1.push_back(VMD(cos(angle), sin(angle)));
bases1.push_back(VMD(-sin(angle), cos(angle)));
std::vector<VMD> bases1{{cos(angle), sin(angle)},
{-sin(angle), cos(angle)}};
ct1.buildOrthogonal(VMD(3.0, 4.0), bases1, VMD(5.5, -6.7));
size_t dimensionToBinFrom[2] = {1, 0};
......
......@@ -66,10 +66,7 @@ public:
void test_AssignmentOperator() {
// Modify EventList such that is does not contain default values.
el.setSpectrumNo(42);
MantidVec x;
x.push_back(0.1);
x.push_back(0.2);
x.push_back(0.3);
MantidVec x{0.1, 0.2, 0.3};
el.setX(x);
el.setDx(x);
......@@ -89,10 +86,7 @@ public:
//==================================================================================
void test_PlusOperator() {
vector<TofEvent> mylist;
mylist.push_back(TofEvent(45, 67));
mylist.push_back(TofEvent(89, 12));
mylist.push_back(TofEvent(34, 56));
vector<TofEvent> mylist{{45, 67}, {89, 12}, {34, 56}};
el += mylist;
vector<TofEvent> rel = el.getEvents();
TS_ASSERT_EQUALS(rel.size(), 6);
......@@ -120,12 +114,8 @@ public:
}
template <class T>
void do_test_memory_handling(EventList &el2,
typename std::vector<T> &events) {
typename std::vector<T> mylist;
mylist.push_back(T(45));
mylist.push_back(T(89));
mylist.push_back(T(34));
void do_test_memory_handling(EventList &el2, std::vector<T> &events) {
std::vector<T> mylist{{45}, {89}, {34}};
el2 += mylist;
TS_ASSERT_EQUALS(events.size(), 3);
TS_ASSERT_EQUALS(events.capacity(), 3);
......@@ -1731,18 +1721,10 @@ public:
outputs.emplace(-1, new EventList());
// Generate time splitters
std::vector<int64_t> vec_splitTimes;
std::vector<int> vec_splitGroup;
// Start only at 100
for (int i = 1; i <= 10; i++) {
vec_splitTimes.push_back(i * 1000000);
}
vec_splitGroup.assign(vec_splitTimes.size(), -1);
vec_splitGroup[1] = 2;
vec_splitGroup[3] = 4;
vec_splitGroup[5] = 6;
vec_splitGroup[7] = 8;
std::vector<int64_t> vec_splitTimes{1000000, 2000000, 3000000, 4000000,
5000000, 6000000, 7000000, 8000000,
9000000, 10000000};
std::vector<int> vec_splitGroup{-1, 2, -1, 4, -1, 6, -1, 8, -1, -1};
for (size_t i = 0; i < vec_splitTimes.size() - 1; ++i) {
std::cout << "F " << vec_splitTimes[i] << ", " << vec_splitTimes[i + 1]
......
......@@ -796,7 +796,7 @@ public:
// Vector with 10 bins, 10 wide
MantidVec X;
for (size_t j = 0; j < 11; j++)
X.push_back(double(j) * 10.0);
X.push_back(static_cast<double>(j) * 10.0);
ew1->setX(i, X);
// Now it should be 20 in that spot
......
......@@ -40,8 +40,7 @@ public:
}
void test_box_factory() {
BoxController_sptr bc =
boost::shared_ptr<BoxController>(new BoxController(4));
BoxController_sptr bc = boost::make_shared<BoxController>(4);
IMDNode *Box = MDEventFactory::createBox(
4, MDEventFactory::BoxType::MDBoxWithLean, bc);
......
......@@ -22,7 +22,8 @@ class MDFramesToSpecialCoordinateSystemTest : public CxxTest::TestSuite {
public:
void test_that_throws_for_non_md_workspace() {
// Arrange
const boost::shared_ptr<MatrixWorkspace> ws(new WorkspaceTester());
const boost::shared_ptr<MatrixWorkspace> ws =
boost::make_shared<WorkspaceTester>();
Mantid::DataObjects::MDFramesToSpecialCoordinateSystem converter;
// Act + Assert
TSM_ASSERT_THROWS(
......
......@@ -1482,7 +1482,7 @@ public:
boxes.push_back(a);
boxes.push_back(b);
auto bc = boost::shared_ptr<BoxController>(new BoxController(1));
auto bc = boost::make_shared<BoxController>(1);
std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(1);
MDGridBox<MDLeanEvent<1>, 1> g(bc, 0, extentsVector);
g.setChildren(boxes, 0, 2);
......@@ -1507,7 +1507,7 @@ public:
boxes.push_back(a);
boxes.push_back(b);
auto bc = boost::shared_ptr<BoxController>(new BoxController(1));
auto bc = boost::make_shared<BoxController>(1);
std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(1);
MDGridBox<MDLeanEvent<1>, 1> g(bc, 0, extentsVector);
g.setChildren(boxes, 0, 2);
......@@ -1532,7 +1532,7 @@ public:
boxes.push_back(a);
boxes.push_back(b);
auto bc = boost::shared_ptr<BoxController>(new BoxController(1));
auto bc = boost::make_shared<BoxController>(1);
std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(1);
MDGridBox<MDLeanEvent<1>, 1> g(bc, 0, extentsVector);
......@@ -1556,7 +1556,7 @@ public:
boxes.push_back(a);
boxes.push_back(b);
auto bc = boost::shared_ptr<BoxController>(new BoxController(1));
auto bc = boost::make_shared<BoxController>(1);
std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(1);
MDGridBox<MDLeanEvent<1>, 1> griddedBox(bc, 0, extentsVector);
......@@ -1580,7 +1580,7 @@ public:
boxes.push_back(a);
boxes.push_back(b);
auto bc = boost::shared_ptr<BoxController>(new BoxController(1));
auto bc = boost::make_shared<BoxController>(1);
std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(1);
MDGridBox<MDLeanEvent<1>, 1> griddedBox(bc, 0, extentsVector);
......
......@@ -92,7 +92,8 @@ public:
void testSetX() {
double aNumber = 5.3;
boost::shared_ptr<MantidVec> v(new MantidVec(nbins, aNumber));
boost::shared_ptr<MantidVec> v =
boost::make_shared<MantidVec>(nbins, aNumber);
TS_ASSERT_THROWS_NOTHING(ws->setX(0, v));
TS_ASSERT_EQUALS(ws->dataX(0)[0], aNumber);
TS_ASSERT_THROWS(ws->setX(-1, v), std::range_error);
......@@ -132,8 +133,10 @@ public:
void testSetData() {
double aNumber = 5.7;
const boost::shared_ptr<MantidVec> v(new MantidVec(nbins, aNumber));
const boost::shared_ptr<MantidVec> e(new MantidVec(nbins, aNumber * 2));
const boost::shared_ptr<MantidVec> v =
boost::make_shared<MantidVec>(nbins, aNumber);
const boost::shared_ptr<MantidVec> e =
boost::make_shared<MantidVec>(nbins, aNumber * 2);
TS_ASSERT_THROWS_NOTHING(ws->setData(0, v, e));
TS_ASSERT_EQUALS(ws->dataY(0)[0], aNumber);
TS_ASSERT_EQUALS(ws->dataE(0)[0], aNumber * 2);
......@@ -225,7 +228,7 @@ public:
/** Get spectrum() */
void testGetSpectrum() {
boost::shared_ptr<MatrixWorkspace> ws(new Workspace2D());
boost::shared_ptr<MatrixWorkspace> ws = boost::make_shared<Workspace2D>();
ws->initialize(4, 1, 1);
ISpectrum *spec = NULL;
TS_ASSERT_THROWS_NOTHING(spec = ws->getSpectrum(0));
......
......@@ -88,7 +88,7 @@ public:
*/
inline bool isPointBounded(const coord_t *coords) const {
coord_t total = 0;
for (size_t d = 0; d < m_nd; d++) {
for (size_t d = 0; d < m_nd; ++d) {
total += m_normal[d] * coords[d];
}
return (total >= m_inequality);
......@@ -103,7 +103,7 @@ public:
*/
inline bool isPointBounded(const Mantid::Kernel::VMD &coords) const {
coord_t total = 0;
for (size_t d = 0; d < m_nd; d++) {
for (size_t d = 0; d < m_nd; ++d) {
total += m_normal[d] * static_cast<coord_t>(coords[d]);
}
return (total >= m_inequality);
......@@ -118,12 +118,48 @@ public:
*/
inline bool isPointBounded(const std::vector<coord_t> &coords) const {
coord_t total = 0;
for (size_t d = 0; d < m_nd; d++) {
for (size_t d = 0; d < m_nd; ++d) {
total += m_normal[d] * coords[d];
}
return (total >= m_inequality);
}
//----------------------------------------------------------------------------------------------
/** Is a point in MDimensions bounded by this hyperplane, that is,
* is (a1*x1 + a2*x2 + ... > b)?
* False for points that lie on the hyperplane, this is used to detect
* when two volumes (for example an MDBox and a mask) touch but do
* not share a finite volume
*
* @param coords :: nd-sized array of coordinates
* @return true if it is bounded by the plane
*/
inline bool isPointInside(const coord_t *coords) const {
coord_t total = 0;
for (size_t d = 0; d < m_nd; ++d) {
total += m_normal[d] * coords[d];
}
return (total > m_inequality);
}
//----------------------------------------------------------------------------------------------
/** Is a point in MDimensions bounded by this hyperplane, that is,
* is (a1*x1 + a2*x2 + ... > b)?
* False for points that lie on the hyperplane, this is used to detect
* when two volumes (for example an MDBox and a mask) touch but do
* not share a finite volume
*
* @param coords :: nd-sized vector of coordinates. No size check is made!
* @return true if it is bounded by the plane
*/
inline bool isPointInside(const std::vector<coord_t> &coords) const {
coord_t total = 0;
for (size_t d = 0; d < m_nd; ++d) {
total += m_normal[d] * coords[d];
}
return (total > m_inequality);
}
//----------------------------------------------------------------------------------------------
/** Given two points defining the start and end point of a line,
* is there an intersection between the hyperplane and the line
......@@ -153,7 +189,7 @@ private:
void construct(IterableType normal, IterableType point) {
m_normal = new coord_t[m_nd];
m_inequality = 0;
for (size_t d = 0; d < m_nd; d++) {
for (size_t d = 0; d < m_nd; ++d) {
m_normal[d] = static_cast<coord_t>(normal[d]);
m_inequality += static_cast<coord_t>(point[d]) * m_normal[d];
}
......
......@@ -93,8 +93,6 @@ private:
public:
Acomp(int const = 0);
Acomp(const Acomp &);
Acomp &operator=(const Acomp &);
bool operator==(const Acomp &) const;
bool operator!=(const Acomp &) const; ///< Complementary operator
bool operator<(const Acomp &) const;
......@@ -102,7 +100,6 @@ public:
Acomp &operator+=(const Acomp &);
Acomp &operator-=(const Acomp &);
Acomp &operator*=(const Acomp &);
~Acomp();
const Acomp *itemC(int const) const; ///< returns a pointer to Comp (or zero)
int itemN(int const) const; ///< returns an integer to Units (or zero)
......
......@@ -183,15 +183,10 @@ void ConventionalCell::init(const Kernel::DblMatrix &UB, ReducedCell &form_0,
* sides in increasing order.
*/
void ConventionalCell::SetSidesIncreasing(Kernel::DblMatrix &UB) {
V3D a_dir;
V3D b_dir;
V3D c_dir;
OrientedLattice::GetABC(UB, a_dir, b_dir, c_dir);
std::vector<V3D> edges;
edges.push_back(a_dir);
edges.push_back(b_dir);
edges.push_back(c_dir);
std::vector<V3D> edges(3, V3D());
OrientedLattice::GetABC(UB, edges[0], edges[1], edges[2]);
std::sort(edges.begin(), edges.end(), V3D::CompareMagnitude);
V3D a = edges[0];
......
......@@ -21,7 +21,7 @@ CyclicGroup::CyclicGroup(const SymmetryOperation &symmetryOperation)
std::vector<SymmetryOperation>
CyclicGroup::generateAllOperations(const SymmetryOperation &operation) const {
std::vector<SymmetryOperation> symOps(1, operation);
symOps.reserve(operation.order());
for (size_t i = 1; i < operation.order(); ++i) {
symOps.push_back(operation * symOps.back());
}
......
......@@ -5,6 +5,7 @@
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidKernel/Exception.h"
#include <boost/make_shared.hpp>
#include <queue>
using namespace Mantid::Kernel;
......@@ -570,7 +571,8 @@ Instrument::getDetectorG(const std::vector<detid_t> &det_ids) const {
if (ndets == 1) {
return this->getDetector(det_ids[0]);
} else {
boost::shared_ptr<DetectorGroup> det_group(new DetectorGroup());
boost::shared_ptr<DetectorGroup> det_group =
boost::make_shared<DetectorGroup>();
bool warn(false);
for (size_t i = 0; i < ndets; ++i) {
det_group->addDetector(this->getDetector(det_ids[i]), warn);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment