mirror of https://github.com/CGAL/cgal
Adjusted formatting and readability
Changed formatting to 80 chars per line. Improved readability. Removed useless renaming of variables.
This commit is contained in:
parent
8ea81e7515
commit
5d9b3d7e74
|
|
@ -23,11 +23,11 @@
|
||||||
#ifndef CGAL_SIMPLE_POLYGON_VISIBILITY_2_H
|
#ifndef CGAL_SIMPLE_POLYGON_VISIBILITY_2_H
|
||||||
#define CGAL_SIMPLE_POLYGON_VISIBILITY_2_H
|
#define CGAL_SIMPLE_POLYGON_VISIBILITY_2_H
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/tags.h>
|
#include <CGAL/tags.h>
|
||||||
#include <CGAL/enum.h>
|
#include <CGAL/enum.h>
|
||||||
#include <CGAL/Visibility_2/visibility_utils.h>
|
#include <CGAL/Visibility_2/visibility_utils.h>
|
||||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||||
|
#include <CGAL/assertions.h>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
@ -37,7 +37,6 @@ template<class Arrangement_2_, class RegularizationCategory = CGAL::Tag_true>
|
||||||
class Simple_polygon_visibility_2 {
|
class Simple_polygon_visibility_2 {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Currently only consider with same type for both
|
|
||||||
typedef Arrangement_2_ Arrangement_2;
|
typedef Arrangement_2_ Arrangement_2;
|
||||||
typedef typename Arrangement_2::Traits_2 Traits_2;
|
typedef typename Arrangement_2::Traits_2 Traits_2;
|
||||||
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
||||||
|
|
@ -66,18 +65,18 @@ public:
|
||||||
typedef CGAL::Tag_false Supports_general_polygon_category;
|
typedef CGAL::Tag_false Supports_general_polygon_category;
|
||||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||||
|
|
||||||
Simple_polygon_visibility_2() : p_arr(NULL), geom_traits(NULL) {}
|
Simple_polygon_visibility_2() : p_arr(NULL), traits(NULL) {}
|
||||||
|
|
||||||
/*! Constructor given an arrangement and the Regularization tag. */
|
/*! Constructor given an arrangement and the Regularization tag. */
|
||||||
Simple_polygon_visibility_2(const Arrangement_2& arr):
|
Simple_polygon_visibility_2(const Arrangement_2& arr):
|
||||||
p_arr(&arr) {
|
p_arr(&arr) {
|
||||||
geom_traits = p_arr->geometry_traits();
|
traits = p_arr->geometry_traits();
|
||||||
query_pt_is_vertex = false;
|
query_pt_is_vertex = false;
|
||||||
query_pt_is_on_halfedge = false;
|
query_pt_is_on_halfedge = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string name(){return std::string("S_visibility_2");}
|
std::string name() const { return std::string("S_visibility_2"); }
|
||||||
|
|
||||||
/*! Method to check if the visibility object is attached or not to
|
/*! Method to check if the visibility object is attached or not to
|
||||||
an arrangement*/
|
an arrangement*/
|
||||||
|
|
@ -90,7 +89,7 @@ public:
|
||||||
if(p_arr != &arr){
|
if(p_arr != &arr){
|
||||||
detach();
|
detach();
|
||||||
p_arr = &arr;
|
p_arr = &arr;
|
||||||
geom_traits = p_arr->geometry_traits();
|
traits = p_arr->geometry_traits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +97,7 @@ public:
|
||||||
attached to*/
|
attached to*/
|
||||||
void detach() {
|
void detach() {
|
||||||
p_arr = NULL;
|
p_arr = NULL;
|
||||||
geom_traits = NULL;
|
traits = NULL;
|
||||||
vertices.clear();
|
vertices.clear();
|
||||||
query_pt_is_vertex = false;
|
query_pt_is_vertex = false;
|
||||||
query_pt_is_on_halfedge = false;
|
query_pt_is_on_halfedge = false;
|
||||||
|
|
@ -114,26 +113,24 @@ public:
|
||||||
'face' and constructs the output in 'out_arr'*/
|
'face' and constructs the output in 'out_arr'*/
|
||||||
template <typename VARR>
|
template <typename VARR>
|
||||||
typename VARR::Face_handle
|
typename VARR::Face_handle
|
||||||
compute_visibility(const Point_2& q, Face_const_handle face,
|
compute_visibility(const Point_2& q,
|
||||||
VARR& out_arr) const {
|
const Face_const_handle face,
|
||||||
|
VARR& out_arr) const
|
||||||
|
{
|
||||||
|
|
||||||
CGAL_precondition_msg(p_arr->number_of_faces() == 2,
|
CGAL_precondition(!face->is_unbounded());
|
||||||
"Only simple polygons are supported.");
|
|
||||||
|
|
||||||
out_arr.clear();
|
out_arr.clear();
|
||||||
|
|
||||||
query_pt_is_vertex = false;
|
query_pt_is_vertex = false;
|
||||||
query_pt_is_on_halfedge = false;
|
query_pt_is_on_halfedge = false;
|
||||||
|
|
||||||
|
|
||||||
// Now retrieve the circulator to first visible vertex from triangulation
|
// Now retrieve the circulator to first visible vertex from triangulation
|
||||||
Ccb_halfedge_const_circulator circ = find_visible_start(face, q);
|
Ccb_halfedge_const_circulator circ = find_visible_start(face, q);
|
||||||
Ccb_halfedge_const_circulator curr = circ;
|
Ccb_halfedge_const_circulator curr = circ;
|
||||||
Halfedge_const_handle he;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
he = curr;
|
vertices.push_back(curr->source()->point());
|
||||||
vertices.push_back(he->source()->point());
|
|
||||||
} while(++curr != circ);
|
} while(++curr != circ);
|
||||||
|
|
||||||
vertices.push_back(vertices[0]);
|
vertices.push_back(vertices[0]);
|
||||||
|
|
@ -153,9 +150,6 @@ public:
|
||||||
VARR& out_arr ) const
|
VARR& out_arr ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
CGAL_precondition_msg(p_arr->number_of_faces() == 2,
|
|
||||||
"Only simple polygons are supported.");
|
|
||||||
|
|
||||||
out_arr.clear();
|
out_arr.clear();
|
||||||
|
|
||||||
query_pt_is_vertex = false;
|
query_pt_is_vertex = false;
|
||||||
|
|
@ -177,12 +171,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Ccb_halfedge_const_circulator circ = he;
|
Ccb_halfedge_const_circulator circ = he;
|
||||||
circ++;
|
++circ;
|
||||||
Ccb_halfedge_const_circulator curr = circ;
|
Ccb_halfedge_const_circulator curr = circ;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Halfedge_const_handle he_handle = curr;
|
const Point_2& curr_vertex = curr->target()->point();
|
||||||
Point_2 curr_vertex = he_handle->target()->point();
|
|
||||||
vertices.push_back(curr_vertex);
|
vertices.push_back(curr_vertex);
|
||||||
} while (++curr != circ);
|
} while (++curr != circ);
|
||||||
|
|
||||||
|
|
@ -194,31 +187,6 @@ public:
|
||||||
|
|
||||||
return output(q, out_arr);
|
return output(q, out_arr);
|
||||||
|
|
||||||
// std::vector<Point_2> points;
|
|
||||||
|
|
||||||
// if (!s.empty()) {
|
|
||||||
// Point_2 prev_pt = s.top();
|
|
||||||
// if (prev_pt != q) {
|
|
||||||
// points.push_back(prev_pt);
|
|
||||||
// }
|
|
||||||
// else if (query_pt_is_vertex) {
|
|
||||||
// points.push_back(prev_pt);
|
|
||||||
// }
|
|
||||||
// if (!s.empty()) {
|
|
||||||
// s.pop();
|
|
||||||
// }
|
|
||||||
// while(!s.empty()) {
|
|
||||||
// Point_2 curr_pt = s.top();
|
|
||||||
// if (curr_pt != q) {
|
|
||||||
// points.push_back(curr_pt);
|
|
||||||
// }
|
|
||||||
// else if (query_pt_is_vertex) {
|
|
||||||
// points.push_back(curr_pt);
|
|
||||||
// }
|
|
||||||
// s.pop();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -230,7 +198,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Arrangement_2 *p_arr;
|
const Arrangement_2 *p_arr;
|
||||||
const Geometry_traits_2 *geom_traits;
|
const Geometry_traits_2 *traits;
|
||||||
|
|
||||||
/*! Boost pointer to the constrained Delaunay triangulation object*/
|
/*! Boost pointer to the constrained Delaunay triangulation object*/
|
||||||
mutable boost::shared_ptr<CDT> p_cdt;
|
mutable boost::shared_ptr<CDT> p_cdt;
|
||||||
|
|
@ -253,28 +221,28 @@ private:
|
||||||
void conditional_regularize(VARR& out_arr, CGAL::Tag_true) const {
|
void conditional_regularize(VARR& out_arr, CGAL::Tag_true) const {
|
||||||
regularize_output(out_arr);
|
regularize_output(out_arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! No need to regularize output if flag is set to false*/
|
/*! No need to regularize output if flag is set to false*/
|
||||||
template <typename VARR>
|
template <typename VARR>
|
||||||
void conditional_regularize(VARR& out_arr, CGAL::Tag_false) const {
|
void conditional_regularize(VARR& out_arr, CGAL::Tag_false) const {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Regularizes the output - removes edges that have the same face on both
|
/*! Regularizes the output - removes edges that have the same face on both
|
||||||
sides */
|
sides */
|
||||||
template <typename VARR>
|
template <typename VARR>
|
||||||
void regularize_output(VARR& out_arr) const {
|
void regularize_output(VARR& out_arr) const {
|
||||||
typename VARR::Edge_iterator e_itr;
|
typename VARR::Edge_iterator e_itr;
|
||||||
for (e_itr = out_arr.edges_begin() ;
|
for (e_itr = out_arr.edges_begin(); e_itr != out_arr.edges_end(); ++e_itr) {
|
||||||
e_itr != out_arr.edges_end() ; e_itr++) {
|
|
||||||
|
|
||||||
typename VARR::Halfedge_handle he = e_itr;
|
if (e_itr->face() == e_itr->twin()->face()) {
|
||||||
typename VARR::Halfedge_handle he_twin = he->twin();
|
out_arr.remove_edge(e_itr);
|
||||||
if (he->face() == he_twin->face()) {
|
|
||||||
out_arr.remove_edge(he);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Initialized the constrained Delaunay triangulation using the edges of
|
/*! Initialized the constrained Delaunay triangulation using the edges of
|
||||||
the outer boundary of 'face' */
|
the outer boundary of 'face' */
|
||||||
void init_cdt(const Face_const_handle &face) const {
|
void init_cdt(const Face_const_handle &face) const {
|
||||||
|
|
@ -286,8 +254,8 @@ private:
|
||||||
Ccb_halfedge_const_circulator curr = circ;
|
Ccb_halfedge_const_circulator curr = circ;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Point_2 source = curr->source()->point();
|
const Point_2& source = curr->source()->point();
|
||||||
Point_2 target = curr->target()->point();
|
const Point_2& target = curr->target()->point();
|
||||||
point_itr_map.insert(std::make_pair(source, curr));
|
point_itr_map.insert(std::make_pair(source, curr));
|
||||||
constraints.push_back(std::make_pair(source, target));
|
constraints.push_back(std::make_pair(source, target));
|
||||||
} while(++curr != circ);
|
} while(++curr != circ);
|
||||||
|
|
@ -296,6 +264,7 @@ private:
|
||||||
constraints.end()));
|
constraints.end()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename VARR>
|
template <typename VARR>
|
||||||
typename VARR::Face_handle
|
typename VARR::Face_handle
|
||||||
output(const Point_2& q, VARR& out_arr) const {
|
output(const Point_2& q, VARR& out_arr) const {
|
||||||
|
|
@ -306,19 +275,15 @@ private:
|
||||||
s.pop();
|
s.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::reverse(points.begin(), points.end());
|
Visibility_2::report_while_handling_needles<Simple_polygon_visibility_2>(
|
||||||
|
traits, q, points, out_arr);
|
||||||
CGAL::Visibility_2::report_while_handling_needles
|
|
||||||
<Simple_polygon_visibility_2>(geom_traits,
|
|
||||||
q,
|
|
||||||
points,
|
|
||||||
out_arr);
|
|
||||||
|
|
||||||
CGAL_postcondition(out_arr.number_of_isolated_vertices() == 0);
|
CGAL_postcondition(out_arr.number_of_isolated_vertices() == 0);
|
||||||
CGAL_postcondition(s.empty());
|
CGAL_postcondition(s.empty());
|
||||||
|
|
||||||
conditional_regularize(out_arr, Regularization_category());
|
conditional_regularize(out_arr, Regularization_category());
|
||||||
vertices.clear();
|
vertices.clear();
|
||||||
|
|
||||||
if (out_arr.faces_begin()->is_unbounded()) {
|
if (out_arr.faces_begin()->is_unbounded()) {
|
||||||
return ++out_arr.faces_begin();
|
return ++out_arr.faces_begin();
|
||||||
}
|
}
|
||||||
|
|
@ -334,33 +299,29 @@ private:
|
||||||
const Point_2 &q) const {
|
const Point_2 &q) const {
|
||||||
init_cdt(face);
|
init_cdt(face);
|
||||||
typename CDT::Face_handle fh = p_cdt->locate(q);
|
typename CDT::Face_handle fh = p_cdt->locate(q);
|
||||||
Point_2 start_point = fh->vertex(0)->point();
|
const Point_2& start_point = fh->vertex(0)->point();
|
||||||
|
|
||||||
// Now retrieve the circulator to first visible vertex from triangulation
|
// Now retrieve the circulator to first visible vertex from triangulation
|
||||||
Ccb_halfedge_const_circulator circ = point_itr_map[start_point];
|
Ccb_halfedge_const_circulator circ = point_itr_map[start_point];
|
||||||
Halfedge_const_handle he_curr = circ;
|
|
||||||
|
|
||||||
Halfedge_around_vertex_const_circulator incident_circ =
|
Halfedge_around_vertex_const_circulator incident_circ =
|
||||||
he_curr->source()->incident_halfedges();
|
circ->source()->incident_halfedges();
|
||||||
Halfedge_around_vertex_const_circulator incident_curr = incident_circ;
|
Halfedge_around_vertex_const_circulator incident_curr = incident_circ;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Ccb_halfedge_const_circulator curr_inc = incident_curr;
|
|
||||||
Halfedge_const_handle he_curr_inc = curr_inc;
|
|
||||||
|
|
||||||
if (he_curr_inc->face() == face) {
|
if (incident_curr->face() == face) {
|
||||||
Ccb_halfedge_const_circulator incident_next = incident_curr;
|
Ccb_halfedge_const_circulator incident_next = incident_curr;
|
||||||
incident_next++;
|
++incident_next;
|
||||||
Halfedge_const_handle he_next_inc = incident_next;
|
|
||||||
|
|
||||||
if (CGAL::Visibility_2::orientation_2(geom_traits,
|
if (Visibility_2::orientation_2(traits,
|
||||||
he_curr_inc->source()->point(),
|
incident_curr->source()->point(),
|
||||||
he_curr_inc->target()->point(),
|
incident_curr->target()->point(),
|
||||||
q) == CGAL::LEFT_TURN
|
q) == LEFT_TURN
|
||||||
|| CGAL::Visibility_2::orientation_2(geom_traits,
|
|| Visibility_2::orientation_2(traits,
|
||||||
he_next_inc->source()->point(),
|
incident_next->source()->point(),
|
||||||
he_next_inc->target()->point(),
|
incident_next->target()->point(),
|
||||||
q) == CGAL::LEFT_TURN)
|
q) == LEFT_TURN)
|
||||||
{
|
{
|
||||||
return incident_next;
|
return incident_next;
|
||||||
}
|
}
|
||||||
|
|
@ -368,6 +329,7 @@ private:
|
||||||
} while (++incident_curr != incident_circ);
|
} while (++incident_curr != incident_circ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Main method of the algorithm - initializes the stack and variables
|
/*! Main method of the algorithm - initializes the stack and variables
|
||||||
and calles the corresponding methods acc. to the algorithm's state;
|
and calles the corresponding methods acc. to the algorithm's state;
|
||||||
'q' - query point;
|
'q' - query point;
|
||||||
|
|
@ -376,11 +338,10 @@ private:
|
||||||
void visibility_region_impl(const Point_2& q) const {
|
void visibility_region_impl(const Point_2& q) const {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Point_2 w;
|
Point_2 w;
|
||||||
CGAL::Orientation orient = CGAL::Visibility_2::orientation_2(geom_traits,
|
Orientation orient =
|
||||||
q,
|
Visibility_2::orientation_2(traits, q, vertices[0], vertices[1]);
|
||||||
vertices[0],
|
|
||||||
vertices[1]);
|
if ( orient != RIGHT_TURN ) {
|
||||||
if ( orient != CGAL::RIGHT_TURN ) {
|
|
||||||
upcase = LEFT;
|
upcase = LEFT;
|
||||||
i = 1;
|
i = 1;
|
||||||
w = vertices[1];
|
w = vertices[1];
|
||||||
|
|
@ -419,16 +380,17 @@ private:
|
||||||
if ( upcase == LEFT ) {
|
if ( upcase == LEFT ) {
|
||||||
Point_2 s_t = s.top();
|
Point_2 s_t = s.top();
|
||||||
s.pop();
|
s.pop();
|
||||||
if ( ( CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
if ( Visibility_2::orientation_2(traits, q, vertices[0], s.top() )
|
||||||
( geom_traits, q, vertices[0], s.top() ) == CGAL::RIGHT_TURN ) &&
|
== RIGHT_TURN
|
||||||
( CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
&&
|
||||||
( geom_traits, q, vertices[0],s_t ) == CGAL::LEFT_TURN ) ) {
|
Visibility_2::orientation_2(traits, q, vertices[0], s_t)
|
||||||
Segment_2 seg( s.top(), s_t );
|
== LEFT_TURN )
|
||||||
if (Visibility_2::do_intersect_2(geom_traits, seg, ray_origin ) )
|
|
||||||
{
|
{
|
||||||
Object_2 result = Visibility_2::intersect_2(geom_traits,
|
Segment_2 seg( s.top(), s_t );
|
||||||
seg, ray_origin);
|
if ( Visibility_2::do_intersect_2(traits, seg, ray_origin) )
|
||||||
const Point_2 * ipoint = CGAL::object_cast<Point_2>(&result);
|
{
|
||||||
|
Object_2 result = Visibility_2::intersect_2(traits, seg,ray_origin);
|
||||||
|
const Point_2 * ipoint = object_cast<Point_2>(&result);
|
||||||
assert( ipoint != NULL );
|
assert( ipoint != NULL );
|
||||||
s_t = *ipoint;
|
s_t = *ipoint;
|
||||||
upcase = SCANB;
|
upcase = SCANB;
|
||||||
|
|
@ -440,7 +402,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Method that handles the left turns in the vertex algorithm */
|
/*! Method that handles the left turns in the vertex algorithm */
|
||||||
void left(int& i, Point_2& w, const Point_2& query_pt) const {
|
void left(int& i, Point_2& w, const Point_2& q) const {
|
||||||
if (i >= vertices.size() - 1) {
|
if (i >= vertices.size() - 1) {
|
||||||
upcase = FINISH;
|
upcase = FINISH;
|
||||||
}
|
}
|
||||||
|
|
@ -449,24 +411,26 @@ private:
|
||||||
s.pop();
|
s.pop();
|
||||||
Point_2 s_t_prev = s.top();
|
Point_2 s_t_prev = s.top();
|
||||||
s.push( s_t );
|
s.push( s_t );
|
||||||
CGAL::Orientation orient1 = Visibility_2::orientation_2
|
Orientation orient1 = Visibility_2::orientation_2
|
||||||
( geom_traits,
|
( traits,
|
||||||
query_pt,
|
q,
|
||||||
vertices[i],
|
vertices[i],
|
||||||
vertices[i+1] );
|
vertices[i+1] );
|
||||||
if ( orient1 != CGAL::RIGHT_TURN ) {
|
|
||||||
|
if ( orient1 != RIGHT_TURN ) {
|
||||||
// Case L2
|
// Case L2
|
||||||
upcase = LEFT;
|
upcase = LEFT;
|
||||||
s.push( vertices[i+1] );
|
s.push( vertices[i+1] );
|
||||||
w = vertices[i+1];
|
w = vertices[i+1];
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
CGAL::Orientation orient2 = Visibility_2::orientation_2
|
Orientation orient2 = Visibility_2::orientation_2
|
||||||
( geom_traits,
|
( traits,
|
||||||
s_t_prev,
|
s_t_prev,
|
||||||
vertices[i],
|
vertices[i],
|
||||||
vertices[i+1] );
|
vertices[i+1] );
|
||||||
if ( orient2 == CGAL::RIGHT_TURN ) {
|
|
||||||
|
if ( orient2 == RIGHT_TURN ) {
|
||||||
// Case L3
|
// Case L3
|
||||||
upcase = SCANA;
|
upcase = SCANA;
|
||||||
w = vertices[i+1];
|
w = vertices[i+1];
|
||||||
|
|
@ -483,25 +447,24 @@ private:
|
||||||
|
|
||||||
/*! Scans the stack such that all vertices that were pushed before to the
|
/*! Scans the stack such that all vertices that were pushed before to the
|
||||||
stack and are now not visible anymore. */
|
stack and are now not visible anymore. */
|
||||||
void right(int& i, Point_2& w, const Point_2& query_pt) const {
|
void right(int& i, Point_2& w, const Point_2& q) const {
|
||||||
Point_2 s_j;
|
Point_2 s_j;
|
||||||
Point_2 s_j_prev;
|
Point_2 s_j_prev;
|
||||||
Point_2 u;
|
Point_2 u;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
CGAL::Orientation orient1, orient2;
|
Orientation orient1, orient2;
|
||||||
|
|
||||||
s_j_prev = s.top();
|
s_j_prev = s.top();
|
||||||
orient2 = CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
orient2 = Visibility_2::orientation_2( traits, q, s_j_prev, vertices[i] );
|
||||||
( geom_traits, query_pt, s_j_prev, vertices[i] );
|
|
||||||
while ( s.size() > 1 ) {
|
while ( s.size() > 1 ) {
|
||||||
s_j = s_j_prev;
|
s_j = s_j_prev;
|
||||||
orient1 = orient2;
|
orient1 = orient2;
|
||||||
s.pop();
|
s.pop();
|
||||||
s_j_prev = s.top();
|
s_j_prev = s.top();
|
||||||
|
|
||||||
orient2 = CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
orient2 = Visibility_2::orientation_2( traits, q, s_j_prev, vertices[i]);
|
||||||
( geom_traits, query_pt, s_j_prev, vertices[i] );
|
if ( orient1 != LEFT_TURN && orient2 != RIGHT_TURN ) {
|
||||||
if ( orient1 != CGAL::LEFT_TURN && orient2 != CGAL::RIGHT_TURN ) {
|
|
||||||
mode = 1;
|
mode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -509,10 +472,10 @@ private:
|
||||||
Segment_2 seg2( vertices[i-1], vertices[i] );
|
Segment_2 seg2( vertices[i-1], vertices[i] );
|
||||||
Segment_2 seg( s_j_prev, s_j );
|
Segment_2 seg( s_j_prev, s_j );
|
||||||
if ( vertices[i-1] != s_j &&
|
if ( vertices[i-1] != s_j &&
|
||||||
Visibility_2::do_intersect_2(geom_traits, seg, seg2) )
|
Visibility_2::do_intersect_2(traits, seg, seg2) )
|
||||||
{
|
{
|
||||||
Object_2 result = Visibility_2::intersect_2(geom_traits, seg, seg2);
|
Object_2 result = Visibility_2::intersect_2(traits, seg, seg2);
|
||||||
const Point_2 * ipoint = CGAL::object_cast<Point_2>(&result);
|
const Point_2 * ipoint = object_cast<Point_2>(&result);
|
||||||
assert( ipoint != NULL );
|
assert( ipoint != NULL );
|
||||||
u = *ipoint;
|
u = *ipoint;
|
||||||
mode = 2;
|
mode = 2;
|
||||||
|
|
@ -522,11 +485,12 @@ private:
|
||||||
|
|
||||||
assert( mode != 0 );
|
assert( mode != 0 );
|
||||||
if ( mode == 1 ) {
|
if ( mode == 1 ) {
|
||||||
orient1 = CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
orient1 = Visibility_2::orientation_2
|
||||||
( geom_traits, query_pt, vertices[i], vertices[i+1] );
|
( traits, q, vertices[i], vertices[i+1] );
|
||||||
orient2 = CGAL::Visibility_2::orientation_2 <Geometry_traits_2>
|
orient2 = Visibility_2::orientation_2
|
||||||
( geom_traits, vertices[i-1], vertices[i], vertices[i+1] );
|
( traits, vertices[i-1], vertices[i], vertices[i+1] );
|
||||||
if ( orient1 == CGAL::RIGHT_TURN ) {
|
|
||||||
|
if ( orient1 == RIGHT_TURN ) {
|
||||||
// Case R1
|
// Case R1
|
||||||
// Since the next action is RIGHT, we do not compute the intersection
|
// Since the next action is RIGHT, we do not compute the intersection
|
||||||
// of (s_j,s_j_prev) and the ray (query_pt, vertices[i]),
|
// of (s_j,s_j_prev) and the ray (query_pt, vertices[i]),
|
||||||
|
|
@ -535,15 +499,16 @@ private:
|
||||||
s.push( s_j );
|
s.push( s_j );
|
||||||
w = vertices[i];
|
w = vertices[i];
|
||||||
i++;
|
i++;
|
||||||
} else if ( orient2 == CGAL::RIGHT_TURN ) {
|
} else if ( orient2 == RIGHT_TURN ) {
|
||||||
// Case R2
|
// Case R2
|
||||||
Ray_2 ray( query_pt, vertices[i] );
|
Ray_2 ray( q, vertices[i] );
|
||||||
Segment_2 seg( s_j_prev, s_j );
|
Segment_2 seg( s_j_prev, s_j );
|
||||||
Object_2 result = CGAL::Visibility_2::intersect_2
|
|
||||||
<Geometry_traits_2, Segment_2, Ray_2>
|
Object_2 result = Visibility_2::intersect_2( traits, seg, ray );
|
||||||
( geom_traits, seg, ray );
|
const Point_2 * ipoint = object_cast<Point_2>(&result);
|
||||||
const Point_2 * ipoint = CGAL::object_cast<Point_2>(&result);
|
|
||||||
assert( ipoint != NULL );
|
assert( ipoint != NULL );
|
||||||
|
|
||||||
u = *ipoint;
|
u = *ipoint;
|
||||||
if ( s.top() != u ) {
|
if ( s.top() != u ) {
|
||||||
s.push( u );
|
s.push( u );
|
||||||
|
|
@ -555,13 +520,14 @@ private:
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
// Case R3
|
// Case R3
|
||||||
Ray_2 ray( query_pt, vertices[i] );
|
Ray_2 ray( q, vertices[i] );
|
||||||
Segment_2 seg( s_j_prev, s_j );
|
Segment_2 seg( s_j_prev, s_j );
|
||||||
Object_2 result = CGAL::Visibility_2::intersect_2
|
|
||||||
<Geometry_traits_2, Segment_2, Ray_2>
|
Object_2 result = Visibility_2::intersect_2( traits, seg, ray );
|
||||||
( geom_traits, seg, ray );
|
const Point_2 * ipoint = object_cast<Point_2>(&result);
|
||||||
const Point_2 * ipoint = CGAL::object_cast<Point_2>(&result);
|
|
||||||
assert( ipoint != NULL );
|
assert( ipoint != NULL );
|
||||||
|
|
||||||
u = *ipoint;
|
u = *ipoint;
|
||||||
if ( s.top() != u ) {
|
if ( s.top() != u ) {
|
||||||
s.push( u );
|
s.push( u );
|
||||||
|
|
@ -579,21 +545,18 @@ private:
|
||||||
|
|
||||||
/*! Scans the vertices starting from index 'i' for the first visible vertex
|
/*! Scans the vertices starting from index 'i' for the first visible vertex
|
||||||
out of the back hidden window */
|
out of the back hidden window */
|
||||||
void scana(int& i, Point_2& w, const Point_2& query_pt) const {
|
void scana(int& i, Point_2& w, const Point_2& q) const {
|
||||||
// Scan v_i, v_i+1, ..., v_n for the first edge to intersect (z, s_t)
|
// Scan v_i, v_i+1, ..., v_n for the first edge to intersect (z, s_t)
|
||||||
Point_2 u;
|
Point_2 u;
|
||||||
int k = scan_edges( i, query_pt, s.top(), u, true );
|
int k = scan_edges( i, q, s.top(), u, true );
|
||||||
|
|
||||||
|
Orientation orient1 =
|
||||||
|
Visibility_2::orientation_2(traits, q, vertices[k], vertices[k+1] );
|
||||||
|
|
||||||
|
if ( orient1 == RIGHT_TURN ) {
|
||||||
|
bool fwd = Visibility_2::collinear_are_ordered_along_line_2
|
||||||
|
( traits, q, s.top(), u );
|
||||||
|
|
||||||
CGAL::Orientation orient1 = CGAL::Visibility_2::orientation_2
|
|
||||||
<Geometry_traits_2>
|
|
||||||
( geom_traits,
|
|
||||||
query_pt,
|
|
||||||
vertices[k],
|
|
||||||
vertices[k+1] );
|
|
||||||
if ( orient1 == CGAL::RIGHT_TURN ) {
|
|
||||||
bool fwd = CGAL::Visibility_2::collinear_are_ordered_along_line_2
|
|
||||||
<Geometry_traits_2>
|
|
||||||
( geom_traits, query_pt, s.top(), u );
|
|
||||||
if ( !fwd ) {
|
if ( !fwd ) {
|
||||||
// Case A1
|
// Case A1
|
||||||
upcase = RIGHT;
|
upcase = RIGHT;
|
||||||
|
|
@ -618,7 +581,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Find the first edge interecting the segment (v_0, s_t) */
|
/*! Find the first edge interecting the segment (v_0, s_t) */
|
||||||
void scanb(int& i, Point_2& w, const Point_2& query_pt) const {
|
void scanb(int& i, Point_2& w, const Point_2& q) const {
|
||||||
if ( i == vertices.size() - 1 ) {
|
if ( i == vertices.size() - 1 ) {
|
||||||
upcase = FINISH;
|
upcase = FINISH;
|
||||||
return;
|
return;
|
||||||
|
|
@ -639,7 +602,7 @@ private:
|
||||||
|
|
||||||
/*! Finds the exit from a general front hidden window by finding the first
|
/*! Finds the exit from a general front hidden window by finding the first
|
||||||
vertex to the right of the ray defined by the query_point and w*/
|
vertex to the right of the ray defined by the query_point and w*/
|
||||||
void scanc(int& i, Point_2& w, const Point_2& query_pt) const {
|
void scanc(int& i, Point_2& w, const Point_2& q) const {
|
||||||
Point_2 u;
|
Point_2 u;
|
||||||
int k = scan_edges( i, s.top(), w, u, false );
|
int k = scan_edges( i, s.top(), w, u, false );
|
||||||
upcase = RIGHT;
|
upcase = RIGHT;
|
||||||
|
|
@ -648,7 +611,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! find the first edge intersecting the given window (s_t, w) */
|
/*! find the first edge intersecting the given window (s_t, w) */
|
||||||
void scand(int& i, Point_2& w, const Point_2& query_pt) const {
|
void scand(int& i, Point_2& w, const Point_2& q) const {
|
||||||
Point_2 u;
|
Point_2 u;
|
||||||
int k = scan_edges( i, s.top(), w, u, false );
|
int k = scan_edges( i, s.top(), w, u, false );
|
||||||
upcase = LEFT;
|
upcase = LEFT;
|
||||||
|
|
@ -669,14 +632,14 @@ private:
|
||||||
Point_2& u,
|
Point_2& u,
|
||||||
bool is_ray ) const
|
bool is_ray ) const
|
||||||
{
|
{
|
||||||
CGAL::Orientation old_orient = CGAL::RIGHT_TURN;
|
Orientation old_orient = RIGHT_TURN;
|
||||||
Ray_2 ray( ray_begin, ray_end );
|
Ray_2 ray( ray_begin, ray_end );
|
||||||
Segment_2 s2( ray_begin, ray_end );
|
Segment_2 s2( ray_begin, ray_end );
|
||||||
int k;
|
int k;
|
||||||
Object_2 result;
|
Object_2 result;
|
||||||
for ( k = i; k+1 < vertices.size(); k++ ) {
|
for ( k = i; k+1 < vertices.size(); k++ ) {
|
||||||
CGAL::Orientation curr_orient = CGAL::Visibility_2::orientation_2
|
Orientation curr_orient = Visibility_2::orientation_2
|
||||||
( geom_traits,
|
( traits,
|
||||||
ray_begin,
|
ray_begin,
|
||||||
ray_end,
|
ray_end,
|
||||||
vertices[k+1] );
|
vertices[k+1] );
|
||||||
|
|
@ -684,15 +647,15 @@ private:
|
||||||
// Orientation switch, an intersection may occur
|
// Orientation switch, an intersection may occur
|
||||||
Segment_2 seg( vertices[k], vertices[k+1] );
|
Segment_2 seg( vertices[k], vertices[k+1] );
|
||||||
if ( is_ray ) {
|
if ( is_ray ) {
|
||||||
if (CGAL::Visibility_2::do_intersect_2(geom_traits, seg, ray) )
|
if (Visibility_2::do_intersect_2(traits, seg, ray) )
|
||||||
{
|
{
|
||||||
result = CGAL::Visibility_2::intersect_2( geom_traits, seg, ray );
|
result = Visibility_2::intersect_2( traits, seg, ray );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Visibility_2::do_intersect_2(geom_traits, seg, s2) )
|
if (Visibility_2::do_intersect_2(traits, seg, s2) )
|
||||||
{
|
{
|
||||||
result = Visibility_2::intersect_2( geom_traits, seg, s2 );
|
result = Visibility_2::intersect_2( traits, seg, s2 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -700,7 +663,7 @@ private:
|
||||||
old_orient = curr_orient;
|
old_orient = curr_orient;
|
||||||
}
|
}
|
||||||
assert( k+1<vertices.size() );
|
assert( k+1<vertices.size() );
|
||||||
const Point_2 * ipoint = CGAL::object_cast<Point_2>( &result );
|
const Point_2 * ipoint = object_cast<Point_2>( &result );
|
||||||
if ( ipoint ) {
|
if ( ipoint ) {
|
||||||
u = *ipoint;
|
u = *ipoint;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,11 @@ void print_arrangement_by_face(const Arrangement_2& arr) {
|
||||||
typedef typename Arrangement_2::Face_const_iterator Face_const_iterator;
|
typedef typename Arrangement_2::Face_const_iterator Face_const_iterator;
|
||||||
typedef typename Arrangement_2::Ccb_halfedge_const_circulator
|
typedef typename Arrangement_2::Ccb_halfedge_const_circulator
|
||||||
Ccb_halfedge_const_circulator;
|
Ccb_halfedge_const_circulator;
|
||||||
Face_const_iterator fit;
|
Face_const_iterator f;
|
||||||
for (fit = arr.faces_begin() ; fit != arr.faces_end() ; fit++) {
|
for (f = arr.faces_begin() ; f != arr.faces_end() ; f++) {
|
||||||
if (!fit->is_unbounded()) {
|
if (!f->is_unbounded()) {
|
||||||
std::cout << "FACE\n";
|
std::cout << "FACE\n";
|
||||||
print_simple_face<Face_const_iterator, Ccb_halfedge_const_circulator>(fit);
|
print_simple_face<Face_const_iterator, Ccb_halfedge_const_circulator>(f);
|
||||||
std::cout << "END FACE\n";
|
std::cout << "END FACE\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,9 +115,11 @@ bool collinear(const Geometry_traits_2 *geom_traits,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Geometry_traits_2, class _Curve_first, class _Curve_second >
|
template <class Geometry_traits_2, class _Curve_first, class _Curve_second >
|
||||||
typename Geometry_traits_2::Object_2 intersect_2(const Geometry_traits_2 *geom_traits,
|
typename Geometry_traits_2::Object_2 intersect_2(
|
||||||
|
const Geometry_traits_2 *geom_traits,
|
||||||
const _Curve_first& s1,
|
const _Curve_first& s1,
|
||||||
const _Curve_second& s2) {
|
const _Curve_second& s2)
|
||||||
|
{
|
||||||
|
|
||||||
typedef typename Geometry_traits_2::Kernel Kernel;
|
typedef typename Geometry_traits_2::Kernel Kernel;
|
||||||
const Kernel *kernel = static_cast<const Kernel*> (geom_traits);
|
const Kernel *kernel = static_cast<const Kernel*> (geom_traits);
|
||||||
|
|
@ -126,9 +128,11 @@ typename Geometry_traits_2::Object_2 intersect_2(const Geometry_traits_2 *geom_t
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Geometry_traits_2>
|
template <class Geometry_traits_2>
|
||||||
CGAL::Comparison_result compare_xy_2(const Geometry_traits_2 *geom_traits,
|
CGAL::Comparison_result compare_xy_2(
|
||||||
|
const Geometry_traits_2 *geom_traits,
|
||||||
const typename Geometry_traits_2::Point_2 &p,
|
const typename Geometry_traits_2::Point_2 &p,
|
||||||
const typename Geometry_traits_2::Point_2 &q) {
|
const typename Geometry_traits_2::Point_2 &q)
|
||||||
|
{
|
||||||
|
|
||||||
typename Geometry_traits_2::Compare_xy_2 cmp =
|
typename Geometry_traits_2::Compare_xy_2 cmp =
|
||||||
geom_traits->compare_xy_2_object();
|
geom_traits->compare_xy_2_object();
|
||||||
|
|
@ -157,10 +161,12 @@ bool do_intersect_2(const Geometry_traits_2 *geom_traits,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Geometry_traits_2>
|
template <class Geometry_traits_2>
|
||||||
bool collinear_are_ordered_along_line_2(const Geometry_traits_2 *geom_traits,
|
bool collinear_are_ordered_along_line_2(
|
||||||
|
const Geometry_traits_2 *geom_traits,
|
||||||
const typename Geometry_traits_2::Point_2 &p,
|
const typename Geometry_traits_2::Point_2 &p,
|
||||||
const typename Geometry_traits_2::Point_2 &q,
|
const typename Geometry_traits_2::Point_2 &q,
|
||||||
const typename Geometry_traits_2::Point_2 &r) {
|
const typename Geometry_traits_2::Point_2 &r)
|
||||||
|
{
|
||||||
|
|
||||||
typename Geometry_traits_2::Collinear_are_ordered_along_line_2 coll =
|
typename Geometry_traits_2::Collinear_are_ordered_along_line_2 coll =
|
||||||
geom_traits->collinear_are_ordered_along_line_2_object();
|
geom_traits->collinear_are_ordered_along_line_2_object();
|
||||||
|
|
@ -195,10 +201,11 @@ typename Geometry_traits_2::Point_2 construct_projected_point_2(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//construct an arrangement of visibility region from a vector of circular ordered vertices with respect to the query point
|
// construct an arrangement of visibility region from a vector of
|
||||||
|
// circular ordered vertices with respect to the query point
|
||||||
template <class Visibility_2, class Visibility_arrangement_2>
|
template <class Visibility_2, class Visibility_arrangement_2>
|
||||||
void report_while_handling_needles(
|
void report_while_handling_needles(
|
||||||
const typename Visibility_2::Arrangement_2::Geometry_traits_2 *geom_traits,
|
const typename Visibility_2::Arrangement_2::Geometry_traits_2 *traits,
|
||||||
const typename Visibility_2::Arrangement_2::Point_2& q,
|
const typename Visibility_2::Arrangement_2::Point_2& q,
|
||||||
std::vector<typename Visibility_2::Arrangement_2::Point_2>& points,
|
std::vector<typename Visibility_2::Arrangement_2::Point_2>& points,
|
||||||
Visibility_arrangement_2& arr_out) {
|
Visibility_arrangement_2& arr_out) {
|
||||||
|
|
@ -211,17 +218,14 @@ void report_while_handling_needles(
|
||||||
typedef typename Geometry_traits_2::Segment_2 Segment_2;
|
typedef typename Geometry_traits_2::Segment_2 Segment_2;
|
||||||
typedef typename Geometry_traits_2::Direction_2 Direction_2;
|
typedef typename Geometry_traits_2::Direction_2 Direction_2;
|
||||||
|
|
||||||
|
|
||||||
typename std::vector<Segment_2>::size_type i = 0;
|
typename std::vector<Segment_2>::size_type i = 0;
|
||||||
|
|
||||||
if (points.front() == points.back()) {
|
if (points.front() == points.back()) {
|
||||||
points.pop_back();
|
points.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (collinear(geom_traits,
|
while (collinear(traits, q, points[i], points.back())) {
|
||||||
q,
|
|
||||||
points[i],
|
|
||||||
points.back())) {
|
|
||||||
|
|
||||||
points.push_back(points[i]);
|
points.push_back(points[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
@ -229,45 +233,62 @@ void report_while_handling_needles(
|
||||||
points.push_back(points[i]);
|
points.push_back(points[i]);
|
||||||
|
|
||||||
typename Visibility_arrangement_2::Halfedge_handle he_handle;
|
typename Visibility_arrangement_2::Halfedge_handle he_handle;
|
||||||
typename Visibility_arrangement_2::Vertex_handle v_trg; //the handle of vertex where the next segment is inserted
|
|
||||||
typename Visibility_arrangement_2::Vertex_handle v_fst; //the handle of vertex inserted first
|
|
||||||
typename Visibility_arrangement_2::Vertex_handle v_needle_end; //the handle of vertex of the end of a needle
|
|
||||||
|
|
||||||
v_trg = v_fst = arr_out.insert_in_face_interior(points[i], arr_out.unbounded_face());
|
//the handle of vertex where the next segment is inserted
|
||||||
|
typename Visibility_arrangement_2::Vertex_handle v_trg;
|
||||||
|
|
||||||
|
//the handle of vertex inserted first
|
||||||
|
typename Visibility_arrangement_2::Vertex_handle v_fst;
|
||||||
|
|
||||||
|
//the handle of vertex of the end of a needle
|
||||||
|
typename Visibility_arrangement_2::Vertex_handle v_needle_end;
|
||||||
|
|
||||||
|
|
||||||
|
v_trg = v_fst = arr_out.insert_in_face_interior(points[i],
|
||||||
|
arr_out.unbounded_face());
|
||||||
|
|
||||||
//find a point that is right after a needle
|
//find a point that is right after a needle
|
||||||
while (i+1 < points.size()) {
|
while (i+1 < points.size()) {
|
||||||
if ( collinear(geom_traits,
|
if ( collinear(traits, points[i], points[i+1], q)) {
|
||||||
points[i],
|
|
||||||
points[i+1],
|
|
||||||
q)) {
|
|
||||||
typename Visibility_arrangement_2::Vertex_handle v_needle_begin = v_trg;
|
typename Visibility_arrangement_2::Vertex_handle v_needle_begin = v_trg;
|
||||||
std::vector<Point_2> forward_needle; //vertices of the needle that are not between q and v_needle_begin; their direction is leaving q;
|
|
||||||
std::vector<Point_2> backward_needle; //vertices of the needle that are not between q and v_needle_begin; their direction is towards q;
|
std::vector<Point_2> forward_needle; //vertices of the needle that are not
|
||||||
std::vector<Point_2> part_in_q_side; //vertices of the needle that are between q and v_needle_begin
|
//between q and v_needle_begin;
|
||||||
|
//their direction is leaving q;
|
||||||
|
|
||||||
|
std::vector<Point_2> backward_needle;//vertices of the needle that are not
|
||||||
|
//between q and v_needle_begin;
|
||||||
|
//their direction is towards q;
|
||||||
|
|
||||||
|
std::vector<Point_2> part_in_q_side; //vertices of the needle that are
|
||||||
|
//between q and v_needle_begin
|
||||||
part_in_q_side.push_back(points[i]);
|
part_in_q_side.push_back(points[i]);
|
||||||
forward_needle.push_back((points[i]));
|
forward_needle.push_back((points[i]));
|
||||||
|
|
||||||
bool same_side_of_q = (compare_xy_2(geom_traits, points[i], q)==compare_xy_2(geom_traits, points[i], points[i+1]));
|
bool same_side_of_q = (compare_xy_2(traits, points[i], q) ==
|
||||||
|
compare_xy_2(traits, points[i], points[i+1]));
|
||||||
|
|
||||||
if (same_side_of_q)
|
if (same_side_of_q)
|
||||||
part_in_q_side.push_back(points[i+1]);
|
part_in_q_side.push_back(points[i+1]);
|
||||||
else
|
else
|
||||||
forward_needle.push_back(points[i+1]);
|
forward_needle.push_back(points[i+1]);
|
||||||
i++;
|
i++;
|
||||||
while (i+1< points.size() && orientation_2(geom_traits,
|
while (i+1 < points.size() &&
|
||||||
points[i],
|
orientation_2(traits, points[i], points[i+1], q ) ==
|
||||||
points[i+1],
|
CGAL::COLLINEAR)
|
||||||
q ) == CGAL::COLLINEAR) {
|
{
|
||||||
if (same_side_of_q) {
|
if (same_side_of_q) {
|
||||||
part_in_q_side.push_back(points[i+1]);
|
part_in_q_side.push_back(points[i+1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (compare_xy_2(geom_traits, part_in_q_side.front(), q)
|
if (compare_xy_2(traits, part_in_q_side.front(), q) ==
|
||||||
== compare_xy_2(geom_traits, part_in_q_side.front(), points[i+1])) {
|
compare_xy_2(traits, part_in_q_side.front(), points[i+1]))
|
||||||
|
{
|
||||||
same_side_of_q = true;
|
same_side_of_q = true;
|
||||||
part_in_q_side.push_back(points[i+1]);
|
part_in_q_side.push_back(points[i+1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (less_distance_to_point_2(geom_traits, q, points[i], points[i+1]))
|
if (less_distance_to_point_2(traits, q, points[i], points[i+1]))
|
||||||
forward_needle.push_back(points[i+1]);
|
forward_needle.push_back(points[i+1]);
|
||||||
else
|
else
|
||||||
backward_needle.push_back(points[i+1]);
|
backward_needle.push_back(points[i+1]);
|
||||||
|
|
@ -296,11 +317,11 @@ void report_while_handling_needles(
|
||||||
while (itr_fst < forward_needle.size() &&
|
while (itr_fst < forward_needle.size() &&
|
||||||
itr_snd < backward_needle.size()) {
|
itr_snd < backward_needle.size()) {
|
||||||
|
|
||||||
if (less_distance_to_point_2(geom_traits,
|
if (less_distance_to_point_2(traits,
|
||||||
q,
|
q,
|
||||||
forward_needle[itr_fst],
|
forward_needle[itr_fst],
|
||||||
backward_needle[itr_snd])) {
|
backward_needle[itr_snd]))
|
||||||
|
{
|
||||||
merged_needle.push_back(forward_needle[itr_fst]);
|
merged_needle.push_back(forward_needle[itr_fst]);
|
||||||
itr_fst++;
|
itr_fst++;
|
||||||
}
|
}
|
||||||
|
|
@ -319,11 +340,15 @@ void report_while_handling_needles(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int p = 0 ; p+1 < merged_needle.size() ; p++) {
|
for (unsigned int p = 0 ; p+1 < merged_needle.size() ; p++) {
|
||||||
if (CGAL::Visibility_2::compare_xy_2<Geometry_traits_2>(geom_traits, merged_needle[p], merged_needle[p+1]) == CGAL::SMALLER) {
|
if (compare_xy_2<Geometry_traits_2>(
|
||||||
he_handle = arr_out.insert_from_left_vertex(Segment_2(merged_needle[p], merged_needle[p+1]), v_trg);
|
traits, merged_needle[p], merged_needle[p+1]) == SMALLER)
|
||||||
|
{
|
||||||
|
he_handle = arr_out.insert_from_left_vertex(
|
||||||
|
Segment_2(merged_needle[p], merged_needle[p+1]), v_trg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
he_handle = arr_out.insert_from_right_vertex(Segment_2(merged_needle[p], merged_needle[p+1]), v_trg);
|
he_handle = arr_out.insert_from_right_vertex(
|
||||||
|
Segment_2(merged_needle[p], merged_needle[p+1]), v_trg);
|
||||||
}
|
}
|
||||||
v_trg = he_handle->target();
|
v_trg = he_handle->target();
|
||||||
if (merged_needle[p+1] == end_of_needle) {
|
if (merged_needle[p+1] == end_of_needle) {
|
||||||
|
|
@ -334,11 +359,15 @@ void report_while_handling_needles(
|
||||||
//insert the part of needle between q and v_needle_begin
|
//insert the part of needle between q and v_needle_begin
|
||||||
v_trg = v_needle_begin;
|
v_trg = v_needle_begin;
|
||||||
for (unsigned int p = 0 ; p+1 < part_in_q_side.size() ; p++) {
|
for (unsigned int p = 0 ; p+1 < part_in_q_side.size() ; p++) {
|
||||||
if (CGAL::Visibility_2::compare_xy_2<Geometry_traits_2>(geom_traits, part_in_q_side[p], part_in_q_side[p+1]) == CGAL::SMALLER) {
|
if (compare_xy_2<Geometry_traits_2>(
|
||||||
he_handle = arr_out.insert_from_left_vertex(Segment_2(part_in_q_side[p], part_in_q_side[p+1]), v_trg);
|
traits, part_in_q_side[p], part_in_q_side[p+1]) == SMALLER)
|
||||||
|
{
|
||||||
|
he_handle = arr_out.insert_from_left_vertex(
|
||||||
|
Segment_2(part_in_q_side[p], part_in_q_side[p+1]), v_trg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
he_handle = arr_out.insert_from_right_vertex(Segment_2(part_in_q_side[p], part_in_q_side[p+1]), v_trg);
|
he_handle = arr_out.insert_from_right_vertex(
|
||||||
|
Segment_2(part_in_q_side[p], part_in_q_side[p+1]), v_trg);
|
||||||
}
|
}
|
||||||
v_trg = he_handle->target();
|
v_trg = he_handle->target();
|
||||||
}
|
}
|
||||||
|
|
@ -347,11 +376,15 @@ void report_while_handling_needles(
|
||||||
v_trg = v_needle_end;
|
v_trg = v_needle_end;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (CGAL::Visibility_2::compare_xy_2<Geometry_traits_2>(geom_traits, v_trg->point(), points[i+1]) == CGAL::SMALLER) {
|
if (compare_xy_2<Geometry_traits_2>(
|
||||||
he_handle = arr_out.insert_from_left_vertex(Segment_2(points[i], points[i+1]), v_trg);
|
traits, v_trg->point(), points[i+1]) == SMALLER)
|
||||||
|
{
|
||||||
|
he_handle = arr_out.insert_from_left_vertex(
|
||||||
|
Segment_2(points[i], points[i+1]), v_trg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
he_handle = arr_out.insert_from_right_vertex(Segment_2(points[i], points[i+1]), v_trg);
|
he_handle = arr_out.insert_from_right_vertex(
|
||||||
|
Segment_2(points[i], points[i+1]), v_trg);
|
||||||
}
|
}
|
||||||
v_trg = he_handle->target();
|
v_trg = he_handle->target();
|
||||||
i++;
|
i++;
|
||||||
|
|
@ -359,7 +392,9 @@ void report_while_handling_needles(
|
||||||
if (i+2 == points.size()) {
|
if (i+2 == points.size()) {
|
||||||
//close the boundary
|
//close the boundary
|
||||||
v_trg = he_handle->target();
|
v_trg = he_handle->target();
|
||||||
arr_out.insert_at_vertices(Segment_2(points[points.size()-2], points[points.size()-1]), v_trg, v_fst);
|
arr_out.insert_at_vertices(Segment_2(points[points.size()-2],
|
||||||
|
points[points.size()-1]),
|
||||||
|
v_trg, v_fst);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ void test_interface() {
|
||||||
template <class Visibility_2>
|
template <class Visibility_2>
|
||||||
void run_tests_with_changes_to_arr() {
|
void run_tests_with_changes_to_arr() {
|
||||||
|
|
||||||
std::cout << "\tTesting changes to attached arrangement:";
|
std::cout << " Testing changes to attached arrangement:";
|
||||||
|
|
||||||
typedef typename Visibility_2::Arrangement_2 Arrangement_2;
|
typedef typename Visibility_2::Arrangement_2 Arrangement_2;
|
||||||
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
||||||
|
|
@ -543,11 +543,11 @@ void run_tests_with_changes_to_arr() {
|
||||||
|
|
||||||
// Change attached arrangement and query again
|
// Change attached arrangement and query again
|
||||||
|
|
||||||
arr.clear();
|
//arr.clear();
|
||||||
|
|
||||||
CGAL::insert(arr, Segment_2(vertices[0], vertices[1]));
|
//CGAL::insert(arr, Segment_2(vertices[0], vertices[1]));
|
||||||
CGAL::insert(arr, Segment_2(vertices[1], vertices[3]));
|
CGAL::insert(arr, Segment_2(vertices[1], vertices[3]));
|
||||||
CGAL::insert(arr, Segment_2(vertices[3], vertices[0]));
|
//CGAL::insert(arr, Segment_2(vertices[3], vertices[0]));
|
||||||
|
|
||||||
CGAL::assign(location, get_location(arr, query));
|
CGAL::assign(location, get_location(arr, query));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue