COGS
Computer Graphics Structures library
cogs::io::DataBlockExporter Class Reference

Enables writing or cogs structures into files. More...

Public Member Functions

 DataBlockExporter ()
 Creates exporter with default DataBlockManager object.
 
 DataBlockExporter (const std::shared_ptr< DataBlockManager > &datablock_manager)
 Creates exporter with custom DataBlockManager object.
 
 DataBlockExporter (const DataBlockExporter &)=delete
 
DataBlockExporter & operator= (const DataBlockExporter &)=delete
 
 DataBlockExporter (const DataBlockExporter &&)=delete
 
DataBlockExporter & operator= (const DataBlockExporter &&)=delete
 
bool OpenFile (const std::string &filename, bool overwrite_existing=false)
 Opens file into which the data blocks can be written. More...
 
void CloseFile ()
 Finishes and closes currently opened file, disabling writers.
 
DataBlockIndex WritePointCloud (const cogs::PointCloud &cloud)
 Adds the object to the export list. More...
 
DataBlockIndex WriteScan (const cogs::Scan &scan)
 Adds the object to the export list. More...
 
DataBlockIndex WriteMesh (const cogs::Mesh &mesh)
 Adds the object to the export list. More...
 

Static Public Attributes

static uint8_t VERSION
 Current exporter version.
 

Detailed Description

Enables writing or cogs structures into files.

Objects and data blocks for export are stored in the export list, and have to be valid until file is saved. Each object can be represented by one or multiple data blocks.

By default, exporter supports only predefined data blocks, but can be altered to support also custom data blocks, when user-defined DataBlockManager is provided during class construction.

For more information about cogs file io system, see page COGS File Format.

Member Function Documentation

◆ OpenFile()

bool cogs::io::DataBlockExporter::OpenFile ( const std::string &  filename,
bool  overwrite_existing = false 
)

Opens file into which the data blocks can be written.

Parameters
filenameName of the file. When extension is not provided, sets to "cogs".
overwrite_existingSet to true is you wish to rewrite the file that already exists.
Returns
True, if the file was successfully opened and can be used for writing.

◆ WriteMesh()

DataBlockIndex cogs::io::DataBlockExporter::WriteMesh ( const cogs::Mesh &  mesh)

Adds the object to the export list.

Parameters
object_refReference to object. Must be valid until saved.
Returns
Index of data block for added object type.

◆ WritePointCloud()

DataBlockIndex cogs::io::DataBlockExporter::WritePointCloud ( const cogs::PointCloud &  cloud)

Adds the object to the export list.

Parameters
object_refReference to object. Must be valid until saved.
Returns
Index of data block for added object type.

◆ WriteScan()

DataBlockIndex cogs::io::DataBlockExporter::WriteScan ( const cogs::Scan &  scan)

Adds the object to the export list.

Parameters
object_refReference to object. Must be valid until saved.
Returns
Index of data block for added object type.