CGAL 6.2 - 2D Snap Rounding
Loading...
Searching...
No Matches
Reference Manual

Eli Packer, Leo Valque
Snap Rounding is a well known method for converting arbitrary-precision arrangements of segments into a smaller precision representation. This package supports methods to converting into various including fixed-precision or floating-point representation.
Introduced in: CGAL 3.1
Depends on: 2D Arrangements
BibTeX: cgal:p-sr2-26a
License: GPL
Windows Demo: 2D Snap Rounding

Classified Reference Pages

Parameters

Optional parameters of the functions of this package are implemented as Named Parameters. The page Named Parameters describes their usage.

Snap Rounding Common

Vertical Slab Snap Rounding

Hot Pixel Snap Rounding

Snap Rounding Concepts

Modules

 Concepts
 

Classes

struct  CGAL::Double_grid_snap_rounding_traits_2< InputKernel, ExactKernel, BaseTraits >
 The class Double_grid_snap_rounding_traits_2<InputKernel, ExactKernel, BaseTraits> is a model of the VerticalSlabSnapRoundingTraits_2 concept. More...
 
struct  CGAL::Float_grid_snap_rounding_traits_2< InputKernel, ExactKernel, BaseTraits >
 The class Float_grid_snap_rounding_traits_2<InputKernel, ExactKernel, BaseTraits> is a model of the VerticalSlabSnapRoundingTraits_2 concept. More...
 
class  CGAL::Hot_pixel_snap_rounding_traits_2< BaseKernel >
 The class Hot_pixel_snap_rounding_traits_2<Kernel> is a model of the HotPixelSnapRoundingTraits_2 concept. More...
 
struct  CGAL::Integer_grid_snap_rounding_traits_2< InputKernel, ExactKernel, BaseTraits >
 The class Integer_grid_snap_rounding_traits_2<InputKernel, ExactKernel, BaseTraits> is a model of the VerticalSlabSnapRoundingTraits_2 concept. More...
 

Functions

template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::hot_pixel_snap_rounding_2 (const SegmentRange &segments, OutputPolylineIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::hot_pixel_snap_rounding_2 (const SegmentRange &segments, OutputSegmentIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::hot_pixel_snap_rounding_2 (PolygonRange &polygons, OutputPolygonIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.
 
template<class Traits , class InputIterator , class OutputContainer >
void CGAL::snap_rounding_2 (InputIterator begin, InputIterator end, OutputContainer &output_container, typename Traits::NT pixel_size, bool do_isr=true, bool int_output=true, unsigned int number_of_kd_trees=1)
 
template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::snap_rounding_2 (const SegmentRange &segments, OutputPolylineIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::snap_rounding_2 (const SegmentRange &segments, OutputSegmentIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::snap_rounding_2 (PolygonRange &polygons, OutputPolygonIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.
 
template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::vertical_slab_snap_rounding_2 (const SegmentRange &segments, OutputPolylineIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::vertical_slab_snap_rounding_2 (const SegmentRange &segments, OutputSegmentIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.
 
template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::vertical_slab_snap_rounding_2 (PolygonRange &polygons, OutputPolygonIterator out, const NamedParameters &np=parameters::default_values())
 subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.
 

Function Documentation

◆ hot_pixel_snap_rounding_2() [1/3]

template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::hot_pixel_snap_rounding_2 ( const SegmentRange &  segments,
OutputPolylineIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/hot_pixel_snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of polylines, where each polyline corresponds to an input segment.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputPolylineIteratormodel of OutputIterator holding Polyline. Polyline must be a type that provides a push_back(Point_2) function.
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • The size of the pixel. The plane will be tiled with square pixels of that width such that the origin is the center of a pixel.
  • Type: GT::FT
  • Default: FT(1.)
  • determines whether to apply Iterative Snap Rounding, see the user manual for more details.
  • Type: Boolean
  • Default: true
  • If set to true, the output coordinates are expressed in the integer grid (pixel indices). Otherwise, they are given in the input coordinate system.
  • Type: Boolean
  • Default: true
Examples
Snap_rounding_2/iterative_snap_rounding.cpp, and Snap_rounding_2/snap_rounding_to_integer.cpp.

◆ hot_pixel_snap_rounding_2() [2/3]

template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::hot_pixel_snap_rounding_2 ( const SegmentRange &  segments,
OutputSegmentIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/hot_pixel_snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of segments.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputSegmentIteratormodel of OutputIterator holding Kernel::Segment_2
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • The size of the pixel. The plane will be tiled with square pixels of that width such that the origin is the center of a pixel.
  • Type: GT::FT
  • Default: FT(1.)
  • determines whether to apply Iterative Snap Rounding, see the user manual for more details.
  • Type: Boolean
  • Default: true
  • If set to true, the output coordinates are expressed in the integer grid (pixel indices). Otherwise, they are given in the input coordinate system.
  • Type: Boolean
  • Default: true

◆ hot_pixel_snap_rounding_2() [3/3]

template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::hot_pixel_snap_rounding_2 ( PolygonRange &  polygons,
OutputPolygonIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/hot_pixel_snap_rounding_2.h>

subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.

If the input polygons are disjoint, the output polygons remain non-overlapping, although they may share vertices or edges. Each output polygon is free of self-intersections but may present pinched sections.

Template Parameters
PolygonRangea range of CGAL::Polygon_2, model of Range. Its iterator type is InputIterator.
OutputPolygonIteratormodel of OutputIterator holding CGAL::Polygon_2
NamedParametersa sequence of Named Parameters
Parameters
polygonsthe range of input polygons
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • The size of the pixel. The plane will be tiled with square pixels of that width such that the origin is the center of a pixel.
  • Type: GT::FT
  • Default: FT(1.)
  • determines whether to apply Iterative Snap Rounding, see the user manual for more details.
  • Type: Boolean
  • Default: true
  • If set to true, the output coordinates are expressed in the integer grid (pixel indices). Otherwise, they are given in the input coordinate system.
  • Type: Boolean
  • Default: true
Warning
a convex input polygon might no longer be convex after rounding.

◆ snap_rounding_2() [1/4]

template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::snap_rounding_2 ( const SegmentRange &  segments,
OutputPolylineIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of polylines, where each polyline corresponds to an input segment.

calls the function CGAL::vertical_slab_snap_rounding_2() or CGAL::hot_pixel_snap_rounding_2() depending if geom_traits is model of VerticalSlabSnapRoundingTraits_2 or HotPixelSnapRoundingTraits_2.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputPolylineIteratormodel of OutputIterator holding Polyline. Polyline must be a type that provides a push_back(Point_2) function.
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters including the one listed below
Optional Named Parameters

◆ snap_rounding_2() [2/4]

template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::snap_rounding_2 ( const SegmentRange &  segments,
OutputSegmentIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of segments.

calls the function CGAL::vertical_slab_snap_rounding_2() or CGAL::hot_pixel_snap_rounding_2() depending if the parameter geom_traits is model of VerticalSlabSnapRoundingTraits_2 or HotPixelSnapRoundingTraits_2.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputSegmentIteratormodel of OutputIterator holding Kernel::Segment_2
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters including the one listed below
Optional Named Parameters

◆ snap_rounding_2() [3/4]

template<class Traits , class InputIterator , class OutputContainer >
void CGAL::snap_rounding_2 ( InputIterator  begin,
InputIterator  end,
OutputContainer &  output_container,
typename Traits::NT  pixel_size,
bool  do_isr = true,
bool  int_output = true,
unsigned int  number_of_kd_trees = 1 
)

#include <CGAL/Snap_rounding_2.h>

Deprecated:
use newer API of CGAL::snap_rounding_2() or CGAL::hot_pixel_snap_rounding_2()
Template Parameters
Traitsmust be a model of HotPixelSnapRoundingTraits_2.
InputIteratormust be an iterator with value type Traits::Segment_2.
OutputContainermust be a container with a method push_back(const OutputContainer::value_type& c), where OutputContainer::value_type must be a container with a method push_back(const Traits::Point_2& p)
Parameters
begin,endThe first two parameters denote the iterator range of the input segments.
output_containeris a reference to a container of the output polylines. Since a polyline is composed of a sequence of points, a polyline is a container itself.
do_isrThe fifth parameter determines whether to apply ISR or SR.
pixel_sizeThe fourth parameter denotes the pixel size w. The plane will be tiled with square pixels of width w such that the origin is the center of a pixel. pixel_size must have a positive value.
int_outputIf set to true, the output coordinates are expressed in the integer grid (pixel indices). Otherwise, they are given in the input coordinate system.
number_of_kd_treesThe seventh parameter is briefly described later on this page; for a detailed description see [3].
Examples
Snap_rounding_2/snap_rounding_to_double.cpp.

◆ snap_rounding_2() [4/4]

template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::snap_rounding_2 ( PolygonRange &  polygons,
OutputPolygonIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Snap_rounding_2.h>

subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.

If the input polygons are disjoint, the output polygons remain non-overlapping, although they may share vertices or edges. Each output polygon is free of self-intersections but may present pinched sections.

Per default, this function rounds on double precision coordinates using CGAL::vertical_slab_snap_rounding_2(). Other rounding schemes or methods can be used by providing a geom_traits that is model of VerticalSlabSnapRoundingTraits_2 or HotPixelSnapRoundingTraits_2.

Template Parameters
PolygonRangea range of CGAL::Polygon_2, model of Range. Its iterator type is InputIterator.
OutputPolygonIteratormodel of OutputIterator holding CGAL::Polygon_2
NamedParametersa sequence of Named Parameters
Parameters
polygonsthe range of input polygons
outthe output inserter
npan optional sequence of Named Parameters including the one listed below
Optional Named Parameters
Warning
a convex input polygon might no longer be convex after rounding.

◆ vertical_slab_snap_rounding_2() [1/3]

template<class SegmentRange , class OutputPolylineIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolylineIterator CGAL::vertical_slab_snap_rounding_2 ( const SegmentRange &  segments,
OutputPolylineIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/vertical_slab_snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of polylines, where each polyline corresponds to an input segment.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputPolylineIteratormodel of OutputIterator holding Polyline. Polyline must be a type that provides a push_back(Point_2) function.
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters

◆ vertical_slab_snap_rounding_2() [2/3]

template<class SegmentRange , class OutputSegmentIterator , class NamedParameters = parameters::Default_named_parameters>
OutputSegmentIterator CGAL::vertical_slab_snap_rounding_2 ( const SegmentRange &  segments,
OutputSegmentIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/vertical_slab_snap_rounding_2.h>

subdivides and rounds a range of segments so that they are pairwise disjoint in their interiors.

The output is a range of segments.

Template Parameters
SegmentRangea range of Kernel::Segment_2, model of Range. Its iterator type is InputIterator.
OutputSegmentIteratormodel of OutputIterator holding Kernel::Segment_2
NamedParametersa sequence of Named Parameters
Parameters
segmentsthe input segment range
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters

◆ vertical_slab_snap_rounding_2() [3/3]

template<class PolygonRange , class OutputPolygonIterator , class NamedParameters = parameters::Default_named_parameters>
OutputPolygonIterator CGAL::vertical_slab_snap_rounding_2 ( PolygonRange &  polygons,
OutputPolygonIterator  out,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/vertical_slab_snap_rounding_2.h>

subdivides and rounds a range of polygons so that their boundary segments are pairwise disjoint in their interiors.

If the input polygons are disjoint, the output polygons remain non-overlapping, although they may share vertices or edges. Each output polygon is free of self-intersections but may present pinched sections.

Template Parameters
PolygonRangea range of CGAL::Polygon_2, model of Range. Its iterator type is InputIterator.
OutputPolygonIteratormodel of OutputIterator holding CGAL::Polygon_2
NamedParametersa sequence of Named Parameters
Parameters
polygonsthe range of input polygons
outthe output inserter
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
Warning
a convex input polygon might no longer be convex after rounding.