replace Object

This commit is contained in:
Efi Fogel 2012-02-06 10:15:38 +00:00
parent 0d9f5aa107
commit 40fac7ad31
8 changed files with 146 additions and 194 deletions

View File

@ -41,32 +41,24 @@ namespace CGAL {
* function called "void _create_point_list(Point_list &)" which
* actually creates the list of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor <typename
Arrangement_::Geometry_traits_2> >
class Arr_landmarks_generator_base
: public Arr_observer <Arrangement_>
{
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor <Arrangement_> >
class Arr_landmarks_generator_base : public Arr_observer <Arrangement_> {
public:
typedef Arrangement_ Arrangement_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arrangement_ Arrangement_2;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arr_landmarks_generator_base<Arrangement_2,
Nearest_neighbor> Self;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
typedef typename Arrangement_2::Face_const_handle Face_const_handle;
typedef typename Arrangement_2::Vertex_handle Vertex_handle;
typedef typename Arrangement_2::Halfedge_handle Halfedge_handle;
typedef typename Arrangement_2::Face_handle Face_handle;
typedef typename Arrangement_2::Vertex_const_iterator
Vertex_const_iterator;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
typedef typename Arrangement_2::Ccb_halfedge_circulator
Ccb_halfedge_circulator;
Ccb_halfedge_circulator;
typedef typename Arrangement_2::Point_2 Point_2;
typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2;
@ -75,16 +67,19 @@ public:
typedef std::list<NN_Point_2> NN_Points_set;
typedef std::vector<Point_2> 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 typename std::vector<PL_pair>::iterator Pairs_iterator;
protected:
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Self;
protected:
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
// Data members:
const Traits_adaptor_2 *m_traits; // The associated traits object.
const Traits_adaptor_2* m_traits; // The associated traits object.
Nearest_neighbor nn; // The associated nearest neighbor object.
bool ignore_notifications;
bool updated;
@ -92,8 +87,8 @@ protected:
public:
bool is_empty() const { return nn.is_empty(); }
private:
private:
/*! Copy constructor - not supported. */
Arr_landmarks_generator_base (const Self& );

View File

@ -31,22 +31,15 @@ namespace CGAL {
* A generator for the landmarks point-locatoion class, which uses a
* set of points on a grid as its set of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<typename
Arrangement_::Geometry_traits_2> >
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_grid_landmarks_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
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 Arrangement_ Arrangement_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
@ -57,19 +50,25 @@ public:
typedef typename Arrangement_2::Halfedge_handle Halfedge_handle;
typedef typename Arrangement_2::Face_handle Face_handle;
typedef typename Arrangement_2::Ccb_halfedge_circulator
Ccb_halfedge_circulator;
Ccb_halfedge_circulator;
typedef typename Geometry_traits_2::Approximate_number_type ANT;
typedef typename Geometry_traits_2::Approximate_number_type
ANT;
typedef typename Arrangement_2::Point_2 Point_2;
typedef typename Arrangement_2::Point_2 Point_2;
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
typedef Arr_grid_landmarks_generator<Arrangement_2, Nearest_neighbor>
Self;
protected:
typedef typename Base::Points_set Points_set;
typedef std::pair<Point_2,CGAL::Object> PL_pair;
typedef std::vector<PL_pair> Pairs_set;
typedef typename Base::Points_set Points_set;
typedef std::pair<Point_2,CGAL::Object> PL_pair;
typedef std::vector<PL_pair> Pairs_set;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
// Data members:
const Traits_adaptor_2 *m_traits;

View File

@ -31,45 +31,39 @@ namespace CGAL {
* A generator for the landmarks point-locatoion class, which uses a
* sequence of Halton points as its set of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<typename
Arrangement_::Geometry_traits_2> >
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_halton_landmarks_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arr_landmarks_generator_base<Arrangement_2,
Nearest_neighbor> Base;
typedef Arr_halton_landmarks_generator<Arrangement_2,
Nearest_neighbor> Self;
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
typedef Arr_halton_landmarks_generator<Arrangement_2, Nearest_neighbor>
Self;
public:
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Point_2 Point_2;
typedef typename Base::Points_set Points_set;
typedef typename Arrangement_2::Vertex_const_iterator
Vertex_const_iterator;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
protected:
// Data members:
// Data members:
unsigned int num_landmarks;
private:
/*! Copy constructor - not supported. */
Arr_halton_landmarks_generator (const Self& );
Arr_halton_landmarks_generator(const Self&);
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
Self& operator=(const Self&);
public:
/*! Constructor. */
Arr_halton_landmarks_generator (const Arrangement_2& arr,
unsigned int n_landmarks = 0) :

View File

@ -36,18 +36,23 @@ namespace CGAL {
* arrangement edges, which must be segments !
* IMPORTANT: THIS ALGORITHM WORKS ONLY FOR SEGMENTS !!!
*/
template <class Arrangement_,
class Nearest_neighbor_
= Arr_landmarks_nearest_neighbor <typename Arrangement_::Traits_2> >
class Arr_middle_edges_landmarks_generator
: public Arr_landmarks_generator_base <Arrangement_, Nearest_neighbor_>
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_middle_edges_landmarks_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef Arr_middle_edges_landmarks_generator<Arrangement_2,
Nearest_neighbor_> Self;
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor_> Base;
typedef Arrangement_ Arrangement_2;
typedef Nearest_neighbor_ Nearest_neighbor;
private:
typedef Arr_middle_edges_landmarks_generator<Arrangement_2, Nearest_neighbor>
Self;
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
public:
typedef typename Arrangement_2::Traits_2 Traits_2;
typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
@ -58,33 +63,31 @@ public:
typedef typename Arrangement_2::Face_handle Face_handle;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
typedef typename Arrangement_2::Ccb_halfedge_circulator
Ccb_halfedge_circulator;
typedef typename Base::NN_Points_set NN_Points_set;
typedef typename Base::NN_Point_2 NN_Point_2;
Ccb_halfedge_circulator;
typedef typename Base::NN_Points_set NN_Points_set;
typedef typename Base::NN_Point_2 NN_Point_2;
typedef typename Traits_2::Point_2 Point_2;
typedef std::vector<Point_2> Points_set;
typedef typename Traits_2::Point_2 Point_2;
typedef std::vector<Point_2> Points_set;
private:
/*! Copy constructor - not supported. */
Arr_middle_edges_landmarks_generator (const Self& );
Arr_middle_edges_landmarks_generator(const Self&);
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
Self& operator=(const Self&);
public:
/*! Constructor. */
Arr_middle_edges_landmarks_generator
(const Arrangement_2& arr, int /* lm_num */ = -1) :
Arr_middle_edges_landmarks_generator(const Arrangement_2& arr,
int /* lm_num */ = -1) :
Base (arr)
{
//CGAL_PRINT_DEBUG("Arr_middle_edges_landmarks_generator constructor.");
this->build_landmark_set();
}
//Observer functions that should be empty, because they
// Observer functions that should be empty, because they
// got nothing to do with middle edges
//-------------------------------------------------
virtual void after_create_vertex (Vertex_handle /* v */){}

View File

@ -34,39 +34,31 @@ namespace CGAL {
* It recieves a set of points, and builds a kd-tree for them.
* Given a query point, it finds the closest point to the query.
*/
template <class GeomTraits_>
class Arr_landmarks_nearest_neighbor
{
template <typename Arrangement_>
class Arr_landmarks_nearest_neighbor {
public:
typedef Arrangement_ Arrangement_2;
typedef GeomTraits_ Geometry_traits_2;
typedef typename Geometry_traits_2::Approximate_number_type ANT;
typedef typename Geometry_traits_2::Point_2 Point_2;
typedef Arr_landmarks_nearest_neighbor<Geometry_traits_2> Self;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Geometry_traits_2::Approximate_number_type ANT;
typedef typename Geometry_traits_2::Point_2 Point_2;
/*! \class NN_Point_2
* Stores a point along with its approximate coordinates and its location
* in the arrangement.
*/
class NN_Point_2
{
class NN_Point_2 {
public:
Point_2 m_point; // The point.
Object m_object; // The arrangement feature containing the point.
ANT m_vec[2]; // Approximate x and y-coordinates of the point.
public:
/*! Default constructor. */
NN_Point_2()
{
m_vec[0] = m_vec[1] = 0;
}
NN_Point_2() { m_vec[0] = m_vec[1] = 0; }
/*! Constructor from a point. */
NN_Point_2 (const Point_2 &p) :
NN_Point_2(const Point_2& p) :
m_point (p)
{
// Obtain the coordinate approximations,
@ -76,7 +68,7 @@ public:
}
/*! Constructor from a point and an its location in the arrangement. */
NN_Point_2 (const Point_2& p, const Object& obj) :
NN_Point_2(const Point_2& p, const Object& obj) :
m_point (p),
m_object (obj)
{
@ -87,10 +79,7 @@ public:
}
/* Get the point. */
const Point_2& point() const
{
return (m_point);
}
const Point_2& point() const { return (m_point); }
/* Get the object representing the location in the arrangement. */
const Object& object() const
@ -99,30 +88,17 @@ public:
}
/*! Get an iterator for the approximate coordinates. */
const ANT* begin () const
{
return (m_vec);
}
const ANT* begin () const { return (m_vec); }
/*! Get a past-the-end iterator for the approximate coordinates. */
const ANT* end () const
{
return (m_vec + 2);
}
const ANT* end () const { return (m_vec + 2); }
/*! Equality operators. */
bool operator== (const NN_Point_2& nnp) const
{
return (m_vec[0] == nnp.m_vec[0] &&
m_vec[1] == nnp.m_vec[1]);
}
{ return (m_vec[0] == nnp.m_vec[0] && m_vec[1] == nnp.m_vec[1]); }
bool operator!= (const NN_Point_2& nnp) const
{
return (m_vec[0] != nnp.m_vec[0] ||
m_vec[1] != nnp.m_vec[1]);
}
{ return (m_vec[0] != nnp.m_vec[0] || m_vec[1] != nnp.m_vec[1]); }
};
/*! \struct Construct_coord_iterator
@ -134,20 +110,15 @@ public:
typedef const ANT* result_type;
/*! Get an iterator for the approximate coordinates. */
const ANT* operator() (const NN_Point_2& nnp) const
{
return (nnp.begin());
}
const ANT* operator()(const NN_Point_2& nnp) const
{ return (nnp.begin()); }
/*! Get a past-the-end iterator for the approximate coordinates. */
const ANT* operator() (const NN_Point_2& nnp, int) const
{
return (nnp.end());
}
const ANT* operator()(const NN_Point_2& nnp, int) const
{ return (nnp.end()); }
};
protected:
typedef CGAL::Search_traits<ANT, NN_Point_2, const ANT*,
Construct_coord_iterator> Search_traits;
typedef CGAL::Orthogonal_k_neighbor_search<Search_traits> Neighbor_search;
@ -155,19 +126,20 @@ protected:
typedef typename Neighbor_search::Tree Tree;
// Data members:
Tree *m_tree; // The search tree.
bool m_is_empty; // Is the search tree empty.
Tree* m_tree; // The search tree.
bool m_is_empty; // Is the search tree empty.
public:
bool is_empty() const{ return m_is_empty; }
bool is_empty() const { return m_is_empty; }
private:
typedef Arr_landmarks_nearest_neighbor<Arrangement_2> Self;
/*! Copy constructor - not supported. */
Arr_landmarks_nearest_neighbor (const Self& );
Arr_landmarks_nearest_neighbor(const Self& );
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
Self& operator=(const Self& );
public:

View File

@ -33,48 +33,43 @@ namespace CGAL {
* random set of points as its set of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<typename
Arrangement_::Geometry_traits_2> >
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_random_landmarks_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arr_landmarks_generator_base<Arrangement_2,
Nearest_neighbor> Base;
typedef Arr_random_landmarks_generator<Arrangement_2,
Nearest_neighbor> Self;
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
typedef Arr_random_landmarks_generator<Arrangement_2, Nearest_neighbor>
Self;
public:
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Point_2 Point_2;
typedef typename Base::Points_set Points_set;
typedef typename Arrangement_2::Vertex_const_iterator
Vertex_const_iterator;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
protected:
// Data members:
unsigned int num_landmarks;
private:
/*! Copy constructor - not supported. */
Arr_random_landmarks_generator (const Self& );
Arr_random_landmarks_generator(const Self&);
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
public:
Self& operator=(const Self&);
public:
/*! Constructor. */
Arr_random_landmarks_generator (const Arrangement_2& arr,
unsigned int n_landmarks = 0) :
Arr_random_landmarks_generator(const Arrangement_2& arr,
unsigned int n_landmarks = 0) :
Base (arr),
num_landmarks (n_landmarks)
{

View File

@ -30,24 +30,24 @@ namespace CGAL {
* A generator for the landmarks point-locatoion class, which uses
* specified set of points as its set of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<typename
Arrangement_::Geometry_traits_2> >
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_landmarks_specified_points_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arr_landmarks_generator_base<Arrangement_2,
Nearest_neighbor> Base;
typedef Arr_landmarks_vertices_generator<Arrangement_2,
Nearest_neighbor> Self;
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
typedef Arr_landmarks_vertices_generator<Arrangement_2, Nearest_neighbor>
Self;
public:
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
typedef typename Arrangement_2::Face_const_handle Face_const_handle;
@ -63,32 +63,29 @@ public:
typedef typename Nearest_neighbor::NN_Point_2 NN_Point_2;
typedef std::list<NN_Point_2> NN_Point_list;
protected:
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
typedef std::pair<Point_2,CGAL::Object> PL_pair;
typedef std::vector<PL_pair> Pairs_set;
// Data members:
const Traits_adaptor_2 *m_traits; // Its associated traits object.
const Traits_adaptor_2* m_traits; // Its associated traits object.
Points_set m_points; // container of the specified points
Pairs_set lm_pairs;
int num_landmarks;
private:
/*! Copy constructor - not supported. */
Arr_landmarks_specified_points_generator (const Self& );
Arr_landmarks_specified_points_generator(const Self&);
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
Self& operator=(const Self&);
public:
/*! Constructor. */
Arr_landmarks_specified_points_generator (const Arrangement_2& arr,
const Points_set points) :
Arr_landmarks_specified_points_generator(const Arrangement_2& arr,
const Points_set points) :
Base (arr),
num_landmarks(points.size())
{

View File

@ -31,24 +31,24 @@ namespace CGAL {
* A generator for the landmarks point-locatoion class, which uses the
* arrangement vertices as its set of landmarks.
*/
template <class Arrangement_,
class Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<typename
Arrangement_::Geometry_traits_2> >
template <typename Arrangement_,
typename Nearest_neighbor_ =
Arr_landmarks_nearest_neighbor<Arrangement_> >
class Arr_landmarks_vertices_generator :
public Arr_landmarks_generator_base<Arrangement_, Nearest_neighbor_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef Nearest_neighbor_ Nearest_neighbor;
typedef Arr_landmarks_generator_base<Arrangement_2,
Nearest_neighbor> Base;
typedef Arr_landmarks_vertices_generator<Arrangement_2,
Nearest_neighbor> Self;
private:
typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor>
Base;
typedef Arr_landmarks_vertices_generator<Arrangement_2, Nearest_neighbor>
Self;
public:
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
typedef typename Arrangement_2::Face_const_handle Face_const_handle;
@ -66,25 +66,22 @@ public:
typedef std::list<NN_Point_2> NN_Point_list;
protected:
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
// Data members:
const Traits_adaptor_2 *m_traits; // Its associated traits object.
const Traits_adaptor_2* m_traits; // Its associated traits object.
int num_landmarks;
private:
/*! Copy constructor - not supported. */
Arr_landmarks_vertices_generator (const Self& );
Arr_landmarks_vertices_generator(const Self&);
/*! Assignment operator - not supported. */
Self& operator= (const Self& );
public:
Self& operator=(const Self&);
public:
/*! Constructor. */
Arr_landmarks_vertices_generator (const Arrangement_2& arr) :
Arr_landmarks_vertices_generator(const Arrangement_2& arr) :
Base (arr),
num_landmarks(0)
{