36 #ifndef __POINTMATCHER_IOFUNCTIONS_H
37 #define __POINTMATCHER_IOFUNCTIONS_H
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