Unverified Commit 0bc884fc authored by DannyHindson's avatar DannyHindson Committed by GitHub
Browse files

Merge pull request #32531 from DavidFair/cppcheck_cache

Cppcheck cache
parents 3ee31c71 30f7d72e
......@@ -518,7 +518,6 @@ const std::string LoadRKH::readUnit(const std::string &line) {
// however to use is safely other checks would be required that would impair
// readability, therefore in this case the unlikely performance hit is
// accepted.
// cppcheck-suppress stlIfStrFind
if (unit.find('(') != 0 || unit.find(')') != unit.size()) {
std::string qCode = std::to_string(SaveRKH::Q_CODE);
if (symbol == qCode && theQuantity == "q" &&
......
......@@ -906,7 +906,6 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) {
* get time in VMS format 01-JAN-1970 00:00:00
*/
size_t i, n;
// cppcheck-suppress redundantAssignment
struct tm *tmstruct = nullptr;
#ifdef MS_VISUAL_STUDIO
errno_t err = localtime_s(tmstruct, &time_value);
......
......@@ -353,6 +353,11 @@ public:
virtual ~ISISRAW();
explicit ISISRAW(ISISCRPT_STRUCT *crpt);
ISISRAW(ISISCRPT_STRUCT *crpt, bool doUpdateFromCRPT);
// Explicitly prevent copying with all the dynamic allocations
ISISRAW(const ISISRAW &) = delete;
ISISRAW &operator=(ISISRAW) = delete;
int updateFromCRPT();
virtual int ioRAW(FILE *file, bool from_file, bool read_data = true);
......
......@@ -104,12 +104,12 @@ void ProcessBankData::run() { // override {
// Default pulse time (if none are found)
const bool pulsetimesincreasing =
std::is_sorted(thisBankPulseTimes->pulseTimes, thisBankPulseTimes->pulseTimes + thisBankPulseTimes->numPulses);
std::is_sorted(thisBankPulseTimes->pulseTimes.cbegin(), thisBankPulseTimes->pulseTimes.cend());
if (!std::is_sorted(event_index->cbegin(), event_index->cend()))
throw std::runtime_error("Event index is not sorted");
// And there are this many pulses
const auto NUM_PULSES = thisBankPulseTimes->numPulses;
const auto NUM_PULSES = thisBankPulseTimes->pulseTimes.size();
prog->report(entry_name + ": filling events");
// Will we need to compress?
......
......@@ -100,7 +100,6 @@ std::map<std::string, std::string> SaveDiffCal::validateInputs() {
*/
void SaveDiffCal::writeDoubleFieldFromTable(H5::Group &group, const std::string &name) {
auto column = m_calibrationWS->getColumn(name);
// cppcheck-suppress compareBoolExpressionWithInt
// Retrieve only the first m_numValues, not necessarily the whole column
auto data = column->numeric_fill<>(m_numValues);
H5Util::writeArray1D(group, name, data);
......
......@@ -28,6 +28,7 @@
#include <fstream>
#include <iterator>
#include <map>
#include <memory>
#include <sstream>
namespace Mantid::DataHandling {
......@@ -40,8 +41,9 @@ using namespace API;
/// Empty default constructor
SaveISISNexus::SaveISISNexus()
: Algorithm(), m_isisRaw(), handle(), rawFile(), nper(0), nsp(0), ntc(0), nmon(0), ndet(0), counts_link(),
period_index_link(), spectrum_index_link(), time_of_flight_link(), time_of_flight_raw_link() {}
: Algorithm(), m_isisRaw(std::make_unique<ISISRAW2>()), handle(), rawFile(), nper(0), nsp(0), ntc(0), nmon(0),
ndet(0), counts_link(), period_index_link(), spectrum_index_link(), time_of_flight_link(),
time_of_flight_raw_link() {}
/** Initialisation method.
*
......@@ -97,18 +99,18 @@ void SaveISISNexus::exec() {
// Retrieve the filename from the properties
inputFilename = getPropertyValue("InputFileName");
m_isisRaw = ISISRAW2();
m_isisRaw = std::make_unique<ISISRAW2>();
rawFile = fopen(inputFilename.c_str(), "rb");
if (rawFile == nullptr) {
throw Exception::FileError("Cannot open file ", inputFilename);
}
m_isisRaw.ioRAW(rawFile, true);
m_isisRaw->ioRAW(rawFile, true);
nper = m_isisRaw.t_nper; // number of periods
nsp = m_isisRaw.t_nsp1; // number of spectra
ntc = m_isisRaw.t_ntc1; // number of time channels
nmon = m_isisRaw.i_mon; // number of monitors
ndet = m_isisRaw.i_det; // number of detectors
nper = m_isisRaw->t_nper; // number of periods
nsp = m_isisRaw->t_nsp1; // number of spectra
ntc = m_isisRaw->t_ntc1; // number of time channels
nmon = m_isisRaw->i_mon; // number of monitors
ndet = m_isisRaw->i_det; // number of detectors
std::string outputFilename = getPropertyValue("OutputFileName");
......@@ -124,7 +126,7 @@ void SaveISISNexus::exec() {
write_isis_vms_compat();
saveString("beamline", " ");
flt = static_cast<float>(m_isisRaw.rpb.r_dur); // could be wrong
flt = static_cast<float>(m_isisRaw->rpb.r_dur); // could be wrong
saveFloatOpen("collection_time", &flt, 1);
putAttr("units", "second");
close();
......@@ -139,32 +141,32 @@ void SaveISISNexus::exec() {
putAttr("url", "http://svn.isis.rl.ac.uk/instruments/ISISTOFRAW/?version=1.0");
close();
flt = static_cast<float>(m_isisRaw.rpb.r_dur);
flt = static_cast<float>(m_isisRaw->rpb.r_dur);
saveFloatOpen("duration", &flt, 1);
putAttr("units", "second");
close();
start_time_str.assign(m_isisRaw.hdr.hd_date, m_isisRaw.hdr.hd_date + 12);
start_time_str.assign(m_isisRaw->hdr.hd_date, m_isisRaw->hdr.hd_date + 12);
toISO8601(start_time_str);
start_time_str += 'T';
start_time_str += std::string(m_isisRaw.hdr.hd_time, m_isisRaw.hdr.hd_time + 8);
start_time_str += std::string(m_isisRaw->hdr.hd_time, m_isisRaw->hdr.hd_time + 8);
saveCharOpen("start_time", &start_time_str[0], 19);
putAttr("units", "ISO8601");
close();
std::string str;
str.assign(m_isisRaw.rpb.r_enddate, m_isisRaw.rpb.r_enddate + 12);
str.assign(m_isisRaw->rpb.r_enddate, m_isisRaw->rpb.r_enddate + 12);
toISO8601(str);
str += 'T';
str += std::string(m_isisRaw.rpb.r_endtime, m_isisRaw.rpb.r_endtime + 8);
str += std::string(m_isisRaw->rpb.r_endtime, m_isisRaw->rpb.r_endtime + 8);
saveCharOpen("end_time", &str[0], 19);
putAttr("units", "ISO8601");
close();
saveChar("title", m_isisRaw.r_title, 80);
saveInt("good_frames", &m_isisRaw.rpb.r_goodfrm);
saveChar("title", m_isisRaw->r_title, 80);
saveInt("good_frames", &m_isisRaw->rpb.r_goodfrm);
std::string experiment_identifier = std::to_string(m_isisRaw.rpb.r_prop);
std::string experiment_identifier = std::to_string(m_isisRaw->rpb.r_prop);
saveChar("experiment_identifier", &experiment_identifier[0], static_cast<int>(experiment_identifier.size()));
int tmp_int(0);
saveInt("measurement_first_run", &tmp_int);
......@@ -173,27 +175,27 @@ void SaveISISNexus::exec() {
saveString("measurement_subid", " ");
saveString("measurement_type", " ");
saveCharOpen("name", &m_isisRaw.i_inst, 8);
putAttr("short_name", m_isisRaw.hdr.inst_abrv, 3);
saveCharOpen("name", &m_isisRaw->i_inst, 8);
putAttr("short_name", m_isisRaw->hdr.inst_abrv, 3);
close();
logNotes();
saveString("program_name", "isisicp");
saveFloatOpen("proton_charge", &m_isisRaw.rpb.r_gd_prtn_chrg, 1);
saveFloatOpen("proton_charge", &m_isisRaw->rpb.r_gd_prtn_chrg, 1);
putAttr("units", "uamp.hour");
close();
saveFloatOpen("proton_charge_raw", &m_isisRaw.rpb.r_tot_prtn_chrg, 1);
saveFloatOpen("proton_charge_raw", &m_isisRaw->rpb.r_tot_prtn_chrg, 1);
putAttr("units", "uamp.hour");
close();
saveInt("raw_frames", &m_isisRaw.rpb.r_rawfrm);
saveInt("raw_frames", &m_isisRaw->rpb.r_rawfrm);
run_cycle();
saveInt("run_number", &m_isisRaw.r_number);
saveInt("run_number", &m_isisRaw->r_number);
// script_name
// seci_config
......@@ -383,67 +385,67 @@ void SaveISISNexus::toISO8601(std::string &str) {
void SaveISISNexus::write_isis_vms_compat() {
NXmakegroup(handle, "isis_vms_compat", "IXvms");
NXopengroup(handle, "isis_vms_compat", "IXvms");
int ndet = m_isisRaw.i_det;
int nmon = m_isisRaw.i_mon;
int ndet = m_isisRaw->i_det;
int nmon = m_isisRaw->i_mon;
saveInt("ADD", &m_isisRaw.add, 9);
saveInt("CODE", m_isisRaw.code, ndet);
saveInt("CRAT", m_isisRaw.crat, ndet);
saveInt("ADD", &m_isisRaw->add, 9);
saveInt("CODE", m_isisRaw->code, ndet);
saveInt("CRAT", m_isisRaw->crat, ndet);
write_rpb();
write_spb();
write_vpb();
saveInt("DAEP", &m_isisRaw.daep, 64);
saveInt("DELT", m_isisRaw.delt, ndet);
saveInt("FORM", &m_isisRaw.data_format);
saveChar("HDR", &m_isisRaw.hdr, 80);
saveFloat("LEN2", m_isisRaw.len2, ndet);
saveInt("MDET", m_isisRaw.mdet, nmon);
saveInt("MODN", m_isisRaw.modn, ndet);
saveInt("MONP", m_isisRaw.monp, nmon);
saveInt("MPOS", m_isisRaw.mpos, ndet);
saveChar("NAME", m_isisRaw.i_inst, 8);
saveInt("DAEP", &m_isisRaw->daep, 64);
saveInt("DELT", m_isisRaw->delt, ndet);
saveInt("FORM", &m_isisRaw->data_format);
saveChar("HDR", &m_isisRaw->hdr, 80);
saveFloat("LEN2", m_isisRaw->len2, ndet);
saveInt("MDET", m_isisRaw->mdet, nmon);
saveInt("MODN", m_isisRaw->modn, ndet);
saveInt("MONP", m_isisRaw->monp, nmon);
saveInt("MPOS", m_isisRaw->mpos, ndet);
saveChar("NAME", m_isisRaw->i_inst, 8);
saveInt("NDET", &ndet);
saveInt("NFPP", &m_isisRaw.t_nfpp);
saveInt("NFPP", &m_isisRaw->t_nfpp);
saveInt("NMON", &nmon);
saveInt("NPER", &m_isisRaw.t_nper);
saveInt("NSER", &m_isisRaw.e_nse);
saveInt("NSP1", &m_isisRaw.t_nsp1);
saveInt("NTC1", &m_isisRaw.t_ntc1);
saveInt("NTRG", &m_isisRaw.t_ntrg);
saveInt("NUSE", &m_isisRaw.i_use);
saveInt("PMAP", &m_isisRaw.t_pmap, 256);
saveInt("PRE1", &m_isisRaw.t_pre1);
saveInt("RUN", &m_isisRaw.r_number);
saveInt("SPEC", m_isisRaw.spec, ndet);
saveInt("TCM1", &m_isisRaw.t_tcm1);
saveFloat("TCP1", m_isisRaw.t_tcp1, 20);
saveInt("TIMR", m_isisRaw.timr, ndet);
saveChar("TITL", m_isisRaw.r_title, 80);
saveFloat("TTHE", m_isisRaw.tthe, ndet);
saveInt("UDET", m_isisRaw.udet, ndet);
saveInt("ULEN", &m_isisRaw.u_len);
saveInt("NPER", &m_isisRaw->t_nper);
saveInt("NSER", &m_isisRaw->e_nse);
saveInt("NSP1", &m_isisRaw->t_nsp1);
saveInt("NTC1", &m_isisRaw->t_ntc1);
saveInt("NTRG", &m_isisRaw->t_ntrg);
saveInt("NUSE", &m_isisRaw->i_use);
saveInt("PMAP", &m_isisRaw->t_pmap, 256);
saveInt("PRE1", &m_isisRaw->t_pre1);
saveInt("RUN", &m_isisRaw->r_number);
saveInt("SPEC", m_isisRaw->spec, ndet);
saveInt("TCM1", &m_isisRaw->t_tcm1);
saveFloat("TCP1", m_isisRaw->t_tcp1, 20);
saveInt("TIMR", m_isisRaw->timr, ndet);
saveChar("TITL", m_isisRaw->r_title, 80);
saveFloat("TTHE", m_isisRaw->tthe, ndet);
saveInt("UDET", m_isisRaw->udet, ndet);
saveInt("ULEN", &m_isisRaw->u_len);
std::string user_info(160, ' ');
if (m_isisRaw.u_len > 0) {
std::copy(reinterpret_cast<char *>(&m_isisRaw.user), reinterpret_cast<char *>(&m_isisRaw.user) + m_isisRaw.u_len,
if (m_isisRaw->u_len > 0) {
std::copy(reinterpret_cast<char *>(&m_isisRaw->user), reinterpret_cast<char *>(&m_isisRaw->user) + m_isisRaw->u_len,
user_info.begin());
}
saveString("USER", user_info);
saveInt("VER1", &m_isisRaw.frmt_ver_no);
saveInt("VER2", &m_isisRaw.ver2);
saveInt("VER3", &m_isisRaw.ver3);
saveInt("VER4", &m_isisRaw.ver4);
saveInt("VER5", &m_isisRaw.ver5);
saveInt("VER6", &m_isisRaw.ver6);
saveInt("VER7", &m_isisRaw.ver7);
saveInt("VER8", &m_isisRaw.ver8);
saveInt("VER1", &m_isisRaw->frmt_ver_no);
saveInt("VER2", &m_isisRaw->ver2);
saveInt("VER3", &m_isisRaw->ver3);
saveInt("VER4", &m_isisRaw->ver4);
saveInt("VER5", &m_isisRaw->ver5);
saveInt("VER6", &m_isisRaw->ver6);
saveInt("VER7", &m_isisRaw->ver7);
saveInt("VER8", &m_isisRaw->ver8);
int tmp_int(0);
saveInt("VER9", &tmp_int);
int n = m_isisRaw.logsect.nlines;
int n = m_isisRaw->logsect.nlines;
log_notes.resize(n);
for (int i = 0; i < n; ++i) {
log_notes[i].assign(m_isisRaw.logsect.lines[i].data, m_isisRaw.logsect.lines[i].len);
log_notes[i].assign(m_isisRaw->logsect.lines[i].data, m_isisRaw->logsect.lines[i].len);
}
int ll = saveStringVectorOpen("NOTE", log_notes);
saveInt("NTNL", &n);
......@@ -455,8 +457,8 @@ void SaveISISNexus::write_isis_vms_compat() {
void SaveISISNexus::instrument() {
NXmakegroup(handle, "instrument", "NXinstrument");
NXopengroup(handle, "instrument", "NXinstrument");
saveCharOpen("name", &m_isisRaw.i_inst, 8);
putAttr("short_name", m_isisRaw.hdr.inst_abrv, 3);
saveCharOpen("name", &m_isisRaw->i_inst, 8);
putAttr("short_name", m_isisRaw->hdr.inst_abrv, 3);
close();
dae();
detector_1();
......@@ -470,7 +472,8 @@ void SaveISISNexus::detector_1() {
NXopengroup(handle, "detector_1", "NXdata");
for (int i = 0; i < nmon; ++i) {
auto si = int(std::distance(m_isisRaw.spec, std::find(m_isisRaw.spec, m_isisRaw.spec + nsp, m_isisRaw.mdet[i])));
auto si =
int(std::distance(m_isisRaw->spec, std::find(m_isisRaw->spec, m_isisRaw->spec + nsp, m_isisRaw->mdet[i])));
monitor_index[si] = i;
}
......@@ -489,15 +492,15 @@ void SaveISISNexus::detector_1() {
int index = 0;
for (int p = 0; p < nper; ++p) {
int ispec = 0;
m_isisRaw.skipData(rawFile, index++);
m_isisRaw->skipData(rawFile, index++);
for (int si = 0; si < nsp; ++si) {
if (monitor_index.find(si) != monitor_index.end()) {
m_isisRaw.readData(rawFile, index);
monitorData.insert(monitorData.end(), m_isisRaw.dat1 + 1, m_isisRaw.dat1 + ntc + 1);
m_isisRaw->readData(rawFile, index);
monitorData.insert(monitorData.end(), m_isisRaw->dat1 + 1, m_isisRaw->dat1 + ntc + 1);
} else {
m_isisRaw.readData(rawFile, index);
m_isisRaw->readData(rawFile, index);
int start[] = {p, ispec, 0};
NXputslab(handle, m_isisRaw.dat1 + 1, start, size);
NXputslab(handle, m_isisRaw->dat1 + 1, start, size);
++ispec;
}
++index;
......@@ -509,7 +512,7 @@ void SaveISISNexus::detector_1() {
NXmakelink(handle, &period_index_link);
std::vector<int> spec_minus_monitors(nsp - nmon);
std::generate(spec_minus_monitors.begin(), spec_minus_monitors.end(), getWithoutMonitors<int>(this, m_isisRaw.spec));
std::generate(spec_minus_monitors.begin(), spec_minus_monitors.end(), getWithoutMonitors<int>(this, m_isisRaw->spec));
saveIntOpen("spectrum_index", &spec_minus_monitors[0], nsp - nmon);
NXgetdataID(handle, &spectrum_index_link);
close();
......@@ -518,19 +521,19 @@ void SaveISISNexus::detector_1() {
NXmakelink(handle, &time_of_flight_raw_link);
std::vector<float> float_vec(ndet - nmon);
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw.delt));
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw->delt));
saveFloat("delt", &float_vec[0], ndet - nmon);
saveFloat("source_detector_distance", &m_isisRaw.ivpb.i_sddist, 1);
saveFloat("source_detector_distance", &m_isisRaw->ivpb.i_sddist, 1);
// using the same float_vec, size unchanged ndet-nmon
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw.len2));
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw->len2));
saveFloatOpen("distance", &float_vec[0], ndet - nmon);
putAttr("units", "metre");
close();
// using the same float_vec, size unchanged ndet-nmon
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw.tthe));
std::generate(float_vec.begin(), float_vec.end(), getWithoutMonitors<float>(this, m_isisRaw->tthe));
saveFloatOpen("polar_angle", &float_vec[0], ndet - nmon);
putAttr("units", "degree");
close();
......@@ -545,7 +548,7 @@ void SaveISISNexus::moderator() {
NXmakegroup(handle, "moderator", "NXmoderator");
NXopengroup(handle, "moderator", "NXmoderator");
float l1 = -m_isisRaw.ivpb.i_l1;
float l1 = -m_isisRaw->ivpb.i_l1;
saveFloatOpen("distance", &l1, 1);
putAttr("units", "metre");
......@@ -588,11 +591,11 @@ void SaveISISNexus::make_detector_1_link() {
* @param imon Monitor index (not its spectrum number)
*/
int *SaveISISNexus::getMonitorData(int period, int imon) {
return &monitorData[period * m_isisRaw.i_mon * m_isisRaw.t_ntc1 + imon * m_isisRaw.t_ntc1];
return &monitorData[period * m_isisRaw->i_mon * m_isisRaw->t_ntc1 + imon * m_isisRaw->t_ntc1];
}
void SaveISISNexus::write_monitors() {
int nmon = m_isisRaw.i_mon;
int nmon = m_isisRaw->i_mon;
for (int i = 0; i < nmon; ++i) {
monitor_i(i);
}
......@@ -603,8 +606,8 @@ void SaveISISNexus::write_monitors() {
* @param i Index of a monitor
*/
void SaveISISNexus::monitor_i(int i) {
int nper = m_isisRaw.t_nper; // number of periods
int ntc = m_isisRaw.t_ntc1; // number of time channels
int nper = m_isisRaw->t_nper; // number of periods
int ntc = m_isisRaw->t_ntc1; // number of time channels
int dim[] = {nper, 1, ntc};
int size[] = {1, 1, ntc};
std::ostringstream ostr;
......@@ -613,7 +616,7 @@ void SaveISISNexus::monitor_i(int i) {
NXmakegroup(handle, ostr.str().c_str(), "NXmonitor");
NXopengroup(handle, ostr.str().c_str(), "NXmonitor");
// int imon = m_isisRaw.mdet[i]; // spectrum number
// int imon = m_isisRaw->mdet[i]; // spectrum number
NXmakedata(handle, "data", NX_INT32, 3, dim);
NXopendata(handle, "data");
for (int p = 0; p < nper; ++p) {
......@@ -627,7 +630,7 @@ void SaveISISNexus::monitor_i(int i) {
saveInt("monitor_number", &mon_num);
NXmakelink(handle, &period_index_link);
saveInt("spectrum_index", &m_isisRaw.mdet[i]);
saveInt("spectrum_index", &m_isisRaw->mdet[i]);
NXmakelink(handle, &time_of_flight_link);
NXclosegroup(handle);
......@@ -641,7 +644,7 @@ void SaveISISNexus::dae() {
saveString("spectra_table_file", " ");
saveString("wiring_table_file", " ");
saveIntOpen("period_index", m_isisRaw.t_pmap, nper);
saveIntOpen("period_index", m_isisRaw->t_pmap, nper);
NXgetdataID(handle, &period_index_link);
close();
......@@ -649,7 +652,7 @@ void SaveISISNexus::dae() {
NXopengroup(handle, "time_channels_1", "IXtime_channels");
boost::scoped_array<float> timeChannels(new float[ntc + 1]);
m_isisRaw.getTimeChannels(timeChannels.get(), ntc + 1);
m_isisRaw->getTimeChannels(timeChannels.get(), ntc + 1);
saveFloatOpen("time_of_flight", timeChannels.get(), ntc + 1);
putAttr("axis", 1);
putAttr("primary", 1);
......@@ -657,7 +660,7 @@ void SaveISISNexus::dae() {
NXgetdataID(handle, &time_of_flight_link);
close();
saveIntOpen("time_of_flight_raw", m_isisRaw.t_tcb1, ntc + 1);
saveIntOpen("time_of_flight_raw", m_isisRaw->t_tcb1, ntc + 1);
putAttr("units", "pulses");
putAttr("frequency", "32 MHz");
NXgetdataID(handle, &time_of_flight_raw_link);
......@@ -672,8 +675,8 @@ void SaveISISNexus::user() {
NXmakegroup(handle, "user_1", "NXuser");
NXopengroup(handle, "user_1", "NXuser");
saveChar("name", m_isisRaw.user.r_user, 20);
saveChar("affiliation", m_isisRaw.user.r_instit, 20);
saveChar("name", m_isisRaw->user.r_user, 20);
saveChar("affiliation", m_isisRaw->user.r_instit, 20);
NXclosegroup(handle); // user_1
}
......@@ -682,20 +685,20 @@ void SaveISISNexus::sample() {
NXmakegroup(handle, "sample", "NXsample");
NXopengroup(handle, "sample", "NXsample");
saveChar("name", m_isisRaw.spb.e_name, 40);
saveFloat("height", &m_isisRaw.spb.e_height, 1);
saveFloat("width", &m_isisRaw.spb.e_width, 1);
saveFloat("thickness", &m_isisRaw.spb.e_thick, 1);
saveChar("name", m_isisRaw->spb.e_name, 40);
saveFloat("height", &m_isisRaw->spb.e_height, 1);
saveFloat("width", &m_isisRaw->spb.e_width, 1);
saveFloat("thickness", &m_isisRaw->spb.e_thick, 1);
saveString("id", " ");
float tmp(0.0);
saveFloat("distance", &tmp, 1);
std::string shape[] = {"cylinder", "flat plate", "HRPD slab", "unknown"};
int i = m_isisRaw.spb.e_geom - 1;
int i = m_isisRaw->spb.e_geom - 1;
if (i < 0 || i > 3)
i = 3;
saveString("shape", shape[i]);
std::string type[] = {"sample+can", "empty can", "vanadium", "absorber", "nothing", "sample, no can", "unknown"};
i = m_isisRaw.spb.e_type - 1;
i = m_isisRaw->spb.e_type - 1;
if (i < 0 || i > 6)
i = 6;
saveString("type", type[i]);
......@@ -1021,28 +1024,28 @@ void SaveISISNexus::write_rpb() {
int dim[] = {32, 4};
NXmakedata(handle, "CRPB", NX_CHAR, 2, dim);
NXopendata(handle, "CRPB");
NXputdata(handle, &m_isisRaw.rpb);
NXputdata(handle, &m_isisRaw->rpb);
NXclosedata(handle);
saveInt("IRPB", &m_isisRaw.rpb, 32);
saveFloat("RRPB", &m_isisRaw.rpb, 32);
saveInt("IRPB", &m_isisRaw->rpb, 32);
saveFloat("RRPB", &m_isisRaw->rpb, 32);
}
void SaveISISNexus::write_spb() {
int dim[] = {64, 4};
NXmakedata(handle, "CSPB", NX_CHAR, 2, dim);
NXopendata(handle, "CSPB");
NXputdata(handle, &m_isisRaw.spb);
NXputdata(handle, &m_isisRaw->spb);
NXclosedata(handle);
saveInt("SPB", &m_isisRaw.spb, 64);
saveInt("ISPB", &m_isisRaw.spb, 64);
saveFloat("RSPB", &m_isisRaw.spb, 64);
saveInt("SPB", &m_isisRaw->spb, 64);
saveInt("ISPB", &m_isisRaw->spb, 64);
saveFloat("RSPB", &m_isisRaw->spb, 64);
}
void SaveISISNexus::write_vpb() {
saveInt("IVPB", &m_isisRaw.ivpb, 64);
saveFloat("RVPB", &m_isisRaw.ivpb, 64);
saveInt("IVPB", &m_isisRaw->ivpb, 64);
saveFloat("RVPB", &m_isisRaw->ivpb, 64);
}
} // namespace Mantid::DataHandling
......@@ -136,7 +136,7 @@ bool SaveReflectometryAscii::includeQResolution() const {
* @param firstColumn :: true if the value is the first column in the output
*/
template <typename T> void SaveReflectometryAscii::outputval(const T &val, bool firstColumn) {
// cppcheck-suppress syntaxError
if constexpr (std::is_floating_point<T>::value) {
if (std::isinf(val))
return outputval("inf", firstColumn);
......
......@@ -36,6 +36,11 @@ namespace DataObjects {
class DLLExport CoordTransformAffine : public Mantid::API::CoordTransform {
public:
CoordTransformAffine(const size_t inD, const size_t outD);
CoordTransformAffine(const CoordTransformAffine &);
friend void swap(CoordTransformAffine &, CoordTransformAffine &);
CoordTransformAffine &operator=(CoordTransformAffine);
CoordTransform *clone() const override;
~CoordTransformAffine() override;
std::string toXMLString() const override;
......
......@@ -46,6 +46,22 @@ CoordTransformAffine::CoordTransformAffine(const size_t inD, const size_t outD)
copyRawMatrix();
}
CoordTransformAffine::CoordTransformAffine(const CoordTransformAffine &other) : CoordTransform(other.inD, other.outD) {
this->setMatrix(other.getMatrix());
}
void swap(CoordTransformAffine &obj1, CoordTransformAffine &obj2) {
using std::swap;
swap(obj1.m_affineMatrix, obj2.m_affineMatrix);
swap(obj1.m_rawMatrix, obj2.m_rawMatrix);
swap(obj1.m_rawMemory, obj2.m_rawMemory);
}
CoordTransformAffine &CoordTransformAffine::operator=(CoordTransformAffine other) {
swap(*this, other);
return *this;
}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
......
......@@ -946,13 +946,13 @@ void EventList::setSortOrder(const EventSortType order) const { this->order = or
/** Sort events by TOF in one thread */
void EventList::sortTof() const {
// nothing to do
if (this->order == TOF_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
if (this->order == TOF_SORT)
return;