mirror of https://github.com/CGAL/cgal
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#ifndef _PRINT_UTILS_H_
|
|
#define _PRINT_UTILS_H_
|
|
|
|
#include <CGAL/Polygon_with_holes_2.h>
|
|
#include <iostream>
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Pretty-print a CGAL polygon.
|
|
//
|
|
template<class Kernel, class Container>
|
|
void print_polygon (const CGAL::Polygon_2<Kernel, Container>& P)
|
|
{
|
|
typename CGAL::Polygon_2<Kernel, Container>::Vertex_const_iterator vit;
|
|
|
|
std::cout << "[ " << P.size() << " vertices:";
|
|
for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit)
|
|
std::cout << " (" << *vit << ')';
|
|
std::cout << " ]" << std::endl;
|
|
|
|
return;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Pretty-print a polygon with holes.
|
|
//
|
|
template<class Kernel, class Container>
|
|
void print_polygon_with_holes
|
|
(const CGAL::Polygon_with_holes_2<Kernel, Container>& pwh)
|
|
{
|
|
if (! pwh.is_unbounded())
|
|
{
|
|
std::cout << "{ Outer boundary = ";
|
|
print_polygon (pwh.outer_boundary());
|
|
}
|
|
else
|
|
std::cout << "{ Unbounded polygon." << std::endl;
|
|
|
|
typename CGAL::Polygon_with_holes_2<Kernel,Container>::
|
|
Hole_const_iterator hit;
|
|
unsigned int k = 1;
|
|
|
|
std::cout << " " << pwh.number_of_holes() << " holes:" << std::endl;
|
|
for (hit = pwh.holes_begin(); hit != pwh.holes_end(); ++hit, ++k)
|
|
{
|
|
std::cout << " Hole #" << k << " = ";
|
|
print_polygon (*hit);
|
|
}
|
|
std::cout << " }" << std::endl;
|
|
|
|
return;
|
|
}
|
|
|
|
#endif
|