Commit 24a9e2e5 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #4791: use static_cast instead of c-style cast

parent efde066a
......@@ -338,8 +338,8 @@ namespace API
for (size_t d=0; d<m_dimensions.size(); d++)
{
IMDDimension_sptr dim = m_dimensions[d];
coord_t min = (dim->getMinimum() * coord_t(scaling[d])) + coord_t(offset[d]);
coord_t max = (dim->getMaximum() * coord_t(scaling[d])) + coord_t(offset[d]);
coord_t min = (dim->getMinimum() * static_cast<coord_t>(scaling[d])) + static_cast<coord_t>(offset[d]);
coord_t max = (dim->getMaximum() * static_cast<coord_t>(scaling[d])) + static_cast<coord_t>(offset[d]);
dim->setRange( dim->getNBins(), min, max);
}
// Clear the original workspace
......
......@@ -108,7 +108,7 @@ namespace Geometry
coord_t total = 0;
for (size_t d=0; d<m_nd; d++)
{
total += m_normal[d] * coord_t(coords[d]);
total += m_normal[d] * static_cast<coord_t>(coords[d]);
}
return (total >= m_inequality);
}
......@@ -165,8 +165,8 @@ namespace Geometry
m_inequality = 0;
for (size_t d=0; d<m_nd; d++)
{
m_normal[d] = coord_t(normal[d]);
m_inequality += coord_t(point[d]) * m_normal[d];
m_normal[d] = static_cast<coord_t>(normal[d]);
m_inequality += static_cast<coord_t>(point[d]) * m_normal[d];
}
}
......
......@@ -82,7 +82,7 @@ Mantid::Geometry::IMDDimension* IMDDimensionFactory::create() const
Mantid::Geometry::IMDDimension* IMDDimensionFactory::create(int nBins, double min, double max) const
{
MDHistoDimension* product = doCreate();
product->setRange(nBins, coord_t(min), coord_t(max)); //Override the number of bins, min and max.
product->setRange(nBins, static_cast<coord_t>(min), static_cast<coord_t>(max)); //Override the number of bins, min and max.
return product;
}
......@@ -126,7 +126,7 @@ Mantid::Geometry::MDHistoDimension* IMDDimensionFactory::doCreate() const
lowerBounds = lowerLimit;
}
return new MDHistoDimension(name, id, units, coord_t(lowerBounds), coord_t(upperBounds), nBins);
return new MDHistoDimension(name, id, units, static_cast<coord_t>(lowerBounds), static_cast<coord_t>(upperBounds), nBins);
}
/**
......
......@@ -67,7 +67,7 @@ namespace Geometry
normal_min[d] = +1.0;
// Origin just needs to have its X set to the value. Other coords are irrelevant
std::vector<coord_t> origin_min(nd,0);
origin_min[d] = coord_t(min[d]);
origin_min[d] = static_cast<coord_t>(min[d]);
// Build the plane
MDPlane p_min(normal_min, origin_min);
this->addPlane(p_min);
......@@ -77,7 +77,7 @@ namespace Geometry
normal_max[d] = -1.0;
// Origin just needs to have its X set to the value. Other coords are irrelevant
std::vector<coord_t> origin_max(nd,0);
origin_max[d] = coord_t(max[d]);
origin_max[d] = static_cast<coord_t>(max[d]);
// Build the plane
MDPlane p_max(normal_max, origin_max);
this->addPlane(p_max);
......
......@@ -36,7 +36,7 @@ MDPlaneImplicitFunction::MDPlaneImplicitFunction(const size_t nd,
this->origin = new coord_t[nd];
for( std::size_t i = 0; i < nd; i++)
{
this->origin[i] = coord_t(point[i]);
this->origin[i] = static_cast<coord_t>(point[i]);
}
this->addPlane(MDPlane(nd, normal, point));
}
......@@ -57,7 +57,7 @@ MDPlaneImplicitFunction::MDPlaneImplicitFunction(const size_t nd,
this->origin = new coord_t[nd];
for( std::size_t i = 0; i < nd; i++)
{
this->origin[i] = coord_t(point[i]);
this->origin[i] = static_cast<coord_t>(point[i]);
}
this->addPlane(MDPlane(nd, normal, point));
}
......
......@@ -30,7 +30,7 @@ public:
/// Helper function for the 2D case
bool try2Dpoint(MDImplicitFunction & f, double x, double y)
{
coord_t centers[2] = {coord_t(x),coord_t(y)};
coord_t centers[2] = {static_cast<coord_t>(x),static_cast<coord_t>(y)};
return f.isPointContained(centers);
}
......
......@@ -38,7 +38,7 @@ public:
/// Helper function for the 2D case
bool try2Dpoint(MDImplicitFunction & f, double x, double y)
{
coord_t centers[2] = {coord_t(x),coord_t(y)};
coord_t centers[2] = {static_cast<coord_t>(x),static_cast<coord_t>(y)};
return f.isPointContained(centers);
}
......@@ -99,8 +99,8 @@ public:
void add2DVertex(std::vector<std::vector<coord_t> > & vertexes, double x, double y)
{
std::vector<coord_t> vertex;
vertex.push_back(coord_t(x));
vertex.push_back(coord_t(y));
vertex.push_back(static_cast<coord_t>(x));
vertex.push_back(static_cast<coord_t>(y));
vertexes.push_back(vertex);
}
......@@ -114,13 +114,13 @@ public:
coord_t * out = new coord_t[8];
vertexes.clear();
add2DVertex(vertexes, x1,y1);
out[0] = coord_t(x1); out[1] = coord_t(y1);
out[0] = static_cast<coord_t>(x1); out[1] = static_cast<coord_t>(y1);
add2DVertex(vertexes, x2,y1);
out[2] = coord_t(x2); out[3] = coord_t(y1);
out[2] = static_cast<coord_t>(x2); out[3] = static_cast<coord_t>(y1);
add2DVertex(vertexes, x2,y2);
out[4] = coord_t(x2); out[5] = coord_t(y2);
out[4] = static_cast<coord_t>(x2); out[5] = static_cast<coord_t>(y2);
add2DVertex(vertexes, x1,y2);
out[6] = coord_t(x1); out[7] = coord_t(y2);
out[6] = static_cast<coord_t>(x1); out[7] = static_cast<coord_t>(y2);
return out;
}
......
......@@ -139,7 +139,7 @@ public:
/// Helper function for the 2D case
bool try2Dpoint(MDPlane & p, double x, double y)
{
coord_t centers[2] = {coord_t(x),coord_t(y)};
coord_t centers[2] = {static_cast<coord_t>(x),static_cast<coord_t>(y)};
return p.isPointBounded(centers);
}
......@@ -191,8 +191,8 @@ public:
/// Helper function for the 2D case of a line intersecting the plane
bool try2Dline(MDPlane & p, double x1, double y1, double x2, double y2)
{
coord_t centers1[2] = {coord_t(x1),coord_t(y1)};
coord_t centers2[2] = {coord_t(x2),coord_t(y2)};
coord_t centers1[2] = {static_cast<coord_t>(x1),static_cast<coord_t>(y1)};
coord_t centers2[2] = {static_cast<coord_t>(x2),static_cast<coord_t>(y2)};
return p.doesLineIntersect(centers1, centers2);
}
......
......@@ -33,11 +33,11 @@ namespace MDEvents
//---------------------------------------------------------------------------------------
/** Returns the mean position of events in this dimension */
coord_t getMean() const
{ return total / coord_t(numPoints); }
{ return total / static_cast<coord_t>(numPoints); }
/** Returns the approximate standard deviation of the position of events in this dimension */
coord_t getApproxVariance() const
{ return totalApproxVariance / coord_t(numPoints); }
{ return totalApproxVariance / static_cast<coord_t>(numPoints); }
//---------------------------------------------------------------------------------------
......@@ -48,7 +48,7 @@ namespace MDEvents
{
total += x;
numPoints++;
coord_t diff = (x - total/coord_t(numPoints));
coord_t diff = (x - total/static_cast<coord_t>(numPoints));
totalApproxVariance += diff * diff;
}
......
......@@ -251,11 +251,11 @@ namespace MDEvents
const MDEvent<nd> & event = *it;
float signal = event.signal;
float errorSquared = event.errorSquared;
data[index++] = coord_t(signal);
data[index++] = coord_t(errorSquared);
data[index++] = static_cast<coord_t>(signal);
data[index++] = static_cast<coord_t>(errorSquared);
// Additional stuff for MDEvent
data[index++] = coord_t(event.runIndex);
data[index++] = coord_t(event.detectorId);
data[index++] = static_cast<coord_t>(event.runIndex);
data[index++] = static_cast<coord_t>(event.detectorId);
for(size_t d=0; d<nd; d++)
data[index++] = event.center[d];
// Track the total signal
......
......@@ -111,7 +111,7 @@ namespace MDEvents
signal(signal), errorSquared(errorSquared)
{
for (size_t i=0; i<nd; i++)
center[i] = coord_t(centers[i]);
center[i] = static_cast<coord_t>(centers[i]);
}
#endif
//---------------------------------------------------------------------------------------------
......@@ -172,7 +172,7 @@ namespace MDEvents
* */
void setCenter(const size_t n, const double value)
{
center[n] = coord_t(value);
center[n] = static_cast<coord_t>(value);
}
#endif
......@@ -355,8 +355,8 @@ namespace MDEvents
const MDLeanEvent<nd> & event = *it;
float signal = event.signal;
float errorSquared = event.errorSquared;
data[index++] = coord_t(signal);
data[index++] = coord_t(errorSquared);
data[index++] = static_cast<coord_t>(signal);
data[index++] = static_cast<coord_t>(errorSquared);
for(size_t d=0; d<nd; d++)
data[index++] = event.center[d];
// Track the total signal
......
......@@ -132,7 +132,7 @@ namespace MDEvents
for (size_t d=0; d<nd; ++d)
{
dimensionsUsed[d] = true; // Use all dimensions
center[d] = coord_t(pos[d]);
center[d] = static_cast<coord_t>(pos[d]);
}
CoordTransformDistance sphere(nd, center, dimensionsUsed);
......@@ -143,13 +143,13 @@ namespace MDEvents
centroid[d] = 0.0;
// Perform centroid
ws->getBox()->centroidSphere(sphere, coord_t(PeakRadius*PeakRadius), centroid, signal);
ws->getBox()->centroidSphere(sphere, static_cast<coord_t>(PeakRadius*PeakRadius), centroid, signal);
// Normalize by signal
if (signal != 0.0)
{
for (size_t d=0; d<nd; d++)
centroid[d] /= coord_t(signal);
centroid[d] /= static_cast<coord_t>(signal);
V3D vecCentroid(centroid[0], centroid[1], centroid[2]);
......
......@@ -356,7 +356,7 @@ namespace MDEvents
// Give all the dimensions
for (size_t d=0; d<nd; d++)
{
MDHistoDimension * dim = new MDHistoDimension(dimensionNames[d], dimensionNames[d], dimensionUnits, coord_t(extents[d*2]), coord_t(extents[d*2+1]), 10);
MDHistoDimension * dim = new MDHistoDimension(dimensionNames[d], dimensionNames[d], dimensionUnits, static_cast<coord_t>(extents[d*2]), static_cast<coord_t>(extents[d*2+1]), 10);
ws->addDimension(MDHistoDimension_sptr(dim));
}
ws->initialize();
......
......@@ -186,14 +186,14 @@ namespace MDEvents
basis.normalize();
// The row of the affine matrix = the unit vector
for (size_t j=0; j<basis.size(); j++)
affineMatrix[i][j] = coord_t(basis[j] * scaling[i]);
affineMatrix[i][j] = static_cast<coord_t>(basis[j] * scaling[i]);
// Now account for the translation
coord_t transl = 0;
for (size_t j=0; j<basis.size(); j++)
transl += coord_t(origin[j] * basis[j]); // dot product of origin * basis aka ( X0 . U )
transl += static_cast<coord_t>(origin[j] * basis[j]); // dot product of origin * basis aka ( X0 . U )
// The last column of the matrix = the translation movement
affineMatrix[i][inD] = -transl * coord_t(scaling[i]);
affineMatrix[i][inD] = -transl * static_cast<coord_t>(scaling[i]);
}
// Copy into the raw matrix (for speed)
......
......@@ -167,7 +167,7 @@ namespace MDEvents
// Give all the dimensions
for (size_t d=0; d<ndims; d++)
{
MDHistoDimension * dim = new MDHistoDimension(names[d], names[d], units[d], coord_t(extents[d*2]), coord_t(extents[d*2+1]), 1);
MDHistoDimension * dim = new MDHistoDimension(names[d], names[d], units[d], static_cast<coord_t>(extents[d*2]), static_cast<coord_t>(extents[d*2+1]), 1);
out->addDimension(MDHistoDimension_sptr(dim));
}
......
......@@ -134,19 +134,19 @@ namespace MDEvents
}
// Make a unit vector pointing in this direction
coord_t radius = coord_t(sqrt(radiusSquared));
coord_t radius = static_cast<coord_t>(sqrt(radiusSquared));
for (size_t d=0; d<nd; d++)
centers[d] /= radius;
// Now place the point along this radius, scaled with ^1/n for uniformity.
coord_t radPos = genUnit();
radPos = coord_t(pow(radPos, 1.0/double(nd)));
radPos = static_cast<coord_t>(pow(radPos, 1.0/double(nd)));
for (size_t d=0; d<nd; d++)
{
// Multiply by the scaling and the desired peak radius
centers[d] *= (radPos * coord_t(desiredRadius));
centers[d] *= (radPos * static_cast<coord_t>(desiredRadius));
// Also offset by the center of the peak, as taken in Params
centers[d] += coord_t(params[d+1]);
centers[d] += static_cast<coord_t>(params[d+1]);
}
// Default or randomized error/signal
......@@ -230,7 +230,7 @@ namespace MDEvents
{
coord_t centers[nd];
for (size_t d=0; d<nd; d++)
centers[d] = coord_t((*gens[d])()); // use a different generator for each dimension
centers[d] = static_cast<coord_t>((*gens[d])()); // use a different generator for each dimension
// Default or randomized error/signal
float signal = 1.0;
......
......@@ -513,7 +513,7 @@ namespace MDEvents
// Other parameters
double PeakDistanceThreshold = getProperty("PeakDistanceThreshold");
peakRadiusSquared = coord_t(PeakDistanceThreshold*PeakDistanceThreshold);
peakRadiusSquared = static_cast<coord_t>(PeakDistanceThreshold*PeakDistanceThreshold);
DensityThresholdFactor = getProperty("DensityThresholdFactor");
MaxPeaks = getProperty("MaxPeaks");
......
......@@ -136,8 +136,8 @@ namespace MDEvents
{
for (size_t d=0; d<nd; d++)
{
extents[d].min = (extents[d].min * coord_t(scaling[d])) + coord_t(offset[d]);
extents[d].max = (extents[d].max * coord_t(scaling[d])) + coord_t(offset[d]);
extents[d].min = (extents[d].min * static_cast<coord_t>(scaling[d])) + static_cast<coord_t>(offset[d]);
extents[d].max = (extents[d].max * static_cast<coord_t>(scaling[d])) + static_cast<coord_t>(offset[d]);
}
// Re-calculate the volume of the box
this->calcVolume();
......
......@@ -146,14 +146,14 @@ namespace MDEvents
for (size_t d=0; d<nd; ++d)
{
dimensionsUsed[d] = true; // Use all dimensions
center[d] = coord_t(pos[d]);
center[d] = static_cast<coord_t>(pos[d]);
}
CoordTransformDistance sphere(nd, center, dimensionsUsed);
// Perform the integration into whatever box is contained within.
signal_t signal = 0;
signal_t errorSquared = 0;
ws->getBox()->integrateSphere(sphere, coord_t(PeakRadius*PeakRadius), signal, errorSquared);
ws->getBox()->integrateSphere(sphere, static_cast<coord_t>(PeakRadius*PeakRadius), signal, errorSquared);
// Integrate around the background radius
signal_t bgSignal = 0;
......@@ -161,7 +161,7 @@ namespace MDEvents
if (BackgroundRadius > PeakRadius)
{
// Get the total signal inside "BackgroundRadius"
ws->getBox()->integrateSphere(sphere, coord_t(BackgroundRadius*BackgroundRadius), bgSignal, bgErrorSquared);
ws->getBox()->integrateSphere(sphere, static_cast<coord_t>(BackgroundRadius*BackgroundRadius), bgSignal, bgErrorSquared);
// Evaluate the signal inside "BackgroundStartRadius"
signal_t interiorSignal = 0;
......@@ -169,7 +169,7 @@ namespace MDEvents
// Integrate this 3rd radius, if needed
if (BackgroundStartRadius != PeakRadius)
ws->getBox()->integrateSphere(sphere, coord_t(BackgroundStartRadius*BackgroundStartRadius), interiorSignal, interiorErrorSquared);
ws->getBox()->integrateSphere(sphere, static_cast<coord_t>(BackgroundStartRadius*BackgroundStartRadius), interiorSignal, interiorErrorSquared);
else
{
// PeakRadius == BackgroundStartRadius, so use the previous value
......
......@@ -406,8 +406,8 @@ namespace Mantid
std::vector<Mantid::Geometry::MDDimensionExtents> extentsVector(nd);
for (size_t d=0; d<nd; d++)
{
extentsVector[d].min = coord_t(extents[i*nd*2 + d*2]);
extentsVector[d].max = coord_t(extents[i*nd*2 + d*2 + 1]);
extentsVector[d].min = static_cast<coord_t>(extents[i*nd*2 + d*2]);
extentsVector[d].max = static_cast<coord_t>(extents[i*nd*2 + d*2 + 1]);
}
if (box_type == 1)
......
Markdown is supported
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