DART  6.10.1
C3D.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, 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 <ctime>
37 #include <vector>
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 {
50  unsigned char prec_start;
51  unsigned char key;
52  short pnt_cnt;
53  short a_channels;
54  short start_frame;
55  short end_frame;
56  short int_gap;
57  float scale;
58  short rec_start;
59  short a_frames;
60  float freq;
61  short stuff[244];
63 
64 typedef struct c3d_param_t
65 {
66  unsigned char reserved[2];
67  unsigned char pblocks;
68  unsigned char ftype;
69  char stuff[C3D_REC_SIZE - 4];
71 
72 typedef struct c3d_frameSI_t
73 {
74  short x, y, z;
75  unsigned char cam_byte;
76  unsigned char residual;
78 
79 typedef struct c3d_frame_t
80 {
81  float x, y, z;
82  float residual;
84 
85 float convertDecToFloat(char _bytes[4]);
86 void convertFloatToDec(float _f, char* _bytes);
87 
88 bool loadC3DFile(
89  const char* _fileName,
90  std::vector<std::vector<Eigen::Vector3d>>& _pointData,
91  int* _nFrame,
92  int* _nMarker,
93  double* _freq);
94 bool saveC3DFile(
95  const char* _fileName,
96  std::vector<std::vector<Eigen::Vector3d>>& _pointData,
97  int _nFrame,
98  int _nMarker,
99  double _freq);
100 
101 } // namespace utils
102 } // namespace dart
103 
104 #endif // #ifndef DART_UTILS_C3D_HPP_
#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:61
bool loadC3DFile(const char *_fileName, std::vector< std::vector< Eigen::Vector3d >> &_pointData, int *_nFrame, int *_nMarker, double *_freq)
Definition: C3D.cpp:72
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:198
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:65
Definition: C3D.hpp:73
unsigned char cam_byte
Definition: C3D.hpp:75
short z
Definition: C3D.hpp:74
unsigned char residual
Definition: C3D.hpp:76
short y
Definition: C3D.hpp:74
short x
Definition: C3D.hpp:74
Definition: C3D.hpp:80
float residual
Definition: C3D.hpp:82
float y
Definition: C3D.hpp:81
float x
Definition: C3D.hpp:81
float z
Definition: C3D.hpp:81
Definition: C3D.hpp:49
short stuff[244]
Definition: C3D.hpp:61
short start_frame
Definition: C3D.hpp:54
short int_gap
Definition: C3D.hpp:56
float freq
Definition: C3D.hpp:60
short pnt_cnt
Definition: C3D.hpp:52
short end_frame
Definition: C3D.hpp:55
short a_channels
Definition: C3D.hpp:53
unsigned char key
Definition: C3D.hpp:51
unsigned char prec_start
Definition: C3D.hpp:50
short a_frames
Definition: C3D.hpp:59
float scale
Definition: C3D.hpp:57
short rec_start
Definition: C3D.hpp:58
Definition: C3D.hpp:65
unsigned char reserved[2]
Definition: C3D.hpp:66
char stuff[512 - 4]
Definition: C3D.hpp:69
unsigned char pblocks
Definition: C3D.hpp:67
unsigned char ftype
Definition: C3D.hpp:68