MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / write

Method write

io/src/ifs_io.cpp:332–414  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

330
331///////////////////////////////////////////////////////////////////////////////////////////////
332int
333pcl::IFSWriter::write (const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const std::string& cloud_name)
334{
335 if (cloud.data.empty ())
336 {
337 PCL_ERROR ("[pcl::IFSWriter::write] Input point cloud has no data!\n");
338 return (-1);
339 }
340
341 if (!cloud.is_dense)
342 {
343 PCL_ERROR ("[pcl::IFSWriter::write] Non dense cloud are not allowed by IFS format!\n");
344 return (-1);
345 }
346
347 const std::string magic = "IFS";
348 const float version = 1.0f;
349 const std::string vertices = "VERTICES";
350 std::vector<char> header (sizeof (std::uint32_t) + magic.size () + 1 +
351 sizeof (float) +
352 sizeof (std::uint32_t) + cloud_name.size () + 1 +
353 sizeof (std::uint32_t) + vertices.size () + 1 +
354 sizeof (std::uint32_t));
355 char* addr = header.data();
356 const std::uint32_t magic_size = static_cast<std::uint32_t> (magic.size ()) + 1;
357 memcpy (addr, &magic_size, sizeof (std::uint32_t));
358 addr+= sizeof (std::uint32_t);
359 memcpy (addr, magic.c_str (), magic_size * sizeof (char));
360 addr+= magic_size * sizeof (char);
361 memcpy (addr, &version, sizeof (float));
362 addr+= sizeof (float);
363 const std::uint32_t cloud_name_size = static_cast<std::uint32_t> (cloud_name.size ()) + 1;
364 memcpy (addr, &cloud_name_size, sizeof (std::uint32_t));
365 addr+= sizeof (std::uint32_t);
366 memcpy (addr, cloud_name.c_str (), cloud_name_size * sizeof (char));
367 addr+= cloud_name_size * sizeof (char);
368 const std::uint32_t vertices_size = static_cast<std::uint32_t> (vertices.size ()) + 1;
369 memcpy (addr, &vertices_size, sizeof (std::uint32_t));
370 addr+= sizeof (std::uint32_t);
371 memcpy (addr, vertices.c_str (), vertices_size * sizeof (char));
372 addr+= vertices_size * sizeof (char);
373 const std::uint32_t nb_vertices = cloud.data.size () / cloud.point_step;
374 memcpy (addr, &nb_vertices, sizeof (std::uint32_t));
375 /*addr+= sizeof (std::uint32_t);*/
376
377 std::size_t data_idx = header.size ();
378
379 boost::iostreams::mapped_file_sink sink;
380 boost::iostreams::mapped_file_params params;
381 params.path = file_name;
382 params.flags = boost::iostreams::mapped_file_base::readwrite;
383 params.offset = 0;
384 params.new_file_size = data_idx + cloud.data.size ();
385 params.length = data_idx + cloud.data.size ();
386
387 try
388 {
389 sink.open (params);

Callers 15

saveCloudFunction · 0.45
writeToDiskMethod · 0.45
saveCloudFunction · 0.45
saveCloudFunction · 0.45
saveCloudFunction · 0.45
saveCloudFunction · 0.45
serializeFunction · 0.45
writeFunction · 0.45
serializeMethod · 0.45

Calls 5

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by 3

TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36