Main MRPT website > C++ reference for MRPT 1.9.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 // This must be added to any CSerializable class implementation file.
21 
22 /*---------------------------------------------------------------
23  writeToStream
24  ---------------------------------------------------------------*/
25 void CMatrixB::writeToStream(mrpt::utils::CStream& out, int* out_Version) const
26 {
27  if (out_Version)
28  *out_Version = 0;
29  else
30  {
31  out << (uint32_t)sizeof(m_Val[0][0]);
32 
33  // First, write the number of rows and columns:
34  out << (uint32_t)m_Rows << (uint32_t)m_Cols;
35 
36  if (m_Rows > 0 && m_Cols > 0)
37  for (unsigned int i = 0; i < m_Rows; i++)
38  out.WriteBuffer(m_Val[i], sizeof(m_Val[0][0]) * m_Cols);
39  }
40 }
41 
42 /*---------------------------------------------------------------
43  readFromStream
44  ---------------------------------------------------------------*/
46 {
47  switch (version)
48  {
49  case 0:
50  {
51  uint32_t size_bool;
52  in >> size_bool;
53  if (size_bool != sizeof(m_Val[0][0]))
55  "Error: size of 'bool' is different in serialized data!")
56 
57  uint32_t nRows, nCols;
58 
59  // First, write the number of rows and columns:
60  in >> nRows >> nCols;
61 
62  setSize(nRows, nCols);
63 
64  if (nRows > 0 && nCols > 0)
65  for (unsigned int i = 0; i < nRows; i++)
66  in.ReadBuffer(m_Val[i], sizeof(m_Val[0][0]) * m_Cols);
67  }
68  break;
69  default:
71  };
72 }
73 
74 // Implementation of CMatrixBool
75 CMatrixBool::CMatrixBool(size_t row, size_t col)
76  : CMatrixTemplate<bool>(row, col)
77 {
78 }
80  : CMatrixTemplate<bool>(m)
81 {
82 }
84 {
86  return *this;
87 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Declares a matrix of booleans (non serializable).
CMatrixBool & operator=(const CMatrixTemplate< bool > &m)
Assignment operator for float matrixes.
Definition: CMatrixB.cpp:83
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define THROW_EXCEPTION(msg)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CMatrixB.cpp:45
#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...
CMatrixBool(size_t row=1, size_t col=1)
Constructor.
Definition: CMatrixB.cpp:75
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:3576
GLuint in
Definition: glext.h:7274
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:24
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
CMatrixTemplate & operator=(const CMatrixTemplate &m)
Assignment operator from another matrix.
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019