/usr/include/openigtlink/igtlNDArrayMessage.h is in libopenigtlink-dev 1.11.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | /*=========================================================================
Program: The OpenIGTLink Library
Language: C++
Web page: http://openigtlink.org/
Copyright (c) Insight Software Consortium. All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __igtlNDArrayMessage_h
#define __igtlNDArrayMessage_h
#include <string>
#include "igtlObject.h"
#include "igtlMath.h"
#include "igtlMessageBase.h"
#include "igtlTypes.h"
#define IGTL_STRING_MESSAGE_DEFAULT_ENCODING 3 /* Default encoding -- ANSI-X3.5-1968 */
namespace igtl
{
class IGTLCommon_EXPORT ArrayBase
{
public:
/// Vector type for an index of N-D array
typedef std::vector<igtlUint16> IndexType;
protected:
ArrayBase();
~ArrayBase();
public:
/// Sets the size of the N-D array. Returns non-zero value, if success.
int SetSize(IndexType size);
/// Gets the size of the N-D array.
IndexType GetSize() { return this->m_Size; };
/// Gets the dimension of the N-D array.
int GetDimension() { return this->m_Size.size(); };
/// Sets an array from a byte array. Size and dimension must be specified prior to
/// calling the SetArray() function.
int SetArray(void * array);
/// Gets the size of the raw byte array stored in the class.
igtlUint64 GetRawArraySize();
/// Gets the raw byte array stored in the class.
void * GetRawArray() { return this->m_ByteArray; };
protected:
/// Gets the size of a element of the array.
virtual int GetElementSize() = 0;
/// Gets the number of elements in the array.
igtlUint32 GetNumberOfElements();
/// Returns the 1-D index of the element specified by 'index'.
/// This function is used to calculate the index of the element in
/// the raw array.
igtlUint32 Get1DIndex(IndexType index);
private:
/// A vector representing the size of the N-D array.
IndexType m_Size;
/// A pointer to the byte array data.
void * m_ByteArray;
};
template <typename T>
class IGTLCommon_EXPORT Array : public ArrayBase
{
public:
/// Sets a value of the element specified by 'index'
int SetValue(IndexType index, T value)
{
if (Get1DIndex(index) <= GetNumberOfElements()) {
T* ByteArray = (T*)GetRawArray();
ByteArray[Get1DIndex(index) * sizeof(T)] = value;
return 1;
} else {
return 0;
}
}
/// Gets a value of the element specified by 'index'
int GetValue(IndexType index, T & value)
{
if (Get1DIndex(index) <= GetNumberOfElements()) {
T* ByteArray = (T*)GetRawArray();
value = ByteArray[Get1DIndex(index) * sizeof(T)];
return 1;
} else {
return 0;
}
}
protected:
/// Gets the size of elements (e.g. 1 byte in case of 8-bit integer)
virtual int GetElementSize() { return sizeof(T); };
};
class IGTLCommon_EXPORT NDArrayMessage: public MessageBase
{
public:
/// Types of elements
enum {
TYPE_INT8 = 2,
TYPE_UINT8 = 3,
TYPE_INT16 = 4,
TYPE_UINT16 = 5,
TYPE_INT32 = 6,
TYPE_UINT32 = 7,
TYPE_FLOAT32 = 10,
TYPE_FLOAT64 = 11,
TYPE_COMPLEX = 13,
};
public:
typedef NDArrayMessage Self;
typedef MessageBase Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
igtlTypeMacro(igtl::NDArrayMessage, igtl::MessageBase);
igtlNewMacro(igtl::NDArrayMessage);
public:
/// Sets an array with an element type.
int SetArray(int type, ArrayBase * a);
/// Gets a pointer to the array.
ArrayBase * GetArray() { return this->m_Array; };
/// Gets the type of elements of the array. (e.g. TYPE_INT8)
int GetType() { return this->m_Type; } ;
protected:
NDArrayMessage();
~NDArrayMessage();
protected:
virtual int GetBodyPackSize();
virtual int PackBody();
virtual int UnpackBody();
/// A pointer to the N-D array.
ArrayBase * m_Array;
/// A variable for the type of the N-D array.
int m_Type;
};
} // namespace igtl
#endif // _igtlNDArrayMessage_h
|