diff --git a/Triangulation_2/benchmark/Triangulation_2/CDT_insert_on_constraints.cpp b/Triangulation_2/benchmark/Triangulation_2/CDT_insert_on_constraints.cpp new file mode 100644 index 00000000000..b99ff26fb81 --- /dev/null +++ b/Triangulation_2/benchmark/Triangulation_2/CDT_insert_on_constraints.cpp @@ -0,0 +1,203 @@ +#include +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; + + +// usage example CDT_insert_on_constraints < norway.cin +int main() +{ + std::size_t nbs; + char s; + CDT::Point p1, p2; + std::cin >> nbs; + + CDT cdt; + + do + { + std::cin >> s >> p1 >> p2; + cdt.insert_constraint(p1,p2); + } + while ( --nbs!=0 ); + + std::cout << "Triangulation built "<< cdt.number_of_vertices() << "\n"; + + { + CDT cdt2(cdt); + CGAL::Timer time; + time.start(); + std::vector< std::pair >csts; + for ( CDT::Finite_edges_iterator eit=cdt2.finite_edges_begin(), + eit_end=cdt2.finite_edges_end(); + eit!=eit_end; ++eit) + { + if ( cdt2.is_constrained(*eit) ) + { + CDT::Vertex_handle v1 = eit->first->vertex( CDT::cw(eit->second) ); + CDT::Vertex_handle v2 = eit->first->vertex( CDT::ccw(eit->second) ); + csts.push_back( std::make_pair(v1,v2) ); + } + } + + std::cout << csts.size() << " edges to process\n"; + while ( !csts.empty() ) + { + CDT::Face_handle face; + int index=0; + CDT::Vertex_handle v1=csts.back().first; + CDT::Vertex_handle v2=csts.back().second; + csts.pop_back(); + cdt2.is_edge( v1, v2, face, index ); + cdt2.remove_constrained_edge(face, index); + CDT::Vertex_handle vn = + cdt2.insert( CGAL::midpoint(v1->point(), v2->point()) ); + cdt2.insert_constraint(vn,v1); + cdt2.insert_constraint(vn,v2); + } + + time.stop(); + std::cout << "Unconstraining first " << cdt2.number_of_vertices() << " " << time.time() << std::endl; + } + + { + CDT cdt2(cdt); + CGAL::Timer time; + time.start(); + std::vector< std::pair >csts; + for ( CDT::Finite_edges_iterator eit=cdt2.finite_edges_begin(), + eit_end=cdt2.finite_edges_end(); + eit!=eit_end; ++eit) + { + if ( cdt2.is_constrained(*eit) ) + { + CDT::Vertex_handle v1 = eit->first->vertex( CDT::cw(eit->second) ); + CDT::Vertex_handle v2 = eit->first->vertex( CDT::ccw(eit->second) ); + csts.push_back( std::make_pair(v1,v2) ); + } + } + + std::cout << csts.size() << " edges to process\n"; + while ( !csts.empty() ) + { + CDT::Face_handle face; + int index=0; + CDT::Vertex_handle v1=csts.back().first; + CDT::Vertex_handle v2=csts.back().second; + csts.pop_back(); + cdt2.is_edge( v1, v2, face, index ); + cdt2.remove_constrained_edge(face, index); + CDT::Vertex_handle vn = + cdt2.insert( CGAL::midpoint(v1->point(), v2->point()), v1->face() ); + cdt2.insert_constraint(vn,v1); + cdt2.insert_constraint(vn,v2); + } + + time.stop(); + std::cout << "Unconstraining first +hint " << cdt2.number_of_vertices() << " " << time.time() << std::endl; + } + + { + CDT cdt2(cdt); + CGAL::Timer time; + time.start(); + std::vector< std::pair >csts; + for ( CDT::Finite_edges_iterator eit=cdt2.finite_edges_begin(), + eit_end=cdt2.finite_edges_end(); + eit!=eit_end; ++eit) + { + if ( cdt2.is_constrained(*eit) ) + { + CDT::Vertex_handle v1 = eit->first->vertex( CDT::cw(eit->second) ); + CDT::Vertex_handle v2 = eit->first->vertex( CDT::ccw(eit->second) ); + csts.push_back( std::make_pair(v1,v2) ); + } + } + + std::cout << csts.size() << " edges to process\n"; + while ( !csts.empty() ) + { + CDT::Vertex_handle v1=csts.back().first; + CDT::Vertex_handle v2=csts.back().second; + csts.pop_back(); + CDT::Vertex_handle vn = + cdt2.insert( CGAL::midpoint(v1->point(), v2->point()) ); + } + + time.stop(); + std::cout << "Not unconstraining first " << cdt2.number_of_vertices() << " " << time.time() << std::endl; + } + + { + CDT cdt2(cdt); + CGAL::Timer time; + time.start(); + std::vector< std::pair >csts; + for ( CDT::Finite_edges_iterator eit=cdt2.finite_edges_begin(), + eit_end=cdt2.finite_edges_end(); + eit!=eit_end; ++eit) + { + if ( cdt2.is_constrained(*eit) ) + { + CDT::Vertex_handle v1 = eit->first->vertex( CDT::cw(eit->second) ); + CDT::Vertex_handle v2 = eit->first->vertex( CDT::ccw(eit->second) ); + csts.push_back( std::make_pair(v1,v2) ); + } + } + + std::cout << csts.size() << " edges to process\n"; + while ( !csts.empty() ) + { + CDT::Face_handle face; + int index; + CDT::Vertex_handle v1=csts.back().first; + CDT::Vertex_handle v2=csts.back().second; + csts.pop_back(); + cdt2.is_edge( v1, v2, face, index ); + CDT::Vertex_handle vn = + cdt2.insert( CGAL::midpoint(v1->point(), v2->point()), face ); + } + + time.stop(); + std::cout << "Not unconstraining + hint " << cdt2.number_of_vertices() << " " << time.time() << std::endl; + } + + { + CDT cdt2(cdt); + CGAL::Timer time; + time.start(); + std::vector< std::pair >csts; + for ( CDT::Finite_edges_iterator eit=cdt2.finite_edges_begin(), + eit_end=cdt2.finite_edges_end(); + eit!=eit_end; ++eit) + { + if ( cdt2.is_constrained(*eit) ) + { + CDT::Vertex_handle v1 = eit->first->vertex( CDT::cw(eit->second) ); + CDT::Vertex_handle v2 = eit->first->vertex( CDT::ccw(eit->second) ); + csts.push_back( std::make_pair(v1,v2) ); + } + } + + std::cout << csts.size() << " edges to process\n"; + while ( !csts.empty() ) + { + CDT::Face_handle face; + int index=0; + CDT::Vertex_handle v1=csts.back().first; + CDT::Vertex_handle v2=csts.back().second; + csts.pop_back(); + cdt2.is_edge( v1, v2, face, index ); + CDT::Vertex_handle vn = + cdt2.insert( CGAL::midpoint(v1->point(), v2->point()), CDT::EDGE, face, index ); + } + + time.stop(); + std::cout << "Not unconstraining + locate " << cdt2.number_of_vertices() << " " << time.time() << std::endl; + } +} diff --git a/Triangulation_2/benchmark/Triangulation_2/CMakeLists.txt b/Triangulation_2/benchmark/Triangulation_2/CMakeLists.txt deleted file mode 100644 index 079013837cf..00000000000 --- a/Triangulation_2/benchmark/Triangulation_2/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Created by the script cgal_create_cmake_script -# This is the CMake script for compiling a CGAL application. - - -project( Triangulation_2_test ) - -cmake_minimum_required(VERSION 2.6.2) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) -else() - cmake_policy(VERSION 2.6) -endif() - -find_package(CGAL QUIET COMPONENTS Core ) - -if ( CGAL_FOUND ) - - include( ${CGAL_USE_FILE} ) - - include( CGAL_CreateSingleSourceCGALProgram ) - - include_directories (BEFORE ../../include) - - include_directories (BEFORE ../../../../experimental-packages/Triangulation_2-unrecursive/include) - - create_single_source_cgal_program( "Triangulation_benchmark_2.cpp" ) - create_single_source_cgal_program( "Triangulation_benchmark_2_with_star_hole.cpp" ) - create_single_source_cgal_program( "Delaunay_remove.cpp" ) - create_single_source_cgal_program( "CDT_with_intersection_2.cpp" ) - -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - -endif() -