mirror of https://github.com/CGAL/cgal
Pretty-print headers using astyle with the following configuration:
--add-brackets --align-pointer=name --break-blocks --convert-tabs --pad-header --pad-oper --style=attach --unpad-paren
This commit is contained in:
parent
cfc89c5744
commit
26fa63eff1
|
|
@ -10,16 +10,14 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
double eps(double x)
|
||||
{
|
||||
double eps(double x) {
|
||||
//return nextafter(x, DBL_MAX) - x;
|
||||
return CGAL::abs(CGAL::nextafter(x, DBL_MAX) - x);
|
||||
//CGAL::nextafter(
|
||||
}
|
||||
|
||||
template<typename GeomTraits, typename AABB_primitive>
|
||||
class AABB_traits_2
|
||||
{
|
||||
class AABB_traits_2 {
|
||||
public:
|
||||
typedef AABB_traits_2<GeomTraits, AABB_primitive> AT;
|
||||
/// AABBTraits concept types
|
||||
|
|
@ -53,8 +51,7 @@ class AABB_traits_2
|
|||
Construct_cartesian_const_iterator_3;
|
||||
|
||||
/// Constructor
|
||||
AABB_traits_2(const Point& point,const Container& p,const Container& q):m_t_point(point),m_p(p),m_q(q)
|
||||
{
|
||||
AABB_traits_2(const Point &point, const Container &p, const Container &q): m_t_point(point), m_p(p), m_q(q) {
|
||||
//GeomTraits::ComputeX_2 c_x_o;
|
||||
//GeomTraits::ComputeY_2 c_y_o;
|
||||
m_x_interval = Interval_nt<true>(CGAL::to_interval(point.x()));
|
||||
|
|
@ -63,20 +60,29 @@ class AABB_traits_2
|
|||
m_py = CGAL::to_double(point.y());
|
||||
};
|
||||
|
||||
AABB_traits_2():m_p(Container()),m_q(Container())
|
||||
{
|
||||
AABB_traits_2(): m_p(Container()), m_q(Container()) {
|
||||
|
||||
};
|
||||
|
||||
/// Non-virtual Destructor
|
||||
~AABB_traits_2() { };
|
||||
|
||||
Interval_nt<true> getIntX() const{return m_x_interval;}
|
||||
Interval_nt<true> getIntY() const{return m_y_interval;}
|
||||
Interval_nt<true> getIntX() const {
|
||||
return m_x_interval;
|
||||
}
|
||||
Interval_nt<true> getIntY() const {
|
||||
return m_y_interval;
|
||||
}
|
||||
|
||||
Point getTPoint() const{return m_t_point;}
|
||||
const Container& get_p() const{return m_p;}
|
||||
const Container& get_q() const{return m_q;}
|
||||
Point getTPoint() const {
|
||||
return m_t_point;
|
||||
}
|
||||
const Container &get_p() const {
|
||||
return m_p;
|
||||
}
|
||||
const Container &get_q() const {
|
||||
return m_q;
|
||||
}
|
||||
///
|
||||
/**
|
||||
* @brief Sorts [first,beyond[
|
||||
|
|
@ -88,34 +94,37 @@ class AABB_traits_2
|
|||
* axis, using the comparison function <dim>_less_than (dim in {x,y,z})
|
||||
*/
|
||||
|
||||
class Sort_primitives
|
||||
{
|
||||
class Sort_primitives {
|
||||
public:
|
||||
template<typename PrimitiveIterator>
|
||||
void operator()(PrimitiveIterator first,
|
||||
PrimitiveIterator beyond,
|
||||
const typename AT::Bounding_box& bbox) const
|
||||
{
|
||||
const typename AT::Bounding_box &bbox) const {
|
||||
PrimitiveIterator middle = first + (beyond - first) / 2;
|
||||
switch(longest_axis(bbox))
|
||||
{
|
||||
|
||||
switch (longest_axis(bbox)) {
|
||||
case AT::CGAL_AXIS_X: // sort along x
|
||||
std::nth_element(first, middle, beyond, less_x);
|
||||
break;
|
||||
|
||||
case AT::CGAL_AXIS_Y: // sort along y
|
||||
std::nth_element(first, middle, beyond, less_y);
|
||||
break;
|
||||
|
||||
case AT::CGAL_AXIS_Z: // sort along z
|
||||
CGAL_error();
|
||||
//std::nth_element(first, middle, beyond, less_z);
|
||||
break;
|
||||
|
||||
default:
|
||||
CGAL_error();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Sort_primitives sort_primitives_object() {return Sort_primitives();}
|
||||
Sort_primitives sort_primitives_object() {
|
||||
return Sort_primitives();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -129,18 +138,20 @@ Sort_primitives sort_primitives_object() {return Sort_primitives();}
|
|||
public:
|
||||
template<typename ConstPrimitiveIterator>
|
||||
typename AT::Bounding_box operator()(ConstPrimitiveIterator first,
|
||||
ConstPrimitiveIterator beyond) const
|
||||
{
|
||||
ConstPrimitiveIterator beyond) const {
|
||||
typename AT::Bounding_box bbox = compute_bbox(*first);
|
||||
for(++first; first != beyond; ++first)
|
||||
{
|
||||
|
||||
for (++first; first != beyond; ++first) {
|
||||
bbox = bbox + compute_bbox(*first);
|
||||
}
|
||||
|
||||
return bbox;
|
||||
}
|
||||
};
|
||||
|
||||
Compute_bbox compute_bbox_object() {return Compute_bbox();}
|
||||
Compute_bbox compute_bbox_object() {
|
||||
return Compute_bbox();
|
||||
}
|
||||
|
||||
|
||||
class Do_intersect {
|
||||
|
|
@ -151,8 +162,7 @@ public:
|
|||
Do_intersect(AABB_traits_2 *_traits): m_traits(_traits) {}
|
||||
|
||||
|
||||
bool operator()(const Bounding_box& q, const Bounding_box& bbox) const
|
||||
{
|
||||
bool operator()(const Bounding_box &q, const Bounding_box &bbox) const {
|
||||
|
||||
/* Code for faster bbox, needs to be tested
|
||||
// Get x max error.
|
||||
|
|
@ -178,8 +188,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
bool operator()(const Primitive& q, const Bounding_box& bbox) const
|
||||
{
|
||||
bool operator()(const Primitive &q, const Bounding_box &bbox) const {
|
||||
/* Code for faster bbox, needs to be tested
|
||||
// Get x max error.
|
||||
double x_epsilon = CGAL::max(CGAL::max(eps(m_traits->m_px),eps(bbox.xmin())),eps(bbox.xmax()))*2;
|
||||
|
|
@ -204,55 +213,49 @@ public:
|
|||
return CGAL::do_overlap(q.datum().bbox(), t_box);
|
||||
}
|
||||
|
||||
bool operator()(const Bounding_box& q, const Primitive& pr) const
|
||||
{
|
||||
bool operator()(const Bounding_box &q, const Primitive &pr) const {
|
||||
|
||||
typename Primitive::Datum tr_pr = pr.datum().transform(typename GeomTraits::Aff_transformation_2(CGAL::Translation(), Vector_2(CGAL::ORIGIN, m_traits->getTPoint())));
|
||||
return CGAL::do_overlap(q, tr_pr.bbox());
|
||||
}
|
||||
|
||||
|
||||
bool operator()(const Primitive& q, const Primitive& pr) const
|
||||
{
|
||||
bool operator()(const Primitive &q, const Primitive &pr) const {
|
||||
|
||||
typename Primitive::Datum tr_pr = pr.datum().transform(typename GeomTraits::Aff_transformation_2(CGAL::Translation(), Vector_2(CGAL::ORIGIN, m_traits->getTPoint())));
|
||||
if (!CGAL::do_overlap(q.datum().bbox(),tr_pr.bbox()))
|
||||
|
||||
if (!CGAL::do_overlap(q.datum().bbox(), tr_pr.bbox())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CGAL::Object intersection_object = GeomTraits().intersect_2_object()(q.datum(), tr_pr);
|
||||
if (const CGAL::Point_2<GeomTraits> *ipoint = CGAL::object_cast<CGAL::Point_2<GeomTraits> >(&intersection_object))
|
||||
{ // handle weak intersections
|
||||
|
||||
if (const CGAL::Point_2<GeomTraits> *ipoint = CGAL::object_cast<CGAL::Point_2<GeomTraits> >(&intersection_object)) {
|
||||
// handle weak intersections
|
||||
bool has_weak_intersection = false;
|
||||
bool p_intersect = false;
|
||||
bool p_intersect_start = false;
|
||||
bool q_intersect = false;
|
||||
bool q_intersect_start = false;
|
||||
|
||||
if (*ipoint == tr_pr.source ())
|
||||
{
|
||||
if (*ipoint == tr_pr.source()) {
|
||||
has_weak_intersection = true;
|
||||
p_intersect = true;
|
||||
p_intersect_start = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ipoint == tr_pr.target())
|
||||
{
|
||||
} else {
|
||||
if (*ipoint == tr_pr.target()) {
|
||||
has_weak_intersection = true;
|
||||
p_intersect = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (*ipoint == q.datum().source () )
|
||||
{
|
||||
if (*ipoint == q.datum().source()) {
|
||||
has_weak_intersection = true;
|
||||
q_intersect = true;
|
||||
q_intersect_start = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ipoint == q.datum().target())
|
||||
{
|
||||
} else {
|
||||
if (*ipoint == q.datum().target()) {
|
||||
q_intersect = true;
|
||||
has_weak_intersection = true;
|
||||
}
|
||||
|
|
@ -260,12 +263,11 @@ public:
|
|||
}
|
||||
|
||||
|
||||
if (has_weak_intersection)
|
||||
{
|
||||
if (has_weak_intersection) {
|
||||
|
||||
bool val = handleWeakIntersections(p_intersect, q_intersect, p_intersect_start, q_intersect_start, pr, q, tr_pr);
|
||||
if (val == false)
|
||||
{
|
||||
|
||||
if (val == false) {
|
||||
int k = 4;
|
||||
k = k + 4;
|
||||
k++;
|
||||
|
|
@ -274,12 +276,12 @@ public:
|
|||
|
||||
return val;
|
||||
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (const CGAL::Segment_2<GeomTraits> *iseg = CGAL::object_cast<CGAL::Segment_2<GeomTraits> >(&intersection_object)) // we have overlapping segments
|
||||
{
|
||||
}
|
||||
|
||||
if (const CGAL::Segment_2<GeomTraits> *iseg = CGAL::object_cast<CGAL::Segment_2<GeomTraits> >(&intersection_object)) { // we have overlapping segments
|
||||
//GeomTraits::CompareXY_2 t_compare_endpoints_xy_2_obj = GeomTraits().CompareXY_2();
|
||||
//CGAL::Comparison_result c1 =t_compare_endpoints_xy_2_obj(tr_pr);
|
||||
//CGAL::Comparison_result c2 = t_compare_endpoints_xy_2_obj(q.datum());
|
||||
|
|
@ -296,43 +298,42 @@ public:
|
|||
|
||||
bool same_dir = (c1 == c2);
|
||||
return same_dir;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return false; // no intersection
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool handleWeakIntersections(bool p_intersect,bool q_intersect,bool p_intersect_start,bool q_intersect_start,const Primitive& p,const Primitive& q,const Datum& tr_pr_datum) const
|
||||
{
|
||||
bool handleWeakIntersections(bool p_intersect, bool q_intersect, bool p_intersect_start, bool q_intersect_start, const Primitive &p, const Primitive &q, const Datum &tr_pr_datum) const {
|
||||
Id itr_p = p.id();
|
||||
Id itr_q = q.id();
|
||||
Id p_other = getOtherSegment(p_intersect_start, itr_p, m_traits->get_p());
|
||||
Id q_other = getOtherSegment(q_intersect_start, itr_q, m_traits->get_q());
|
||||
Datum p_other_translated = (*p_other).transform(typename GeomTraits::Aff_transformation_2(CGAL::Translation(), Vector_2(CGAL::ORIGIN, m_traits->getTPoint())));
|
||||
if (p_intersect && !q_intersect){
|
||||
if (p_intersect_start)
|
||||
return handle_one_weak_int(p_other_translated,tr_pr_datum,*itr_q);
|
||||
else
|
||||
return handle_one_weak_int(tr_pr_datum,p_other_translated,*itr_q);
|
||||
|
||||
if (p_intersect && !q_intersect) {
|
||||
if (p_intersect_start) {
|
||||
return handle_one_weak_int(p_other_translated, tr_pr_datum, *itr_q);
|
||||
} else {
|
||||
return handle_one_weak_int(tr_pr_datum, p_other_translated, *itr_q);
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
if (!p_intersect && q_intersect) {
|
||||
if (q_intersect_start)
|
||||
if (q_intersect_start) {
|
||||
return handle_one_weak_int(*q_other, *itr_q, tr_pr_datum);
|
||||
else
|
||||
} else {
|
||||
return handle_one_weak_int(*itr_q, *q_other, tr_pr_datum);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Datum first_p, second_p;
|
||||
Datum first_q, second_q;
|
||||
|
||||
if (p_intersect_start) {
|
||||
first_p = p_other_translated;
|
||||
second_p = tr_pr_datum;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
first_p = tr_pr_datum;
|
||||
second_p = p_other_translated;
|
||||
}
|
||||
|
|
@ -340,8 +341,7 @@ public:
|
|||
if (q_intersect_start) {
|
||||
first_q = *q_other;
|
||||
second_q = *itr_q;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
first_q = *itr_q;
|
||||
second_q = *q_other;
|
||||
}
|
||||
|
|
@ -352,8 +352,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
bool handle_one_weak_int(const Datum& incoming,const Datum& outgoing,const Datum& other_segment) const
|
||||
{
|
||||
bool handle_one_weak_int(const Datum &incoming, const Datum &outgoing, const Datum &other_segment) const {
|
||||
// There is an overlap in polygon regions if the outgoing of p is ccw-between outgoing q and -incoming q or vice versa.
|
||||
//return (other_segment.direction()).counterclockwise_in_between(outgoing.direction(),incoming.opposite().direction());
|
||||
return (other_segment.direction()).counterclockwise_in_between(outgoing.direction(), incoming.opposite().direction()) ||
|
||||
|
|
@ -361,76 +360,76 @@ public:
|
|||
|
||||
}
|
||||
|
||||
bool check_overlapping(const Datum& incoming_p,const Datum& outgoing_p,const Datum& incoming_q,const Datum& outgoing_q) const
|
||||
{
|
||||
bool check_overlapping(const Datum &incoming_p, const Datum &outgoing_p, const Datum &incoming_q, const Datum &outgoing_q) const {
|
||||
// There is an overlap in polygon regions if the outgoing of p is ccw-between outgoing q and -incoming q or vice versa.
|
||||
return ((outgoing_q.direction()).counterclockwise_in_between(outgoing_p.direction(), incoming_p.opposite().direction()) ||
|
||||
(outgoing_p.direction()).counterclockwise_in_between(outgoing_q.direction(), incoming_q.opposite().direction()));
|
||||
}
|
||||
|
||||
Id getOtherSegment(bool start,const Id& itr_p,const Container& cont) const
|
||||
{
|
||||
Id getOtherSegment(bool start, const Id &itr_p, const Container &cont) const {
|
||||
Id p_other;
|
||||
if (start)
|
||||
{
|
||||
|
||||
if (start) {
|
||||
p_other = cont.edges_begin();
|
||||
if (p_other == itr_p)
|
||||
{
|
||||
|
||||
if (p_other == itr_p) {
|
||||
p_other = cont.edges_end();
|
||||
--p_other;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (p_other != itr_p)
|
||||
} else {
|
||||
while (p_other != itr_p) {
|
||||
++p_other;
|
||||
}
|
||||
|
||||
--p_other;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_other = cont.edges_end();
|
||||
--p_other;
|
||||
if (p_other == itr_p)
|
||||
{
|
||||
|
||||
if (p_other == itr_p) {
|
||||
p_other = cont.edges_begin();
|
||||
// ++p_other;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (p_other != itr_p)
|
||||
} else {
|
||||
while (p_other != itr_p) {
|
||||
--p_other;
|
||||
}
|
||||
|
||||
++p_other;
|
||||
}
|
||||
}
|
||||
|
||||
return p_other;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Do_intersect do_intersect_object() {return Do_intersect(this);}
|
||||
Do_intersect do_intersect_object() {
|
||||
return Do_intersect(this);
|
||||
}
|
||||
|
||||
class Intersection {
|
||||
public:
|
||||
template<typename Query>
|
||||
boost::optional<typename AT::Object_and_primitive_id>
|
||||
operator()(const Query& query, const typename AT::Primitive& primitive) const
|
||||
{
|
||||
operator()(const Query &query, const typename AT::Primitive &primitive) const {
|
||||
typedef boost::optional<Object_and_primitive_id> Intersection;
|
||||
|
||||
CGAL::Object object = GeomTraits().intersect_2_object()(primitive.datum(), query);
|
||||
if ( object.empty() )
|
||||
|
||||
if (object.empty()) {
|
||||
return Intersection();
|
||||
else
|
||||
} else {
|
||||
return Intersection(Object_and_primitive_id(object, primitive.id()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Intersection intersection_object() {return Intersection();}
|
||||
Intersection intersection_object() {return Do_intersect(this);}
|
||||
Intersection intersection_object() {
|
||||
return Do_intersect(this);
|
||||
}
|
||||
|
||||
|
||||
// This should go down to the GeomTraits, i.e. the kernel
|
||||
|
|
@ -438,8 +437,7 @@ Intersection intersection_object() {return Do_intersect(this);}
|
|||
typedef typename AT::Point Point;
|
||||
typedef typename AT::Primitive Primitive;
|
||||
public:
|
||||
Point operator()(const Point& p, const Primitive& pr, const Point& bound) const
|
||||
{
|
||||
Point operator()(const Point &p, const Primitive &pr, const Point &bound) const {
|
||||
// seems to be unused:
|
||||
//return CGAL::nearest_point_2(p, pr.datum(), bound);
|
||||
return p;
|
||||
|
|
@ -455,8 +453,7 @@ Intersection intersection_object() {return Do_intersect(this);}
|
|||
typedef typename AT::Primitive Primitive;
|
||||
public:
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
|
||||
{
|
||||
CGAL::Comparison_result operator()(const Point &p, const Solid &pr, const Point &bound) const {
|
||||
return GeomTraits().do_intersect_2_object()
|
||||
(GeomTraits().construct_sphere_2_object()
|
||||
(p, GeomTraits().compute_squared_distance_2_object()(p, bound)), pr) ?
|
||||
|
|
@ -464,8 +461,12 @@ Intersection intersection_object() {return Do_intersect(this);}
|
|||
}
|
||||
};
|
||||
|
||||
Closest_point closest_point_object() {return Closest_point();}
|
||||
Compare_distance compare_distance_object() {return Compare_distance();}
|
||||
Closest_point closest_point_object() {
|
||||
return Closest_point();
|
||||
}
|
||||
Compare_distance compare_distance_object() {
|
||||
return Compare_distance();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
|
@ -481,21 +482,23 @@ private:
|
|||
* @param pr the primitive
|
||||
* @return the bounding box of the primitive \c pr
|
||||
*/
|
||||
static Bounding_box compute_bbox(const Primitive& pr)
|
||||
{
|
||||
static Bounding_box compute_bbox(const Primitive &pr) {
|
||||
return pr.datum().bbox();
|
||||
}
|
||||
|
||||
typedef enum { CGAL_AXIS_X = 0,
|
||||
CGAL_AXIS_Y = 1,
|
||||
CGAL_AXIS_Z = 2} Axis;
|
||||
CGAL_AXIS_Z = 2
|
||||
} Axis;
|
||||
|
||||
static Axis longest_axis(const Bounding_box &bbox);
|
||||
/// Comparison functions
|
||||
static bool less_x(const Primitive& pr1, const Primitive& pr2)
|
||||
{ return pr1.reference_point().x() < pr2.reference_point().x(); }
|
||||
static bool less_y(const Primitive& pr1, const Primitive& pr2)
|
||||
{ return pr1.reference_point().y() < pr2.reference_point().y(); }
|
||||
static bool less_x(const Primitive &pr1, const Primitive &pr2) {
|
||||
return pr1.reference_point().x() < pr2.reference_point().x();
|
||||
}
|
||||
static bool less_y(const Primitive &pr1, const Primitive &pr2) {
|
||||
return pr1.reference_point().y() < pr2.reference_point().y();
|
||||
}
|
||||
/* static bool less_z(const Primitive& pr1, const Primitive& pr2)
|
||||
{ return pr1.reference_point().z() < pr2.reference_point().z(); }*/
|
||||
|
||||
|
|
@ -503,15 +506,16 @@ private:
|
|||
|
||||
template<typename GT, typename P>
|
||||
typename AABB_traits_2<GT, P>::Axis
|
||||
AABB_traits_2<GT,P>::longest_axis(const Bounding_box& bbox)
|
||||
{
|
||||
AABB_traits_2<GT, P>::longest_axis(const Bounding_box &bbox) {
|
||||
const double dx = bbox.xmax() - bbox.xmin();
|
||||
const double dy = bbox.ymax() - bbox.ymin();
|
||||
|
||||
// const double dz = bbox.zmax() - bbox.zmin();
|
||||
if (dx>=dy)
|
||||
if (dx >= dy) {
|
||||
return CGAL_AXIS_X;
|
||||
else
|
||||
} else {
|
||||
return CGAL_AXIS_Y;
|
||||
}
|
||||
|
||||
//if(dx>=dy)
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
#include "AABB_2d_traits.h"
|
||||
#include "AABB_segment_2_primitive.h"
|
||||
namespace CGAL {
|
||||
template <class Kernel_, class Container_> class AABBCollisionDetector : public ICollisionDetector< Kernel_, Container_>
|
||||
{
|
||||
template <class Kernel_, class Container_> class AABBCollisionDetector : public ICollisionDetector< Kernel_, Container_> {
|
||||
|
||||
|
||||
|
||||
|
|
@ -29,18 +28,17 @@ protected:
|
|||
|
||||
public:
|
||||
AABBCollisionDetector(Polygon_2 &p, Polygon_2 &q)//:m_stationary_tree((q.edges_begin()),(q.edges_end())),m_translating_tree((p.edges_begin()),(p.edges_end())),m_p(p),m_q(q)
|
||||
:m_stationary_tree((p.edges_begin()),(p.edges_end())),m_translating_tree((q.edges_begin()),(q.edges_end())),m_p(q),m_q(p)
|
||||
{
|
||||
: m_stationary_tree((p.edges_begin()), (p.edges_end())), m_translating_tree((q.edges_begin()), (q.edges_end())), m_p(q), m_q(p) {
|
||||
|
||||
}
|
||||
//typedef typename Polygon_2::Vertex_circulator Vertex_circulator;
|
||||
//typedef typename
|
||||
virtual bool checkCollision(const Polygon_2& p,const Polygon_2& q)
|
||||
{
|
||||
virtual bool checkCollision(const Polygon_2 &p, const Polygon_2 &q) {
|
||||
//Traits_2::Compare_endpoints_xy_2 cmp_obj = m_traits.compare_endpoints_xy_2_object();
|
||||
|
||||
if (m_stationary_tree.do_intersect_join(m_translating_tree,m_translation_point,m_p,m_q))
|
||||
if (m_stationary_tree.do_intersect_join(m_translating_tree, m_translation_point, m_p, m_q)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (p.has_on_bounded_side(*(q.vertices_begin())) || q.has_on_bounded_side(*(p.vertices_begin())));
|
||||
//return true;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ namespace CGAL {
|
|||
*
|
||||
*/
|
||||
template<typename AABBTraits>
|
||||
class AABB_node
|
||||
{
|
||||
class AABB_node {
|
||||
public:
|
||||
typedef typename AABBTraits::Bounding_box Bounding_box;
|
||||
|
||||
|
|
@ -50,7 +49,9 @@ public:
|
|||
~AABB_node() { };
|
||||
|
||||
/// Returns the bounding box of the node
|
||||
Bounding_box bbox() const { return m_bbox; }
|
||||
Bounding_box bbox() const {
|
||||
return m_bbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Builds the tree by recursive expansion.
|
||||
|
|
@ -91,19 +92,31 @@ private:
|
|||
typedef typename AABB_traits::Primitive Primitive;
|
||||
|
||||
/// Helper functions
|
||||
const Node& left_child() const
|
||||
{ return *static_cast<Node*>(m_p_left_child); }
|
||||
const Node& right_child() const
|
||||
{ return *static_cast<Node*>(m_p_right_child); }
|
||||
const Primitive& left_data() const
|
||||
{ return *static_cast<Primitive*>(m_p_left_child); }
|
||||
const Primitive& right_data() const
|
||||
{ return *static_cast<Primitive*>(m_p_right_child); }
|
||||
const Node &left_child() const {
|
||||
return *static_cast<Node *>(m_p_left_child);
|
||||
}
|
||||
const Node &right_child() const {
|
||||
return *static_cast<Node *>(m_p_right_child);
|
||||
}
|
||||
const Primitive &left_data() const {
|
||||
return *static_cast<Primitive *>(m_p_left_child);
|
||||
}
|
||||
const Primitive &right_data() const {
|
||||
return *static_cast<Primitive *>(m_p_right_child);
|
||||
}
|
||||
|
||||
Node& left_child() { return *static_cast<Node*>(m_p_left_child); }
|
||||
Node& right_child() { return *static_cast<Node*>(m_p_right_child); }
|
||||
Primitive& left_data() { return *static_cast<Primitive*>(m_p_left_child); }
|
||||
Primitive& right_data() { return *static_cast<Primitive*>(m_p_right_child); }
|
||||
Node &left_child() {
|
||||
return *static_cast<Node *>(m_p_left_child);
|
||||
}
|
||||
Node &right_child() {
|
||||
return *static_cast<Node *>(m_p_right_child);
|
||||
}
|
||||
Primitive &left_data() {
|
||||
return *static_cast<Primitive *>(m_p_left_child);
|
||||
}
|
||||
Primitive &right_data() {
|
||||
return *static_cast<Primitive *>(m_p_right_child);
|
||||
}
|
||||
|
||||
private:
|
||||
/// node bounding box
|
||||
|
|
@ -128,24 +141,24 @@ template<typename ConstPrimitiveIterator>
|
|||
void
|
||||
AABB_node<Tr>::expand(ConstPrimitiveIterator first,
|
||||
ConstPrimitiveIterator beyond,
|
||||
const std::size_t range)
|
||||
{
|
||||
const std::size_t range) {
|
||||
m_bbox = AABB_traits().compute_bbox_object()(first, beyond);
|
||||
|
||||
// sort primitives along longest axis aabb
|
||||
AABB_traits().sort_primitives_object()(first, beyond, m_bbox);
|
||||
|
||||
switch(range)
|
||||
{
|
||||
switch (range) {
|
||||
case 2:
|
||||
m_p_left_child = &(*first);
|
||||
m_p_right_child = &(*(++first));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
m_p_left_child = &(*first);
|
||||
m_p_right_child = static_cast<Node *>(this) + 1;
|
||||
right_child().expand(first + 1, beyond, 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
const std::size_t new_range = range / 2;
|
||||
m_p_left_child = static_cast<Node *>(this) + 1;
|
||||
|
|
@ -161,36 +174,35 @@ template<class Traversal_traits, class Query>
|
|||
void
|
||||
AABB_node<Tr>::traversal(const Query &query,
|
||||
Traversal_traits &traits,
|
||||
const std::size_t nb_primitives) const
|
||||
{
|
||||
const std::size_t nb_primitives) const {
|
||||
// Recursive traversal
|
||||
switch(nb_primitives)
|
||||
{
|
||||
switch (nb_primitives) {
|
||||
case 2:
|
||||
traits.intersection(query, left_data());
|
||||
if( traits.go_further() )
|
||||
{
|
||||
|
||||
if (traits.go_further()) {
|
||||
traits.intersection(query, right_data());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
traits.intersection(query, left_data());
|
||||
if( traits.go_further() && traits.do_intersect(query, right_child()) )
|
||||
{
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(query, right_child())) {
|
||||
right_child().traversal(query, traits, 2);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if( traits.do_intersect(query, left_child()) )
|
||||
{
|
||||
if (traits.do_intersect(query, left_child())) {
|
||||
left_child().traversal(query, traits, nb_primitives / 2);
|
||||
if( traits.go_further() && traits.do_intersect(query, right_child()) )
|
||||
{
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(query, right_child())) {
|
||||
right_child().traversal(query, traits, nb_primitives - nb_primitives / 2);
|
||||
}
|
||||
}
|
||||
else if( traits.do_intersect(query, right_child()) )
|
||||
{
|
||||
} else if (traits.do_intersect(query, right_child())) {
|
||||
right_child().traversal(query, traits, nb_primitives - nb_primitives / 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,8 +214,7 @@ template<class Traversal_traits>
|
|||
void
|
||||
AABB_node<Tr>::join_traversal(const AABB_node &other_node,
|
||||
Traversal_traits &traits,
|
||||
const std::size_t nb_primitives_this,const std::size_t nb_primitives_other, bool first_stationary) const
|
||||
{
|
||||
const std::size_t nb_primitives_this, const std::size_t nb_primitives_other, bool first_stationary) const {
|
||||
// Recursive traversal
|
||||
bool first_tree_small = nb_primitives_this <= 3;
|
||||
bool second_tree_small = nb_primitives_other <= 3;
|
||||
|
|
@ -211,35 +222,39 @@ AABB_node<Tr>::join_traversal(const AABB_node& other_node,
|
|||
bool second_tree_even = nb_primitives_other == 2;
|
||||
|
||||
|
||||
if (first_tree_small && second_tree_small)
|
||||
{
|
||||
if (first_tree_small && second_tree_small) {
|
||||
traits.intersection(left_data(), other_node.left_data(), !first_stationary);
|
||||
if (traits.go_further() )
|
||||
{ // 4 cases
|
||||
|
||||
if (traits.go_further()) {
|
||||
// 4 cases
|
||||
if (first_tree_even) {
|
||||
if (second_tree_even) { // 2 and 2
|
||||
traits.intersection(right_data(), other_node.right_data(), !first_stationary);
|
||||
if (traits.go_further())
|
||||
|
||||
if (traits.go_further()) {
|
||||
traits.intersection(right_data(), other_node.left_data(), !first_stationary);
|
||||
if (traits.go_further())
|
||||
}
|
||||
|
||||
if (traits.go_further()) {
|
||||
traits.intersection(left_data(), other_node.right_data(), !first_stationary);
|
||||
}
|
||||
else{ // 2 and 3
|
||||
} else { // 2 and 3
|
||||
if (traits.do_intersect(right_data(), other_node.right_child(), !first_stationary) || traits.do_intersect(left_data(), other_node.right_child(), !first_stationary)) {
|
||||
other_node.right_child().join_traversal(*this, traits, 2, 2, !first_stationary);
|
||||
}
|
||||
|
||||
/*if (traits.go_further() && traits.do_intersect(other_node.right_child(), left_data(),!first_stationary))
|
||||
{
|
||||
other_node.right_child().join_traversal(left_data(),traits,2,1,!first_stationary);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
if (second_tree_even) { // 3 and 2
|
||||
if (traits.do_intersect(right_child(), other_node.right_data(), !first_stationary) || traits.do_intersect(right_child(), other_node.left_data(), !first_stationary)) {
|
||||
right_child().join_traversal(other_node, traits, 2, 2, first_stationary);
|
||||
}
|
||||
|
||||
/*if (traits.go_further() && traits.do_intersect(right_child(), other_node.left_data(),first_stationary))
|
||||
{
|
||||
right_child().join_traversal(other_node.left_data(),traits,2,1,first_stationary);
|
||||
|
|
@ -248,12 +263,12 @@ AABB_node<Tr>::join_traversal(const AABB_node& other_node,
|
|||
if (traits.do_intersect(right_child(), other_node.right_child(), !first_stationary)) {
|
||||
right_child().join_traversal(other_node.right_child(), traits, 2, 2, first_stationary);
|
||||
}
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.left_data(),!first_stationary))
|
||||
{
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.left_data(), !first_stationary)) {
|
||||
right_child().join_traversal(other_node, traits, 2, 3, first_stationary);
|
||||
}
|
||||
if (traits.go_further() && traits.do_intersect(left_data(),other_node.right_child(),!first_stationary))
|
||||
{
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(left_data(), other_node.right_child(), !first_stationary)) {
|
||||
other_node.right_child().join_traversal(*this, traits, 2, 3, !first_stationary);
|
||||
}
|
||||
}
|
||||
|
|
@ -264,57 +279,46 @@ AABB_node<Tr>::join_traversal(const AABB_node& other_node,
|
|||
}
|
||||
|
||||
// first tree is 3 or smaller and second tree is larger
|
||||
if (first_tree_small && !second_tree_small)
|
||||
{
|
||||
if (traits.do_intersect(*this,other_node.left_child(),!first_stationary))
|
||||
{
|
||||
if (first_tree_small && !second_tree_small) {
|
||||
if (traits.do_intersect(*this, other_node.left_child(), !first_stationary)) {
|
||||
other_node.left_child().join_traversal(*this, traits, nb_primitives_other / 2, nb_primitives_this, !first_stationary);
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(*this, other_node.right_child(), !first_stationary)) {
|
||||
other_node.right_child().join_traversal(*this, traits, nb_primitives_other - nb_primitives_other / 2, nb_primitives_this, !first_stationary);
|
||||
}
|
||||
}
|
||||
else if (traits.do_intersect(*this,other_node.right_child(),!first_stationary))
|
||||
{
|
||||
} else if (traits.do_intersect(*this, other_node.right_child(), !first_stationary)) {
|
||||
other_node.right_child().join_traversal(*this, traits, nb_primitives_other - nb_primitives_other / 2, nb_primitives_this, !first_stationary);
|
||||
}
|
||||
}
|
||||
|
||||
// symetrical to previous case.
|
||||
if (!first_tree_small && second_tree_small)
|
||||
{
|
||||
if (traits.do_intersect(left_child(),other_node,!first_stationary))
|
||||
{
|
||||
if (!first_tree_small && second_tree_small) {
|
||||
if (traits.do_intersect(left_child(), other_node, !first_stationary)) {
|
||||
left_child().join_traversal(other_node, traits, nb_primitives_this / 2, nb_primitives_other, first_stationary);
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node, !first_stationary)) {
|
||||
right_child().join_traversal(other_node, traits, nb_primitives_this - nb_primitives_this / 2, nb_primitives_other, first_stationary);
|
||||
}
|
||||
}
|
||||
else if (traits.do_intersect(right_child(),other_node,!first_stationary))
|
||||
{
|
||||
} else if (traits.do_intersect(right_child(), other_node, !first_stationary)) {
|
||||
right_child().join_traversal(other_node, traits, nb_primitives_this - nb_primitives_this / 2, nb_primitives_other, first_stationary);
|
||||
}
|
||||
}
|
||||
|
||||
// both trees as larger then 3
|
||||
if (!first_tree_small && !second_tree_small)
|
||||
{
|
||||
if (traits.do_intersect(left_child(),other_node.left_child(),!first_stationary))
|
||||
{
|
||||
if (!first_tree_small && !second_tree_small) {
|
||||
if (traits.do_intersect(left_child(), other_node.left_child(), !first_stationary)) {
|
||||
left_child().join_traversal(other_node.left_child(), traits, nb_primitives_this / 2, nb_primitives_other / 2, first_stationary);
|
||||
}
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(left_child(), other_node.right_child(),!first_stationary))
|
||||
{
|
||||
if (traits.go_further() && traits.do_intersect(left_child(), other_node.right_child(), !first_stationary)) {
|
||||
left_child().join_traversal(other_node.right_child(), traits, nb_primitives_this / 2, nb_primitives_other - nb_primitives_other / 2, first_stationary);
|
||||
}
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.left_child(),!first_stationary))
|
||||
{
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.left_child(), !first_stationary)) {
|
||||
right_child().join_traversal(other_node.left_child(), traits, nb_primitives_this - nb_primitives_this / 2, nb_primitives_other / 2, first_stationary);
|
||||
}
|
||||
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.right_child(),!first_stationary))
|
||||
{
|
||||
if (traits.go_further() && traits.do_intersect(right_child(), other_node.right_child(), !first_stationary)) {
|
||||
right_child().join_traversal(other_node.right_child(), traits, nb_primitives_this - nb_primitives_this / 2, nb_primitives_other - nb_primitives_other / 2, first_stationary);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Iterator, class Container_type>
|
||||
class AABB_segment_2_primitive
|
||||
{
|
||||
class AABB_segment_2_primitive {
|
||||
// types
|
||||
public:
|
||||
typedef typename GeomTraits::Point_2 Point; // point type
|
||||
|
|
@ -46,23 +45,31 @@ public:
|
|||
// constructors
|
||||
AABB_segment_2_primitive() {}
|
||||
AABB_segment_2_primitive(Id it)
|
||||
: m_it(it)
|
||||
{
|
||||
: m_it(it) {
|
||||
m_datum = *it; // copy segment
|
||||
}
|
||||
AABB_segment_2_primitive(const AABB_segment_2_primitive& primitive)
|
||||
{
|
||||
AABB_segment_2_primitive(const AABB_segment_2_primitive &primitive) {
|
||||
m_it = primitive.id();
|
||||
m_datum = primitive.datum();
|
||||
}
|
||||
public:
|
||||
Id& id() { return m_it; }
|
||||
const Id& id() const { return m_it; }
|
||||
Datum& datum() { return m_datum; }
|
||||
const Datum& datum() const { return m_datum; }
|
||||
Id &id() {
|
||||
return m_it;
|
||||
}
|
||||
const Id &id() const {
|
||||
return m_it;
|
||||
}
|
||||
Datum &datum() {
|
||||
return m_datum;
|
||||
}
|
||||
const Datum &datum() const {
|
||||
return m_datum;
|
||||
}
|
||||
|
||||
/// Returns a point on the primitive
|
||||
Point reference_point() const { return m_datum.source(); }
|
||||
Point reference_point() const {
|
||||
return m_datum.source();
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace CGAL
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ namespace CGAL {
|
|||
*
|
||||
*/
|
||||
template <typename AABBTraits>
|
||||
class AABB_tree
|
||||
{
|
||||
class AABB_tree {
|
||||
public:
|
||||
/// types
|
||||
typedef typename AABBTraits::FT FT;
|
||||
|
|
@ -88,14 +87,12 @@ namespace CGAL {
|
|||
void rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond);
|
||||
|
||||
/// Non virtual destructor
|
||||
~AABB_tree()
|
||||
{
|
||||
~AABB_tree() {
|
||||
clear();
|
||||
}
|
||||
|
||||
/// Clears the tree
|
||||
void clear()
|
||||
{
|
||||
void clear() {
|
||||
// clear AABB tree
|
||||
m_primitives.clear();
|
||||
delete [] m_p_root_node;
|
||||
|
|
@ -105,9 +102,15 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
// bbox and size
|
||||
Bounding_box bbox() const { return m_p_root_node->bbox(); }
|
||||
size_type size() const { return m_primitives.size(); }
|
||||
bool empty() const { return m_primitives.empty(); }
|
||||
Bounding_box bbox() const {
|
||||
return m_p_root_node->bbox();
|
||||
}
|
||||
size_type size() const {
|
||||
return m_primitives.size();
|
||||
}
|
||||
bool empty() const {
|
||||
return m_primitives.empty();
|
||||
}
|
||||
|
||||
/// Construct internal search tree with a given point set
|
||||
// returns true iff successful memory allocation
|
||||
|
|
@ -153,8 +156,7 @@ namespace CGAL {
|
|||
private:
|
||||
|
||||
// clears internal KD tree
|
||||
void clear_search_tree()
|
||||
{
|
||||
void clear_search_tree() {
|
||||
/* delete m_p_search_tree;
|
||||
m_p_search_tree = NULL;
|
||||
m_search_tree_constructed = false;*/
|
||||
|
|
@ -165,23 +167,21 @@ namespace CGAL {
|
|||
|
||||
/// generic traversal of the tree
|
||||
template <class Query, class Traversal_traits>
|
||||
void traversal(const Query& query, Traversal_traits& traits) const
|
||||
{
|
||||
if(!empty())
|
||||
void traversal(const Query &query, Traversal_traits &traits) const {
|
||||
if (!empty()) {
|
||||
m_p_root_node->template traversal<Traversal_traits, Query>(query, traits, m_primitives.size());
|
||||
else
|
||||
} else {
|
||||
std::cerr << "AABB tree traversal with empty tree" << std::endl;
|
||||
}
|
||||
|
||||
template <class Traversal_traits> void join_traversal(const AABB_tree& other_tree, Traversal_traits& traits) const
|
||||
{
|
||||
if (!empty() && !other_tree.empty())
|
||||
{
|
||||
m_p_root_node->template join_traversal<Traversal_traits>(*(other_tree.m_p_root_node), traits, m_primitives.size(),other_tree.m_primitives.size(),true);
|
||||
}
|
||||
else
|
||||
|
||||
template <class Traversal_traits> void join_traversal(const AABB_tree &other_tree, Traversal_traits &traits) const {
|
||||
if (!empty() && !other_tree.empty()) {
|
||||
m_p_root_node->template join_traversal<Traversal_traits>(*(other_tree.m_p_root_node), traits, m_primitives.size(), other_tree.m_primitives.size(), true);
|
||||
} else {
|
||||
std::cerr << "AABB tree joint traversal with empty tree" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -193,29 +193,32 @@ namespace CGAL {
|
|||
* @class First_intersection_traits
|
||||
*/
|
||||
template<typename Query>
|
||||
class First_intersection_traits
|
||||
{
|
||||
class First_intersection_traits {
|
||||
public:
|
||||
typedef typename boost::optional<Object_and_primitive_id> Result;
|
||||
public:
|
||||
First_intersection_traits()
|
||||
: m_result()
|
||||
{}
|
||||
: m_result() {
|
||||
}
|
||||
|
||||
bool go_further() const { return !m_result; }
|
||||
bool go_further() const {
|
||||
return !m_result;
|
||||
}
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
m_result = AABBTraits().intersection_object()(query, primitive);
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
Result result() const { return m_result; }
|
||||
bool is_intersection_found() const { return m_result; }
|
||||
Result result() const {
|
||||
return m_result;
|
||||
}
|
||||
bool is_intersection_found() const {
|
||||
return m_result;
|
||||
}
|
||||
|
||||
private:
|
||||
Result m_result;
|
||||
|
|
@ -226,29 +229,29 @@ namespace CGAL {
|
|||
* @class Counting_traits
|
||||
*/
|
||||
template<typename Query>
|
||||
class Counting_traits
|
||||
{
|
||||
class Counting_traits {
|
||||
public:
|
||||
Counting_traits()
|
||||
: m_nb_intersections(0)
|
||||
{}
|
||||
: m_nb_intersections(0) {
|
||||
}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
bool go_further() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().do_intersect_object()(query, primitive) )
|
||||
{
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
if (AABBTraits().do_intersect_object()(query, primitive)) {
|
||||
++m_nb_intersections;
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
size_type number_of_intersections() const { return m_nb_intersections; }
|
||||
size_type number_of_intersections() const {
|
||||
return m_nb_intersections;
|
||||
}
|
||||
|
||||
private:
|
||||
size_type m_nb_intersections;
|
||||
|
|
@ -259,26 +262,25 @@ namespace CGAL {
|
|||
* @class Listing_intersection_traits
|
||||
*/
|
||||
template<typename Query, typename Output_iterator>
|
||||
class Listing_intersection_traits
|
||||
{
|
||||
class Listing_intersection_traits {
|
||||
public:
|
||||
Listing_intersection_traits(Output_iterator out_it)
|
||||
: m_out_it(out_it) {}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
bool go_further() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
boost::optional<Object_and_primitive_id> intersection;
|
||||
intersection = AABBTraits().intersection_object()(query, primitive);
|
||||
if(intersection)
|
||||
{
|
||||
|
||||
if (intersection) {
|
||||
*m_out_it++ = *intersection;
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
|
|
@ -291,24 +293,22 @@ namespace CGAL {
|
|||
* @class Listing_primitive_traits
|
||||
*/
|
||||
template<typename Query, typename Output_iterator>
|
||||
class Listing_primitive_traits
|
||||
{
|
||||
class Listing_primitive_traits {
|
||||
public:
|
||||
Listing_primitive_traits(Output_iterator out_it)
|
||||
: m_out_it(out_it) {}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
bool go_further() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().do_intersect_object()(query, primitive) )
|
||||
{
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
if (AABBTraits().do_intersect_object()(query, primitive)) {
|
||||
*m_out_it++ = primitive.id();
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
|
|
@ -321,31 +321,33 @@ namespace CGAL {
|
|||
* @class First_primitive_traits
|
||||
*/
|
||||
template<typename Query>
|
||||
class First_primitive_traits
|
||||
{
|
||||
class First_primitive_traits {
|
||||
public:
|
||||
First_primitive_traits()
|
||||
: m_is_found(false)
|
||||
, m_result() {}
|
||||
|
||||
bool go_further() const { return !m_is_found; }
|
||||
bool go_further() const {
|
||||
return !m_is_found;
|
||||
}
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().do_intersect_object()(query, primitive) )
|
||||
{
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
if (AABBTraits().do_intersect_object()(query, primitive)) {
|
||||
m_result = boost::optional<typename Primitive::Id>(primitive.id());
|
||||
m_is_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
boost::optional<typename Primitive::Id> result() const { return m_result; }
|
||||
bool is_intersection_found() const { return m_is_found; }
|
||||
boost::optional<typename Primitive::Id> result() const {
|
||||
return m_result;
|
||||
}
|
||||
bool is_intersection_found() const {
|
||||
return m_is_found;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_found;
|
||||
|
|
@ -356,27 +358,29 @@ namespace CGAL {
|
|||
* @class Do_intersect_traits
|
||||
*/
|
||||
template<typename Query>
|
||||
class Do_intersect_traits
|
||||
{
|
||||
class Do_intersect_traits {
|
||||
public:
|
||||
Do_intersect_traits()
|
||||
: m_is_found(false)
|
||||
{}
|
||||
|
||||
bool go_further() const { return !m_is_found; }
|
||||
|
||||
void intersection(const Query& query, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().do_intersect_object()(query, primitive) )
|
||||
m_is_found = true;
|
||||
: m_is_found(false) {
|
||||
}
|
||||
|
||||
bool do_intersect(const Query& query, const Node& node) const
|
||||
{
|
||||
bool go_further() const {
|
||||
return !m_is_found;
|
||||
}
|
||||
|
||||
void intersection(const Query &query, const Primitive &primitive) {
|
||||
if (AABBTraits().do_intersect_object()(query, primitive)) {
|
||||
m_is_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Query &query, const Node &node) const {
|
||||
return AABBTraits().do_intersect_object()(query, node.bbox());
|
||||
}
|
||||
|
||||
bool is_intersection_found() const { return m_is_found; }
|
||||
bool is_intersection_found() const {
|
||||
return m_is_found;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_found;
|
||||
|
|
@ -384,58 +388,58 @@ namespace CGAL {
|
|||
|
||||
friend class Do_intersect_joined_traits;
|
||||
template<typename Primitive_type>
|
||||
class Do_intersect_joined_traits
|
||||
{
|
||||
class Do_intersect_joined_traits {
|
||||
public:
|
||||
Do_intersect_joined_traits(const Point &point, const Primitive_type &p, const Primitive_type &q)
|
||||
: m_is_found(false) , m_point(point)//, m_p(p),m_q(q)
|
||||
{
|
||||
: m_is_found(false) , m_point(point) { //, m_p(p),m_q(q)
|
||||
m_traits_ptr = new AABBTraits(point, p, q);
|
||||
}
|
||||
|
||||
bool go_further() const { return !m_is_found; }
|
||||
bool go_further() const {
|
||||
return !m_is_found;
|
||||
}
|
||||
|
||||
void intersection(const Primitive& primitive1, const Primitive& primitive2,bool toSwitch)
|
||||
{
|
||||
if (!toSwitch)
|
||||
{
|
||||
if( m_traits_ptr->do_intersect_object()(primitive1, primitive2) )
|
||||
void intersection(const Primitive &primitive1, const Primitive &primitive2, bool toSwitch) {
|
||||
if (!toSwitch) {
|
||||
if (m_traits_ptr->do_intersect_object()(primitive1, primitive2)) {
|
||||
m_is_found = true;
|
||||
}else
|
||||
{
|
||||
if( m_traits_ptr->do_intersect_object()(primitive2, primitive1) )
|
||||
}
|
||||
} else {
|
||||
if (m_traits_ptr->do_intersect_object()(primitive2, primitive1)) {
|
||||
m_is_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Node& node_1, const Node& node_2,bool toSwitch) const
|
||||
{
|
||||
if (!toSwitch)
|
||||
bool do_intersect(const Node &node_1, const Node &node_2, bool toSwitch) const {
|
||||
if (!toSwitch) {
|
||||
return m_traits_ptr->do_intersect_object()(node_1.bbox(), node_2.bbox());
|
||||
else
|
||||
} else {
|
||||
return m_traits_ptr->do_intersect_object()(node_2.bbox(), node_1.bbox());
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Node& node_1, const Primitive& primitive2,bool toSwitch) const
|
||||
{
|
||||
if (!toSwitch)
|
||||
bool do_intersect(const Node &node_1, const Primitive &primitive2, bool toSwitch) const {
|
||||
if (!toSwitch) {
|
||||
return m_traits_ptr->do_intersect_object()(node_1.bbox(), primitive2);
|
||||
else
|
||||
} else {
|
||||
return m_traits_ptr->do_intersect_object()(primitive2, node_1.bbox());
|
||||
}
|
||||
|
||||
bool do_intersect(const Primitive& primitive1,const Node& node_2,bool toSwitch) const
|
||||
{
|
||||
if (!toSwitch)
|
||||
return m_traits_ptr->do_intersect_object()(primitive1,node_2.bbox());
|
||||
else
|
||||
return m_traits_ptr->do_intersect_object()(node_2.bbox(),primitive1);
|
||||
}
|
||||
|
||||
bool is_intersection_found() const { return m_is_found; }
|
||||
bool do_intersect(const Primitive &primitive1, const Node &node_2, bool toSwitch) const {
|
||||
if (!toSwitch) {
|
||||
return m_traits_ptr->do_intersect_object()(primitive1, node_2.bbox());
|
||||
} else {
|
||||
return m_traits_ptr->do_intersect_object()(node_2.bbox(), primitive1);
|
||||
}
|
||||
}
|
||||
|
||||
~Do_intersect_joined_traits()
|
||||
{
|
||||
bool is_intersection_found() const {
|
||||
return m_is_found;
|
||||
}
|
||||
|
||||
~Do_intersect_joined_traits() {
|
||||
delete m_traits_ptr;
|
||||
}
|
||||
|
||||
|
|
@ -451,37 +455,37 @@ namespace CGAL {
|
|||
/**
|
||||
* @class Distance_traits
|
||||
*/
|
||||
class Distance_traits
|
||||
{
|
||||
class Distance_traits {
|
||||
public:
|
||||
Distance_traits(const Point &hint,
|
||||
const typename Primitive::Id &hint_primitive)
|
||||
: m_closest_point(hint),
|
||||
m_closest_primitive(hint_primitive)
|
||||
{}
|
||||
m_closest_primitive(hint_primitive) {
|
||||
}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
bool go_further() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void intersection(const Point& query, const Primitive& primitive)
|
||||
{
|
||||
void intersection(const Point &query, const Primitive &primitive) {
|
||||
Point new_closest_point = AABBTraits().closest_point_object()
|
||||
(query, primitive, m_closest_point);
|
||||
if(new_closest_point != m_closest_point)
|
||||
{
|
||||
|
||||
if (new_closest_point != m_closest_point) {
|
||||
m_closest_primitive = primitive.id();
|
||||
m_closest_point = new_closest_point; // this effectively shrinks the sphere
|
||||
}
|
||||
}
|
||||
|
||||
bool do_intersect(const Point& query, const Node& node) const
|
||||
{
|
||||
bool do_intersect(const Point &query, const Node &node) const {
|
||||
return AABBTraits().compare_distance_object()
|
||||
(query, node.bbox(), m_closest_point) == CGAL::SMALLER;
|
||||
}
|
||||
|
||||
Point closest_point() const { return m_closest_point; }
|
||||
Point_and_primitive_id closest_point_and_primitive() const
|
||||
{
|
||||
Point closest_point() const {
|
||||
return m_closest_point;
|
||||
}
|
||||
Point_and_primitive_id closest_point_and_primitive() const {
|
||||
return Point_and_primitive_id(m_closest_point, m_closest_primitive);
|
||||
}
|
||||
|
||||
|
|
@ -492,15 +496,13 @@ namespace CGAL {
|
|||
|
||||
public:
|
||||
// returns a point which must be on one primitive
|
||||
Point_and_primitive_id any_reference_point_and_id() const
|
||||
{
|
||||
Point_and_primitive_id any_reference_point_and_id() const {
|
||||
CGAL_assertion(!empty());
|
||||
return Point_and_primitive_id(m_primitives[0].reference_point(), m_primitives[0].id());
|
||||
}
|
||||
|
||||
public:
|
||||
Point_and_primitive_id best_hint(const Point& query) const
|
||||
{
|
||||
Point_and_primitive_id best_hint(const Point &query) const {
|
||||
/* if(m_search_tree_constructed)
|
||||
return m_p_search_tree->closest_point(query);
|
||||
else
|
||||
|
|
@ -529,8 +531,8 @@ namespace CGAL {
|
|||
: m_primitives()
|
||||
, m_p_root_node(NULL)
|
||||
//, m_p_search_tree(NULL)
|
||||
, m_search_tree_constructed(false)
|
||||
{ }
|
||||
, m_search_tree_constructed(false) {
|
||||
}
|
||||
|
||||
template<typename Tr>
|
||||
template<typename ConstPrimitiveIterator>
|
||||
|
|
@ -539,47 +541,43 @@ namespace CGAL {
|
|||
: m_primitives()
|
||||
, m_p_root_node(NULL)
|
||||
// , m_p_search_tree(NULL)
|
||||
, m_search_tree_constructed(false)
|
||||
{
|
||||
, m_search_tree_constructed(false) {
|
||||
// Insert each primitive into tree
|
||||
while ( first != beyond )
|
||||
{
|
||||
while (first != beyond) {
|
||||
m_primitives.push_back(Primitive(first));
|
||||
++first;
|
||||
}
|
||||
|
||||
CGAL_assertion(m_primitives.size() > 1);
|
||||
m_p_root_node = new Node[m_primitives.size() - 1]();
|
||||
if(m_p_root_node == NULL)
|
||||
{
|
||||
|
||||
if (m_p_root_node == NULL) {
|
||||
std::cerr << "Unable to allocate memory for AABB tree" << std::endl;
|
||||
CGAL_assertion(m_p_root_node != NULL);
|
||||
m_primitives.clear();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
m_p_root_node->expand(m_primitives.begin(), m_primitives.end(), m_primitives.size());
|
||||
}
|
||||
}
|
||||
|
||||
// Clears tree and insert a set of primitives
|
||||
template<typename Tr>
|
||||
template<typename ConstPrimitiveIterator>
|
||||
void AABB_tree<Tr>::rebuild(ConstPrimitiveIterator first,
|
||||
ConstPrimitiveIterator beyond)
|
||||
{
|
||||
ConstPrimitiveIterator beyond) {
|
||||
// cleanup current tree and internal KD tree
|
||||
clear();
|
||||
|
||||
// inserts primitives
|
||||
while(first != beyond)
|
||||
{
|
||||
while (first != beyond) {
|
||||
m_primitives.push_back(Primitive(first));
|
||||
first++;
|
||||
}
|
||||
|
||||
// allocates tree nodes
|
||||
m_p_root_node = new Node[m_primitives.size() - 1]();
|
||||
if(m_p_root_node == NULL)
|
||||
{
|
||||
|
||||
if (m_p_root_node == NULL) {
|
||||
std::cerr << "Unable to allocate memory for AABB tree" << std::endl;
|
||||
m_primitives.clear();
|
||||
clear();
|
||||
|
|
@ -595,8 +593,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
template<typename ConstPointIterator>
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries(ConstPointIterator first,
|
||||
ConstPointIterator beyond)
|
||||
{
|
||||
ConstPointIterator beyond) {
|
||||
// clears current KD tree
|
||||
//clear_search_tree();
|
||||
|
||||
|
|
@ -615,15 +612,16 @@ namespace CGAL {
|
|||
|
||||
// constructs the search KD tree from internal primitives
|
||||
template<typename Tr>
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries()
|
||||
{
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries() {
|
||||
CGAL_assertion(!m_primitives.empty());
|
||||
|
||||
// iterate over primitives to get reference points on them
|
||||
std::vector<Point_and_primitive_id> points;
|
||||
typename Primitives::const_iterator it;
|
||||
for(it = m_primitives.begin(); it != m_primitives.end(); ++it)
|
||||
|
||||
for (it = m_primitives.begin(); it != m_primitives.end(); ++it) {
|
||||
points.push_back(Point_and_primitive_id(it->reference_point(), it->id()));
|
||||
}
|
||||
|
||||
return accelerate_distance_queries(points.begin(), points.end());
|
||||
}
|
||||
|
|
@ -631,8 +629,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
template<typename Query>
|
||||
bool
|
||||
AABB_tree<Tr>::do_intersect(const Query& query) const
|
||||
{
|
||||
AABB_tree<Tr>::do_intersect(const Query &query) const {
|
||||
Do_intersect_traits<Query> traversal_traits;
|
||||
this->traversal(query, traversal_traits);
|
||||
return traversal_traits.is_intersection_found();
|
||||
|
|
@ -641,8 +638,7 @@ namespace CGAL {
|
|||
|
||||
template<typename Tr>
|
||||
template<typename Primitive_type>
|
||||
bool AABB_tree<Tr>::do_intersect_join(const AABB_tree& other,const Point& Translation_point,const Primitive_type& p,const Primitive_type& q) const
|
||||
{
|
||||
bool AABB_tree<Tr>::do_intersect_join(const AABB_tree &other, const Point &Translation_point, const Primitive_type &p, const Primitive_type &q) const {
|
||||
Do_intersect_joined_traits<Primitive_type> traversal_traits(Translation_point, p, q);
|
||||
this->join_traversal(other, traversal_traits);
|
||||
return traversal_traits.is_intersection_found();
|
||||
|
|
@ -651,8 +647,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
template<typename Query>
|
||||
typename AABB_tree<Tr>::size_type
|
||||
AABB_tree<Tr>::number_of_intersected_primitives(const Query& query) const
|
||||
{
|
||||
AABB_tree<Tr>::number_of_intersected_primitives(const Query &query) const {
|
||||
Counting_traits<Query> traversal_traits;
|
||||
this->traversal(query, traversal_traits);
|
||||
return traversal_traits.number_of_intersections();
|
||||
|
|
@ -662,8 +657,7 @@ namespace CGAL {
|
|||
template<typename Query, typename OutputIterator>
|
||||
OutputIterator
|
||||
AABB_tree<Tr>::all_intersected_primitives(const Query &query,
|
||||
OutputIterator out) const
|
||||
{
|
||||
OutputIterator out) const {
|
||||
Listing_primitive_traits<Query, OutputIterator> traversal_traits(out);
|
||||
this->traversal(query, traversal_traits);
|
||||
return out;
|
||||
|
|
@ -673,8 +667,7 @@ namespace CGAL {
|
|||
template<typename Query, typename OutputIterator>
|
||||
OutputIterator
|
||||
AABB_tree<Tr>::all_intersections(const Query &query,
|
||||
OutputIterator out) const
|
||||
{
|
||||
OutputIterator out) const {
|
||||
Listing_intersection_traits<Query, OutputIterator> traversal_traits(out);
|
||||
this->traversal(query, traversal_traits);
|
||||
return out;
|
||||
|
|
@ -683,8 +676,7 @@ namespace CGAL {
|
|||
template <typename Tr>
|
||||
template <typename Query>
|
||||
boost::optional<typename AABB_tree<Tr>::Object_and_primitive_id>
|
||||
AABB_tree<Tr>::any_intersection(const Query& query) const
|
||||
{
|
||||
AABB_tree<Tr>::any_intersection(const Query &query) const {
|
||||
First_intersection_traits<Query> traversal_traits;
|
||||
this->traversal(query, traversal_traits);
|
||||
return traversal_traits.result();
|
||||
|
|
@ -693,8 +685,7 @@ namespace CGAL {
|
|||
template <typename Tr>
|
||||
template <typename Query>
|
||||
boost::optional<typename AABB_tree<Tr>::Primitive_id>
|
||||
AABB_tree<Tr>::any_intersected_primitive(const Query& query) const
|
||||
{
|
||||
AABB_tree<Tr>::any_intersected_primitive(const Query &query) const {
|
||||
First_primitive_traits<Query> traversal_traits;
|
||||
this->traversal(query, traversal_traits);
|
||||
return traversal_traits.result();
|
||||
|
|
@ -704,8 +695,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Point
|
||||
AABB_tree<Tr>::closest_point(const Point &query,
|
||||
const Point& hint) const
|
||||
{
|
||||
const Point &hint) const {
|
||||
typename Primitive::Id hint_primitive = m_primitives[0].id();
|
||||
Distance_traits distance_traits(hint, hint_primitive);
|
||||
this->traversal(query, distance_traits);
|
||||
|
|
@ -716,8 +706,7 @@ namespace CGAL {
|
|||
// first closest neighbor point to get a hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Point
|
||||
AABB_tree<Tr>::closest_point(const Point& query) const
|
||||
{
|
||||
AABB_tree<Tr>::closest_point(const Point &query) const {
|
||||
const Point_and_primitive_id hint = best_hint(query);
|
||||
return closest_point(query, hint.first);
|
||||
}
|
||||
|
|
@ -726,8 +715,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::FT
|
||||
AABB_tree<Tr>::squared_distance(const Point &query,
|
||||
const Point& hint) const
|
||||
{
|
||||
const Point &hint) const {
|
||||
const Point closest = this->closest_point(query, hint);
|
||||
return typename Tr::Compute_squared_distance_3()(query, closest);
|
||||
}
|
||||
|
|
@ -735,8 +723,7 @@ namespace CGAL {
|
|||
// squared distance without user-specified hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::FT
|
||||
AABB_tree<Tr>::squared_distance(const Point& query) const
|
||||
{
|
||||
AABB_tree<Tr>::squared_distance(const Point &query) const {
|
||||
const Point closest = this->closest_point(query);
|
||||
return typename Tr::Compute_squared_distance_3()(query, closest);
|
||||
}
|
||||
|
|
@ -744,8 +731,7 @@ namespace CGAL {
|
|||
// closest point with user-specified hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Point_and_primitive_id
|
||||
AABB_tree<Tr>::closest_point_and_primitive(const Point& query) const
|
||||
{
|
||||
AABB_tree<Tr>::closest_point_and_primitive(const Point &query) const {
|
||||
return closest_point_and_primitive(query, best_hint(query));
|
||||
}
|
||||
|
||||
|
|
@ -753,8 +739,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Point_and_primitive_id
|
||||
AABB_tree<Tr>::closest_point_and_primitive(const Point &query,
|
||||
const Point_and_primitive_id& hint) const
|
||||
{
|
||||
const Point_and_primitive_id &hint) const {
|
||||
Distance_traits distance_traits(hint.first, hint.second);
|
||||
this->traversal(query, distance_traits);
|
||||
return distance_traits.closest_point_and_primitive();
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ namespace CGAL{
|
|||
//enum Segment_color {MY_RED,MY_BLUE};
|
||||
struct Segment_Data_Label {
|
||||
Segment_Data_Label(state min_id, state max_id, CGAL::Comparison_result orientation, int origin): _min_id(min_id), _max_id(max_id), _orientation(orientation), _origin(origin) {}
|
||||
Segment_Data_Label()
|
||||
{
|
||||
Segment_Data_Label() {
|
||||
_min_id = state(-1, -1);
|
||||
_max_id = state(-1, -1);
|
||||
_orientation = CGAL::SMALLER;
|
||||
|
|
@ -28,8 +27,7 @@ namespace CGAL{
|
|||
state _min_id, _max_id;
|
||||
CGAL::Comparison_result _orientation;
|
||||
int _origin;
|
||||
bool operator==(const Segment_Data_Label& rhs) const
|
||||
{
|
||||
bool operator==(const Segment_Data_Label &rhs) const {
|
||||
//return _color == rhs._color;
|
||||
return (this == &rhs);
|
||||
}
|
||||
|
|
@ -37,8 +35,7 @@ namespace CGAL{
|
|||
|
||||
|
||||
|
||||
template <class Traits_> class Arr_SegmentData_traits : public Traits_//protected Arr_curve_data_traits_2<Traits_,Segment_Data_Label>
|
||||
{
|
||||
template <class Traits_> class Arr_SegmentData_traits : public Traits_ { //protected Arr_curve_data_traits_2<Traits_,Segment_Data_Label>
|
||||
|
||||
public:
|
||||
//typedef Arr_curve_data_traits_2<Traits_,Segment_Data_Label> Base;
|
||||
|
|
@ -72,8 +69,7 @@ public:
|
|||
typedef Tag_false Has_merge_category;
|
||||
// static int count;
|
||||
|
||||
class Ex_point_2
|
||||
{
|
||||
class Ex_point_2 {
|
||||
public:
|
||||
|
||||
typedef Base_point_2 Base_p;
|
||||
|
|
@ -98,26 +94,22 @@ public:
|
|||
|
||||
|
||||
/*! Get the base point (const version). */
|
||||
const Base_p& base () const
|
||||
{
|
||||
const Base_p &base() const {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Get the base point (non-const version). */
|
||||
Base_p& base ()
|
||||
{
|
||||
Base_p &base() {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Casting to a base point (const version). */
|
||||
operator const Base_p& () const
|
||||
{
|
||||
operator const Base_p &() const {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Casting to a base point (non-const version). */
|
||||
operator Base_p& ()
|
||||
{
|
||||
operator Base_p &() {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
|
|
@ -126,8 +118,7 @@ public:
|
|||
|
||||
typedef Ex_point_2 Point_2;
|
||||
|
||||
class X_monotone_curve_2 : public Base_x_monotone_curve_2
|
||||
{
|
||||
class X_monotone_curve_2 : public Base_x_monotone_curve_2 {
|
||||
private:
|
||||
|
||||
Segment_Data_Label _label;
|
||||
|
|
@ -135,47 +126,42 @@ public:
|
|||
public:
|
||||
|
||||
/*! Default constructor. */
|
||||
X_monotone_curve_2 ()
|
||||
{}
|
||||
X_monotone_curve_2() {
|
||||
}
|
||||
|
||||
/*! Constructor from a base x-monotone curve. */
|
||||
X_monotone_curve_2(const Base_x_monotone_curve_2 &p) :
|
||||
Base_x_monotone_curve_2(p),
|
||||
_label()
|
||||
{}
|
||||
_label() {
|
||||
}
|
||||
|
||||
/*! Constructor from an x-monotone curve an a label. */
|
||||
X_monotone_curve_2(const Base_x_monotone_curve_2 &p,
|
||||
const Segment_Data_Label &label) :
|
||||
Base_x_monotone_curve_2(p),
|
||||
_label (label)
|
||||
{}
|
||||
_label(label) {
|
||||
}
|
||||
|
||||
/*! Get the label (const version). */
|
||||
const Segment_Data_Label& label () const
|
||||
{
|
||||
const Segment_Data_Label &label() const {
|
||||
return (_label);
|
||||
}
|
||||
|
||||
const Segment_Data_Label& data () const
|
||||
{
|
||||
const Segment_Data_Label &data() const {
|
||||
return (_label);
|
||||
}
|
||||
|
||||
/*! Get the label (non-const version). */
|
||||
Segment_Data_Label& label ()
|
||||
{
|
||||
Segment_Data_Label &label() {
|
||||
return (_label);
|
||||
}
|
||||
|
||||
Segment_Data_Label& data ()
|
||||
{
|
||||
Segment_Data_Label &data() {
|
||||
return (_label);
|
||||
}
|
||||
|
||||
/*! Set the label. */
|
||||
void set_label (const Segment_Data_Label& label)
|
||||
{
|
||||
void set_label(const Segment_Data_Label &label) {
|
||||
_label = label;
|
||||
return;
|
||||
}
|
||||
|
|
@ -183,8 +169,7 @@ public:
|
|||
|
||||
typedef X_monotone_curve_2 Curve_2;
|
||||
|
||||
class Make_x_monotone_2
|
||||
{
|
||||
class Make_x_monotone_2 {
|
||||
public:
|
||||
/*!
|
||||
* Cut the given curve into x-monotone subcurves and insert them into the
|
||||
|
|
@ -195,8 +180,7 @@ public:
|
|||
* \return The past-the-end iterator.
|
||||
*/
|
||||
template<class OutputIterator>
|
||||
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) const
|
||||
{
|
||||
OutputIterator operator()(const Curve_2 &cv, OutputIterator oi) const {
|
||||
// Wrap the segment with an object.
|
||||
*oi = make_object(cv);
|
||||
++oi;
|
||||
|
|
@ -205,13 +189,11 @@ public:
|
|||
};
|
||||
|
||||
/*! Get a Make_x_monotone_2 functor object. */
|
||||
Make_x_monotone_2 make_x_monotone_2_object () const
|
||||
{
|
||||
Make_x_monotone_2 make_x_monotone_2_object() const {
|
||||
return Make_x_monotone_2();
|
||||
}
|
||||
|
||||
class Split_2
|
||||
{
|
||||
class Split_2 {
|
||||
private:
|
||||
|
||||
const Traits_ *m_traits;
|
||||
|
|
@ -220,27 +202,25 @@ public:
|
|||
|
||||
/*! Constructor. */
|
||||
Split_2(const Base *_base) :
|
||||
m_traits (_base)
|
||||
{}
|
||||
m_traits(_base) {
|
||||
}
|
||||
|
||||
/*!
|
||||
* Split a given x-monotone curve at a given point into two sub-curves.
|
||||
*/
|
||||
void operator()(const X_monotone_curve_2 &cv, const Point_2 &p,
|
||||
X_monotone_curve_2& c1, X_monotone_curve_2& c2) const
|
||||
{
|
||||
X_monotone_curve_2 &c1, X_monotone_curve_2 &c2) const {
|
||||
// Split the base curve into two.
|
||||
m_traits->split_2_object()(cv, p, c1, c2);
|
||||
if (cv.data()._orientation == CGAL::SMALLER)
|
||||
{
|
||||
|
||||
if (cv.data()._orientation == CGAL::SMALLER) {
|
||||
c1.data()._min_id = cv.data()._min_id;
|
||||
c2.data()._max_id = cv.data()._max_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
c1.data()._min_id = cv.data()._max_id;
|
||||
c2.data()._max_id = cv.data()._min_id;
|
||||
}
|
||||
|
||||
c1.data()._orientation = cv.data()._orientation;
|
||||
c2.data()._orientation = cv.data()._orientation;
|
||||
// Duplicate the label to both subcurves.
|
||||
|
|
@ -252,8 +232,7 @@ public:
|
|||
};
|
||||
|
||||
/*! Get a Split_2 functor object. */
|
||||
Split_2 split_2_object () const
|
||||
{
|
||||
Split_2 split_2_object() const {
|
||||
return (Split_2(this));
|
||||
}
|
||||
|
||||
|
|
@ -277,8 +256,7 @@ public:
|
|||
template<class OutputIterator>
|
||||
OutputIterator operator()(const X_monotone_curve_2 &xcv1,
|
||||
const X_monotone_curve_2 &xcv2,
|
||||
OutputIterator oi)
|
||||
{
|
||||
OutputIterator oi) {
|
||||
state no_state = state(-1, -1);
|
||||
// In case the curves originate from the same arrangement, they are
|
||||
// obviously interior-disjoint.
|
||||
|
|
@ -288,12 +266,12 @@ public:
|
|||
//Arr_SegmentData_traits<Traits_>::count++;
|
||||
|
||||
// Ignore edges which originates from the same polygon and are added to the same vertex.
|
||||
if (xcv1.data()._origin == xcv2.data()._origin )
|
||||
{
|
||||
if (xcv1.data()._origin == xcv2.data()._origin) {
|
||||
if ((xcv1.data()._origin == 0 && ((xcv1.data()._min_id.second == xcv2.data()._min_id.second)) ||
|
||||
(xcv1.data()._origin == 1 && ((xcv1.data()._min_id.first == xcv2.data()._min_id.first) ))))
|
||||
(xcv1.data()._origin == 1 && ((xcv1.data()._min_id.first == xcv2.data()._min_id.first))))) {
|
||||
return oi;
|
||||
}
|
||||
}
|
||||
|
||||
Construct_min_vertex_2 min_vertex_obj = m_traits->construct_min_vertex_2_object();
|
||||
Construct_max_vertex_2 max_vertex_obj = m_traits->construct_max_vertex_2_object();
|
||||
|
|
@ -302,45 +280,54 @@ public:
|
|||
|
||||
if ((xcv1.data()._min_id == xcv2.data()._min_id) && (xcv2.data()._min_id != no_state)) {
|
||||
return oi;
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER)
|
||||
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER) {
|
||||
*oi = CGAL::make_object(std::make_pair(min_vertex_obj(xcv1), 1));
|
||||
else
|
||||
} else {
|
||||
*oi = CGAL::make_object(std::make_pair(max_vertex_obj(xcv1), 1));
|
||||
++oi;
|
||||
return oi;
|
||||
//++endp_coll;
|
||||
}
|
||||
if ((xcv1.data()._min_id == xcv2.data()._max_id) && (xcv2.data()._max_id != no_state))
|
||||
{
|
||||
return oi;
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER)
|
||||
*oi = CGAL::make_object(std::make_pair (min_vertex_obj (xcv1),1));
|
||||
else
|
||||
*oi = CGAL::make_object(std::make_pair (max_vertex_obj (xcv1),1));
|
||||
++oi;
|
||||
return oi;
|
||||
// ++endp_coll;
|
||||
}
|
||||
if ((xcv1.data()._max_id == xcv2.data()._min_id) && (xcv2.data()._min_id != no_state))
|
||||
{
|
||||
return oi;
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER)
|
||||
*oi = CGAL::make_object(std::make_pair (max_vertex_obj (xcv1),1));
|
||||
else
|
||||
*oi = CGAL::make_object(std::make_pair (min_vertex_obj (xcv1),1));
|
||||
|
||||
++oi;
|
||||
return oi;
|
||||
//++endp_coll;
|
||||
}
|
||||
|
||||
if ((xcv1.data()._max_id == xcv2.data()._max_id) && (xcv2.data()._max_id != no_state))
|
||||
{
|
||||
if ((xcv1.data()._min_id == xcv2.data()._max_id) && (xcv2.data()._max_id != no_state)) {
|
||||
return oi;
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER)
|
||||
*oi = CGAL::make_object(std::make_pair (max_vertex_obj (xcv1),1));
|
||||
else
|
||||
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER) {
|
||||
*oi = CGAL::make_object(std::make_pair(min_vertex_obj(xcv1), 1));
|
||||
} else {
|
||||
*oi = CGAL::make_object(std::make_pair(max_vertex_obj(xcv1), 1));
|
||||
}
|
||||
|
||||
++oi;
|
||||
return oi;
|
||||
// ++endp_coll;
|
||||
}
|
||||
|
||||
if ((xcv1.data()._max_id == xcv2.data()._min_id) && (xcv2.data()._min_id != no_state)) {
|
||||
return oi;
|
||||
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER) {
|
||||
*oi = CGAL::make_object(std::make_pair(max_vertex_obj(xcv1), 1));
|
||||
} else {
|
||||
*oi = CGAL::make_object(std::make_pair(min_vertex_obj(xcv1), 1));
|
||||
}
|
||||
|
||||
++oi;
|
||||
return oi;
|
||||
// ++endp_coll;
|
||||
}
|
||||
|
||||
if ((xcv1.data()._max_id == xcv2.data()._max_id) && (xcv2.data()._max_id != no_state)) {
|
||||
return oi;
|
||||
|
||||
if (xcv1.data()._orientation == CGAL::SMALLER) {
|
||||
*oi = CGAL::make_object(std::make_pair(max_vertex_obj(xcv1), 1));
|
||||
} else {
|
||||
*oi = CGAL::make_object(std::make_pair(min_vertex_obj(xcv1), 1));
|
||||
}
|
||||
|
||||
++oi;
|
||||
return oi;
|
||||
|
|
@ -348,8 +335,9 @@ public:
|
|||
}
|
||||
|
||||
|
||||
if (endp_coll == 1)
|
||||
if (endp_coll == 1) {
|
||||
return oi;
|
||||
}
|
||||
|
||||
// state temp = xcv1.data()._min_id;
|
||||
|
||||
|
|
@ -366,28 +354,25 @@ public:
|
|||
|
||||
m_traits->intersect_2_object()(xcv1, xcv2, std::back_inserter(base_objs));
|
||||
|
||||
if (base_objs.empty())
|
||||
if (base_objs.empty()) {
|
||||
return (oi);
|
||||
}
|
||||
|
||||
// Attach labels to the intersection objects.
|
||||
std::list<CGAL::Object>::iterator obj_it;
|
||||
const std::pair<Base_point_2, unsigned int> *base_pt;
|
||||
const Base_x_monotone_curve_2 *base_xcv;
|
||||
|
||||
for (obj_it = base_objs.begin(); obj_it != base_objs.end(); ++obj_it)
|
||||
{
|
||||
for (obj_it = base_objs.begin(); obj_it != base_objs.end(); ++obj_it) {
|
||||
base_pt =
|
||||
object_cast<std::pair<Base_point_2, unsigned int> > (&(*obj_it));
|
||||
|
||||
if (base_pt != NULL)
|
||||
{
|
||||
if (base_pt != NULL) {
|
||||
// Attach an invalid label to an itersection point.
|
||||
*oi = CGAL::make_object
|
||||
(std::make_pair(Point_2(base_pt->first), base_pt->second));
|
||||
++oi;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
base_xcv = object_cast<Base_x_monotone_curve_2> (&(*obj_it));
|
||||
CGAL_assertion(base_xcv != NULL);
|
||||
|
||||
|
|
@ -460,8 +445,7 @@ public:
|
|||
};
|
||||
|
||||
/*! Obtain an Intersect_2 functor object. */
|
||||
Intersect_2 intersect_2_object () const
|
||||
{
|
||||
Intersect_2 intersect_2_object() const {
|
||||
return Intersect_2(this);
|
||||
}
|
||||
|
||||
|
|
@ -487,29 +471,28 @@ public:
|
|||
* constructing it.
|
||||
*/
|
||||
Compare_xy_2(const Base_compare_xy_2 &base) :
|
||||
m_base_cmp_xy(base)
|
||||
{}
|
||||
m_base_cmp_xy(base) {
|
||||
}
|
||||
|
||||
//! Allow its functor obtaining function calling the protected constructor.
|
||||
friend class Arr_SegmentData_traits<Traits_>;
|
||||
|
||||
public:
|
||||
Comparison_result operator() (const Point_2& p1, const Point_2& p2) const
|
||||
{
|
||||
Comparison_result operator()(const Point_2 &p1, const Point_2 &p2) const {
|
||||
// if (&p1 == &p2)
|
||||
//Ex_point_2 p1_e,p2_e;
|
||||
//p1_e = *dynamic_cast<const Ex_point_2 *>(&p1);
|
||||
//p2_e = *dynamic_cast<const Ex_point_2 *>(&p2);
|
||||
if ((p1.id == p2.id) && (p1.id != state(-1,-1)))
|
||||
if ((p1.id == p2.id) && (p1.id != state(-1, -1))) {
|
||||
return EQUAL;
|
||||
}
|
||||
|
||||
return m_base_cmp_xy(p1, p2);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Compare_xy_2 compare_xy_2_object () const
|
||||
{
|
||||
Compare_xy_2 compare_xy_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_xy_2(((Base *)this)->compare_xy_2_object()));
|
||||
}
|
||||
|
|
@ -530,30 +513,31 @@ public:
|
|||
*/
|
||||
Construct_min_vertex_2(const Base_construct_min_vertex_2 &base_min_v
|
||||
) :
|
||||
m_base_min_v (base_min_v)
|
||||
{}
|
||||
m_base_min_v(base_min_v) {
|
||||
}
|
||||
|
||||
//! Allow its functor obtaining function calling the protected constructor.
|
||||
friend class Arr_SegmentData_traits<Traits_>;
|
||||
|
||||
public:
|
||||
Point_2 operator() (const X_monotone_curve_2& xcv)
|
||||
{
|
||||
Point_2 operator()(const X_monotone_curve_2 &xcv) {
|
||||
Point_2 min_p = m_base_min_v(xcv);
|
||||
|
||||
/* if (xcv.data().size()>1)
|
||||
min_p.id = -1;
|
||||
else*/
|
||||
if (xcv.label()._orientation == CGAL::SMALLER)
|
||||
if (xcv.label()._orientation == CGAL::SMALLER) {
|
||||
min_p.id = xcv.data()._min_id;
|
||||
else
|
||||
} else {
|
||||
min_p.id = xcv.data()._max_id;
|
||||
}
|
||||
|
||||
return (min_p);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Construct_min_vertex_2 construct_min_vertex_2_object () const
|
||||
{
|
||||
Construct_min_vertex_2 construct_min_vertex_2_object() const {
|
||||
return
|
||||
(Construct_min_vertex_2(((Base *)this)->construct_min_vertex_2_object()));
|
||||
}
|
||||
|
|
@ -579,16 +563,17 @@ public:
|
|||
friend class Arr_SegmentData_traits<Traits_>;
|
||||
|
||||
public:
|
||||
Point_2 operator() (const X_monotone_curve_2 & xcv) const
|
||||
{
|
||||
Point_2 operator()(const X_monotone_curve_2 &xcv) const {
|
||||
Point_2 max_p = m_base_max_v(xcv);
|
||||
|
||||
/* if (xcv.data().size()>1)
|
||||
max_p.id = -1;
|
||||
else*/
|
||||
if (xcv.label()._orientation == CGAL::SMALLER)
|
||||
if (xcv.label()._orientation == CGAL::SMALLER) {
|
||||
max_p.id = xcv.data()._max_id;
|
||||
else
|
||||
} else {
|
||||
max_p.id = xcv.data()._min_id;
|
||||
}
|
||||
|
||||
//max_p.id = xcv.data()._max_id;
|
||||
return (max_p);
|
||||
|
|
@ -596,32 +581,27 @@ public:
|
|||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Construct_max_vertex_2 construct_max_vertex_2_object () const
|
||||
{
|
||||
Construct_max_vertex_2 construct_max_vertex_2_object() const {
|
||||
return
|
||||
(Construct_max_vertex_2(((Base *)this)->construct_max_vertex_2_object()));
|
||||
}
|
||||
|
||||
Compare_y_at_x_2 compare_y_at_x_2_object () const
|
||||
{
|
||||
Compare_y_at_x_2 compare_y_at_x_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_y_at_x_2(((Base *)this)->compare_y_at_x_2_object()));
|
||||
}
|
||||
|
||||
Compare_x_2 compare_x_2_object () const
|
||||
{
|
||||
Compare_x_2 compare_x_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_x_2(((Base *)this)->compare_x_2_object()));
|
||||
}
|
||||
|
||||
Compare_endpoints_xy_2 compare_endpoints_xy_2_object () const
|
||||
{
|
||||
Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_endpoints_xy_2(((Base *)this)->compare_endpoints_xy_2_object()));
|
||||
}
|
||||
|
||||
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const
|
||||
{
|
||||
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_y_at_x_right_2(((Base *)this)->compare_y_at_x_right_2_object()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ public:
|
|||
typedef typename Traits_2::X_monotone_curve_2 Segment_2;
|
||||
typedef std::list<Segment_2> Segments_list;
|
||||
|
||||
virtual void calc_sum(Polygon_2& a,Polygon_2& b,Polygon_2& res_poly)
|
||||
{
|
||||
virtual void calc_sum(Polygon_2 &a, Polygon_2 &b, Polygon_2 &res_poly) {
|
||||
Segments_list reduced_conv;
|
||||
_mink->buildReducedConvolution(a, b, reduced_conv);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
//#include "ReferencePoint_t.h"
|
||||
//#include "BasicPolygonManipulation_T.h"
|
||||
class Graphics
|
||||
{
|
||||
class Graphics {
|
||||
public:
|
||||
typedef QGraphicsLineItem *Line_handle;
|
||||
typedef std::vector< Line_handle> Object_handle;
|
||||
|
|
@ -28,8 +27,7 @@ public:
|
|||
//clear the scene
|
||||
void clear();
|
||||
//edge drawing functions
|
||||
template <typename K> void draw_edge (const typename K::Point_2& p1,const typename K::Point_2& p2,const QColor& color)
|
||||
{
|
||||
template <typename K> void draw_edge(const typename K::Point_2 &p1, const typename K::Point_2 &p2, const QColor &color) {
|
||||
_scene.addLine(QLineF(to_screen_double_x<K::FT> (p1.x()),
|
||||
to_screen_double_y<K::FT> (p1.y()),
|
||||
to_screen_double_x<K::FT> (p2.x()),
|
||||
|
|
@ -43,8 +41,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
template <typename K> void draw_edge (const typename K::Point_2& p1,const typename K::Point_2& p2,const QColor& color,const QColor& color2)
|
||||
{
|
||||
template <typename K> void draw_edge(const typename K::Point_2 &p1, const typename K::Point_2 &p2, const QColor &color, const QColor &color2) {
|
||||
_scene.addLine(QLineF(to_screen_double_x<K::FT> (p1.x()),
|
||||
to_screen_double_y<K::FT> (p1.y()),
|
||||
to_screen_double_x<K::FT> (p2.x()),
|
||||
|
|
@ -76,45 +73,43 @@ public:
|
|||
to_screen_double_y<K::FT> (p2.y())),
|
||||
QPen(color2));
|
||||
}
|
||||
template <typename K> void draw_edge (const typename K::Segment_2& s,const QColor& color)
|
||||
{
|
||||
template <typename K> void draw_edge(const typename K::Segment_2 &s, const QColor &color) {
|
||||
return (this->draw_edge<K> (s.source(), s.target(), color));
|
||||
}
|
||||
|
||||
template <typename K> void draw_edge (const typename K::Segment_2& s,const QColor& color,bool)
|
||||
{
|
||||
template <typename K> void draw_edge(const typename K::Segment_2 &s, const QColor &color, bool) {
|
||||
QColor r(255, 0, 0);
|
||||
(this->draw_edge<K> (s.source(), s.target(), color, r));
|
||||
}
|
||||
//cross drawing functions
|
||||
template <typename K> void draw_cross(const typename K::Point_2& p,const QColor& color,double size = CROSS_SIZE)
|
||||
{
|
||||
template <typename K> void draw_cross(const typename K::Point_2 &p, const QColor &color, double size = CROSS_SIZE) {
|
||||
draw_edge<K>(K::Point_2(p.x() - size, p.y()), K::Point_2(p.x() + size, p.y()), color);
|
||||
draw_edge<K>(K::Point_2(p.x(), p.y() + size), K::Point_2(p.x(), p.y() - size), color);
|
||||
return;
|
||||
}
|
||||
//polgon drawing functions
|
||||
template <typename K> void draw_polygon(const CGAL::Polygon_2<K>& polygon, const QColor& color)
|
||||
{
|
||||
template <typename K> void draw_polygon(const CGAL::Polygon_2<K> &polygon, const QColor &color) {
|
||||
typedef CGAL::Polygon_2<K>::Edge_const_iterator E_iter;
|
||||
|
||||
for (E_iter ei (polygon.edges_begin()) ; ei != polygon.edges_end(); ++ei)
|
||||
{
|
||||
for (E_iter ei(polygon.edges_begin()) ; ei != polygon.edges_end(); ++ei) {
|
||||
draw_edge<K>(*ei, color);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
template <typename K> void draw_polygon(const CGAL::Polygon_with_holes_2<K>& polygon, const QColor& color)
|
||||
{
|
||||
template <typename K> void draw_polygon(const CGAL::Polygon_with_holes_2<K> &polygon, const QColor &color) {
|
||||
//outer boundary
|
||||
if (! polygon.is_unbounded())
|
||||
if (! polygon.is_unbounded()) {
|
||||
draw_polygon<K> (polygon.outer_boundary(), color);
|
||||
}
|
||||
|
||||
//holes
|
||||
CGAL::Polygon_with_holes_2<K>::Hole_const_iterator hit;
|
||||
for (hit = polygon.holes_begin(); hit != polygon.holes_end(); ++hit)
|
||||
|
||||
for (hit = polygon.holes_begin(); hit != polygon.holes_end(); ++hit) {
|
||||
draw_polygon<K>(*hit, color);
|
||||
}
|
||||
}
|
||||
|
||||
//template <typename K> void draw_arrangement(const CGAL)
|
||||
/*
|
||||
|
|
@ -150,8 +145,7 @@ public:
|
|||
}
|
||||
*/
|
||||
//utils
|
||||
template <typename K> void draw_axis (const QColor& color = BLUE)
|
||||
{
|
||||
template <typename K> void draw_axis(const QColor &color = BLUE) {
|
||||
draw_edge<K> (typename K::Segment_2(typename K::Point_2(0, 0), typename K::Point_2(0, 1)), color);
|
||||
draw_edge<K> (typename K::Segment_2(typename K::Point_2(0, 0), typename K::Point_2(1, 0)), color);
|
||||
return;
|
||||
|
|
@ -287,20 +281,16 @@ public:
|
|||
return;
|
||||
}*/
|
||||
private:
|
||||
template <typename NT> double to_screen_double_x(const NT& x)
|
||||
{
|
||||
template <typename NT> double to_screen_double_x(const NT &x) {
|
||||
return ((CGAL::to_double(x) - _min_x) * _ratio_x);
|
||||
}
|
||||
template <typename NT> double to_screen_double_y(const NT& y)
|
||||
{
|
||||
template <typename NT> double to_screen_double_y(const NT &y) {
|
||||
return (- (CGAL::to_double(y) - _min_y) * _ratio_y);
|
||||
}
|
||||
template <typename NT> double to_file_double_x(const NT& x)
|
||||
{
|
||||
template <typename NT> double to_file_double_x(const NT &x) {
|
||||
return (CGAL::to_double(x));
|
||||
}
|
||||
template <typename NT> double to_file_double_y(const NT& y)
|
||||
{
|
||||
template <typename NT> double to_file_double_y(const NT &y) {
|
||||
return (-CGAL::to_double(y));
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,8 +4,7 @@
|
|||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/Boolean_set_operations_2.h>
|
||||
|
||||
template <class Kernel_, class Container_> class NaiveCollisionDetector : public ICollisionDetector< Kernel_, Container_>
|
||||
{
|
||||
template <class Kernel_, class Container_> class NaiveCollisionDetector : public ICollisionDetector< Kernel_, Container_> {
|
||||
public:
|
||||
NaiveCollisionDetector() {}
|
||||
typedef CGAL::Polygon_2<Kernel_> Polygon_2;
|
||||
|
|
@ -13,12 +12,14 @@ public:
|
|||
typedef typename Polygon_2::Traits::Segment_2 Segment_2 ;
|
||||
//typedef typename Polygon_2::Vertex_circulator Vertex_circulator;
|
||||
//typedef typename
|
||||
virtual bool checkCollision(const Polygon_2& p,const Polygon_2& q)
|
||||
{
|
||||
virtual bool checkCollision(const Polygon_2 &p, const Polygon_2 &q) {
|
||||
bool intersect = false;
|
||||
if (CGAL::do_intersect(p,q))
|
||||
|
||||
if (CGAL::do_intersect(p, q)) {
|
||||
return true;
|
||||
else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
for (Edge_iterator itr1 = p.edges_begin();itr1!=p.edges_end();++itr1)
|
||||
|
|
|
|||
|
|
@ -28,15 +28,13 @@ namespace CGAL{
|
|||
Segment_Data(Segment_color color, int min_id, int max_id): _color(color), _min_id(min_id), _max_id(max_id) {}
|
||||
Segment_color _color;
|
||||
int _min_id, _max_id;
|
||||
bool operator==(const Segment_Data& rhs) const
|
||||
{
|
||||
bool operator==(const Segment_Data &rhs) const {
|
||||
//return _color == rhs._color;
|
||||
return (this == &rhs);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Traits_> class Sweep_line_do_curves_x_visitor_ : public Sweep_line_empty_visitor<Traits_>
|
||||
{
|
||||
template <class Traits_> class Sweep_line_do_curves_x_visitor_ : public Sweep_line_empty_visitor<Traits_> {
|
||||
typedef Traits_ Traits_2;
|
||||
typedef Sweep_line_do_curves_x_visitor_<Traits_2> Self;
|
||||
|
||||
|
|
@ -58,12 +56,11 @@ protected:
|
|||
public:
|
||||
|
||||
Sweep_line_do_curves_x_visitor_() :
|
||||
m_found_x(false),m_had_overlap_no_cross(false)
|
||||
{}
|
||||
m_found_x(false), m_had_overlap_no_cross(false) {
|
||||
}
|
||||
|
||||
template <class CurveIterator>
|
||||
void sweep(CurveIterator begin, CurveIterator end)
|
||||
{
|
||||
void sweep(CurveIterator begin, CurveIterator end) {
|
||||
std::vector<X_monotone_curve_2> curves_vec;
|
||||
std::vector<Point_2> points_vec;
|
||||
|
||||
|
|
@ -86,14 +83,12 @@ public:
|
|||
void update_event(Event *e ,
|
||||
Subcurve *sc1 ,
|
||||
Subcurve *sc2 ,
|
||||
bool is_new )
|
||||
{
|
||||
bool is_new) {
|
||||
//m_found_x = true;
|
||||
}
|
||||
|
||||
void update_event(Event * /* e */,
|
||||
Subcurve* /* sc1 */)
|
||||
{
|
||||
Subcurve * /* sc1 */) {
|
||||
// m_found_x = true;
|
||||
}
|
||||
|
||||
|
|
@ -101,17 +96,16 @@ public:
|
|||
const Point_2 & /* end_point */,
|
||||
const X_monotone_curve_2 & /* cv */,
|
||||
Arr_curve_end /* cv_end */,
|
||||
bool /* is_new */)
|
||||
{}
|
||||
bool /* is_new */) {
|
||||
}
|
||||
|
||||
void update_event(Event * /* e */,
|
||||
const Point_2 & /* pt */,
|
||||
bool /* is_new */)
|
||||
{}
|
||||
bool /* is_new */) {
|
||||
}
|
||||
|
||||
template <class XCurveIterator>
|
||||
void sweep_xcurves (XCurveIterator begin, XCurveIterator end)
|
||||
{
|
||||
void sweep_xcurves(XCurveIterator begin, XCurveIterator end) {
|
||||
// Perform the sweep.
|
||||
Sweep_line_2 *sl = reinterpret_cast<Sweep_line_2 *>(this->sweep_line());
|
||||
|
||||
|
|
@ -120,11 +114,9 @@ public:
|
|||
|
||||
void found_overlap(Subcurve *sc1 ,
|
||||
Subcurve *sc2 ,
|
||||
Subcurve* ov_sc )
|
||||
{
|
||||
Subcurve *ov_sc) {
|
||||
|
||||
if (sc1->last_curve().data().front()._color != sc2->last_curve().data().front()._color)
|
||||
{
|
||||
if (sc1->last_curve().data().front()._color != sc2->last_curve().data().front()._color) {
|
||||
Sweep_line_2 *sl = reinterpret_cast<Sweep_line_2 *>(this->sweep_line());
|
||||
const Traits_2 *traits = sl->traits();
|
||||
|
||||
|
|
@ -143,14 +135,14 @@ public:
|
|||
|
||||
bool after_handle_event(Event *event ,
|
||||
Status_line_iterator iter,
|
||||
bool flag )
|
||||
{
|
||||
bool flag) {
|
||||
Sweep_line_2 *sl = reinterpret_cast<Sweep_line_2 *>(this->sweep_line());
|
||||
if(m_found_x)
|
||||
{
|
||||
|
||||
if (m_found_x) {
|
||||
sl->stop_sweep();
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if there was an intersection event:
|
||||
if (((event->is_intersection() || event->is_weak_intersection() || (event->is_left_end() && event->is_right_end()))) && (event->number_of_left_curves() + event->number_of_right_curves() == 4)) {
|
||||
Sweep_line_2 *sl = reinterpret_cast<Sweep_line_2 *>(this->sweep_line());
|
||||
|
|
@ -166,44 +158,46 @@ public:
|
|||
std::vector<bool> incoming_edges(ordered_list.size(), false);
|
||||
typename std::list<Subcurve *>::iterator itr = ordered_list.begin();
|
||||
int i = 0;
|
||||
|
||||
for (; itr != ordered_list.end(); ++itr) {
|
||||
if (i<event->number_of_left_curves())
|
||||
{
|
||||
if (t_compare_endpoints_xy_2_obj((*itr)->last_curve())==CGAL::SMALLER)
|
||||
if (i < event->number_of_left_curves()) {
|
||||
if (t_compare_endpoints_xy_2_obj((*itr)->last_curve()) == CGAL::SMALLER) {
|
||||
incoming_edges[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t_compare_endpoints_xy_2_obj((*itr)->last_curve())==CGAL::LARGER)
|
||||
} else {
|
||||
if (t_compare_endpoints_xy_2_obj((*itr)->last_curve()) == CGAL::LARGER) {
|
||||
incoming_edges[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (ordered_list.size() == 4)
|
||||
{ // normal intersection case
|
||||
if (ordered_list.size() == 4) {
|
||||
// normal intersection case
|
||||
// check for alterations
|
||||
typename std::list<Subcurve *>::iterator itr1, itr2, itr3;
|
||||
itr1 = ordered_list.begin();
|
||||
itr2 = itr1; ++itr2;
|
||||
itr3 = itr2; ++itr3;
|
||||
itr2 = itr1;
|
||||
++itr2;
|
||||
itr3 = itr2;
|
||||
++itr3;
|
||||
bool c = ((*itr1)->last_curve().data().front()._color != (*itr2)->last_curve().data().front()._color);
|
||||
|
||||
if (((*itr1)->last_curve().data().front()._color != (*itr2)->last_curve().data().front()._color) &&
|
||||
((*itr2)->last_curve().data().front()._color != (*itr3)->last_curve().data().front()._color)) {
|
||||
// we have alternating edges
|
||||
m_found_x = true;
|
||||
sl->stop_sweep();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // either 1 and 2 are the same or 1 and for are the same colors.
|
||||
} else {
|
||||
// either 1 and 2 are the same or 1 and for are the same colors.
|
||||
//Subcurve* r1,r2,b1,b2;
|
||||
if ((*itr1)->last_curve().data().front()._color == (*itr2)->last_curve().data().front()._color) {
|
||||
// 1==2
|
||||
/* std::list<Subcurve>::iterator itr =ordered_list.front();
|
||||
r1 = itr; r2 = ++itr; b1 = ++itr; b2 = ++itr;*/
|
||||
if (incoming_edges[0] || incoming_edges[2] )
|
||||
{
|
||||
if (incoming_edges[0] || incoming_edges[2]) {
|
||||
m_found_x = true;
|
||||
sl->stop_sweep();
|
||||
return true;
|
||||
|
|
@ -211,8 +205,7 @@ public:
|
|||
} else {// 1 == 4
|
||||
/* std::list<Subcurve>::iterator itr =ordered_list.front();
|
||||
r2 = itr; b1 = ++itr; b2 = ++itr; r1 = ++itr;*/
|
||||
if (incoming_edges[1] || incoming_edges[3] )
|
||||
{
|
||||
if (incoming_edges[1] || incoming_edges[3]) {
|
||||
m_found_x = true;
|
||||
sl->stop_sweep();
|
||||
return true;
|
||||
|
|
@ -221,9 +214,7 @@ public:
|
|||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Maybe a bug here when we have 2 overlap not overlapping and two outgoing which cause overlap.
|
||||
// this case needs to be studied and handled here.
|
||||
// /
|
||||
|
|
@ -241,19 +232,16 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool found_intersection ()
|
||||
{
|
||||
bool found_intersection() {
|
||||
return (m_found_x);
|
||||
}
|
||||
|
||||
bool had_overlap_no_cross()
|
||||
{
|
||||
bool had_overlap_no_cross() {
|
||||
return m_had_overlap_no_cross;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Traits_> class Colored_traits : public Arr_consolidated_curve_data_traits_2<Traits_,Segment_Data>
|
||||
{
|
||||
template <class Traits_> class Colored_traits : public Arr_consolidated_curve_data_traits_2<Traits_, Segment_Data> {
|
||||
|
||||
public:
|
||||
typedef Arr_consolidated_curve_data_traits_2<Traits_, Segment_Data> Base;
|
||||
|
|
@ -285,24 +273,28 @@ public:
|
|||
template<class OutputIterator>
|
||||
OutputIterator operator()(const X_monotone_colored_segment_2 &xcv1,
|
||||
const X_monotone_colored_segment_2 &xcv2,
|
||||
OutputIterator oi)
|
||||
{
|
||||
OutputIterator oi) {
|
||||
// In case the curves originate from the same arrangement, they are
|
||||
// obviously interior-disjoint.
|
||||
//if (xcv1.data().front() == xcv2.data().front())
|
||||
if (xcv1.data().front()._color == xcv2.data().front()._color)
|
||||
if (xcv1.data().front()._color == xcv2.data().front()._color) {
|
||||
return (oi);
|
||||
}
|
||||
|
||||
typename Base::Intersect_2 int_obj = typename Base::Intersect_2(m_traits);
|
||||
//OutputIterator oi_temp;
|
||||
OutputIterator oi_end = int_obj(xcv1, xcv2, oi);
|
||||
if (oi == oi_end)
|
||||
|
||||
if (oi == oi_end) {
|
||||
return oi_end;
|
||||
}
|
||||
|
||||
const std::pair<Base_point_2, unsigned int> *xp_point;
|
||||
for (;oi!=oi_end;++oi)
|
||||
{
|
||||
|
||||
for (; oi != oi_end; ++oi) {
|
||||
xp_point = object_cast<std::pair<Base_point_2, unsigned int> > (&(*oi));
|
||||
if (xp_point!=NULL)
|
||||
{
|
||||
|
||||
if (xp_point != NULL) {
|
||||
*oi = CGAL::make_object(std::make_pair(Point_2(xp_point->first),
|
||||
xp_point->second));
|
||||
}
|
||||
|
|
@ -315,13 +307,11 @@ public:
|
|||
};
|
||||
|
||||
/*! Obtain an Intersect_2 functor object. */
|
||||
Intersect_2 intersect_2_object () const
|
||||
{
|
||||
Intersect_2 intersect_2_object() const {
|
||||
return Intersect_2(this);
|
||||
}
|
||||
|
||||
class Ex_point_2
|
||||
{
|
||||
class Ex_point_2 {
|
||||
public:
|
||||
|
||||
typedef Base_point_2 Base_p;
|
||||
|
|
@ -346,26 +336,22 @@ public:
|
|||
|
||||
|
||||
/*! Get the base point (const version). */
|
||||
const Base_p& base () const
|
||||
{
|
||||
const Base_p &base() const {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Get the base point (non-const version). */
|
||||
Base_p& base ()
|
||||
{
|
||||
Base_p &base() {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Casting to a base point (const version). */
|
||||
operator const Base_p& () const
|
||||
{
|
||||
operator const Base_p &() const {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
/*! Casting to a base point (non-const version). */
|
||||
operator Base_p& ()
|
||||
{
|
||||
operator Base_p &() {
|
||||
return (m_base_pt);
|
||||
}
|
||||
|
||||
|
|
@ -396,29 +382,28 @@ public:
|
|||
* constructing it.
|
||||
*/
|
||||
Compare_xy_2(const Base_compare_xy_2 &base) :
|
||||
m_base_cmp_xy(base)
|
||||
{}
|
||||
m_base_cmp_xy(base) {
|
||||
}
|
||||
|
||||
//! Allow its functor obtaining function calling the protected constructor.
|
||||
friend class Colored_traits<Traits_>;
|
||||
|
||||
public:
|
||||
Comparison_result operator() (const Point_2& p1, const Point_2& p2) const
|
||||
{
|
||||
Comparison_result operator()(const Point_2 &p1, const Point_2 &p2) const {
|
||||
// if (&p1 == &p2)
|
||||
//Ex_point_2 p1_e,p2_e;
|
||||
//p1_e = *dynamic_cast<const Ex_point_2 *>(&p1);
|
||||
//p2_e = *dynamic_cast<const Ex_point_2 *>(&p2);
|
||||
if ((p1.id == p2.id) && (p1.id != -1))
|
||||
if ((p1.id == p2.id) && (p1.id != -1)) {
|
||||
return EQUAL;
|
||||
}
|
||||
|
||||
return m_base_cmp_xy(p1, p2);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Compare_xy_2 compare_xy_2_object () const
|
||||
{
|
||||
Compare_xy_2 compare_xy_2_object() const {
|
||||
//Base::Compare_xy_2 obj();
|
||||
return (Compare_xy_2(((Base *)this)->compare_xy_2_object()));
|
||||
}
|
||||
|
|
@ -439,28 +424,29 @@ public:
|
|||
*/
|
||||
Construct_min_vertex_2(const Base_construct_min_vertex_2 &base_min_v
|
||||
) :
|
||||
m_base_min_v (base_min_v)
|
||||
{}
|
||||
m_base_min_v(base_min_v) {
|
||||
}
|
||||
|
||||
//! Allow its functor obtaining function calling the protected constructor.
|
||||
friend class Colored_traits<Traits_>;
|
||||
typedef typename Colored_traits::X_monotone_curve_2 X_monotone_curve_2;
|
||||
|
||||
public:
|
||||
Point_2 operator() (const X_monotone_curve_2& xcv)
|
||||
{
|
||||
Point_2 operator()(const X_monotone_curve_2 &xcv) {
|
||||
Point_2 min_p = m_base_min_v(xcv);
|
||||
if (xcv.data().size()>1)
|
||||
|
||||
if (xcv.data().size() > 1) {
|
||||
min_p.id = -1;
|
||||
else
|
||||
} else {
|
||||
min_p.id = xcv.data().front()._min_id;
|
||||
}
|
||||
|
||||
return (min_p);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Construct_min_vertex_2 construct_min_vertex_2_object () const
|
||||
{
|
||||
Construct_min_vertex_2 construct_min_vertex_2_object() const {
|
||||
return
|
||||
(Construct_min_vertex_2(((Base *)this)->construct_min_vertex_2_object()));
|
||||
}
|
||||
|
|
@ -487,20 +473,21 @@ public:
|
|||
typedef typename Colored_traits::X_monotone_curve_2 X_monotone_curve_2;
|
||||
|
||||
public:
|
||||
Point_2 operator() (const X_monotone_curve_2 & xcv) const
|
||||
{
|
||||
Point_2 operator()(const X_monotone_curve_2 &xcv) const {
|
||||
Point_2 max_p = m_base_max_v(xcv);
|
||||
if (xcv.data().size()>1)
|
||||
|
||||
if (xcv.data().size() > 1) {
|
||||
max_p.id = -1;
|
||||
else
|
||||
} else {
|
||||
max_p.id = xcv.data().front()._max_id;
|
||||
}
|
||||
|
||||
return (max_p);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Obtain a Construct_min_vertex_2 functor object. */
|
||||
Construct_max_vertex_2 construct_max_vertex_2_object () const
|
||||
{
|
||||
Construct_max_vertex_2 construct_max_vertex_2_object() const {
|
||||
return
|
||||
(Construct_max_vertex_2(((Base *)this)->construct_max_vertex_2_object()));
|
||||
}
|
||||
|
|
@ -510,8 +497,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template <class Kernel_, class Container_> class SweepCollisionDetector : public ICollisionDetector< Kernel_, Container_>
|
||||
{
|
||||
template <class Kernel_, class Container_> class SweepCollisionDetector : public ICollisionDetector< Kernel_, Container_> {
|
||||
|
||||
|
||||
|
||||
|
|
@ -537,63 +523,63 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
virtual bool checkCollision(const typename CGAL::Polygon_2<Kernel_>& p,const typename CGAL::Polygon_2<Kernel_>& q)
|
||||
{
|
||||
virtual bool checkCollision(const typename CGAL::Polygon_2<Kernel_> &p, const typename CGAL::Polygon_2<Kernel_> &q) {
|
||||
typename Traits_2::Compare_endpoints_xy_2 cmp_obj = m_traits.compare_endpoints_xy_2_object();
|
||||
if (p.has_on_bounded_side(*(q.vertices_begin())) || q.has_on_bounded_side(*(p.vertices_begin())))
|
||||
|
||||
if (p.has_on_bounded_side(*(q.vertices_begin())) || q.has_on_bounded_side(*(p.vertices_begin()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//std::list<Segment_2> edges(p.edges_begin(),p.edges_end());
|
||||
std::list<Colored_segment_2> edges;
|
||||
Edge_iterator itr = p.edges_begin();
|
||||
int i = 0;
|
||||
int n = p.size();
|
||||
for (;itr!=p.edges_end();++itr,++i)
|
||||
{
|
||||
|
||||
for (; itr != p.edges_end(); ++itr, ++i) {
|
||||
//Traits_2::
|
||||
|
||||
//CGAL::Comparison_result res = CGAL::compare((itr)->source(),(itr)->target());
|
||||
CGAL::Comparison_result res = cmp_obj(*itr);
|
||||
|
||||
if (res != CGAL::SMALLER)
|
||||
{
|
||||
if (i==n-1)
|
||||
if (res != CGAL::SMALLER) {
|
||||
if (i == n - 1) {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_RED, 0, i)));
|
||||
else
|
||||
} else {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_RED, i + 1, i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i==n-1)
|
||||
} else {
|
||||
if (i == n - 1) {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_RED, i, 0)));
|
||||
else
|
||||
} else {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_RED, i, i + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
itr = q.edges_begin();
|
||||
n = q.size();
|
||||
int j = 0;
|
||||
int q_first = i;
|
||||
for (;itr!=q.edges_end();++itr,++i,++j)
|
||||
{
|
||||
|
||||
for (; itr != q.edges_end(); ++itr, ++i, ++j) {
|
||||
//CGAL::Comparison_result res = CGAL::compare((itr)->source(),(itr)->target());
|
||||
CGAL::Comparison_result res = cmp_obj(*itr);
|
||||
|
||||
if (res != CGAL::SMALLER)
|
||||
{
|
||||
if (j==n-1)
|
||||
if (res != CGAL::SMALLER) {
|
||||
if (j == n - 1) {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_BLUE, q_first, i)));
|
||||
else
|
||||
} else {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_BLUE, i + 1, i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j==n-1)
|
||||
} else {
|
||||
if (j == n - 1) {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_BLUE, i, q_first)));
|
||||
else
|
||||
} else {
|
||||
edges.push_back(Colored_segment_2(*itr, Segment_Data(MY_BLUE, i, i + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//edges.push_back(Colored_segment_2(*itr,Segment_Data(MY_BLUE,2*i,2*i+1)));
|
||||
|
|
@ -604,11 +590,14 @@ public:
|
|||
Sweep_line_2<Data_traits_2, Sweep_line_do_curves_x_visitor_<Data_traits_2> > sweep_line(&visitor);
|
||||
visitor.attach((void *)&sweep_line);
|
||||
visitor.sweep(edges.begin(), edges.end());
|
||||
if (visitor.found_intersection())
|
||||
return true;
|
||||
|
||||
if (visitor.had_overlap_no_cross())
|
||||
if (visitor.found_intersection()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (visitor.had_overlap_no_cross()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//else
|
||||
//{
|
||||
|
|
|
|||
Loading…
Reference in New Issue