From 2a0df8435cc3917d55809d20b81824481589223e Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:12:47 -0400 Subject: [PATCH 01/14] Implemented DATA_START for ROTATION group properly --- CMakeLists.txt | 1 + include/Data.h | 6 +- include/DataStartInfo.h | 120 ++++++++++++++++++++++++++++++++++++++++ include/Frame.h | 4 +- include/Group.h | 16 ++++-- include/Header.h | 4 +- include/Parameter.h | 6 +- include/Parameters.h | 4 +- include/ezc3d.h | 11 +++- src/Data.cpp | 16 +++++- src/DataStartInfo.cpp | 90 ++++++++++++++++++++++++++++++ src/Frame.cpp | 15 +++-- src/Group.cpp | 15 +++-- src/Header.cpp | 5 +- src/Parameter.cpp | 21 ++++--- src/Parameters.cpp | 13 +++-- src/ezc3d.cpp | 61 ++++++++++++-------- test/test_ezc3d.cpp | 2 +- 18 files changed, 341 insertions(+), 69 deletions(-) create mode 100644 include/DataStartInfo.h create mode 100644 src/DataStartInfo.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 007fc5fc..8b3978fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ set(SRC_LIST src/AnalogsSubframe.cpp src/Channel.cpp src/Data.cpp + src/DataStartInfo.cpp src/ezc3d.cpp src/Frame.cpp src/Group.cpp diff --git a/include/Data.h b/include/Data.h index e3ec01c9..d06db422 100644 --- a/include/Data.h +++ b/include/Data.h @@ -45,16 +45,20 @@ class EZC3D_API ezc3d::DataNS::Data{ /// /// \brief Write all the data to an opened file + /// \param The header of a c3d /// \param f Already opened fstream file with write access /// \param pointScaleFactor The factor to scale the point data with /// \param analogScaleFactors The factors to scale the analog data with + /// \param dataStartInfoToFill The start position to fill /// /// Write all the data to a file by calling sequentially all the write method for all the frames /// void write( + const ezc3d::Header& header, std::fstream &f, float pointScaleFactor, - std::vector analogScaleFactors) const; + std::vector analogScaleFactors, + ezc3d::DataStartInfo& dataStartInfoToFill) const; //---- FRAME ----// diff --git a/include/DataStartInfo.h b/include/DataStartInfo.h new file mode 100644 index 00000000..ca89b886 --- /dev/null +++ b/include/DataStartInfo.h @@ -0,0 +1,120 @@ +#ifndef DATA_START_INFO_H +#define DATA_START_INFO_H +/// +/// \file DataStartInfo.h +/// \brief Declaration of DataStartInfo class +/// \author Pariterre +/// \version 1.0 +/// \date October 17th, 2018 +/// + +#include "ezc3d.h" +/// +/// \brief Placeholder for stocking the position and value of data start +/// +class EZC3D_API ezc3d::DataStartInfo{ + +protected: + std::streampos m_pointDataStart = -1; ///< The data start for the points + +public: + /// + /// \brief The point data start + /// \param value The starting position of the points data in the c3d file + /// + void setPointDataStart(const std::streampos& value); + + /// + /// \brief Get the point data start + /// \return The point data start + /// + const std::streampos& pointDataStart() const; + + +protected: + std::streampos m_headerPointDataStart = -1; ///< Position in the c3d to put the point start start in the header + DATA_TYPE m_headerPointDataStartSize = DATA_TYPE::WORD; ///< The size of the value in the c3d file + +public: + /// + /// \brief The position in the c3d where to put the header point data start + /// \param position + /// + void setHeaderPositionInC3dForPointDataStart(const std::streampos& position); + + /// + /// \brief Get the position in the c3d to put the point start start in the header + /// \return The position in the c3d to put the point start start in the header + /// + const std::streampos& headerPointDataStart() const; + + /// + /// \brief Get the size of the value in the c3d file header + /// \return The size of the value in the c3d file header + /// + DATA_TYPE headerPointDataStartSize() const; + +protected: + std::streampos m_parameterPointDataStart = -1; ///< Position in the c3d to put the point start start in the parameters + DATA_TYPE m_parameterPointDataStartSize = DATA_TYPE::BYTE; ///< The size of the value in the c3d file + +public: + /// + /// \brief The position in the c3d where to put the parameter point data start + /// \param position + /// + void setParameterPositionInC3dForPointDataStart(const std::streampos& position); + + /// + /// \brief Get the position in the c3d to put the point start start in the parameters + /// \return The position in the c3d to put the point start start in the parameters + /// + const std::streampos& parameterPointDataStart() const; + + /// + /// \brief Get the size of the value in the c3d file parameter + /// \return The size of the value in the c3d file parameter + /// + DATA_TYPE parameterPointDataStartSize() const; + +protected: + std::streampos m_rotationsDataStart = -1; ///< The data start for the rotations + +public: + /// + /// \brief The rotations data start + /// \param value The starting position of the rotations data in the c3d file + /// + void setRotationsDataStart(const std::streampos& value); + + /// + /// \brief Get the rotations data start + /// \return The rotations data start + /// + const std::streampos& rotationsDataStart() const; + +protected: + std::streampos m_parameterRotationsDataStart = -1; ///< Position in the c3d to put the rotations start start in the parameters + DATA_TYPE m_parameterRotationsDataStartSize = DATA_TYPE::BYTE; ///< The size of the value in the c3d file + +public: + /// + /// \brief The position in the c3d where to put the parameter rotations data start + /// \param position + /// + void setParameterPositionInC3dForRotationsDataStart(const std::streampos& position); + + /// + /// \brief Get the position in the c3d to put the rotations start start in the parameters + /// \return The position in the c3d to put the rotations start start in the parameters + /// + const std::streampos& parameterRotationsDataStart() const; + + /// + /// \brief Get the size of the value in the c3d file parameter + /// \return The size of the value in the c3d file parameter + /// + DATA_TYPE parameterRotationsDataStartSize() const; +}; + +#endif diff --git a/include/Frame.h b/include/Frame.h index ccbe6f31..e312f9a7 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -39,13 +39,15 @@ class EZC3D_API ezc3d::DataNS::Frame{ /// \param f Already opened fstream file with write access /// \param pointScaleFactor The factor to scale the point data with /// \param analogScaleFactors The factor to scale the analog data with + /// \param dataTypeToWrite The type of data block (0 points/analogs, 1 rotations) /// /// Write the frame to a file by calling sequentially the write method for points and analogs /// void write( std::fstream &f, float pointScaleFactor, - std::vector analogScaleFactors) const; + std::vector analogScaleFactors, + int dataTypeToWrite) const; //---- POINTS ----// diff --git a/include/Group.h b/include/Group.h index c4b20a40..010ec2cf 100644 --- a/include/Group.h +++ b/include/Group.h @@ -37,9 +37,12 @@ class EZC3D_API ezc3d::ParametersNS::GroupNS::Group{ /// \brief Write the group to an opened file by calling the write method of all the parameters /// \param f Already opened fstream file with write access /// \param groupIdx Index of the group that this particular parameter is in - /// \param dataStartPosition The position in the file where the data start (special case for POINT:DATA_START parameter) + /// \param dataStartPositionToFill The position in the file where the data start (special case for POINT:DATA_START and ROTATION:DATA_START parameters) /// - void write(std::fstream &f, int groupIdx, std::streampos &dataStartPosition) const; + void write( + std::fstream &f, + int groupIdx, + ezc3d::DataStartInfo &dataStartPositionToFill) const; /// /// \brief Read and store a group of parameter from an opened C3D file @@ -49,10 +52,11 @@ class EZC3D_API ezc3d::ParametersNS::GroupNS::Group{ /// \param nbCharInName The number of character of the group name /// \return The position in the file of the next Group/Parameter /// - int read(ezc3d::c3d &c3d, - const Parameters ¶ms, - std::fstream &file, - int nbCharInName); + int read( + ezc3d::c3d &c3d, + const Parameters ¶ms, + std::fstream &file, + int nbCharInName); /// /// \brief isEmpty If the group has no name and no parameter, it is considered empty diff --git a/include/Header.h b/include/Header.h index 58a5eee7..7564b568 100644 --- a/include/Header.h +++ b/include/Header.h @@ -41,11 +41,11 @@ class EZC3D_API ezc3d::Header{ /// /// \brief Write the header to an opened file /// \param f Already opened fstream file with write access - /// \param dataStartPosition Returns the byte where to put the data start parameter + /// \param dataStartPositionToFill Returns the byte where to put the data start parameter /// void write( std::fstream &f, - std::streampos &dataStartPosition) const; + ezc3d::DataStartInfo &dataStartPositionToFill) const; /// /// \brief Read and store a header from an opened C3D file diff --git a/include/Parameter.h b/include/Parameter.h index db20b741..8123ddc4 100644 --- a/include/Parameter.h +++ b/include/Parameter.h @@ -37,14 +37,16 @@ class EZC3D_API ezc3d::ParametersNS::GroupNS::Parameter{ /// \brief Write the parameter to an opened file /// \param f Already opened fstream file with write access /// \param groupIdx Index of the group that this particular parameter is in - /// \param dataStartPosition The position in the file where the data start (special case for POINT:DATA_START parameter) + /// \param dataStartPositionToFill The position in the file where the data start (special case for POINT:DATA_START and ROTATION:DATA_START parameters) + /// \param dataStartType The type of data start (-1 no data start, 0 points, 1 rotations) /// /// Write the parameter and its values to a file /// void write( std::fstream &f, int groupIdx, - std::streampos &dataStartPosition) const; + ezc3d::DataStartInfo &dataStartPositionToFill, + int dataStartType) const; protected: /// diff --git a/include/Parameters.h b/include/Parameters.h index 5bb2b2dc..448ed79e 100644 --- a/include/Parameters.h +++ b/include/Parameters.h @@ -67,13 +67,13 @@ class EZC3D_API ezc3d::ParametersNS::Parameters{ /// /// \brief Write the groups to an opened file by calling the write method of all the groups /// \param f Already opened fstream file with write access - /// \param dataStartPosition Returns the byte where to put the data start parameter + /// \param dataStartPositionToFill Returns the byte where to put the data start parameter /// \param header A reference to the header section /// \param format What order should the file has /// ezc3d::ParametersNS::Parameters write( std::fstream &f, - std::streampos &dataStartPosition, + ezc3d::DataStartInfo &dataStartPositionToFill, const ezc3d::Header& header, const ezc3d::WRITE_FORMAT& format = ezc3d::WRITE_FORMAT::DEFAULT ) const; diff --git a/include/ezc3d.h b/include/ezc3d.h index 0c1c29bf..37d62b7a 100644 --- a/include/ezc3d.h +++ b/include/ezc3d.h @@ -112,6 +112,7 @@ namespace ezc3d { class EZC3D_API Vector3d; class EZC3D_API Vector6d; class EZC3D_API Header; + class DataStartInfo; /// /// \brief Namespace that holds the Parameters hierarchy @@ -267,11 +268,9 @@ class EZC3D_API ezc3d::c3d { /// \brief Write the data_start parameter where demanded /// \param file opened file stream to be read /// \param dataStartPosition The position in block of the data - /// \param type The type of data to write /// void writeDataStart(std::fstream &file, - const std::streampos& dataStartPosition, - const DATA_TYPE &type) const; + const ezc3d::DataStartInfo& dataStartPosition) const; public: /// @@ -373,6 +372,12 @@ class EZC3D_API ezc3d::c3d { const std::vector &dimension, std::vector ¶m_data); + /// + /// \brief Advance the cursor in a file to a new 512 bytes block + /// \param file The file stream + /// + static void moveCursorToANewBlock( + std::fstream & file); protected: /// /// \brief Internal function to dispatch a string array to a matrix of strings diff --git a/src/Data.cpp b/src/Data.cpp index feb52e12..97cea896 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -13,6 +13,7 @@ #include "AnalogsInfo.h" #include "PointsInfo.h" #include "RotationsInfo.h" +#include "DataStartInfo.h" ezc3d::DataNS::Data::Data() { } @@ -63,11 +64,22 @@ void ezc3d::DataNS::Data::print() const { } void ezc3d::DataNS::Data::write( + const ezc3d::Header& header, std::fstream &f, float pointScaleFactor, - std::vector analogScaleFactors) const { + std::vector analogScaleFactors, + ezc3d::DataStartInfo& dataStartInfoToFill) const { + + dataStartInfoToFill.setPointDataStart(f.tellg()); for (size_t i = 0; i < nbFrames(); ++i) - frame(i).write(f, pointScaleFactor, analogScaleFactors); + frame(i).write(f, pointScaleFactor, analogScaleFactors, 0); + + if (header.hasRotationalData()){ + ezc3d::c3d::moveCursorToANewBlock(f); + dataStartInfoToFill.setRotationsDataStart(f.tellg()); + for (size_t i = 0; i < nbFrames(); ++i) + frame(i).write(f, pointScaleFactor, analogScaleFactors, 1); + } } size_t ezc3d::DataNS::Data::nbFrames() const { diff --git a/src/DataStartInfo.cpp b/src/DataStartInfo.cpp new file mode 100644 index 00000000..55ccc589 --- /dev/null +++ b/src/DataStartInfo.cpp @@ -0,0 +1,90 @@ +#define EZC3D_API_EXPORTS +/// +/// \file DataStartInfo.cpp +/// \brief Implementation of DataStartInfo class +/// \author Pariterre +/// \version 1.0 +/// \date October 17th, 2018 +/// + +#include "DataStartInfo.h" + +void ezc3d::DataStartInfo::setPointDataStart( + const std::streampos &value) +{ + m_pointDataStart = value; + if (int(m_pointDataStart) % 512 > 0) + throw std::out_of_range( + "Something went wrong in the positioning of the pointer " + "for writting the data. Please report this error."); +} + +const std::streampos &ezc3d::DataStartInfo::pointDataStart() const +{ + return m_pointDataStart; +} + +void ezc3d::DataStartInfo::setHeaderPositionInC3dForPointDataStart( + const std::streampos &position) +{ + m_headerPointDataStart = position; +} + +const std::streampos &ezc3d::DataStartInfo::headerPointDataStart() const +{ + return m_headerPointDataStart; +} + +ezc3d::DATA_TYPE ezc3d::DataStartInfo::headerPointDataStartSize() const +{ + return m_headerPointDataStartSize; +} + +void ezc3d::DataStartInfo::setParameterPositionInC3dForPointDataStart( + const std::streampos &position) +{ + m_parameterPointDataStart = position; +} + +const std::streampos &ezc3d::DataStartInfo::parameterPointDataStart() const +{ + return m_parameterPointDataStart; +} + +ezc3d::DATA_TYPE ezc3d::DataStartInfo::parameterPointDataStartSize() const +{ + return m_parameterPointDataStartSize; +} + +void ezc3d::DataStartInfo::setRotationsDataStart( + const std::streampos &value) +{ + m_rotationsDataStart = value; +} + +const std::streampos &ezc3d::DataStartInfo::rotationsDataStart() const +{ + return m_rotationsDataStart; + if (int(m_rotationsDataStart) % 512 > 0) + throw std::out_of_range( + "Something went wrong in the positioning of the pointer " + "for writting the data. Please report this error."); +} + +void ezc3d::DataStartInfo::setParameterPositionInC3dForRotationsDataStart( + const std::streampos &position) +{ + m_parameterRotationsDataStart = position; +} + +const std::streampos &ezc3d::DataStartInfo::parameterRotationsDataStart() const +{ + return m_parameterRotationsDataStart; +} + +ezc3d::DATA_TYPE ezc3d::DataStartInfo::parameterRotationsDataStartSize() const +{ + return m_parameterRotationsDataStartSize; +} + + diff --git a/src/Frame.cpp b/src/Frame.cpp index 6061fb72..e4c8d09f 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -8,6 +8,7 @@ /// #include "Frame.h" +#include "DataStartInfo.h" ezc3d::DataNS::Frame::Frame() { _points = std::shared_ptr( @@ -27,10 +28,16 @@ void ezc3d::DataNS::Frame::print() const { void ezc3d::DataNS::Frame::write( std::fstream &f, float pointScaleFactor, - std::vector analogScaleFactors) const { - points().write(f, pointScaleFactor); - analogs().write(f, analogScaleFactors); - rotations().write(f); + std::vector analogScaleFactors, + int dataTypeToWrite) const { + if (dataTypeToWrite == 0){ // Points and analogs + points().write(f, pointScaleFactor); + analogs().write(f, analogScaleFactors); + } else if (dataTypeToWrite == 1) { // Rotations + rotations().write(f); + } else { + throw std::runtime_error("Data type not implemented yet"); + } } const ezc3d::DataNS::Points3dNS::Points& ezc3d::DataNS::Frame::points() const { diff --git a/src/Group.cpp b/src/Group.cpp index 7504b7f4..cc71aaa9 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -33,7 +33,7 @@ void ezc3d::ParametersNS::GroupNS::Group::print() const { void ezc3d::ParametersNS::GroupNS::Group::write( std::fstream &f, int groupIdx, - std::streampos &dataStartPosition) const { + ezc3d::DataStartInfo &dataStartPositionToFill) const { int nCharName(static_cast(name().size())); if (isLocked()) nCharName *= -1; @@ -64,12 +64,15 @@ void ezc3d::ParametersNS::GroupNS::Group::write( 2*ezc3d::DATA_TYPE::BYTE); f.seekg(currentPos); - std::streampos defaultDataStartPosition(-1); - for (size_t i=0; i < nbParameters(); ++i) + for (size_t i=0; i < nbParameters(); ++i){ + int tagForDataStartFilling = -1; if (!name().compare("POINT")) - parameter(i).write(f, -groupIdx, dataStartPosition); - else - parameter(i).write(f, -groupIdx, defaultDataStartPosition); + tagForDataStartFilling = 0; + else if (!name().compare("ROTATION")) + tagForDataStartFilling = 1; + parameter(i).write(f, -groupIdx, dataStartPositionToFill, tagForDataStartFilling); + + } } int ezc3d::ParametersNS::GroupNS::Group::read( diff --git a/src/Header.cpp b/src/Header.cpp index fca204e2..53abab32 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -9,6 +9,7 @@ #include "Header.h" #include "Parameters.h" +#include "DataStartInfo.h" ezc3d::Header::Header(): _nbOfZerosBeforeHeader(0), @@ -99,7 +100,7 @@ void ezc3d::Header::print() const { void ezc3d::Header::write( std::fstream &f, - std::streampos &dataStartPosition) const { + ezc3d::DataStartInfo &dataStartPositionToFill) const { // write the checksum byte and the start point of header int parameterAddessDefault(2); f.write(reinterpret_cast( @@ -132,7 +133,7 @@ void ezc3d::Header::write( 2*ezc3d::DATA_TYPE::WORD); // Parameters of analog data - dataStartPosition = f.tellg(); + dataStartPositionToFill.setHeaderPositionInC3dForPointDataStart(f.tellg()); // dataStartPosition is to be changed when we know where the data are f.write(reinterpret_cast(&_dataStart), 1*ezc3d::DATA_TYPE::WORD); diff --git a/src/Parameter.cpp b/src/Parameter.cpp index c53293e4..a8fb9a43 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -9,6 +9,7 @@ #include "Parameter.h" #include "Parameters.h" +#include "DataStartInfo.h" ezc3d::ParametersNS::GroupNS::Parameter::Parameter( const std::string &name, @@ -49,7 +50,8 @@ void ezc3d::ParametersNS::GroupNS::Parameter::print() const { void ezc3d::ParametersNS::GroupNS::Parameter::write( std::fstream &f, int groupIdx, - std::streampos &dataStartPosition) const { + ezc3d::DataStartInfo &dataStartPositionToFill, + int dataStartType) const { int nCharName(static_cast(name().size())); if (isLocked()) nCharName *= -1; @@ -117,15 +119,16 @@ void ezc3d::ParametersNS::GroupNS::Parameter::write( writeImbricatedParameter(f, dimension, 1); } } else { - if (static_cast(dataStartPosition) != -1 - && !_name.compare("DATA_START")){ - // -1 means that it is not the POINT group - + if (!_name.compare("DATA_START") && dataStartType >= 0){ // 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); + // the number of blocks up to the data for POINT or ROTATION group + if (dataStartType == 0) // POINT + dataStartPositionToFill.setParameterPositionInC3dForPointDataStart(f.tellg()); + else if (dataStartType == 1) // ROTATION + dataStartPositionToFill.setParameterPositionInC3dForRotationsDataStart(f.tellg()); + else + throw std::runtime_error("data start type not recognized"); + f.write(reinterpret_cast(&blank), 2*ezc3d::DATA_TYPE::BYTE); } else writeImbricatedParameter(f, dimension); } diff --git a/src/Parameters.cpp b/src/Parameters.cpp index 86b3e7e2..b1f781aa 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -336,7 +336,7 @@ void ezc3d::ParametersNS::Parameters::print() const { ezc3d::ParametersNS::Parameters ezc3d::ParametersNS::Parameters::write( std::fstream &f, - std::streampos &dataStartPosition, + ezc3d::DataStartInfo &dataStartPositionToFill, const ezc3d::Header& header, const ezc3d::WRITE_FORMAT& format) const { ezc3d::ParametersNS::Parameters p(prepareCopyForWriting(header, format)); @@ -357,21 +357,22 @@ ezc3d::ParametersNS::Parameters ezc3d::ParametersNS::Parameters::write( for (size_t i=0; i < p.nbGroups(); ++i){ const ezc3d::ParametersNS::GroupNS::Group& currentGroup(p.group(i)); if (!currentGroup.isEmpty()) - currentGroup.write(f, -static_cast(i+1), dataStartPosition); + currentGroup.write(f, -static_cast(i+1), dataStartPositionToFill); } // Move the cursor to a beginning of a block + ezc3d::c3d::moveCursorToANewBlock(f); + // Go back at the left blank space (next parameter position in the last parameter) + // and write the current position std::streampos currentPos(f.tellg()); - for (int i=0; i<512 - static_cast(currentPos) % 512; ++i){ - f.write(reinterpret_cast(&blankValue), ezc3d::BYTE); - } - // Go back at the left blank space and write the current position currentPos = f.tellg(); f.seekg(pos); int nBlocksToNext = int(currentPos - pos-2)/512; if (int(currentPos - pos-2) % 512 > 0) ++nBlocksToNext; f.write(reinterpret_cast(&nBlocksToNext), ezc3d::BYTE); + + // Go back to where to start writing the data f.seekg(currentPos); return p; diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index c3a1a31b..175e49f5 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -11,6 +11,7 @@ #include "Header.h" #include "Data.h" #include "Parameters.h" +#include "DataStartInfo.h" void ezc3d::removeTrailingSpaces( @@ -92,23 +93,22 @@ void ezc3d::c3d::write( const WRITE_FORMAT& format) const { std::fstream f(filePath, std::ios::out | std::ios::binary); + ezc3d::DataStartInfo dataStartInfoToFill; + // Write the header - std::streampos dataStartHeader; - header().write(f, dataStartHeader); + header().write(f, dataStartInfoToFill); // Write the parameters - std::streampos dataStartParameters(-2); // -1 means not POINT group ezc3d::ParametersNS::Parameters p( - parameters().write(f, dataStartParameters, header(), format)); - - // Write the data start parameter in header and parameter sections - writeDataStart(f, dataStartHeader, DATA_TYPE::WORD); - writeDataStart(f, dataStartParameters, DATA_TYPE::BYTE); + parameters().write(f, dataStartInfoToFill, header(), format)); // Write the data float pointScaleFactor(p.group("POINT").parameter("SCALE").valuesAsDouble()[0]); std::vector pointAnalogFactors(p.group("ANALOG").parameter("SCALE").valuesAsDouble()); - data().write(f, pointScaleFactor, pointAnalogFactors); + data().write(header(), f, pointScaleFactor, pointAnalogFactors, dataStartInfoToFill); + + // Go back and write all the required data start + writeDataStart(f, dataStartInfoToFill); f.close(); } @@ -165,19 +165,25 @@ int ezc3d::c3d::hex2int( void ezc3d::c3d::writeDataStart( std::fstream &f, - const std::streampos &dataStartPosition, - const DATA_TYPE& type) const { - // Go back to data start blank space and write the current - // position (assuming current is the position of data!) - std::streampos dataPos = f.tellg(); - f.seekg(dataStartPosition); - if (int(dataPos) % 512 > 0) - throw std::out_of_range( - "Something went wrong in the positioning of the pointer " - "for writting the data. Please report this error."); - int nBlocksToNext = int(dataPos)/512 + 1; // DATA_START is 1-based - f.write(reinterpret_cast(&nBlocksToNext), type); - f.seekg(dataPos); + const ezc3d::DataStartInfo &dataStartPosition) const { + + if (dataStartPosition.headerPointDataStart() != -1){ + f.seekg(dataStartPosition.headerPointDataStart()); + int nBlocksToNext = int(dataStartPosition.pointDataStart())/512 + 1; // DATA_START is 1-based + f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.headerPointDataStartSize()); + } + + if (dataStartPosition.parameterPointDataStart() != -1){ + f.seekg(dataStartPosition.parameterPointDataStart()); + int nBlocksToNext = int(dataStartPosition.pointDataStart())/512 + 1; // DATA_START is 1-based + f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.parameterPointDataStartSize()); + } + + if (dataStartPosition.parameterRotationsDataStart() != -1){ + f.seekg(dataStartPosition.parameterRotationsDataStart()); + int nBlocksToNext = int(dataStartPosition.rotationsDataStart())/512 + 1; // DATA_START is 1-based + f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.parameterRotationsDataStartSize()); + } } int ezc3d::c3d::readInt( @@ -331,6 +337,17 @@ void ezc3d::c3d::readParam( _dispatchMatrix(dimension, param_data_string_tp, param_data_string); } +void ezc3d::c3d::moveCursorToANewBlock( + std::fstream &f) +{ + // Move the cursor to the beginning of a block as rotations should start at a new block + int blankValue(0); + std::streampos currentPos(f.tellg()); + for (int i=0; i<512 - static_cast(currentPos) % 512; ++i){ + f.write(reinterpret_cast(&blankValue), ezc3d::BYTE); + } +} + size_t ezc3d::c3d::_dispatchMatrix( const std::vector &dimension, const std::vector ¶m_data_in, diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index 383e04c3..590b2534 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -1761,7 +1761,7 @@ TEST(c3dFileIO, readC3DWithRotation){ EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("USED").valuesAsInt()[0], 21); EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("DATA_START").type(), ezc3d::INT); EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("DATA_START").valuesAsInt().size(), 1); - EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("DATA_START").valuesAsInt()[0], 6); + EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("DATA_START").valuesAsInt()[0], 7); EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("RATIO").type(), ezc3d::INT); EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("RATIO").valuesAsInt().size(), 1); EXPECT_EQ(c3dCopy.parameters().group("ROTATION").parameter("RATIO").valuesAsInt()[0], 1); From 266e63dba447103327969dde5ee8648c2c853446 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:23:27 -0400 Subject: [PATCH 02/14] created a file for namespace --- include/AnalogsInfo.h | 2 +- include/Channel.h | 2 +- include/DataStartInfo.h | 2 +- include/Header.h | 2 +- include/Parameter.h | 2 +- include/PointsInfo.h | 2 +- include/RotationsInfo.h | 2 +- include/ezc3d.h | 125 +--------------------- include/ezc3dNamespace.h | 178 +++++++++++++++++++++++++++++++ include/ezc3d_all.h | 1 + include/math/Matrix.h | 2 +- include/modules/ForcePlatforms.h | 2 +- src/Analogs.cpp | 1 + src/AnalogsInfo.cpp | 1 + src/AnalogsSubframe.cpp | 1 + src/Channel.cpp | 1 + src/Data.cpp | 1 + src/Group.cpp | 1 + src/Header.cpp | 1 + src/Parameter.cpp | 1 + src/Parameters.cpp | 1 + src/Point.cpp | 1 + src/Points.cpp | 1 + src/PointsInfo.cpp | 1 + src/Rotation.cpp | 1 + src/Rotations.cpp | 1 + src/RotationsInfo.cpp | 1 + src/modules/ForcePlatforms.cpp | 1 - 28 files changed, 204 insertions(+), 134 deletions(-) create mode 100644 include/ezc3dNamespace.h diff --git a/include/AnalogsInfo.h b/include/AnalogsInfo.h index 1b64e21a..7ff40d34 100644 --- a/include/AnalogsInfo.h +++ b/include/AnalogsInfo.h @@ -8,7 +8,7 @@ /// \date April 30th, 2022 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief 3D rotation data diff --git a/include/Channel.h b/include/Channel.h index 8987ea20..91ce7fb2 100644 --- a/include/Channel.h +++ b/include/Channel.h @@ -8,7 +8,7 @@ /// \date October 17th, 2018 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief Channel of an analogous data diff --git a/include/DataStartInfo.h b/include/DataStartInfo.h index ca89b886..4a1b7008 100644 --- a/include/DataStartInfo.h +++ b/include/DataStartInfo.h @@ -8,7 +8,7 @@ /// \date October 17th, 2018 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief Placeholder for stocking the position and value of data start /// diff --git a/include/Header.h b/include/Header.h index 7564b568..c7f17aea 100644 --- a/include/Header.h +++ b/include/Header.h @@ -8,7 +8,7 @@ /// \date October 17th, 2018 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief Header of a C3D file diff --git a/include/Parameter.h b/include/Parameter.h index 8123ddc4..6b458bba 100644 --- a/include/Parameter.h +++ b/include/Parameter.h @@ -8,7 +8,7 @@ /// \date October 17th, 2018 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief Parameter of a C3D file diff --git a/include/PointsInfo.h b/include/PointsInfo.h index 866f0e86..92e77afb 100644 --- a/include/PointsInfo.h +++ b/include/PointsInfo.h @@ -8,7 +8,7 @@ /// \date April 30th, 2022 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief 3D rotation data diff --git a/include/RotationsInfo.h b/include/RotationsInfo.h index 010ba9b3..f38d473e 100644 --- a/include/RotationsInfo.h +++ b/include/RotationsInfo.h @@ -8,7 +8,7 @@ /// \date April 30th, 2022 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief 3D rotation data diff --git a/include/ezc3d.h b/include/ezc3d.h index 37d62b7a..7b5d4731 100644 --- a/include/ezc3d.h +++ b/include/ezc3d.h @@ -50,130 +50,7 @@ #endif #include "ezc3dConfig.h" - -/// -/// \brief Namespace ezc3d -/// -/// Useful functions, enum and misc useful for the ezc3d project -/// -namespace ezc3d { - // ---- UTILS ---- // - /// - /// \brief Enum that describes the size of different types - /// - enum DATA_TYPE{ - CHAR = -1, - BYTE = 1, - INT = 2, - WORD = 2, - FLOAT = 4, - NO_DATA_TYPE = 10000 - }; - - /// - /// \brief The type of processor used to store the data - /// - enum PROCESSOR_TYPE{ - INTEL = 84, - DEC = 85, - MIPS = 86, - NO_PROCESSOR_TYPE = INTEL - }; - - /// - /// \brief The order of the parameters in the new c3d file - /// - enum WRITE_FORMAT{ - DEFAULT=0, - NEXUS - }; - - /// - /// \brief Remove the spaces at the end of a string - /// \param str The string to remove the trailing spaces from. - /// - /// The function receive a string and modify it by remove the trailing spaces - /// - EZC3D_API void removeTrailingSpaces(std::string& str); - - /// - /// \brief Swap all characters of a string to capital letters - /// \param str The string to capitalize - /// - EZC3D_API std::string toUpper(const std::string &str); - - - // ---- FORWARD DECLARATION OF THE WHOLE PROJECT STRUCTURE ----// - class c3d; - class EZC3D_API Matrix; - class EZC3D_API Matrix33; - class EZC3D_API Matrix44; - class EZC3D_API Matrix66; - class EZC3D_API Vector3d; - class EZC3D_API Vector6d; - class EZC3D_API Header; - class DataStartInfo; - - /// - /// \brief Namespace that holds the Parameters hierarchy - /// - namespace ParametersNS { - class EZC3D_API Parameters; - - /// - /// \brief Namespace that holds the Group and Parameter classes - /// - namespace GroupNS { - class EZC3D_API Group; - class EZC3D_API Parameter; - } - } - - /// - /// \brief Namespace that holds the Data hierarchy - /// - namespace DataNS { - class EZC3D_API Data; - - class Frame; - /// - /// \brief Namespace that holds the Points hierarchy - /// - namespace Points3dNS { - class EZC3D_API Points; - class EZC3D_API Point; - class EZC3D_API Info; - } - /// - /// \brief Namespace that holds the Analogs hierarchy - /// - namespace AnalogsNS { - class EZC3D_API Analogs; - class EZC3D_API SubFrame; - class EZC3D_API Channel; - class EZC3D_API Info; - } - - /// - /// \brief Namespace that holds the Rotations hierarchy - /// - namespace RotationNS { - class EZC3D_API Rotations; - class EZC3D_API Rotation; - class EZC3D_API SubFrame; - class EZC3D_API Info; - } - } - - - /// - /// \brief Namespace for all the analysis modules - /// - namespace Modules { - class EZC3D_API ForcePlatform; - class EZC3D_API ForcePlatforms; - } -} +#include "ezc3dNamespace.h" /// /// \brief Main class for C3D holder diff --git a/include/ezc3dNamespace.h b/include/ezc3dNamespace.h new file mode 100644 index 00000000..f11d02cb --- /dev/null +++ b/include/ezc3dNamespace.h @@ -0,0 +1,178 @@ +#ifndef EZC3D_NAMESPACE_H +#define EZC3D_NAMESPACE_H +/// +/// \file ezc3d_namespace.h +/// \brief Declaration of the ezc3d namespace +/// \author Pariterre +/// \version 1.0 +/// \date October 17th, 2018 +/// + +/// +/// \mainpage Documentation of ezc3d +/// +/// \section intro_sec Introduction +/// +/// This is the document for the library ezc3d +/// (http://github.com/pyomeca/ezc3d). The main goal of +/// this library is to eazily create, read and modify c3d (http://c3d.org) +/// files, largely used in biomechanics. +/// +/// This documentation was automatically generated for the "Nostalgia" Release 1.1.0 on the 9th of August, 2019. +/// +/// \section install_sec Installation +/// +/// To install ezc3d, please refer to the README.md file accessible via the github repository or by following this +/// link. +/// +/// \section contact_sec Contact +/// +/// If you have any questions, comments or suggestions for future development, you are very welcomed to +/// send me an email at pariterre@gmail.com. +/// +/// \section conclusion_sec Conclusion +/// +/// Enjoy C3D files! +/// + +// Includes for standard library +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif + +#include "ezc3dConfig.h" + +/// +/// \brief Namespace ezc3d +/// +/// Useful functions, enum and misc useful for the ezc3d project +/// +namespace ezc3d { + // ---- UTILS ---- // + /// + /// \brief Enum that describes the size of different types + /// + enum DATA_TYPE{ + CHAR = -1, + BYTE = 1, + INT = 2, + WORD = 2, + FLOAT = 4, + NO_DATA_TYPE = 10000 + }; + + /// + /// \brief The type of processor used to store the data + /// + enum PROCESSOR_TYPE{ + INTEL = 84, + DEC = 85, + MIPS = 86, + NO_PROCESSOR_TYPE = INTEL + }; + + /// + /// \brief The order of the parameters in the new c3d file + /// + enum WRITE_FORMAT{ + DEFAULT=0, + NEXUS + }; + + /// + /// \brief Remove the spaces at the end of a string + /// \param str The string to remove the trailing spaces from. + /// + /// The function receive a string and modify it by remove the trailing spaces + /// + EZC3D_API void removeTrailingSpaces(std::string& str); + + /// + /// \brief Swap all characters of a string to capital letters + /// \param str The string to capitalize + /// + EZC3D_API std::string toUpper(const std::string &str); + + + // ---- FORWARD DECLARATION OF THE WHOLE PROJECT STRUCTURE ----// + class c3d; + class EZC3D_API Matrix; + class EZC3D_API Matrix33; + class EZC3D_API Matrix44; + class EZC3D_API Matrix66; + class EZC3D_API Vector3d; + class EZC3D_API Vector6d; + class EZC3D_API Header; + class DataStartInfo; + + /// + /// \brief Namespace that holds the Parameters hierarchy + /// + namespace ParametersNS { + class EZC3D_API Parameters; + + /// + /// \brief Namespace that holds the Group and Parameter classes + /// + namespace GroupNS { + class EZC3D_API Group; + class EZC3D_API Parameter; + } + } + + /// + /// \brief Namespace that holds the Data hierarchy + /// + namespace DataNS { + class EZC3D_API Data; + + class Frame; + /// + /// \brief Namespace that holds the Points hierarchy + /// + namespace Points3dNS { + class EZC3D_API Points; + class EZC3D_API Point; + class EZC3D_API Info; + } + /// + /// \brief Namespace that holds the Analogs hierarchy + /// + namespace AnalogsNS { + class EZC3D_API Analogs; + class EZC3D_API SubFrame; + class EZC3D_API Channel; + class EZC3D_API Info; + } + + /// + /// \brief Namespace that holds the Rotations hierarchy + /// + namespace RotationNS { + class EZC3D_API Rotations; + class EZC3D_API Rotation; + class EZC3D_API SubFrame; + class EZC3D_API Info; + } + } + + + /// + /// \brief Namespace for all the analysis modules + /// + namespace Modules { + class EZC3D_API ForcePlatform; + class EZC3D_API ForcePlatforms; + } +} +#endif + diff --git a/include/ezc3d_all.h b/include/ezc3d_all.h index 50f2b499..6f0a1f86 100644 --- a/include/ezc3d_all.h +++ b/include/ezc3d_all.h @@ -10,6 +10,7 @@ #include "math/ezc3dMath.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" #include "Data.h" diff --git a/include/math/Matrix.h b/include/math/Matrix.h index f62ece99..2bdabeb7 100644 --- a/include/math/Matrix.h +++ b/include/math/Matrix.h @@ -8,7 +8,7 @@ /// \date March 25th, 2020 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" /// /// \brief Matrix of unknown dimension diff --git a/include/modules/ForcePlatforms.h b/include/modules/ForcePlatforms.h index 1aabe443..9444ccdf 100644 --- a/include/modules/ForcePlatforms.h +++ b/include/modules/ForcePlatforms.h @@ -8,7 +8,7 @@ /// \date March 25th, 2020 /// -#include "ezc3d.h" +#include "ezc3dNamespace.h" #include "math/Matrix33.h" #include "math/Matrix66.h" diff --git a/src/Analogs.cpp b/src/Analogs.cpp index ccdc5cf3..7d78811a 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -8,6 +8,7 @@ /// #include "Analogs.h" +#include "ezc3d.h" #include "Header.h" ezc3d::DataNS::AnalogsNS::Analogs::Analogs() { diff --git a/src/AnalogsInfo.cpp b/src/AnalogsInfo.cpp index 98d0749f..d04b6836 100644 --- a/src/AnalogsInfo.cpp +++ b/src/AnalogsInfo.cpp @@ -8,6 +8,7 @@ /// #include "AnalogsInfo.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" diff --git a/src/AnalogsSubframe.cpp b/src/AnalogsSubframe.cpp index 33002963..d6b8b69f 100644 --- a/src/AnalogsSubframe.cpp +++ b/src/AnalogsSubframe.cpp @@ -8,6 +8,7 @@ /// #include "AnalogsSubframe.h" +#include "ezc3d.h" #include "Header.h" ezc3d::DataNS::AnalogsNS::SubFrame::SubFrame() { diff --git a/src/Channel.cpp b/src/Channel.cpp index faf2a4a8..6db3a76a 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -8,6 +8,7 @@ /// #include "Channel.h" +#include "ezc3d.h" #include "Header.h" #include "AnalogsInfo.h" diff --git a/src/Data.cpp b/src/Data.cpp index 97cea896..fa55a090 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -8,6 +8,7 @@ /// #include "Data.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" #include "AnalogsInfo.h" diff --git a/src/Group.cpp b/src/Group.cpp index cc71aaa9..94efe0a6 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -8,6 +8,7 @@ /// #include "Group.h" +#include "ezc3d.h" #include "Parameters.h" ezc3d::ParametersNS::GroupNS::Group::Group( diff --git a/src/Header.cpp b/src/Header.cpp index 53abab32..2938cd56 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -8,6 +8,7 @@ /// #include "Header.h" +#include "ezc3d.h" #include "Parameters.h" #include "DataStartInfo.h" diff --git a/src/Parameter.cpp b/src/Parameter.cpp index a8fb9a43..5bd00fe7 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -8,6 +8,7 @@ /// #include "Parameter.h" +#include "ezc3d.h" #include "Parameters.h" #include "DataStartInfo.h" diff --git a/src/Parameters.cpp b/src/Parameters.cpp index b1f781aa..a0272516 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -8,6 +8,7 @@ /// #include "Parameters.h" +#include "ezc3d.h" #include "Header.h" ezc3d::ParametersNS::Parameters::Parameters(): diff --git a/src/Point.cpp b/src/Point.cpp index 0f3ddbbe..320ccf7a 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -8,6 +8,7 @@ /// #include "Point.h" +#include "ezc3d.h" #include "Header.h" #include "PointsInfo.h" diff --git a/src/Points.cpp b/src/Points.cpp index 8dc0e0ef..f49f5198 100644 --- a/src/Points.cpp +++ b/src/Points.cpp @@ -8,6 +8,7 @@ /// #include "Points.h" +#include "ezc3d.h" #include "Header.h" // Point3d data diff --git a/src/PointsInfo.cpp b/src/PointsInfo.cpp index 9283f06e..e5936f45 100644 --- a/src/PointsInfo.cpp +++ b/src/PointsInfo.cpp @@ -8,6 +8,7 @@ /// #include "PointsInfo.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" diff --git a/src/Rotation.cpp b/src/Rotation.cpp index ee19aaef..abf69884 100644 --- a/src/Rotation.cpp +++ b/src/Rotation.cpp @@ -8,6 +8,7 @@ /// #include "Rotation.h" +#include "ezc3d.h" #include "RotationsInfo.h" #include diff --git a/src/Rotations.cpp b/src/Rotations.cpp index 32721265..cd47b3a2 100644 --- a/src/Rotations.cpp +++ b/src/Rotations.cpp @@ -8,6 +8,7 @@ /// #include "Rotations.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" #include "RotationsInfo.h" diff --git a/src/RotationsInfo.cpp b/src/RotationsInfo.cpp index 672e8457..702ebc74 100644 --- a/src/RotationsInfo.cpp +++ b/src/RotationsInfo.cpp @@ -8,6 +8,7 @@ /// #include "RotationsInfo.h" +#include "ezc3d.h" #include "Header.h" #include "Parameters.h" diff --git a/src/modules/ForcePlatforms.cpp b/src/modules/ForcePlatforms.cpp index 3e89265b..d53fc05d 100644 --- a/src/modules/ForcePlatforms.cpp +++ b/src/modules/ForcePlatforms.cpp @@ -8,7 +8,6 @@ /// #include "modules/ForcePlatforms.h" - #include "ezc3d_all.h" ezc3d::Modules::ForcePlatform::ForcePlatform() From 7f4bfb8527aa4ba9bd7b8a99e947c5f7ce464d4a Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:32:41 -0400 Subject: [PATCH 03/14] Minimize the number of includes --- binding/matlab/ezc3dRead.cpp | 2 ++ binding/matlab/utils.cpp | 1 + examples/force_plate_example.cpp | 3 ++- include/AnalogsInfo.h | 1 + include/AnalogsSubframe.h | 1 + include/Header.h | 1 + include/Parameter.h | 1 + include/ezc3d.h | 9 +-------- include/ezc3dNamespace.h | 8 -------- include/math/Matrix.h | 1 + src/Analogs.cpp | 1 + src/Channel.cpp | 1 + src/Data.cpp | 1 + src/Group.cpp | 1 + src/Header.cpp | 2 ++ src/Parameter.cpp | 1 + src/Parameters.cpp | 2 ++ src/Point.cpp | 3 ++- src/Rotation.cpp | 3 ++- src/Rotations.cpp | 1 + src/RotationsSubframe.cpp | 1 + src/ezc3d.cpp | 3 ++- src/math/Matrix.cpp | 1 + src/math/Vector3d.cpp | 2 ++ src/math/Vector6d.cpp | 1 + test/test_ezc3d.cpp | 1 + 26 files changed, 33 insertions(+), 20 deletions(-) diff --git a/binding/matlab/ezc3dRead.cpp b/binding/matlab/ezc3dRead.cpp index 7a96a67c..46f53ad1 100644 --- a/binding/matlab/ezc3dRead.cpp +++ b/binding/matlab/ezc3dRead.cpp @@ -8,6 +8,8 @@ #include "Parameters.h" #include "Data.h" #include "modules/ForcePlatforms.h" +#include +#include void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { diff --git a/binding/matlab/utils.cpp b/binding/matlab/utils.cpp index bbf7e918..d25595f5 100644 --- a/binding/matlab/utils.cpp +++ b/binding/matlab/utils.cpp @@ -3,6 +3,7 @@ #include #include "utils.h" +#include mxArray * fillMetadata( mxArray *field, diff --git a/examples/force_plate_example.cpp b/examples/force_plate_example.cpp index 027ba781..9af0572e 100644 --- a/examples/force_plate_example.cpp +++ b/examples/force_plate_example.cpp @@ -1,5 +1,6 @@ -#include #include "ezc3d_all.h" +#include +#include int main() { diff --git a/include/AnalogsInfo.h b/include/AnalogsInfo.h index 7ff40d34..b158bdc2 100644 --- a/include/AnalogsInfo.h +++ b/include/AnalogsInfo.h @@ -9,6 +9,7 @@ /// #include "ezc3dNamespace.h" +#include /// /// \brief 3D rotation data diff --git a/include/AnalogsSubframe.h b/include/AnalogsSubframe.h index 2f50d260..1e9473e6 100644 --- a/include/AnalogsSubframe.h +++ b/include/AnalogsSubframe.h @@ -9,6 +9,7 @@ /// #include "Channel.h" +#include /// /// \brief Subframe for the analogous data diff --git a/include/Header.h b/include/Header.h index c7f17aea..e148ad64 100644 --- a/include/Header.h +++ b/include/Header.h @@ -9,6 +9,7 @@ /// #include "ezc3dNamespace.h" +#include /// /// \brief Header of a C3D file diff --git a/include/Parameter.h b/include/Parameter.h index 6b458bba..0cd99306 100644 --- a/include/Parameter.h +++ b/include/Parameter.h @@ -9,6 +9,7 @@ /// #include "ezc3dNamespace.h" +#include /// /// \brief Parameter of a C3D file diff --git a/include/ezc3d.h b/include/ezc3d.h index 7b5d4731..443843b6 100644 --- a/include/ezc3d.h +++ b/include/ezc3d.h @@ -36,15 +36,8 @@ /// // Includes for standard library -#include -#include #include -#include #include -#include -#include -#include -#include #ifdef _WIN32 #include #endif @@ -123,7 +116,7 @@ class EZC3D_API ezc3d::c3d { unsigned int nByteToRead, std::vector& c, int nByteFromPrevious = 0, - const std::ios_base::seekdir &pos = std::ios::cur); + const std::ios_base::seekdir &pos = std::ios::cur); /// /// \brief Convert an hexadecimal value to an unsigned integer diff --git a/include/ezc3dNamespace.h b/include/ezc3dNamespace.h index f11d02cb..41d07f07 100644 --- a/include/ezc3dNamespace.h +++ b/include/ezc3dNamespace.h @@ -36,14 +36,6 @@ /// // Includes for standard library -#include -#include -#include -#include -#include -#include -#include -#include #include #ifdef _WIN32 #include diff --git a/include/math/Matrix.h b/include/math/Matrix.h index 2bdabeb7..3e44a0ef 100644 --- a/include/math/Matrix.h +++ b/include/math/Matrix.h @@ -9,6 +9,7 @@ /// #include "ezc3dNamespace.h" +#include /// /// \brief Matrix of unknown dimension diff --git a/src/Analogs.cpp b/src/Analogs.cpp index 7d78811a..367fae0e 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -10,6 +10,7 @@ #include "Analogs.h" #include "ezc3d.h" #include "Header.h" +#include ezc3d::DataNS::AnalogsNS::Analogs::Analogs() { diff --git a/src/Channel.cpp b/src/Channel.cpp index 6db3a76a..5c6ae1c0 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -11,6 +11,7 @@ #include "ezc3d.h" #include "Header.h" #include "AnalogsInfo.h" +#include ezc3d::DataNS::AnalogsNS::Channel::Channel() { diff --git a/src/Data.cpp b/src/Data.cpp index fa55a090..c998892b 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -15,6 +15,7 @@ #include "PointsInfo.h" #include "RotationsInfo.h" #include "DataStartInfo.h" +#include ezc3d::DataNS::Data::Data() { } diff --git a/src/Group.cpp b/src/Group.cpp index 94efe0a6..f165983a 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -10,6 +10,7 @@ #include "Group.h" #include "ezc3d.h" #include "Parameters.h" +#include ezc3d::ParametersNS::GroupNS::Group::Group( const std::string &name, diff --git a/src/Header.cpp b/src/Header.cpp index 2938cd56..76c5ef49 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -11,6 +11,8 @@ #include "ezc3d.h" #include "Parameters.h" #include "DataStartInfo.h" +#include +#include ezc3d::Header::Header(): _nbOfZerosBeforeHeader(0), diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 5bd00fe7..43cce976 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -11,6 +11,7 @@ #include "ezc3d.h" #include "Parameters.h" #include "DataStartInfo.h" +#include ezc3d::ParametersNS::GroupNS::Parameter::Parameter( const std::string &name, diff --git a/src/Parameters.cpp b/src/Parameters.cpp index a0272516..0d517d03 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -10,6 +10,8 @@ #include "Parameters.h" #include "ezc3d.h" #include "Header.h" +#include +#include ezc3d::ParametersNS::Parameters::Parameters(): _parametersStart(1), diff --git a/src/Point.cpp b/src/Point.cpp index 320ccf7a..4fbc9f59 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -11,8 +11,9 @@ #include "ezc3d.h" #include "Header.h" #include "PointsInfo.h" - +#include #include +#include ezc3d::DataNS::Points3dNS::Point::Point() : ezc3d::Vector3d(), diff --git a/src/Rotation.cpp b/src/Rotation.cpp index abf69884..898919eb 100644 --- a/src/Rotation.cpp +++ b/src/Rotation.cpp @@ -10,8 +10,9 @@ #include "Rotation.h" #include "ezc3d.h" #include "RotationsInfo.h" - +#include #include +#include ezc3d::DataNS::RotationNS::Rotation::Rotation() : ezc3d::Matrix44(), diff --git a/src/Rotations.cpp b/src/Rotations.cpp index cd47b3a2..c329e1b4 100644 --- a/src/Rotations.cpp +++ b/src/Rotations.cpp @@ -13,6 +13,7 @@ #include "Parameters.h" #include "RotationsInfo.h" #include "RotationsSubframe.h" +#include // Rotations data ezc3d::DataNS::RotationNS::Rotations::Rotations() diff --git a/src/RotationsSubframe.cpp b/src/RotationsSubframe.cpp index 48c851db..2ed55876 100644 --- a/src/RotationsSubframe.cpp +++ b/src/RotationsSubframe.cpp @@ -10,6 +10,7 @@ #include "RotationsSubframe.h" #include "Header.h" #include "RotationsInfo.h" +#include ezc3d::DataNS::RotationNS::SubFrame::SubFrame() { diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index 175e49f5..2af343eb 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -12,7 +12,8 @@ #include "Data.h" #include "Parameters.h" #include "DataStartInfo.h" - +#include +#include void ezc3d::removeTrailingSpaces( std::string& s) { diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 77e7ca81..2862da72 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -10,6 +10,7 @@ #include "math/Matrix.h" #include "math/Vector3d.h" #include "math/Vector6d.h" +#include ezc3d::Matrix::Matrix(): _nbRows(0), diff --git a/src/math/Vector3d.cpp b/src/math/Vector3d.cpp index b0514015..7d285e0e 100644 --- a/src/math/Vector3d.cpp +++ b/src/math/Vector3d.cpp @@ -8,6 +8,8 @@ /// #include "math/Vector3d.h" +#include +#include ezc3d::Vector3d::Vector3d() : ezc3d::Matrix(3, 1) diff --git a/src/math/Vector6d.cpp b/src/math/Vector6d.cpp index 17bfa294..2c263f4e 100644 --- a/src/math/Vector6d.cpp +++ b/src/math/Vector6d.cpp @@ -8,6 +8,7 @@ /// #include "math/Vector6d.h" +#include ezc3d::Vector6d::Vector6d() : ezc3d::Matrix(6, 1) diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index 590b2534..6436fadf 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -2,6 +2,7 @@ #include #include "ezc3d_all.h" +#include enum HEADER_TYPE{ ALL, From 46e90fb7acbc5f4b24227dbc15fd966f5be055a7 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:33:15 -0400 Subject: [PATCH 04/14] Removed the string in _WIN32 --- include/ezc3d.h | 3 --- include/ezc3dNamespace.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/include/ezc3d.h b/include/ezc3d.h index 443843b6..e16efb62 100644 --- a/include/ezc3d.h +++ b/include/ezc3d.h @@ -38,9 +38,6 @@ // Includes for standard library #include #include -#ifdef _WIN32 -#include -#endif #include "ezc3dConfig.h" #include "ezc3dNamespace.h" diff --git a/include/ezc3dNamespace.h b/include/ezc3dNamespace.h index 41d07f07..d1c08b0e 100644 --- a/include/ezc3dNamespace.h +++ b/include/ezc3dNamespace.h @@ -37,9 +37,6 @@ // Includes for standard library #include -#ifdef _WIN32 -#include -#endif #include "ezc3dConfig.h" From fd3de0609e7e3b68d371185874dbb19196902486 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:47:34 -0400 Subject: [PATCH 05/14] Fixed swig --- binding/ezc3d.i | 1 + include/ezc3d_all.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/binding/ezc3d.i b/binding/ezc3d.i index ec290c5e..9158a991 100644 --- a/binding/ezc3d.i +++ b/binding/ezc3d.i @@ -58,6 +58,7 @@ namespace std { #define __attribute__(x) %include "ezc3dConfig.h" +%include "ezc3dNamespace.h" %include "ezc3d.h" %include "math/Matrix.h" %include "math/Matrix33.h" diff --git a/include/ezc3d_all.h b/include/ezc3d_all.h index 6f0a1f86..d8694aa3 100644 --- a/include/ezc3d_all.h +++ b/include/ezc3d_all.h @@ -8,7 +8,7 @@ /// \date March 27th, 2020 /// - +#include "ezc3dNamespace.h" #include "math/ezc3dMath.h" #include "ezc3d.h" #include "Header.h" From 79fb66360561c89f1d143bd1be45cdea629aee57 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 10:51:28 -0400 Subject: [PATCH 06/14] Fixed windows string --- src/Analogs.cpp | 3 +++ src/Channel.cpp | 3 +++ src/Data.cpp | 3 +++ src/Group.cpp | 3 +++ src/Header.cpp | 3 +++ src/Parameter.cpp | 3 +++ src/Parameters.cpp | 3 +++ src/Point.cpp | 3 +++ src/Rotation.cpp | 3 +++ src/Rotations.cpp | 3 +++ src/RotationsSubframe.cpp | 3 +++ src/math/Matrix.cpp | 3 +++ src/math/Vector3d.cpp | 3 +++ src/math/Vector6d.cpp | 3 +++ test/test_ezc3d.cpp | 3 +++ test/test_math.cpp | 3 +++ 16 files changed, 48 insertions(+) diff --git a/src/Analogs.cpp b/src/Analogs.cpp index 367fae0e..8bd46316 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -11,6 +11,9 @@ #include "ezc3d.h" #include "Header.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::DataNS::AnalogsNS::Analogs::Analogs() { diff --git a/src/Channel.cpp b/src/Channel.cpp index 5c6ae1c0..5476b897 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -12,6 +12,9 @@ #include "Header.h" #include "AnalogsInfo.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::DataNS::AnalogsNS::Channel::Channel() { diff --git a/src/Data.cpp b/src/Data.cpp index c998892b..2ad5ca20 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -16,6 +16,9 @@ #include "RotationsInfo.h" #include "DataStartInfo.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::DataNS::Data::Data() { } diff --git a/src/Group.cpp b/src/Group.cpp index f165983a..922a7069 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -11,6 +11,9 @@ #include "ezc3d.h" #include "Parameters.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::ParametersNS::GroupNS::Group::Group( const std::string &name, diff --git a/src/Header.cpp b/src/Header.cpp index 76c5ef49..ec7bd26a 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -12,6 +12,9 @@ #include "Parameters.h" #include "DataStartInfo.h" #include +#ifdef _WIN32 +#include +#endif #include ezc3d::Header::Header(): diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 43cce976..912b24e1 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -12,6 +12,9 @@ #include "Parameters.h" #include "DataStartInfo.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::ParametersNS::GroupNS::Parameter::Parameter( const std::string &name, diff --git a/src/Parameters.cpp b/src/Parameters.cpp index 0d517d03..8db36d87 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -11,6 +11,9 @@ #include "ezc3d.h" #include "Header.h" #include +#ifdef _WIN32 +#include +#endif #include ezc3d::ParametersNS::Parameters::Parameters(): diff --git a/src/Point.cpp b/src/Point.cpp index 4fbc9f59..3e5327bd 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -12,6 +12,9 @@ #include "Header.h" #include "PointsInfo.h" #include +#ifdef _WIN32 +#include +#endif #include #include diff --git a/src/Rotation.cpp b/src/Rotation.cpp index 898919eb..1eb6e315 100644 --- a/src/Rotation.cpp +++ b/src/Rotation.cpp @@ -11,6 +11,9 @@ #include "ezc3d.h" #include "RotationsInfo.h" #include +#ifdef _WIN32 +#include +#endif #include #include diff --git a/src/Rotations.cpp b/src/Rotations.cpp index c329e1b4..199702e2 100644 --- a/src/Rotations.cpp +++ b/src/Rotations.cpp @@ -14,6 +14,9 @@ #include "RotationsInfo.h" #include "RotationsSubframe.h" #include +#ifdef _WIN32 +#include +#endif // Rotations data ezc3d::DataNS::RotationNS::Rotations::Rotations() diff --git a/src/RotationsSubframe.cpp b/src/RotationsSubframe.cpp index 2ed55876..ffe60592 100644 --- a/src/RotationsSubframe.cpp +++ b/src/RotationsSubframe.cpp @@ -11,6 +11,9 @@ #include "Header.h" #include "RotationsInfo.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::DataNS::RotationNS::SubFrame::SubFrame() { diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 2862da72..2f49ed96 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -11,6 +11,9 @@ #include "math/Vector3d.h" #include "math/Vector6d.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::Matrix::Matrix(): _nbRows(0), diff --git a/src/math/Vector3d.cpp b/src/math/Vector3d.cpp index 7d285e0e..69e0f650 100644 --- a/src/math/Vector3d.cpp +++ b/src/math/Vector3d.cpp @@ -9,6 +9,9 @@ #include "math/Vector3d.h" #include +#ifdef _WIN32 +#include +#endif #include ezc3d::Vector3d::Vector3d() : diff --git a/src/math/Vector6d.cpp b/src/math/Vector6d.cpp index 2c263f4e..1d4298e4 100644 --- a/src/math/Vector6d.cpp +++ b/src/math/Vector6d.cpp @@ -9,6 +9,9 @@ #include "math/Vector6d.h" #include +#ifdef _WIN32 +#include +#endif ezc3d::Vector6d::Vector6d() : ezc3d::Matrix(6, 1) diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index 6436fadf..b93d6760 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -3,6 +3,9 @@ #include "ezc3d_all.h" #include +#ifdef _WIN32 +#include +#endif enum HEADER_TYPE{ ALL, diff --git a/test/test_math.cpp b/test/test_math.cpp index 509e23a3..d5ea023b 100644 --- a/test/test_math.cpp +++ b/test/test_math.cpp @@ -2,6 +2,9 @@ #include #include "ezc3d_all.h" +#ifdef _WIN32 +#include +#endif void testPrintingCall(const ezc3d::Matrix& m){ std::streambuf *old = std::cout.rdbuf(); // Save cout direction From ec63c6fc56e2329ae390cb1db2453aaeeb34ae57 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 11:12:59 -0400 Subject: [PATCH 07/14] Fixed octave binder --- binding/matlab/utils.cpp | 3 +++ binding/octave/utils.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/binding/matlab/utils.cpp b/binding/matlab/utils.cpp index d25595f5..34e2d81f 100644 --- a/binding/matlab/utils.cpp +++ b/binding/matlab/utils.cpp @@ -1,5 +1,8 @@ #include "mex.h" #include +#ifdef _WIN32 +#include +#endif #include #include "utils.h" diff --git a/binding/octave/utils.cpp b/binding/octave/utils.cpp index c65ca912..33493bb2 100644 --- a/binding/octave/utils.cpp +++ b/binding/octave/utils.cpp @@ -1,8 +1,13 @@ #include "mex.h" #include +#include +#ifdef _WIN32 +#include +#endif #include #include "utils.h" +#include mxArray * fillMetadata( mxArray *field, From ac6013f9416c1064e0454fc0af2a3222c8681841 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 11:13:07 -0400 Subject: [PATCH 08/14] Refixed Windows includes --- include/ezc3dNamespace.h | 3 +++ src/Analogs.cpp | 3 --- src/Channel.cpp | 3 --- src/Data.cpp | 3 --- src/Group.cpp | 3 --- src/Header.cpp | 3 --- src/Parameter.cpp | 3 --- src/Parameters.cpp | 3 --- src/Point.cpp | 3 --- src/Rotation.cpp | 3 --- src/Rotations.cpp | 3 --- src/math/Matrix.cpp | 3 --- src/math/Vector3d.cpp | 3 --- src/math/Vector6d.cpp | 3 --- test/test_ezc3d.cpp | 3 --- test/test_math.cpp | 3 --- 16 files changed, 3 insertions(+), 45 deletions(-) diff --git a/include/ezc3dNamespace.h b/include/ezc3dNamespace.h index d1c08b0e..ae3e9c34 100644 --- a/include/ezc3dNamespace.h +++ b/include/ezc3dNamespace.h @@ -39,6 +39,9 @@ #include #include "ezc3dConfig.h" +#ifdef _WIN32 +#include +#endif /// /// \brief Namespace ezc3d diff --git a/src/Analogs.cpp b/src/Analogs.cpp index 8bd46316..367fae0e 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -11,9 +11,6 @@ #include "ezc3d.h" #include "Header.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::DataNS::AnalogsNS::Analogs::Analogs() { diff --git a/src/Channel.cpp b/src/Channel.cpp index 5476b897..5c6ae1c0 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -12,9 +12,6 @@ #include "Header.h" #include "AnalogsInfo.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::DataNS::AnalogsNS::Channel::Channel() { diff --git a/src/Data.cpp b/src/Data.cpp index 2ad5ca20..c998892b 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -16,9 +16,6 @@ #include "RotationsInfo.h" #include "DataStartInfo.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::DataNS::Data::Data() { } diff --git a/src/Group.cpp b/src/Group.cpp index 922a7069..f165983a 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -11,9 +11,6 @@ #include "ezc3d.h" #include "Parameters.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::ParametersNS::GroupNS::Group::Group( const std::string &name, diff --git a/src/Header.cpp b/src/Header.cpp index ec7bd26a..76c5ef49 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -12,9 +12,6 @@ #include "Parameters.h" #include "DataStartInfo.h" #include -#ifdef _WIN32 -#include -#endif #include ezc3d::Header::Header(): diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 912b24e1..43cce976 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -12,9 +12,6 @@ #include "Parameters.h" #include "DataStartInfo.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::ParametersNS::GroupNS::Parameter::Parameter( const std::string &name, diff --git a/src/Parameters.cpp b/src/Parameters.cpp index 8db36d87..0d517d03 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -11,9 +11,6 @@ #include "ezc3d.h" #include "Header.h" #include -#ifdef _WIN32 -#include -#endif #include ezc3d::ParametersNS::Parameters::Parameters(): diff --git a/src/Point.cpp b/src/Point.cpp index 3e5327bd..4fbc9f59 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -12,9 +12,6 @@ #include "Header.h" #include "PointsInfo.h" #include -#ifdef _WIN32 -#include -#endif #include #include diff --git a/src/Rotation.cpp b/src/Rotation.cpp index 1eb6e315..898919eb 100644 --- a/src/Rotation.cpp +++ b/src/Rotation.cpp @@ -11,9 +11,6 @@ #include "ezc3d.h" #include "RotationsInfo.h" #include -#ifdef _WIN32 -#include -#endif #include #include diff --git a/src/Rotations.cpp b/src/Rotations.cpp index 199702e2..c329e1b4 100644 --- a/src/Rotations.cpp +++ b/src/Rotations.cpp @@ -14,9 +14,6 @@ #include "RotationsInfo.h" #include "RotationsSubframe.h" #include -#ifdef _WIN32 -#include -#endif // Rotations data ezc3d::DataNS::RotationNS::Rotations::Rotations() diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 2f49ed96..2862da72 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -11,9 +11,6 @@ #include "math/Vector3d.h" #include "math/Vector6d.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::Matrix::Matrix(): _nbRows(0), diff --git a/src/math/Vector3d.cpp b/src/math/Vector3d.cpp index 69e0f650..7d285e0e 100644 --- a/src/math/Vector3d.cpp +++ b/src/math/Vector3d.cpp @@ -9,9 +9,6 @@ #include "math/Vector3d.h" #include -#ifdef _WIN32 -#include -#endif #include ezc3d::Vector3d::Vector3d() : diff --git a/src/math/Vector6d.cpp b/src/math/Vector6d.cpp index 1d4298e4..2c263f4e 100644 --- a/src/math/Vector6d.cpp +++ b/src/math/Vector6d.cpp @@ -9,9 +9,6 @@ #include "math/Vector6d.h" #include -#ifdef _WIN32 -#include -#endif ezc3d::Vector6d::Vector6d() : ezc3d::Matrix(6, 1) diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index b93d6760..6436fadf 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -3,9 +3,6 @@ #include "ezc3d_all.h" #include -#ifdef _WIN32 -#include -#endif enum HEADER_TYPE{ ALL, diff --git a/test/test_math.cpp b/test/test_math.cpp index d5ea023b..509e23a3 100644 --- a/test/test_math.cpp +++ b/test/test_math.cpp @@ -2,9 +2,6 @@ #include #include "ezc3d_all.h" -#ifdef _WIN32 -#include -#endif void testPrintingCall(const ezc3d::Matrix& m){ std::streambuf *old = std::cout.rdbuf(); // Save cout direction From 7252979b965e76f05ad7b18fd0287964b34f5d27 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 11:33:15 -0400 Subject: [PATCH 09/14] Fixed include for octave and error --- binding/octave/ezc3dRead.cpp | 2 ++ include/Parameter.h | 4 ++++ src/Frame.cpp | 1 + src/Group.cpp | 1 + src/Header.cpp | 1 + src/Parameter.cpp | 1 + src/Parameters.cpp | 1 + src/Point.cpp | 1 + src/RotationsInfo.cpp | 1 + src/ezc3d.cpp | 1 + src/math/Matrix.cpp | 1 + src/math/Matrix33.cpp | 1 + src/math/Matrix44.cpp | 1 + src/math/Matrix66.cpp | 1 + src/math/Vector3d.cpp | 1 + src/math/Vector6d.cpp | 1 + src/modules/ForcePlatforms.cpp | 1 + test/test_ezc3d.cpp | 1 + test/test_math.cpp | 1 + 19 files changed, 23 insertions(+) diff --git a/binding/octave/ezc3dRead.cpp b/binding/octave/ezc3dRead.cpp index c4e05384..cbd621e7 100644 --- a/binding/octave/ezc3dRead.cpp +++ b/binding/octave/ezc3dRead.cpp @@ -12,6 +12,8 @@ #endif #include "Frame.h" #include "modules/ForcePlatforms.h" +#include +#include void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { diff --git a/include/Parameter.h b/include/Parameter.h index 0cd99306..3cda65a2 100644 --- a/include/Parameter.h +++ b/include/Parameter.h @@ -10,6 +10,10 @@ #include "ezc3dNamespace.h" #include +#include +#ifdef _WIN32 +#include +#endif /// /// \brief Parameter of a C3D file diff --git a/src/Frame.cpp b/src/Frame.cpp index e4c8d09f..48c80461 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -9,6 +9,7 @@ #include "Frame.h" #include "DataStartInfo.h" +#include ezc3d::DataNS::Frame::Frame() { _points = std::shared_ptr( diff --git a/src/Group.cpp b/src/Group.cpp index f165983a..6cb9f3d4 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -11,6 +11,7 @@ #include "ezc3d.h" #include "Parameters.h" #include +#include ezc3d::ParametersNS::GroupNS::Group::Group( const std::string &name, diff --git a/src/Header.cpp b/src/Header.cpp index 76c5ef49..de8ba5bf 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -13,6 +13,7 @@ #include "DataStartInfo.h" #include #include +#include ezc3d::Header::Header(): _nbOfZerosBeforeHeader(0), diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 43cce976..d769c47c 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -12,6 +12,7 @@ #include "Parameters.h" #include "DataStartInfo.h" #include +#include ezc3d::ParametersNS::GroupNS::Parameter::Parameter( const std::string &name, diff --git a/src/Parameters.cpp b/src/Parameters.cpp index 0d517d03..697c83d0 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -12,6 +12,7 @@ #include "Header.h" #include #include +#include ezc3d::ParametersNS::Parameters::Parameters(): _parametersStart(1), diff --git a/src/Point.cpp b/src/Point.cpp index 4fbc9f59..b5a138bf 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -14,6 +14,7 @@ #include #include #include +#include ezc3d::DataNS::Points3dNS::Point::Point() : ezc3d::Vector3d(), diff --git a/src/RotationsInfo.cpp b/src/RotationsInfo.cpp index 702ebc74..131ae720 100644 --- a/src/RotationsInfo.cpp +++ b/src/RotationsInfo.cpp @@ -11,6 +11,7 @@ #include "ezc3d.h" #include "Header.h" #include "Parameters.h" +#include ezc3d::DataNS::RotationNS::Info::Info( diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index 2af343eb..d0ffd9c8 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -14,6 +14,7 @@ #include "DataStartInfo.h" #include #include +#include void ezc3d::removeTrailingSpaces( std::string& s) { diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 2862da72..66c7e7d0 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -11,6 +11,7 @@ #include "math/Vector3d.h" #include "math/Vector6d.h" #include +#include ezc3d::Matrix::Matrix(): _nbRows(0), diff --git a/src/math/Matrix33.cpp b/src/math/Matrix33.cpp index 1b07220a..18452a67 100644 --- a/src/math/Matrix33.cpp +++ b/src/math/Matrix33.cpp @@ -10,6 +10,7 @@ #include "math/Matrix33.h" #include "math/Vector3d.h" +#include ezc3d::Matrix33::Matrix33() : ezc3d::Matrix(3, 3) diff --git a/src/math/Matrix44.cpp b/src/math/Matrix44.cpp index 12118b2e..041c58c7 100644 --- a/src/math/Matrix44.cpp +++ b/src/math/Matrix44.cpp @@ -10,6 +10,7 @@ #include "math/Matrix44.h" #include "math/Vector3d.h" +#include ezc3d::Matrix44::Matrix44() : ezc3d::Matrix(4, 4) diff --git a/src/math/Matrix66.cpp b/src/math/Matrix66.cpp index 3483d333..41970d35 100644 --- a/src/math/Matrix66.cpp +++ b/src/math/Matrix66.cpp @@ -10,6 +10,7 @@ #include "math/Matrix66.h" #include "math/Vector6d.h" +#include ezc3d::Matrix66::Matrix66() : ezc3d::Matrix(6, 6) diff --git a/src/math/Vector3d.cpp b/src/math/Vector3d.cpp index 7d285e0e..8c640279 100644 --- a/src/math/Vector3d.cpp +++ b/src/math/Vector3d.cpp @@ -10,6 +10,7 @@ #include "math/Vector3d.h" #include #include +#include ezc3d::Vector3d::Vector3d() : ezc3d::Matrix(3, 1) diff --git a/src/math/Vector6d.cpp b/src/math/Vector6d.cpp index 2c263f4e..5420d8fb 100644 --- a/src/math/Vector6d.cpp +++ b/src/math/Vector6d.cpp @@ -9,6 +9,7 @@ #include "math/Vector6d.h" #include +#include ezc3d::Vector6d::Vector6d() : ezc3d::Matrix(6, 1) diff --git a/src/modules/ForcePlatforms.cpp b/src/modules/ForcePlatforms.cpp index d53fc05d..485808db 100644 --- a/src/modules/ForcePlatforms.cpp +++ b/src/modules/ForcePlatforms.cpp @@ -9,6 +9,7 @@ #include "modules/ForcePlatforms.h" #include "ezc3d_all.h" +#include ezc3d::Modules::ForcePlatform::ForcePlatform() { diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index 6436fadf..3bf46638 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -3,6 +3,7 @@ #include "ezc3d_all.h" #include +#include enum HEADER_TYPE{ ALL, diff --git a/test/test_math.cpp b/test/test_math.cpp index 509e23a3..d4d2dac4 100644 --- a/test/test_math.cpp +++ b/test/test_math.cpp @@ -2,6 +2,7 @@ #include #include "ezc3d_all.h" +#include void testPrintingCall(const ezc3d::Matrix& m){ std::streambuf *old = std::cout.rdbuf(); // Save cout direction From a3735a743d0fdb19e046f71d0a51e81b65a92270 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 12:34:41 -0400 Subject: [PATCH 10/14] fixed #include --- src/Analogs.cpp | 1 + src/AnalogsSubframe.cpp | 1 + src/Data.cpp | 1 + src/DataStartInfo.cpp | 1 + src/Points.cpp | 1 + src/Rotations.cpp | 1 + src/RotationsSubframe.cpp | 1 + test/test_modules.cpp | 1 + 8 files changed, 8 insertions(+) diff --git a/src/Analogs.cpp b/src/Analogs.cpp index 367fae0e..aa0abd98 100644 --- a/src/Analogs.cpp +++ b/src/Analogs.cpp @@ -11,6 +11,7 @@ #include "ezc3d.h" #include "Header.h" #include +#include ezc3d::DataNS::AnalogsNS::Analogs::Analogs() { diff --git a/src/AnalogsSubframe.cpp b/src/AnalogsSubframe.cpp index d6b8b69f..90adda5d 100644 --- a/src/AnalogsSubframe.cpp +++ b/src/AnalogsSubframe.cpp @@ -10,6 +10,7 @@ #include "AnalogsSubframe.h" #include "ezc3d.h" #include "Header.h" +#include ezc3d::DataNS::AnalogsNS::SubFrame::SubFrame() { diff --git a/src/Data.cpp b/src/Data.cpp index c998892b..54cae2d9 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -16,6 +16,7 @@ #include "RotationsInfo.h" #include "DataStartInfo.h" #include +#include ezc3d::DataNS::Data::Data() { } diff --git a/src/DataStartInfo.cpp b/src/DataStartInfo.cpp index 55ccc589..b52f2f9c 100644 --- a/src/DataStartInfo.cpp +++ b/src/DataStartInfo.cpp @@ -8,6 +8,7 @@ /// #include "DataStartInfo.h" +#include void ezc3d::DataStartInfo::setPointDataStart( const std::streampos &value) diff --git a/src/Points.cpp b/src/Points.cpp index f49f5198..4510153f 100644 --- a/src/Points.cpp +++ b/src/Points.cpp @@ -10,6 +10,7 @@ #include "Points.h" #include "ezc3d.h" #include "Header.h" +#include // Point3d data ezc3d::DataNS::Points3dNS::Points::Points() { diff --git a/src/Rotations.cpp b/src/Rotations.cpp index c329e1b4..3aef07b4 100644 --- a/src/Rotations.cpp +++ b/src/Rotations.cpp @@ -14,6 +14,7 @@ #include "RotationsInfo.h" #include "RotationsSubframe.h" #include +#include // Rotations data ezc3d::DataNS::RotationNS::Rotations::Rotations() diff --git a/src/RotationsSubframe.cpp b/src/RotationsSubframe.cpp index ffe60592..9ad24078 100644 --- a/src/RotationsSubframe.cpp +++ b/src/RotationsSubframe.cpp @@ -14,6 +14,7 @@ #ifdef _WIN32 #include #endif +#include ezc3d::DataNS::RotationNS::SubFrame::SubFrame() { diff --git a/test/test_modules.cpp b/test/test_modules.cpp index a9d00fb3..6180ba53 100644 --- a/test/test_modules.cpp +++ b/test/test_modules.cpp @@ -2,6 +2,7 @@ #include #include "ezc3d_all.h" +#include TEST(ForcePlatForm, NoPlatForm){ ezc3d::c3d c3d("c3dTestFiles/Vicon.c3d"); From 62ea63605d0888383c63639e54421416569a4b61 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 12:44:28 -0400 Subject: [PATCH 11/14] Fixed the python test for Data-start --- test/python3/test_binder_python.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/python3/test_binder_python.py b/test/python3/test_binder_python.py index 179e753e..381e8747 100644 --- a/test/python3/test_binder_python.py +++ b/test/python3/test_binder_python.py @@ -504,6 +504,8 @@ def c3d_build_rebuild_reduced(request): original = ezc3d.c3d(orig_file.as_posix()) original.write(rebuild_file.as_posix()) rebuilt = ezc3d.c3d(rebuild_file.as_posix()) + if request.param == "C3DRotationExample": + rebuilt["parameters"]["ROTATION"]["DATA_START"]["value"][0] = 6 yield (original, rebuilt) From 316737043df2056185239c35b59b031ff815cc7e Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 13:19:05 -0400 Subject: [PATCH 12/14] Fixed macosx complaints about setting a stream to -1 --- include/DataStartInfo.h | 44 ++++++++++++++++++++++++++++++++++++----- src/DataStartInfo.cpp | 38 +++++++++++++++++++++++++++++++---- src/ezc3d.cpp | 6 +++--- 3 files changed, 76 insertions(+), 12 deletions(-) diff --git a/include/DataStartInfo.h b/include/DataStartInfo.h index 4a1b7008..49dbdb02 100644 --- a/include/DataStartInfo.h +++ b/include/DataStartInfo.h @@ -15,9 +15,16 @@ class EZC3D_API ezc3d::DataStartInfo{ protected: - std::streampos m_pointDataStart = -1; ///< The data start for the points + bool m_hasPointDataStart = false; ///< If the point data start is set + std::streampos m_pointDataStart; ///< The data start for the points public: + /// + /// \brief Returns if the point data start is set + /// \return If the point data start is set + /// + bool hasPointDataStart() const; + /// /// \brief The point data start /// \param value The starting position of the points data in the c3d file @@ -32,10 +39,17 @@ class EZC3D_API ezc3d::DataStartInfo{ protected: - std::streampos m_headerPointDataStart = -1; ///< Position in the c3d to put the point start start in the header + bool m_hasHeaderPointDataStart = false; ///< If the point data start is set for the header + std::streampos m_headerPointDataStart; ///< Position in the c3d to put the point start start in the header DATA_TYPE m_headerPointDataStartSize = DATA_TYPE::WORD; ///< The size of the value in the c3d file public: + /// + /// \brief Returns if the point data start is set for the header + /// \return If the point data start is set for the header + /// + bool hasHeaderPointDataStart() const; + /// /// \brief The position in the c3d where to put the header point data start /// \param position @@ -55,10 +69,16 @@ class EZC3D_API ezc3d::DataStartInfo{ DATA_TYPE headerPointDataStartSize() const; protected: - std::streampos m_parameterPointDataStart = -1; ///< Position in the c3d to put the point start start in the parameters + bool m_hasParameterPointDataStart = false; ///< If the point data start is set for the parameters + std::streampos m_parameterPointDataStart; ///< Position in the c3d to put the point start start in the parameters DATA_TYPE m_parameterPointDataStartSize = DATA_TYPE::BYTE; ///< The size of the value in the c3d file public: + /// + /// \brief Returns if the point data start is set for the parameters + /// \return If the point data start is set for the parameters + /// + bool hasParameterPointDataStart() const; /// /// \brief The position in the c3d where to put the parameter point data start /// \param position @@ -78,9 +98,16 @@ class EZC3D_API ezc3d::DataStartInfo{ DATA_TYPE parameterPointDataStartSize() const; protected: - std::streampos m_rotationsDataStart = -1; ///< The data start for the rotations + bool m_hasRotationDataStart = false; ///< If the rotation data start is set + std::streampos m_rotationsDataStart; ///< The data start for the rotations public: + /// + /// \brief Returns if the rotations data start is set + /// \return If the rotations data start is set + /// + bool hasRotationsDataStart() const; + /// /// \brief The rotations data start /// \param value The starting position of the rotations data in the c3d file @@ -94,10 +121,17 @@ class EZC3D_API ezc3d::DataStartInfo{ const std::streampos& rotationsDataStart() const; protected: - std::streampos m_parameterRotationsDataStart = -1; ///< Position in the c3d to put the rotations start start in the parameters + bool m_hasParameterRotationsDataStart = false; ///< If the rotations data start is set for the parameters + std::streampos m_parameterRotationsDataStart; ///< Position in the c3d to put the rotations start start in the parameters DATA_TYPE m_parameterRotationsDataStartSize = DATA_TYPE::BYTE; ///< The size of the value in the c3d file public: + /// + /// \brief Returns if the rotations data start is set for the parameters + /// \return If the rotations data start is set for the parameters + /// + bool hasParameterRotationsDataStart() const; + /// /// \brief The position in the c3d where to put the parameter rotations data start /// \param position diff --git a/src/DataStartInfo.cpp b/src/DataStartInfo.cpp index b52f2f9c..100d9b58 100644 --- a/src/DataStartInfo.cpp +++ b/src/DataStartInfo.cpp @@ -10,6 +10,11 @@ #include "DataStartInfo.h" #include +bool ezc3d::DataStartInfo::hasPointDataStart() const +{ + return m_hasPointDataStart; +} + void ezc3d::DataStartInfo::setPointDataStart( const std::streampos &value) { @@ -18,6 +23,7 @@ void ezc3d::DataStartInfo::setPointDataStart( throw std::out_of_range( "Something went wrong in the positioning of the pointer " "for writting the data. Please report this error."); + m_hasPointDataStart = true; } const std::streampos &ezc3d::DataStartInfo::pointDataStart() const @@ -25,10 +31,16 @@ const std::streampos &ezc3d::DataStartInfo::pointDataStart() const return m_pointDataStart; } +bool ezc3d::DataStartInfo::hasHeaderPointDataStart() const +{ + return m_hasHeaderPointDataStart; +} + void ezc3d::DataStartInfo::setHeaderPositionInC3dForPointDataStart( const std::streampos &position) { m_headerPointDataStart = position; + m_hasHeaderPointDataStart = true; } const std::streampos &ezc3d::DataStartInfo::headerPointDataStart() const @@ -41,10 +53,16 @@ ezc3d::DATA_TYPE ezc3d::DataStartInfo::headerPointDataStartSize() const return m_headerPointDataStartSize; } +bool ezc3d::DataStartInfo::hasParameterPointDataStart() const +{ + return m_hasParameterPointDataStart; +} + void ezc3d::DataStartInfo::setParameterPositionInC3dForPointDataStart( const std::streampos &position) { m_parameterPointDataStart = position; + m_hasParameterPointDataStart = true; } const std::streampos &ezc3d::DataStartInfo::parameterPointDataStart() const @@ -57,25 +75,37 @@ ezc3d::DATA_TYPE ezc3d::DataStartInfo::parameterPointDataStartSize() const return m_parameterPointDataStartSize; } +bool ezc3d::DataStartInfo::hasRotationsDataStart() const +{ + return m_hasRotationDataStart; +} + void ezc3d::DataStartInfo::setRotationsDataStart( const std::streampos &value) { m_rotationsDataStart = value; + if (int(m_rotationsDataStart) % 512 > 0) + throw std::out_of_range( + "Something went wrong in the positioning of the pointer " + "for writting the data. Please report this error."); + m_hasRotationDataStart = true; } const std::streampos &ezc3d::DataStartInfo::rotationsDataStart() const { return m_rotationsDataStart; - if (int(m_rotationsDataStart) % 512 > 0) - throw std::out_of_range( - "Something went wrong in the positioning of the pointer " - "for writting the data. Please report this error."); +} + +bool ezc3d::DataStartInfo::hasParameterRotationsDataStart() const +{ + return m_hasRotationDataStart; } void ezc3d::DataStartInfo::setParameterPositionInC3dForRotationsDataStart( const std::streampos &position) { m_parameterRotationsDataStart = position; + m_hasParameterRotationsDataStart = true; } const std::streampos &ezc3d::DataStartInfo::parameterRotationsDataStart() const diff --git a/src/ezc3d.cpp b/src/ezc3d.cpp index d0ffd9c8..4c2922df 100644 --- a/src/ezc3d.cpp +++ b/src/ezc3d.cpp @@ -169,19 +169,19 @@ void ezc3d::c3d::writeDataStart( std::fstream &f, const ezc3d::DataStartInfo &dataStartPosition) const { - if (dataStartPosition.headerPointDataStart() != -1){ + if (dataStartPosition.hasHeaderPointDataStart()){ f.seekg(dataStartPosition.headerPointDataStart()); int nBlocksToNext = int(dataStartPosition.pointDataStart())/512 + 1; // DATA_START is 1-based f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.headerPointDataStartSize()); } - if (dataStartPosition.parameterPointDataStart() != -1){ + if (dataStartPosition.hasParameterPointDataStart()){ f.seekg(dataStartPosition.parameterPointDataStart()); int nBlocksToNext = int(dataStartPosition.pointDataStart())/512 + 1; // DATA_START is 1-based f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.parameterPointDataStartSize()); } - if (dataStartPosition.parameterRotationsDataStart() != -1){ + if (dataStartPosition.hasParameterRotationsDataStart()){ f.seekg(dataStartPosition.parameterRotationsDataStart()); int nBlocksToNext = int(dataStartPosition.rotationsDataStart())/512 + 1; // DATA_START is 1-based f.write(reinterpret_cast(&nBlocksToNext), dataStartPosition.parameterRotationsDataStartSize()); From 5dfdde8b154bb6f183db0f23165afa7c07c4488c Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 13:41:32 -0400 Subject: [PATCH 13/14] Included a mandatory header for macosx --- include/DataStartInfo.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/DataStartInfo.h b/include/DataStartInfo.h index 49dbdb02..efba82cc 100644 --- a/include/DataStartInfo.h +++ b/include/DataStartInfo.h @@ -9,6 +9,8 @@ /// #include "ezc3dNamespace.h" +#include + /// /// \brief Placeholder for stocking the position and value of data start /// From 47bd292e38df213afd32b54e733d2b90ae28e4af Mon Sep 17 00:00:00 2001 From: Pariterre Date: Sat, 7 May 2022 14:01:22 -0400 Subject: [PATCH 14/14] same --- include/modules/ForcePlatforms.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/modules/ForcePlatforms.h b/include/modules/ForcePlatforms.h index 9444ccdf..f986223e 100644 --- a/include/modules/ForcePlatforms.h +++ b/include/modules/ForcePlatforms.h @@ -13,6 +13,7 @@ #include "math/Matrix33.h" #include "math/Matrix66.h" #include "math/Vector3d.h" +#include /// /// \brief Force Platform analyse