mirror of https://github.com/CGAL/cgal
improve traits
This commit is contained in:
parent
051eac1dc4
commit
8df682f7f4
|
|
@ -24,8 +24,9 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <CGAL/leda_integer.h>
|
||||
#include <CGAL/leda_integer.h>
|
||||
#include "../../include/CGAL/Snap_rounding_2_utility.h"
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
|
@ -118,71 +119,67 @@ class Bounding_box_of_minkowski_sum_2 {
|
|||
return(p1);
|
||||
}
|
||||
|
||||
void minkowski_sum(std::list<Point_2>& points_list,Segment_2 s,NT unit_squere)
|
||||
{
|
||||
Comparison_result cx = _gt->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();
|
||||
Point_2 ms1,ms2,ms3,ms4,ms5,ms6;// minkowski sum points
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
points_list.push_back(ms1);
|
||||
points_list.push_back(ms2);
|
||||
points_list.push_back(ms3);
|
||||
points_list.push_back(ms4);
|
||||
points_list.push_back(ms5);
|
||||
points_list.push_back(ms6);
|
||||
}
|
||||
|
||||
public:
|
||||
Iso_rectangle_2 operator()(Segment_2 s,
|
||||
NT unit_squere,
|
||||
NT angle)
|
||||
{
|
||||
Point_2 ms1,ms2,ms3,ms4,ms5,ms6;// minkowski sum points
|
||||
std::list<Point_2> points_list;
|
||||
|
||||
Comparison_result cx = _gt->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);
|
||||
}
|
||||
minkowski_sum(points_list,s,unit_squere);
|
||||
|
||||
static Snap_rounding_rotation<base_rep> r;
|
||||
r(ms1,angle);
|
||||
r(ms2,angle);
|
||||
r(ms3,angle);
|
||||
r(ms4,angle);
|
||||
r(ms5,angle);
|
||||
r(ms6,angle);
|
||||
|
||||
typename std::list<Point_2>::iterator iter;
|
||||
|
||||
for(iter = points_list.begin();iter != points_list.end();++iter)
|
||||
r(*iter,angle);
|
||||
|
||||
// query
|
||||
iter = points_list.begin();
|
||||
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);
|
||||
point_left = point_right = point_bot = point_top = *iter;
|
||||
for(++iter;iter != points_list.end();++iter) {
|
||||
point_left = small_x_point(point_left,*iter);
|
||||
point_right = big_x_point(point_right,*iter);
|
||||
point_bot = small_y_point(point_bot,*iter);
|
||||
point_top = big_y_point(point_top,*iter);
|
||||
}
|
||||
|
||||
Iso_rectangle_2 rec(point_left,point_right,point_bot,point_top);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue