From d8d6e2c7727af4eae49e31e714833a0c9f23b92f Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Thu, 26 Mar 2015 15:55:08 +0100 Subject: [PATCH] rm parallel stuff rescued in new branch --- .../Parallel_rotational_sweep_visibility_2.h | 1627 ----------------- ...rallel_triangular_expansion_visibility_2.h | 601 ------ .../test/Visibility_2/pure_benchmark.cpp | 5 +- .../test/Visibility_2/simple_benchmark.cpp | 8 +- .../test_parallel_rotational_visibility.cpp | 97 - 5 files changed, 2 insertions(+), 2336 deletions(-) delete mode 100644 Visibility_2/include/CGAL/Parallel_rotational_sweep_visibility_2.h delete mode 100644 Visibility_2/include/CGAL/Parallel_triangular_expansion_visibility_2.h delete mode 100644 Visibility_2/test/Visibility_2/test_parallel_rotational_visibility.cpp diff --git a/Visibility_2/include/CGAL/Parallel_rotational_sweep_visibility_2.h b/Visibility_2/include/CGAL/Parallel_rotational_sweep_visibility_2.h deleted file mode 100644 index 2e792833c39..00000000000 --- a/Visibility_2/include/CGAL/Parallel_rotational_sweep_visibility_2.h +++ /dev/null @@ -1,1627 +0,0 @@ -// Copyright (c) 2013 Technical University Braunschweig (Germany). -// 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$ -// -// -// Author(s): Kan Huang -// Ning Xu -// - -#ifndef CGAL_PARALLEL_ROTATIONAL_SWEEP_VISIBILITY_2_H -#define CGAL_PARALLEL_ROTATIONAL_SWEEP_VISIBILITY_2_H - -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -#ifdef CGAL_LINKED_WITH_TBB - #include "tbb/parallel_sort.h" - #include "tbb/parallel_for.h" -#endif - -#ifndef NDEBUG - #include - using std::cout; - using std::ostream; - using std::endl; -#endif - -namespace CGAL { - -template < class Arrangement_2_, - class RegularizationCategory = CGAL::Tag_true, - class ConcurrencyCategory = CGAL::Parallel_tag > -class Parallel_rotational_sweep_visibility_2 -{ - -// Public types declaration -public: - typedef Arrangement_2_ Arrangement_2; - typedef typename Arrangement_2::Traits_2 Traits_2; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - - typedef typename Geometry_traits_2::Kernel K; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::Ray_2 Ray_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; - typedef typename Geometry_traits_2::Line_2 Line_2; - typedef typename Geometry_traits_2::Vector_2 Vector_2; - typedef typename Geometry_traits_2::Direction_2 Direction_2; - typedef typename Geometry_traits_2::FT Number_type; - typedef typename Geometry_traits_2::Object_2 Object_2; - - typedef RegularizationCategory Regularization_category; - typedef CGAL::Tag_true Supports_general_polygon_category; - typedef CGAL::Tag_true Supports_simple_polygon_category; - -//private data types declaration - typedef Ccb_halfedge_const_circulator Circulator; - typedef typename Arrangement_2::Hole_const_iterator Hole_const_iterator; - typedef std::vector Index_vector; - -// private nested classes -private: - class Vertex - { - private: - Vertex_const_handle vh; - int quad; - int first_ic; - int last_ic; - int alias_idx; - int sorted_idx; - private: - public: - Vertex ( const Vertex_const_handle& v ) - : vh( v ), first_ic( 0 ), last_ic( 0 ), alias_idx( -1 ), sorted_idx( -1 ) - {} - void init_quadrant ( const Point_2& query_pt ) - { - CGAL::Comparison_result cx = CGAL::compare_x( vh->point(), query_pt ); - CGAL::Comparison_result cy = CGAL::compare_y( vh->point(), query_pt ); - if ( cx == CGAL::LARGER ) - quad = ( cy != CGAL::SMALLER ) ? 1 : 4; - else if ( cx == CGAL::SMALLER ) - quad = ( cy != CGAL::LARGER ) ? 3 : 2; - else { - if ( cy == CGAL::LARGER ) - quad = 2; - else if ( cy == CGAL::SMALLER ) - quad = 4; - else - quad = 0; - } - } - const Vertex_const_handle& handle () const - { return vh; } - int quadrant () const - { return quad; } - int first_incident () const - { return first_ic; } - int last_incident () const - { return last_ic; } - int alias_index () const - { return alias_idx; } - int sorted_index () const - { return sorted_idx; } - - void set_incident_index( int f, int l ) - { first_ic = f; last_ic = l; } - void set_alias_index( int idx ) - { alias_idx = idx; } - void set_sorted_index( int idx ) - { sorted_idx = idx; } - - const Point_2& point () const - { return vh->point(); } -#ifndef NDEBUG - void trace ( ostream& os, int level ) const - { - for ( int i = 0; i < level; i++ ) - os << " "; - os << "point=[" << point() - << "], quadrant=[" << quadrant() - << "], first ic=[" << first_incident() - << "], last ic=[" << last_incident() - << "]" << endl; - for ( int i = 0; i < level; i++ ) - os << " "; - os << " alias=[" << alias_index() - << "], sorted=[" << sorted_index() - << "]" << endl; - } -#endif - }; - - class Edge - { - private: - int source_idx; - int target_idx; - enum { LTURN, RTURN, OUTWARD, INWARD, AT_SOURCE, AT_TARGET, IN_EDGE } mode; - public: - Edge ( int s, int t ) - : source_idx( s ), target_idx( t ) - {} - void init_orientation ( const Point_2& query_pt, - const Point_2& source, - const Point_2& target ) - { - CGAL::Orientation orient = CGAL::orientation( query_pt, source, target ); - if ( orient == CGAL::LEFT_TURN ) - mode = LTURN; - else if ( orient == CGAL::RIGHT_TURN ) - mode = RTURN; - else { - if ( query_pt == source ) - mode = AT_SOURCE; - else if ( query_pt == target ) - mode = AT_TARGET; - else if ( CGAL::collinear_are_ordered_along_line - ( query_pt, source, target ) ) - mode = OUTWARD; - else if ( CGAL::collinear_are_ordered_along_line - ( query_pt, target, source ) ) - mode = INWARD; - else - mode = IN_EDGE; - } - } - - int source_index () const - { return source_idx; } - int target_index () const - { return target_idx; } - void set_index ( int s, int t ) - { source_idx = s; target_idx = t; } - bool left_turn () const - { return ( mode == LTURN ); } - bool right_turn () const - { return ( mode == RTURN ); } - bool collinear () const - { return ( !left_turn() && !right_turn() ); } - bool inward () const - { return ( mode == INWARD ); } - bool outward () const - { return ( mode == OUTWARD ); } - bool at_source () const - { return ( mode == AT_SOURCE ); } - bool at_target () const - { return ( mode == AT_TARGET ); } - bool in_edge () const - { return ( mode == IN_EDGE ); } - bool pass_query_pt () const - { return ( at_source() || at_target() || in_edge() ); } - CGAL::Orientation orientation() const - { - if ( left_turn() ) return CGAL::LEFT_TURN; - if ( right_turn() ) return CGAL::RIGHT_TURN; - return CGAL::COLLINEAR; - } - CGAL::Orientation reverse_orientation() const - { - if ( left_turn() ) return CGAL::RIGHT_TURN; - if ( right_turn() ) return CGAL::LEFT_TURN; - return CGAL::COLLINEAR; - } - -#ifndef NDEBUG - void trace ( ostream& os, int level ) const - { - for ( int i = 0; i < level; i++ ) - os << " "; - os << "source_idx=[" << source_index() - << "],target_idx=[" << target_index() - << "],mode =["; - switch( mode ) { - case LTURN: - os << "left turn"; - break; - case RTURN: - os << "right turn"; - break; - case OUTWARD: - os << "outward"; - break; - case INWARD: - os << "inward"; - break; - case AT_SOURCE: - os << "at source"; - break; - case AT_TARGET: - os << "at target"; - break; - case IN_EDGE: - os << "in edge"; - break; - } - os << "]" << endl; - } -#endif - }; - - class Closer_edge : public std::binary_function - { - private: - const Point_2& query_pt; - const std::vector& edges; - const std::vector& vertices; - private: - int vtype( const Edge& e, bool incident_at_source ) const - { - if ( incident_at_source ) { - if ( e.left_turn() ) return 1; - if ( e.right_turn() ) return 2; - if ( e.outward()|| e.at_source() || e.in_edge() ) return 3; - return 0; - } else { - if ( e.left_turn() ) return 2; - if ( e.right_turn() ) return 1; - if ( e.inward() || e.at_target() || e.in_edge() ) return 3; - return 0; - } - } - const Point_2& source_point( const Edge& e ) const - { return vertices[e.source_index()].point(); } - const Point_2& target_point( const Edge& e ) const - { return vertices[e.target_index()].point(); } - bool less ( const Edge& e1, const Edge& e2 ) const - { - CGAL::Orientation orient1, orient2, orient3; - if ( e1.source_index() == e2.source_index() ) { - int vt1 = vtype( e1, true ); - int vt2 = vtype( e2, true ); - if ( vt1 != vt2 ) return ( vt1 < vt2 ); - orient1 = CGAL::orientation( source_point( e2 ), - target_point( e2 ), - target_point( e1 ) ); - return ( orient1 == e2.orientation() ); - } else if ( e1.target_index() == e2.source_index() ) { - int vt1 = vtype( e1, false ); - int vt2 = vtype( e2, true ); - if ( vt1 != vt2 ) return ( vt1 < vt2 ); - orient1 = CGAL::orientation( source_point( e2 ), - target_point( e2 ), - source_point( e1 ) ); - return ( orient1 == e2.orientation() ); - } else if ( e1.source_index() == e2.target_index() ) { - int vt1 = vtype( e1, true ); - int vt2 = vtype( e2, false ); - if ( vt1 != vt2 ) return ( vt1 < vt2 ); - orient1 = CGAL::orientation( target_point( e2 ), - source_point( e2 ), - target_point( e1 ) ); - return ( orient1 == e2.reverse_orientation() ); - } else if ( e1.target_index() == e2.target_index() ) { - int vt1 = vtype( e1, false ); - int vt2 = vtype( e2, false ); - if ( vt1 != vt2 ) return ( vt1 < vt2 ); - orient1 = CGAL::orientation( target_point( e2 ), - source_point( e2 ), - source_point( e1 ) ); - return ( orient1 == e2.reverse_orientation() ); - } else { - // General case - const Point_2& s1 = source_point( e1 ); - const Point_2& t1 = target_point( e1 ); - const Point_2& s2 = source_point( e2 ); - const Point_2& t2 = target_point( e2 ); - - if ( e1.collinear() ) { - if ( e2.collinear() ) - return CGAL::collinear_are_ordered_along_line( query_pt, s1, s2 ); - else - return ( CGAL::orientation( s2, t2, s1 ) == e2.orientation() ); - } else { - orient1 = CGAL::orientation( s1, t1, s2 ); - orient2 = CGAL::orientation( s1, t1, t2 ); - if ( orient1 == CGAL::COLLINEAR ) - return ( orient2 != e1.orientation() ); - if ( orient1 == e1.orientation() ) { - if ( orient2 != e1.orientation() ) - return ( CGAL::orientation( s2, t2, s1 ) == e2.orientation() ); - else - return false; - } else { - if ( orient2 != e1.orientation() ) - return true; - else - return ( CGAL::orientation( s2, t2, s1 ) == e2.orientation() ); - } - } - } - } - public: - Closer_edge( const Point_2& q, const std::vector& e, - const std::vector& v ) - : query_pt( q ), edges( e ), vertices( v ) - {} - bool operator () ( int idx1, int idx2 ) const - { - if ( idx1 == idx2 ) return false; - if ( edges[idx1].pass_query_pt() && edges[idx2].pass_query_pt() ) - return ( idx1 < idx2 ); - if ( edges[idx1].pass_query_pt() ) - return true; - if ( edges[idx2].pass_query_pt() ) - return false; - return less( edges[idx1], edges[idx2] ); - } - }; - - class Intersection_edges - { - private: - struct IE_node { - bool exist; - int prev; - int next; - IE_node () - : exist( false ), prev( -1 ), next( -1 ) - {} - IE_node ( bool f, int p, int n ) - : exist( f ), prev( p ), next( n ) - {} - }; - private: - std::vector< IE_node > _data; - int _head; - public: - Intersection_edges( int s ) - { - _data.reserve( s+1 ); - for ( int i = 0; i < s+1; i++ ) - _data.push_back( IE_node( false, i, i ) ); - _head = s; - } - void insert( int idx ) - { - if ( _data[idx].exist ) - return; - _data[idx].exist = true; - _data[idx].next = _data[_head].next; - _data[idx].prev = _head; - _data[_data[_head].next].prev = idx; - _data[_head].next = idx; - } - void erase ( int idx ) - { - if ( !_data[idx].exist ) - return; - _data[_data[idx].prev].next = _data[idx].next; - _data[_data[idx].next].prev = _data[idx].prev; - _data[idx].exist = false; - _data[idx].prev = _data[idx].next = idx; - } - std::vector data () - { - std::vector res; - int curr = _data[_head].next; - while ( curr != _head ) { - res.push_back( curr ); - curr = _data[curr].next; - } - return res; - } - int begin () const - { return _data[_head].next; } - int end () const - { return _head; } - int next ( int curr ) const - { return _data[curr].next; } - bool has ( int idx ) const - { return _data[idx].exist; } - }; - - class Cone - { - private: - int _begin; - int _end; - std::vector _edx; - public: - Cone ( int b, int e ) - : _begin( b ), _end( e ) - { _edx.reserve( e - b ); } - int begin () const - { return _begin; } - int end () const - { return _end; } - int size () const - { return _edx.size(); } - int operator [] ( int pos ) const - { return _edx[pos]; } - void insert ( int idx ) - { _edx.push_back( idx ); } -#ifndef NDEBUG - void trace ( ostream& os, int level ) const - { - for ( int i = 0; i < level; i++ ) os << " "; - os << "begin = " << begin() << " , end = " << end() << " , size = " << size() << endl; - for ( int i = 0; i < level; i++ ) os << " "; - os << "edx = [ "; - for ( int i = 0; i < _edx.size(); i++ ) - os << _edx[i] << " "; - os << "]" << endl; - } -#endif - }; - - class Sub_region - { - private: - struct Intersection_point - { - bool by_edge; - int v_idx; - int e_idx; - Intersection_point( bool b, int v, int e ) - : by_edge( b ), v_idx( v ), e_idx( e ) - {} - }; - private: - std::vector _pts; - private: - Point_2 compute_intersection( const Point_2& q, - const Point_2& dp, - const Point_2& s, - const Point_2& t ) const - { - if ( CGAL::collinear( q, dp, s ) ) { - if ( CGAL::collinear( q, dp, t ) ) { - if ( CGAL::collinear_are_ordered_along_line( q, s, t ) ) - return s; - else - return t; - } else { - return s; - } - } - Ray_2 ray( q, dp ); - Segment_2 seg( s, t ); - CGAL::Object obj = CGAL::intersection( ray, seg ); - const Point_2 * ipoint = CGAL::object_cast (&obj); - assert( ipoint != NULL ); - return *ipoint; - } - public: - Sub_region ( int est_pts_num ) - { _pts.reserve( est_pts_num*2+2 ); } - int size () const - { return _pts.size(); } - Point_2 get_point ( const Point_2& q, - const std::vector& vertices, - const std::vector& edges, - int pos ) const - { - if ( _pts[pos].by_edge ) { - return compute_intersection( q, vertices[_pts[pos].v_idx].point(), - vertices[edges[_pts[pos].e_idx].source_index()].point(), - vertices[edges[_pts[pos].e_idx].target_index()].point() ); - } else { - return vertices[_pts[pos].v_idx].point(); - } - } - void insert ( int v_idx ) - { _pts.push_back( Intersection_point( false, v_idx, -1 ) ); } - void insert ( int v_idx, int e_idx ) - { _pts.push_back( Intersection_point( true, v_idx, e_idx ) ); } -#ifndef NDEBUG - void trace ( ostream& os, int level ) const - { - for ( int i = 0; i < level; i++ ) os << " "; - os << "size = " << size() << endl; - for ( int i = 0; i < level; i++ ) os << " "; - os << "pts = [ "; - for ( int i = 0; i < _pts.size(); i++ ) - os << _pts[i].by_edge << " " << _pts[i].v_idx << " " <<_pts[i].e_idx << " , "; - os << "]" << endl; - } -#endif - }; - -//private data types declaration -private: - typedef Vertex Vertex_type; - typedef std::vector Vertex_vector; - typedef Edge Edge_type; - typedef std::vector Edge_vector; - typedef std::vector Point_vector; - -private: - class Is_swept_earlier - { - private: - const Point_2& query_pt; - const Vertex_vector * vertices; - const Point_2& shifted_source; - int shifted_quadrant; - - bool is_vertex_query; - private: - // less_vertex - // Precondition: v1 == query_pt, v2 != query_pt - bool less_vertex ( const Vertex_type& v1, const Vertex_type& v2 ) const - { - CGAL::Orientation orient = CGAL::orientation( query_pt, - shifted_source, - v2.point() ); - if ( orient == CGAL::COLLINEAR ) { - if ( shifted_quadrant != v2.quadrant() ) - return ( shifted_quadrant < v2.quadrant() ); - else - return true; - } else { - if ( shifted_quadrant != v2.quadrant() ) - return ( shifted_quadrant < v2.quadrant() ); - else - return ( orient == CGAL::LEFT_TURN ); - } - } - bool less_general ( const Vertex_type& v1, const Vertex_type& v2 ) const - { - if ( v1.quadrant() != v2.quadrant() ) - return ( v1.quadrant() < v2.quadrant() ); - CGAL::Orientation orient = CGAL::orientation( query_pt, - v1.point(), v2.point() ); - if ( orient != CGAL::COLLINEAR ) - return ( orient == CGAL::LEFT_TURN ); - else - return CGAL::collinear_are_ordered_along_line( query_pt, - v1.point(), v2.point() ); - } - // less - // compare two points by their polar angle - bool less ( const Vertex_type& v1, const Vertex_type& v2 ) const - { - if ( v1.handle() == v2.handle() ) - return false; - if ( is_vertex_query ) { - if ( v1.quadrant() == 0 ) - return less_vertex( v1, v2 ); - else if ( v2.quadrant() == 0 ) - return !less_vertex( v2, v1 ); - else - return less_general( v1, v2 ); - } else - return less_general( v1, v2 ); - } - public: - Is_swept_earlier ( const Point_2& q, const Vertex_vector * pv, - const Point_2& fs, int fq ) - : query_pt( q ), vertices( pv ), shifted_source( fs ), - shifted_quadrant( fq ) - { is_vertex_query = ( fs != query_pt ); } - bool operator () ( int vdx1, int vdx2 ) const - { return less( vertices->at( vdx1 ), vertices->at( vdx2 ) ); } - }; - -#ifdef CGAL_LINKED_WITH_TBB - class Parallel_sweep - { - private: - Parallel_rotational_sweep_visibility_2 * algo; - public: - Parallel_sweep ( Parallel_rotational_sweep_visibility_2 * a ) - : algo( a ) - {} - void operator () ( const tbb::blocked_range& range ) const - { - for ( int i = range.begin(); i != range.end(); i++ ) - algo->compute_visibility_partition( i ); - } - }; - - class Parallel_init_quadrant - { - private: - Parallel_rotational_sweep_visibility_2 * algo; - public: - Parallel_init_quadrant ( Parallel_rotational_sweep_visibility_2 * a ) - : algo( a ) - {} - void operator () ( const tbb::blocked_range& range ) const - { - for ( int i = range.begin(); i != range.end(); i++ ) - algo->init_quadrant_each_vertex( i ); - } - }; - - class Parallel_init_orientation - { - private: - Parallel_rotational_sweep_visibility_2 * algo; - public: - Parallel_init_orientation ( Parallel_rotational_sweep_visibility_2 * a ) - : algo( a ) - {} - void operator () ( const tbb::blocked_range& range ) const - { - for ( int i = range.begin(); i != range.end(); i++ ) - algo->init_orientation_each_edge( i ); - } - }; - - class Parallel_do_intersect_edge - { - private: - Parallel_rotational_sweep_visibility_2 * algo; - const Point_2& dp; - std::vector& results; - public: - Parallel_do_intersect_edge ( Parallel_rotational_sweep_visibility_2 * a, - const Point_2& p, - std::vector& r ) - : algo( a ), dp( p ), results( r ) - {} - void operator () ( const tbb::blocked_range& range ) const - { - for ( int i = range.begin(); i != range.end(); i++ ) - results[i] = algo->do_intersect_edge( dp, i ); - } - }; -#endif - -//private methods -private: - void add_box () const - { - std::vector pts; - pts.reserve( vs.size()+1 ); - for ( int i = 0; i < vs.size(); i++ ) - pts.push_back( vs[i].point() ); - pts.push_back( query_pt ); - - typename Geometry_traits_2::Iso_rectangle_2 bb = CGAL::bounding_box( pts.begin(), pts.end() ); - - Number_type xmin = bb.xmin() - 1, - ymin = bb.ymin() - 1, - xmax = bb.xmax() + 1, - ymax = bb.ymax() + 1; - Point_2 box[4] = { Point_2( xmin, ymin ), Point_2( xmax, ymin ), - Point_2( xmax, ymax ), Point_2( xmin, ymax ) }; - Halfedge_handle e1 = arr_box.insert_in_face_interior - ( Segment_2( box[0], box[1] ), arr_box.unbounded_face() ); - Halfedge_handle e2 = arr_box.insert_from_left_vertex - ( Segment_2( box[1], box[2] ), e1->target() ); - Halfedge_handle e3 = arr_box.insert_from_right_vertex - ( Segment_2( box[2], box[3] ), e2->target() ); - arr_box.insert_at_vertices( Segment_2( box[0], box[3] ), - e1->source(), e3->target() ); - - Circulator circ,curr; - circ = curr = e1->face()->outer_ccb(); - int edge_base = vs.size(); - do { - assert( curr->face() == e1->face() ); - vs.push_back( Vertex_type( curr->source() ) ); - es.push_back( Edge_type( vs.size()-1, vs.size() ) ); - } while ( ++curr != circ ); - es.back().set_index( es.back().source_index(), edge_base ); - } - - void compute_shifted_source () const - { - if ( query_type != VERTEX_QUERY ) { - shifted_source = query_pt; - shifted_quadrant = 0; - } else { - Vertex_type vt( query_edge->next()->target() ); - vt.init_quadrant( query_pt ); - if ( is_small_cone ) { - shifted_source = Point_2( query_pt.x() + query_pt.x() - vt.point().x(), - query_pt.y() + query_pt.y() - vt.point().y() ); - shifted_quadrant = ( vt.quadrant() + 2 ) % 4; - } else { - shifted_source = vt.point(); - shifted_quadrant = vt.quadrant(); - } - } - } - - void init_quadrant_each_vertex( int i ) const - { vs[i].init_quadrant( query_pt ); } - - void init_quadrant_parallel( CGAL::Sequential_tag ) const - { - for ( int i = 0; i < vs.size(); i++ ) - init_quadrant_each_vertex( i ); - } - void init_quadrant_parallel( CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_EBB - Parallel_init_quadrant init( this ); - tbb::parallel_for( tbb::blocked_range(0, vs.size() ), init ); -#else - init_quadrant_parallel( CGAL::Sequential_tag() ); -#endif - } - - void init_orientation_each_edge( int i ) const - { - es[i].init_orientation( query_pt, vs[es[i].source_index()].point(), - vs[es[i].target_index()].point() ); - } - - void init_orientation_parallel( CGAL::Sequential_tag ) const - { - for ( int i = 0; i < es.size(); i++ ) - init_orientation_each_edge( i ); - } - - void init_orientation_parallel( CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_EBB - Parallel_init_orientation init( this ); - tbb::parallel_for( tbb::blocked_range(0, es.size() ), init ); -#else - init_orientation_parallel( CGAL::Sequential_tag() ); -#endif - } - - void sort_vertices( CGAL::Sequential_tag ) const - { - Is_swept_earlier comp ( query_pt, &vs, shifted_source, shifted_quadrant ); - std::sort( good_vdx.begin(), good_vdx.end(), comp ); - } - - void sort_vertices( CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_TBB - Is_swept_earlier comp ( query_pt, &vs, shifted_source, shifted_quadrant ); - tbb::parallel_sort( good_vdx.begin(), good_vdx.end(), comp ); -#else - sort_vertices( CGAL::Sequential_tag() ); -#endif - } - - void remove_duplicated_vertices() const - { - // find duplicated vertices - int last = 0; - for ( int i = 0; i < good_vdx.size(); i++ ) { - if ( vs[good_vdx[i]].handle() != vs[good_vdx[last]].handle() ) { - last++; - vs[good_vdx[i]].set_sorted_index( last ); - good_vdx[last] = good_vdx[i]; - } else { - vs[good_vdx[i]].set_sorted_index( last ); - vs[good_vdx[i]].set_alias_index( good_vdx[last] ); - } - } - good_vdx.erase( good_vdx.begin()+last+1, good_vdx.end() ); - } - - void sort_incident ( CGAL::Sequential_tag ) const - { std::sort( incident.begin(), incident.end() ); } - void sort_incident ( CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_TBB - tbb::parallel_sort( incident.begin(), incident.end() ); -#else - sort_incident( CGAL::Sequential_tag() ); -#endif - } - - void construct_incident_map() const - { - incident.clear(); - incident.reserve( es.size()*2 ); - for ( int i = 0; i < es.size(); i++ ) { - incident.push_back( std::make_pair( vs[es[i].source_index()].alias_index(), i ) ); - incident.push_back( std::make_pair( vs[es[i].target_index()].alias_index(), i ) ); - } - sort_incident( ConcurrencyCategory() ); - - int i = 0; - while ( i < incident.size() ) { - int j = i; - while ( j < incident.size() && incident[j].first == incident[i].first ) - j++; - vs[incident[i].first].set_incident_index( i, j ); - i = j; - } - } - - bool funnel_block_right( int v_idx, int e_idx ) const - { - int s_idx = vs[es[e_idx].source_index()].alias_index(); - int t_idx = vs[es[e_idx].target_index()].alias_index(); - assert( s_idx == v_idx || t_idx == v_idx ); - if ( v_idx == s_idx ) { - return ( es[e_idx].right_turn() || - es[e_idx].outward() || - ( es[e_idx].at_source() && !is_small_cone ) ); - } else { - return ( es[e_idx].left_turn() || - es[e_idx].outward() || - es[e_idx].in_edge() || - es[e_idx].at_source() || - ( es[e_idx].at_target() && !is_small_cone ) ); - } - } - - bool funnel_has_precedessor( int v_idx, int e_idx ) const - { - int s_idx = vs[es[e_idx].source_index()].alias_index(); - int t_idx = vs[es[e_idx].target_index()].alias_index(); - assert( s_idx == v_idx || t_idx == v_idx ); - if ( v_idx == s_idx ) - return es[e_idx].inward(); - else - return es[e_idx].outward(); - } - - void funnel ( int first, int last ) const - { - std::vector left, right; - left.reserve( last - first ); - right.reserve( last - first ); - bool block_right = false; - for ( int i = first; i < last; i++ ) { - int v_idx = good_vdx[i]; - bool right_v = false, has_precedessor = false; - for ( int j = vs[v_idx].first_incident(); - j < vs[v_idx].last_incident(); j++ ) { - int e_idx = incident[j].second; - if ( funnel_block_right( v_idx, e_idx ) ) - right_v = true; - if ( funnel_has_precedessor( v_idx, e_idx ) ) - has_precedessor = true; - } - if ( has_precedessor ) - block_right = block_right || right_v; - else - block_right = right_v; - if ( block_right ) - right.push_back( good_vdx[i] ); - else - left.push_back( good_vdx[i] ); - } - for ( int i = 0; i < right.size(); i++ ) - good_vdx[first+i] = right[i]; - for ( int i = 0; i < left.size(); i++ ) - good_vdx[first+right.size()+i] = left[left.size()-1-i]; - for ( int i = first; i < last; i++ ) - vs[good_vdx[i]].set_sorted_index( i ); - } - - void process_funnel () const - { - // TBD: future inmprovement: parallelly compute orientation - std::vector orients( good_vdx.size()-1, CGAL::LEFT_TURN ); - for ( int i = 0; i < good_vdx.size()-1; i++ ) { - if ( query_type == VERTEX_QUERY ) { - if ( vs[good_vdx[i+1]].quadrant() == 0 ) { - // (i+1)-th point is the query point - orients[i] = CGAL::orientation( query_pt, vs[good_vdx[i]].point(), - shifted_source ); - if ( orients[i] == CGAL::COLLINEAR && - shifted_quadrant != vs[good_vdx[i]].quadrant() ) - orients[i] = CGAL::RIGHT_TURN; - } else if ( vs[good_vdx[i]].quadrant() == 0 ) { - // i-th point is the query point - orients[i] = CGAL::orientation( query_pt, shifted_source, - vs[good_vdx[i+1]].point() ); - if ( orients[i] == CGAL::COLLINEAR && - shifted_quadrant != vs[good_vdx[i+1]].quadrant() ) - orients[i] = CGAL::RIGHT_TURN; - } else { - orients[i] = CGAL::orientation( query_pt, vs[good_vdx[i]].point(), - vs[good_vdx[i+1]].point() ); - } - } else { - orients[i] = CGAL::orientation( query_pt, vs[good_vdx[i]].point(), - vs[good_vdx[i+1]].point() ); - if ( orients[i] == CGAL::COLLINEAR && - vs[good_vdx[i]].quadrant() != vs[good_vdx[i+1]].quadrant() ) - orients[i] = CGAL::RIGHT_TURN; - } - } - - for ( int i = 0; i < good_vdx.size(); i++ ) { - int j = i + 1; - while ( j < good_vdx.size() ) { - if ( orients[j-1] != CGAL::COLLINEAR ) - break; - j++; - } - if ( j - i > 1 ) - funnel ( i, j ); - i = j - 1; - } - } - -#ifndef NDEBUG - void check_consistency_after_init() const - { - for ( int i = 0; i < vs.size(); i++ ) { - int alias = vs[i].alias_index(); - if ( vs[alias].handle() != vs[i].handle() ) { - cout << "vs[" << i << "].handle() != vs[" << alias << "].handle()" << endl; - } - int vdx = vs[alias].sorted_index(); - if ( vdx < 0 || vdx >= good_vdx.size() ) { - cout << "vs[" << alias << "].sorted_index() = " << vdx << " : out of range" << endl; - } else if ( good_vdx[vdx] != alias ) { - cout << "Inconsistency: vs[" << alias << "].sorted_index = " << vdx << ", but good_vdx[" << vdx <<"] = " << good_vdx[vdx] << endl; - } - for ( int j = vs[alias].first_incident(); j < vs[alias].last_incident(); j++ ) { - if ( incident[j].first != alias ) { - cout << "Inconsistency: in vs[" << alias << "].incident() : incident[" << j << "].first = " << incident[j].first << endl; - } - if ( j == vs[alias].first_incident() && - j != 0 && incident[j-1].first >= alias ) { - cout << "Inconsistency: in vs[" << alias << "].incident() : previous : incident[" << (j-1) << "].first = " << incident[j-1].first << endl; - } - if ( j == vs[alias].last_incident()-1 && - j < incident.size()-1 && incident[j+1].first <= alias ) { - cout << "Inconsistency: in vs[" << alias << "].incident() : next : incident[" << (j+1) << "].first = " << incident[j+1].first << endl; - } - int s_idx = es[incident[j].second].source_index(); - int t_idx = es[incident[j].second].target_index(); - if ( vs[s_idx].alias_index() != alias && - vs[t_idx].alias_index() != alias ) { - cout << "Inconsistency: in vs[" << i << "] : alias = [" << alias << "]; incident[" << j << "].second=[" << incident[j].second << "]" << endl; - } - } - } - } -#endif - - void keep_consistency_after_init() const - { - for ( int i = 0; i < vs.size(); i++ ) { - int alias = vs[i].alias_index(); - if ( alias == i ) - continue; - vs[i].set_incident_index( vs[alias].first_incident(), - vs[alias].last_incident() ); - vs[i].set_sorted_index( vs[alias].sorted_index() ); - } - for ( int i = 0; i < es.size(); i++ ) { - int s_idx = es[i].source_index(); - int t_idx = es[i].target_index(); - es[i].set_index( vs[s_idx].alias_index(), vs[t_idx].alias_index() ); - } - } - - void init_vertices ( const Face_const_handle& fh ) const - { - Circulator circ, curr; - Hole_const_iterator hi; - - vs.clear(); - es.clear(); - good_vdx.clear(); - arr_box.clear(); - - curr = circ = fh->outer_ccb(); - int edge_base = vs.size(); - do { - assert( curr->face() == fh ); - vs.push_back( Vertex_type( curr->source() ) ); - es.push_back( Edge_type( vs.size()-1, vs.size() ) ); - } while ( ++curr != circ ); - es.back().set_index( es.back().source_index(), edge_base ); - for ( hi = fh->holes_begin(); hi != fh->holes_end(); hi++ ) { - curr = circ = *hi; - edge_base = vs.size(); - do { - assert( curr->face() == fh ); - vs.push_back( Vertex_type( curr->source() ) ); - es.push_back( Edge_type( vs.size()-1, vs.size() ) ); - } while ( ++curr != circ ); - es.back().set_index( es.back().source_index(), edge_base ); - } - - if ( query_type != FACE_QUERY ) - add_box(); - - init_quadrant_parallel( ConcurrencyCategory() ); - - init_orientation_parallel( ConcurrencyCategory() ); - - good_vdx.reserve( vs.size() ); - for ( int i = 0; i < vs.size(); i++ ) - good_vdx.push_back( i ); - - // sort vertices by their polar angle - compute_shifted_source(); - sort_vertices( ConcurrencyCategory() ); - - // Build the reverse indexes - for ( int i = 0; i < good_vdx.size(); i++ ) { - vs[good_vdx[i]].set_alias_index( good_vdx[i] ); - vs[good_vdx[i]].set_sorted_index( i ); - } - - // Remove duplicated vertices - remove_duplicated_vertices(); - - // construct the edge index list - construct_incident_map(); - - // deal with funnel - process_funnel(); - - // Keep consistency - keep_consistency_after_init(); - } - - // Precondtion: dp != any end point of the edge. - int do_intersect_edge ( const Point_2& dp, int i ) const - { - CGAL::Orientation orient1, orient2; - if ( es[i].pass_query_pt() ) // ignore bad edges - return 0; - if ( es[i].inward() || es[i].outward() ) - return 0; - orient1 = CGAL::orientation( query_pt, dp, - vs[es[i].source_index()].point() ); - orient2 = CGAL::orientation( query_pt, dp, - vs[es[i].target_index()].point() ); - if ( orient1 != orient2 && orient1 != es[i].orientation() ) - return 1; - return 0; - } - - void do_intersect_parallel ( const Point_2& dp, - std::vector& results, - CGAL::Sequential_tag ) const - { - for ( int i = 0; i < es.size(); i++ ) - results[i] = do_intersect_edge( dp, i ); - } - void do_intersect_parallel ( const Point_2& dp, - std::vector& results, - CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_TBB - Parallel_do_intersect_edge obj( this, dp, results ); - tbb::parallel_for( tbb::blocked_range(0, es.size() ), obj ); -#else - do_intersect_parallel( dp, results, CGAL::Sequential_tag() ); -#endif - } - - int default_cone_size ( CGAL::Sequential_tag ) const - { return vs.size(); } - int default_cone_size ( CGAL::Parallel_tag ) const - { return 256; } - - void partition_cones () const - { - Intersection_edges active_edges( es.size() ); - int curr; - - cones.clear(); - - // Determine the first ray - Point_2 dp; - if ( vs[good_vdx.back()].quadrant() == 0 ) { - if ( shifted_quadrant < 4 ) - dp = query_pt + Vector_2( 1, -1 ); - else - dp = shifted_source + Vector_2( 1, 0 ); - } else if ( vs[good_vdx.back()].quadrant() < 4 ) { - dp = query_pt + Vector_2( 1, -1 ); - } else { - dp = vs[good_vdx.back()].point() + Vector_2( 1, 0 ); - } - - // Initialize - std::vector is( es.size(), 0 ); - /* - * There is a bug here. When I verified the intersection parallelly, - * the program crashed. Thus, I use the Sequential_tag here. - * I will solve this one later. - do_intersect_parallel( dp, is, ConcurrencyCategory() ); - */ - do_intersect_parallel( dp, is, CGAL::Sequential_tag() ); - for ( int i = 0; i < es.size(); i++ ) { - if ( is[i] != 0 ) - active_edges.insert( i ); - } - - // initialize the first cone - int step = default_cone_size( ConcurrencyCategory() ); - int cone_base = 0; - int cone_next = cone_base + step; - if ( cone_next + 16 >= vs.size() ) - cone_next = vs.size(); - cones.push_back( Cone( cone_base, cone_next ) ); - for ( curr = active_edges.begin(); curr != active_edges.end(); - curr = active_edges.next( curr ) ) { - cones.back().insert( curr ); - } - if ( cone_next == vs.size() ) - return; - - // Rotational sweep points to find the intersection edges for other cones - for ( int i = 0; i < good_vdx.size(); i++ ) { - if ( i == cone_next ) { - cone_base = cone_next; - cone_next = cone_base + step; - if ( cone_next + 16 >= good_vdx.size() ) - cone_next = good_vdx.size(); - cones.push_back( Cone( cone_base, cone_next ) ); - for ( curr = active_edges.begin(); curr != active_edges.end(); - curr = active_edges.next( curr ) ) { - cones.back().insert( curr ); - } - if ( cone_next == good_vdx.size() ) - break; - } - - int v_idx = good_vdx[i]; - if ( vs[v_idx].quadrant() == 0 ) - continue; // ignore bad vertex - for ( int j = vs[v_idx].first_incident(); - j < vs[v_idx].last_incident(); j++ ) { - int edx = incident[j].second; - if ( es[edx].pass_query_pt() ) - continue; // ignore bad edges - if ( !active_edges.has( edx ) ) { - active_edges.insert( edx ); - } else { - active_edges.erase( edx ); - } - } - } - } - - Point_2 ray_edge_intersection( int v_idx, int e_idx ) const - { - const Point_2& dp = vs[v_idx].point(); - const Point_2& s = vs[es[e_idx].source_index()].point(); - const Point_2& t = vs[es[e_idx].target_index()].point(); - - if ( CGAL::collinear( query_pt, dp, s ) ) { - if ( CGAL::collinear( query_pt, dp, t ) ) { - if ( CGAL::collinear_are_ordered_along_line( query_pt, s, t ) ) - return s; - else - return t; - } else { - return s; - } - } - - Ray_2 ray( query_pt, dp ); - Segment_2 seg( s, t ); - CGAL::Object obj = CGAL::intersection( ray, seg ); - const Point_2 * ipoint = CGAL::object_cast (&obj ); - assert( ipoint != NULL ); - return Point_2( ipoint->x(), ipoint->y() ); - } - - void compute_visibility_partition( int cone_idx ) const - { - const Cone& cone = cones[cone_idx]; - Sub_region& result = sub_regions[cone_idx]; - typedef std::set edge_container; - typedef typename edge_container::const_iterator edge_iterator; - - Closer_edge comp( query_pt, es, vs ); - edge_container active_edges( comp ); - edge_iterator eit; - - // Initialize - for ( int i = 0; i < cone.size(); i++ ) - active_edges.insert( cone[i] ); - - // Rotational sweep - std::vector insert_edx; - std::vector remove_its; - for ( int i = cone.begin(); i < cone.end(); i++ ) { - int old_top, new_top; - if ( active_edges.empty() ) - old_top = -1; - else - old_top = *active_edges.begin(); - int v_idx = good_vdx[i]; - if ( vs[v_idx].quadrant() == 0 ) - continue; // ignore bad vertex - - insert_edx.clear(); - remove_its.clear(); - for ( int j = vs[v_idx].first_incident(); - j < vs[v_idx].last_incident(); j++ ) { - int edx = incident[j].second; - if ( es[edx].pass_query_pt() ) - continue; // ignore bad edges - eit = active_edges.find( edx ); - if ( eit == active_edges.end() ) - insert_edx.push_back( edx ); - else - remove_its.push_back( eit ); - } - - if ( insert_edx.empty() && remove_its.empty() ) - continue; - - if ( insert_edx.size() == 1 && remove_its.size() == 1 ) { - // Simple replacement - // Use a dirty trick for local replacement - const int& ctemp = *remove_its.front(); - int& temp = const_cast( ctemp ); - temp = insert_edx.front(); - } else { - for ( int i = 0; i < insert_edx.size(); i++ ) { - active_edges.insert( insert_edx[i] ); - } - for ( int i = 0; i < remove_its.size(); i++ ) - active_edges.erase( remove_its[i] ); - } - - if ( active_edges.empty() ) - new_top = -1; - else - new_top = *active_edges.begin(); - if ( old_top != new_top ) { - // The closest edge changed - if ( !insert_edx.empty() && !remove_its.empty() ) { - // Some edges are added, and some are removed - // the current vertex is part of visibility region - result.insert( v_idx ); - } else if ( remove_its.empty() ) { - // Only add edges, the view ray is blocked by new edges - if ( old_top != -1 ) - result.insert( v_idx, old_top ); - result.insert( v_idx ); - } else { - // Only remove edges, a block for the view ray is removed - result.insert( v_idx ); - if ( new_top != -1 ) - result.insert( v_idx, new_top ); - } - } - } - } - - void compute_visibility_parallel( CGAL::Sequential_tag ) const - { - for ( int i = 0; i < cones.size(); i++ ) - compute_visibility_partition( i ); - } - - void compute_visibility_parallel( CGAL::Parallel_tag ) const - { -#ifdef CGAL_LINKED_WITH_TBB - if ( cones.size() == 1 ) - return compute_visibility_parallel( CGAL::Sequential_tag() ); - Parallel_sweep sweep( this ); - tbb::parallel_for( tbb::blocked_range(0, cones.size() ), sweep ); -#else - return compute_visibility_parallel( CGAL::Sequential_tag() ); -#endif - } - - void merge_result() const - { - polygon.clear(); - cone_end_idx = cone_start_idx = -1; - for ( int i = 0; i < sub_regions.size(); i++ ) { - for ( int j = 0; j < sub_regions[i].size(); j++ ) { - Point_2 p = sub_regions[i].get_point( query_pt, vs, es, j ); - if ( !polygon.empty() && p == polygon.back() ) - continue; - polygon.push_back( p ); - if ( query_type != FACE_QUERY ) { - if ( p == cone_end->point() ) - cone_end_idx = polygon.size() - 1; - if ( p == cone_start->point() ) - cone_start_idx = polygon.size() - 1; - } - } - } - assert( polygon.size() > 2 ); - } - - void compute_visibility_impl ( const Face_const_handle& fh ) const - { - assert( !fh->is_unbounded() ); - - init_vertices( fh ); - - partition_cones(); - - // Initial visibility results - sub_regions.clear(); - for ( int i = 0; i < cones.size(); i++ ) { - int pts_num = cones[i].end() - cones[i].begin(); - sub_regions.push_back( Sub_region( pts_num ) ); - } - - compute_visibility_parallel( ConcurrencyCategory() ); - - merge_result(); - - //trace_all( cout ); - } - - template - void conditional_regularize( VARR& arr_out, CGAL::Tag_true ) const - { regularize_output( arr_out ); } - - template - void conditional_regularize( VARR& arr_out, CGAL::Tag_false ) const - {} // do nothing - - template - void regularize_output( VARR& arr_out ) const - { - typename VARR::Edge_iterator eit; - for ( eit = arr_out.edges_begin(); eit != arr_out.edges_end(); eit++ ) { - if ( eit->face() == eit->twin()->face() ) { - arr_out.remove_edge( eit ); - } - } - } - - -// private trace mthods -private: -#ifndef NDEBUG - void trace_all ( ostream& os ) const - { - os << "***********************************" << endl; - os << " Trace All" << endl; - os << "***********************************" << endl; - os << "query_pt = [" << query_pt << "]" << endl; - os << "query_type = ["; - switch( query_type ) { - case VERTEX_QUERY: - os << "Vertex query"; - break; - case EDGE_QUERY: - os << "Edge query"; - break; - case FACE_QUERY: - os << "Face query"; - break; - } - os << "]" << endl; - os << "vs = " << endl; - for ( int i = 0; i < vs.size(); i++ ) { - os << " idx = [" << i << "] : "; - vs[i].trace( os, 0 ); - } - os << "es = " << endl; - for ( int i = 0; i < es.size(); i++ ) { - os << " idx = [" << i << "] : "; - es[i].trace( os, 0 ); - } - os << "good_vdx = " << endl; - for ( int i = 0; i < good_vdx.size(); i++ ) - os << " vdx[" << i << "] = [" << good_vdx[i] << "]" << endl; - os << "incident = " << endl; - for ( int i = 0; i < incident.size(); i++ ) { - os << " incident[" << i << "] : vidx = " << incident[i].first << " , eidx = " << incident[i].second << endl; - } - if ( query_type != FACE_QUERY ) { - os << "query_edge = [" << query_edge->source()->point() - << " -> " << query_edge->target()->point() - << ", is_small_cone=[" << is_small_cone - << "]" << endl; - } - os << "cones = " << endl; - for ( int i = 0; i < cones.size(); i++ ) { - os << " " << "cone[" << i << "] =" << endl; - cones[i].trace( os, 2 ); - } - os << "sub_regions = " << endl; - for ( int i = 0; i < sub_regions.size(); i++ ) { - os << " " << "sub_regions[" << i << "] =" << endl; - sub_regions[i].trace( os, 2 ); - } - os << "polygon = " << endl; - for ( int i = 0; i < polygon.size(); i++ ) { - os << " " << polygon[i] << endl; - } - os << "***********************************" << endl; - os << endl; - } -#endif - -// public methods -public: - // Constructors - Parallel_rotational_sweep_visibility_2 () - : p_arr(NULL), geom_traits(NULL) - {} - Parallel_rotational_sweep_visibility_2 ( const Arrangement_2& arr ) - : p_arr(&arr) - { geom_traits = p_arr->geometry_traits(); } - const std::string name () const - { return std::string("R_visibility_2"); } - - // function to compute visibility, query point lies in the interior of a face - template - typename VARR::Face_handle - compute_visibility( const Point_2& q, const Halfedge_const_handle& e, - VARR& arr_out ) const - { - if ( q == e->source()->point() ) - return compute_visibility( q, e->prev(), arr_out ); - arr_out.clear(); - query_pt = q; - query_edge = e; - - if ( query_pt == e->target()->point() ) { - query_type = VERTEX_QUERY; - cone_end = e->source(); - cone_start = e->next()->target(); - if ( CGAL::orientation( e->source()->point(), - e->target()->point(), - e->next()->target()->point() ) - == CGAL::LEFT_TURN ) - is_small_cone = true; - else - is_small_cone = false; - } else { - query_type = EDGE_QUERY; - cone_end = e->source(); - cone_start = e->target(); - is_small_cone = false; - } - - compute_visibility_impl( e->face() ); - - // decide which inside of the visibility butterfly - int small_idx, big_idx; - if ( cone_end_idx < cone_start_idx ) { - small_idx = cone_end_idx; - big_idx = cone_start_idx; - } else { - small_idx = cone_start_idx; - big_idx = cone_end_idx; - } - int next_idx = small_idx + 1; - bool is_between; - if ( CGAL::right_turn( cone_end->point(), query_pt, cone_start->point() ) ) { - is_between = false; - while ( next_idx != big_idx ) { - if ( CGAL::left_turn( cone_end->point(), query_pt, polygon[next_idx] ) || - CGAL::left_turn( query_pt, cone_start->point(), polygon[next_idx] ) ) { - is_between = true; - break; - } - next_idx++; - } - } else { - is_between = true; - while ( next_idx != big_idx ) { - if ( CGAL::right_turn( cone_end->point(), query_pt, polygon[next_idx] ) || - CGAL::right_turn( query_pt, cone_start->point(), polygon[next_idx] ) ) { - is_between = false; - break; - } - next_idx++; - } - } - - std::vector polygon_out; - typename std::vector::iterator first = polygon.begin() + small_idx; - typename std::vector::iterator last = polygon.begin() + big_idx; - if ( is_between ) { - polygon_out.assign( first, last+1 ); - if ( query_type == VERTEX_QUERY ) - polygon_out.push_back( query_pt ); - } else { - polygon_out.assign( polygon.begin(), first+1 ); - if ( query_type == VERTEX_QUERY ) - polygon_out.push_back( query_pt ); - for ( int i = big_idx; i != polygon.size(); i++ ) - polygon_out.push_back( polygon[i] ); - } - - CGAL::Visibility_2::report_while_handling_needles - < Parallel_rotational_sweep_visibility_2 > - ( geom_traits, query_pt, polygon_out, arr_out ); - - conditional_regularize( arr_out, Regularization_category() ); - - if ( arr_out.faces_begin()->is_unbounded() ) - return ++arr_out.faces_begin(); - else - return arr_out.faces_begin(); - } - - // function to compute visibility, query point lies on an edge or at a vertex - template - typename VARR::Face_handle - compute_visibility( const Point_2& q, const Face_const_handle f, - VARR& arr_out ) const - { - arr_out.clear(); - query_pt = q; - query_type = FACE_QUERY; - is_small_cone = false; - - compute_visibility_impl( f ); - - CGAL::Visibility_2::report_while_handling_needles - < Parallel_rotational_sweep_visibility_2 > - ( geom_traits, query_pt, polygon, arr_out ); - - conditional_regularize( arr_out, Regularization_category() ); - - if ( arr_out.faces_begin()->is_unbounded() ) - return ++arr_out.faces_begin(); - else - return arr_out.faces_begin(); - } - - bool is_attached () const - { return ( p_arr != NULL ); } - void attach( const Arrangement_2& arr ) - { p_arr = &arr; geom_traits = p_arr->geometry_traits(); } - void detach () - { p_arr = NULL; geom_traits = NULL; } - const Arrangement_2& arrangement_2() const - { return *p_arr; } - - -// Private data members -private: - const Geometry_traits_2 * geom_traits; - const Arrangement_2 * p_arr; - - mutable Point_2 query_pt; - mutable Halfedge_const_handle query_edge; - mutable enum { VERTEX_QUERY, EDGE_QUERY, FACE_QUERY } query_type; - mutable Vertex_vector vs; - mutable Edge_vector es; - mutable std::vector good_vdx; - mutable std::vector< std::pair > incident; - mutable std::vector cones; - mutable std::vector sub_regions; - mutable Point_vector polygon; - - mutable Vertex_const_handle cone_end; - mutable Vertex_const_handle cone_start; - mutable int cone_end_idx; - mutable int cone_start_idx; - mutable Arrangement_2 arr_box; - - mutable bool is_small_cone; - mutable Point_2 shifted_source; - mutable int shifted_quadrant; -}; - -} // end namespace CGAL - - - -#endif - - diff --git a/Visibility_2/include/CGAL/Parallel_triangular_expansion_visibility_2.h b/Visibility_2/include/CGAL/Parallel_triangular_expansion_visibility_2.h deleted file mode 100644 index 29136266d94..00000000000 --- a/Visibility_2/include/CGAL/Parallel_triangular_expansion_visibility_2.h +++ /dev/null @@ -1,601 +0,0 @@ -// Copyright (c) 2013 Technical University Braunschweig (Germany). -// 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$ -// -// -// Author(s): Michael Hemmer -// Ning Xu -// - -#ifndef CGAL_PARALLEL_TRIANGULAR_EXPANSION_VISIBILITY_2__H -#define CGAL_PARALLEL_TRIANGULAR_EXPANSION_VISIBILITY_2__H - -#include -#include -#include -#include - -#ifdef CGAL_LINKED_WITH_TBB - #include "tbb/parallel_do.h" - #include "tbb/concurrent_vector.h" -#endif - -namespace CGAL { - -template < class Arrangement_2_, - class RegularizationCategory = CGAL::Tag_true, - class ConcurrencyCategory = CGAL::Parallel_tag > -class Parallel_triangular_expansion_visibility_2 -{ - typedef typename Arrangement_2_::Geometry_traits_2 Geometry_traits_2; - typedef typename Geometry_traits_2::Kernel K; -public: - // Currently only consider with same type for both - typedef Arrangement_2_ Arrangement_2; - typedef typename Arrangement_2::Traits_2 Traits_2; - typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - - typedef typename K::Point_2 Point_2; - typedef typename Geometry_traits_2::Ray_2 Ray_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; - typedef typename Geometry_traits_2::Line_2 Line_2; - typedef typename Geometry_traits_2::Vector_2 Vector_2; - typedef typename Geometry_traits_2::Direction_2 Direction_2; - typedef typename Geometry_traits_2::FT Number_type; - typedef typename Geometry_traits_2::Object_2 Object_2; - - // TODO - typedef RegularizationCategory Regularization_category; - - typedef CGAL::Tag_true Supports_general_polygon_category; - typedef CGAL::Tag_true Supports_simple_polygon_category; - -private: - typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::No_intersection_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; - - typedef typename CDT::Face_handle CDT_Face_handle; - typedef std::pair CDT_Edge; - typedef typename CDT::Vertex_handle CDT_Vertex_handle; - -private: - class Edge - { - private: - CDT_Face_handle fh; - int idx; - CDT_Vertex_handle lvh; - CDT_Vertex_handle rvh; - public: - Edge () - : fh( NULL ), idx( -1 ), lvh( NULL ), rvh( NULL ) - {} - Edge ( CDT_Face_handle f, int i, CDT_Vertex_handle l, CDT_Vertex_handle r ) - : fh( f ), idx( i ), lvh( l ), rvh( r ) - {} - CDT_Face_handle face () const - { return fh; } - int index () const - { return idx; } - CDT_Vertex_handle left_source () const - { return lvh; } - CDT_Vertex_handle right_source () const - { return rvh; } - CDT_Vertex_handle left_vertex () const - { return fh->vertex( fh->cw( idx ) ); } - CDT_Vertex_handle right_vertex () const - { return fh->vertex( fh->ccw( idx ) ); } - bool left_ray_degenerate () const - { return ( lvh->point() == left_vertex()->point() ); } - bool right_ray_degenerate () const - { return ( rvh->point() == right_vertex()->point() ); } - - CDT_Edge edge () const - { return CDT_Edge( fh, idx ); } - - void trace ( ostream& os, int level ) const - { - for ( int i = 0; i < level; i++ ) os << " "; - os << "lvh = " << lvh->point() << ", rvh = " << rvh->point() << " , left = " << left_vertex()->point() << " , right = " << right_vertex()->point() << endl; - } - }; - - class Edge_bundle - { - private: - std::queue data; - std::vector constrained; - public: - Edge_bundle () - {} - - int capacity () const - { return 128; } - int size () const - { return data.size(); } - bool empty () const - { return data.empty(); } - bool full () const - { return ( data.size() == capacity() ); } - int constrained_size () const - { return constrained.size(); } - const Edge& get_constrained( int pos ) const - { return constrained[pos]; } - - const Edge& front () const - { return data.front(); } - void push( const Edge& e ) - { data.push( e ); } - void pop () - { data.pop(); } - void clear () - { - while ( !data.empty() ) data.pop(); - constrained.clear(); - } - void push_constrained ( const Edge& e ) - { - constrained.push_back( e ); - } - - void trace ( ostream& os, int level ) const - { - std::queue tmp = data; - int i = 0; - while ( !tmp.empty() ) { - for ( int j = 0; j < level; j++ ) os << " "; - os << "edge[" << i << "] = "; - tmp.front().trace( os, level+1 ); - i++; - tmp.pop(); - } - } - }; - -private: - typedef std::vector EB_vector; -#ifdef CGAL_LINKED_WITH_TBB - typedef tbb::concurrent_vector Result_container; -#else - typedef std::vector Result_container; -#endif - -private: - -#ifdef CGAL_LINKED_WITH_TBB - class Parallel_expand - { - private: - Parallel_triangular_expansion_visibility_2 * algo; - Result_container * p_result; - public: - Parallel_expand( Parallel_triangular_expansion_visibility_2 * a, - Result_container * pr ) - : algo( a ), p_result( pr ) - {} - void operator () ( Edge_bundle& bundle, tbb::parallel_do_feeder& feeder ) const - { - algo->compute_visibility_bundle( bundle ); - for ( int i = 0; i < bundle.constrained_size(); i++ ) - p_result->push_back( bundle.get_constrained( i ) ); - if ( bundle.empty() ) - return; - Edge_bundle res; - while ( !bundle.empty() ) { - res.push( bundle.front() ); - bundle.pop(); - if ( res.full() ) { - feeder.add( res ); - res.clear(); - } - } - if ( !res.empty() ) - feeder.add( res ); - } - }; -#endif - -private: - Edge left_edge ( CDT_Face_handle f, int idx ) - { return Edge( f, f->cw(idx), f->vertex(f->ccw(idx)), f->vertex(idx) ); } - Edge right_edge ( CDT_Face_handle f, int idx ) - { return Edge( f, f->ccw(idx), f->vertex(idx), f->vertex(f->cw(idx)) ); } - - CDT_Face_handle find_face_having_halfedge( CDT_Face_handle fh, int index ) - { - CDT_Face_handle curr, circ, nfh; - int curr_idx, nindex; - - curr = circ = fh; - curr_idx = index; - do { - if ( curr->vertex( curr->cw( curr_idx ) )->point() == query_edge->source()->point() ) - return curr; - nfh = curr->neighbor( curr->cw(curr_idx) ); - nindex = nfh->index( curr ); - curr = nfh; - curr_idx = nfh->cw( nindex ); - } while ( curr != circ && !p_cdt->is_infinite( curr ) ); - - if ( p_cdt->is_infinite( curr ) ) { - curr = circ = fh; - curr_idx = index; - do { - if ( curr->vertex( curr->cw( curr_idx ) )->point() == query_edge->source()->point() ) - return curr; - nfh = curr->neighbor( curr->ccw(curr_idx) ); - nindex = nfh->index( curr ); - curr = nfh; - curr_idx = nfh->ccw( nindex ); - } while ( curr != circ && !p_cdt->is_infinite( curr ) ); - } - // Something must be wrong here! - return NULL; - } - int find_index_of_halfedge( CDT_Face_handle fh ) - { - for ( int i = 0; i < 3; i++ ) { - if ( fh->vertex( i )->point() == query_pt ) - return i; - } - // Something must be wrong here! - return -1; - } - void insert_edges_of_vertex_query( Edge_bundle& edges, CDT_Face_handle fh, int index ) - { - CDT_Face_handle curr = fh; - int curr_idx = index; - do { - edges.push( left_edge( curr, curr->ccw( curr_idx ) ) ); - CDT_Face_handle nfh = curr->neighbor( curr->cw(curr_idx) ); - int nindex = nfh->index( curr ); - curr = nfh; - curr_idx = nfh->cw( nindex ); - } while ( curr->vertex(curr->cw(curr_idx))->point() != query_edge->next()->target()->point() ); - } - - int expand_threshold () - { return 1024; } - - void compute_visibility_bundle( Edge_bundle& bundle ) - { - int count = 0; - int threshold = expand_threshold(); - while ( !bundle.empty() && count < threshold ) { - const Edge& e = bundle.front(); - - if ( p_cdt->is_constrained( e.edge() ) ) { - // A constrained edge - bundle.push_constrained( e ); - } else { - // An unconstrained edge, should be expanded - // deal with the left edge - - CDT_Face_handle nfh = e.face()->neighbor( e.index() ); - int nindex = nfh->index( e.face() ); - int rindex = p_cdt->ccw( nindex ); - int lindex = p_cdt->cw( nindex ); - - CDT_Vertex_handle nvh = nfh->vertex( nindex ); - CDT_Vertex_handle rvh = nfh->vertex( lindex ); - CDT_Vertex_handle lvh = nfh->vertex( rindex ); - - CGAL::Orientation ro = CGAL::orientation( query_pt, - e.right_source()->point(), - nvh->point() ); - CGAL::Orientation lo = CGAL::orientation( query_pt, - e.left_source()->point(), - nvh->point() ); - - if ( ro == CGAL::LEFT_TURN ) { - // The right edge is seen - if ( lo == CGAL::LEFT_TURN ) { - // No split is needed - bundle.push( Edge( nfh, rindex, e.left_source(), e.right_source() ) ); - count++; - } else if ( lo == CGAL::RIGHT_TURN ) { - // split at the new vertex - bundle.push( Edge( nfh, rindex, nvh, e.right_source() ) ); - count++; - } else { - // the right edge is not seen, but the opposite vertex is seen - bundle.push( Edge( nfh, rindex, nvh, e.right_source() ) ); - count++; - bundle.push_constrained( Edge( nfh, rindex, e.left_source(), e.left_source() ) ); - } - } - - if ( lo == CGAL::RIGHT_TURN ) { - // The left edge is seen - if ( ro == CGAL::RIGHT_TURN ) { - // No split is needed - bundle.push( Edge( nfh, lindex, e.left_source(), e.right_source() ) ); - count++; - } else if ( ro == CGAL::LEFT_TURN ) { - // split at the new vertex - bundle.push( Edge( nfh, lindex, e.left_source(), nvh ) ); - count++; - } else { - // the left edge is not seen, but the opposite vertex is seen - bundle.push_constrained( Edge( nfh, lindex, e.right_source(), e.right_source() ) ); - } - } - } - - bundle.pop(); - } - } - - void compute_visibility_parallel ( Edge_bundle& bundle, - Result_container& result, - CGAL::Sequential_tag ) - { - } - - void compute_visibility_parallel ( Edge_bundle& bundle, - Result_container& result, - CGAL::Parallel_tag ) - { -#ifdef CGAL_LINKED_WITH_TBB - std::vector bundles; - bundles.push_back( bundle ); - Parallel_expand exp( this, &result ); - tbb::parallel_do( bundles.begin(), bundles.end(), exp ); -#else - compute_visibility_parallel( bundle, CGAL::Sequential_tag() ); -#endif - } - - - Point_2 ray_seg_intersection ( const Point_2& dp, - const Point_2& s, - const Point_2& t ) - { - Ray_2 ray( query_pt, dp ); - Segment_2 seg( s, t ); - assert( CGAL::do_intersect( ray, seg ) ); - CGAL::Object obj = CGAL::intersection( ray, seg ); - const Point_2 * ipoint = CGAL::object_cast( &obj ); - assert( ipoint != NULL ); - return *ipoint; - } - - template < class VARR > - void compute_visibility_impl ( VARR& arr_out) - { - arr_out.clear(); - // Locate the query point - typename CDT::Locate_type location; - int index; - CDT_Face_handle fh = p_cdt->locate( query_pt, location, index ); - - Edge_bundle edges; - - switch( location ) { - case CDT::FACE: - // The query point locates in a face - // It only occurs in FACE_QUERY - assert( query_type == FACE_QUERY ); - edges.push( Edge( fh, 0, fh->vertex(2), fh->vertex(1) ) ); - edges.push( Edge( fh, 1, fh->vertex(0), fh->vertex(2) ) ); - edges.push( Edge( fh, 2, fh->vertex(1), fh->vertex(0) ) ); - break; - case CDT::VERTEX: - // The query point locates at a vertex - // It only occurs in VERTEX_QUERY - // Find the face containing the halfedge in query - assert( query_type == VERTEX_QUERY ); - fh = find_face_having_halfedge( fh, index ); - assert( fh != NULL ); - index = find_index_of_halfedge( fh ); - assert( index >= 0 ); - - insert_edges_of_vertex_query( edges, fh, index ); - break; - case CDT::EDGE: - // The query point locates on an edge - // It may occur in FACE_QUERY and EDGE_QUERY - assert( query_type != VERTEX_QUERY ); - if ( !p_cdt->is_constrained( std::make_pair(fh, index) ) ) { - // the edge is not contrained - CDT_Face_handle nfh = fh->neighbor( index ); - int nindex = nfh->index( fh ); - assert( !p_cdt->is_infinite( fh ) ); - assert( !p_cdt->is_infinite( nfh ) ); - edges.push( left_edge( fh, index ) ); - edges.push( right_edge( fh, index ) ); - edges.push( left_edge( nfh, nindex ) ); - edges.push( right_edge( nfh, nindex ) ); - } else { - // the edge is contrained - if ( fh->vertex(fh->cw(index))->point() == query_edge->target()->point() ) { - // the locating edge is the halfedge in query - assert( !p_cdt->is_infinite( fh ) ); - edges.push( left_edge( fh, index ) ); - edges.push( right_edge( fh, index ) ); - } else { - // the locating edge is not the halfedge in query - CDT_Face_handle nfh = fh->neighbor( index ); - int nindex = nfh->index( fh ); - assert( !p_cdt->is_infinite( nfh ) ); - edges.push( left_edge( nfh, nindex ) ); - edges.push( right_edge( nfh, nindex ) ); - } - } - break; - } - - Result_container results; - - compute_visibility_parallel( edges, results, ConcurrencyCategory() ); - - // Generate results - std::vector segs; - for ( int i = 0; i < results.size(); i++ ) { - // push segments on the edge - if ( results[i].left_source()->point() == results[i].right_source()->point() ) { - // Special case - // the constrained edge is introduced by a single ray - if ( CGAL::orientation( query_pt, results[i].left_source()->point(), - results[i].left_vertex()->point() ) - == CGAL::COLLINEAR ) { - // the left vertex is shoot by the ray - if ( !results[i].left_ray_degenerate() ) { - segs.push_back( Segment_2( results[i].left_vertex()->point(), - results[i].left_source()->point() ) ); - } - } else { - // the right vertex is shoot by the ray - if ( !results[i].right_ray_degenerate() ) { - segs.push_back( Segment_2( results[i].right_source()->point(), - results[i].right_vertex()->point() ) ); - } - } - continue; - } - - Point_2 lp = ray_seg_intersection( results[i].left_source()->point(), - results[i].left_vertex()->point(), - results[i].right_vertex()->point() ); - Point_2 rp = ray_seg_intersection( results[i].right_source()->point(), - results[i].left_vertex()->point(), - results[i].right_vertex()->point() ); - if ( lp != rp ) - segs.push_back( Segment_2( rp, lp ) ); - - //push segments on the left side - if ( results[i].left_source() != results[i].left_vertex() ) { - segs.push_back( Segment_2( lp, results[i].left_source()->point() ) ); - } - - //push segments on the right side - if ( results[i].right_source() != results[i].right_vertex() ) { - segs.push_back( Segment_2( results[i].right_source()->point(), rp ) ); - } - } - - CGAL::insert( arr_out, segs.begin(), segs.end() ); - } - - void init_cdt () - { - std::vector< std::pair > constraints; - typename Arrangement_2::Edge_const_iterator eit; - for ( eit = p_arr->edges_begin(); eit != p_arr->edges_end(); eit++ ) { - constraints.push_back( std::make_pair( eit->source()->point(), - eit->target()->point() ) ); - } - CDT * p = new CDT( constraints.begin(), constraints.end() ); - assert( p != NULL ); - p_cdt = boost::shared_ptr( p ); - } - -public: - Parallel_triangular_expansion_visibility_2 () - : p_arr( NULL ) - {} - Parallel_triangular_expansion_visibility_2 ( const Arrangement_2& arr ) - : p_arr( &arr ) - { init_cdt(); } - void attach ( const Arrangement_2& arr ) - { - if ( p_arr != &arr ) { - p_arr = arr; - init_cdt(); - } - } - void detach () - { - p_arr = NULL; - p_cdt = boost::shared_ptr(); - } - bool is_attached () const - { return ( p_arr != NULL ); } - const Arrangement_2& arr () const - { return &p_arr; } - const std::string name () const - { return std::string( "PT_visibility_2" ); } - - - template < class VARR > - typename VARR::Face_handle - compute_visibility ( const Point_2& q, - const Face_const_handle& fh, - VARR& arr_out ) - { - query_pt = q; - query_type = FACE_QUERY; - - - compute_visibility_impl( arr_out ); - - assert( arr_out.number_of_faces() == 2 ); - - if ( arr_out.faces_begin()->is_unbounded() ) - return ++arr_out.faces_begin(); - else - return arr_out.faces_begin(); - } - - template < class VARR > - typename VARR::Face_handle - compute_visibility ( const Point_2& q, - const Halfedge_const_handle& eh, - VARR& arr_out ) - { - if ( q == eh->source()->point() ) - return compute_visibility( q, eh->prev(), arr_out ); - - query_pt = q; - query_edge = eh; - if ( query_pt == eh->target()->point() ) { - query_type = VERTEX_QUERY; - } else { - query_type = EDGE_QUERY; - } - compute_visibility_impl( arr_out ); - - assert( arr_out.number_of_faces() == 2 ); - - if ( arr_out.faces_begin()->is_unbounded() ) - return ++arr_out.faces_begin(); - else - return arr_out.faces_begin(); - } - - -private: - const Arrangement_2* p_arr; - boost::shared_ptr p_cdt; - - Point_2 query_pt; - enum { VERTEX_QUERY, EDGE_QUERY, FACE_QUERY } query_type; - Halfedge_const_handle query_edge; -}; - -} // namespace CGAL - -#endif //CGAL_TRIANGULAR_EXPANSION_VISIBILITY_2__H diff --git a/Visibility_2/test/Visibility_2/pure_benchmark.cpp b/Visibility_2/test/Visibility_2/pure_benchmark.cpp index 3fa7a370b8d..2e266af4f46 100644 --- a/Visibility_2/test/Visibility_2/pure_benchmark.cpp +++ b/Visibility_2/test/Visibility_2/pure_benchmark.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -60,13 +59,11 @@ void benchmark_one_class(std::string name, const CGAL::Query_choice& qchoice, st deploy_pure_benchmark > (qchoice, input); if (name == "R") deploy_pure_benchmark > (qchoice, input); - if (name == "PR") - deploy_pure_benchmark > (qchoice, input); } void print_usage() { std::cout << "Usage: ./pure_benchmark [filename] [Class type] [Query type] [Regularize]\n"; - std::cout << "where [Class type] could be S(simple), R(rotational sweep), PR(parallel rotational sweep), and T(triangular), indicating which class you want to test.\n"; + std::cout << "where [Class type] could be S(simple), R(rotational sweep), and T(triangular), indicating which class you want to test.\n"; std::cout << "[Query type] can be: {vertex, edge, face}.\n"; std::cout << "[Regularize] can be: {true, false}.\n"; } diff --git a/Visibility_2/test/Visibility_2/simple_benchmark.cpp b/Visibility_2/test/Visibility_2/simple_benchmark.cpp index fd51382fa42..c00d92082d9 100644 --- a/Visibility_2/test/Visibility_2/simple_benchmark.cpp +++ b/Visibility_2/test/Visibility_2/simple_benchmark.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -63,9 +62,6 @@ void define_snd_class(std::string name2, CGAL::Query_choice& qchoice, std::ifstr if (name2 == "R") deploy_benchmark > (qchoice, input); - if (name2 == "PR") - deploy_benchmark > - (qchoice, input); } template @@ -76,13 +72,11 @@ void benchmark_two_classes(std::string name1, std::string name2, CGAL::Query_cho define_snd_class, Regularization_category> (name2, qchoice, input); if (name1 == "R") define_snd_class, Regularization_category> (name2, qchoice, input); - if (name1 == "PR") - define_snd_class, Regularization_category> (name2, qchoice, input); } void print_usage() { std::cout << "Usage: ./simple_benchmark [filename] [Class type 1] [Class type 2] [Query type] [Regularize]\n"; - std::cout << "where [Class type] could be S(simple), R(rotational sweep), T(triangular), and PR(parallel rotational sweep), indicating which classes you want to test.\n"; + std::cout << "where [Class type] could be S(simple), R(rotational sweep) and T(triangular), indicating which classes you want to test.\n"; std::cout << "[Query type] can be: {vertex, edge, face}.\n"; std::cout << "[Regularize] can be: {true, false}.\n"; } diff --git a/Visibility_2/test/Visibility_2/test_parallel_rotational_visibility.cpp b/Visibility_2/test/Visibility_2/test_parallel_rotational_visibility.cpp deleted file mode 100644 index a6aeafd6881..00000000000 --- a/Visibility_2/test/Visibility_2/test_parallel_rotational_visibility.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2013 Technical University Braunschweig (Germany). -// 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$ -// -// -// Author(s): Francisc Bungiu -// Kan Huang - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include - -int main() { -{ - typedef CGAL::Cartesian Kernel; - typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef Traits_2::Point_2 Point_2; - typedef Traits_2::X_monotone_curve_2 Segment_2; - typedef CGAL::Arrangement_2 Arrangement_2; - { - typedef CGAL::Parallel_rotational_sweep_visibility_2 - RSV; - CGAL::test_model_methods(); - std::cout << "Running test suite with " << GREEN << "Cartesian" << RESET << " Kernel..." << std::endl; - CGAL::run_tests(21, 2); - } - { - typedef CGAL::Parallel_rotational_sweep_visibility_2 - RSV; - CGAL::test_model_methods(); - std::cout << "Running test suite with " << GREEN << "Cartesian" << RESET << " Kernel..." << std::endl; - CGAL::run_tests(21, 2); - } -}{ - typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; - typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef Traits_2::Point_2 Point_2; - typedef Traits_2::X_monotone_curve_2 Segment_2; - typedef CGAL::Arrangement_2 Arrangement_2; - { - typedef CGAL::Parallel_rotational_sweep_visibility_2 - RSV; - CGAL::test_model_methods(); - std::cout << "Running test suite with " << GREEN << "EPECK" << RESET << " Kernel..." << std::endl; - CGAL::run_tests(21, 2); - } - { - typedef CGAL::Parallel_rotational_sweep_visibility_2 - RSV; - CGAL::test_model_methods(); - std::cout << "Running test suite with " << GREEN << "EPECK" << RESET << " Kernel..." << std::endl; - CGAL::run_tests(21, 2); - } -} -{ - // test Visibility_arrangement_type with extended DCEL - typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; - typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef CGAL::Arrangement_2 ARR; - typedef CGAL::Arr_extended_dcel EDCEL; - typedef CGAL::Arrangement_2 EARR; - { - typedef CGAL::Parallel_rotational_sweep_visibility_2 Visibility_2; - CGAL::test_model_methods(); - CGAL::run_tests(21, 2); - }{ - typedef CGAL::Parallel_rotational_sweep_visibility_2 Visibility_2; - CGAL::test_model_methods(); - CGAL::run_tests(21, 2); - } -} -return 0; -}