CGAL 6.2 - 2D Polygons

Loading...
Searching...
No Matches
List of all members | Public Member Functions | Related Functions
CGAL::Polygon_with_holes_2< Kernel, Container_ > Class Template Reference
Reference Manual

`#include <CGAL/Polygon_with_holes_2.h>`

## Inherits from

CGAL::General_polygon_with_holes_2< Polygon_ >.

## Definition

template<class Kernel, class Container_ = std::vector<typename Kernel::Point_2>>
class CGAL::Polygon_with_holes_2< Kernel, Container_ >

The class `Polygon_with_holes_2` models the concept `GeneralPolygonWithHoles_2`.

It represents a linear polygon with holes. It is parameterized with two types (`Kernel` and `Container_`) that are used to instantiate the type `Polygon_2<Kernel,Container_>`. This polygon type is used to represent the outer boundary and the boundary of the holes (if any exist).

Is model of
  `GeneralPolygonWithHoles_2`

Examples
  Polygon/draw_polygon_with_holes.cpp, Polygon/multipolygon.cpp, and Stream_support/Polygon_WKT.cpp.

## Public Member Functions
| Polygon_with_holes_2 ()=default
| Default constructor.
| Polygon_with_holes_2 (const Base &base)
| Constructor from the base class.
| Polygon_with_holes_2 (const Polygon_2 &pgn_boundary)
| Constructor from a polygon.
| Polygon_with_holes_2 (Polygon_2 &&pgn_boundary)
| Cconstructor moving a polygon.
template<class HolesInputIterator >
| Polygon_with_holes_2 (const Polygon_2 &pgn_boundary, HolesInputIterator h_begin, HolesInputIterator h_end)
| Constructor from a polygon (outer boundary) and hole polygons.
template<class HolesInputIterator >
| Polygon_with_holes_2 (Polygon_2 &&pgn_boundary, HolesInputIterator h_begin, HolesInputIterator h_end)
| Cconstructor moving a polygon.
Bbox_2 | bbox () const
| returns the bounding box of the polygon with holes

## Related Functions
(Note that these are not member functions.)
template<class Kernel_ , class Container_ >
std::ostream & | operator<< (std::ostream &os, const Polygon_with_holes_2< Kernel_, Container_ > &p)
| This operator exports a polygon with holes to the output stream `os`.
template<class Kernel_ , class Container_ >
std::istream & | operator>> (std::istream &is, Polygon_with_holes_2< Kernel_, Container_ > &p)
| This operator imports a polygon with holes from the input stream `is`.
Related Functions inherited from CGAL::General_polygon_with_holes_2< Polygon_ >
template<typename Polygon_ >
std::ostream & | operator<< (std::ostream &os, const General_polygon_with_holes_2< Polygon_ > &p)
| This operator exports a `General_polygon_with_holes_2` to the output stream `os`.
template<typename Polygon_ >
std::istream & | operator>> (std::istream &is, General_polygon_with_holes_2< Polygon_ > &p)
| This operator imports a `General_polygon_with_holes_2` from the input stream `is`.

## Additional Inherited Members
Public Types inherited from CGAL::General_polygon_with_holes_2< Polygon_ >
typedef Polygon_ | Polygon_2
| polygon without hole type

## Constructor & Destructor Documentation

## ◆ Polygon_with_holes_2()

template<class Kernel , class Container_ = std::vector<typename Kernel::Point_2>>
template<class HolesInputIterator >

CGAL::Polygon_with_holes_2< Kernel, Container_ >::Polygon_with_holes_2 | ( | Polygon_2 && | pgn_boundary,
|  | HolesInputIterator | h_begin,
|  | HolesInputIterator | h_end
| ) |  |

Cconstructor moving a polygon.

Note
  In order to move the hole polygons a `std::move_iterator` may be used.

## Friends And Related Function Documentation

## ◆ operator<<()

template<class Kernel_ , class Container_ >

std::ostream & operator<< | ( | std::ostream & | os,
|  | const Polygon_with_holes_2< Kernel_, Container_ > & | p
| ) |  |
| related

This operator exports a polygon with holes to the output stream `os`.

An ASCII and a binary format exist. The format can be selected with the CGAL modifiers for streams, `CGAL::IO::set_ascii_mode()` and `CGAL::IO::set_binary_mode()`, respectively. The modifier `CGAL::IO::set_pretty_mode()` can be used to allow for (a few) structuring comments in the output. Otherwise, the output would be free of comments. The default for writing is ASCII without comments.

The number of points of the outer boundary is exported followed by the points themselves in counterclockwise order. Then, the number of holes is exported, and for each hole, the number of points on its outer boundary is exported followed by the points themselves in clockwise order.

## ◆ operator>>()

template<class Kernel_ , class Container_ >

std::istream & operator>> | ( | std::istream & | is,
|  | Polygon_with_holes_2< Kernel_, Container_ > & | p
| ) |  |
| related

This operator imports a polygon with holes from the input stream `is`.

Both ASCII and binary formats are supported, and the format is automatically detected.

The format consists of the number of points of the outer boundary followed by the points themselves in counterclockwise order, followed by the number of holes, and for each hole, the number of points of the outer boundary is followed by the points themselves, in clockwise order.