mirror of https://github.com/CGAL/cgal
Adding the choice of even or odd cones for half-theta/yao-graphs
This commit is contained in:
parent
910f69c6a0
commit
8e71637b81
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2013-2015 The University of Western Sydney, Australia.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Authors: Weisheng Si, Quincy Tse
|
||||
|
||||
/*! \file Cone_spanners_2_enum.h
|
||||
*
|
||||
* This header defines enumerators for the cone spanners functors.
|
||||
*/
|
||||
|
||||
#ifndef CONE_SPANNERS_2_ENUM_H
|
||||
#define CONE_SPANNERS_2_ENUM_H
|
||||
|
||||
namespace CGAL {
|
||||
/*! \ingroup PkgConeBasedSpanners
|
||||
|
||||
\brief An enum of the types of cone spanners.
|
||||
*/
|
||||
enum Half { EVEN_CONES = 0, ODD_CONES = 1, ALL_CONES = 2 };
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
#include <CGAL/Compute_cone_boundaries_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_enum.h>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
|
|
@ -79,7 +80,7 @@ private:
|
|||
unsigned int cone_number;
|
||||
|
||||
/* Store whether this is an half-theta graph */
|
||||
bool half;
|
||||
Half half;
|
||||
|
||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||
* stored in rays[0].
|
||||
|
|
@ -98,7 +99,7 @@ public:
|
|||
*/
|
||||
Construct_theta_graph_2 (unsigned int k,
|
||||
Direction_2 initial_direction = Direction_2(1,0),
|
||||
bool half_theta = false
|
||||
Half half_theta = ALL_CONES
|
||||
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_theta)
|
||||
|
||||
{
|
||||
|
|
@ -137,8 +138,9 @@ public:
|
|||
unsigned int j; // index of the ccw ray
|
||||
|
||||
// add edges into the graph for every cone
|
||||
int increment = half ? 2 : 1;
|
||||
for (i = 0; i < cone_number; i += increment) {
|
||||
int new_start = half != ALL_CONES ? half : 0;
|
||||
int increment = half != ALL_CONES ? 2 : 1;
|
||||
for (i = new_start; i < cone_number; i += increment) {
|
||||
j = (i+1) % cone_number;
|
||||
add_edges_in_cone(rays[i], rays[j], g);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <utility>
|
||||
#include <CGAL/Compute_cone_boundaries_2.h>
|
||||
#include <CGAL/Cone_spanners_2/Less_by_direction_2.h>
|
||||
#include <CGAL/Cone_spanners_2_enum.h>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
|
|
@ -73,8 +74,8 @@ private:
|
|||
/* Store the number of cones. */
|
||||
unsigned int cone_number;
|
||||
|
||||
/* Store whether this is an half-theta graph */
|
||||
bool half;
|
||||
/* Store whether this is an half-yao graph */
|
||||
Half half;
|
||||
|
||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||
stored in rays[0]. */
|
||||
|
|
@ -93,7 +94,7 @@ public:
|
|||
*/
|
||||
Construct_yao_graph_2 (unsigned int k,
|
||||
Direction_2 initial_direction = Direction_2(1,0),
|
||||
bool half_yao = false
|
||||
Half half_yao = ALL_CONES
|
||||
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_yao)
|
||||
|
||||
{
|
||||
|
|
@ -133,8 +134,9 @@ public:
|
|||
unsigned int j; // index of the ccw ray
|
||||
|
||||
// add edges into the graph for every cone
|
||||
int increment = half ? 2 : 1;
|
||||
for (i = 0; i < cone_number; i += increment) {
|
||||
int new_start = half != ALL_CONES ? half : 0;
|
||||
int increment = half != ALL_CONES ? 2 : 1;
|
||||
for (i = new_start; i < cone_number; i += increment) {
|
||||
j = (i+1) % cone_number;
|
||||
add_edges_in_cone(rays[i], rays[j], g);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue