CGAL 6.2 - IO Streams: I/O Functions

CGAL 6.2 - IO Streams

Loading...
Searching...
No Matches
Modules | Functions
I/O Functions
Reference Manual

##

## 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).
| VTK I/O Functions
| I/O Functions for the VTK (VTU / VTP / legacy) File Formats.
| GOCAD I/O Functions
| I/O Functions for the GOCAD (TS) File Format.
| WKT I/O Functions
| I/O Functions for the Well-Known Text (WKT) File Format.
| 3MF I/O Functions
| I/O Functions for the 3D Manufacturing Format (3MF).
| LAS I/O Functions
| I/O Functions for the LAS (Lidar) File Format.
| XYZ I/O Functions
| I/O Functions for the XYZ File Format.

## Functions
template<typename PointRange , typename PolygonRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::read_polygon_soup (const std::string &fname, PointRange &points, PolygonRange &polygons, const NamedParameters &np=parameters::default_values())
| reads a polygon soup from a file.
template<typename PointRange , typename PolygonRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::write_polygon_soup (const std::string &fname, const PointRange &points, const PolygonRange &polygons, const NamedParameters &np=parameters::default_values())
| writes the content of `points` and `polygons` in a file.
template<typename OutputIteratorValueType , typename PointOutputIterator , typename NamedParameters = parameters::Default_named_parameters>
bool | CGAL::IO::read_points (const std::string &fname, PointOutputIterator output, const NamedParameters &np=parameters::default_values())
| reads the point set from an input file.
template<typename PointRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::write_points (const std::string &fname, const PointRange &points, const NamedParameters &np=parameters::default_values(),)
| writes the range of `points` with properties to a file.

## Function Documentation

## ◆ read_points()

template<typename OutputIteratorValueType , typename PointOutputIterator , typename NamedParameters = parameters::Default_named_parameters>

bool CGAL::IO::read_points | ( | const std::string & | fname,
|  | PointOutputIterator | output,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

`#include <CGAL/IO/read_points.h>`

reads the point set from an input file.

Supported file formats are the following:

- Object File Format (OFF) (`.off`)
- Polygon File Format (PLY) (`.ply`)
- LAS (Lidar) File Format (`.las`)
- XYZ File Format (`.xyz`)

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

Template Parameters

  OutputIteratorValueType | type of objects that can be put in `PointOutputIterator`. It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::type`. It can be omitted when the default is fine.
  PointOutputIterator | iterator over output points.
  NamedParameters | a sequence of Named Parameters

Parameters

  fname | the name of the input file.
  output | output iterator over points.
  np | optional sequence of Named Parameters among the ones listed below.

Optional Named Parameters

  a property map associating points to the elements of the point range Type: a model of `WritablePropertyMap` with value type `geom_traits::Point_3` Default: `CGAL::Identity_property_map<geom_traits::Point_3>` |
  a property map associating normals to the elements of the point range Type: a model of `WritablePropertyMap` with value type `geom_traits::Vector_3` Default: If this parameter is omitted, normals in the input stream are ignored. |
  an instance of a geometric traits class Type: a model of `Kernel` Default: a CGAL Kernel deduced from the point type, using `CGAL::Kernel_traits` |
  indicates whether data should be read in binary (`true`) or in ASCII (`false`) Type: Boolean Default: `true` Extra: This parameter is only relevant for `PLY` reading: the `OFF` and `XYZ` formats are always ASCII, and the `LAS` format is always binary. |

Returns
  `true` if reading was successful, `false` otherwise.

## ◆ read_polygon_soup()

template<typename PointRange , typename PolygonRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>

bool CGAL::IO::read_polygon_soup | ( | const std::string & | fname,
|  | PointRange & | points,
|  | PolygonRange & | polygons,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

`#include <CGAL/IO/polygon_soup_io.h>`

reads a polygon soup from a file.

Supported file formats are the following:

- Object File Format (OFF) (`.off`)
- Wavefront Advanced Visualizer Object Format (OBJ) (`.obj`)
- STereoLithography (STL) File Format (`.stl`)
- Polygon File Format (PLY) (`.ply`)
- GOCAD (TS) File Format (`.ts`)
- VTK (VTU / VTP / legacy) File Formats (`.vtp`)

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

Template Parameters

  PointRange | a model of the concept `RandomAccessContainer` whose value type is the point type.
  PolygonRange | a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` whose `value_type` is itself a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` whose `value_type` is an unsigned integer type convertible to `std::size_t`
  NamedParameters | a sequence of Named Parameters

Parameters

  fname | the name of the file.
  points | points of the soup of polygons
  polygons | each element in the range describes a polygon using the indices of the vertices.
  np | optional Named Parameters described below

Optional Named Parameters

  indicates whether output warnings and error messages should be printed or not. Type: Boolean Default: `false` |

Returns
  `true` if reading was successful, `false` otherwise.

## ◆ write_points()

template<typename PointRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>

bool CGAL::IO::write_points | ( | const std::string & | fname,
|  | const PointRange & | points,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

`#include <CGAL/IO/write_points.h>`

writes the range of `points` with properties to a file.

Supported file formats are the following:

- Object File Format (OFF) (`.off`)
- Polygon File Format (PLY) (`.ply`)
- LAS (Lidar) File Format (`.las`)
- XYZ File Format (`.xyz`)

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

Template Parameters

  PointRange | is a model of `ConstRange`. The value type of its iterator is the key type of the named parameter `point_map`.
  NamedParameters | a sequence of Named Parameters

Parameters

  fname | the name of the output file.
  points | the range of points that will be written.
  np | optional sequence of Named Parameters among the ones listed below.

Optional Named Parameters

  a property map associating points to the elements of the point range Type: a model of `ReadablePropertyMap` with value type `geom_traits::Point_3` Default: `CGAL::Identity_property_map<geom_traits::Point_3>` |
  a property map associating normals to the elements of the point range Type: a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3` Default: If this parameter is omitted, normals are not written in the output file. |
  an instance of a geometric traits class Type: a model of `Kernel` Default: a CGAL Kernel deduced from the point type, using `CGAL::Kernel_traits` |
  indicates whether data should be written in binary (`true`) or in ASCII (`false`) Type: Boolean Default: `true` Extra: This parameter is only relevant for `PLY` writing: the `OFF` and `XYZ` formats are always ASCII, and the `LAS` format is always binary. |
  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. |

Returns
  `true` if writing was successful, `false` otherwise.

## ◆ write_polygon_soup()

template<typename PointRange , typename PolygonRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>

bool CGAL::IO::write_polygon_soup | ( | const std::string & | fname,
|  | const PointRange & | points,
|  | const PolygonRange & | polygons,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

`#include <CGAL/IO/polygon_soup_io.h>`

writes the content of `points` and `polygons` in a file.

Supported file formats are the following:

- Object File Format (OFF) (`.off`)
- Wavefront Advanced Visualizer Object Format (OBJ) (`.obj`)
- STereoLithography (STL) File Format (`.stl`)
- Polygon File Format (PLY) (`.ply`)
- GOCAD (TS) File Format (`.ts`)
- VTK (VTU / VTP / legacy) File Formats (`.vtp`)

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

Template Parameters

  PolygonRange | a model of the concept `RandomAccessContainer` whose `value_type` is a model of the concept `RandomAccessContainer` whose `value_type` is `std::size_t`.
  PointRange | a model of the concept `RandomAccessContainer` whose value type is the point type
  NamedParameters | a sequence of Named Parameters

Parameters

  fname | the name of the file.
  points | points of the soup of polygons
  polygons | each element in the range describes a polygon using the indices of the vertices.
  np | optional Named Parameters described below

Optional Named Parameters

  a property map associating points to the elements of the range `points` Type: a model of `ReadablePropertyMap` whose key type is the value type of the iterator of `PointRange` and value type is a model of concept `Point_3` Default: `CGAL::Identity_property_map<std::iterator_traits<PointRange::iterator>::value_type>` |
  indicates whether output warnings and error messages should be printed or not. Type: Boolean Default: `false` |

Returns
  `true` if writing was successful, `false` otherwise.