sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
RTPacket.cpp
Go to the documentation of this file.
1 #define _CRT_SECURE_NO_WARNINGS
2 #define NOMINMAX
3 
4 #include <float.h>
5 #include <math.h>
6 #include <memory.h>
7 #include <stdint.h>
8 
9 #ifdef _WIN32
10 #include <Winsock2.h>
11 #else
12 #include <arpa/inet.h>
13 #endif
14 
16 
17 CRTPacket::CRTPacket(int nMajorVersion, int nMinorVersion, bool bBigEndian) {
18  mnMajorVersion = nMajorVersion;
19  mnMinorVersion = nMinorVersion;
20  mbBigEndian = bBigEndian;
21 
22  ClearData();
23 }
24 
25 void CRTPacket::GetVersion(unsigned int &nMajorVersion,
26  unsigned int &nMinorVersion) {
27  nMajorVersion = mnMajorVersion;
28  nMinorVersion = mnMinorVersion;
29 }
30 
31 void CRTPacket::SetVersion(unsigned int nMajorVersion,
32  unsigned int nMinorVersion) {
33  mnMajorVersion = nMajorVersion;
34  mnMinorVersion = nMinorVersion;
35 }
36 
37 bool CRTPacket::GetEndianness() { return mbBigEndian; }
38 
39 void CRTPacket::SetEndianness(bool bBigEndian) { mbBigEndian = bBigEndian; }
40 
42  mpData = nullptr;
43  mnComponentCount = 0;
44  mn2DCameraCount = 0;
45  mn2DLinCameraCount = 0;
46  mnImageCameraCount = 0;
47  mnAnalogDeviceCount = 0;
48  mnAnalogSingleDeviceCount = 0;
49  mnForcePlateCount = 0;
50  mnForceSinglePlateCount = 0;
51  mnGazeVectorCount = 0;
52  mnTimecodeCount = 0;
53  mSkeletonCount = 0;
54  memset(mpComponentData, 0, ComponentNone * 4);
55  memset(mp2DData, 0, MAX_CAMERA_COUNT * 4);
56  memset(mp2DLinData, 0, MAX_CAMERA_COUNT * 4);
57  memset(mpImageData, 0, MAX_CAMERA_COUNT * 4);
58  memset(mpAnalogData, 0, MAX_ANALOG_DEVICE_COUNT * 4);
59  memset(mpAnalogSingleData, 0, MAX_ANALOG_DEVICE_COUNT * 4);
60  memset(mpForceData, 0, MAX_FORCE_PLATE_COUNT * 4);
61  memset(mpForceSingleData, 0, MAX_FORCE_PLATE_COUNT * 4);
62  memset(mpGazeVectorData, 0, MAX_GAZE_VECTOR_COUNT * 4);
63  memset(mpSkeletonData, 0, MAX_SKELETON_COUNT * 4);
64 }
65 
66 void CRTPacket::SetData(char *ptr) {
67  unsigned int nComponent;
68  unsigned int nCamera, nDevice;
69 
70  mpData = ptr;
71 
72  mnComponentCount = 0;
73  mn2DCameraCount = 0;
74  mn2DLinCameraCount = 0;
75  mnImageCameraCount = 0;
76  mnAnalogDeviceCount = 0;
77  mnAnalogSingleDeviceCount = 0;
78  mnForcePlateCount = 0;
79  mnForceSinglePlateCount = 0;
80  mnGazeVectorCount = 0;
81  mnTimecodeCount = 0;
82  mSkeletonCount = 0;
83 
84  // Check if it's a data packet
85  if (GetType() == PacketData) {
86  // Reset all component data pointers
87  for (nComponent = 1; nComponent < ComponentNone; nComponent++) {
88  mpComponentData[nComponent - 1] = nullptr;
89  }
90 
91  char *pCurrentComponent = mpData + 24;
92  unsigned int nComponentType =
93  SetByteOrder((unsigned int *)(pCurrentComponent + 4));
94 
95  mnComponentCount = SetByteOrder((unsigned int *)(mpData + 20));
96 
97  for (nComponent = 1; nComponent <= mnComponentCount && nComponentType > 0 &&
98  nComponentType < ComponentNone;
99  nComponent++) {
100  mpComponentData[nComponentType - 1] = pCurrentComponent;
101 
102  if (nComponentType == Component2d) {
103  mn2DCameraCount = SetByteOrder((unsigned int *)(pCurrentComponent + 8));
104 
105  mp2DData[0] = pCurrentComponent + 16;
106  for (nCamera = 1; nCamera < mn2DCameraCount; nCamera++) {
107  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
108  mp2DData[nCamera] =
109  mp2DData[nCamera - 1] + 5 + Get2DMarkerCount(nCamera - 1) * 12;
110  } else {
111  mp2DData[nCamera] =
112  mp2DData[nCamera - 1] + 4 + Get2DMarkerCount(nCamera - 1) * 12;
113  }
114  }
115  }
116  if (nComponentType == Component2dLin) {
117  mn2DLinCameraCount =
118  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
119 
120  mp2DLinData[0] = pCurrentComponent + 16;
121  for (nCamera = 1; nCamera < mn2DLinCameraCount; nCamera++) {
122  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
123  mp2DLinData[nCamera] = mp2DLinData[nCamera - 1] + 5 +
124  Get2DLinMarkerCount(nCamera - 1) * 12;
125  } else {
126  mp2DLinData[nCamera] = mp2DLinData[nCamera - 1] + 4 +
127  Get2DLinMarkerCount(nCamera - 1) * 12;
128  }
129  }
130  }
131  if (nComponentType == ComponentImage) {
132  mnImageCameraCount =
133  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
134 
135  mpImageData[0] = pCurrentComponent + 12;
136  for (nCamera = 1; nCamera < mnImageCameraCount; nCamera++) {
137  mpImageData[nCamera] =
138  mpImageData[nCamera - 1] + 36 +
139  SetByteOrder((unsigned int *)(mpImageData[nCamera - 1] + 32));
140  }
141  }
142  if (nComponentType == ComponentAnalog) {
143  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
144  mnAnalogDeviceCount = 1;
145  } else {
146  mnAnalogDeviceCount =
147  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
148  }
149 
150  if ((mnMajorVersion > 1) || (mnMinorVersion > 7)) {
151  mpAnalogData[0] = pCurrentComponent + 12;
152  } else {
153  mpAnalogData[0] = pCurrentComponent + 16;
154  }
155  for (nDevice = 1; nDevice < mnAnalogDeviceCount; nDevice++) {
156  mpAnalogData[nDevice] =
157  mpAnalogData[nDevice - 1] + 16 +
158  (SetByteOrder((unsigned int *)(mpAnalogData[nDevice - 1] + 4)) *
159  SetByteOrder((unsigned int *)(mpAnalogData[nDevice - 1] + 8)) *
160  4);
161  }
162  }
163  if (nComponentType == ComponentAnalogSingle) {
164  mnAnalogSingleDeviceCount =
165  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
166 
167  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
168  mpAnalogSingleData[0] = pCurrentComponent + 12;
169  } else {
170  mpAnalogSingleData[0] = pCurrentComponent + 16;
171  }
172 
173  for (nDevice = 1; nDevice < mnAnalogSingleDeviceCount; nDevice++) {
174  mpAnalogSingleData[nDevice] =
175  mpAnalogSingleData[nDevice - 1] + 8 +
176  SetByteOrder(
177  (unsigned int *)(mpAnalogSingleData[nDevice - 1] + 4)) *
178  4;
179  }
180  }
181  if (nComponentType == ComponentForce) {
182  mnForcePlateCount =
183  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
184 
185  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
186  mpForceData[0] = pCurrentComponent + 12;
187  } else {
188  mpForceData[0] = pCurrentComponent + 16;
189  }
190  for (nDevice = 1; nDevice < mnForcePlateCount; nDevice++) {
191  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
192  mpForceData[nDevice] = mpForceData[nDevice - 1] + 72;
193  } else {
194  mpForceData[nDevice] =
195  mpForceData[nDevice - 1] + 12 +
196  SetByteOrder((unsigned int *)(mpForceData[nDevice - 1] + 4)) *
197  36;
198  }
199  }
200  }
201  if (nComponentType == ComponentForceSingle) {
202  mnForceSinglePlateCount =
203  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
204 
205  mpForceSingleData[0] = pCurrentComponent + 12;
206 
207  for (nDevice = 1; nDevice < mnForceSinglePlateCount; nDevice++) {
208  mpForceSingleData[nDevice] = mpForceSingleData[nDevice - 1] + 4 + 36;
209  }
210  }
211  if (nComponentType == ComponentGazeVector) {
212  mnGazeVectorCount =
213  SetByteOrder((unsigned int *)(pCurrentComponent + 8));
214 
215  mpGazeVectorData[0] = pCurrentComponent + 12;
216 
217  for (nDevice = 1; nDevice < mnGazeVectorCount; nDevice++) {
218  unsigned int nPrevSampleCount =
219  SetByteOrder((unsigned int *)(mpGazeVectorData[nDevice - 1]));
220  mpGazeVectorData[nDevice] = mpGazeVectorData[nDevice - 1] + 4 +
221  ((nPrevSampleCount == 0) ? 0 : 4) +
222  nPrevSampleCount * 24;
223  }
224  }
225  if (nComponentType == ComponentTimecode) {
226  mnTimecodeCount = SetByteOrder((unsigned int *)(pCurrentComponent + 8));
227 
228  mpTimecodeData[0] = pCurrentComponent + 12;
229 
230  for (nDevice = 1; nDevice < mnTimecodeCount; nDevice++) {
231  mpTimecodeData[nDevice] = mpTimecodeData[nDevice - 1] + 12;
232  }
233  }
234  if (nComponentType == ComponentSkeleton) {
235  mSkeletonCount = SetByteOrder((unsigned int *)(pCurrentComponent + 8));
236 
237  mpSkeletonData[0] = pCurrentComponent + 12;
238 
239  for (nDevice = 1; nDevice < mSkeletonCount; nDevice++) {
240  unsigned int prevSegmentCount =
241  SetByteOrder((unsigned int *)(mpSkeletonData[nDevice - 1]));
242  mpSkeletonData[nDevice] =
243  mpSkeletonData[nDevice - 1] + 4 + prevSegmentCount * 32;
244  }
245  }
246  pCurrentComponent += SetByteOrder((int *)pCurrentComponent);
247  nComponentType = SetByteOrder((unsigned int *)(pCurrentComponent + 4));
248  }
249  }
250 } // SetData
251 
252 void CRTPacket::GetData(char *&ptr, unsigned int &nSize) {
253  if (mpData == nullptr) {
254  nSize = 0;
255  } else {
256  ptr = mpData;
257  nSize = *((int *)mpData);
258  }
259 }
260 
261 unsigned int CRTPacket::GetSize() {
262  if (mpData == nullptr) {
263  return 0;
264  }
265  if (mbBigEndian || ((mnMajorVersion == 1) && (mnMinorVersion == 0))) {
266  return ntohl(*((unsigned int *)mpData));
267  }
268  return *((unsigned int *)mpData);
269 }
270 
272  if (GetSize() < 8) {
273  return PacketNone;
274  }
275  if (mbBigEndian || ((mnMajorVersion == 1) && (mnMinorVersion == 0))) {
276  return (EPacketType)ntohl(*(unsigned int *)(mpData + 4));
277  }
278  return (EPacketType) * ((unsigned int *)(mpData + 4));
279 }
280 
281 unsigned long long CRTPacket::GetTimeStamp() {
282  if (GetType() == PacketData) {
283  return SetByteOrder((long long *)(mpData + 8));
284  }
285  return 0;
286 }
287 
289  if (GetType() == PacketData) {
290  return SetByteOrder((unsigned int *)(mpData + 16));
291  }
292  return 0;
293 }
294 
295 unsigned int CRTPacket::GetSize(char *pData, bool bBigEndian) {
296  if (bBigEndian) {
297  return ntohl(*((unsigned int *)pData));
298  }
299  return *((unsigned int *)pData);
300 }
301 
302 CRTPacket::EPacketType CRTPacket::GetType(char *pData, bool bBigEndian) {
303  if (GetSize(pData, bBigEndian) < 8) {
304  return PacketNone;
305  }
306  if (bBigEndian) {
307  return (EPacketType)ntohl(*(unsigned int *)(pData + 4));
308  }
309  return (EPacketType) * ((unsigned int *)(pData + 4));
310 }
311 
312 unsigned long long CRTPacket::GetTimeStamp(char *pData, bool bBigEndian) {
313  if (GetType(pData, bBigEndian) == PacketData) {
314  if (bBigEndian) {
315  return ((unsigned long long)(ntohl((long)*((long long *)(pData + 8))))
316  << 32) +
317  ntohl(*((long long *)(pData + 8)) >> 32);
318  }
319  return *((long long *)(pData + 8));
320  }
321  return 0;
322 }
323 
324 unsigned int CRTPacket::GetFrameNumber(char *pData, bool bBigEndian) {
325  if (GetType(pData, bBigEndian) == PacketData) {
326  if (bBigEndian) {
327  return ntohl(*((unsigned int *)(pData + 16)));
328  }
329  return *((unsigned int *)(pData + 16));
330  }
331  return 0;
332 }
333 
334 unsigned int CRTPacket::GetComponentCount() { return mnComponentCount; }
335 
336 unsigned int CRTPacket::GetComponentSize(EComponentType eComponent) {
337  if (eComponent < Component3d || eComponent >= ComponentNone) {
338  return 0;
339  }
340  if (mpComponentData[eComponent - 1] == nullptr) {
341  return 0;
342  }
343  return SetByteOrder((unsigned int *)(mpComponentData[eComponent - 1]));
344 }
345 
347  if (GetType() == PacketError) {
348  return mpData + 8;
349  }
350  return nullptr;
351 }
352 
354  if (GetType() == PacketCommand) {
355  return mpData + 8;
356  }
357  return nullptr;
358 }
359 
360 char *CRTPacket::GetCommandString(char *pData, bool bBigEndian) {
361  if (GetType(pData, bBigEndian) == PacketCommand) {
362  return pData + 8;
363  }
364  return nullptr;
365 }
366 
368  if (GetType() == PacketXML) {
369  return mpData + 8;
370  }
371  return nullptr;
372 }
373 
375  if (GetType() == PacketCommand) {
376  if (GetSize() == (8 + strlen(mpData + 8) + 1 + 2)) {
377  return ntohs(*((short *)(mpData + 8 + strlen(mpData + 8) + 1)));
378  }
379  }
380  return 0;
381 }
382 
383 short CRTPacket::GetDiscoverResponseBasePort(char *pData, bool bBigEndian) {
384  if (GetType(pData, bBigEndian) == PacketCommand) {
385  if (GetSize(pData, bBigEndian) == (8 + strlen(pData + 8) + 1 + 2)) {
386  return ntohs(*((short *)(pData + 8 + strlen(pData + 8) + 1)));
387  }
388  }
389  return 0;
390 }
391 
393  if (GetType() == PacketEvent) {
394  eEvent = (EEvent) * (mpData + 8);
395  return true;
396  }
397  return false;
398 }
399 
400 bool CRTPacket::GetEvent(EEvent &eEvent, char *pData, bool bBigEndian) {
401  if (GetType(pData, bBigEndian) == PacketEvent) {
402  eEvent = (EEvent) * (pData + 8);
403  return true;
404  }
405  return false;
406 }
407 
408 unsigned short CRTPacket::GetDropRate() {
409  for (int i = 0; i <= 1; i++) {
410  if (mpComponentData[i] != nullptr) {
411  return SetByteOrder((unsigned short *)(mpComponentData[i] + 12));
412  }
413  }
414  for (int i = 4; i <= 11; i++) {
415  if (mpComponentData[i] != nullptr) {
416  return SetByteOrder((unsigned short *)(mpComponentData[i] + 12));
417  }
418  }
419  return 0;
420 }
421 
422 unsigned short CRTPacket::GetOutOfSyncRate() {
423  for (int i = 0; i <= 1; i++) {
424  if (mpComponentData[i] != nullptr) {
425  return SetByteOrder((unsigned short *)(mpComponentData[i] + 14));
426  }
427  }
428  for (int i = 4; i <= 11; i++) {
429  if (mpComponentData[i] != nullptr) {
430  return SetByteOrder((unsigned short *)(mpComponentData[i] + 14));
431  }
432  }
433  return 0;
434 }
435 
436 //-----------------------------------------------------------
437 // 2D
438 //-----------------------------------------------------------
439 unsigned int CRTPacket::Get2DCameraCount() { return mn2DCameraCount; }
440 
441 unsigned int CRTPacket::Get2DMarkerCount(unsigned int nCameraIndex) {
442  if (mn2DCameraCount <= nCameraIndex) {
443  return 0;
444  }
445  return SetByteOrder((unsigned int *)(mp2DData[nCameraIndex]));
446 }
447 
448 unsigned char CRTPacket::Get2DStatusFlags(unsigned int nCameraIndex) {
449  if (mn2DCameraCount > nCameraIndex &&
450  ((mnMajorVersion > 1) || (mnMinorVersion > 7))) {
451  return *((unsigned char *)(mp2DData[nCameraIndex] + 4));
452  }
453  return 0;
454 }
455 
456 bool CRTPacket::Get2DMarker(unsigned int nCameraIndex,
457  unsigned int nMarkerIndex, unsigned int &nX,
458  unsigned int &nY, unsigned short &nXDiameter,
459  unsigned short &nYDiameter) {
460  int nOffset;
461 
462  if (mn2DCameraCount <= nCameraIndex ||
463  Get2DMarkerCount(nCameraIndex) <= nMarkerIndex) {
464  return false;
465  }
466 
467  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
468  nOffset = 5;
469  } else {
470  nOffset = 4;
471  }
472  nX = SetByteOrder(
473  (unsigned int *)(mp2DData[nCameraIndex] + nOffset + nMarkerIndex * 12));
474  nY = SetByteOrder((unsigned int *)(mp2DData[nCameraIndex] + nOffset + 4 +
475  nMarkerIndex * 12));
476  nXDiameter =
477  SetByteOrder((unsigned short *)(mp2DData[nCameraIndex] + nOffset + 8 +
478  nMarkerIndex * 12));
479  nYDiameter =
480  SetByteOrder((unsigned short *)(mp2DData[nCameraIndex] + nOffset + 10 +
481  nMarkerIndex * 12));
482 
483  return true;
484 }
485 
486 //-----------------------------------------------------------
487 // 2D Linearized
488 //-----------------------------------------------------------
489 unsigned int CRTPacket::Get2DLinCameraCount() { return mn2DLinCameraCount; }
490 
491 unsigned int CRTPacket::Get2DLinMarkerCount(unsigned int nCameraIndex) {
492  if (mn2DLinCameraCount <= nCameraIndex) {
493  return 0;
494  }
495  return SetByteOrder((unsigned int *)(mp2DLinData[nCameraIndex]));
496 }
497 
498 unsigned char CRTPacket::Get2DLinStatusFlags(unsigned int nCameraIndex) {
499  if (mn2DLinCameraCount > nCameraIndex &&
500  ((mnMajorVersion > 1) || (mnMinorVersion > 7))) {
501  return *((unsigned char *)(mp2DLinData[nCameraIndex] + 4));
502  }
503  return 0;
504 }
505 
506 bool CRTPacket::Get2DLinMarker(unsigned int nCameraIndex,
507  unsigned int nMarkerIndex, unsigned int &nX,
508  unsigned int &nY, unsigned short &nXDiameter,
509  unsigned short &nYDiameter) {
510  int nOffset;
511 
512  if (mn2DLinCameraCount <= nCameraIndex ||
513  Get2DLinMarkerCount(nCameraIndex) <= nMarkerIndex) {
514  return false;
515  }
516 
517  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
518  nOffset = 5;
519  } else {
520  nOffset = 4;
521  }
522  nX = SetByteOrder((unsigned int *)(mp2DLinData[nCameraIndex] + nOffset +
523  nMarkerIndex * 12));
524  nY = SetByteOrder((unsigned int *)(mp2DLinData[nCameraIndex] + nOffset + 4 +
525  nMarkerIndex * 12));
526  nXDiameter =
527  SetByteOrder((unsigned short *)(mp2DLinData[nCameraIndex] + nOffset + 8 +
528  nMarkerIndex * 12));
529  nYDiameter =
530  SetByteOrder((unsigned short *)(mp2DLinData[nCameraIndex] + nOffset + 10 +
531  nMarkerIndex * 12));
532 
533  return true;
534 }
535 
536 //-----------------------------------------------------------
537 // 3D
538 //-----------------------------------------------------------
541  return 0;
542  }
543 
544  char *pData = mpComponentData[Component3d - 1];
545 
546  if (pData == nullptr) {
547  return 0;
548  }
549  return SetByteOrder((unsigned int *)(pData + 8));
550 }
551 
552 bool CRTPacket::Get3DMarker(unsigned int nMarkerIndex, float &fX, float &fY,
553  float &fZ) {
554  char *pData = mpComponentData[Component3d - 1];
555 
556  if (Get3DMarkerCount() <= nMarkerIndex) {
557  return false;
558  }
559 
560  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
561  fX = SetByteOrder((float *)(pData + 16 + nMarkerIndex * 12));
562  fY = SetByteOrder((float *)(pData + 20 + nMarkerIndex * 12));
563  fZ = SetByteOrder((float *)(pData + 24 + nMarkerIndex * 12));
564  } else {
565  fX = (float)SetByteOrder((double *)(pData + 16 + nMarkerIndex * 24));
566  fY = (float)SetByteOrder((double *)(pData + 24 + nMarkerIndex * 24));
567  fZ = (float)SetByteOrder((double *)(pData + 32 + nMarkerIndex * 24));
568  }
569  return (isnan(fX) == 0);
570 }
571 
572 //-----------------------------------------------------------
573 // 3D Residual
574 //-----------------------------------------------------------
576  char *pData = mpComponentData[Component3dRes - 1];
577 
578  if (pData == nullptr) {
579  return 0;
580  }
581  return SetByteOrder((unsigned int *)(pData + 8));
582 }
583 
584 bool CRTPacket::Get3DResidualMarker(unsigned int nMarkerIndex, float &fX,
585  float &fY, float &fZ, float &fResidual) {
586  char *pData = mpComponentData[Component3dRes - 1];
587 
588  if (Get3DResidualMarkerCount() <= nMarkerIndex) {
589  return false;
590  }
591 
592  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
593  fX = SetByteOrder((float *)(pData + 16 + nMarkerIndex * 16));
594  fY = SetByteOrder((float *)(pData + 20 + nMarkerIndex * 16));
595  fZ = SetByteOrder((float *)(pData + 24 + nMarkerIndex * 16));
596  fResidual = SetByteOrder((float *)(pData + 28 + nMarkerIndex * 16));
597  } else {
598  fX = (float)SetByteOrder((double *)(pData + 16 + nMarkerIndex * 32));
599  fY = (float)SetByteOrder((double *)(pData + 24 + nMarkerIndex * 32));
600  fZ = (float)SetByteOrder((double *)(pData + 32 + nMarkerIndex * 32));
601  fResidual = SetByteOrder((float *)(pData + 40 + nMarkerIndex * 32));
602  }
603  return (isnan(fX) == 0);
604 }
605 
606 //-----------------------------------------------------------
607 // 3D No Labels
608 //-----------------------------------------------------------
610  char *pData = mpComponentData[Component3dNoLabels - 1];
611 
612  if (pData == nullptr) {
613  return 0;
614  }
615  return SetByteOrder((unsigned int *)(pData + 8));
616 }
617 
618 bool CRTPacket::Get3DNoLabelsMarker(unsigned int nMarkerIndex, float &fX,
619  float &fY, float &fZ, unsigned int &nId) {
620  char *pData = mpComponentData[Component3dNoLabels - 1];
621 
622  if (Get3DNoLabelsMarkerCount() <= nMarkerIndex) {
623  return false;
624  }
625 
626  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
627  fX = SetByteOrder((float *)(pData + 16 + nMarkerIndex * 16));
628  fY = SetByteOrder((float *)(pData + 20 + nMarkerIndex * 16));
629  fZ = SetByteOrder((float *)(pData + 24 + nMarkerIndex * 16));
630  nId = SetByteOrder((unsigned int *)(pData + 28 + nMarkerIndex * 16));
631  } else {
632  fX = (float)SetByteOrder((double *)(pData + 16 + nMarkerIndex * 32));
633  fY = (float)SetByteOrder((double *)(pData + 24 + nMarkerIndex * 32));
634  fZ = (float)SetByteOrder((double *)(pData + 32 + nMarkerIndex * 32));
635  nId = SetByteOrder((unsigned int *)(pData + 40 + nMarkerIndex * 32));
636  }
637  return true;
638 }
639 
640 //-----------------------------------------------------------
641 // 3D No Labels Residual
642 //-----------------------------------------------------------
644  char *pData = mpComponentData[Component3dNoLabelsRes - 1];
645 
646  if (pData == nullptr) {
647  return 0;
648  }
649  return SetByteOrder((unsigned int *)(pData + 8));
650 }
651 
652 bool CRTPacket::Get3DNoLabelsResidualMarker(unsigned int nMarkerIndex,
653  float &fX, float &fY, float &fZ,
654  unsigned int &nId,
655  float &fResidual) {
656  char *pData = mpComponentData[Component3dNoLabelsRes - 1];
657 
658  if (Get3DNoLabelsResidualMarkerCount() <= nMarkerIndex) {
659  return false;
660  }
661 
662  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
663  fX = SetByteOrder((float *)(pData + 16 + nMarkerIndex * 20));
664  fY = SetByteOrder((float *)(pData + 20 + nMarkerIndex * 20));
665  fZ = SetByteOrder((float *)(pData + 24 + nMarkerIndex * 20));
666  nId = SetByteOrder((unsigned int *)(pData + 28 + nMarkerIndex * 20));
667  fResidual = SetByteOrder((float *)(pData + 32 + nMarkerIndex * 20));
668  } else {
669  fX = (float)SetByteOrder((double *)(pData + 16 + nMarkerIndex * 32));
670  fY = (float)SetByteOrder((double *)(pData + 24 + nMarkerIndex * 32));
671  fZ = (float)SetByteOrder((double *)(pData + 32 + nMarkerIndex * 32));
672  nId = SetByteOrder((unsigned int *)(pData + 40 + nMarkerIndex * 32));
673  fResidual = SetByteOrder((float *)(pData + 44 + nMarkerIndex * 32));
674  }
675  return true;
676 }
677 
678 //-----------------------------------------------------------
679 // 6DOF
680 //-----------------------------------------------------------
682  char *pData = mpComponentData[Component6d - 1];
683 
684  if (pData == nullptr) {
685  return 0;
686  }
687  return SetByteOrder((unsigned int *)(pData + 8));
688 }
689 
690 bool CRTPacket::Get6DOFBody(unsigned int nBodyIndex, float &fX, float &fY,
691  float &fZ, float afRotMatrix[9]) {
692  char *pData = mpComponentData[Component6d - 1];
693 
694  if (Get6DOFBodyCount() <= nBodyIndex) {
695  return false;
696  }
697 
698  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
699  fX = SetByteOrder((float *)(pData + 16 + nBodyIndex * 48));
700  fY = SetByteOrder((float *)(pData + 20 + nBodyIndex * 48));
701  fZ = SetByteOrder((float *)(pData + 24 + nBodyIndex * 48));
702  for (int i = 0; i < 9; i++) {
703  afRotMatrix[i] =
704  SetByteOrder((float *)(pData + 28 + (i * 4) + nBodyIndex * 48));
705  }
706  } else {
707  fX = (float)SetByteOrder((double *)(pData + 16 + nBodyIndex * 96));
708  fY = (float)SetByteOrder((double *)(pData + 24 + nBodyIndex * 96));
709  fZ = (float)SetByteOrder((double *)(pData + 32 + nBodyIndex * 96));
710  for (int i = 0; i < 9; i++) {
711  afRotMatrix[i] = (float)SetByteOrder(
712  (double *)(pData + 40 + (i * 4) + nBodyIndex * 96));
713  }
714  }
715  return true;
716 }
717 
718 //-----------------------------------------------------------
719 // 6DOF Residual
720 //-----------------------------------------------------------
722  char *pData = mpComponentData[Component6dRes - 1];
723 
724  if (pData == nullptr) {
725  return 0;
726  }
727  return SetByteOrder((unsigned int *)(pData + 8));
728 }
729 
730 bool CRTPacket::Get6DOFResidualBody(unsigned int nBodyIndex, float &fX,
731  float &fY, float &fZ, float afRotMatrix[9],
732  float &fResidual) {
733  char *pData = mpComponentData[Component6dRes - 1];
734 
735  if (Get6DOFResidualBodyCount() <= nBodyIndex) {
736  return false;
737  }
738 
739  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
740  fX = SetByteOrder((float *)(pData + 16 + nBodyIndex * 52));
741  fY = SetByteOrder((float *)(pData + 20 + nBodyIndex * 52));
742  fZ = SetByteOrder((float *)(pData + 24 + nBodyIndex * 52));
743  for (int i = 0; i < 9; i++) {
744  afRotMatrix[i] =
745  SetByteOrder((float *)(pData + 28 + (i * 4) + nBodyIndex * 52));
746  }
747  fResidual = SetByteOrder((float *)(pData + 64 + nBodyIndex * 52));
748  } else {
749  fX = (float)SetByteOrder((double *)(pData + 16 + nBodyIndex * 104));
750  fY = (float)SetByteOrder((double *)(pData + 24 + nBodyIndex * 104));
751  fZ = (float)SetByteOrder((double *)(pData + 32 + nBodyIndex * 104));
752  for (int i = 0; i < 9; i++) {
753  afRotMatrix[i] = (float)SetByteOrder(
754  (double *)(pData + 40 + (i * 8) + nBodyIndex * 104));
755  }
756  fResidual = SetByteOrder((float *)(pData + 112 + nBodyIndex * 104));
757  }
758  return true;
759 }
760 
761 //-----------------------------------------------------------
762 // 6DOF Euler
763 //-----------------------------------------------------------
765  char *pData = mpComponentData[Component6dEuler - 1];
766 
767  if (pData == nullptr) {
768  return 0;
769  }
770  return SetByteOrder((unsigned int *)(pData + 8));
771 }
772 
773 bool CRTPacket::Get6DOFEulerBody(unsigned int nBodyIndex, float &fX, float &fY,
774  float &fZ, float &fAng1, float &fAng2,
775  float &fAng3) {
776  char *pData = mpComponentData[Component6dEuler - 1];
777 
778  if (Get6DOFEulerBodyCount() <= nBodyIndex) {
779  return false;
780  }
781 
782  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
783  fX = SetByteOrder((float *)(pData + 16 + nBodyIndex * 24));
784  fY = SetByteOrder((float *)(pData + 20 + nBodyIndex * 24));
785  fZ = SetByteOrder((float *)(pData + 24 + nBodyIndex * 24));
786  fAng1 = SetByteOrder((float *)(pData + 28 + nBodyIndex * 24));
787  fAng2 = SetByteOrder((float *)(pData + 32 + nBodyIndex * 24));
788  fAng3 = SetByteOrder((float *)(pData + 36 + nBodyIndex * 24));
789  } else {
790  fX = (float)SetByteOrder((double *)(pData + 16 + nBodyIndex * 48));
791  fY = (float)SetByteOrder((double *)(pData + 24 + nBodyIndex * 48));
792  fZ = (float)SetByteOrder((double *)(pData + 32 + nBodyIndex * 48));
793  fAng1 = (float)SetByteOrder((double *)(pData + 40 + nBodyIndex * 48));
794  fAng2 = (float)SetByteOrder((double *)(pData + 48 + nBodyIndex * 48));
795  fAng3 = (float)SetByteOrder((double *)(pData + 56 + nBodyIndex * 48));
796  }
797  return true;
798 }
799 
800 //-----------------------------------------------------------
801 // 6DOF Euler Residual
802 //-----------------------------------------------------------
804  char *pData = mpComponentData[Component6dEulerRes - 1];
805 
806  if (pData == nullptr) {
807  return 0;
808  }
809  return SetByteOrder((unsigned int *)(pData + 8));
810 }
811 
812 bool CRTPacket::Get6DOFEulerResidualBody(unsigned int nBodyIndex, float &fX,
813  float &fY, float &fZ, float &fAng1,
814  float &fAng2, float &fAng3,
815  float &fResidual) {
816  char *pData = mpComponentData[Component6dEulerRes - 1];
817 
818  if (Get6DOFEulerResidualBodyCount() <= nBodyIndex) {
819  return false;
820  }
821 
822  if (mnMajorVersion > 1 || mnMinorVersion > 7) {
823  fX = SetByteOrder((float *)(pData + 16 + nBodyIndex * 28));
824  fY = SetByteOrder((float *)(pData + 20 + nBodyIndex * 28));
825  fZ = SetByteOrder((float *)(pData + 24 + nBodyIndex * 28));
826  fAng1 = SetByteOrder((float *)(pData + 28 + nBodyIndex * 28));
827  fAng2 = SetByteOrder((float *)(pData + 32 + nBodyIndex * 28));
828  fAng3 = SetByteOrder((float *)(pData + 36 + nBodyIndex * 28));
829  fResidual = SetByteOrder((float *)(pData + 40 + nBodyIndex * 28));
830  } else {
831  fX = (float)SetByteOrder((double *)(pData + 16 + nBodyIndex * 56));
832  fY = (float)SetByteOrder((double *)(pData + 24 + nBodyIndex * 56));
833  fZ = (float)SetByteOrder((double *)(pData + 32 + nBodyIndex * 56));
834  fAng1 = (float)SetByteOrder((double *)(pData + 40 + nBodyIndex * 56));
835  fAng2 = (float)SetByteOrder((double *)(pData + 48 + nBodyIndex * 56));
836  fAng3 = (float)SetByteOrder((double *)(pData + 56 + nBodyIndex * 56));
837  fResidual = SetByteOrder((float *)(pData + 64 + nBodyIndex * 56));
838  }
839  return true;
840 }
841 
842 //-----------------------------------------------------------
843 // Gaze Vector
844 //-----------------------------------------------------------
845 unsigned int CRTPacket::GetGazeVectorCount() { return mnGazeVectorCount; }
846 
847 unsigned int CRTPacket::GetGazeVectorSampleCount(unsigned int nVectorIndex) {
848  if (mnGazeVectorCount <= nVectorIndex) {
849  return 0;
850  }
851  return SetByteOrder((unsigned int *)(mpGazeVectorData[nVectorIndex]));
852 }
853 
854 unsigned int CRTPacket::GetGazeVectorSampleNumber(unsigned int nVectorIndex) {
855  unsigned int nSampleCount = GetGazeVectorSampleCount(nVectorIndex);
856 
857  if (nSampleCount == 0) {
858  return 0;
859  }
860  return SetByteOrder((unsigned int *)(mpGazeVectorData[nVectorIndex] + 4));
861 }
862 
863 bool CRTPacket::GetGazeVector(unsigned int nVectorIndex,
864  unsigned int nSampleIndex,
865  SGazeVector &sGazeVector) {
866  unsigned int nSampleCount = GetGazeVectorSampleCount(nVectorIndex);
867 
868  if (nSampleCount == 0 || nSampleIndex >= nSampleCount) {
869  return false;
870  }
871 
872  for (unsigned int k = 0; k < 6; k++) {
873  *(((float *)&sGazeVector) + k) =
874  (float)SetByteOrder((float *)(mpGazeVectorData[nVectorIndex] + 8 +
875  k * sizeof(float) + nSampleIndex * 24));
876  }
877 
878  return (isnan(sGazeVector.fPosX) == 0);
879 }
880 
881 bool CRTPacket::GetGazeVector(unsigned int nVectorIndex,
882  SGazeVector *pGazeVectorBuf,
883  unsigned int nBufSize) {
884  unsigned int nSampleCount = GetGazeVectorSampleCount(nVectorIndex);
885 
886  if (nSampleCount == 0 || (nBufSize < nSampleCount * sizeof(SGazeVector))) {
887  return false;
888  }
889 
890  for (unsigned int nSample = 0; nSample < nSampleCount; nSample++) {
891  for (unsigned int k = 0; k < 6; k++) {
892  *(((float *)pGazeVectorBuf) + k + (nSample * sizeof(SGazeVector))) =
893  (float)SetByteOrder((float *)(mpGazeVectorData[nVectorIndex] + 8 +
894  k * sizeof(float) + nSample * 24));
895  }
896  }
897 
898  return true;
899 }
900 
901 //-----------------------------------------------------------
902 // Timecode
903 //-----------------------------------------------------------
904 unsigned int CRTPacket::GetTimecodeCount() { return mnTimecodeCount; }
905 
906 bool CRTPacket::GetTimecodeType(unsigned int nTimecodeIndex,
907  CRTPacket::ETimecodeType &timecodeType) {
908  if (mnTimecodeCount <= nTimecodeIndex) {
909  return false;
910  }
911  timecodeType = (CRTPacket::ETimecodeType)SetByteOrder(
912  (unsigned int *)(mpTimecodeData[nTimecodeIndex]));
913  return true;
914 }
915 
916 bool CRTPacket::GetTimecodeSMPTE(unsigned int nTimecodeIndex, int &hours,
917  int &minutes, int &seconds, int &frame) {
918  if (mnTimecodeCount <= nTimecodeIndex) {
919  return false;
920  }
921  CRTPacket::ETimecodeType timecodeType;
922  if (GetTimecodeType(nTimecodeIndex, timecodeType)) {
923  if (timecodeType == TimecodeSMPTE) {
924  hours = 0x1f & SetByteOrder(
925  (unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8));
926  minutes =
927  0x3f &
928  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
929  5);
930  seconds =
931  0x3f &
932  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
933  11);
934  frame =
935  0x1f &
936  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
937  17);
938  return true;
939  }
940  }
941  return false;
942 }
943 
944 bool CRTPacket::GetTimecodeIRIG(unsigned int nTimecodeIndex, int &year,
945  int &day, int &hours, int &minutes,
946  int &seconds, int &tenths) {
947  if (mnTimecodeCount <= nTimecodeIndex) {
948  return false;
949  }
950  CRTPacket::ETimecodeType timecodeType;
951  if (GetTimecodeType(nTimecodeIndex, timecodeType)) {
952  if (timecodeType == TimecodeIRIG) {
953  year = 0x007f &
954  SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 4));
955  day =
956  0x01ff &
957  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 4)) >>
958  7);
959  hours =
960  0x001f &
961  SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8));
962  minutes =
963  0x003f &
964  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
965  5);
966  seconds =
967  0x003f &
968  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
969  11);
970  tenths =
971  0x000f &
972  (SetByteOrder((unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8)) >>
973  17);
974  return true;
975  }
976  }
977  return false;
978 }
979 
980 bool CRTPacket::GetTimecodeCameraTime(unsigned int nTimecodeIndex,
981  unsigned long long &cameraTime) {
982  if (mnTimecodeCount <= nTimecodeIndex) {
983  return false;
984  }
985  CRTPacket::ETimecodeType timecodeType;
986  if (GetTimecodeType(nTimecodeIndex, timecodeType)) {
987  if (timecodeType == TimecodeCamerTime) {
988  cameraTime = ((long long)SetByteOrder(
989  (unsigned int *)(mpTimecodeData[nTimecodeIndex] + 4)))
990  << 32 |
991  (long long)SetByteOrder(
992  (unsigned int *)(mpTimecodeData[nTimecodeIndex] + 8));
993  return true;
994  }
995  }
996  return false;
997 }
998 
999 //-----------------------------------------------------------
1000 // Image
1001 //-----------------------------------------------------------
1002 unsigned int CRTPacket::GetImageCameraCount() { return mnImageCameraCount; }
1003 
1004 unsigned int CRTPacket::GetImageCameraId(unsigned int nCameraIndex) {
1005  if (mnImageCameraCount <= nCameraIndex) {
1006  return 0;
1007  }
1008  return SetByteOrder((unsigned int *)(mpImageData[nCameraIndex]));
1009 }
1010 
1011 bool CRTPacket::GetImageFormat(unsigned int nCameraIndex,
1012  EImageFormat &eImageFormat) {
1013  if (mnImageCameraCount <= nCameraIndex) {
1014  return false;
1015  }
1016  eImageFormat = (EImageFormat)SetByteOrder(
1017  (unsigned int *)(mpImageData[nCameraIndex] + 4));
1018 
1019  return true;
1020 }
1021 
1022 bool CRTPacket::GetImageSize(unsigned int nCameraIndex, unsigned int &nWidth,
1023  unsigned int &nHeight) {
1024  if (mnImageCameraCount <= nCameraIndex) {
1025  return false;
1026  }
1027  nWidth = SetByteOrder((unsigned int *)(mpImageData[nCameraIndex] + 8));
1028  nHeight = SetByteOrder((unsigned int *)(mpImageData[nCameraIndex] + 12));
1029 
1030  return true;
1031 }
1032 
1033 bool CRTPacket::GetImageCrop(unsigned int nCameraIndex, float &fCropLeft,
1034  float &fCropTop, float &fCropRight,
1035  float &fCropBottom) {
1036  if (mnImageCameraCount <= nCameraIndex) {
1037  return false;
1038  }
1039  fCropLeft = SetByteOrder((float *)(mpImageData[nCameraIndex] + 16));
1040  fCropTop = SetByteOrder((float *)(mpImageData[nCameraIndex] + 20));
1041  fCropRight = SetByteOrder((float *)(mpImageData[nCameraIndex] + 24));
1042  fCropBottom = SetByteOrder((float *)(mpImageData[nCameraIndex] + 28));
1043 
1044  return true;
1045 }
1046 
1047 unsigned int CRTPacket::GetImageSize(unsigned int nCameraIndex) {
1048  if (((mnMajorVersion == 1) && (mnMinorVersion < 8)) ||
1049  mnImageCameraCount <= nCameraIndex) {
1050  return 0;
1051  }
1052 
1053  return SetByteOrder((unsigned int *)(mpImageData[nCameraIndex] + 32));
1054 }
1055 
1056 unsigned int CRTPacket::GetImage(unsigned int nCameraIndex, char *pDataBuf,
1057  unsigned int nBufSize) {
1058  if (((mnMajorVersion == 1) && (mnMinorVersion < 8)) ||
1059  mnImageCameraCount <= nCameraIndex) {
1060  return 0;
1061  }
1062 
1063  unsigned int nSize =
1064  SetByteOrder((unsigned int *)(mpImageData[nCameraIndex] + 32));
1065 
1066  if (nBufSize < nSize) {
1067  return 0;
1068  }
1069  memcpy(pDataBuf, mpImageData[nCameraIndex] + 36, nSize);
1070 
1071  return nSize;
1072 }
1073 
1074 //-----------------------------------------------------------
1075 // Analog
1076 //-----------------------------------------------------------
1077 unsigned int CRTPacket::GetAnalogDeviceCount() { return mnAnalogDeviceCount; }
1078 
1079 unsigned int CRTPacket::GetAnalogDeviceId(unsigned int nDeviceIndex) {
1080  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1081  return 1;
1082  }
1083  if (mnAnalogDeviceCount <= nDeviceIndex) {
1084  return 0;
1085  }
1086  return SetByteOrder((unsigned int *)(mpAnalogData[nDeviceIndex]));
1087 }
1088 
1089 unsigned int CRTPacket::GetAnalogChannelCount(unsigned int nDeviceIndex) {
1090  char *pData = mpComponentData[ComponentAnalog - 1];
1091 
1092  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1093  return SetByteOrder((unsigned int *)(pData + 8));
1094  }
1095  if (mnAnalogDeviceCount <= nDeviceIndex) {
1096  return 0;
1097  }
1098  return SetByteOrder((unsigned int *)(mpAnalogData[nDeviceIndex] + 4));
1099 }
1100 
1101 unsigned int CRTPacket::GetAnalogSampleCount(unsigned int nDeviceIndex) {
1102  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1103  return 1;
1104  }
1105  if (mnAnalogDeviceCount <= nDeviceIndex) {
1106  return 0;
1107  }
1108  return SetByteOrder((unsigned int *)(mpAnalogData[nDeviceIndex] + 8));
1109 }
1110 
1111 unsigned int CRTPacket::GetAnalogSampleNumber(unsigned int nDeviceIndex) {
1112  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1113  return GetFrameNumber();
1114  }
1115 
1116  if (mnAnalogDeviceCount <= nDeviceIndex) {
1117  return 0;
1118  }
1119  return SetByteOrder((unsigned int *)(mpAnalogData[nDeviceIndex] + 12));
1120 }
1121 
1122 unsigned int CRTPacket::GetAnalogData(unsigned int nDeviceIndex,
1123  float *pDataBuf, unsigned int nBufSize) {
1124  unsigned int nSize = 0;
1125 
1126  if (nDeviceIndex < mnAnalogDeviceCount) {
1127  unsigned int nChannelCount = GetAnalogChannelCount(nDeviceIndex);
1128 
1129  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1130  nSize = nChannelCount;
1131  if (nBufSize < nSize || pDataBuf == nullptr) {
1132  nSize = 0;
1133  }
1134  for (unsigned int i = 0; i < nSize; i++) {
1135  pDataBuf[i] = (float)SetByteOrder(
1136  (double *)(mpAnalogData[nDeviceIndex] + i * sizeof(double)));
1137  }
1138  } else {
1139  nSize = nChannelCount * GetAnalogSampleCount(nDeviceIndex);
1140  if (nBufSize < nSize || pDataBuf == nullptr) {
1141  nSize = 0;
1142  }
1143  for (unsigned int i = 0; i < nSize; i++) {
1144  pDataBuf[i] = (float)SetByteOrder(
1145  (float *)(mpAnalogData[nDeviceIndex] + 16 + i * sizeof(float)));
1146  }
1147  }
1148  }
1149 
1150  return nSize;
1151 }
1152 
1153 unsigned int CRTPacket::GetAnalogData(unsigned int nDeviceIndex,
1154  unsigned int nChannelIndex,
1155  float *pDataBuf, unsigned int nBufSize) {
1156  unsigned int nSampleCount = 0;
1157  unsigned int nChannelCount = GetAnalogChannelCount(nDeviceIndex);
1158 
1159  if (nDeviceIndex < mnAnalogDeviceCount && nChannelIndex < nChannelCount) {
1160  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1161  if (nBufSize == 0 || pDataBuf == nullptr) {
1162  nSampleCount = 0;
1163  } else {
1164  nSampleCount = 1;
1165  pDataBuf[0] =
1166  (float)SetByteOrder((double *)(mpAnalogData[nDeviceIndex] +
1167  nChannelIndex * sizeof(double)));
1168  }
1169  } else {
1170  nSampleCount = GetAnalogSampleCount(nDeviceIndex);
1171  if (nBufSize < nSampleCount || pDataBuf == nullptr) {
1172  nSampleCount = 0;
1173  }
1174  for (unsigned int i = 0; i < nSampleCount; i++) {
1175  pDataBuf[i] = (float)SetByteOrder(
1176  (float *)(mpAnalogData[nDeviceIndex] + 16 +
1177  nChannelIndex * nSampleCount * sizeof(float) +
1178  i * sizeof(float)));
1179  }
1180  }
1181  }
1182 
1183  return nSampleCount;
1184 }
1185 
1186 bool CRTPacket::GetAnalogData(unsigned int nDeviceIndex,
1187  unsigned int nChannelIndex,
1188  unsigned int nSampleIndex, float &fAnalogValue) {
1189  if (nDeviceIndex < mnAnalogDeviceCount) {
1190  unsigned int nSampleCount = GetAnalogSampleCount(nDeviceIndex);
1191 
1192  if (GetAnalogChannelCount(nDeviceIndex) > nChannelIndex &&
1193  nSampleCount > nSampleIndex) {
1194  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1195  fAnalogValue =
1196  (float)SetByteOrder((double *)(mpAnalogData[nDeviceIndex] +
1197  nChannelIndex * sizeof(double)));
1198  } else {
1199  fAnalogValue = SetByteOrder(
1200  (float *)(mpAnalogData[nDeviceIndex] + 16 +
1201  (nChannelIndex * nSampleCount + nSampleIndex) *
1202  sizeof(float)));
1203  }
1204  if (isnan(fAnalogValue) == 0) {
1205  return true;
1206  }
1207  }
1208  }
1209  return false;
1210 }
1211 
1212 //-----------------------------------------------------------
1213 // Analog Single
1214 //-----------------------------------------------------------
1216  return mnAnalogSingleDeviceCount;
1217 }
1218 
1219 unsigned int CRTPacket::GetAnalogSingleDeviceId(unsigned int nDeviceIndex) {
1220  if (mnAnalogSingleDeviceCount <= nDeviceIndex) {
1221  return 0;
1222  }
1223  return SetByteOrder((unsigned int *)(mpAnalogSingleData[nDeviceIndex]));
1224 }
1225 
1226 unsigned int CRTPacket::GetAnalogSingleChannelCount(unsigned int nDeviceIndex) {
1227  if (mnAnalogSingleDeviceCount <= nDeviceIndex) {
1228  return 0;
1229  }
1230  return SetByteOrder((unsigned int *)(mpAnalogSingleData[nDeviceIndex] + 4));
1231 }
1232 
1233 unsigned int CRTPacket::GetAnalogSingleData(unsigned int nDeviceIndex,
1234  float *pDataBuf,
1235  unsigned int nBufSize) {
1236  unsigned int nSize = 0;
1237 
1238  if (nDeviceIndex < mnAnalogSingleDeviceCount) {
1239  nSize = GetAnalogSingleChannelCount(nDeviceIndex);
1240  if (nBufSize < nSize || pDataBuf == nullptr) {
1241  nSize = 0;
1242  }
1243  for (unsigned int i = 0; i < nSize; i++) {
1244  pDataBuf[i] = SetByteOrder(
1245  (float *)(mpAnalogSingleData[nDeviceIndex] + 8 + i * sizeof(float)));
1246  }
1247  }
1248 
1249  return nSize;
1250 }
1251 
1252 bool CRTPacket::GetAnalogSingleData(unsigned int nDeviceIndex,
1253  unsigned int nChannelIndex, float &fValue) {
1254  if (nDeviceIndex < mnAnalogSingleDeviceCount) {
1255  if (nChannelIndex < GetAnalogSingleChannelCount(nDeviceIndex)) {
1256  fValue = SetByteOrder(((float *)(mpAnalogSingleData[nDeviceIndex] + 8 +
1257  nChannelIndex * sizeof(float))));
1258  return (isnan(fValue) == 0);
1259  }
1260  }
1261  return false;
1262 }
1263 
1264 //-----------------------------------------------------------
1265 // Force
1266 //-----------------------------------------------------------
1267 unsigned int CRTPacket::GetForcePlateCount() { return mnForcePlateCount; }
1268 
1269 unsigned int CRTPacket::GetForcePlateId(unsigned int nPlateIndex) {
1270  if ((mnMajorVersion == 1 && mnMinorVersion == 0) ||
1271  mnForcePlateCount <= nPlateIndex) {
1272  return 0;
1273  }
1274  return SetByteOrder((unsigned int *)(mpForceData[nPlateIndex]));
1275 }
1276 
1277 unsigned int CRTPacket::GetForceCount(unsigned int nPlateIndex) {
1278  if (mnForcePlateCount <= nPlateIndex) {
1279  return 0;
1280  }
1281  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1282  return 1;
1283  }
1284  return SetByteOrder((unsigned int *)(mpForceData[nPlateIndex] + 4));
1285 }
1286 
1287 unsigned int CRTPacket::GetForceNumber(unsigned int nPlateIndex) {
1288  if (mnForcePlateCount <= nPlateIndex) {
1289  return 0;
1290  }
1291  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1292  return GetFrameNumber();
1293  }
1294  return SetByteOrder((unsigned int *)(mpForceData[nPlateIndex] + 8));
1295 }
1296 
1297 unsigned int CRTPacket::GetForceData(unsigned int nPlateIndex,
1298  SForce *pForceBuf, unsigned int nBufSize) {
1299  unsigned int nSize = 0;
1300 
1301  if (nPlateIndex < mnForcePlateCount) {
1302  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1303  if (nPlateIndex == 0) {
1304  for (unsigned int k = 0; k < 9; k++) {
1305  *(((float *)pForceBuf) + k) = (float)SetByteOrder(
1306  (double *)(mpForceData[nPlateIndex] + k * sizeof(double)));
1307  }
1308  nSize = 1;
1309  }
1310  } else {
1311  nSize = GetForceCount(nPlateIndex);
1312  if (nBufSize < nSize || pForceBuf == nullptr) {
1313  nSize = 0;
1314  }
1315  for (unsigned int i = 0; i < nSize; i++) {
1316  for (unsigned int k = 0; k < 9; k++) {
1317  *(((float *)&pForceBuf[i]) + k) =
1318  SetByteOrder((float *)(mpForceData[nPlateIndex] + 12 + (k * 4) +
1319  i * sizeof(SForce)));
1320  }
1321  }
1322  }
1323  }
1324  return nSize;
1325 }
1326 
1327 bool CRTPacket::GetForceData(unsigned int nPlateIndex, unsigned int nForceIndex,
1328  SForce &sForce) {
1329  if (nPlateIndex < mnForcePlateCount) {
1330  if ((mnMajorVersion == 1) && (mnMinorVersion == 0)) {
1331  if (nPlateIndex == 0 && nForceIndex == 0) {
1332  for (unsigned int k = 0; k < 9; k++) {
1333  *(((float *)&sForce) + k) = (float)SetByteOrder(
1334  (double *)(mpForceData[nPlateIndex] + k * sizeof(double)));
1335 
1336  // Not a valid force if one of the values is not a valid float.
1337  if (isnan(*(((float *)&sForce) + k)) != 0) {
1338  return false;
1339  }
1340  }
1341  return true;
1342  }
1343  } else {
1344  if (nForceIndex < GetForceCount(nPlateIndex)) {
1345  for (unsigned int k = 0; k < 9; k++) {
1346  *(((float *)&sForce) + k) = SetByteOrder(
1347  (float *)(mpForceData[nPlateIndex] + 12 + k * sizeof(float) +
1348  nForceIndex * sizeof(SForce)));
1349 
1350  // Not a valid force if one of the values is not a valid float.
1351  if (isnan(*(((float *)&sForce) + k)) != 0) {
1352  return false;
1353  }
1354  }
1355  return true;
1356  }
1357  }
1358  }
1359  return false;
1360 }
1361 
1362 //-----------------------------------------------------------
1363 // Skeleton
1364 //-----------------------------------------------------------
1365 unsigned int CRTPacket::GetSkeletonCount() { return mSkeletonCount; }
1366 
1367 unsigned int CRTPacket::GetSkeletonSegmentCount(unsigned int nSkeletonIndex) {
1368  if (mSkeletonCount <= nSkeletonIndex) {
1369  return 0;
1370  }
1371  return SetByteOrder((unsigned int *)(mpSkeletonData[nSkeletonIndex]));
1372 }
1373 
1374 bool CRTPacket::GetSkeletonSegments(unsigned int nSkeletonIndex,
1375  SSkeletonSegment *segmentBuffer,
1376  unsigned int nBufSize) {
1377  if (mSkeletonCount <= nSkeletonIndex) {
1378  return false;
1379  }
1380 
1381  unsigned int segmentCount = GetSkeletonSegmentCount(nSkeletonIndex);
1382  if (segmentCount == 0) {
1383  return false;
1384  }
1385 
1386  if (nBufSize < segmentCount * 32 || segmentBuffer == nullptr) {
1387  segmentCount = 0;
1388  return false;
1389  }
1390 
1391  if (mbBigEndian) {
1392  for (unsigned int i = 0; i < segmentCount; i++) {
1393  segmentBuffer[i].id = SetByteOrder(
1394  (unsigned int *)(mpSkeletonData[nSkeletonIndex] + 4 + i * 32));
1395  segmentBuffer[i].positionX =
1396  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 8 + i * 32));
1397  segmentBuffer[i].positionY =
1398  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 12 + i * 32));
1399  segmentBuffer[i].positionZ =
1400  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 16 + i * 32));
1401  segmentBuffer[i].rotationX =
1402  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 20 + i * 32));
1403  segmentBuffer[i].rotationY =
1404  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 24 + i * 32));
1405  segmentBuffer[i].rotationZ =
1406  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 28 + i * 32));
1407  segmentBuffer[i].rotationW =
1408  SetByteOrder((float *)(mpSkeletonData[nSkeletonIndex] + 32 + i * 32));
1409  }
1410  } else {
1411  memcpy(segmentBuffer, mpSkeletonData[nSkeletonIndex] + 4,
1412  sizeof(SSkeletonSegment) * segmentCount);
1413  }
1414  return true;
1415 }
1416 
1417 bool CRTPacket::GetSkeletonSegment(unsigned int nSkeletonIndex,
1418  unsigned segmentIndex,
1419  SSkeletonSegment &segment) {
1420  if (mSkeletonCount <= nSkeletonIndex) {
1421  return false;
1422  }
1423 
1424  unsigned int segmentCount = GetSkeletonSegmentCount(nSkeletonIndex);
1425  if (segmentCount == 0) {
1426  return false;
1427  }
1428 
1429  if (segmentIndex >= segmentCount) {
1430  return false;
1431  }
1432 
1433  if (mbBigEndian) {
1434  segment.id = SetByteOrder((unsigned int *)(mpSkeletonData[nSkeletonIndex] +
1435  4 + 32 * segmentIndex));
1436  segment.positionX = SetByteOrder(
1437  (float *)(mpSkeletonData[nSkeletonIndex] + 8 + 32 * segmentIndex));
1438  segment.positionY = SetByteOrder(
1439  (float *)(mpSkeletonData[nSkeletonIndex] + 12 + 32 * segmentIndex));
1440  segment.positionZ = SetByteOrder(
1441  (float *)(mpSkeletonData[nSkeletonIndex] + 16 + 32 * segmentIndex));
1442  segment.rotationX = SetByteOrder(
1443  (float *)(mpSkeletonData[nSkeletonIndex] + 20 + 32 * segmentIndex));
1444  segment.rotationY = SetByteOrder(
1445  (float *)(mpSkeletonData[nSkeletonIndex] + 24 + 32 * segmentIndex));
1446  segment.rotationZ = SetByteOrder(
1447  (float *)(mpSkeletonData[nSkeletonIndex] + 28 + 32 * segmentIndex));
1448  segment.rotationW = SetByteOrder(
1449  (float *)(mpSkeletonData[nSkeletonIndex] + 32 + 32 * segmentIndex));
1450  } else {
1451  memcpy(&segment, mpSkeletonData[nSkeletonIndex] + 4 + 32 * segmentIndex,
1452  sizeof(SSkeletonSegment));
1453  }
1454 
1455  return true;
1456 }
1457 
1458 //-----------------------------------------------------------
1459 // Force Single
1460 //-----------------------------------------------------------
1462  return mnForceSinglePlateCount;
1463 }
1464 
1465 unsigned int CRTPacket::GetForceSinglePlateId(unsigned int nPlateIndex) {
1466  if ((mnMajorVersion == 1 && mnMinorVersion == 0) ||
1467  mnForceSinglePlateCount <= nPlateIndex) {
1468  return 0;
1469  }
1470  return SetByteOrder((unsigned int *)(mpForceSingleData[nPlateIndex]));
1471 }
1472 
1473 bool CRTPacket::GetForceSingleData(unsigned int nPlateIndex, SForce &sForce) {
1474  if (nPlateIndex < mnForceSinglePlateCount) {
1475  for (unsigned int k = 0; k < 9; k++) {
1476  *(((float *)&sForce) + k) = SetByteOrder(
1477  (float *)(mpForceSingleData[nPlateIndex] + 4 + k * sizeof(float)));
1478 
1479  // Not a valid force if one of the values is not a valid float.
1480  if (isnan(*(((float *)&sForce) + k)) != 0) {
1481  return false;
1482  }
1483  }
1484  return true;
1485  }
1486 
1487  return false;
1488 }
1489 
1490 float CRTPacket::SetByteOrder(float *pfData) {
1491  unsigned int nTmp;
1492 
1493  if (mbBigEndian) {
1494  nTmp = ntohl(*((unsigned int *)pfData));
1495  return *((float *)&nTmp);
1496  }
1497  return *pfData;
1498 } // SetByteOrder
1499 
1500 double CRTPacket::SetByteOrder(double *pfData) {
1501  unsigned long long nTmp;
1502 
1503  if (mbBigEndian) {
1504  nTmp = (((unsigned long long)(ntohl((long)*((unsigned long long *)pfData)))
1505  << 32) +
1506  ntohl(*((unsigned long long *)pfData) >> 32));
1507  return *((double *)&nTmp);
1508  }
1509  return *pfData;
1510 } // SetByteOrder
1511 
1512 short CRTPacket::SetByteOrder(short *pnData) {
1513  if (mbBigEndian) {
1514  return ntohs(*pnData);
1515  }
1516  return *pnData;
1517 } // SetByteOrder
1518 
1519 unsigned short CRTPacket::SetByteOrder(unsigned short *pnData) {
1520  if (mbBigEndian) {
1521  return ntohs(*pnData);
1522  }
1523  return *pnData;
1524 } // SetByteOrder
1525 
1526 long CRTPacket::SetByteOrder(long *pnData) {
1527  if (mbBigEndian) {
1528  return ntohl(*pnData);
1529  }
1530  return *pnData;
1531 } // SetByteOrder
1532 
1533 int CRTPacket::SetByteOrder(int *pnData) {
1534  if (mbBigEndian) {
1535  return ntohl(*pnData);
1536  }
1537  return *pnData;
1538 } // SetByteOrder
1539 
1540 unsigned int CRTPacket::SetByteOrder(unsigned int *pnData) {
1541  if (mbBigEndian) {
1542  return ntohl(*pnData);
1543  }
1544  return *pnData;
1545 } // SetByteOrder
1546 
1547 long long CRTPacket::SetByteOrder(long long *pnData) {
1548  if (mbBigEndian) {
1549  return ((unsigned long long)(ntohl((long)*pnData)) << 32) +
1550  ntohl(*pnData >> 32);
1551  }
1552  return *pnData;
1553 } // SetByteOrder
1554 
1555 unsigned long long CRTPacket::SetByteOrder(unsigned long long *pnData) {
1556  if (mbBigEndian) {
1557  return ((unsigned long long)(ntohl((long)*pnData)) << 32) +
1558  ntohl(*pnData >> 32);
1559  }
1560  return *pnData;
1561 } // SetByteOrder
CRTPacket::Get3DMarker
bool Get3DMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ)
Definition: RTPacket.cpp:552
CRTPacket::GetForceCount
unsigned int GetForceCount(unsigned int nPlateIndex)
Definition: RTPacket.cpp:1277
CRTPacket::EImageFormat
EImageFormat
Definition: RTPacket.h:60
CRTPacket::Component3dRes
@ Component3dRes
Definition: RTPacket.h:47
CRTPacket::GetType
EPacketType GetType()
Definition: RTPacket.cpp:271
CRTPacket::ComponentTimecode
@ ComponentTimecode
Definition: RTPacket.h:55
CRTPacket::SSkeletonSegment::positionY
float positionY
Definition: RTPacket.h:118
MAX_FORCE_PLATE_COUNT
#define MAX_FORCE_PLATE_COUNT
Definition: RTPacket.h:18
CRTPacket::PacketError
@ PacketError
Definition: RTPacket.h:26
CRTPacket::SSkeletonSegment::positionZ
float positionZ
Definition: RTPacket.h:119
CRTPacket::GetImageSize
bool GetImageSize(unsigned int nCameraIndex, unsigned int &nWidth, unsigned int &nHeight)
Definition: RTPacket.cpp:1022
CRTPacket::TimecodeIRIG
@ TimecodeIRIG
Definition: RTPacket.h:90
CRTPacket::PacketEvent
@ PacketEvent
Definition: RTPacket.h:32
CRTPacket::Get6DOFEulerResidualBodyCount
unsigned int Get6DOFEulerResidualBodyCount()
Definition: RTPacket.cpp:803
CRTPacket::SGazeVector
Definition: RTPacket.h:106
CRTPacket::GetAnalogSingleData
unsigned int GetAnalogSingleData(unsigned int nDeviceIndex, float *pDataBuf, unsigned int nBufSize)
Definition: RTPacket.cpp:1233
CRTPacket::GetSkeletonSegmentCount
unsigned int GetSkeletonSegmentCount(unsigned int nSkeletonIndex)
Definition: RTPacket.cpp:1367
CRTPacket::GetDiscoverResponseBasePort
short GetDiscoverResponseBasePort()
Definition: RTPacket.cpp:374
CRTPacket::Component2dLin
@ Component2dLin
Definition: RTPacket.h:46
CRTPacket::Get2DLinCameraCount
unsigned int Get2DLinCameraCount()
Definition: RTPacket.cpp:489
CRTPacket::Get3DMarkerCount
unsigned int Get3DMarkerCount()
Definition: RTPacket.cpp:539
CRTPacket::CRTPacket
CRTPacket(int nMajorVersion=MAJOR_VERSION, int nMinorVersion=MINOR_VERSION, bool bBigEndian=false)
Definition: RTPacket.cpp:17
CRTPacket::GetFrameNumber
unsigned int GetFrameNumber()
Definition: RTPacket.cpp:288
CRTPacket::Get6DOFEulerBodyCount
unsigned int Get6DOFEulerBodyCount()
Definition: RTPacket.cpp:764
CRTPacket::EPacketType
EPacketType
Definition: RTPacket.h:25
CRTPacket::GetEndianness
bool GetEndianness()
Definition: RTPacket.cpp:37
CRTPacket::Get2DLinMarker
bool Get2DLinMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex, unsigned int &nX, unsigned int &nY, unsigned short &nXDiameter, unsigned short &nYDiameter)
Definition: RTPacket.cpp:506
CRTPacket::Component6d
@ Component6d
Definition: RTPacket.h:43
CRTPacket::GetForcePlateCount
unsigned int GetForcePlateCount()
Definition: RTPacket.cpp:1267
CRTPacket::GetGazeVectorSampleNumber
unsigned int GetGazeVectorSampleNumber(unsigned int nVectorIndex)
Definition: RTPacket.cpp:854
CRTPacket::GetImageFormat
bool GetImageFormat(unsigned int nCameraIndex, EImageFormat &eImageFormat)
Definition: RTPacket.cpp:1011
CRTPacket::GetForceNumber
unsigned int GetForceNumber(unsigned int nPlateIndex)
Definition: RTPacket.cpp:1287
CRTPacket::Get2DMarker
bool Get2DMarker(unsigned int nCameraIndex, unsigned int nMarkerIndex, unsigned int &nX, unsigned int &nY, unsigned short &nXDiameter, unsigned short &nYDiameter)
Definition: RTPacket.cpp:456
CRTPacket::Component2d
@ Component2d
Definition: RTPacket.h:45
CRTPacket::Get3DNoLabelsMarker
bool Get3DNoLabelsMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ, unsigned int &nId)
Definition: RTPacket.cpp:618
MAX_SKELETON_COUNT
#define MAX_SKELETON_COUNT
Definition: RTPacket.h:21
CRTPacket::ComponentNone
@ ComponentNone
Definition: RTPacket.h:57
CRTPacket::PacketData
@ PacketData
Definition: RTPacket.h:29
CRTPacket::Get3DNoLabelsMarkerCount
unsigned int Get3DNoLabelsMarkerCount()
Definition: RTPacket.cpp:609
CRTPacket::Get2DMarkerCount
unsigned int Get2DMarkerCount(unsigned int nCameraIndex)
Definition: RTPacket.cpp:441
CRTPacket::SSkeletonSegment::rotationX
float rotationX
Definition: RTPacket.h:120
CRTPacket::GetImageCrop
bool GetImageCrop(unsigned int nCameraIndex, float &fCropLeft, float &fCropTop, float &fCropRight, float &fCropBottom)
Definition: RTPacket.cpp:1033
CRTPacket::ComponentForceSingle
@ ComponentForceSingle
Definition: RTPacket.h:53
CRTPacket::Get6DOFResidualBodyCount
unsigned int Get6DOFResidualBodyCount()
Definition: RTPacket.cpp:721
RTPacket.h
CRTPacket::GetTimecodeType
bool GetTimecodeType(unsigned int nTimecodeIndex, CRTPacket::ETimecodeType &timecodeType)
Definition: RTPacket.cpp:906
CRTPacket::ComponentSkeleton
@ ComponentSkeleton
Definition: RTPacket.h:56
CRTPacket::Get3DNoLabelsResidualMarkerCount
unsigned int Get3DNoLabelsResidualMarkerCount()
Definition: RTPacket.cpp:643
CRTPacket::GetSkeletonSegments
bool GetSkeletonSegments(unsigned int nSkeletonIndex, SSkeletonSegment *segmentBuf, unsigned int nBufSize)
Definition: RTPacket.cpp:1374
CRTPacket::ClearData
void ClearData()
Definition: RTPacket.cpp:41
CRTPacket::SSkeletonSegment::rotationW
float rotationW
Definition: RTPacket.h:123
CRTPacket::Get6DOFBodyCount
unsigned int Get6DOFBodyCount()
Definition: RTPacket.cpp:681
CRTPacket::Get2DLinStatusFlags
unsigned char Get2DLinStatusFlags(unsigned int nCameraIndex)
Definition: RTPacket.cpp:498
CRTPacket::GetForceSinglePlateId
unsigned int GetForceSinglePlateId(unsigned int nPlateIndex)
Definition: RTPacket.cpp:1465
CRTPacket::SSkeletonSegment::rotationY
float rotationY
Definition: RTPacket.h:121
CRTPacket::GetTimecodeCount
unsigned int GetTimecodeCount()
Definition: RTPacket.cpp:904
CRTPacket::PacketCommand
@ PacketCommand
Definition: RTPacket.h:27
CRTPacket::Component3d
@ Component3d
Definition: RTPacket.h:39
CRTPacket::PacketXML
@ PacketXML
Definition: RTPacket.h:28
CRTPacket::GetAnalogDeviceId
unsigned int GetAnalogDeviceId(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1079
CRTPacket::TimecodeCamerTime
@ TimecodeCamerTime
Definition: RTPacket.h:91
CRTPacket::GetEvent
bool GetEvent(EEvent &eEvent)
Definition: RTPacket.cpp:392
CRTPacket::SSkeletonSegment::id
unsigned int id
Definition: RTPacket.h:116
CRTPacket::GetImageCameraCount
unsigned int GetImageCameraCount()
Definition: RTPacket.cpp:1002
CRTPacket::GetAnalogSingleChannelCount
unsigned int GetAnalogSingleChannelCount(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1226
CRTPacket::GetImage
unsigned int GetImage(unsigned int nCameraIndex, char *pDataBuf, unsigned int nBufSize)
Definition: RTPacket.cpp:1056
CRTPacket::GetErrorString
char * GetErrorString()
Definition: RTPacket.cpp:346
CRTPacket::GetSkeletonSegment
bool GetSkeletonSegment(unsigned int nSkeletonIndex, unsigned segmentIndex, SSkeletonSegment &segment)
Definition: RTPacket.cpp:1417
CRTPacket::SSkeletonSegment
Definition: RTPacket.h:115
CRTPacket::GetData
void GetData(char *&ptr, unsigned int &nSize)
Definition: RTPacket.cpp:252
CRTPacket::ETimecodeType
ETimecodeType
Definition: RTPacket.h:88
CRTPacket::Component3dNoLabelsRes
@ Component3dNoLabelsRes
Definition: RTPacket.h:48
CRTPacket::GetAnalogDeviceCount
unsigned int GetAnalogDeviceCount()
Definition: RTPacket.cpp:1077
CRTPacket::SetVersion
void SetVersion(unsigned int nMajorVersion, unsigned int nMinorVersion)
Definition: RTPacket.cpp:31
CRTPacket::Get3DResidualMarker
bool Get3DResidualMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ, float &fResidual)
Definition: RTPacket.cpp:584
CRTPacket::GetForcePlateId
unsigned int GetForcePlateId(unsigned int nPlateIndex)
Definition: RTPacket.cpp:1269
CRTPacket::GetComponentCount
unsigned int GetComponentCount()
Definition: RTPacket.cpp:334
CRTPacket::Component6dRes
@ Component6dRes
Definition: RTPacket.h:49
CRTPacket::ComponentForce
@ ComponentForce
Definition: RTPacket.h:42
CRTPacket::GetSize
unsigned int GetSize()
Definition: RTPacket.cpp:261
CRTPacket::EEvent
EEvent
Definition: RTPacket.h:67
CRTPacket::SForce
Definition: RTPacket.h:94
CRTPacket::GetComponentSize
unsigned int GetComponentSize(EComponentType eComponent)
Definition: RTPacket.cpp:336
CRTPacket::Component3dNoLabels
@ Component3dNoLabels
Definition: RTPacket.h:40
CRTPacket::Get6DOFEulerBody
bool Get6DOFEulerBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ, float &fAng1, float &fAng2, float &fAng3)
Definition: RTPacket.cpp:773
CRTPacket::SSkeletonSegment::rotationZ
float rotationZ
Definition: RTPacket.h:122
CRTPacket::GetGazeVectorSampleCount
unsigned int GetGazeVectorSampleCount(unsigned int nVectorIndex)
Definition: RTPacket.cpp:847
CRTPacket::GetTimecodeCameraTime
bool GetTimecodeCameraTime(unsigned int nTimecodeIndex, unsigned long long &cameraTime)
Definition: RTPacket.cpp:980
CRTPacket::EComponentType
EComponentType
Definition: RTPacket.h:38
CRTPacket::SGazeVector::fPosX
float fPosX
Definition: RTPacket.h:110
CRTPacket::GetSkeletonCount
unsigned int GetSkeletonCount()
Definition: RTPacket.cpp:1365
CRTPacket::GetGazeVectorCount
unsigned int GetGazeVectorCount()
Definition: RTPacket.cpp:845
CRTPacket::GetGazeVector
bool GetGazeVector(unsigned int nVectorIndex, unsigned int nSampleIndex, SGazeVector &nGazeVector)
Definition: RTPacket.cpp:863
CRTPacket::ComponentImage
@ ComponentImage
Definition: RTPacket.h:52
MAX_ANALOG_DEVICE_COUNT
#define MAX_ANALOG_DEVICE_COUNT
Definition: RTPacket.h:17
CRTPacket::ComponentGazeVector
@ ComponentGazeVector
Definition: RTPacket.h:54
CRTPacket::ComponentAnalog
@ ComponentAnalog
Definition: RTPacket.h:41
CRTPacket::Component6dEulerRes
@ Component6dEulerRes
Definition: RTPacket.h:50
CRTPacket::GetVersion
void GetVersion(unsigned int &nMajorVersion, unsigned int &nMinorVersion)
Definition: RTPacket.cpp:25
CRTPacket::GetForceSingleData
bool GetForceSingleData(unsigned int nPlateIndex, SForce &pForce)
Definition: RTPacket.cpp:1473
CRTPacket::SetData
void SetData(char *ptr)
Definition: RTPacket.cpp:66
CRTPacket::GetOutOfSyncRate
unsigned short GetOutOfSyncRate()
Definition: RTPacket.cpp:422
CRTPacket::Get2DLinMarkerCount
unsigned int Get2DLinMarkerCount(unsigned int nCameraIndex)
Definition: RTPacket.cpp:491
CRTPacket::Get6DOFEulerResidualBody
bool Get6DOFEulerResidualBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ, float &fAng1, float &fAng2, float &fAng3, float &fResidual)
Definition: RTPacket.cpp:812
CRTPacket::TimecodeSMPTE
@ TimecodeSMPTE
Definition: RTPacket.h:89
CRTPacket::GetAnalogSampleCount
unsigned int GetAnalogSampleCount(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1101
CRTPacket::Get2DStatusFlags
unsigned char Get2DStatusFlags(unsigned int nCameraIndex)
Definition: RTPacket.cpp:448
CRTPacket::PacketNone
@ PacketNone
Definition: RTPacket.h:35
CRTPacket::Get2DCameraCount
unsigned int Get2DCameraCount()
Definition: RTPacket.cpp:439
CRTPacket::GetAnalogChannelCount
unsigned int GetAnalogChannelCount(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1089
CRTPacket::GetAnalogData
unsigned int GetAnalogData(unsigned int nDeviceIndex, float *pDataBuf, unsigned int nBufSize)
Definition: RTPacket.cpp:1122
CRTPacket::GetDropRate
unsigned short GetDropRate()
Definition: RTPacket.cpp:408
CRTPacket::Component6dEuler
@ Component6dEuler
Definition: RTPacket.h:44
MAX_GAZE_VECTOR_COUNT
#define MAX_GAZE_VECTOR_COUNT
Definition: RTPacket.h:19
CRTPacket::GetTimecodeSMPTE
bool GetTimecodeSMPTE(unsigned int nTimecodeIndex, int &hours, int &minutes, int &seconds, int &frame)
Definition: RTPacket.cpp:916
CRTPacket::GetForceData
unsigned int GetForceData(unsigned int nPlateIndex, SForce *pForceBuf, unsigned int nBufSize)
Definition: RTPacket.cpp:1297
CRTPacket::Get3DNoLabelsResidualMarker
bool Get3DNoLabelsResidualMarker(unsigned int nMarkerIndex, float &fX, float &fY, float &fZ, unsigned int &nId, float &fResidual)
Definition: RTPacket.cpp:652
CRTPacket::GetAnalogSingleDeviceId
unsigned int GetAnalogSingleDeviceId(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1219
CRTPacket::Get3DResidualMarkerCount
unsigned int Get3DResidualMarkerCount()
Definition: RTPacket.cpp:575
CRTPacket::ComponentAnalogSingle
@ ComponentAnalogSingle
Definition: RTPacket.h:51
CRTPacket::GetForceSinglePlateCount
unsigned int GetForceSinglePlateCount()
Definition: RTPacket.cpp:1461
CRTPacket::GetAnalogSingleDeviceCount
unsigned int GetAnalogSingleDeviceCount()
Definition: RTPacket.cpp:1215
CRTPacket::SetEndianness
void SetEndianness(bool bBigEndian)
Definition: RTPacket.cpp:39
CRTPacket::GetTimecodeIRIG
bool GetTimecodeIRIG(unsigned int nTimecodeIndex, int &year, int &day, int &hours, int &minutes, int &seconds, int &tenths)
Definition: RTPacket.cpp:944
CRTPacket::Get6DOFResidualBody
bool Get6DOFResidualBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ, float afRotMatrix[9], float &fResidual)
Definition: RTPacket.cpp:730
CRTPacket::GetCommandString
char * GetCommandString()
Definition: RTPacket.cpp:353
CRTPacket::GetAnalogSampleNumber
unsigned int GetAnalogSampleNumber(unsigned int nDeviceIndex)
Definition: RTPacket.cpp:1111
CRTPacket::GetXMLString
char * GetXMLString()
Definition: RTPacket.cpp:367
MAX_CAMERA_COUNT
#define MAX_CAMERA_COUNT
Definition: RTPacket.h:16
CRTPacket::GetImageCameraId
unsigned int GetImageCameraId(unsigned int nCameraIndex)
Definition: RTPacket.cpp:1004
CRTPacket::SSkeletonSegment::positionX
float positionX
Definition: RTPacket.h:117
CRTPacket::GetTimeStamp
unsigned long long GetTimeStamp()
Definition: RTPacket.cpp:281
CRTPacket::Get6DOFBody
bool Get6DOFBody(unsigned int nBodyIndex, float &fX, float &fY, float &fZ, float afRotMatrix[9])
Definition: RTPacket.cpp:690