CGAL 6.2 - 2D Snap Rounding
Loading...
Searching...
No Matches
Snap_rounding_2/double_snap_rounding.cpp
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Snap_rounding_2.h>
#include <CGAL/Snap_rounding_traits_2.h>
typedef Kernel::Segment_2 Segment_2;
typedef Kernel::Point_2 Point_2;
typedef Kernel::FT FT;
typedef std::vector<Point_2> Polyline_2;
int main()
{
// Example with a non-trivial rounding
std::vector< Segment_2 > segs;
FT e(std::pow(2, -60));
segs.emplace_back(Point_2(1-e, 1), Point_2(-1-e, -1+2*e));
segs.emplace_back(Point_2(e/2, e/2), Point_2(1, -1));
segs.emplace_back(Point_2(0, 2-e/2), Point_2(2, 0));
segs.emplace_back(Point_2(0, 2-e/2), Point_2(-2+e, -4));
segs.emplace_back(Point_2(-2, 2), Point_2(2, 2));
// Compute the snapped subcurves and check if they do intersect
std::vector< Segment_2 > out;
CGAL::snap_rounding_2(segs, std::back_inserter(out));
std::cout << "Does the output intersect: " << CGAL::do_curves_intersect(out.begin(), out.end()) << std::endl;
std::cout << "Size of the output: " << out.size() << std::endl;
// Compute the polylines corresponding to the output rounded on single precision floats
std::vector< Polyline_2 > polylines;
CGAL::snap_rounding_2(segs, std::back_inserter(polylines), CGAL::parameters::geom_traits(CGAL::Float_grid_snap_rounding_traits_2<Kernel>()));
return 0;
}
void 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)
Definition: Snap_rounding_2.h:140
bool do_curves_intersect(InputIterator curves_begin, InputIterator curves_end)
The class Float_grid_snap_rounding_traits_2<InputKernel, ExactKernel, BaseTraits> is a model of the V...
Definition: Vertical_slabs_snap_rounding_traits_2.h:173