CGAL 6.3-dev - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits > Class Template Reference

#include <CGAL/HDVF/Mesh_object_io.h>

Inherited by CGAL::Homological_discrete_vector_field::Icosphere_object_io< Traits >, CGAL::Homological_discrete_vector_field::Surface_mesh_io< TriangleMesh, Traits >, CGAL::Homological_discrete_vector_field::Tet_object_io< Traits >, and CGAL::Homological_discrete_vector_field::Triangulation_3_io< Triangulation3, Traits >.

Definition

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

The class Mesh_object_io is an intermediate IO class, used to load and create arbitrary collections of simplices, that is collections without a priori structures, unlike simplicial complexes (closed under the face operation), proper meshes (including only cells of maximal dimension) or manifolds.

These collections are then used as input to produce Abstract_simplicial_chain_complex.

The collection of simplices stored in a Mesh_object_io are simply considered as maximal simplices when generating an associated Abstract_simplicial_chain_complex.

Simplices are identified by an index together with their dimension.

Template Parameters
Traitsa geometric traits class model of the HDVFTraits concept.

Public Types

typedef Traits::Point Point
 Underlying point type.
typedef Traits::Bbox Bbox
 Bounding box type.

Public Member Functions

int dimension () const
 Returns the dimension of the Mesh_object_io.
 Mesh_object_io (int d=0)
 Default constructor.
 Mesh_object_io (int d, const std::vector< Point > &vnodes, const std::vector< Io_cell_type > &vcells, bool sort_data=false)
 Constructor from a vector of points (vertex coordinates) and a vector of simplices.
 Mesh_object_io (const Point &BBmin, const Point &BBmax)
 Build a Mesh_object_io representing the bounding box of diagonal BB_min - BBmax.
const std::vector< Point > & nodes () const
 Returns the vector of nodes (ie vertices coordinates).
int number_of_nodes () const
 Returns the number of nodes (ie vertices).
const std::vector< Io_cell_type > & cells () const
 Returns the vector of cells.
void set_node (size_t i, const Point &P)
 Updates the coordinates of the ith node (ie vertex).
void push_back (const Mesh_object_io &mesh)
 Adds a Mesh_object_io to the current Mesh_object_io.
size_t add_node (const Point &v)
 Adds a node (vertex).
void clear_cells ()
 Removes all cells (simplices).
void clear_nodes ()
 Removes all nodes (vertices).
void clear ()
 Removes all nodes and cells.
void add_cell (Io_cell_type &c, bool sort_indices=false)
 Adds a cells (simplex).
size_t cells_of_dim (int q) const
 Number of cells (simplices) of dimension q.
bool read_off (const std::string &filename)
 Imports a mesh stored in an OFF file.
bool write_off (const std::string &filename) const
 Exports triangles (simplices of dimension 2) of the current object to an OFF file.
void write_vtk (const std::string &filename)
 Exports cells of the current object to an VTK file.
bool write_simp (const std::string &filename)
 Exports cells to a SIMP file.
bool read_simp (const std::string &filename)
 Imports cells from a SIMP file.
bool read_nodes_file (const std::string &filename)
 Reads nodes from a file in tetgen NODES format.
std::ostream & print_infos (std::ostream &out_stream=std::cout) const
 Prints compact informations on the object into a stream.
Point centroid () const
 Returns the centroid of the object's nodes.
double radius (const Point &bary) const
 Returns maximum distance from a point bary to the object's nodes.
Bbox bbox (double ratio=1.) const
 Returns the bounding box of the object's nodes.

Friends

std::ostream & operator<< (std::ostream &out_stream, const Mesh_object_io &mesh_io)
 Prints compact informations on the object into a stream.

(Note that these are not member symbols.)

typedef std::vector< size_t > Io_cell_type
 Type of cells of Mesh_object_io.
typedef std::vector< Io_cell_type > Io_cells_type
 Type respresenting sets of cells.
template<typename Traits>
size_t read_nodes (const std::string &filename, std::vector< typename Traits::Point > *nodes, bool adapt=false)
 Loads vertices coordinates from a .nodes file.

Constructor & Destructor Documentation

◆ Mesh_object_io() [1/3]

template<typename Traits>
CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::Mesh_object_io ( int d = 0)

Default constructor.

Create an empty Mesh_object_io of dimension d.

Parameters
dDimension of the Mesh_object_io (the default is 0).

◆ Mesh_object_io() [2/3]

template<typename Traits>
CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::Mesh_object_io ( int d,
const std::vector< Point > & vnodes,
const std::vector< Io_cell_type > & vcells,
bool sort_data = false )

Constructor from a vector of points (vertex coordinates) and a vector of simplices.

Simplices are described by the list of vertex indices.

Parameters
dThe dimension d can be positive or negative:
  • if positive: the set of simplicial cells loaded is a "mesh" and all cells have the same dimension
  • if negative: the set of simplicial cells loaded have various dimensions and d must be the maximum of these dimensions.

Vertices are described by their index; this index must be unique (vertices with similar underlying points and different vertex indices will be considered as different).

Parameters
vnodesVector of vertex coordinates.
vcellsVector of cells (each cell is described by a vector of vertices index)
sort_dataIf true the vectors of vertices index are sorted, if false they are assumed to be sorted (faster).
Exceptions
Traits_dimension_mismatchIf the dimension `d` provided does not match the dimension of the Traits, raises a `std::runtime_error`.
Inconsistent_dimensionIf the dimension of one of the cell does not match the dimension of the Traits, raises a `std::runtime_error`.

◆ Mesh_object_io() [3/3]

template<typename Traits>
CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::Mesh_object_io ( const Point & BBmin,
const Point & BBmax )

Build a Mesh_object_io representing the bounding box of diagonal BB_min - BBmax.

Vertices and simplices are enumerated as indicated in the picture below:

Parameters
BBmincoordinates of the lower corner of the bounding box.
BBmaxcoordinates of the higher corner of the bounding box.

Member Function Documentation

◆ add_cell()

template<typename Traits>
void CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::add_cell ( Io_cell_type & c,
bool sort_indices = false )

Adds a cells (simplex).

Parameters
cCell (simplex) added (vector of indices).
sort_indicesIf true the vector of indices is sorted, if false it is assumed to be sorted (faster).

◆ add_node()

template<typename Traits>
size_t CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::add_node ( const Point & v)

Adds a node (vertex).

Returns
The index of the added node.

◆ dimension()

template<typename Traits>
int CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::dimension ( ) const

Returns the dimension of the Mesh_object_io.

The dimension can be positive or negative:

  • if positive: the set of simplicial cells loaded is a "mesh" and all cells have the same dimension which is the dimension of the Mesh_object_io
  • if negative: the set of simplicial cells loaded have various dimensions and the dimension of the Mesh_object_io is the maximum of these dimensions.

◆ print_infos()

template<typename Traits>
std::ostream & CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::print_infos ( std::ostream & out_stream = std::cout) const

Prints compact informations on the object into a stream.

Prints the dimension, number of nodes, number of cells and number or cells by dimension.

◆ push_back()

template<typename Traits>
void CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::push_back ( const Mesh_object_io< Traits > & mesh)

Adds a Mesh_object_io to the current Mesh_object_io.

In order to concatenate objects (ie. compute their disjoint union), the function updates indices of the simplices of mesh (such that the numbering of mesh vertices starts after vertices of this).

Parameters
meshSet of simplices to concatenate to the current mesh.

◆ read_nodes_file()

template<typename Traits>
bool CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::read_nodes_file ( const std::string & filename)

Reads nodes from a file in tetgen NODES format.

See user manual for details on the file format.

◆ write_vtk()

template<typename Traits>
void CGAL::Homological_discrete_vector_field::Mesh_object_io< Traits >::write_vtk ( const std::string & filename)

Exports cells of the current object to an VTK file.

Exceptions
Invalid_dimensionIf the dimension is larger than 3, raises a `std::invalid_argument` error.

◆ Io_cell_type

template<typename Traits>
typedef std::vector<size_t> Io_cell_type
related

Type of cells of Mesh_object_io.

Sorted vector of the vertex indices.

◆ operator<<

template<typename Traits>
std::ostream & operator<< ( std::ostream & out_stream,
const Mesh_object_io< Traits > & mesh_io )
friend

Prints compact informations on the object into a stream.

Prints the dimension, number of nodes, number of cells and number or cells by dimension.

◆ read_nodes()

template<typename Traits>
size_t read_nodes ( const std::string & filename,
std::vector< typename Traits::Point > * nodes,
bool adapt = false )
related

Loads vertices coordinates from a .nodes file.

Reads nodes (ie. vertices coordinates) from a .nodes file (tetgen format, see user manual for details) .

Parameters
filenameName of the input file.
nodesPointer to a vector of points into which nodes are outputed.
adaptIf fill is false, nodes must have the same dimension as the traits Point, if true, nodes dimension can be lower (and missing coordinates are filled with zeros) or higher (and coordinates are truncated to the traits dimension).
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 nodes do not match.