CGAL 6.2 - IO Streams: STL I/O Functions

CGAL 6.2 - IO Streams

Loading...
Searching...
No Matches
Functions
STL I/O Functions
Reference Manual » I/O Functions

##

I/O Functions for the STereoLithography (STL) File Format.

## Functions
template<typename PointRange , typename TriangleRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::read_STL (std::istream &is, PointRange &points, TriangleRange &facets, const NamedParameters &np=parameters::default_values())
| reads the content of `is` into `points` and `facets`, using the STereoLithography (STL) File Format.
template<typename PointRange , typename TriangleRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::read_STL (const std::string &fname, PointRange &points, TriangleRange &facets, const NamedParameters &np=parameters::default_values())
| reads the content of a file named `fname` into `points` and `facets`, using the STereoLithography (STL) File Format.
template<typename PointRange , typename TriangleRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::write_STL (std::ostream &os, const PointRange &points, const TriangleRange &facets, const NamedParameters &np=parameters::default_values())
| writes the content of `points` and `facets` in `os`, using the STereoLithography (STL) File Format.
template<typename PointRange , typename TriangleRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
bool | CGAL::IO::write_STL (const std::string &fname, const PointRange &points, const TriangleRange &facets, const NamedParameters &np=parameters::default_values())
| writes the content of `points` and `facets` in a file named `fname`, using the STereoLithography (STL) File Format.

## Function Documentation

## ◆ read_STL() [1/2]

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

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

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

reads the content of a file named `fname` into `points` and `facets`, using the STereoLithography (STL) File Format.

If `use_binary_mode` is `true`, but the reading fails, ASCII reading will be automatically tested.

Attention
  The polygon soup is not cleared, and the data from the file are appended.

Template Parameters

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

Parameters

  fname | the path to the input file
  points | points of the soup of triangles
  facets | a range of triangles; each triangle uses the indices of the points in `points`.
  np | optional Named Parameters described below

Optional Named Parameters

  indicates whether data should be read in binary (`true`) or in ASCII (`false`) Type: Boolean Default: `true` |
  indicates whether output warnings and error messages should be printed or not. Type: Boolean Default: `false` |

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

## ◆ read_STL() [2/2]

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

bool CGAL::IO::read_STL | ( | std::istream & | is,
|  | PointRange & | points,
|  | TriangleRange & | facets,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

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

reads the content of `is` into `points` and `facets`, using the STereoLithography (STL) File Format.

Attention
  The polygon soup is not cleared, and the data from the stream are appended.
  To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.

Template Parameters

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

Parameters

  is | the input stream
  points | points of the soup of triangles
  facets | a range of triangles; each triangle uses the indices of the points in `points`.
  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 the reading was successful, `false` otherwise.

## ◆ write_STL() [1/2]

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

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

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

writes the content of `points` and `facets` in a file named `fname`, using the STereoLithography (STL) File Format.

Attention
  The polygon soup is not cleared, and the data from the file are appended.

Template Parameters

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

Parameters

  fname | the path to the output file
  points | points of the soup of triangles
  facets | a range of triangles; each triangle uses the indices of the points in `points`.
  np | optional sequence of Named Parameters among the ones listed below

Optional Named Parameters

  indicates whether data should be written in binary (`true`) or in ASCII (`false`) Type: Boolean Default: `true` |
  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 the writing was successful, `false` otherwise.

## ◆ write_STL() [2/2]

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

bool CGAL::IO::write_STL | ( | std::ostream & | os,
|  | const PointRange & | points,
|  | const TriangleRange & | facets,
|  | const NamedParameters & | np = `parameters::default_values()`
| ) |  |

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

writes the content of `points` and `facets` in `os`, using the STereoLithography (STL) File Format.

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

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

Parameters

  os | the output stream
  points | points of the soup of triangles
  facets | a range of triangles; each triangle uses the indices of the points in `points`.
  np | optional sequence of Named Parameters among the ones listed 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 the writing was successful, `false` otherwise.