Main MRPT website > C++ reference for MRPT 1.5.9
CMatrixB.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrixB.h>
13 #include <mrpt/utils/CStream.h>
14 
15 using namespace mrpt;
16 using namespace mrpt::math;
17 using namespace mrpt::utils;
18 
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 /*---------------------------------------------------------------
24  writeToStream
25  ---------------------------------------------------------------*/
26 void CMatrixB::writeToStream(mrpt::utils::CStream &out, int *out_Version) const
27 {
28  if (out_Version)
29  *out_Version = 0;
30  else
31  {
32  out << (uint32_t)sizeof(m_Val[0][0]);
33 
34  // First, write the number of rows and columns:
35  out << (uint32_t)m_Rows << (uint32_t)m_Cols;
36 
37  if (m_Rows>0 && m_Cols>0)
38  for (unsigned int i=0;i<m_Rows;i++)
39  out.WriteBuffer(m_Val[i],sizeof(m_Val[0][0])*m_Cols);
40  }
41 
42 }
43 
44 /*---------------------------------------------------------------
45  readFromStream
46  ---------------------------------------------------------------*/
48 {
49  switch(version)
50  {
51  case 0:
52  {
53  uint32_t size_bool;
54  in >> size_bool;
55  if ( size_bool != sizeof(m_Val[0][0]) )
56  THROW_EXCEPTION("Error: size of 'bool' is different in serialized data!")
57 
58  uint32_t nRows,nCols;
59 
60  // First, write the number of rows and columns:
61  in >> nRows >> nCols;
62 
63  setSize(nRows,nCols);
64 
65  if (nRows>0 && nCols>0)
66  for (unsigned int i=0;i<nRows;i++)
67  in.ReadBuffer(m_Val[i],sizeof(m_Val[0][0])*m_Cols);
68  } break;
69  default:
71 
72  };
73 }
74 
75 // Implementation of CMatrixBool
76 CMatrixBool::CMatrixBool(size_t row, size_t col) : CMatrixTemplate<bool>(row,col) { }
79 
80 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
Declares a matrix of booleans (non serializable).
CMatrixBool & operator=(const CMatrixTemplate< bool > &m)
Assignment operator for float matrixes.
Definition: CMatrixB.cpp:78
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#define THROW_EXCEPTION(msg)
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
int version
Definition: mrpt_jpeglib.h:898
CMatrixBool(size_t row=1, size_t col=1)
Constructor.
Definition: CMatrixB.cpp:76
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CMatrixB.cpp:47
This template class provides the basic functionality for a general 2D any-size, resizable container o...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLenum GLenum GLvoid * row
Definition: glext.h:3533
GLuint in
Definition: glext.h:6301
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:26
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
CMatrixTemplate & operator=(const CMatrixTemplate &m)
Assignment operator from another matrix.
unsigned __int32 uint32_t
Definition: rptypes.h:49



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020