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

I/O Functions for the Polygon File Format (PLY).

Functions

template<typename P >
bool CGAL::IO::read_PLY (std::istream &is, Surface_mesh< P > &sm, std::string &comments, bool verbose=true)
 extracts the surface mesh from an input stream in the Polygon File Format (PLY) and appends it to the surface mesh sm.
 
template<typename P , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool CGAL::IO::write_PLY (std::ostream &os, const Surface_mesh< P > &sm, const std::string &comments, const NamedParameters &np=parameters::default_values())
 inserts the surface mesh in an output stream in the Polygon File Format (PLY).
 

Function Documentation

◆ read_PLY()

template<typename P >
bool CGAL::IO::read_PLY ( std::istream &  is,
Surface_mesh< P > &  sm,
std::string &  comments,
bool  verbose = true 
)

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

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

Attention
To read a binary file, the flag std::ios::binary flag must be set during the creation of the ifstream.
  • 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.
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.
Parameters
isthe input stream
smthe surface mesh to be constructed
commentsa string 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).
verbosewhether extra information is printed when an incident occurs during reading
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.
Returns
true if reading was successful, false otherwise.

◆ write_PLY()

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

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

inserts the surface mesh in an output stream in the Polygon File Format (PLY).

If found, internal property maps with names "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.

Attention
To write to a binary file, the flag std::ios::binary must be set during the creation of the ofstream, and the IO::Mode of the stream must be set to BINARY.
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
commentsa string included line by line in the header of the PLY stream (each line will be precedeed by "comment ")
npoptional Named Parameters described below
Optional Named Parameters
  • 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
  • Extra: This parameter is only meaningful while using ASCII encoding.
Returns
true if writing was successful, false otherwise.