36 #ifndef __POINTMATCHER_IOFUNCTIONS_H 37 #define __POINTMATCHER_IOFUNCTIONS_H 65 std::reverse_copy(tmp.
bytes, tmp.
bytes +
sizeof(
T), bytes);
70 out.write(c.
bytes,
sizeof(
T));
75 in.read(c.
bytes,
sizeof(
T));
80 template<
typename Matrix>
85 typedef typename Matrix::Scalar TargetDataType;
86 for(
int r = 0; r < data.rows(); r++)
88 for(
int c = 0; c < data.cols(); c++)
107 template<
typename DataType,
typename MatrixRef>
108 std::istream &
readVtkData(
bool readBinary, MatrixRef into, std::istream & in)
110 typedef typename MatrixRef::Scalar TargetDataType;
112 for(
int r = 0; r < into.rows(); r++)
114 for(
int c = 0; c < into.cols(); c++)
116 TargetDataType & dest = into(r, c);
136 template<
typename MatrixRef>
139 if(dataType ==
"float")
141 return readVtkData<float>(readBinary, into, in);
143 else if (dataType ==
"double")
145 return readVtkData<double>(readBinary, into, in);
147 else if (dataType ==
"unsigned_int")
149 return readVtkData<unsigned int>(readBinary, into, in);
153 throw std::runtime_error(
std::string(
"Unsupported data type : " + dataType +
"! Expected 'float' or 'double'."));
163 #endif // __POINTMATCHER_IOFUNCTIONS_H std::istream & readVtkData(bool readBinary, MatrixRef into, std::istream &in)
const bool isBigEndian
true if platform is big endian
std::ostream & writeVtkData(bool writeBinary, const Matrix &data, std::ostream &out)
Functions and classes that are not dependant on scalar type are defined in this namespace.
std::istream & safeGetLine(std::istream &is, std::string &t)
Replaces getline for handling windows style CR/LF line endings.
ConverterToAndFromBytes(T v=static_cast< T >(0))
friend std::ostream & operator<<(std::ostream &out, const ConverterToAndFromBytes &c)
const int oneBigEndian
is always a big endian independent of the platforms endianness
friend std::istream & operator>>(std::istream &in, ConverterToAndFromBytes &c)