mirror of https://github.com/CGAL/cgal
Refactoring of the enum Half to Cones_selected and fix bugs in cone spanners ipelet
This commit is contained in:
parent
7369b842a4
commit
c0e49e7a29
|
|
@ -4,6 +4,7 @@
|
||||||
#include <CGAL/Construct_theta_graph_2.h>
|
#include <CGAL/Construct_theta_graph_2.h>
|
||||||
#include <CGAL/Construct_yao_graph_2.h>
|
#include <CGAL/Construct_yao_graph_2.h>
|
||||||
#include <CGAL/Compute_cone_boundaries_2.h>
|
#include <CGAL/Compute_cone_boundaries_2.h>
|
||||||
|
#include <CGAL/Cone_spanners_enum_2.h>
|
||||||
#include <CGAL/property_map.h>
|
#include <CGAL/property_map.h>
|
||||||
#include <boost/graph/graph_traits.hpp>
|
#include <boost/graph/graph_traits.hpp>
|
||||||
#include <boost/graph/adjacency_list.hpp>
|
#include <boost/graph/adjacency_list.hpp>
|
||||||
|
|
@ -40,10 +41,10 @@ const std::string hmsg[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cone_spanners_ipelet
|
class Cone_spanners_ipelet
|
||||||
: public CGAL::Ipelet_base<Kernel,6> {
|
: public CGAL::Ipelet_base<Kernel,7> {
|
||||||
public:
|
public:
|
||||||
Cone_spanners_ipelet()
|
Cone_spanners_ipelet()
|
||||||
:CGAL::Ipelet_base<Kernel,6>("Cone Spanners",labels,hmsg){}
|
:CGAL::Ipelet_base<Kernel,7>("Cone Spanners",labels,hmsg){}
|
||||||
void protected_run(int);
|
void protected_run(int);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
@ -94,11 +95,11 @@ void Cone_spanners_ipelet::protected_run(int fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fn >= 0 && fn <= 5) {
|
if(fn >= 0 && fn <= 5) {
|
||||||
CGAL::Half half = CGAL::ALL_CONES;
|
CGAL::Cones_selected cones_selected = CGAL::ALL_CONES;
|
||||||
if(fn == 2 || fn == 3)
|
if(fn == 2 || fn == 3)
|
||||||
half = CGAL::EVEN_CONES;
|
cones_selected = CGAL::EVEN_CONES;
|
||||||
else if(fn == 4 || fn == 5)
|
else if(fn == 4 || fn == 5)
|
||||||
half = CGAL::ODD_CONES;
|
cones_selected = CGAL::ODD_CONES;
|
||||||
|
|
||||||
Graph g;
|
Graph g;
|
||||||
switch (fn){
|
switch (fn){
|
||||||
|
|
@ -106,7 +107,7 @@ void Cone_spanners_ipelet::protected_run(int fn)
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
CGAL::Construct_theta_graph_2<Kernel, Graph> theta(number_of_cones, Direction_2(1,0), half);
|
CGAL::Construct_theta_graph_2<Kernel, Graph> theta(number_of_cones, Direction_2(1,0), cones_selected);
|
||||||
theta(lst.begin(), lst.end(), g);
|
theta(lst.begin(), lst.end(), g);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +115,7 @@ void Cone_spanners_ipelet::protected_run(int fn)
|
||||||
case 3:
|
case 3:
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
CGAL::Construct_yao_graph_2<Kernel, Graph> yao(number_of_cones, Direction_2(1,0), half);
|
CGAL::Construct_yao_graph_2<Kernel, Graph> yao(number_of_cones, Direction_2(1,0), cones_selected);
|
||||||
yao(lst.begin(), lst.end(), g);
|
yao(lst.begin(), lst.end(), g);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +129,7 @@ void Cone_spanners_ipelet::protected_run(int fn)
|
||||||
}
|
}
|
||||||
group_selected_objects_();
|
group_selected_objects_();
|
||||||
}
|
}
|
||||||
else if(fn == 4) {
|
else if(fn == 6) {
|
||||||
CGAL::Compute_cone_boundaries_2<Kernel> cones;
|
CGAL::Compute_cone_boundaries_2<Kernel> cones;
|
||||||
std::vector<Direction_2> directions(number_of_cones);
|
std::vector<Direction_2> directions(number_of_cones);
|
||||||
cones(number_of_cones, Direction_2(1,0), directions.begin());
|
cones(number_of_cones, Direction_2(1,0), directions.begin());
|
||||||
|
|
|
||||||
|
|
@ -16,22 +16,31 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Authors: Weisheng Si, Quincy Tse
|
// Authors: Frédérk Paradis
|
||||||
|
|
||||||
/*! \file Cone_spanners_2_enum.h
|
/*! \file Cone_spanners_enum_2.h
|
||||||
*
|
*
|
||||||
* This header defines enumerators for the cone spanners functors.
|
* This header defines enumerators for the cone spanners functors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONE_SPANNERS_2_ENUM_H
|
#ifndef CONE_SPANNERS_ENUM_2_H
|
||||||
#define CONE_SPANNERS_2_ENUM_H
|
#define CONE_SPANNERS_ENUM_2_H
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
/*! \ingroup PkgConeBasedSpanners
|
/*! \ingroup PkgConeBasedSpanners
|
||||||
|
|
||||||
\brief An enum of the types of cone spanners.
|
\brief An enum of the choice of cones in cone spanners.
|
||||||
*/
|
*/
|
||||||
enum Half { EVEN_CONES = 0, ODD_CONES = 1, ALL_CONES = 2 };
|
enum Cones_selected {
|
||||||
|
/*! \brief Select even cones.
|
||||||
|
*/
|
||||||
|
EVEN_CONES = 0,
|
||||||
|
/*! \brief Select odd cones.
|
||||||
|
*/
|
||||||
|
ODD_CONES = 1,
|
||||||
|
/*! \brief Select all cones.
|
||||||
|
*/
|
||||||
|
ALL_CONES = 2 };
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Authors: Weisheng Si, Quincy Tse
|
// Authors: Weisheng Si, Quincy Tse, Frédérk Paradis
|
||||||
|
|
||||||
/*! \file Construct_theta_graph_2.h
|
/*! \file Construct_theta_graph_2.h
|
||||||
*
|
*
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include <CGAL/Compute_cone_boundaries_2.h>
|
#include <CGAL/Compute_cone_boundaries_2.h>
|
||||||
#include <CGAL/Cone_spanners_2/Less_by_direction_2.h>
|
#include <CGAL/Cone_spanners_2/Less_by_direction_2.h>
|
||||||
#include <CGAL/Cone_spanners_2/Plane_scan_tree.h>
|
#include <CGAL/Cone_spanners_2/Plane_scan_tree.h>
|
||||||
#include <CGAL/Cone_spanners_2_enum.h>
|
#include <CGAL/Cone_spanners_enum_2.h>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/graph/adjacency_list.hpp>
|
#include <boost/graph/adjacency_list.hpp>
|
||||||
|
|
@ -79,8 +79,8 @@ private:
|
||||||
/* Store the number of cones. */
|
/* Store the number of cones. */
|
||||||
unsigned int cone_number;
|
unsigned int cone_number;
|
||||||
|
|
||||||
/* Store whether this is an half-theta graph */
|
/* Store whether even, odd or all cones are selected to construct graph. */
|
||||||
Half half;
|
Cones_selected cones_choice;
|
||||||
|
|
||||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||||
* stored in rays[0].
|
* stored in rays[0].
|
||||||
|
|
@ -94,13 +94,13 @@ public:
|
||||||
\param initial_direction A direction denoting one of the rays dividing the
|
\param initial_direction A direction denoting one of the rays dividing the
|
||||||
cones. This allows arbitary rotations of the rays that divide
|
cones. This allows arbitary rotations of the rays that divide
|
||||||
the plane. (default: positive x-axis)
|
the plane. (default: positive x-axis)
|
||||||
\param half_theta Indicates whether all the cones are used or just half of
|
\param cones_selected Indicates whether even, odd or all cones are
|
||||||
them (default: all cones).
|
selected to construct graph.
|
||||||
*/
|
*/
|
||||||
Construct_theta_graph_2 (unsigned int k,
|
Construct_theta_graph_2 (unsigned int k,
|
||||||
Direction_2 initial_direction = Direction_2(1,0),
|
Direction_2 initial_direction = Direction_2(1,0),
|
||||||
Half half_theta = ALL_CONES
|
Cones_selected cones_selected = ALL_CONES
|
||||||
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_theta)
|
): cone_number(k), rays(std::vector<Direction_2>(k)), cones_choice(cones_selected)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (k<2) {
|
if (k<2) {
|
||||||
|
|
@ -138,8 +138,8 @@ public:
|
||||||
unsigned int j; // index of the ccw ray
|
unsigned int j; // index of the ccw ray
|
||||||
|
|
||||||
// add edges into the graph for every cone
|
// add edges into the graph for every cone
|
||||||
int new_start = half != ALL_CONES ? half : 0;
|
int new_start = cones_choice != ALL_CONES ? cones_choice : 0;
|
||||||
int increment = half != ALL_CONES ? 2 : 1;
|
int increment = cones_choice != ALL_CONES ? 2 : 1;
|
||||||
for (i = new_start; i < cone_number; i += increment) {
|
for (i = new_start; i < cone_number; i += increment) {
|
||||||
j = (i+1) % cone_number;
|
j = (i+1) % cone_number;
|
||||||
add_edges_in_cone(rays[i], rays[j], g);
|
add_edges_in_cone(rays[i], rays[j], g);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Authors: Weisheng Si, Quincy Tse
|
// Authors: Weisheng Si, Quincy Tse, Frédérk Paradis
|
||||||
|
|
||||||
/*! \file Construct_yao_graph_2.h
|
/*! \file Construct_yao_graph_2.h
|
||||||
*
|
*
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <CGAL/Compute_cone_boundaries_2.h>
|
#include <CGAL/Compute_cone_boundaries_2.h>
|
||||||
#include <CGAL/Cone_spanners_2/Less_by_direction_2.h>
|
#include <CGAL/Cone_spanners_2/Less_by_direction_2.h>
|
||||||
#include <CGAL/Cone_spanners_2_enum.h>
|
#include <CGAL/Cone_spanners_enum_2.h>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/graph/adjacency_list.hpp>
|
#include <boost/graph/adjacency_list.hpp>
|
||||||
|
|
@ -74,8 +74,8 @@ private:
|
||||||
/* Store the number of cones. */
|
/* Store the number of cones. */
|
||||||
unsigned int cone_number;
|
unsigned int cone_number;
|
||||||
|
|
||||||
/* Store whether this is an half-yao graph */
|
/* Store whether even, odd or all cones are selected to construct graph. */
|
||||||
Half half;
|
Cones_selected cones_choice;
|
||||||
|
|
||||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||||
stored in rays[0]. */
|
stored in rays[0]. */
|
||||||
|
|
@ -89,13 +89,13 @@ public:
|
||||||
\param initial_direction A direction denoting one of the rays dividing the
|
\param initial_direction A direction denoting one of the rays dividing the
|
||||||
cones. This allows arbitary rotations of the rays that divide
|
cones. This allows arbitary rotations of the rays that divide
|
||||||
the plane. (default: positive x-axis)
|
the plane. (default: positive x-axis)
|
||||||
\param half_yao Indicates whether all the cones are used or just half of
|
\param cones_selected Indicates whether even, odd or all cones are
|
||||||
them (default: all cones).
|
selected to construct graph.
|
||||||
*/
|
*/
|
||||||
Construct_yao_graph_2 (unsigned int k,
|
Construct_yao_graph_2 (unsigned int k,
|
||||||
Direction_2 initial_direction = Direction_2(1,0),
|
Direction_2 initial_direction = Direction_2(1,0),
|
||||||
Half half_yao = ALL_CONES
|
Cones_selected cones_selected = ALL_CONES
|
||||||
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_yao)
|
): cone_number(k), rays(std::vector<Direction_2>(k)), cones_choice(cones_selected)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (k<2) {
|
if (k<2) {
|
||||||
|
|
@ -134,8 +134,8 @@ public:
|
||||||
unsigned int j; // index of the ccw ray
|
unsigned int j; // index of the ccw ray
|
||||||
|
|
||||||
// add edges into the graph for every cone
|
// add edges into the graph for every cone
|
||||||
int new_start = half != ALL_CONES ? half : 0;
|
int new_start = cones_choice != ALL_CONES ? cones_choice : 0;
|
||||||
int increment = half != ALL_CONES ? 2 : 1;
|
int increment = cones_choice != ALL_CONES ? 2 : 1;
|
||||||
for (i = new_start; i < cone_number; i += increment) {
|
for (i = new_start; i < cone_number; i += increment) {
|
||||||
j = (i+1) % cone_number;
|
j = (i+1) % cone_number;
|
||||||
add_edges_in_cone(rays[i], rays[j], g);
|
add_edges_in_cone(rays[i], rays[j], g);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue