CGAL 5.5.2 - Surface Mesh
I/O Functions (OFF)

I/O Functions for the Object File Format (OFF).

## Functions

template<typename Point , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool CGAL::IO::read_OFF (std::istream &is, Surface_mesh< Point > &sm, const NamedParameters &np=parameters::default_values())
extracts the surface mesh from an input stream in the Object File Format (OFF) and appends it to the surface mesh sm. More...

template<typename Point , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool CGAL::IO::write_OFF (std::ostream &os, const Surface_mesh< Point > &sm, const NamedParameters &np=parameters::default_values())
writes the surface mesh sm in the output stream, using the Object File Format (OFF). More...

## Function Documentation

template<typename Point , typename NamedParameters = CGAL::parameters::Default_named_parameters>
 bool CGAL::IO::read_OFF ( std::istream & is, Surface_mesh< Point > & sm, const NamedParameters & np = parameters::default_values() )

#include <CGAL/Surface_mesh/IO/OFF.h>

extracts the surface mesh from an input stream in the Object File Format (OFF) and appends it to the surface mesh sm.

This function reads points, as well as vertex normals, vertex and face colors, and texture vertex coordinates if those attributes are available in the input. These last four attributes are stored in internal property maps of sm named "v:normal", "v:color", "f:color", and "v:texcoord", respectively, which will be created if they do not already exist. If property maps are passed through named parameters (see below), then they are used instead of the internal ones.

Ignores comment lines which start with a hash, and lines with whitespace.

Attention
The graph sm is not cleared, and the data from the stream is added.
Template Parameters
 Point The type of the point property of a vertex. There is no requirement on P, besides being default constructible and assignable. In typical use cases it will be a 2D or 3D point type. NamedParameters a sequence of Named Parameters
Parameters
 is the input stream sm the surface mesh to be constructed np optional Named Parameters described below
Optional Named Parameters
 a property map associating points to the vertices of sm Type: a class model of WritablePropertyMap with Surface_mesh::Vertex_index as key type and Point as value type Default: boost::get(CGAL::vertex_point, g) a property map associating normals to the vertices of sm Type: a class model of WritablePropertyMap with Surface_mesh::Vertex_index as key type and a 3D vector type issued from the same kernel as Point as value type Default: If this parameter is unsused, vertex normals (if they exist) will be written in an internal property map called v:normal. a property map associating colors to the vertices of sm Type: a class model of WritablePropertyMap with Surface_mesh::Vertex_index as key type and CGAL::IO::Color as value type Default: If this parameter is unsused, vertex colors (if they exist) will be written in an internal property map called v:color. a property map associating textures to the vertices of sm Type: a class model of WritablePropertyMap with Surface_mesh::Vertex_index as key type and a 2D vector type issued from the same kernel as Point as value type Default: If this parameter is unsused, vertex textures (if they exist) will be written in an internal property map called v:texcoords. a property map associating colors to the faces of sm Type: a class model of WritablePropertyMap with Surface_mesh::Face_index as key type and CGAL::IO::Color as value type Default: If this parameter is unsused, face colors (if they exist) will be written in an internal property map called f:color.
Precondition
The data in the stream must represent a two-manifold. If this is not the case the failbit of is is set and the mesh cleared.

## ◆ write_OFF()

template<typename Point , typename NamedParameters = CGAL::parameters::Default_named_parameters>
 bool CGAL::IO::write_OFF ( std::ostream & os, const Surface_mesh< Point > & sm, const NamedParameters & np = parameters::default_values() )

#include <CGAL/Surface_mesh/IO/OFF.h>

writes the surface mesh sm in the output stream, using the Object File Format (OFF).

This overload of write_OFF(std::ostream&, const Graph&) will also output the following property maps internal to the surface mesh, if they exist and if they are not already present in the named parameters:

• vertex normals (property map named "v:normal" in the surface mesh)
• vertex colors (property map named "v:color" in the surface mesh)
• vertex textures (property map named "v:texcoord" in the surface mesh)
• face colors (property map named "f:color" in the surface mesh)
Template Parameters
 Point The type of the point property of a vertex. There is no requirement on P, besides being default constructible and assignable. In typical use cases it will be a 2D or 3D point type. NamedParameters a sequence of Named Parameters
Parameters
 os the output stream sm the surface mesh to be output np optional Named Parameters described below
Optional Named Parameters
 a property map associating points to the vertices of sm Type: a class model of ReadablePropertyMap with Surface_mesh::Vertex_index as key type and Point as value type Default: boost::get(CGAL::vertex_point, g) a property map associating normals to the vertices of sm Type: a class model of ReadablePropertyMap with Surface_mesh::Vertex_index as key type and a 3D vector type issued from the same kernel as Point as value type Default: vertex normals will be output using the internal property map, if it exists. a property map associating colors to the vertices of sm Type: a class model of ReadablePropertyMap with Surface_mesh::Vertex_index as key type and CGAL::IO::Color as value type Default: vertex colors will be output using the internal property map, if it exists. a property map associating textures to the vertices of sm Type: a class model of ReadablePropertyMap with Surface_mesh::Vertex_index as key type and a 2D point type issued from the same kernel as Point as value type Default: vertex textures will be output using the internal property map, if it exists. a property map associating colors to the faces of sm Type: a class model of ReadablePropertyMap with Surface_mesh::Face_index as key type and CGAL::IO::Color as value type Default: face colors will be output using the internal property map, if it exists. a parameter used to set the precision (i.e. how many digits are generated) of the output stream Type: int Default: the precision of the stream os
Returns
true if writing was successful, false otherwise.