\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.3 - Surface Mesh
Surface Mesh Reference

Surface_mesh_teaser.png
Mario Botsch, Daniel Sieger, Philipp Moeller, and Andreas Fabri
The surface mesh class provided by this package is an implementation of the halfedge data structure allowing to represent polyhedral surfaces. It is an alternative to the packages Halfedge Data Structures and 3D Polyhedral Surface. The main differences are that it is indexed based and not pointer based, and that the mechanism for adding information to vertices, halfedges, edges, and faces is much simpler and can be used at runtime and not at compile time.
Introduced in: CGAL 4.6
BibTeX: cgal:bsmf-sm-20b
License: GPL

Classified Reference Pages

Classes

Draw a Surface Mesh

Modules

 Draw a Surface Mesh
 

Classes

class  CGAL::Surface_mesh< P >
 This class is a data structure that can be used as halfedge data structure or polyhedral surface. It is an alternative to the classes HalfedgeDS and Polyhedron_3 defined in the packages Halfedge Data Structures and 3D Polyhedral Surface. The main difference is that it is indexed based and not pointer based, and that the mechanism for adding information to vertices, halfedges, edges, and faces is much simpler and done at runtime and not at compile time. When elements are removed, they are only marked as removed, and a garbage collection function must be called to really remove them. More...
 

Functions

template<typename P >
bool CGAL::write_off (std::ostream &os, const Surface_mesh< P > &sm)
 
template<typename P >
bool CGAL::read_off (std::istream &is, Surface_mesh< P > &sm)
 
template<typename P >
Surface_mesh< P > & operator+= (Surface_mesh< P > &sm, const Surface_mesh< P > &other)
 
template<typename P , typename NamedParameters >
bool write_off (std::ostream &os, const Surface_mesh< P > &sm, const NamedParameters &np)
 
template<typename P >
std::ostream & operator<< (std::ostream &os, const Surface_mesh< P > &sm)
 
template<typename P >
bool write_ply (std::ostream &os, const Surface_mesh< P > &sm, const std::string &comments=std::string())
 
template<typename P , typename NamedParameters >
bool read_off (std::istream &is, Surface_mesh< P > &sm, NamedParameters np)
 
template<typename P >
bool read_ply (std::istream &is, Surface_mesh< P > &sm, std::string &comments)
 Extracts the surface mesh from an input stream in Ascii or Binary PLY format and appends it to the surface mesh sm. More...
 
template<typename P >
std::istream & operator>> (std::istream &is, Surface_mesh< P > &sm)
 

Function Documentation

◆ operator+=()

template<typename P >
Surface_mesh< P > & operator+= ( Surface_mesh< P > &  sm,
const Surface_mesh< P > &  other 
)
related

Inserts other into sm. Shifts the indices of vertices of other by sm.number_of_vertices() + sm.number_of_removed_vertices() and analoguously for halfedges, edges, and faces. Copies entries of all property maps which have the same name in sm and other. that is, property maps which are only in other are ignored. Also copies elements which are marked as removed, and concatenates the freelists of sm and other.

◆ operator
template<typename P >
std::ostream & operator<< ( std::ostream &  os,
const Surface_mesh< P > &  sm 
)
related

◆ operator>>()

template<typename P >
std::istream & operator>> ( std::istream &  is,
Surface_mesh< P > &  sm 
)
related

This operator calls read_off(std::istream& is, CGAL::Surface_mesh& sm).

Attention
Up to CGAL 4.10 this operator called sm.clear().

◆ read_off()

template<typename P , typename NamedParameters >
bool read_off ( std::istream &  is,
Surface_mesh< P > &  sm,
NamedParameters  np 
)
related

Extracts the surface mesh from an input stream in Ascii OFF, COFF, NOFF, CNOFF format and appends it to the surface mesh sm. The operator reads the point property as well as "v:normal", "v:color", and "f:color". Vertex texture coordinates are ignored. If an alternative vertex_point map is given through np, then it will be used instead of the default one.

Precondition
operator>>(std::istream&,const P&) must be defined.
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.

◆ read_ply()

template<typename P >
bool read_ply ( std::istream &  is,
Surface_mesh< P > &  sm,
std::string &  comments 
)
related

Extracts the surface mesh from an input stream in Ascii or Binary PLY format and appends it to the surface mesh sm.

  • the operator reads the vertex point property and the face vertex_index (or vertex_indices) property;
  • if three PLY properties nx, ny and nz with type float or double are found for vertices, a "v:normal" vertex property map is added;
  • if three PLY properties red, green and blue with type uchar are found for vertices, a "v:color" vertex property map is added;
  • if three PLY properties red, green and blue with type uchar are found for faces, a "f:color" face property map is added;
  • if any other PLY property is found, a "[s]:[name]" property map is added, where [s] is v for vertex and f for face, and [name] is the name of the PLY property.

The comments parameter can be omitted. If provided, it will be used to store the potential comments found in the PLY header. Each line starting by "comment " in the header is appended to the comments string (without the "comment " word).

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 P , typename NamedParameters >
bool write_off ( std::ostream &  os,
const Surface_mesh< P > &  sm,
const NamedParameters &  np 
)
related

Inserts the surface mesh in an output stream in Ascii OFF format. Only the point property is inserted in the stream. If an alternative vertex_point map is given through np, then it will be used instead of the default one.

Precondition
operator<<(std::ostream&,const P&) must be defined.
Note
The precision() of the output stream might not be sufficient depending on the data to be written.

◆ write_ply()

template<typename P >
bool write_ply ( std::ostream &  os,
const Surface_mesh< P > &  sm,
const std::string &  comments = std::string() 
)
related

Inserts the surface mesh in an output stream in PLY format. If found, "v:normal", "v:color" and "f:color" are inserted in the stream. All other vertex and face properties with simple types are inserted in the stream. Edges are only inserted in the stream if they have at least one property with simple type: if they do, all edge properties with simple types are inserted in the stream. The halfedges follow the same behavior.

If provided, the comments string is included line by line in the header of the PLY stream (each line will be precedeed by "comment ").