Skip to content

Commit

Permalink
Merge pull request #242 from pariterre/dev
Browse files Browse the repository at this point in the history
Finalized Rotation group
  • Loading branch information
pariterre authored May 8, 2022
2 parents f67861f + 47bd292 commit 64b4d02
Show file tree
Hide file tree
Showing 54 changed files with 681 additions and 217 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions binding/ezc3d.i
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions binding/matlab/ezc3dRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Parameters.h"
#include "Data.h"
#include "modules/ForcePlatforms.h"
#include <string.h>
#include <cmath>

void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
Expand Down
4 changes: 4 additions & 0 deletions binding/matlab/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include "mex.h"
#include <iostream>
#ifdef _WIN32
#include <string>
#endif
#include <memory>

#include "utils.h"
#include <string.h>

mxArray * fillMetadata(
mxArray *field,
Expand Down
2 changes: 2 additions & 0 deletions binding/octave/ezc3dRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#endif
#include "Frame.h"
#include "modules/ForcePlatforms.h"
#include <string.h>
#include <cmath>

void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
Expand Down
5 changes: 5 additions & 0 deletions binding/octave/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "mex.h"
#include <iostream>
#include <iostream>
#ifdef _WIN32
#include <string>
#endif
#include <memory>

#include "utils.h"
#include <string.h>

mxArray * fillMetadata(
mxArray *field,
Expand Down
3 changes: 2 additions & 1 deletion examples/force_plate_example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <vector>
#include "ezc3d_all.h"
#include <iostream>
#include <vector>

int main()
{
Expand Down
3 changes: 2 additions & 1 deletion include/AnalogsInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/// \date April 30th, 2022
///

#include "ezc3d.h"
#include "ezc3dNamespace.h"
#include <vector>

///
/// \brief 3D rotation data
Expand Down
1 change: 1 addition & 0 deletions include/AnalogsSubframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
///

#include "Channel.h"
#include <vector>

///
/// \brief Subframe for the analogous data
Expand Down
2 changes: 1 addition & 1 deletion include/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// \date October 17th, 2018
///

#include "ezc3d.h"
#include "ezc3dNamespace.h"

///
/// \brief Channel of an analogous data
Expand Down
6 changes: 5 additions & 1 deletion include/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> analogScaleFactors) const;
std::vector<double> analogScaleFactors,
ezc3d::DataStartInfo& dataStartInfoToFill) const;


//---- FRAME ----//
Expand Down
156 changes: 156 additions & 0 deletions include/DataStartInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#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 "ezc3dNamespace.h"
#include <sstream>

///
/// \brief Placeholder for stocking the position and value of data start
///
class EZC3D_API ezc3d::DataStartInfo{

protected:
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
///
void setPointDataStart(const std::streampos& value);

///
/// \brief Get the point data start
/// \return The point data start
///
const std::streampos& pointDataStart() const;


protected:
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
///
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:
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
///
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:
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
///
void setRotationsDataStart(const std::streampos& value);

///
/// \brief Get the rotations data start
/// \return The rotations data start
///
const std::streampos& rotationsDataStart() const;

protected:
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
///
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
4 changes: 3 additions & 1 deletion include/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> analogScaleFactors) const;
std::vector<double> analogScaleFactors,
int dataTypeToWrite) const;


//---- POINTS ----//
Expand Down
16 changes: 10 additions & 6 deletions include/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 &params,
std::fstream &file,
int nbCharInName);
int read(
ezc3d::c3d &c3d,
const Parameters &params,
std::fstream &file,
int nbCharInName);

///
/// \brief isEmpty If the group has no name and no parameter, it is considered empty
Expand Down
7 changes: 4 additions & 3 deletions include/Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/// \date October 17th, 2018
///

#include "ezc3d.h"
#include "ezc3dNamespace.h"
#include <vector>

///
/// \brief Header of a C3D file
Expand Down Expand Up @@ -41,11 +42,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
Expand Down
13 changes: 10 additions & 3 deletions include/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
/// \date October 17th, 2018
///

#include "ezc3d.h"
#include "ezc3dNamespace.h"
#include <vector>
#include <iostream>
#ifdef _WIN32
#include <string>
#endif

///
/// \brief Parameter of a C3D file
Expand Down Expand Up @@ -37,14 +42,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:
///
Expand Down
4 changes: 2 additions & 2 deletions include/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 64b4d02

Please sign in to comment.