mirror of https://github.com/CGAL/cgal
towards generic ISR
This commit is contained in:
parent
253853abe2
commit
e44cd9ff2b
|
|
@ -20,6 +20,7 @@ int main()
|
|||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/IO/Window_stream.h>
|
||||
//#include <CGAL/IO/cgal_window_redefine.h>
|
||||
#include "../../include/CGAL/Snap_rounding_2_traits.h"
|
||||
#include "../../include/CGAL/Snap_rounding_2.h"
|
||||
|
||||
typedef leda_rational Number_Type;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
\input{snap}
|
||||
\input{Snap_rounding_ref/snap_ref}
|
||||
\input{snap_concept}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,10 @@
|
|||
Snap rounding is a well known method for converting
|
||||
arbitrary-precision arrangements of segments into a fixed-precision
|
||||
representation. It is classified as a finite precision approximation
|
||||
technique. This package makes Snap Rounding of line segments in $\reals_2$.
|
||||
Iterated Snap Rounding is a modification of Snap Rounding. In
|
||||
Iterated Snap Rounding,
|
||||
each vertex is at leat half-the-width-of-a-pixel away from any non-incident
|
||||
edge.
|
||||
This package provides both Iterated Snap Rounding and Snap Rounding.
|
||||
technique. Iterated Snap Rounding is a modification of Snap Rounding in
|
||||
which each vertex is at leat half-the-width-of-a-pixel away from any
|
||||
non-incident edge.
|
||||
This package provides supports both methods.
|
||||
|
||||
\begin{figure}
|
||||
\begin{center}
|
||||
|
|
@ -60,14 +58,13 @@ replaced by the polygonal chain through the centers of the hot pixels
|
|||
met by $e$, in the same order as they are met by $e$.
|
||||
Figure~\ref{fig:sr1} demonstrates a snap rounding output.
|
||||
|
||||
Since in a snap-rounded arrangement, the distance between a vertex and
|
||||
In a snap-rounded arrangement, the distance between a vertex and
|
||||
a non-incident edge can be extremely small compared with the width of a
|
||||
pixel in the grid used for rounding, this package provides, beside the
|
||||
usual Snap Rounding, a modification of it, named Iterated Snap Rounding,
|
||||
which makes the a vertex and a non-incident edge well separated. However,
|
||||
the guaranteed quality of the approximation in Iterated Snap Rounding
|
||||
degrades.
|
||||
Figure~\ref{fig:isr_vs_sr} demonstrates the differences between Iterated
|
||||
pixel in the grid used for rounding. Iterated Snap Rounding is a modification
|
||||
of Snap Rounding which makes the a vertex and a non-incident edge well separated
|
||||
(the distance between each is at least half-the-width-of-a-pixel).
|
||||
However, the guaranteed quality of the approximation in Iterated Snap Rounding
|
||||
degrades. Figure~\ref{fig:isr_vs_sr} demonstrates the differences between Iterated
|
||||
Snap Rounding and Snap Rounding.
|
||||
|
||||
\begin{figure}
|
||||
|
|
|
|||
|
|
@ -56,12 +56,23 @@ in the grid used by the Snap Rounding algorithm. Must have the syntax
|
|||
input point, \ccc{pixel_size} is the size of the pixel of the grid,
|
||||
and $x$ and $y$ are the $x$ and $y$-coordinates of the rounded point
|
||||
respectively.}
|
||||
\ccGlue
|
||||
|
||||
\ccNestedType{segment_direction}{Returns the slope of a segment.
|
||||
\ccNestedType{segment_direction}{Returns the slope of a segment
|
||||
as described in CITE.
|
||||
Must have the syntax \ccc{double segment_direction(Segment_2 s)}
|
||||
where $s$ is the input segment.}
|
||||
\ccGlue
|
||||
|
||||
\ccNestedType{rotate_point}{Rotate a point by a given angle.
|
||||
Must have the syntax \ccc{Point_2 rotate_point(Point_2 p,NT angle)}
|
||||
where $p$ is the point to rotate and angle is the rotation magnitude
|
||||
in radians.}
|
||||
|
||||
\ccNestedType{get_bounding_of_min_sum}{Get the bounding box
|
||||
of the minkowski sum of a segment and a unit pixel as described in CITE.
|
||||
Must have the syntax \ccc{Iso_rectangle_2 get_bounding_of_min_sum(
|
||||
Segment_2 s,NT unit_squere,NT angle)}
|
||||
where $s$ is the segment, $unit_square$ is the edge size of the pixel
|
||||
and $angle$ is the slope of the segment.}
|
||||
|
||||
\ccCreation
|
||||
\ccCreationVariable{traits} %% choose variable name
|
||||
|
|
@ -70,11 +81,11 @@ Only a default constructor, copy constructor
|
|||
Note that further constructors
|
||||
can be provided.
|
||||
|
||||
\ccConstructor{LargestEmptyIsoRectangleTraits_2();}{Default constructor.}
|
||||
\ccConstructor{SnapRoundingTraits_2();}{Default constructor.}
|
||||
\ccGlue
|
||||
\ccConstructor{LargestEmptyIsoRectangleTraits_2(LargestEmptyIsoRectangleTraits_2);}
|
||||
\ccConstructor{SnapRoundingTraits_2(SnapRoundingTraits_2);}
|
||||
{Copy constructor}
|
||||
\ccMethod{LargestEmptyIsoRectangleTraits_2 operator=(LargestEmptyIsoRectangleTraits_2 gtr);}
|
||||
\ccMethod{SnapRoundingTraits_2 operator=(SnapRoundingTraits_2 gtr);}
|
||||
{Assignment operator.}
|
||||
|
||||
\ccHeading{Predicate functions}
|
||||
|
|
@ -102,7 +113,7 @@ and constructor objects.
|
|||
\ccc{CGAL::Homogeneous<R>}
|
||||
|
||||
\ccSeeAlso
|
||||
\ccc{CGAL::Largest_empty_iso_rectangle_2<Traits>}
|
||||
\ccc{CGAL::Snap_rounding_2<Traits>}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include "../../include/CGAL/Snap_rounding_2_traits.h"
|
||||
#include "../../include/CGAL/Snap_rounding_2.h"
|
||||
|
||||
#include <CGAL/leda_real.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
//#ifndef CGAL_ENUM_H
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
// @@@@ special includes for pm
|
||||
|
|
@ -141,258 +141,6 @@ struct hot_pixel_dir_cmp
|
|||
bool operator ()(const Hot_Pixel<Rep_> *h1,const Hot_Pixel<Rep_> *h2);
|
||||
};
|
||||
|
||||
template<class base_rep>
|
||||
class Snap_rounding_traits : public base_rep {
|
||||
|
||||
typedef typename base_rep::FT NT;
|
||||
typedef typename base_rep::Point_2 Point_2;
|
||||
typedef typename base_rep::Segment_2 Segment_2;
|
||||
typedef typename base_rep::Iso_rectangle_2 Iso_rectangle_2;
|
||||
|
||||
public:
|
||||
|
||||
Snap_rounding_traits()
|
||||
{
|
||||
init_angle_appr();
|
||||
}
|
||||
|
||||
void snap(Point_2 p,NT pixel_size,NT &x,NT &y)
|
||||
{
|
||||
x = NT(floor((p.x() / pixel_size).to_double())) * pixel_size +
|
||||
pixel_size / 2.0;
|
||||
|
||||
y = NT(floor((p.y() / pixel_size).to_double())) * pixel_size +
|
||||
pixel_size / 2.0;
|
||||
}
|
||||
|
||||
double segment_direction(Segment_2 s)
|
||||
{
|
||||
double x1 = s.source().x().to_double();
|
||||
double y1 = s.source().y().to_double();
|
||||
double x2 = s.target().x().to_double();
|
||||
double y2 = s.target().y().to_double();
|
||||
|
||||
return(atan((y2 - y1)/(x2 - x1)));
|
||||
}
|
||||
|
||||
Point_2 rotate_point(Point_2 p,NT angle)
|
||||
{
|
||||
int tranc_angle = int(angle.to_double() * rad_to_deg);
|
||||
NT cosine_val = angle_to_sines_appr[90 - tranc_angle],
|
||||
sine_val = angle_to_sines_appr[tranc_angle];
|
||||
|
||||
NT x = p.x() * cosine_val - p.y() * sine_val,
|
||||
y = p.x() * sine_val + p.y() * cosine_val;
|
||||
|
||||
return(Point_2(x,y));
|
||||
}
|
||||
|
||||
Iso_rectangle_2 get_bounding_of_min_sum(
|
||||
Segment_2 s,
|
||||
NT unit_squere,
|
||||
NT angle)
|
||||
{
|
||||
Point_2 ms1,ms2,ms3,ms4,ms5,ms6;// minkowski sum points
|
||||
|
||||
Comparison_result cx = compare_x_2_object()(s.source(),s.target());
|
||||
NT x1 = s.source().x(),y1 = s.source().y(),x2 =
|
||||
s.target().x(),y2 = s.target().y();
|
||||
|
||||
if(cx == SMALLER) {
|
||||
// we use unit_squere instead of unit_squere / 2 in order to
|
||||
// find tangency points which are not supported by kd-tree
|
||||
ms1 = Point_2(x1 - 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms2 = Point_2(x1 - 0.6 * unit_squere,y1 + 0.6 * unit_squere);
|
||||
ms3 = Point_2(x1 + 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms4 = Point_2(x2 + 0.6 * unit_squere,y2 - 0.6 * unit_squere);
|
||||
ms5 = Point_2(x2 + 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms6 = Point_2(x2 - 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
} else {
|
||||
// we use unit_squere instead of unit_squere / 2 in order to
|
||||
// find tangency points which are not supported by kd-tree
|
||||
ms1 = Point_2(x1 + 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms2 = Point_2(x1 - 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms3 = Point_2(x1 + 0.6 * unit_squere,y1 + 0.6 * unit_squere);
|
||||
ms4 = Point_2(x2 + 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms5 = Point_2(x2 - 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms6 = Point_2(x2 - 0.6 * unit_squere,y2 - 0.6 * unit_squere);
|
||||
}
|
||||
|
||||
rotate_point(ms1,angle);
|
||||
rotate_point(ms2,angle);
|
||||
rotate_point(ms3,angle);
|
||||
rotate_point(ms4,angle);
|
||||
rotate_point(ms5,angle);
|
||||
rotate_point(ms6,angle);
|
||||
|
||||
// query
|
||||
Point_2 point_left,point_right,point_bot,point_top;
|
||||
|
||||
point_left = small_x_point(ms1,ms2);
|
||||
point_left = small_x_point(point_left,ms3);
|
||||
point_left = small_x_point(point_left,ms4);
|
||||
point_left = small_x_point(point_left,ms5);
|
||||
point_left = small_x_point(point_left,ms6);
|
||||
|
||||
point_right = big_x_point(ms1,ms2);
|
||||
point_right = big_x_point(point_right,ms3);
|
||||
point_right = big_x_point(point_right,ms4);
|
||||
point_right = big_x_point(point_right,ms5);
|
||||
point_right = big_x_point(point_right,ms6);
|
||||
|
||||
point_bot = small_y_point(ms1,ms2);
|
||||
point_bot = small_y_point(point_bot,ms3);
|
||||
point_bot = small_y_point(point_bot,ms4);
|
||||
point_bot = small_y_point(point_bot,ms5);
|
||||
point_bot = small_y_point(point_bot,ms6);
|
||||
|
||||
point_top = big_y_point(ms1,ms2);
|
||||
point_top = big_y_point(point_top,ms3);
|
||||
point_top = big_y_point(point_top,ms4);
|
||||
point_top = big_y_point(point_top,ms5);
|
||||
point_top = big_y_point(point_top,ms6);
|
||||
|
||||
Iso_rectangle_2 rec(point_left,point_right,point_bot,point_top);
|
||||
|
||||
return(rec);
|
||||
}
|
||||
|
||||
private:
|
||||
static const double rad_to_deg = 57.297;
|
||||
std::map<const int,NT> angle_to_sines_appr;
|
||||
|
||||
Point_2 small_x_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_x_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p1);
|
||||
else
|
||||
return(p2);
|
||||
}
|
||||
|
||||
Point_2 small_y_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_y_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p1);
|
||||
else
|
||||
return(p2);
|
||||
}
|
||||
|
||||
Point_2 big_x_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_x_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p2);
|
||||
else
|
||||
return(p1);
|
||||
}
|
||||
|
||||
Point_2 big_y_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_y_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p2);
|
||||
else
|
||||
return(p1);
|
||||
}
|
||||
|
||||
void init_angle_appr()
|
||||
{
|
||||
angle_to_sines_appr[0] = NT(0);
|
||||
angle_to_sines_appr[1] = NT(115) / NT(6613);
|
||||
angle_to_sines_appr[2] = NT(57) / NT(1625);
|
||||
angle_to_sines_appr[3] = NT(39) / NT(761);
|
||||
angle_to_sines_appr[4] = NT(29) / NT(421);
|
||||
angle_to_sines_appr[5] = NT(23) / NT(265);
|
||||
angle_to_sines_appr[6] = NT(19) / NT(181);
|
||||
angle_to_sines_appr[7] = NT(32) / NT(257);
|
||||
angle_to_sines_appr[8] = NT(129) / NT(929);
|
||||
angle_to_sines_appr[9] = NT(100) / NT(629);
|
||||
angle_to_sines_appr[10] = NT(92) / NT(533);
|
||||
angle_to_sines_appr[11] = NT(93) / NT(485);
|
||||
angle_to_sines_appr[12] = NT(76) / NT(365);
|
||||
angle_to_sines_appr[13] = NT(156) / NT(685);
|
||||
angle_to_sines_appr[14] = NT(205) / NT(853);
|
||||
angle_to_sines_appr[15] = NT(69) / NT(269);
|
||||
angle_to_sines_appr[16] = NT(7) / NT(25);
|
||||
angle_to_sines_appr[17] = NT(120) / NT(409);
|
||||
angle_to_sines_appr[18] = NT(57) / NT(185);
|
||||
angle_to_sines_appr[19] = NT(12) / NT(37);
|
||||
angle_to_sines_appr[20] = NT(51) / NT(149);
|
||||
angle_to_sines_appr[21] = NT(135) / NT(377);
|
||||
angle_to_sines_appr[22] = NT(372) / NT(997);
|
||||
angle_to_sines_appr[23] = NT(348) / NT(877);
|
||||
angle_to_sines_appr[24] = NT(231) / NT(569);
|
||||
angle_to_sines_appr[25] = NT(36) / NT(85);
|
||||
angle_to_sines_appr[26] = NT(39) / NT(89);
|
||||
angle_to_sines_appr[27] = NT(300) / NT(661);
|
||||
angle_to_sines_appr[28] = NT(8) / NT(17);
|
||||
angle_to_sines_appr[29] = NT(189) / NT(389);
|
||||
angle_to_sines_appr[30] = NT(451) / NT(901);
|
||||
angle_to_sines_appr[31] = NT(180) / NT(349);
|
||||
angle_to_sines_appr[32] = NT(28) / NT(53);
|
||||
angle_to_sines_appr[33] = NT(432) / NT(793);
|
||||
angle_to_sines_appr[34] = NT(161) / NT(289);
|
||||
angle_to_sines_appr[35] = NT(228) / NT(397);
|
||||
angle_to_sines_appr[36] = NT(504) / NT(865);
|
||||
angle_to_sines_appr[37] = NT(3) / NT(5);
|
||||
angle_to_sines_appr[38] = NT(580) / NT(941);
|
||||
angle_to_sines_appr[39] = NT(341) / NT(541);
|
||||
angle_to_sines_appr[40] = NT(88) / NT(137);
|
||||
angle_to_sines_appr[41] = NT(48) / NT(73);
|
||||
angle_to_sines_appr[42] = NT(65) / NT(97);
|
||||
angle_to_sines_appr[43] = NT(429) / NT(629);
|
||||
angle_to_sines_appr[44] = NT(555) / NT(797);
|
||||
angle_to_sines_appr[45] = NT(697) / NT(985);
|
||||
angle_to_sines_appr[46] = NT(572) / NT(797);
|
||||
angle_to_sines_appr[47] = NT(460) / NT(629);
|
||||
angle_to_sines_appr[48] = NT(72) / NT(97);
|
||||
angle_to_sines_appr[49] = NT(55) / NT(73);
|
||||
angle_to_sines_appr[50] = NT(105) / NT(137);
|
||||
angle_to_sines_appr[51] = NT(420) / NT(541);
|
||||
angle_to_sines_appr[52] = NT(741) / NT(941);
|
||||
angle_to_sines_appr[53] = NT(4) / NT(5);
|
||||
angle_to_sines_appr[54] = NT(703) / NT(865);
|
||||
angle_to_sines_appr[55] = NT(325) / NT(397);
|
||||
angle_to_sines_appr[56] = NT(240) / NT(289);
|
||||
angle_to_sines_appr[57] = NT(665) / NT(793);
|
||||
angle_to_sines_appr[58] = NT(45) / NT(53);
|
||||
angle_to_sines_appr[59] = NT(299) / NT(349);
|
||||
angle_to_sines_appr[60] = NT(780) / NT(901);
|
||||
angle_to_sines_appr[61] = NT(340) / NT(389);
|
||||
angle_to_sines_appr[62] = NT(15) / NT(17);
|
||||
angle_to_sines_appr[63] = NT(589) / NT(661);
|
||||
angle_to_sines_appr[64] = NT(80) / NT(89);
|
||||
angle_to_sines_appr[65] = NT(77) / NT(85);
|
||||
angle_to_sines_appr[66] = NT(520) / NT(569);
|
||||
angle_to_sines_appr[67] = NT(805) / NT(877);
|
||||
angle_to_sines_appr[68] = NT(925) / NT(997);
|
||||
angle_to_sines_appr[69] = NT(352) / NT(377);
|
||||
angle_to_sines_appr[70] = NT(140) / NT(149);
|
||||
angle_to_sines_appr[71] = NT(35) / NT(37);
|
||||
angle_to_sines_appr[72] = NT(176) / NT(185);
|
||||
angle_to_sines_appr[73] = NT(391) / NT(409);
|
||||
angle_to_sines_appr[74] = NT(24) / NT(25);
|
||||
angle_to_sines_appr[75] = NT(260) / NT(269);
|
||||
angle_to_sines_appr[76] = NT(828) / NT(853);
|
||||
angle_to_sines_appr[77] = NT(667) / NT(685);
|
||||
angle_to_sines_appr[78] = NT(357) / NT(365);
|
||||
angle_to_sines_appr[79] = NT(476) / NT(485);
|
||||
angle_to_sines_appr[80] = NT(525) / NT(533);
|
||||
angle_to_sines_appr[81] = NT(621) / NT(629);
|
||||
angle_to_sines_appr[82] = NT(920) / NT(929);
|
||||
angle_to_sines_appr[83] = NT(255) / NT(257);
|
||||
angle_to_sines_appr[84] = NT(180) / NT(181);
|
||||
angle_to_sines_appr[85] = NT(264) / NT(265);
|
||||
angle_to_sines_appr[86] = NT(420) / NT(421);
|
||||
angle_to_sines_appr[87] = NT(760) / NT(761);
|
||||
angle_to_sines_appr[88] = NT(1624) / NT(1625);
|
||||
angle_to_sines_appr[89] = NT(6612) / NT(6613);
|
||||
angle_to_sines_appr[90] = NT(1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class Rep_>
|
||||
class Snap_rounding_2 {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,285 @@
|
|||
// ======================================================================
|
||||
//
|
||||
// Copyright (c) The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// release : $CGAL_Revision: CGAL-2.3-I-24 $
|
||||
// release_date : $CGAL_Date: 2000/12/29 $
|
||||
//
|
||||
// file : include/CGAL/Snap_rounding_2_traits.h
|
||||
// package : arr (1.73)
|
||||
// maintainer : Eli Packer <elip@post.tau.ac.il>
|
||||
// author(s) : Eli Packer
|
||||
// coordinator : Tel-Aviv University (Dan Halperin <danha@post.tau.ac.il>)
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef CGAL_SR_2_TRAITS_H
|
||||
#define CGAL_SR_2_TRAITS_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <map>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template<class base_rep>
|
||||
class Snap_rounding_traits : public base_rep {
|
||||
|
||||
typedef typename base_rep::FT NT;
|
||||
typedef typename base_rep::Point_2 Point_2;
|
||||
typedef typename base_rep::Segment_2 Segment_2;
|
||||
typedef typename base_rep::Iso_rectangle_2 Iso_rectangle_2;
|
||||
|
||||
public:
|
||||
|
||||
Snap_rounding_traits()
|
||||
{
|
||||
init_angle_appr();
|
||||
}
|
||||
|
||||
void snap(Point_2 p,NT pixel_size,NT &x,NT &y)
|
||||
{
|
||||
x = NT(floor((p.x() / pixel_size).to_double())) * pixel_size +
|
||||
pixel_size / 2.0;
|
||||
|
||||
y = NT(floor((p.y() / pixel_size).to_double())) * pixel_size +
|
||||
pixel_size / 2.0;
|
||||
}
|
||||
|
||||
double segment_direction(Segment_2 s)
|
||||
{
|
||||
double x1 = s.source().x().to_double();
|
||||
double y1 = s.source().y().to_double();
|
||||
double x2 = s.target().x().to_double();
|
||||
double y2 = s.target().y().to_double();
|
||||
|
||||
return(atan((y2 - y1)/(x2 - x1)));
|
||||
}
|
||||
|
||||
Point_2 rotate_point(Point_2 p,NT angle)
|
||||
{
|
||||
int tranc_angle = int(angle.to_double() * rad_to_deg);
|
||||
NT cosine_val = angle_to_sines_appr[90 - tranc_angle],
|
||||
sine_val = angle_to_sines_appr[tranc_angle];
|
||||
|
||||
NT x = p.x() * cosine_val - p.y() * sine_val,
|
||||
y = p.x() * sine_val + p.y() * cosine_val;
|
||||
|
||||
return(Point_2(x,y));
|
||||
}
|
||||
|
||||
Iso_rectangle_2 get_bounding_of_min_sum(
|
||||
Segment_2 s,
|
||||
NT unit_squere,
|
||||
NT angle)
|
||||
{
|
||||
Point_2 ms1,ms2,ms3,ms4,ms5,ms6;// minkowski sum points
|
||||
|
||||
Comparison_result cx = compare_x_2_object()(s.source(),s.target());
|
||||
NT x1 = s.source().x(),y1 = s.source().y(),x2 =
|
||||
s.target().x(),y2 = s.target().y();
|
||||
|
||||
if(cx == SMALLER) {
|
||||
// we use unit_squere instead of unit_squere / 2 in order to
|
||||
// find tangency points which are not supported by kd-tree
|
||||
ms1 = Point_2(x1 - 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms2 = Point_2(x1 - 0.6 * unit_squere,y1 + 0.6 * unit_squere);
|
||||
ms3 = Point_2(x1 + 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms4 = Point_2(x2 + 0.6 * unit_squere,y2 - 0.6 * unit_squere);
|
||||
ms5 = Point_2(x2 + 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms6 = Point_2(x2 - 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
} else {
|
||||
// we use unit_squere instead of unit_squere / 2 in order to
|
||||
// find tangency points which are not supported by kd-tree
|
||||
ms1 = Point_2(x1 + 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms2 = Point_2(x1 - 0.6 * unit_squere,y1 - 0.6 * unit_squere);
|
||||
ms3 = Point_2(x1 + 0.6 * unit_squere,y1 + 0.6 * unit_squere);
|
||||
ms4 = Point_2(x2 + 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms5 = Point_2(x2 - 0.6 * unit_squere,y2 + 0.6 * unit_squere);
|
||||
ms6 = Point_2(x2 - 0.6 * unit_squere,y2 - 0.6 * unit_squere);
|
||||
}
|
||||
|
||||
rotate_point(ms1,angle);
|
||||
rotate_point(ms2,angle);
|
||||
rotate_point(ms3,angle);
|
||||
rotate_point(ms4,angle);
|
||||
rotate_point(ms5,angle);
|
||||
rotate_point(ms6,angle);
|
||||
|
||||
// query
|
||||
Point_2 point_left,point_right,point_bot,point_top;
|
||||
|
||||
point_left = small_x_point(ms1,ms2);
|
||||
point_left = small_x_point(point_left,ms3);
|
||||
point_left = small_x_point(point_left,ms4);
|
||||
point_left = small_x_point(point_left,ms5);
|
||||
point_left = small_x_point(point_left,ms6);
|
||||
|
||||
point_right = big_x_point(ms1,ms2);
|
||||
point_right = big_x_point(point_right,ms3);
|
||||
point_right = big_x_point(point_right,ms4);
|
||||
point_right = big_x_point(point_right,ms5);
|
||||
point_right = big_x_point(point_right,ms6);
|
||||
|
||||
point_bot = small_y_point(ms1,ms2);
|
||||
point_bot = small_y_point(point_bot,ms3);
|
||||
point_bot = small_y_point(point_bot,ms4);
|
||||
point_bot = small_y_point(point_bot,ms5);
|
||||
point_bot = small_y_point(point_bot,ms6);
|
||||
|
||||
point_top = big_y_point(ms1,ms2);
|
||||
point_top = big_y_point(point_top,ms3);
|
||||
point_top = big_y_point(point_top,ms4);
|
||||
point_top = big_y_point(point_top,ms5);
|
||||
point_top = big_y_point(point_top,ms6);
|
||||
|
||||
Iso_rectangle_2 rec(point_left,point_right,point_bot,point_top);
|
||||
|
||||
return(rec);
|
||||
}
|
||||
|
||||
private:
|
||||
static const double rad_to_deg = 57.297;
|
||||
std::map<const int,NT> angle_to_sines_appr;
|
||||
|
||||
Point_2 small_x_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_x_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p1);
|
||||
else
|
||||
return(p2);
|
||||
}
|
||||
|
||||
Point_2 small_y_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_y_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p1);
|
||||
else
|
||||
return(p2);
|
||||
}
|
||||
|
||||
Point_2 big_x_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_x_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p2);
|
||||
else
|
||||
return(p1);
|
||||
}
|
||||
|
||||
Point_2 big_y_point(Point_2 p1,Point_2 p2)
|
||||
{
|
||||
Comparison_result c = compare_y_2_object()(p1,p2);
|
||||
if(c == SMALLER)
|
||||
return(p2);
|
||||
else
|
||||
return(p1);
|
||||
}
|
||||
|
||||
void init_angle_appr()
|
||||
{
|
||||
angle_to_sines_appr[0] = NT(0);
|
||||
angle_to_sines_appr[1] = NT(115) / NT(6613);
|
||||
angle_to_sines_appr[2] = NT(57) / NT(1625);
|
||||
angle_to_sines_appr[3] = NT(39) / NT(761);
|
||||
angle_to_sines_appr[4] = NT(29) / NT(421);
|
||||
angle_to_sines_appr[5] = NT(23) / NT(265);
|
||||
angle_to_sines_appr[6] = NT(19) / NT(181);
|
||||
angle_to_sines_appr[7] = NT(32) / NT(257);
|
||||
angle_to_sines_appr[8] = NT(129) / NT(929);
|
||||
angle_to_sines_appr[9] = NT(100) / NT(629);
|
||||
angle_to_sines_appr[10] = NT(92) / NT(533);
|
||||
angle_to_sines_appr[11] = NT(93) / NT(485);
|
||||
angle_to_sines_appr[12] = NT(76) / NT(365);
|
||||
angle_to_sines_appr[13] = NT(156) / NT(685);
|
||||
angle_to_sines_appr[14] = NT(205) / NT(853);
|
||||
angle_to_sines_appr[15] = NT(69) / NT(269);
|
||||
angle_to_sines_appr[16] = NT(7) / NT(25);
|
||||
angle_to_sines_appr[17] = NT(120) / NT(409);
|
||||
angle_to_sines_appr[18] = NT(57) / NT(185);
|
||||
angle_to_sines_appr[19] = NT(12) / NT(37);
|
||||
angle_to_sines_appr[20] = NT(51) / NT(149);
|
||||
angle_to_sines_appr[21] = NT(135) / NT(377);
|
||||
angle_to_sines_appr[22] = NT(372) / NT(997);
|
||||
angle_to_sines_appr[23] = NT(348) / NT(877);
|
||||
angle_to_sines_appr[24] = NT(231) / NT(569);
|
||||
angle_to_sines_appr[25] = NT(36) / NT(85);
|
||||
angle_to_sines_appr[26] = NT(39) / NT(89);
|
||||
angle_to_sines_appr[27] = NT(300) / NT(661);
|
||||
angle_to_sines_appr[28] = NT(8) / NT(17);
|
||||
angle_to_sines_appr[29] = NT(189) / NT(389);
|
||||
angle_to_sines_appr[30] = NT(451) / NT(901);
|
||||
angle_to_sines_appr[31] = NT(180) / NT(349);
|
||||
angle_to_sines_appr[32] = NT(28) / NT(53);
|
||||
angle_to_sines_appr[33] = NT(432) / NT(793);
|
||||
angle_to_sines_appr[34] = NT(161) / NT(289);
|
||||
angle_to_sines_appr[35] = NT(228) / NT(397);
|
||||
angle_to_sines_appr[36] = NT(504) / NT(865);
|
||||
angle_to_sines_appr[37] = NT(3) / NT(5);
|
||||
angle_to_sines_appr[38] = NT(580) / NT(941);
|
||||
angle_to_sines_appr[39] = NT(341) / NT(541);
|
||||
angle_to_sines_appr[40] = NT(88) / NT(137);
|
||||
angle_to_sines_appr[41] = NT(48) / NT(73);
|
||||
angle_to_sines_appr[42] = NT(65) / NT(97);
|
||||
angle_to_sines_appr[43] = NT(429) / NT(629);
|
||||
angle_to_sines_appr[44] = NT(555) / NT(797);
|
||||
angle_to_sines_appr[45] = NT(697) / NT(985);
|
||||
angle_to_sines_appr[46] = NT(572) / NT(797);
|
||||
angle_to_sines_appr[47] = NT(460) / NT(629);
|
||||
angle_to_sines_appr[48] = NT(72) / NT(97);
|
||||
angle_to_sines_appr[49] = NT(55) / NT(73);
|
||||
angle_to_sines_appr[50] = NT(105) / NT(137);
|
||||
angle_to_sines_appr[51] = NT(420) / NT(541);
|
||||
angle_to_sines_appr[52] = NT(741) / NT(941);
|
||||
angle_to_sines_appr[53] = NT(4) / NT(5);
|
||||
angle_to_sines_appr[54] = NT(703) / NT(865);
|
||||
angle_to_sines_appr[55] = NT(325) / NT(397);
|
||||
angle_to_sines_appr[56] = NT(240) / NT(289);
|
||||
angle_to_sines_appr[57] = NT(665) / NT(793);
|
||||
angle_to_sines_appr[58] = NT(45) / NT(53);
|
||||
angle_to_sines_appr[59] = NT(299) / NT(349);
|
||||
angle_to_sines_appr[60] = NT(780) / NT(901);
|
||||
angle_to_sines_appr[61] = NT(340) / NT(389);
|
||||
angle_to_sines_appr[62] = NT(15) / NT(17);
|
||||
angle_to_sines_appr[63] = NT(589) / NT(661);
|
||||
angle_to_sines_appr[64] = NT(80) / NT(89);
|
||||
angle_to_sines_appr[65] = NT(77) / NT(85);
|
||||
angle_to_sines_appr[66] = NT(520) / NT(569);
|
||||
angle_to_sines_appr[67] = NT(805) / NT(877);
|
||||
angle_to_sines_appr[68] = NT(925) / NT(997);
|
||||
angle_to_sines_appr[69] = NT(352) / NT(377);
|
||||
angle_to_sines_appr[70] = NT(140) / NT(149);
|
||||
angle_to_sines_appr[71] = NT(35) / NT(37);
|
||||
angle_to_sines_appr[72] = NT(176) / NT(185);
|
||||
angle_to_sines_appr[73] = NT(391) / NT(409);
|
||||
angle_to_sines_appr[74] = NT(24) / NT(25);
|
||||
angle_to_sines_appr[75] = NT(260) / NT(269);
|
||||
angle_to_sines_appr[76] = NT(828) / NT(853);
|
||||
angle_to_sines_appr[77] = NT(667) / NT(685);
|
||||
angle_to_sines_appr[78] = NT(357) / NT(365);
|
||||
angle_to_sines_appr[79] = NT(476) / NT(485);
|
||||
angle_to_sines_appr[80] = NT(525) / NT(533);
|
||||
angle_to_sines_appr[81] = NT(621) / NT(629);
|
||||
angle_to_sines_appr[82] = NT(920) / NT(929);
|
||||
angle_to_sines_appr[83] = NT(255) / NT(257);
|
||||
angle_to_sines_appr[84] = NT(180) / NT(181);
|
||||
angle_to_sines_appr[85] = NT(264) / NT(265);
|
||||
angle_to_sines_appr[86] = NT(420) / NT(421);
|
||||
angle_to_sines_appr[87] = NT(760) / NT(761);
|
||||
angle_to_sines_appr[88] = NT(1624) / NT(1625);
|
||||
angle_to_sines_appr[89] = NT(6612) / NT(6613);
|
||||
angle_to_sines_appr[90] = NT(1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_ISR_2_TRAITS_H
|
||||
|
|
@ -13,6 +13,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
#else
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include "../../include/CGAL/Snap_rounding_2_traits.h"
|
||||
#include "../../include/CGAL/Snap_rounding_2.h"
|
||||
|
||||
typedef leda_rational Number_Type;
|
||||
|
|
|
|||
Loading…
Reference in New Issue