Commit b6ed204a authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #3137: Used coord_t and signal_t in appropriate spots in MD* classes....

Refs #3137: Used coord_t and signal_t in appropriate spots in MD* classes. Right now both are typedef'd to double but it builds if typedef'd so something else e.g float.
parent 6042993e
......@@ -92,103 +92,101 @@ namespace Mantid
/// Get the signal at the specified index.
virtual double getSignalAt(size_t index1) const
virtual signal_t getSignalAt(size_t index1) const
{
return getPoint(index1).getSignal();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getSignalAt(size_t index1, size_t index2) const
virtual signal_t getSignalAt(size_t index1, size_t index2) const
{
return getCell(index1,index2).getSignal();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getSignalAt(size_t index1, size_t index2, size_t index3) const
virtual signal_t getSignalAt(size_t index1, size_t index2, size_t index3) const
{
return getCell(index1,index2,index3).getSignal();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getSignalAt(size_t index1, size_t index2, size_t index3, size_t index4) const
virtual signal_t getSignalAt(size_t index1, size_t index2, size_t index3, size_t index4) const
{
return getCell(index1,index2,index3,index4).getSignal();
}
/// Get the error of the signal at the specified index.
virtual double getErrorAt(size_t index) const
virtual signal_t getErrorAt(size_t index) const
{
return getPoint(index).getError();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getErrorAt(size_t index1, size_t index2) const
virtual signal_t getErrorAt(size_t index1, size_t index2) const
{
return getCell(index1,index2).getError();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getErrorAt(size_t index1, size_t index2, size_t index3) const
virtual signal_t getErrorAt(size_t index1, size_t index2, size_t index3) const
{
return getCell(index1,index2,index3).getError();
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t)
virtual double getErrorAt(size_t index1, size_t index2, size_t index3, size_t index4) const
virtual signal_t getErrorAt(size_t index1, size_t index2, size_t index3, size_t index4) const
{
return getCell(index1,index2,index3,index4).getError();
}
/// Get the signal at the specified index, normalized by cell volume
virtual double getSignalNormalizedAt(size_t index) const
virtual signal_t getSignalNormalizedAt(size_t index) const
{ UNUSED_ARG(index);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getSignalNormalizedAt(size_t index1, size_t index2) const
virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getSignalNormalizedAt(size_t index1, size_t index2, size_t index3) const
virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getSignalNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const
virtual signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); UNUSED_ARG(index4);
throw std::runtime_error("Not implemented yet.");
}
/// Get the error of the signal at the specified index, normalized by cell volume
virtual double getErrorNormalizedAt(size_t index) const
virtual signal_t getErrorNormalizedAt(size_t index) const
{ UNUSED_ARG(index);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getErrorNormalizedAt(size_t index1, size_t index2) const
virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getErrorNormalizedAt(size_t index1, size_t index2, size_t index3) const
virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3);
throw std::runtime_error("Not implemented yet.");
}
/// Get the signal at the specified index given in 4 dimensions (typically X,Y,Z,t), normalized by cell volume
virtual double getErrorNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const
virtual signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const
{ UNUSED_ARG(index1); UNUSED_ARG(index2); UNUSED_ARG(index3); UNUSED_ARG(index4);
throw std::runtime_error("Not implemented yet.");
}
......@@ -197,13 +195,13 @@ namespace Mantid
/// Return a vector containing a copy of the signal data in the workspace. TODO: Make this more efficient if needed.
virtual std::vector<double> getSignalDataVector() const
virtual std::vector<signal_t> getSignalDataVector() const
{
throw std::runtime_error("Not implemented yet.");
}
/// Return a vector containing a copy of the signal data in the workspace. TODO: Make this more efficient if needed.
virtual std::vector<double> getErrorDataVector() const
virtual std::vector<signal_t> getErrorDataVector() const
{
throw std::runtime_error("Not implemented yet.");
}
......
......@@ -2,7 +2,7 @@
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidKernel/IPropertyManager.h"
using Mantid::MDEvents::coord_t;
using Mantid::coord_t;
using namespace Mantid::Geometry;
namespace Mantid
......
......@@ -1077,17 +1077,17 @@ namespace Mantid
{
VecCoordinate verts(4);
double x = this->dataX(histogram)[bin];
double signal = this->dataY(histogram)[bin];
double error = this->dataE(histogram)[bin];
double histogram_d = static_cast<double>(histogram);
signal_t signal = this->dataY(histogram)[bin];
signal_t error = this->dataE(histogram)[bin];
coord_t x = this->dataX(histogram)[bin];
coord_t histogram_d = static_cast<double>(histogram);
if(isHistogramData()) //TODO. complete vertex generating cases.
{
verts[0] = coordinate::createCoordinate2D(x, histogram_d);
verts[1] = coordinate::createCoordinate2D(this->dataX(histogram)[bin+1], histogram_d);
verts[2] = coordinate::createCoordinate2D(x, histogram_d+1.);
verts[3] = coordinate::createCoordinate2D(this->dataX(histogram)[bin+1], histogram_d+1.);
verts[0] = Coordinate::createCoordinate2D(x, histogram_d);
verts[1] = Coordinate::createCoordinate2D(this->dataX(histogram)[bin+1], histogram_d);
verts[2] = Coordinate::createCoordinate2D(x, histogram_d+1.);
verts[3] = Coordinate::createCoordinate2D(this->dataX(histogram)[bin+1], histogram_d+1.);
}
IDetector_sptr detector;
......
......@@ -204,7 +204,7 @@ public:
void testGetPointVertexes()
{
const Mantid::Geometry::SignalAggregate& pointA = workspace.getPoint(4);
std::vector<coordinate> vertexes = pointA.getVertexes();
std::vector<Coordinate> vertexes = pointA.getVertexes();
TSM_ASSERT_EQUALS("Wrong number of vertexes returned", 4, vertexes.size());
TSM_ASSERT_EQUALS("The v0 x-value is incorrect.", 4, vertexes.at(0).getX());
......
......@@ -5,10 +5,10 @@
* Author: owen
*/
#ifndef MD_COORDINATE_H_
#define MD_COORDINATE_H_
#ifndef MD_Coordinate_H_
#define MD_Coordinate_H_
/** The class represents a 4dimensional coordinate. Supports simple rendering of MDCells and MDPoints.
/** The class represents a 4dimensional Coordinate. Supports simple rendering of MDCells and MDPoints.
*
* Abstract type for a multi dimensional dimension. Gives a read-only layer to the concrete implementation.
......@@ -43,67 +43,67 @@ namespace Mantid
{
namespace Geometry
{
class EXPORT_OPT_MANTID_GEOMETRY coordinate
class EXPORT_OPT_MANTID_GEOMETRY Coordinate
{
public:
///Default constructor. All vertexes zero.
coordinate();
Coordinate();
/// Construct from an array
coordinate(Mantid::MDEvents::coord_t * coords, size_t numdims);
Coordinate(Mantid::coord_t * coords, size_t numdims);
//Copy constructor
coordinate(const coordinate & other);
Coordinate(const Coordinate & other);
//Assignment operator
coordinate & operator= (const coordinate & other);
Coordinate & operator= (const Coordinate & other);
///Construction Method for 1D.
static coordinate createCoordinate1D(const double& xArg);
static Coordinate createCoordinate1D(const coord_t& xArg);
///Construction Method for 2D.
static coordinate createCoordinate2D(const double& xArg, const double& yArg);
static Coordinate createCoordinate2D(const coord_t& xArg, const coord_t& yArg);
///Construction Method for 3D.
static coordinate createCoordinate3D(const double& xArg, const double& yArg, const double& zArg);
static Coordinate createCoordinate3D(const coord_t& xArg, const coord_t& yArg, const coord_t& zArg);
///Construction Method for 4D.
static coordinate createCoordinate4D(const double& xArg, const double& yArg,const double& zArg,const double& tArg);
static Coordinate createCoordinate4D(const coord_t& xArg, const coord_t& yArg,const coord_t& zArg,const coord_t& tArg);
/// Getter for x value
double getX() const;
coord_t getX() const;
/// Getter for y value.
double getY() const;
coord_t getY() const;
/// Getter for z value.
double getZ() const;
coord_t getZ() const;
/// Getter for t value.
double gett() const;
coord_t gett() const;
private:
double m_x;
double m_y;
double m_z;
double m_t;
coord_t m_x;
coord_t m_y;
coord_t m_z;
coord_t m_t;
///Constructor for 1D.
coordinate(const double& xArg);
Coordinate(const coord_t& xArg);
///Constructor for 2D.
coordinate(const double& xArg, const double& yArg);
Coordinate(const coord_t& xArg, const coord_t& yArg);
///Constructor for 3D.
coordinate(const double& xArg, const double& yArg, const double& zArg);
Coordinate(const coord_t& xArg, const coord_t& yArg, const coord_t& zArg);
///Constructor for 4D.
coordinate(const double& xArg, const double& yArg,const double& zArg,const double& tArg);
Coordinate(const coord_t& xArg, const coord_t& yArg,const coord_t& zArg,const coord_t& tArg);
};
typedef std::vector<coordinate> VecCoordinate;
typedef std::vector<Coordinate> VecCoordinate;
}
}
#endif /* COORDINATE_H_ */
#endif /* Coordinate_H_ */
......@@ -43,19 +43,19 @@ namespace Mantid
private:
double m_cachedSignal;
double m_cachedError;
std::vector<coordinate> m_vertexes;
std::vector<Coordinate> m_vertexes;
std::vector<boost::shared_ptr<MDPoint> > m_contributingPoints;
inline void calculateCachedValues();
public:
/// Default constructor
MDCell(){};
/// Construct from exising points.
MDCell(std::vector<boost::shared_ptr<MDPoint> > pContributingPoints, std::vector<coordinate> vertexes);
MDCell(std::vector<boost::shared_ptr<MDPoint> > pContributingPoints, std::vector<Coordinate> vertexes);
/// Construct image-only mode. No contributing points maintained.
MDCell(const double& signal,const double& error, const std::vector<coordinate>& vertexes);
std::vector<coordinate> getVertexes() const;
double getSignal() const;
double getError() const;
MDCell(const double& signal,const double& error, const std::vector<Coordinate>& vertexes);
std::vector<Coordinate> getVertexes() const;
signal_t getSignal() const;
signal_t getError() const;
std::vector<boost::shared_ptr<MDPoint> > getContributingPoints() const;
~MDCell();
};
......
......@@ -32,10 +32,11 @@
// Includes
//----------------------------------------------------------------------
#include "MantidGeometry/DllExport.h"
#include <vector>
#include "MantidGeometry/IDetector.h"
#include "MantidGeometry/IInstrument.h"
#include "MantidGeometry/MDGeometry/Coordinate.h"
#include "MantidKernel/System.h"
#include <vector>
namespace Mantid
{
......@@ -46,9 +47,9 @@ namespace Mantid
class EXPORT_OPT_MANTID_GEOMETRY SignalAggregate
{
public:
virtual std::vector<coordinate> getVertexes() const = 0;
virtual double getSignal() const = 0;
virtual double getError() const = 0;
virtual std::vector<Coordinate> getVertexes() const = 0;
virtual signal_t getSignal() const = 0;
virtual signal_t getError() const = 0;
virtual std::vector<boost::shared_ptr<MDPoint> > getContributingPoints() const = 0;
virtual ~SignalAggregate(){};
};
......@@ -56,19 +57,19 @@ namespace Mantid
class EXPORT_OPT_MANTID_GEOMETRY MDPoint : public SignalAggregate
{
private:
double m_signal;
double m_error;
signal_t m_signal;
signal_t m_error;
IInstrument_sptr m_instrument;
IDetector_sptr m_detector;
std::vector<coordinate> m_vertexes;
std::vector<Coordinate> m_vertexes;
int m_runId;
public:
MDPoint(){};
MDPoint(double signal, double error, const std::vector<coordinate>& vertexes, IDetector_sptr detector, IInstrument_sptr instrument,
MDPoint(signal_t signal, signal_t error, const std::vector<Coordinate>& vertexes, IDetector_sptr detector, IInstrument_sptr instrument,
const int runId = 0);
std::vector<coordinate> getVertexes() const;
double getSignal() const;
double getError() const;
std::vector<Coordinate> getVertexes() const;
signal_t getSignal() const;
signal_t getError() const;
IDetector_sptr getDetector() const;
IInstrument_sptr getInstrument() const;
int getRunId() const;
......
......@@ -4,42 +4,42 @@ namespace Mantid
{
namespace Geometry
{
///Construction Method for 1D.
coordinate coordinate::createCoordinate1D(const double& xArg)
///Construction Method for 1D.
Coordinate Coordinate::createCoordinate1D(const coord_t& xArg)
{
return coordinate(xArg);
return Coordinate(xArg);
}
///Construction Method for 2D.
coordinate coordinate::createCoordinate2D(const double& xArg, const double& yArg)
Coordinate Coordinate::createCoordinate2D(const coord_t& xArg, const coord_t& yArg)
{
return coordinate(xArg, yArg);
return Coordinate(xArg, yArg);
}
///Construction Method for 3D.
coordinate coordinate::createCoordinate3D(const double& xArg, const double& yArg, const double& zArg)
Coordinate Coordinate::createCoordinate3D(const coord_t& xArg, const coord_t& yArg, const coord_t& zArg)
{
return coordinate(xArg, yArg, zArg);
return Coordinate(xArg, yArg, zArg);
}
///Construction Method for 4D.
coordinate coordinate::createCoordinate4D(const double& xArg, const double& yArg,const double& zArg,const double& tArg)
Coordinate Coordinate::createCoordinate4D(const coord_t& xArg, const coord_t& yArg,const coord_t& zArg,const coord_t& tArg)
{
return coordinate(xArg, yArg, zArg, tArg);
return Coordinate(xArg, yArg, zArg, tArg);
}
/** Default Constructor */
coordinate::coordinate()
Coordinate::Coordinate()
: m_x(0),m_y(0),m_z(0),m_t(0)
{
}
/** Constructor
*
* @param coords :: array of coordinates
* @param coords :: array of Coordinates
* @param numdims :: number of dimensions in array
*/
coordinate::coordinate(Mantid::MDEvents::coord_t * coords, size_t numdims)
Coordinate::Coordinate(Mantid::coord_t * coords, size_t numdims)
: m_x(0),m_y(0),m_z(0),m_t(0)
{
if (numdims > 0) m_x = coords[0];
......@@ -49,32 +49,32 @@ namespace Geometry
}
coordinate::coordinate(const double& xArg)
Coordinate::Coordinate(const coord_t& xArg)
: m_x(xArg),m_y(0),m_z(0),m_t(0)
{
}
coordinate::coordinate(const double& xArg, const double& yArg)
Coordinate::Coordinate(const coord_t& xArg, const coord_t& yArg)
: m_x(xArg),m_y(yArg),m_z(0),m_t(0)
{
}
coordinate::coordinate(const double& xArg, const double& yArg, const double& zArg)
Coordinate::Coordinate(const coord_t& xArg, const coord_t& yArg, const coord_t& zArg)
: m_x(xArg),m_y(yArg),m_z(zArg),m_t(0)
{
}
coordinate::coordinate(const double& xArg, const double& yArg,const double& zArg,const double& tArg)
Coordinate::Coordinate(const coord_t& xArg, const coord_t& yArg,const coord_t& zArg,const coord_t& tArg)
: m_x(xArg),m_y(yArg),m_z(zArg),m_t(tArg)
{
}
coordinate::coordinate(const coordinate & other)
Coordinate::Coordinate(const Coordinate & other)
: m_x(other.m_x),m_y(other.m_y),m_z(other.m_z),m_t(other.m_t)
{
}
coordinate & coordinate::operator= (const coordinate & other)
Coordinate & Coordinate::operator= (const Coordinate & other)
{
if(this != &other)
{
......@@ -86,19 +86,19 @@ namespace Geometry
return *this;
}
double coordinate::getX() const
coord_t Coordinate::getX() const
{
return m_x;
}
double coordinate::getY() const
coord_t Coordinate::getY() const
{
return m_y;
}
double coordinate::getZ() const
coord_t Coordinate::getZ() const
{
return m_z;
}
double coordinate::gett() const
coord_t Coordinate::gett() const
{
return m_t;
}
......
......@@ -6,7 +6,7 @@ namespace Mantid
namespace Geometry
{
MDCell::MDCell(std::vector<boost::shared_ptr<Mantid::Geometry::MDPoint> > pContributingPoints, std::vector<coordinate> vertexes)
MDCell::MDCell(std::vector<boost::shared_ptr<Mantid::Geometry::MDPoint> > pContributingPoints, std::vector<Coordinate> vertexes)
: m_cachedSignal(0),
m_cachedError(0),
m_vertexes(vertexes),
......@@ -17,7 +17,7 @@ namespace Mantid
calculateCachedValues();
}
MDCell::MDCell(const double& signal,const double& error, const std::vector<coordinate>& vertexes)
MDCell::MDCell(const double& signal,const double& error, const std::vector<Coordinate>& vertexes)
: m_cachedSignal(signal),
m_cachedError(error),
m_vertexes(vertexes)
......@@ -27,16 +27,16 @@ namespace Mantid
std::vector<coordinate> MDCell::getVertexes() const
std::vector<Coordinate> MDCell::getVertexes() const
{
return this->m_vertexes;
}
double MDCell::getSignal() const
signal_t MDCell::getSignal() const
{
return this->m_cachedSignal;
}
double MDCell::getError() const
signal_t MDCell::getError() const
{
return this->m_cachedError;
}
......
......@@ -4,7 +4,8 @@ namespace Mantid
{
namespace Geometry
{
MDPoint::MDPoint(double signal, double error,const std::vector<coordinate>& vertexes, IDetector_sptr detector, IInstrument_sptr instrument,
MDPoint::MDPoint(signal_t signal, signal_t error,
const std::vector<Coordinate>& vertexes, IDetector_sptr detector, IInstrument_sptr instrument,
const int runId)
: m_signal(signal),
m_error(error),
......@@ -15,17 +16,17 @@ namespace Mantid
{
}
std::vector<coordinate> MDPoint::getVertexes() const
std::vector<Coordinate> MDPoint::getVertexes() const
{
return this->m_vertexes;
}
double MDPoint::getSignal() const
signal_t MDPoint::getSignal() const
{
return this->m_signal;
}
double MDPoint::getError() const
signal_t MDPoint::getError() const
{
return this->m_error;
}
......
......@@ -1660,9 +1660,11 @@ Matrix<T>::str() const
///\cond TEMPLATE
template class DLLExport Matrix<double>;
template class DLLExport Matrix<float>;
template class DLLExport Matrix<int>;
template DLLExport std::ostream& operator<<(std::ostream&,const Geometry::Matrix<double>&);
template DLLExport std::ostream& operator<<(std::ostream&,const Geometry::Matrix<float>&);
template DLLExport std::ostream& operator<<(std::ostream&,const Geometry::Matrix<int>&);
///\endcond TEMPLATE
......
......@@ -208,6 +208,7 @@ template
template DLLExport void indexSort(const std::vector<double>&,std::vector<int>&);