CGAL 5.5.4 - CGAL and the Boost Graph Library

Methods to read and write graphs.

Modules

 STL I/O Functions
 I/O Functions for the STereoLithography (STL) File Format.
 
 PLY I/O Functions
 I/O Functions for the Polygon File Format (PLY).
 
 OBJ I/O Functions
 I/O Functions for the Wavefront Advanced Visualizer Object Format (OBJ).
 
 OFF I/O Functions
 I/O Functions for the Object File Format (OFF).
 
 VTP I/O Functions
 I/O Functions for the VTK (VTU / VTP) File Formats.
 
 GOCAD I/O Functions
 I/O Functions for the GOCAD (TS) File Format.
 
 WRL I/O Functions
 I/O Functions for the Virtual Reality Modeling Language (VRML) File Format.
 
 3MF I/O Functions
 I/O Functions for the 3D Manufacturing Format (3MF).
 
 I/O Functions (Deprecated)
 

Functions

template<class Graph , typename NamedParameters = parameters::Default_named_parameters>
bool CGAL::IO::read_polygon_mesh (const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
 reads a polygon mesh from a file. More...
 
template<class Graph , typename NamedParameters = parameters::Default_named_parameters>
bool CGAL::IO::write_polygon_mesh (const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
 writes a polygon mesh in a file. More...
 

Function Documentation

◆ read_polygon_mesh()

template<class Graph , typename NamedParameters = parameters::Default_named_parameters>
bool CGAL::IO::read_polygon_mesh ( const std::string &  fname,
Graph &  g,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/boost/graph/IO/polygon_mesh_io.h>

reads a polygon mesh from a file.

Supported file formats are the following:

The format is detected from the filename extension (letter case is not important).

The data is expected to represent a 2-manifold (possibly with borders).

Template Parameters
Grapha model of MutableFaceGraph
NamedParametersa sequence of Named Parameters
Parameters
fnamethe name of the file
gthe mesh
npoptional Named Parameters described below
Optional Named Parameters
  • a property map associating points to the vertices of g
  • Type: a class model of WritablePropertyMap with boost::graph_traits<Graph>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, g)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in Graph.

  • whether extra information is printed when an incident occurs during reading
  • Type: Boolean
  • Default: false

Other named parameters may be used according to the file extension, see I/O Functions for an exhaustive list.

Returns
true if reading was successful, false otherwise.
See also
CGAL::Polygon_mesh_processing::IO::read_polygon_mesh() if the data is not 2-manifold

◆ write_polygon_mesh()

template<class Graph , typename NamedParameters = parameters::Default_named_parameters>
bool CGAL::IO::write_polygon_mesh ( const std::string &  fname,
Graph &  g,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/boost/graph/IO/polygon_mesh_io.h>

writes a polygon mesh in a file.

Supported file formats are the following:

The format is detected from the filename extension (letter case is not important).

Template Parameters
Grapha model of FaceListGraph and HalfedgeListGraph
NamedParametersa sequence of Named Parameters
Parameters
fnamethe name of the file
gthe mesh to be output
npoptional Named Parameters described below
Optional Named Parameters
  • a property map associating points to the vertices of g
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<Graph>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, g)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in Graph.

  • a parameter used to set the precision (i.e. how many digits are generated) of the output stream
  • Type: int
  • Default: 6
  • Extra: This parameter is only meaningful while using ASCII encoding.

  • whether extra information is printed when an incident occurs during reading
  • Type: Boolean
  • Default: false

Other named parameters may be used according to the file extension, see I/O Functions for an exhaustive list.

Returns
true if writing was successful, false otherwise.
Examples:
BGL_surface_mesh/surface_mesh_partition.cpp.