コード例 #1
0
ファイル: CHolonomicND.cpp プロジェクト: mangi020/mrpt
/*---------------------------------------------------------------
					readFromStream
  ---------------------------------------------------------------*/
void  CLogFileRecord_ND::readFromStream(mrpt::utils::CStream &in,int version)
{
	switch(version)
	{
	case 0:
		{
			int32_t	n;

			in >> n;
			gaps_ini.resize(n);
			gaps_end.resize(n);
			in.ReadBuffer( &(*gaps_ini.begin()), sizeof(gaps_ini[0]) * n );
			in.ReadBuffer( &(*gaps_end.begin()), sizeof(gaps_end[0]) * n );

			in >> n;
			gaps_eval.resize(n);
			in.ReadBuffer( &(*gaps_eval.begin()), sizeof(gaps_eval[0]) * n );

			in >> selectedSector >> evaluation >> riskEvaluation >> n;

			situation = (CHolonomicND::TSituations) n;
		} break;
	case 1:
		{
			uint32_t    n;
			in >> gaps_ini >> gaps_end >> gaps_eval;
			in >> selectedSector >> evaluation >> riskEvaluation >> n;
			situation  = (CHolonomicND::TSituations) n;
		} break;
	default:
		MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version)

	};
}
コード例 #2
0
ファイル: CMatrixB.cpp プロジェクト: 3660628/mrpt
/*---------------------------------------------------------------
						readFromStream
 ---------------------------------------------------------------*/
void  CMatrixB::readFromStream(mrpt::utils::CStream &in, int version)
{
	switch(version)
	{
	case 0:
		{
			uint32_t size_bool;
			in >> size_bool;
			if ( size_bool != sizeof(m_Val[0][0]) )
				THROW_EXCEPTION("Error: size of 'bool' is different in serialized data!")
	
			uint32_t nRows,nCols;

			// First, write the number of rows and columns:
			in >> nRows >> nCols;

			setSize(nRows,nCols);

			if (nRows>0 && nCols>0)
				for (unsigned int i=0;i<nRows;i++)
					in.ReadBuffer(m_Val[i],sizeof(m_Val[0][0])*m_Cols);
		} break;
	default:
		MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version)

	};
}
コード例 #3
0
void CRandomFieldGridMap3D::readFromStream(mrpt::utils::CStream &in, int version)
{
	switch (version)
	{
	case 0:
	{
		dyngridcommon_readFromStream(in);

		// To assure compatibility: The size of each cell:
		uint32_t n;
		in >> n;

		ASSERT_EQUAL_(n, static_cast<uint32_t>(sizeof(TRandomFieldVoxel)));
		// Load the map contents:
		in >> n;
		m_map.resize(n);

		// Read the note in writeToStream()
#if MRPT_IS_BIG_ENDIAN
		for (uint32_t i = 0; i<n; i++)
			in >> m_map[i].mean_value >> m_map[i].stddev_value;
#else
		// Little endian: just read all at once:
		in.ReadBuffer(&m_map[0], sizeof(m_map[0])*m_map.size());
#endif
		in >> insertionOptions.GMRF_lambdaPrior
		   >> insertionOptions.GMRF_skip_variance;

	} break;
	default:
		MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version);
	};

}
コード例 #4
0
ファイル: CMemoryChunk.cpp プロジェクト: Insomnia-/mrpt
/*---------------------------------------------------------------
						readFromStream
 ---------------------------------------------------------------*/
void  CMemoryChunk::readFromStream(mrpt::utils::CStream &in, int version)
{
	switch(version)
	{
	case 0:
		{
			uint64_t   N;
			in >> N;
			resize(N);

			m_bytesWritten = N;
			m_position     = 0;
			if (N)
				in.ReadBuffer( m_memory.get(), N );

		} break;
	default:
		MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version)

	};
}
コード例 #5
0
ファイル: CRenderizable.cpp プロジェクト: Insomnia-/mrpt
void  CRenderizable::readFromStreamRender(mrpt::utils::CStream &in)
{
	// MRPT 0.9.5 svn 2774 (Dec 14th 2011):
	// See comments in CRenderizable::writeToStreamRender() for the employed serialization mechanism.
	//

	// Read signature:
	union {
		uint8_t  magic_signature[2+2];  // (the extra 4 bytes will be used only for the old format)
		uint32_t magic_signature_uint32;  // So we can interpret the 4bytes above as a 32bit number cleanly.
	};

	in >> magic_signature[0] >> magic_signature[1];

	const bool is_new_format = (magic_signature[0]==0xFF) && ((magic_signature[1]&0x80)!=0);

	if (is_new_format)
	{
		// NEW FORMAT:
		uint8_t serialization_version = (magic_signature[1] & 0x1F);
		const bool all_scales_unity = ((magic_signature[1]&0x40)!=0);
		const bool all_scales_equal_but_not_unity = ((magic_signature[1]&0x20)!=0);

		switch(serialization_version)
		{
		case 0:
			{
			// "m_name"
			uint16_t nameLen;
			in >> nameLen;
			m_name.resize(nameLen);
			if (nameLen) in.ReadBuffer((void*)(&m_name[0]),m_name.size());

			// Color, as u8:
			in >> m_color.R >> m_color.G >> m_color.B >> m_color.A;

			// the rest of fields:
			float x,y,z,yaw,pitch,roll;
			in >> x >> y >> z >> yaw >> pitch >> roll;
			m_pose.x(x); m_pose.y(y); m_pose.z(z);
			m_pose.setYawPitchRoll( yaw,pitch,roll );

			if (all_scales_unity)
					m_scale_x=m_scale_y=m_scale_z=1;
			else {
				if (all_scales_equal_but_not_unity)
				{
					in >> m_scale_x;
					m_scale_y = m_scale_z = m_scale_x;
				}
				else in >> m_scale_x >> m_scale_y >> m_scale_z;
			}

			in >> m_show_name
			   >> m_visible;
			}
			break;
		default:
			THROW_EXCEPTION_CUSTOM_MSG1("Can't parse CRenderizable standard data field: corrupt data stream or format in a newer MRPT format? (serialization version=%u)",static_cast<unsigned int>(serialization_version))
		};
	}
	else
	{