From 05a5f12cb1ac5e3900c48f45ef77b83f0db85aad Mon Sep 17 00:00:00 2001 From: Pariterre Date: Mon, 19 Aug 2019 17:45:37 +0200 Subject: [PATCH 01/28] Allow for the tag DATA_START to be in any parameters without interfering with POINT:DATA_START --- src/Group.cpp | 7 +++++-- src/Parameter.cpp | 2 +- src/ezc3d.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Group.cpp b/src/Group.cpp index da6c3bcc..68799301 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -57,9 +57,12 @@ void ezc3d::ParametersNS::GroupNS::Group::write(std::fstream &f, int groupIdx, s f.write(reinterpret_cast(&nCharToNext), 2*ezc3d::DATA_TYPE::BYTE); f.seekg(currentPos); + std::streampos defaultDataStartPosition(-1); for (size_t i=0; i < nbParameters(); ++i) - parameter(i).write(f, -groupIdx, dataStartPosition); - + if (name() != "POINT") + parameter(i).write(f, -groupIdx, dataStartPosition); + else + parameter(i).write(f, -groupIdx, defaultDataStartPosition); } int ezc3d::ParametersNS::GroupNS::Group::read(ezc3d::c3d &c3d, const ezc3d::ParametersNS::Parameters ¶ms, diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 45a2d50e..efff1aca 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -85,7 +85,7 @@ void ezc3d::ParametersNS::GroupNS::Parameter::write(std::fstream &f, int groupId writeImbricatedParameter(f, _dimension, 1); } } else { - if (!_name.compare("DATA_START")){ + if (dataStartPosition != -1 && !_name.compare("DATA_START")){ // -1 means that it is not the POINT group // This is a special case defined in the standard where you write the number of blocks up to the data dataStartPosition = f.tellg(); f.write(reinterpret_cast(&blank), 2*ezc3d::DATA_TYPE::BYTE); diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index 6cdc9151..74f77ca0 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -106,7 +106,7 @@ void ezc3d::c3d::write(const std::string& filePath) const frames.set(-1); params.group_nonConst("POINT").parameter(frames); } - std::streampos dataStartParameters; + std::streampos dataStartParameters(-1); params.write(f, dataStartParameters); // Write the data start parameter in header and parameter sections From ba07f21d45c261da805c15b89f32276a69efe00b Mon Sep 17 00:00:00 2001 From: Pariterre Date: Mon, 19 Aug 2019 18:24:29 +0200 Subject: [PATCH 02/28] Test with data_start problem are now passing --- src/Group.cpp | 2 +- src/Header.cpp | 4 ++-- src/ezc3d.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Group.cpp b/src/Group.cpp index 68799301..182b08d5 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -59,7 +59,7 @@ void ezc3d::ParametersNS::GroupNS::Group::write(std::fstream &f, int groupIdx, s std::streampos defaultDataStartPosition(-1); for (size_t i=0; i < nbParameters(); ++i) - if (name() != "POINT") + if (!name().compare("POINT")) parameter(i).write(f, -groupIdx, dataStartPosition); else parameter(i).write(f, -groupIdx, defaultDataStartPosition); diff --git a/src/Header.cpp b/src/Header.cpp index 2f3e634a..1de55772 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -174,8 +174,8 @@ void ezc3d::Header::read(ezc3d::c3d &c3d, std::fstream &file) _firstFrame = c3d.readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD); if (_firstFrame != 0) // First frame is 1-based, but some forgot hence they put 0.. _firstFrame -= 1; - _lastFrame = c3d.readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD) - 1; - if (_lastFrame != 0) // Las frame is 1-based, but some forgot hence they put 0.. + _lastFrame = c3d.readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD); + if (_lastFrame != 0) // Last frame is 1-based, but some forgot hence they put 0.. _lastFrame -= 1; // Some info diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index 74f77ca0..b0c4ecab 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -106,7 +106,7 @@ void ezc3d::c3d::write(const std::string& filePath) const frames.set(-1); params.group_nonConst("POINT").parameter(frames); } - std::streampos dataStartParameters(-1); + std::streampos dataStartParameters(-2); // -1 means not POINT group params.write(f, dataStartParameters); // Write the data start parameter in header and parameter sections From 1bfc89a462ef806e31e930be370b8cb50ebe37a7 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 10:04:59 +0200 Subject: [PATCH 03/28] Removed the nonConst tag --- example/main.cpp | 4 ++-- include/Analogs.h | 2 +- include/Data.h | 2 +- include/Frame.h | 4 ++-- include/Group.h | 4 ++-- include/Parameters.h | 4 ++-- include/Point.h | 2 +- include/Points.h | 2 +- include/Subframe.h | 2 +- src/Analogs.cpp | 2 +- src/Data.cpp | 2 +- src/Frame.cpp | 4 ++-- src/Group.cpp | 6 +++--- src/Parameters.cpp | 10 +++++----- src/Point.cpp | 2 +- src/Points.cpp | 2 +- src/Subframe.cpp | 2 +- src/ezc3d.cpp | 40 ++++++++++++++++++++-------------------- 18 files changed, 48 insertions(+), 48 deletions(-) diff --git a/example/main.cpp b/example/main.cpp index 54a96d50..db9c546a 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -54,7 +54,7 @@ int main() ezc3d::DataNS::AnalogsNS::Channel c(subframes_analog.channel(0)); c.data(sf + 1); subframes_analog.channel(c, 0); - frame.analogs_nonConst().subframe(subframes_analog); + frame.analogs().subframe(subframes_analog); } for (size_t f = 0; f < c3d.data().nbFrames(); ++f) frames_analog.push_back(frame); @@ -189,7 +189,7 @@ int main() newChannel.data(sf+1); ezc3d::DataNS::AnalogsNS::SubFrame subframes_analog; subframes_analog.channel(newChannel); - frame.analogs_nonConst().subframe(subframes_analog); + frame.analogs().subframe(subframes_analog); } for (size_t f=0; f data_nonConst(); + std::vector data(); /// /// \brief Get the X component of the 3D point diff --git a/include/Points.h b/include/Points.h index c2977ca9..2dbc4a6e 100644 --- a/include/Points.h +++ b/include/Points.h @@ -76,7 +76,7 @@ class EZC3D_API ezc3d::DataNS::Points3dNS::Points{ /// /// Throw a std::out_of_range exception if idx is larger than the number of frames /// - ezc3d::DataNS::Points3dNS::Point& point_nonConst(size_t idx); + ezc3d::DataNS::Points3dNS::Point& point(size_t idx); /// /// \brief Add/replace a point to the points data set diff --git a/include/Subframe.h b/include/Subframe.h index 314cc6d5..0533c7b2 100644 --- a/include/Subframe.h +++ b/include/Subframe.h @@ -78,7 +78,7 @@ class EZC3D_API ezc3d::DataNS::AnalogsNS::SubFrame{ /// /// Throw a std::out_of_range exception if idx is larger than the number of channels /// - ezc3d::DataNS::AnalogsNS::Channel& channel_nonConst(size_t idx); + ezc3d::DataNS::AnalogsNS::Channel& channel(size_t idx); /// /// \brief Add/replace a channel to the analog subframe data set diff --git a/src/Analogs.cpp b/src/Analogs.cpp index 8fa5e3cd..05a6694e 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -52,7 +52,7 @@ const ezc3d::DataNS::AnalogsNS::SubFrame& ezc3d::DataNS::AnalogsNS::Analogs::sub } } -ezc3d::DataNS::AnalogsNS::SubFrame &ezc3d::DataNS::AnalogsNS::Analogs::subframe_nonConst(size_t idx) +ezc3d::DataNS::AnalogsNS::SubFrame &ezc3d::DataNS::AnalogsNS::Analogs::subframe(size_t idx) { try { return _subframe.at(idx); diff --git a/src/Data.cpp b/src/Data.cpp index ad2631a3..e19226ab 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -122,7 +122,7 @@ const ezc3d::DataNS::Frame& ezc3d::DataNS::Data::frame(size_t idx) const } } -ezc3d::DataNS::Frame &ezc3d::DataNS::Data::frame_nonConst(size_t idx) +ezc3d::DataNS::Frame &ezc3d::DataNS::Data::frame(size_t idx) { try { return _frames.at(idx); diff --git a/src/Frame.cpp b/src/Frame.cpp index 1bafe690..578de52f 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -32,7 +32,7 @@ const ezc3d::DataNS::Points3dNS::Points& ezc3d::DataNS::Frame::points() const return *_points; } -ezc3d::DataNS::Points3dNS::Points &ezc3d::DataNS::Frame::points_nonConst() const +ezc3d::DataNS::Points3dNS::Points &ezc3d::DataNS::Frame::points() { return *_points; } @@ -42,7 +42,7 @@ const ezc3d::DataNS::AnalogsNS::Analogs& ezc3d::DataNS::Frame::analogs() const return *_analogs; } -ezc3d::DataNS::AnalogsNS::Analogs &ezc3d::DataNS::Frame::analogs_nonConst() const +ezc3d::DataNS::AnalogsNS::Analogs &ezc3d::DataNS::Frame::analogs() { return *_analogs; } diff --git a/src/Group.cpp b/src/Group.cpp index 182b08d5..caa3e494 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -155,7 +155,7 @@ const ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Gro } } -ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Group::parameter_nonConst(size_t idx) +ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Group::parameter(size_t idx) { try { return _parameters.at(idx); @@ -172,9 +172,9 @@ const ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Gro return parameter(parameterIdx(parameterName)); } -ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Group::parameter_nonConst(std::string parameterName) +ezc3d::ParametersNS::GroupNS::Parameter &ezc3d::ParametersNS::GroupNS::Group::parameter(std::string parameterName) { - return parameter_nonConst(parameterIdx(parameterName)); + return parameter(parameterIdx(parameterName)); } int ezc3d::ParametersNS::GroupNS::Group::parameter(ezc3d::c3d &c3d, const Parameters ¶ms, std::fstream &file, int nbCharInName) diff --git a/src/Parameters.cpp b/src/Parameters.cpp index b64bc595..985fba5a 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -73,9 +73,9 @@ ezc3d::ParametersNS::Parameters::Parameters(ezc3d::c3d &c3d, std::fstream &file) // Group ID always negative for groups and positive parameter of group ID if (id < 0) - nextParamByteInFile = group_nonConst(static_cast(abs(id)-1)).read(c3d, *this, file, nbCharInName); + nextParamByteInFile = group(static_cast(abs(id)-1)).read(c3d, *this, file, nbCharInName); else - nextParamByteInFile = group_nonConst(static_cast(id-1)).parameter(c3d, *this, file, nbCharInName); + nextParamByteInFile = group(static_cast(id-1)).parameter(c3d, *this, file, nbCharInName); } } @@ -321,7 +321,7 @@ const ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::grou } } -ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::group_nonConst(size_t idx) +ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::group(size_t idx) { try { return _groups.at(idx); @@ -338,9 +338,9 @@ const ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::grou return group(groupIdx(groupName)); } -ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::group_nonConst(const std::string &groupName) +ezc3d::ParametersNS::GroupNS::Group &ezc3d::ParametersNS::Parameters::group(const std::string &groupName) { - return group_nonConst(groupIdx(groupName)); + return group(groupIdx(groupName)); } void ezc3d::ParametersNS::Parameters::group(const ezc3d::ParametersNS::GroupNS::Group &g) diff --git a/src/Point.cpp b/src/Point.cpp index 9b76f328..cf8e4bc6 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -41,7 +41,7 @@ const std::vector ezc3d::DataNS::Points3dNS::Point::data() const return _data; } -std::vector ezc3d::DataNS::Points3dNS::Point::data_nonConst() +std::vector ezc3d::DataNS::Points3dNS::Point::data() { return _data; } diff --git a/src/Points.cpp b/src/Points.cpp index bffd0473..91808517 100644 --- a/src/Points.cpp +++ b/src/Points.cpp @@ -49,7 +49,7 @@ const ezc3d::DataNS::Points3dNS::Point& ezc3d::DataNS::Points3dNS::Points::point } } -ezc3d::DataNS::Points3dNS::Point &ezc3d::DataNS::Points3dNS::Points::point_nonConst(size_t idx) +ezc3d::DataNS::Points3dNS::Point &ezc3d::DataNS::Points3dNS::Points::point(size_t idx) { try { return _points.at(idx); diff --git a/src/Subframe.cpp b/src/Subframe.cpp index ca234f85..b88e2350 100644 --- a/src/Subframe.cpp +++ b/src/Subframe.cpp @@ -50,7 +50,7 @@ const ezc3d::DataNS::AnalogsNS::Channel &ezc3d::DataNS::AnalogsNS::SubFrame::cha } } -ezc3d::DataNS::AnalogsNS::Channel &ezc3d::DataNS::AnalogsNS::SubFrame::channel_nonConst(size_t idx) +ezc3d::DataNS::AnalogsNS::Channel &ezc3d::DataNS::AnalogsNS::SubFrame::channel(size_t idx) { try { return _channels.at(idx); diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index b0c4ecab..06eedf3b 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -104,7 +104,7 @@ void ezc3d::c3d::write(const std::string& filePath) const if (nFrames > 0xFFFF){ ezc3d::ParametersNS::GroupNS::Parameter frames("FRAMES"); frames.set(-1); - params.group_nonConst("POINT").parameter(frames); + params.group("POINT").parameter(frames); } std::streampos dataStartParameters(-2); // -1 means not POINT group params.write(f, dataStartParameters); @@ -395,7 +395,7 @@ void ezc3d::c3d::parameter(const std::string &groupName, const ezc3d::Parameters idx = parameters().groupIdx(groupName); } - _parameters->group_nonConst(idx).parameter(p); + _parameters->group(idx).parameter(p); // Do a sanity check on the header if important stuff like number of frames or number of elements is changed updateHeader(); @@ -403,12 +403,12 @@ void ezc3d::c3d::parameter(const std::string &groupName, const ezc3d::Parameters void ezc3d::c3d::lockGroup(const std::string &groupName) { - _parameters->group_nonConst(groupName).lock(); + _parameters->group(groupName).lock(); } void ezc3d::c3d::unlockGroup(const std::string &groupName) { - _parameters->group_nonConst(groupName).unlock(); + _parameters->group(groupName).unlock(); } void ezc3d::c3d::frame(const ezc3d::DataNS::Frame &f, size_t idx) @@ -487,7 +487,7 @@ void ezc3d::c3d::point(const std::vector& ptsNames, const std::vect throw std::invalid_argument("The point you try to create already exists in the data set"); for (size_t f=0; fframe_nonConst(f).points_nonConst().point(frames[f].points().point(idx)); + _data->frame(f).points().point(frames[f].points().point(idx)); } updateParameters(ptsNames); } @@ -502,7 +502,7 @@ void ezc3d::c3d::analog(const std::string &name) ezc3d::DataNS::Frame frame; dummy_subframes.channel(emptyChannel); for (size_t sf = 0; sf < header().nbAnalogByFrame(); ++sf) - frame.analogs_nonConst().subframe(dummy_subframes); + frame.analogs().subframe(dummy_subframes); for (size_t f=0; f &chanNames, const std::ve for (size_t f=0; f < data().nbFrames(); ++f){ for (size_t sf=0; sf < header().nbAnalogByFrame(); ++sf){ - _data->frame_nonConst(f).analogs_nonConst().subframe_nonConst(sf).channel(frames[f].analogs().subframe(sf).channel(idx)); + _data->frame(f).analogs().subframe(sf).channel(frames[f].analogs().subframe(sf).channel(idx)); } } } @@ -581,11 +581,11 @@ void ezc3d::c3d::updateHeader() void ezc3d::c3d::updateParameters(const std::vector &newPoints, const std::vector &newAnalogs) { // If frames has been added - ezc3d::ParametersNS::GroupNS::Group& grpPoint(_parameters->group_nonConst(parameters().groupIdx("POINT"))); + ezc3d::ParametersNS::GroupNS::Group& grpPoint(_parameters->group(parameters().groupIdx("POINT"))); size_t nFrames(data().nbFrames()); if (nFrames != static_cast(grpPoint.parameter("FRAMES").valuesAsInt()[0])){ size_t idx(grpPoint.parameterIdx("FRAMES")); - grpPoint.parameter_nonConst(idx).set(nFrames); + grpPoint.parameter(idx).set(nFrames); } // If points has been added @@ -595,7 +595,7 @@ void ezc3d::c3d::updateParameters(const std::vector &newPoints, con else nPoints = parameters().group("POINT").parameter("LABELS").valuesAsString().size() + newPoints.size(); if (nPoints != static_cast(grpPoint.parameter("USED").valuesAsInt()[0])){ - grpPoint.parameter_nonConst("USED").set(nPoints); + grpPoint.parameter("USED").set(nPoints); size_t idxLabels(grpPoint.parameterIdx("LABELS")); size_t idxDescriptions(grpPoint.parameterIdx("DESCRIPTIONS")); @@ -620,13 +620,13 @@ void ezc3d::c3d::updateParameters(const std::vector &newPoints, con descriptions.push_back(""); units.push_back("mm"); } - grpPoint.parameter_nonConst(idxLabels).set(labels); - grpPoint.parameter_nonConst(idxDescriptions).set(descriptions); - grpPoint.parameter_nonConst(idxUnits).set(units); + grpPoint.parameter(idxLabels).set(labels); + grpPoint.parameter(idxDescriptions).set(descriptions); + grpPoint.parameter(idxUnits).set(units); } // If analogous data has been added - ezc3d::ParametersNS::GroupNS::Group& grpAnalog(_parameters->group_nonConst(parameters().groupIdx("ANALOG"))); + ezc3d::ParametersNS::GroupNS::Group& grpAnalog(_parameters->group(parameters().groupIdx("ANALOG"))); size_t nAnalogs; if (data().nbFrames() > 0){ if (data().frame(0).analogs().nbSubframes() > 0) @@ -639,7 +639,7 @@ void ezc3d::c3d::updateParameters(const std::vector &newPoints, con // Should always be greater than 0..., but we have to take in account Optotrak lazyness if (parameters().group("ANALOG").nbParameters()){ if (nAnalogs != static_cast(grpAnalog.parameter("USED").valuesAsInt()[0])){ - grpAnalog.parameter_nonConst("USED").set(nAnalogs); + grpAnalog.parameter("USED").set(nAnalogs); size_t idxLabels(static_cast(grpAnalog.parameterIdx("LABELS"))); size_t idxDescriptions(static_cast(grpAnalog.parameterIdx("DESCRIPTIONS"))); @@ -661,26 +661,26 @@ void ezc3d::c3d::updateParameters(const std::vector &newPoints, con labels.push_back(name); descriptions.push_back(""); } - grpAnalog.parameter_nonConst(idxLabels).set(labels); - grpAnalog.parameter_nonConst(idxDescriptions).set(descriptions); + grpAnalog.parameter(idxLabels).set(labels); + grpAnalog.parameter(idxDescriptions).set(descriptions); size_t idxScale(grpAnalog.parameterIdx("SCALE")); std::vector scales(grpAnalog.parameter(idxScale).valuesAsFloat()); for (size_t i = grpAnalog.parameter(idxScale).valuesAsFloat().size(); i < nAnalogs; ++i) scales.push_back(1); - grpAnalog.parameter_nonConst(idxScale).set(scales); + grpAnalog.parameter(idxScale).set(scales); size_t idxOffset(grpAnalog.parameterIdx("OFFSET")); std::vector offset(grpAnalog.parameter(idxOffset).valuesAsInt()); for (size_t i = grpAnalog.parameter(idxOffset).valuesAsInt().size(); i < nAnalogs; ++i) offset.push_back(0); - grpAnalog.parameter_nonConst(idxOffset).set(offset); + grpAnalog.parameter(idxOffset).set(offset); size_t idxUnits(grpAnalog.parameterIdx("UNITS")); std::vector units(grpAnalog.parameter(idxUnits).valuesAsString()); for (size_t i = grpAnalog.parameter(idxUnits).valuesAsString().size(); i < nAnalogs; ++i) units.push_back("V"); - grpAnalog.parameter_nonConst(idxUnits).set(units); + grpAnalog.parameter(idxUnits).set(units); } } updateHeader(); From 4fff5d59f396490bd8c61e6685d2798521a204e6 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 10:05:16 +0200 Subject: [PATCH 04/28] Corrected a documentation --- include/ezc3d.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/ezc3d.h b/include/ezc3d.h index 5621a433..f2a8632e 100644 --- a/include/ezc3d.h +++ b/include/ezc3d.h @@ -236,8 +236,7 @@ class EZC3D_API ezc3d::c3d { /// /// \brief Write the data_start parameter where demanded /// \param file opened file stream to be read - /// \param dataPosition The position in block of the data - /// \param paramPosition The position in byte to write the + /// \param dataStartPosition The position in block of the data /// \param type The type of data to write /// void writeDataStart(std::fstream &file, From 9cbbf1d2b8b6cd530ce8a9df6e206f7e7b6a93d6 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 10:07:14 +0200 Subject: [PATCH 05/28] When a parameter is empty XSens is sloppy according to the data type. The returns function of a parameter now checks if it is empty and returns it anyway if it is. --- include/Parameter.h | 7 +++++++ src/Parameter.cpp | 32 +++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/include/Parameter.h b/include/Parameter.h index ca35f842..fe8bfe24 100644 --- a/include/Parameter.h +++ b/include/Parameter.h @@ -146,6 +146,13 @@ class EZC3D_API ezc3d::ParametersNS::GroupNS::Parameter{ //---- DATA ----// protected: + bool _isEmpty; ///< If the parameter is empty + + /// + /// \brief Set the empty flag to true if the parameter is actually empty + /// + void setEmptyFlag(); + std::vector _param_data_int; ///< Parameter values if the parameter type is DATA_TYPE::BYTE of DATA_TYPE::INT std::vector _param_data_float; ///< Parameter values if the parameter type is DATA_TYPE::FLOAT std::vector _param_data_string; ///< Parameter values if the parameter type is DATA_TYPE::CHAR diff --git a/src/Parameter.cpp b/src/Parameter.cpp index efff1aca..2681fcf3 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -14,7 +14,8 @@ ezc3d::ParametersNS::GroupNS::Parameter::Parameter(const std::string &name, cons _name(name), _description(description), _isLocked(false), - _data_type(ezc3d::DATA_TYPE::NO_DATA_TYPE) + _data_type(ezc3d::DATA_TYPE::NO_DATA_TYPE), + _isEmpty(true) { } @@ -185,6 +186,7 @@ int ezc3d::ParametersNS::GroupNS::Parameter::read(ezc3d::c3d &c3d, const Paramet // Byte 6+nbCharInName ==> Group description if (nbCharInDesc) _description = c3d.readString(file, static_cast(nbCharInDesc)); + setEmptyFlag(); // Return how many bytes return nextParamByteInFile; @@ -250,6 +252,14 @@ bool ezc3d::ParametersNS::GroupNS::Parameter::isDimensionConsistent(size_t dataS return false; } +void ezc3d::ParametersNS::GroupNS::Parameter::setEmptyFlag() +{ + if (_dimension.size() ==0 || (_dimension.size() == 1 && _dimension[0] == 0)) + _isEmpty = true; + else + _isEmpty = false; +} + ezc3d::DATA_TYPE ezc3d::ParametersNS::GroupNS::Parameter::type() const { return _data_type; @@ -278,6 +288,7 @@ void ezc3d::ParametersNS::GroupNS::Parameter::set(const std::vector &data, _data_type = ezc3d::DATA_TYPE::INT; _param_data_int = data; _dimension = dimensionCopy; + setEmptyFlag(); } void ezc3d::ParametersNS::GroupNS::Parameter::set(float data) @@ -300,9 +311,11 @@ void ezc3d::ParametersNS::GroupNS::Parameter::set(const std::vector &data } if (!isDimensionConsistent(data.size(), dimensionCopy)) throw std::range_error("Dimension of the data does not correspond to sent dimensions"); + _data_type = ezc3d::DATA_TYPE::FLOAT; _param_data_float = data; _dimension = dimensionCopy; + setEmptyFlag(); } void ezc3d::ParametersNS::GroupNS::Parameter::set(const std::string& data) @@ -331,33 +344,34 @@ void ezc3d::ParametersNS::GroupNS::Parameter::set(const std::vector _data_type = ezc3d::DATA_TYPE::CHAR; _param_data_string = data; _dimension = dimensionWithStrLen; + setEmptyFlag(); } const std::vector &ezc3d::ParametersNS::GroupNS::Parameter::valuesAsByte() const { - if (_data_type != DATA_TYPE::BYTE) - throw std::invalid_argument("This parameter is not a BYTE"); + if (!_isEmpty && _data_type != DATA_TYPE::BYTE) + throw std::invalid_argument(_name + " parameter is not a BYTE"); return _param_data_int; } const std::vector &ezc3d::ParametersNS::GroupNS::Parameter::valuesAsInt() const { - if (_data_type != DATA_TYPE::INT) - throw std::invalid_argument("This parameter is not an INT"); + if (!_isEmpty && _data_type != DATA_TYPE::INT) + throw std::invalid_argument(_name + " parameter is not an INT"); return _param_data_int; } const std::vector &ezc3d::ParametersNS::GroupNS::Parameter::valuesAsFloat() const { - if (_data_type != DATA_TYPE::FLOAT) - throw std::invalid_argument("This parameter is not a FLOAT"); + if (!_isEmpty && _data_type != DATA_TYPE::FLOAT) + throw std::invalid_argument(_name + " parameter is not a FLOAT"); return _param_data_float; } const std::vector& ezc3d::ParametersNS::GroupNS::Parameter::valuesAsString() const { - if (_data_type != DATA_TYPE::CHAR) - throw std::invalid_argument("This parameter is not string"); + if (!_isEmpty && _data_type != DATA_TYPE::CHAR) + throw std::invalid_argument(_name + " parameter is not string"); return _param_data_string; } From 9b9429df9fa51ac318a6b4812fb2025ccd759cb1 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 10:40:55 +0200 Subject: [PATCH 06/28] Repaired a windows compiling error where comparison cast are similar --- src/Parameter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 2681fcf3..1fbbbaee 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -86,7 +86,7 @@ void ezc3d::ParametersNS::GroupNS::Parameter::write(std::fstream &f, int groupId writeImbricatedParameter(f, _dimension, 1); } } else { - if (dataStartPosition != -1 && !_name.compare("DATA_START")){ // -1 means that it is not the POINT group + if (dataStartPosition != static_cast(-1) && !_name.compare("DATA_START")){ // -1 means that it is not the POINT group // This is a special case defined in the standard where you write the number of blocks up to the data dataStartPosition = f.tellg(); f.write(reinterpret_cast(&blank), 2*ezc3d::DATA_TYPE::BYTE); From 13fe11a24011703625e90deaf75d62aa187e9d3a Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 10:41:41 +0200 Subject: [PATCH 07/28] Adjusted test for the new way of returning params --- test/test_ezc3d.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index 321ddbac..f5ae0491 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -420,11 +420,40 @@ TEST(c3dModifier, specificParameters){ EXPECT_THROW(new_c3d.c3d.parameters().group("POINT").parameter(nPointParams), std::out_of_range); EXPECT_THROW(new_c3d.c3d.parameters().group("POINT").parameterIdx("ThisIsNotARealParameter"), std::invalid_argument); - // Try to read a parameter into the wrong format - EXPECT_THROW(p.valuesAsByte(), std::invalid_argument); - EXPECT_THROW(p.valuesAsInt(), std::invalid_argument); - EXPECT_THROW(p.valuesAsFloat(), std::invalid_argument); - EXPECT_THROW(p.valuesAsString(), std::invalid_argument); + // Reading an empty parameter is actually type irrelevant + EXPECT_NO_THROW(p.valuesAsByte()); + EXPECT_NO_THROW(p.valuesAsInt()); + EXPECT_NO_THROW(p.valuesAsFloat()); + EXPECT_NO_THROW(p.valuesAsString()); + + { + // There is no pNonEmptyByte, since the only way to declare a byte + // is from the .c3d file itself. Otherwise it is always an int + + ezc3d::ParametersNS::GroupNS::Parameter pNonEmptyInt; + pNonEmptyInt.name("NewIntParam"); + pNonEmptyInt.set(std::vector(1)); + EXPECT_THROW(pNonEmptyInt.valuesAsByte(), std::invalid_argument); + EXPECT_NO_THROW(pNonEmptyInt.valuesAsInt()); + EXPECT_THROW(pNonEmptyInt.valuesAsFloat(), std::invalid_argument); + EXPECT_THROW(pNonEmptyInt.valuesAsString(), std::invalid_argument); + + ezc3d::ParametersNS::GroupNS::Parameter pNonEmptyFloat; + pNonEmptyFloat.name("NewFloatParam"); + pNonEmptyFloat.set(std::vector(1)); + EXPECT_THROW(pNonEmptyFloat.valuesAsByte(), std::invalid_argument); + EXPECT_THROW(pNonEmptyFloat.valuesAsInt(), std::invalid_argument); + EXPECT_NO_THROW(pNonEmptyFloat.valuesAsFloat()); + EXPECT_THROW(pNonEmptyFloat.valuesAsString(), std::invalid_argument); + + ezc3d::ParametersNS::GroupNS::Parameter pNonEmptyChar; + pNonEmptyChar.name("NewCharParam"); + pNonEmptyChar.set(std::vector(1)); + EXPECT_THROW(pNonEmptyChar.valuesAsByte(), std::invalid_argument); + EXPECT_THROW(pNonEmptyChar.valuesAsInt(), std::invalid_argument); + EXPECT_THROW(pNonEmptyChar.valuesAsFloat(), std::invalid_argument); + EXPECT_NO_THROW(pNonEmptyChar.valuesAsString()); + } // Lock and unlock a parameter EXPECT_EQ(p.isLocked(), false); From 956747162eab038d5f0020902d36ddd40e476d61 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 11:14:28 +0200 Subject: [PATCH 08/28] Increased coverage --- test/test_ezc3d.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index f5ae0491..85e6ea69 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -535,6 +535,7 @@ TEST(c3dModifier, addPoints) { // DATA for (size_t f = 0; f < new_c3d.nFrames; ++f){ + ASSERT_EQ(new_c3d.c3d.data().frame(f).points().isempty(), false); for (size_t m = 0; m < new_c3d.nPoints; ++m){ size_t pointIdx(new_c3d.c3d.pointIdx(new_c3d.pointNames[m])); EXPECT_FLOAT_EQ(new_c3d.c3d.data().frame(f).points().point(pointIdx).x(), static_cast(2*f+3*m+1) / static_cast(7.0)); @@ -548,6 +549,7 @@ TEST(c3dModifier, addPoints) { EXPECT_FLOAT_EQ(new_c3d.c3d.data().frame(f).points().point(pointIdx).z(), data[2]); EXPECT_FLOAT_EQ(new_c3d.c3d.data().frame(f).points().point(pointIdx).residual(), 0); } + ASSERT_EQ(new_c3d.c3d.data().frame(f).analogs().isempty(), true); } // Add frame with a new point with not enough frames @@ -739,11 +741,14 @@ TEST(c3dModifier, addAnalogs) { } // DATA - for (size_t f = 0; f < new_c3d.nFrames; ++f) + for (size_t f = 0; f < new_c3d.nFrames; ++f){ + ASSERT_EQ(new_c3d.c3d.data().frame(f).points().isempty(), true); + ASSERT_EQ(new_c3d.c3d.data().frame(f).analogs().isempty(), false); for (size_t sf = 0; sf < new_c3d.nSubframes; ++sf) for (size_t c = 0; c < new_c3d.nAnalogs; ++c) EXPECT_FLOAT_EQ(new_c3d.c3d.data().frame(f).analogs().subframe(sf).channel(c).data(), static_cast(2*f+3*sf+4*c+1) / static_cast(7.0)); + } } TEST(c3dModifier, removeAnalog){ @@ -1063,6 +1068,9 @@ TEST(c3dModifier, specificFrames){ // Get a frame and some inexistant one EXPECT_THROW(new_c3d.c3d.data().frame(new_c3d.nFrames), std::out_of_range); + // Try to get a all subframes and an out-of-range subframe + EXPECT_NO_THROW(new_c3d.c3d.data().frame(0).analogs().subframes()); + EXPECT_THROW(new_c3d.c3d.data().frame(0).analogs().subframe(0), std::out_of_range); // HEADER // Things that should remain as default From c9ad20728b07b5756af86e8f72dbc4852b0cf492 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 28 Aug 2019 14:20:51 +0200 Subject: [PATCH 09/28] Rechanged the double initiation on Windows --- src/Parameter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 1fbbbaee..670c7d54 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -86,7 +86,7 @@ void ezc3d::ParametersNS::GroupNS::Parameter::write(std::fstream &f, int groupId writeImbricatedParameter(f, _dimension, 1); } } else { - if (dataStartPosition != static_cast(-1) && !_name.compare("DATA_START")){ // -1 means that it is not the POINT group + if (static_cast(dataStartPosition) != -1 && !_name.compare("DATA_START")){ // -1 means that it is not the POINT group // This is a special case defined in the standard where you write the number of blocks up to the data dataStartPosition = f.tellg(); f.write(reinterpret_cast(&blank), 2*ezc3d::DATA_TYPE::BYTE); From ea623d72ef0527e029ae4101c5eda9fccaab6622 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 4 Sep 2019 10:08:46 +0200 Subject: [PATCH 10/28] Moved CMake of Tests and Docs into a proper directory --- .gitignore | 2 +- CMakeLists.txt | 121 ++------------------------------------------ docs/CMakeLists.txt | 18 +++++++ docs/Doxyfile.in | 10 ++-- test/CMakeLists.txt | 90 ++++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 122 deletions(-) create mode 100644 docs/CMakeLists.txt create mode 100644 test/CMakeLists.txt diff --git a/.gitignore b/.gitignore index c6e5e5a4..44b27a28 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ __pycache__ # Testing suite Testing -test/c3dFiles/C3dTestSuite +test/c3dFiles/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c8a8d89..2e664138 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,135 +47,24 @@ install(DIRECTORY include DESTINATION ${${PROJECT_NAME}_INCLUDE_FOLDER}) # Add binding subdirectory add_subdirectory(binding) -# Add the example if asked +# Examples if(NOT WIN32) - set(BUILD_EXAMPLE TRUE CACHE BOOL "Build a C++ example") + option(BUILD_EXAMPLE "Build a C++ example" ON) if (BUILD_EXAMPLE) add_subdirectory(example) endif() endif(NOT WIN32) - -################################ -# Documentation -################################ - -# first we can indicate the documentation build as an option and set it to ON by default +# Doc option(BUILD_DOC "Build documentation" OFF) - if (BUILD_DOC) - # check if Doxygen is installed - find_package(Doxygen) - if (DOXYGEN_FOUND) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - - # note the option ALL which allows to build the docs together with the application - add_custom_target( doc_doxygen ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) - else (DOXYGEN_FOUND) - message("Doxygen need to be installed to generate the doxygen documentation") - endif (DOXYGEN_FOUND) + add_subdirectory(docs) endif (BUILD_DOC) - -################################ # Testing -################################ - -# Options. Turn on with 'cmake -DBUILD_TESTS=ON'. option(BUILD_TESTS "Build all tests." OFF) # Makes boolean 'test' available. - if (BUILD_TESTS) - # Download gtest if necessary - set(RELATIVE_PATH_TO_GTEST external/gtest) - find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_CURRENT_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest) - - if((NOT GTEST_INCLUDE_DIR) OR (NOT EXISTS ${GTEST_INCLUDE_DIR})) - # we couldn't find the header files for gtest or they don't exist - message("Unable to find gtest") - - # we have a submodule setup for gtest, assume it is under external/gtest - # now we need to clone this submodule - execute_process(COMMAND git submodule update --init -- external/gtest - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - - find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_CURRENT_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest) - endif() - - # Prevent overriding the parent project's compiler/linker - # settings on Windows - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This defines - # the gtest and gtest_main targets. - set(BUILD_GMOCK OFF) - set(INSTALL_GTEST OFF) - add_subdirectory(${RELATIVE_PATH_TO_GTEST} - ${CMAKE_BINARY_DIR}/gtest - EXCLUDE_FROM_ALL) - - ############## - # Unit Tests - ############## - enable_testing() - - file(GLOB TEST_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp) - add_executable(runUnitTests ${TEST_SRC_FILES}) - - # Standard linking to gtest stuff. - target_link_libraries(runUnitTests gtest_main) - - # Extra linking for the project. - target_link_libraries(runUnitTests ${PROJECT_NAME}) - - # This is so you can do 'make test' to see all your tests run, instead of - # manually running the executable runUnitTests to see those specific tests. - add_test(UnitTests runUnitTests) - - if (CMAKE_BUILD_TYPE STREQUAL "Coverage") - set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.travis/cmake) - - include(CodeCoverage) - setup_target_for_coverage(${PROJECT_NAME}_coverage runUnitTests coverage) - - SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") - endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage" - - # Download and copy c3d test files from test test suite of c3d.org and add them to the local test files - IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite) - set(TEST_FILES_TO_DOWNLOAD Sample01.zip Sample02.zip) - foreach(FILE ${TEST_FILES_TO_DOWNLOAD}) - file( - DOWNLOAD https://www.c3d.org/data/${FILE} - ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FILE} - TIMEOUT 60 # seconds - TLS_VERIFY ON - ) - get_filename_component(FOLDER_NAME ${FILE} NAME_WE) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}) - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar -xf ../${FILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/ - ) - file(GLOB C3D_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/*.c3d) - file(COPY ${C3D_TEST_FILES} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/) - endforeach() - endif() - - # Copy also some local c3d test files - file(GLOB C3D_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/*.c3d) - file(COPY ${C3D_TEST_FILES} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/) + add_subdirectory(test) endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 00000000..ed11b774 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,18 @@ +set(MASTER_PROJECT_NAME ${PROJECT_NAME}) +project(${MASTER_PROJECT_NAME}_docs) + +# check if Doxygen is installed +find_package(Doxygen REQUIRED) +# set input and output files +set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) +set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + +# request to configure the file +configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + +# note the option ALL which allows to build the docs together with the application +add_custom_target( doc_doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM ) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index bf138a70..7a455ddd 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1,7 +1,7 @@ -OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs/ -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/include/ -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/src/ -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/docs +OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/ +INPUT += @CMAKE_SOURCE_DIR@/include/ +INPUT += @CMAKE_SOURCE_DIR@/src/ +INPUT += @CMAKE_SOURCE_DIR@/docs # Remove dll_export that confuses Doxygen ENABLE_PREPROCESSING = YES @@ -15,4 +15,4 @@ FULL_PATH_NAMES = NO SOURCE_BROWSER = YES # Add the Readme file -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/README.md +INPUT += @CMAKE_SOURCE_DIR@/README.md diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..6f414803 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,90 @@ +set(MASTER_PROJECT_NAME ${PROJECT_NAME}) +project(${MASTER_PROJECT_NAME}_test) + +# Download gtest if necessary +set(RELATIVE_PATH_TO_GTEST external/gtest) +find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest) + +if((NOT GTEST_INCLUDE_DIR) OR (NOT EXISTS ${GTEST_INCLUDE_DIR})) + # we couldn't find the header files for gtest or they don't exist + message("Unable to find gtest") + + # we have a submodule setup for gtest, assume it is under external/gtest + # now we need to clone this submodule + execute_process(COMMAND git submodule update --init -- external/gtest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest) +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +set(BUILD_GMOCK OFF) +set(INSTALL_GTEST OFF) +add_subdirectory(${CMAKE_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST} + ${CMAKE_BINARY_DIR}/gtest + EXCLUDE_FROM_ALL) + +############## +# Unit Tests +############## +enable_testing() +file(GLOB TEST_SRC_FILES ${CMAKE_SOURCE_DIR}/test/*.cpp) +add_executable(runUnitTests ${TEST_SRC_FILES}) +add_dependencies(runUnitTests ${MASTER_PROJECT_NAME}) + +# headers for the project +target_include_directories(runUnitTests PUBLIC + ${CMAKE_SOURCE_DIR}/include +) + +# Standard linking to gtest stuff. +target_link_libraries(runUnitTests gtest_main) + +# Extra linking for the project. +target_link_libraries(runUnitTests ${MASTER_PROJECT_NAME}) + +# This is so you can do 'make test' to see all your tests run, instead of +# manually running the executable runUnitTests to see those specific tests. +add_test(UnitTests runUnitTests) + +if (CMAKE_BUILD_TYPE STREQUAL "Coverage") + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/.travis/cmake) + + include(CodeCoverage) + setup_target_for_coverage(${MASTER_PROJECT_NAME}_coverage runUnitTests coverage) + + SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") + SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage" + +# Download and copy c3d test files from test test suite of c3d.org and add them to the local test files +set(TEST_FILES_TO_DOWNLOAD Sample01.zip Sample02.zip) +foreach(FILE ${TEST_FILES_TO_DOWNLOAD}) + get_filename_component(FOLDER_NAME ${FILE} NAME_WE) + IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite) + file( + DOWNLOAD https://www.c3d.org/data/${FILE} + ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FILE} + TIMEOUT 60 # seconds + TLS_VERIFY ON + ) + file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}) + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar -xf ../${FILE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/ + ) + endif() + file(GLOB C3D_TEST_FILES ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/*.c3d) + file(COPY ${C3D_TEST_FILES} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/) +endforeach() + +# Copy also some local c3d test files +file(GLOB C3D_TEST_FILES ${CMAKE_SOURCE_DIR}/test/c3dFiles/*.c3d) +file(COPY ${C3D_TEST_FILES} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/) From 31c1d22ead5fef9a69db9f5966fcb661b84fc4a7 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 4 Sep 2019 10:09:01 +0200 Subject: [PATCH 11/28] Added an uninstall target --- CMakeLists.txt | 17 ++++++++++++++--- cmake_uninstall.cmake.in | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e664138..706273f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_debug") # Add headers target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) -# Installation +# Install target if(WIN32) set(${PROJECT_NAME}_LIB_FOLDER Lib) set(${PROJECT_NAME}_BIN_FOLDER bin) @@ -43,8 +43,19 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${${PROJECT_NAME}_LIB_FOLDER} ) install(DIRECTORY include DESTINATION ${${PROJECT_NAME}_INCLUDE_FOLDER}) - -# Add binding subdirectory + +# uninstall target +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() + +# Binders add_subdirectory(binding) # Examples diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 00000000..26b84397 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) + From 0871be240ac85ce71a6249fbb5f43e3151ef9fff Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 09:45:43 +0200 Subject: [PATCH 12/28] If nbAnalogs is 0, then the type of ANALOG:SCALE is irrelevant (fix for Xsens sloppiness) --- src/Data.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Data.cpp b/src/Data.cpp index e19226ab..9b220da7 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -31,8 +31,12 @@ ezc3d::DataNS::Data::Data(ezc3d::c3d &c3d, std::fstream &file) // Read the data PROCESSOR_TYPE processorType(c3d.parameters().processorType()); - float pointScaleFactor(c3d.parameters().group("POINT").parameter("SCALE").valuesAsFloat()[0]); - std::vector analogScaleFactors(c3d.parameters().group("ANALOG").parameter("SCALE").valuesAsFloat()); + float pointScaleFactor(-1); + if (c3d.header().nb3dPoints()) + pointScaleFactor = c3d.parameters().group("POINT").parameter("SCALE").valuesAsFloat()[0]; + std::vector analogScaleFactors; + if (c3d.header().nbAnalogs()) + analogScaleFactors = c3d.parameters().group("ANALOG").parameter("SCALE").valuesAsFloat(); float analogGeneralFactor(c3d.parameters().group("ANALOG").parameter("GEN_SCALE").valuesAsFloat()[0]); std::vector analogZeroOffset(c3d.parameters().group("ANALOG").parameter("OFFSET").valuesAsInt()); for (size_t j = 0; j < c3d.header().nbFrames(); ++j){ From a16387fbb1eb4f6f2707fc03a0bba709e8ecafb7 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 09:58:01 +0200 Subject: [PATCH 13/28] Rearranged travis for the new location of tests --- .travis.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f5363e9b..b0a4dcc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,16 +63,27 @@ script: cmake --build ./ --config Release; fi # Only do the coverage on Linux, but run the test anyway to get a nice output + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + cp -r test/c3dTestFiles/ .; + elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + cd test; + elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cd test\\Release; + mkdir .\\c3dTestFiles; + xcopy ..\\c3dTestFiles .\\c3dTestFiles; + fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make ezc3d_coverage; elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./runUnitTests; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - cp bin/Release/*.dll .; - cp Release/*.dll .; - cp Release/*.exe .; ./runUnitTests.exe; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + cd ..; + elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cd ../..; + fi - ctest - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=$HOME/miniconda/ -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON ..; From f039f61045140caf067fa3f2e6c0379966518a6e Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 10:04:16 +0200 Subject: [PATCH 14/28] Indentation --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0a4dcc7..f7cf5f27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,10 +80,10 @@ script: ./runUnitTests.exe; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - cd ..; - elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - cd ../..; - fi + cd ..; + elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cd ../..; + fi - ctest - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=$HOME/miniconda/ -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON ..; From b60ce5babc9fd64526947d33aa83bf3b6e620087 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 10:20:23 +0200 Subject: [PATCH 15/28] Sample02 wasn't downloading anymore --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6f414803..b3ad1d93 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,7 @@ find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_SOURCE_DIR}/${RELATIVE_PATH_TO if((NOT GTEST_INCLUDE_DIR) OR (NOT EXISTS ${GTEST_INCLUDE_DIR})) # we couldn't find the header files for gtest or they don't exist - message("Unable to find gtest") + message("Unable to find gtest, try to automatically download it") # we have a submodule setup for gtest, assume it is under external/gtest # now we need to clone this submodule @@ -66,7 +66,7 @@ endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage" set(TEST_FILES_TO_DOWNLOAD Sample01.zip Sample02.zip) foreach(FILE ${TEST_FILES_TO_DOWNLOAD}) get_filename_component(FOLDER_NAME ${FILE} NAME_WE) - IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite) + IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FILE}) file( DOWNLOAD https://www.c3d.org/data/${FILE} ${CMAKE_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FILE} From 690e8772e886c5cfb8cd43d67a3eb76c664b14b7 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 10:31:07 +0200 Subject: [PATCH 16/28] debugging windows --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f7cf5f27..25b25ab6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,7 +77,8 @@ script: elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./runUnitTests; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - ./runUnitTests.exe; + dir; + runUnitTests.exe; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd ..; From df730c5e9606fb4587ee341a9e5b6cb5556196a1 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 11:04:39 +0200 Subject: [PATCH 17/28] Reintroduced .dll --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25b25ab6..e36be4ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,8 @@ script: elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd test; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cp bin/Release/*.dll ./test/Release; + cp Release/*.dll ./test/Release; cd test\\Release; mkdir .\\c3dTestFiles; xcopy ..\\c3dTestFiles .\\c3dTestFiles; @@ -77,8 +79,7 @@ script: elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./runUnitTests; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - dir; - runUnitTests.exe; + ./runUnitTests.exe; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd ..; From 97bc2060ce128599fd4d4f25e3de219427a9c532 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Thu, 5 Sep 2019 19:39:19 +0200 Subject: [PATCH 18/28] If points exists but POINT:RATE is not provided, take the header's one --- src/ezc3d.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index 06eedf3b..0a3b52a6 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -554,7 +554,13 @@ void ezc3d::c3d::updateHeader() float pointRate(parameters().group("POINT").parameter("RATE").valuesAsFloat()[0]); float buffer(10000); // For decimal truncature if (static_cast(pointRate*buffer) != static_cast(header().frameRate()*buffer)){ - _header->frameRate(pointRate); + // If there are points but the rate don't match keep the one from header + if (static_cast(parameters().group("POINT").parameter("RATE").valuesAsFloat()[0]) == 0.0 && parameters().group("POINT").parameter("USED").valuesAsInt()[0] != 0){ + ezc3d::ParametersNS::GroupNS::Parameter rate("RATE"); + rate.set(header().frameRate()); + parameter("POINT", rate); + } else + _header->frameRate(pointRate); } if (static_cast(parameters().group("POINT").parameter("USED").valuesAsInt()[0]) != header().nb3dPoints()){ _header->nb3dPoints(static_cast(parameters().group("POINT").parameter("USED").valuesAsInt()[0])); From bfb14d6fd90f3e058a364acb464309cf19a92658 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sun, 8 Sep 2019 14:24:30 +0200 Subject: [PATCH 19/28] Trying to solve the uninstallable Windows --- binding/python3/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 19c89455..a6502b21 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -1,12 +1,12 @@ # Include python find_package(PYTHON3 REQUIRED) include_directories(${Python3_INCLUDE_DIRS}) + find_package(Numpy REQUIRED) include_directories(${NUMPY_INCLUDES}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include) if(WIN32) - link_directories(${Python3_RUNTIME_LIBRARY_DIRS}/libs) + link_directories(${Python3_RUNTIME_LIBRARY_DIRS}/libs) endif() # Add swig module @@ -17,6 +17,11 @@ set_property(SOURCE ${I_SOURCE_FILE} PROPERTY CPLUSPLUS ON) SWIG_ADD_LIBRARY(${PROJECT_NAME} TYPE MODULE LANGUAGE python SOURCES ${I_SOURCE_FILE}) swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_LIBRARIES}) +# Add headers +target_include_directories(_${PROJECT_NAME} PUBLIC + ${CMAKE_SOURCE_DIR}/include +) + if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -26,7 +31,6 @@ else() SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) endif() - # Install to the proper directories INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.py DESTINATION ${Python3_SITELIB}/${PROJECT_NAME}) From b9af22b5a71d505d2bdf24f32098c3e4d668322c Mon Sep 17 00:00:00 2001 From: pariterre Date: Sun, 8 Sep 2019 17:02:07 -0400 Subject: [PATCH 20/28] added ian include directory for swig for newer version of cmake --- binding/python3/CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index a6502b21..578b0538 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -21,22 +21,24 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) +set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include) if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) - SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) set_property(TARGET _${PROJECT_NAME} APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress") else() SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) - SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) endif() +SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) # Install to the proper directories INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.py - DESTINATION ${Python3_SITELIB}/${PROJECT_NAME}) + DESTINATION ${Python3_SITELIB}/${PROJECT_NAME} +) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py - DESTINATION ${Python3_SITELIB}/${PROJECT_NAME}) + DESTINATION ${Python3_SITELIB}/${PROJECT_NAME} +) # Check if swig has its version 3 or 4, to choose the right place to put the library if(${SWIG_VERSION} MATCHES "^3(\.[0-9]*)*$") @@ -49,5 +51,6 @@ endif() # Install the library INSTALL(TARGETS _${PROJECT_NAME} - DESTINATION ${PYTHON_INSTALL_DESTINATION}) + DESTINATION ${PYTHON_INSTALL_DESTINATION} +) From 7611afb51e2d66cd88b61e31dcdb00a6fdd78750 Mon Sep 17 00:00:00 2001 From: pariterre Date: Mon, 9 Sep 2019 11:14:39 -0400 Subject: [PATCH 21/28] debugging windows --- .travis.yml | 2 ++ CMakeLists.txt | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e36be4ba..a8da69d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,6 +93,8 @@ script: else cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=$ToolsDir/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON ..; cmake --build ./ --config Release --target install; + echo %PATH%; + fi # Test the python binder - pytest -v --color=yes ../test diff --git a/CMakeLists.txt b/CMakeLists.txt index 706273f2..cf4af0dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,3 @@ option(BUILD_TESTS "Build all tests." OFF) # Makes boolean 'test' available. if (BUILD_TESTS) add_subdirectory(test) endif() - - - - From e76de5a53b3f9b5d367c5498df6b8d579f311556 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Mon, 9 Sep 2019 17:40:53 +0200 Subject: [PATCH 22/28] Adjusted install prefix on the first cmake --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8da69d4..7db7934b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ script: cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF .. ; make; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF ..; + cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=$ToolsDir/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF ..; cmake --build ./ --config Release; fi # Only do the coverage on Linux, but run the test anyway to get a nice output @@ -93,8 +93,6 @@ script: else cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=$ToolsDir/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON ..; cmake --build ./ --config Release --target install; - echo %PATH%; - fi # Test the python binder - pytest -v --color=yes ../test From 7293564a4eeec583c7177d417c39e4fb023165a4 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:03:57 +0200 Subject: [PATCH 23/28] Adjusted path for windows and added an include that depends on cmake version --- .travis.yml | 2 +- binding/python3/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7db7934b..686c49ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: bash miniconda.sh -b -p $HOME/miniconda; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install miniconda3 --params="'/AddToPath:1'"; - export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:$PATH"; + export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program\ Files/Git/miniconda3/Lib/:$PATH"; fi - export PATH="$HOME/miniconda/bin:$PATH" - hash -r diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 578b0538..2c52293b 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -21,7 +21,11 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) -set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include) +if (${CMAKE_VERSION} VERSION_GREATER "3.10.0") + set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include) +else() + include_directories(${CMAKE_SOURCE_DIR}/include) +endif() if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) From 64bc850daf2b4fd10640897e68134a19813d23b6 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:12:06 +0200 Subject: [PATCH 24/28] again --- .travis.yml | 2 +- binding/python3/CMakeLists.txt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 686c49ab..517e89fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: bash miniconda.sh -b -p $HOME/miniconda; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install miniconda3 --params="'/AddToPath:1'"; - export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program\ Files/Git/miniconda3/Lib/:$PATH"; + export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program\ Files/Git/miniconda3/bin/:$PATH"; fi - export PATH="$HOME/miniconda/bin:$PATH" - hash -r diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 2c52293b..9034712d 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -21,11 +21,7 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) -if (${CMAKE_VERSION} VERSION_GREATER "3.10.0") - set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include) -else() - include_directories(${CMAKE_SOURCE_DIR}/include) -endif() +set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../../include) if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) From 29972699cc34d8eb57cfa6fa575389bd194d90d2 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:22:10 +0200 Subject: [PATCH 25/28] again2 --- .travis.yml | 2 +- binding/python3/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 517e89fb..340ab6eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: bash miniconda.sh -b -p $HOME/miniconda; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install miniconda3 --params="'/AddToPath:1'"; - export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program\ Files/Git/miniconda3/bin/:$PATH"; + export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program Files/Git/miniconda3/bin/:$PATH"; fi - export PATH="$HOME/miniconda/bin:$PATH" - hash -r diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 9034712d..59df437c 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -21,7 +21,7 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) -set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../../include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include) if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) From 61e199e51c28366483aaf3539e19d54a08c5f7b4 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:30:52 +0200 Subject: [PATCH 26/28] again3 --- binding/python3/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 59df437c..0968306e 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -21,7 +21,10 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include) +message(coucou) +message(${CMAKE_SOURCE_DIR}) +message(coucou) +include_directories(${CMAKE_SOURCE_DIR}/include) if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) From efa75b7733c46962bcdbbe456f0ebfe0b248867a Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:38:24 +0200 Subject: [PATCH 27/28] again4 --- binding/python3/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index 0968306e..ee63ff07 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -8,6 +8,11 @@ include_directories(${NUMPY_INCLUDES}) if(WIN32) link_directories(${Python3_RUNTIME_LIBRARY_DIRS}/libs) endif() +if (APPLE) + # For unknown reason the later set properties over SWIG_INCLUDE_DIRECTORIES doesn't work + # on travis + include_directories(${CMAKE_SOURCE_DIR}/include) +endif () # Add swig module set(CMAKE_SWIG_FLAGS "") @@ -21,10 +26,7 @@ swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_ target_include_directories(_${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include ) -message(coucou) -message(${CMAKE_SOURCE_DIR}) -message(coucou) -include_directories(${CMAKE_SOURCE_DIR}/include) +set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include) if(APPLE) SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER}) From 6619a12e4698688a1da7403d3916ac65b708572c Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 10 Sep 2019 10:52:13 +0200 Subject: [PATCH 28/28] Update version number --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf4af0dc..6f7d350a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8) cmake_policy(SET CMP0048 NEW) -project(ezc3d VERSION 1.1.0) +project(ezc3d VERSION 1.1.1) set(CMAKE_CXX_STANDARD 11) # Set some variables