CGAL 6.0 - Surface Mesh
Loading...
Searching...
No Matches

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.
 
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).
 

Function Documentation

◆ read_OFF()

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
PointThe 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.
NamedParametersa sequence of Named Parameters
Parameters
isthe input stream
smthe surface mesh to be constructed
npoptional Named Parameters described below
Optional Named Parameters

  • 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 unused, 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 unused, 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 unused, 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 unused, 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
PointThe 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.
NamedParametersa sequence of Named Parameters
Parameters
osthe output stream
smthe surface mesh to be output
npoptional Named Parameters described below
Optional Named Parameters

  • 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 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 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.