CGAL 6.2 - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
CGAL::Homological_discrete_vector_field::Cub_object_io< Traits > Class Template Reference

#include <CGAL/HDVF/Cub_object_io.h>

Definition

template<typename Traits>
class CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >

The class Cub_object_io is an intermediate IO class, used to load binary volumes and produce cubical complexes.

Public Member Functions

int dimension () const
 Returns the dimension of the complex.
 
int init (int dim, const std::vector< size_t > &size_bb)
 Resets the Cub_object_io and sets the dimension of the cubical complex and its size.
 
const std::vector< size_t > & number_of_cubs_by_dimension () const
 Returns the number of cubs in each dimension.
 
const std::vector< size_t > & N () const
 Returns the size of the bounding box along each dimension.
 
const std::vector< IOCubCellType > & cubs () const
 Returns the vector of cubs.
 
const IOCubCellTypecub (size_t i) const
 Returns the ith cub.
 
size_t number_of_cubs () const
 Returns the total number of cubs.
 
void add_cub (const std::vector< size_t > &coords)
 Adds a cub (given by its Khalimsky coordinates) to the Cub_object_io.
 
 Cub_object_io ()
 Default constructor.
 
 Cub_object_io (int d, const std::vector< IOCubCellType > &vcubs, bool khal=false)
 Constructor from a vector of cells.
 
 Cub_object_io (const Cub_object_io &m)
 
void clear_cubs ()
 Removes all cells of the list.
 
void frame ()
 Adds one empty cell of higher dimension all around the complex.
 
bool read_pgm (const std::string &filename, bool khal=false)
 Imports a PGM file (PGM version 2).
 
bool read_cub (const std::string &filename, bool khalimsky=false)
 Imports a CUB file.
 
void print_infos (size_t level=0) const
 Prints synthetic informations related to the object.
 

Protected Attributes

int _dim = 0
 
std::vector< size_t > _ncubs
 
std::vector< size_t > _N
 
std::vector< IOCubCellType_cubs
 
bool _khalimsky
 Khalimsky or coordinates mode.
 

Constructor & Destructor Documentation

◆ Cub_object_io() [1/2]

template<typename Traits >
CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::Cub_object_io ( )

Default constructor.

Create an empty Cub_object_io of dimension 3.

◆ Cub_object_io() [2/2]

template<typename Traits >
CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::Cub_object_io ( int  d,
const std::vector< IOCubCellType > &  vcubs,
bool  khal = false 
)

Constructor from a vector of cells.

Cells coordinates are given in Khalimsky coordinates if the boolean khal is true, or as integer coordinates of voxels of dimension _dim otherwise.

Member Function Documentation

◆ add_cub()

template<typename Traits >
void CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::add_cub ( const std::vector< size_t > &  coords)

Adds a cub (given by its Khalimsky coordinates) to the Cub_object_io.

Parameters
coordsboolean index of the cub to add.

◆ frame()

template<typename Traits >
void CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::frame ( )

Adds one empty cell of higher dimension all around the complex.

The function enlarges the bounding box with 1 cell of higher dimension on each of its sides. Cubs coordinates are shifted accordingly.

◆ read_cub()

template<typename Traits >
bool CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::read_cub ( const std::string &  filename,
bool  khalimsky = false 
)

Imports a CUB file.

Parameters
filenameName of the CUB file (cells are described in Khalimsky coordinates).
khalimskyIf true, Khalimsky coordinates are loaded in _cubs (for PRIMAL construction of a cubical complex), otherwise, checks that all cells provided are of maximal dimension and load the integer coordinates of voxels in _cubs(for DUAL construction).
Exceptions
File_not_foundIf `filename` does not exist, raise a `std::runtime_error` exception.
Incoherent_dimensionRaises a `std::runtime_error` if dimensions of the `Traits` and of the CUB file do not match.
Invalid_lineIf a line is invalid (does not contain a sequence of coordinates), raises a `std::runtime_error`.
Incoherent_cellA `std::runtime_error` is raised if `khalimsky` is false but a cell of non-maximal dimension is encoutered.

◆ read_pgm()

template<typename Traits >
bool CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::read_pgm ( const std::string &  filename,
bool  khal = false 
)

Imports a PGM file (PGM version 2).

Parameters
filenameName of the PGM file.
khalIf true, Khalimsky coordinates of voxels are stored in _cubs (for PRIMAL construction of a cubical complex), otherwise, integer coordinates of voxels are stored in _cubs(for DUAL construction).
Exceptions
File_not_foundIf `filename` does not exist, raise a `std::runtime_error` exception.
Incoherent_dimensionRaises a `std::runtime_error` if dimensions of the `Traits` and dimension of the PGM file do not match.
Invalid_pgm_versionIf the version stored in the PGM file is not P2, raises a `std::runtime_error`.

Member Data Documentation

◆ _khalimsky

template<typename Traits >
bool CGAL::Homological_discrete_vector_field::Cub_object_io< Traits >::_khalimsky
protected

Khalimsky or coordinates mode.

If true, cubs contains cubical cells encoded with Khalismky coordinates, if false, cubs contains voxel coordinates (i.e. cells of dimension _dim).