1 #define EZC3D_API_EXPORTS 14 _nbOfZerosBeforeHeader(0),
15 _parametersAddress(2),
18 _nbAnalogsMeasurement(0),
31 _firstBlockKeyLabel(0),
32 _fourCharPresent(0x3039),
41 _nbOfZerosBeforeHeader(0),
42 _parametersAddress(2),
45 _nbAnalogsMeasurement(0),
58 _firstBlockKeyLabel(0),
59 _fourCharPresent(0x3039),
69 std::cout <<
"HEADER" << std::endl;
70 std::cout <<
"nb3dPoints = " << nb3dPoints() << std::endl;
71 std::cout <<
"nbAnalogsMeasurement = " << nbAnalogsMeasurement() << std::endl;
72 std::cout <<
"nbAnalogs = " << nbAnalogs() << std::endl;
73 std::cout <<
"firstFrame = " << firstFrame() << std::endl;
74 std::cout <<
"lastFrame = " << lastFrame() << std::endl;
75 std::cout <<
"nbFrames = " << nbFrames() << std::endl;
76 std::cout <<
"nbMaxInterpGap = " << nbMaxInterpGap() << std::endl;
77 std::cout <<
"scaleFactor = " << scaleFactor() << std::endl;
78 std::cout <<
"dataStart = " << dataStart() << std::endl;
79 std::cout <<
"nbAnalogByFrame = " << nbAnalogByFrame() << std::endl;
80 std::cout <<
"frameRate = " << frameRate() << std::endl;
81 std::cout <<
"keyLabelPresent = " << keyLabelPresent() << std::endl;
82 std::cout <<
"firstBlockKeyLabel = " << firstBlockKeyLabel() << std::endl;
83 std::cout <<
"fourCharPresent = " << fourCharPresent() << std::endl;
84 std::cout <<
"nbEvents = " << nbEvents() << std::endl;
85 for (
size_t i=0; i < eventsTime().size(); ++i)
86 std::cout <<
"eventsTime[" << i <<
"] = " << eventsTime(i) << std::endl;
87 for (
size_t i=0; i < eventsDisplay().size(); ++i)
88 std::cout <<
"eventsDisplay[" << i <<
"] = " << eventsDisplay(i) << std::endl;
89 for (
size_t i=0; i < eventsLabel().size(); ++i)
90 std::cout <<
"eventsLabel[" << i <<
"] = " << eventsLabel(i) << std::endl;
91 std::cout << std::endl;
97 int parameterAddessDefault(2);
98 f.write(reinterpret_cast<const char*>(¶meterAddessDefault), ezc3d::BYTE);
100 f.write(reinterpret_cast<const char*>(&checksum), ezc3d::BYTE);
103 f.write(reinterpret_cast<const char*>(&_nb3dPoints), 1*ezc3d::DATA_TYPE::WORD);
104 f.write(reinterpret_cast<const char*>(&_nbAnalogsMeasurement), 1*ezc3d::DATA_TYPE::WORD);
107 size_t firstFrame(_firstFrame + 1);
108 size_t lastFrame(_lastFrame + 1);
109 if (lastFrame > 0xFFFF)
111 f.write(reinterpret_cast<const char*>(&firstFrame), 1*ezc3d::DATA_TYPE::WORD);
112 f.write(reinterpret_cast<const char*>(&lastFrame), 1*ezc3d::DATA_TYPE::WORD);
115 f.write(reinterpret_cast<const char*>(&_nbMaxInterpGap), 1*ezc3d::DATA_TYPE::WORD);
116 f.write(reinterpret_cast<const char*>(&_scaleFactor), 2*ezc3d::DATA_TYPE::WORD);
119 dataStartPosition = f.tellg();
120 f.write(reinterpret_cast<const char*>(&_dataStart), 1*ezc3d::DATA_TYPE::WORD);
121 f.write(reinterpret_cast<const char*>(&_nbAnalogByFrame), 1*ezc3d::DATA_TYPE::WORD);
122 float frameRate(_frameRate);
123 f.write(reinterpret_cast<const char*>(&frameRate), 2*ezc3d::DATA_TYPE::WORD);
124 for (
int i=0; i<135; ++i)
125 f.write(reinterpret_cast<const char*>(&_emptyBlock1), 1*ezc3d::DATA_TYPE::WORD);
128 f.write(reinterpret_cast<const char*>(&_keyLabelPresent), 1*ezc3d::DATA_TYPE::WORD);
129 f.write(reinterpret_cast<const char*>(&_firstBlockKeyLabel), 1*ezc3d::DATA_TYPE::WORD);
130 f.write(reinterpret_cast<const char*>(&_fourCharPresent), 1*ezc3d::DATA_TYPE::WORD);
133 f.write(reinterpret_cast<const char*>(&_nbEvents), 1*ezc3d::DATA_TYPE::WORD);
134 f.write(reinterpret_cast<const char*>(&_emptyBlock2), 1*ezc3d::DATA_TYPE::WORD);
135 for (
unsigned int i = 0; i < _eventsTime.size(); ++i)
136 f.write(reinterpret_cast<const char*>(&_eventsTime[i]), 2*ezc3d::DATA_TYPE::WORD);
137 for (
unsigned int i = 0; i < _eventsDisplay.size(); ++i)
138 f.write(reinterpret_cast<const char*>(&_eventsDisplay[i]), 1*ezc3d::DATA_TYPE::WORD);
139 f.write(reinterpret_cast<const char*>(&_emptyBlock3), 1*ezc3d::DATA_TYPE::WORD);
140 for (
unsigned int i = 0; i < _eventsLabel.size(); ++i){
141 const char*
event = _eventsLabel[i].c_str();
142 f.write(event, 2*ezc3d::DATA_TYPE::WORD);
144 for (
int i=0; i<22; ++i)
145 f.write(reinterpret_cast<const char*>(&_emptyBlock4), 1*ezc3d::DATA_TYPE::WORD);
151 _parametersAddress =
c3d.
readUint(PROCESSOR_TYPE::INTEL, file, 1*ezc3d::DATA_TYPE::BYTE, 0, std::ios::beg);
155 while (!_parametersAddress){
156 _parametersAddress =
c3d.
readUint(PROCESSOR_TYPE::INTEL,file, 1*ezc3d::DATA_TYPE::BYTE);
158 throw std::ios_base::failure(
"File is empty");
159 ++_nbOfZerosBeforeHeader;
162 _checksum =
c3d.
readUint(PROCESSOR_TYPE::INTEL, file, 1*ezc3d::DATA_TYPE::BYTE);
163 if (_checksum != 0x50)
164 throw std::ios_base::failure(
"File must be a valid c3d file");
170 _nb3dPoints =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
171 _nbAnalogsMeasurement =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
174 _firstFrame =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
175 if (_firstFrame != 0)
177 _lastFrame =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD) - 1;
182 _nbMaxInterpGap =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
183 _scaleFactor =
c3d.
readFloat(processorType, file, 2*ezc3d::DATA_TYPE::WORD);
186 _dataStart =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
187 _nbAnalogByFrame =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
189 _emptyBlock1 =
c3d.
readInt(processorType, file, 135*ezc3d::DATA_TYPE::WORD);
192 _keyLabelPresent =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
193 _firstBlockKeyLabel =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
194 _fourCharPresent =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
197 _nbEvents =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
198 _emptyBlock2 =
c3d.
readInt(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
199 for (
unsigned int i = 0; i < _eventsTime.size(); ++i)
201 for (
unsigned int i = 0; i < _eventsDisplay.size(); ++i)
202 _eventsDisplay[i] =
c3d.
readUint(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
203 _emptyBlock3 =
c3d.
readInt(processorType, file, 1*ezc3d::DATA_TYPE::WORD);
204 for (
unsigned int i = 0; i<_eventsLabel.size(); ++i)
205 _eventsLabel[i] =
c3d.
readString(file, 2*ezc3d::DATA_TYPE::WORD);
206 _emptyBlock4 =
c3d.
readInt(processorType, file, 22*ezc3d::DATA_TYPE::WORD);
211 return _nbOfZerosBeforeHeader;
216 return _parametersAddress;
222 std::streampos dataPos = file.tellg();
225 size_t parametersAddress(
c3d.
readUint(PROCESSOR_TYPE::INTEL, file, 1*ezc3d::DATA_TYPE::BYTE, 0, std::ios::beg));
226 size_t processorType =
c3d.
readUint(PROCESSOR_TYPE::INTEL, file, 1*ezc3d::DATA_TYPE::BYTE, static_cast<int>(256*ezc3d::DATA_TYPE::WORD*(parametersAddress-1)) + 3*ezc3d::DATA_TYPE::BYTE, std::ios::beg);
231 if (processorType == 84)
232 return ezc3d::PROCESSOR_TYPE::INTEL;
233 else if (processorType == 85)
234 return ezc3d::PROCESSOR_TYPE::DEC;
235 else if (processorType == 86)
236 return ezc3d::PROCESSOR_TYPE::MIPS;
238 throw std::runtime_error(
"Could not read the processor type");
253 _nb3dPoints = numberOfPoints;
258 if (_nbAnalogByFrame == 0)
261 return _nbAnalogsMeasurement / _nbAnalogByFrame;
266 _nbAnalogsMeasurement = nbOfAnalogs * _nbAnalogByFrame;
271 return _nbAnalogsMeasurement;
276 if (nb3dPoints() == 0 && nbAnalogs() == 0)
279 return _lastFrame - _firstFrame + 1;
304 return _nbMaxInterpGap;
319 return _nbAnalogByFrame;
324 size_t analogs(nbAnalogs());
325 _nbAnalogByFrame = nbOfAnalogsByFrame;
336 _frameRate = pointFrameRate;
361 return _keyLabelPresent;
366 return _firstBlockKeyLabel;
371 return _fourCharPresent;
387 return _eventsTime.at(idx);
388 }
catch(std::out_of_range) {
389 throw std::out_of_range(
"Header::eventsTime method is trying to access the event " 390 + std::to_string(idx) +
391 " while the maximum number of events is " 392 + std::to_string(nbEvents()) +
".");
398 return _eventsDisplay;
403 return _eventsDisplay.at(idx);
404 }
catch(std::out_of_range) {
405 throw std::out_of_range(
"Header::eventsDisplay method is trying to access the event " 406 + std::to_string(idx) +
407 " while the maximum number of events is " 408 + std::to_string(nbEvents()) +
".");
420 return _eventsLabel.at(idx);
421 }
catch(std::out_of_range) {
422 throw std::out_of_range(
"Header::eventsLabel method is trying to access the event " 423 + std::to_string(idx) +
424 " while the maximum number of events is " 425 + std::to_string(nbEvents()) +
".");
size_t readUint(PROCESSOR_TYPE processorType, std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read a unsigned integer of nByteToRead bytes at the position current + nByteFromPrevious from a file...
PROCESSOR_TYPE
The type of processor used to store the data.
Main class for C3D holder.
int readInt(PROCESSOR_TYPE processorType, std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read an integer of nByteToRead bytes at the position current + nByteFromPrevious from a file...
std::string readString(std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read a string (array of char of nByteToRead bytes) at the position current + nByteFromPrevious from a...
Declaration of Parameters class.
float readFloat(PROCESSOR_TYPE processorType, std::fstream &file, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read a float at the position current + nByteFromPrevious from a file.