mirror of https://github.com/CGAL/cgal
fixing problems in point location 1) inherit from base generator 2) add middle edges landmarks strategy
This commit is contained in:
parent
e02cb6172a
commit
638b292458
|
|
@ -23,13 +23,7 @@
|
||||||
* Definition of the Arr_grid_landmarks_generator<Arrangement> template.
|
* Definition of the Arr_grid_landmarks_generator<Arrangement> template.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_observer.h>
|
#include <CGAL/Arr_point_location/Arr_lm_generator_base.h>
|
||||||
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
|
|
||||||
#include <CGAL/Arr_batched_point_location.h>
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -37,14 +31,22 @@ CGAL_BEGIN_NAMESPACE
|
||||||
* A generator for the landmarks point-locatoion class, which uses a
|
* A generator for the landmarks point-locatoion class, which uses a
|
||||||
* set of points on a grid as its set of landmarks.
|
* set of points on a grid as its set of landmarks.
|
||||||
*/
|
*/
|
||||||
template <class Arrangement_>
|
template <class Arrangement_,
|
||||||
|
class Nearest_neighbor_ =
|
||||||
|
Arr_landmarks_nearest_neighbor<typename
|
||||||
|
Arrangement_::Geometry_traits_2> >
|
||||||
class Arr_grid_landmarks_generator :
|
class Arr_grid_landmarks_generator :
|
||||||
public Arr_observer <Arrangement_>
|
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef Arrangement_ Arrangement_2;
|
typedef Arrangement_ Arrangement_2;
|
||||||
typedef Arr_grid_landmarks_generator<Arrangement_2> Self;
|
typedef Nearest_neighbor_ Nearest_neighbor;
|
||||||
|
|
||||||
|
typedef Arr_landmarks_generator_base<Arrangement_2,
|
||||||
|
Nearest_neighbor> Base;
|
||||||
|
typedef Arr_grid_landmarks_generator<Arrangement_2,
|
||||||
|
Nearest_neighbor> Self;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
||||||
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
|
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
|
||||||
|
|
@ -63,7 +65,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef std::vector<Point_2> Points_set;
|
typedef typename Base::Points_set Points_set;
|
||||||
typedef std::pair<Point_2,CGAL::Object> PL_pair;
|
typedef std::pair<Point_2,CGAL::Object> PL_pair;
|
||||||
typedef std::vector<PL_pair> Pairs_set;
|
typedef std::vector<PL_pair> Pairs_set;
|
||||||
|
|
||||||
|
|
@ -98,7 +100,7 @@ public:
|
||||||
/*! Constructor. */
|
/*! Constructor. */
|
||||||
|
|
||||||
Arr_grid_landmarks_generator (const Arrangement_2& arr) :
|
Arr_grid_landmarks_generator (const Arrangement_2& arr) :
|
||||||
Arr_observer<Arrangement_2> (const_cast<Arrangement_2 &>(arr)),
|
Base (arr),
|
||||||
ignore_notifications (false),
|
ignore_notifications (false),
|
||||||
updated (false),
|
updated (false),
|
||||||
num_landmarks (0),
|
num_landmarks (0),
|
||||||
|
|
@ -110,7 +112,7 @@ public:
|
||||||
|
|
||||||
Arr_grid_landmarks_generator (const Arrangement_2& arr,
|
Arr_grid_landmarks_generator (const Arrangement_2& arr,
|
||||||
unsigned int n_landmarks) :
|
unsigned int n_landmarks) :
|
||||||
Arr_observer<Arrangement_2> (const_cast<Arrangement_2 &>(arr)),
|
Base (arr),
|
||||||
ignore_notifications (false),
|
ignore_notifications (false),
|
||||||
updated (false),
|
updated (false),
|
||||||
num_landmarks (n_landmarks),
|
num_landmarks (n_landmarks),
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
Nearest_neighbor> Self;
|
Nearest_neighbor> Self;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Point_2 Point_2;
|
typedef typename Arrangement_2::Point_2 Point_2;
|
||||||
typedef std::vector<Point_2> Points_set;
|
typedef typename Base::Points_set Points_set;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Vertex_const_iterator
|
typedef typename Arrangement_2::Vertex_const_iterator
|
||||||
Vertex_const_iterator;
|
Vertex_const_iterator;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
* Definition of the Arr_middle_edges_landmarks_generator<Arrangement> template.
|
* Definition of the Arr_middle_edges_landmarks_generator<Arrangement> template.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_point_location/Arr_lm_generator.h>
|
#include <CGAL/Arr_point_location/Arr_lm_generator_base.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -40,13 +40,13 @@ template <class Arrangement_,
|
||||||
class Nearest_neighbor_
|
class Nearest_neighbor_
|
||||||
= Arr_landmarks_nearest_neighbor <typename Arrangement_::Traits_2> >
|
= Arr_landmarks_nearest_neighbor <typename Arrangement_::Traits_2> >
|
||||||
class Arr_middle_edges_landmarks_generator
|
class Arr_middle_edges_landmarks_generator
|
||||||
: public Arr_landmarks_generator <Arrangement_, Nearest_neighbor_>
|
: public Arr_landmarks_generator_base <Arrangement_, Nearest_neighbor_>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Arrangement_ Arrangement_2;
|
typedef Arrangement_ Arrangement_2;
|
||||||
typedef Arr_middle_edges_landmarks_generator<Arrangement_2,
|
typedef Arr_middle_edges_landmarks_generator<Arrangement_2,
|
||||||
Nearest_neighbor_> Self;
|
Nearest_neighbor_> Self;
|
||||||
typedef Arr_landmarks_generator<Arrangement_2, Nearest_neighbor_> Base;
|
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor_> Base;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Traits_2 Traits_2;
|
typedef typename Arrangement_2::Traits_2 Traits_2;
|
||||||
typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator;
|
typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator;
|
||||||
|
|
@ -78,11 +78,10 @@ public:
|
||||||
/*! Constructor. */
|
/*! Constructor. */
|
||||||
Arr_middle_edges_landmarks_generator
|
Arr_middle_edges_landmarks_generator
|
||||||
(const Arrangement_2& arr, int /* lm_num */ = -1) :
|
(const Arrangement_2& arr, int /* lm_num */ = -1) :
|
||||||
Arr_landmarks_generator<Arrangement_2, Nearest_neighbor_> (arr)
|
Base (arr)
|
||||||
{
|
{
|
||||||
CGAL_PRINT_DEBUG("Arr_middle_edges_landmarks_generator constructor.");
|
//CGAL_PRINT_DEBUG("Arr_middle_edges_landmarks_generator constructor.");
|
||||||
|
this->build_landmark_set();
|
||||||
this->build_landmarks_set();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Observer functions that should be empty, because they
|
//Observer functions that should be empty, because they
|
||||||
|
|
@ -107,8 +106,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void _create_nn_points_set (NN_Points_set &nn_points)
|
virtual void _create_nn_points_set (NN_Points_set &nn_points)
|
||||||
{
|
{
|
||||||
CGAL_PRINT_DEBUG("create_middle_edges_points_list");
|
//CGAL_PRINT_DEBUG("create_middle_edges_points_list");
|
||||||
|
|
||||||
Edge_const_iterator eit;
|
Edge_const_iterator eit;
|
||||||
Halfedge_const_handle hh;
|
Halfedge_const_handle hh;
|
||||||
Arrangement_2 *arr = this->arrangement();
|
Arrangement_2 *arr = this->arrangement();
|
||||||
|
|
@ -132,7 +130,7 @@ protected:
|
||||||
const Point_2& p2 = hh->target()->point();
|
const Point_2& p2 = hh->target()->point();
|
||||||
Point_2 p ((p1.x()+p2.x())/2, (p1.y()+p2.y())/2);
|
Point_2 p ((p1.x()+p2.x())/2, (p1.y()+p2.y())/2);
|
||||||
|
|
||||||
CGAL_PRINT_DEBUG("mid point is= " << p);
|
//CGAL_PRINT_DEBUG("mid point is= " << p);
|
||||||
|
|
||||||
CGAL::Object obj = CGAL::make_object(hh);
|
CGAL::Object obj = CGAL::make_object(hh);
|
||||||
NN_Point_2 np(p, obj);
|
NN_Point_2 np(p, obj);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public:
|
||||||
Nearest_neighbor> Self;
|
Nearest_neighbor> Self;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Point_2 Point_2;
|
typedef typename Arrangement_2::Point_2 Point_2;
|
||||||
typedef std::vector<Point_2> Points_set;
|
typedef typename Base::Points_set Points_set;
|
||||||
|
|
||||||
typedef typename Arrangement_2::Vertex_const_iterator
|
typedef typename Arrangement_2::Vertex_const_iterator
|
||||||
Vertex_const_iterator;
|
Vertex_const_iterator;
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,7 @@
|
||||||
* Definition of the Arr_landmarks_vertices_generator<Arrangement> template.
|
* Definition of the Arr_landmarks_vertices_generator<Arrangement> template.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <list>
|
#include <CGAL/Arr_point_location/Arr_lm_generator_base.h>
|
||||||
#include <CGAL/Arr_observer.h>
|
|
||||||
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
|
|
||||||
#include <CGAL/Arr_point_location/Arr_lm_nearest_neighbor.h>
|
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -39,7 +36,7 @@ template <class Arrangement_,
|
||||||
Arr_landmarks_nearest_neighbor<typename
|
Arr_landmarks_nearest_neighbor<typename
|
||||||
Arrangement_::Geometry_traits_2> >
|
Arrangement_::Geometry_traits_2> >
|
||||||
class Arr_landmarks_vertices_generator :
|
class Arr_landmarks_vertices_generator :
|
||||||
public Arr_observer<Arrangement_>
|
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -47,6 +44,8 @@ public:
|
||||||
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
|
||||||
typedef Nearest_neighbor_ Nearest_neighbor;
|
typedef Nearest_neighbor_ Nearest_neighbor;
|
||||||
|
|
||||||
|
typedef Arr_landmarks_generator_base<Arrangement_2,
|
||||||
|
Nearest_neighbor> Base;
|
||||||
typedef Arr_landmarks_vertices_generator<Arrangement_2,
|
typedef Arr_landmarks_vertices_generator<Arrangement_2,
|
||||||
Nearest_neighbor> Self;
|
Nearest_neighbor> Self;
|
||||||
|
|
||||||
|
|
@ -61,6 +60,8 @@ public:
|
||||||
typedef typename Arrangement_2::Point_2 Point_2;
|
typedef typename Arrangement_2::Point_2 Point_2;
|
||||||
typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2;
|
typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2;
|
||||||
|
|
||||||
|
typedef typename Base::Points_set Points_set;
|
||||||
|
|
||||||
typedef typename Nearest_neighbor::NN_Point_2 NN_Point_2;
|
typedef typename Nearest_neighbor::NN_Point_2 NN_Point_2;
|
||||||
typedef std::list<NN_Point_2> NN_Point_list;
|
typedef std::list<NN_Point_2> NN_Point_list;
|
||||||
|
|
||||||
|
|
@ -88,7 +89,7 @@ public:
|
||||||
|
|
||||||
/*! Constructor. */
|
/*! Constructor. */
|
||||||
Arr_landmarks_vertices_generator (const Arrangement_2& arr) :
|
Arr_landmarks_vertices_generator (const Arrangement_2& arr) :
|
||||||
Arr_observer<Arrangement_2> (const_cast<Arrangement_2 &>(arr)),
|
Base (arr),
|
||||||
ignore_notifications (false),
|
ignore_notifications (false),
|
||||||
updated (false),
|
updated (false),
|
||||||
num_small_not_updated_changes(0),
|
num_small_not_updated_changes(0),
|
||||||
|
|
@ -98,6 +99,12 @@ public:
|
||||||
build_landmark_set();
|
build_landmark_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void _create_points_set (Points_set & /* points */)
|
||||||
|
{
|
||||||
|
std::cerr << "should not reach here!"<< std::endl;
|
||||||
|
CGAL_error();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Creates the landmark set, using all arrangement vertices.
|
* Creates the landmark set, using all arrangement vertices.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include <CGAL/Arr_point_location/Arr_lm_random_generator.h>
|
#include <CGAL/Arr_point_location/Arr_lm_random_generator.h>
|
||||||
#include <CGAL/Arr_point_location/Arr_lm_grid_generator.h>
|
#include <CGAL/Arr_point_location/Arr_lm_grid_generator.h>
|
||||||
#include <CGAL/Arr_point_location/Arr_lm_halton_generator.h>
|
#include <CGAL/Arr_point_location/Arr_lm_halton_generator.h>
|
||||||
|
#include <CGAL/Arr_point_location/Arr_lm_middle_edges_generator.h>
|
||||||
|
//#include <CGAL/Arr_triangulation_point_location.h>
|
||||||
|
|
||||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||||
|
|
@ -61,6 +63,12 @@ typedef CGAL::Arr_halton_landmarks_generator<Arrangement_2>
|
||||||
Halton_lm_generator;
|
Halton_lm_generator;
|
||||||
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Halton_lm_generator>
|
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Halton_lm_generator>
|
||||||
Lm_halton_point_location;
|
Lm_halton_point_location;
|
||||||
|
typedef CGAL::Arr_middle_edges_landmarks_generator<Arrangement_2>
|
||||||
|
Middle_edges_generator;
|
||||||
|
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Middle_edges_generator>
|
||||||
|
Lm_middle_edges_point_location;
|
||||||
|
//typedef CGAL::Arr_triangulation_point_location<Arrangement_2>
|
||||||
|
// Lm_triangulation_point_location;
|
||||||
|
|
||||||
// ===> Add new point location type here <===
|
// ===> Add new point location type here <===
|
||||||
|
|
||||||
|
|
@ -72,7 +80,7 @@ typedef Objects_vector::iterator Object_iterator;
|
||||||
|
|
||||||
// ===> Change the number of point-location startegies
|
// ===> Change the number of point-location startegies
|
||||||
// when a new point location is added. <===
|
// when a new point location is added. <===
|
||||||
#define NUM_OF_POINT_LOCATION_STRATEGIES 7
|
#define NUM_OF_POINT_LOCATION_STRATEGIES 8
|
||||||
|
|
||||||
/*! */
|
/*! */
|
||||||
int check_point_location (Arrangement_2 &arr, Points_list &plist)
|
int check_point_location (Arrangement_2 &arr, Points_list &plist)
|
||||||
|
|
@ -108,6 +116,18 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
|
||||||
timer.stop();
|
timer.stop();
|
||||||
std::cout << "Halton lm construction took " << timer.time() <<std::endl;
|
std::cout << "Halton lm construction took " << timer.time() <<std::endl;
|
||||||
|
|
||||||
|
timer.reset(); timer.start();
|
||||||
|
Middle_edges_generator middle_edges_g(arr);
|
||||||
|
Lm_middle_edges_point_location middle_edges_lm_pl (arr, &middle_edges_g); // 7
|
||||||
|
timer.stop();
|
||||||
|
std::cout << "Middle edges lm construction took " << timer.time() <<std::endl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
timer.reset(); timer.start();
|
||||||
|
Lm_triangulation_point_location triangulation_lm_pl (arr); // 8
|
||||||
|
timer.stop();
|
||||||
|
std::cout << "Triangulation lm construction took " << timer.time() <<std::endl;
|
||||||
|
*/
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
// ===> Add new point location instance here. <===
|
// ===> Add new point location instance here. <===
|
||||||
|
|
@ -205,6 +225,30 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
|
||||||
timer.stop(); ///END
|
timer.stop(); ///END
|
||||||
std::cout << "Halton LM location took " << timer.time() <<std::endl;
|
std::cout << "Halton LM location took " << timer.time() <<std::endl;
|
||||||
|
|
||||||
|
timer.reset();
|
||||||
|
timer.start(); //START
|
||||||
|
for (piter = plist.begin(); piter != plist.end(); piter++ )
|
||||||
|
{
|
||||||
|
q = (*piter);
|
||||||
|
obj = middle_edges_lm_pl.locate (q);
|
||||||
|
objs[7].push_back(obj);
|
||||||
|
}
|
||||||
|
timer.stop(); ///END
|
||||||
|
std::cout << "Middle edges LM location took " << timer.time() <<std::endl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
timer.reset();
|
||||||
|
timer.start(); //START
|
||||||
|
for (piter = plist.begin(); piter != plist.end(); piter++ )
|
||||||
|
{
|
||||||
|
q = (*piter);
|
||||||
|
obj = triangulation_lm_pl.locate (q);
|
||||||
|
objs[8].push_back(obj);
|
||||||
|
}
|
||||||
|
timer.stop(); ///END
|
||||||
|
std::cout << "Triangulation LM location took " << timer.time() <<std::endl;
|
||||||
|
*/
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
// ===> Add a call to operate the the new point location. <===
|
// ===> Add a call to operate the the new point location. <===
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue