MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fiff_coord_trans.h
Go to the documentation of this file.
1//=============================================================================================================
37#ifndef FIFF_COORD_TRANS_H
38#define FIFF_COORD_TRANS_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "fiff_global.h"
45#include "fiff_types.h"
47
48//=============================================================================================================
49// QT INCLUDES
50//=============================================================================================================
51
52#include <QIODevice>
53#include <QSharedPointer>
54
55//=============================================================================================================
56// EIGEN INCLUDES
57//=============================================================================================================
58
59#include <Eigen/Core>
60
61//=============================================================================================================
62// DEFINE NAMESPACE FIFFLIB
63//=============================================================================================================
64
65namespace FIFFLIB
66{
67
68//=============================================================================================================
75{
76public:
77 typedef QSharedPointer<FiffCoordTrans> SPtr;
78 typedef QSharedPointer<const FiffCoordTrans> ConstSPtr;
80 //=========================================================================================================
85
86 //=========================================================================================================
92 FiffCoordTrans(QIODevice &p_IODevice);
93
94 //=========================================================================================================
100 FiffCoordTrans(const FiffCoordTrans &p_FiffCoordTrans);
101
102 //=========================================================================================================
107
108 //=========================================================================================================
112 void clear();
113
114 //=========================================================================================================
123 bool invert_transform();
124
125 //=========================================================================================================
131 inline bool isEmpty() const
132 {
133 return this->from < 0;
134 }
135
136 //=========================================================================================================
147 static bool read(QIODevice& p_IODevice, FiffCoordTrans& p_Trans);
148
149 //=========================================================================================================
162 Eigen::MatrixX3f apply_trans(const Eigen::MatrixX3f& rr, bool do_move = true) const;
163
164 //=========================================================================================================
173 Eigen::MatrixX3f apply_inverse_trans(const Eigen::MatrixX3f& rr, bool do_move = true) const;
174
175 //=========================================================================================================
185 static QString frame_name (int frame);
186
187 //=========================================================================================================
201 static FiffCoordTrans make(int from, int to, const Eigen::Matrix3f& rot, const Eigen::VectorXf& move);
202
203 //=========================================================================================================
215 static FiffCoordTrans make(int from, int to, const Eigen::Matrix4f& matTrans, bool bStandard = false);
216
217 //=========================================================================================================
225 static bool addInverse(FiffCoordTrans& t);
226
227 //=========================================================================================================
232 void print() const;
233
234 //=========================================================================================================
240 void write(QIODevice &p_IODevice);
241
242 //=========================================================================================================
248 void writeToStream(FiffStream* p_pStream);
249
250 //=========================================================================================================
256 inline static qint32 storageSize();
257
258 //========================================================================================================
266 friend bool operator== (const FiffCoordTrans &a, const FiffCoordTrans &b);
267
268 //========================================================================================================
275 float angleTo(Eigen::MatrixX4f mTransDest);
276
277 //========================================================================================================
284 float translationTo(Eigen::MatrixX4f mTransDest);
285
286 //========================================================================================================
292 FiffCoordTransOld toOld();
293
294public:
295 fiff_int_t from;
296 fiff_int_t to;
297 Eigen::Matrix<float, 4,4, Eigen::DontAlign> trans;
298 Eigen::Matrix<float, 4,4, Eigen::DontAlign> invtrans;
300// ### OLD STRUCT ###
301// Coordinate transformation descriptor
302// typedef struct _fiffCoordTransRec {
303// fiff_int_t from; /< Source coordinate system. /
304// fiff_int_t to; /< Destination coordinate system. /
305// fiff_float_t rot[3][3]; /< The forward transform (rotation part) /
306// fiff_float_t move[3]; /< The forward transform (translation part) /
307// fiff_float_t invrot[3][3]; /< The inverse transform (rotation part) /
308// fiff_float_t invmove[3]; /< The inverse transform (translation part) /
309// } *fiffCoordTrans, fiffCoordTransRec; /< Coordinate transformation descriptor /
310
311// typedef fiffCoordTransRec fiff_coord_trans_t;
312};
313
314//=============================================================================================================
315// INLINE DEFINITIONS
316//=============================================================================================================
317
319{
320 return 104;
321}
322
323//=============================================================================================================
324
325inline bool operator== (const FiffCoordTrans &a, const FiffCoordTrans &b)
326{
327 return (a.from == b.from &&
328 a.to == b.to &&
329 a.trans.isApprox(b.trans, 0.0001f) &&
330 a.invtrans.isApprox(b.invtrans, 0.0001f));
331}
332} // NAMESPACE
333
334#ifndef metatype_fiffcoordtrans
335#define metatype_fiffcoordtrans
337#endif
338
339#ifndef metatype_fiffcoordtrans
340#define metatype_fiffcoordtrans
342#endif
343
344#endif // FIFF_COORD_TRANS_H
Fiff library export/import macros.
#define FIFFSHARED_EXPORT
Definition fiff_global.h:56
FiffCoordTransOld class declaration.
Definitions for describing the objects in a FIFF file.
Q_DECLARE_METATYPE(FIFFLIB::FiffCoordTrans)
Coordinate transformation descriptor.
Coordinate transformation description.
QSharedPointer< FiffCoordTrans > SPtr
static FiffCoordTrans make(int from, int to, const Eigen::Matrix3f &rot, const Eigen::VectorXf &move)
static FiffCoordTrans make(int from, int to, const Eigen::Matrix4f &matTrans, bool bStandard=false)
QSharedPointer< const FiffCoordTrans > ConstSPtr
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > invtrans
FIFF File I/O routines.