DART  6.7.3
C3D.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_UTILS_C3D_HPP_
34 #define DART_UTILS_C3D_HPP_
35 
36 #include <vector>
37 #include <ctime>
38 #include <Eigen/Dense>
39 #include "dart/math/MathTypes.hpp"
40 
42 // C3D file reader and writer
43 namespace dart {
44 namespace utils {
45 
46 #define C3D_REC_SIZE 512
47 
48 typedef struct c3d_head_t {
49  unsigned char prec_start;
50  unsigned char key;
51  short pnt_cnt;
52  short a_channels;
53  short start_frame;
54  short end_frame;
55  short int_gap;
56  float scale;
57  short rec_start;
58  short a_frames;
59  float freq;
60  short stuff[244];
62 
63 typedef struct c3d_param_t {
64  unsigned char reserved[2];
65  unsigned char pblocks;
66  unsigned char ftype;
69 
70 typedef struct c3d_frameSI_t {
71  short x, y, z;
72  unsigned char cam_byte;
73  unsigned char residual;
75 
76 typedef struct c3d_frame_t {
77  float x, y, z;
78  float residual;
80 
81 float convertDecToFloat(char _bytes[4]);
82 void convertFloatToDec(float _f, char* _bytes);
83 
84 bool loadC3DFile( const char* _fileName, std::vector<std::vector<Eigen::Vector3d>>& _pointData,
85  int* _nFrame, int* _nMarker, double* _freq );
86 bool saveC3DFile( const char* _fileName, std::vector<std::vector<Eigen::Vector3d>>& _pointData,
87  int _nFrame, int _nMarker, double _freq );
88 
89 } // namespace utils
90 } // namespace dart
91 
92 #endif // #ifndef DART_UTILS_C3D_HPP_
93 
94 
#define C3D_REC_SIZE
Definition: C3D.hpp:46
struct dart::utils::c3d_head_t c3d_head
void convertFloatToDec(float _f, char *_bytes)
Definition: C3D.cpp:60
bool loadC3DFile(const char *_fileName, std::vector< std::vector< Eigen::Vector3d >> &_pointData, int *_nFrame, int *_nMarker, double *_freq)
Definition: C3D.cpp:71
struct dart::utils::c3d_frame_t c3d_frame
bool saveC3DFile(const char *_fileName, std::vector< std::vector< Eigen::Vector3d >> &_pointData, int _nFrame, int _nMarker, double _freq)
Definition: C3D.cpp:178
struct dart::utils::c3d_frameSI_t c3d_frameSI
struct dart::utils::c3d_param_t c3d_param
float convertDecToFloat(char _bytes[4])
Definition: C3D.cpp:45
Definition: BulletCollisionDetector.cpp:63
Definition: C3D.hpp:70
unsigned char cam_byte
Definition: C3D.hpp:72
short z
Definition: C3D.hpp:71
unsigned char residual
Definition: C3D.hpp:73
short y
Definition: C3D.hpp:71
short x
Definition: C3D.hpp:71
Definition: C3D.hpp:76
float residual
Definition: C3D.hpp:78
float y
Definition: C3D.hpp:77
float x
Definition: C3D.hpp:77
float z
Definition: C3D.hpp:77
Definition: C3D.hpp:48
short stuff[244]
Definition: C3D.hpp:60
short start_frame
Definition: C3D.hpp:53
short int_gap
Definition: C3D.hpp:55
float freq
Definition: C3D.hpp:59
short pnt_cnt
Definition: C3D.hpp:51
short end_frame
Definition: C3D.hpp:54
short a_channels
Definition: C3D.hpp:52
unsigned char key
Definition: C3D.hpp:50
unsigned char prec_start
Definition: C3D.hpp:49
short a_frames
Definition: C3D.hpp:58
float scale
Definition: C3D.hpp:56
short rec_start
Definition: C3D.hpp:57
Definition: C3D.hpp:63
unsigned char reserved[2]
Definition: C3D.hpp:64
char stuff[512 -4]
Definition: C3D.hpp:67
unsigned char pblocks
Definition: C3D.hpp:65
unsigned char ftype
Definition: C3D.hpp:66