mirror of https://github.com/CGAL/cgal
add a benchmark on insertion of points on constrained edges with EPEC
results on ../../../Segment_Delaunay_graph_2/benchmark/Segment_Delaunay_graph_2/data/norway.cin Triangulation built 40561 40578 edges to process Unconstraining first 81139 0.988062 40578 edges to process Unconstraining first +hint 81139 0.424027 40578 edges to process Not unconstraining first 81139 0.868054 40578 edges to process Not unconstraining + hint 81139 0.288018 40578 edges to process Not unconstraining + locate 81139 0.056003
This commit is contained in:
parent
4d54051234
commit
fc781d10f0
|
|
@ -0,0 +1,203 @@
|
|||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||
typedef CGAL::Constrained_Delaunay_triangulation_2<K> 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<CDT::Vertex_handle, CDT::Vertex_handle> >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<CDT::Vertex_handle, CDT::Vertex_handle> >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<CDT::Vertex_handle, CDT::Vertex_handle> >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<CDT::Vertex_handle, CDT::Vertex_handle> >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<CDT::Vertex_handle, CDT::Vertex_handle> >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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue