mirror of https://github.com/CGAL/cgal
Add test
This commit is contained in:
parent
7d8f9ebe95
commit
16eb47b50c
|
|
@ -0,0 +1,62 @@
|
|||
# Created by the script cgal_create_CMakeLists
|
||||
# This is the CMake script for compiling a set of CGAL applications.
|
||||
|
||||
project( Polyline_simplification_2 )
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.2)
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
|
||||
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()
|
||||
endif()
|
||||
|
||||
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
|
||||
|
||||
if ( COMMAND cmake_policy )
|
||||
|
||||
cmake_policy( SET CMP0003 NEW )
|
||||
|
||||
endif()
|
||||
|
||||
# CGAL and its components
|
||||
find_package( CGAL QUIET COMPONENTS )
|
||||
|
||||
if ( NOT CGAL_FOUND )
|
||||
|
||||
message(STATUS "This project requires the CGAL library, and will not be compiled.")
|
||||
return()
|
||||
|
||||
endif()
|
||||
|
||||
# include helper file
|
||||
include( ${CGAL_USE_FILE} )
|
||||
|
||||
|
||||
# Boost and its components
|
||||
find_package( Boost REQUIRED )
|
||||
|
||||
if ( NOT Boost_FOUND )
|
||||
|
||||
message(STATUS "This project requires the Boost library, and will not be compiled.")
|
||||
|
||||
return()
|
||||
|
||||
endif()
|
||||
|
||||
# include for local directory
|
||||
|
||||
# include for local package
|
||||
include_directories( BEFORE ../../include )
|
||||
|
||||
|
||||
# Creating entries for all .cpp/.C files with "main" routine
|
||||
# ##########################################################
|
||||
|
||||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
create_single_source_cgal_program( "simplify_polygon.cpp" )
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
2
|
||||
0 0
|
||||
1 1
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Constrained_triangulation_plus_2.h>
|
||||
#include <CGAL/Polyline_simplification_2/simplify.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
namespace PS = CGAL::Polyline_simplification_2;
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef PS::Vertex_base_2<K> Vb;
|
||||
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> TDS;
|
||||
typedef CGAL::Exact_predicates_tag Itag;
|
||||
typedef CGAL::Constrained_Delaunay_triangulation_2<K,TDS, Itag> CDT;
|
||||
typedef CGAL::Constrained_triangulation_plus_2<CDT> CT;
|
||||
typedef CGAL::Polygon_2<K> Polygon_2;
|
||||
typedef PS::Stop_above_cost_threshold Stop;
|
||||
typedef PS::Squared_distance_cost Cost;
|
||||
|
||||
|
||||
|
||||
void test(char* fname)
|
||||
{
|
||||
CGAL::Timer timer;
|
||||
std::cerr << "simplify " << fname << std::endl;
|
||||
std::ifstream in(fname);
|
||||
int n;
|
||||
CT ct;
|
||||
Polygon_2 P;
|
||||
in >> n; // number of polygons
|
||||
while(in >> P){
|
||||
ct.insert_constraint(P);
|
||||
}
|
||||
std::cerr << ct.number_of_vertices() << " vertices\n";
|
||||
timer.start();
|
||||
PS::simplify(ct, Cost(), Stop(0.5));
|
||||
std::cerr << ct.number_of_vertices() << " vertices\n";
|
||||
std::cerr << timer.time() << " sec.\n";
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
for(int i= 1;i < argc; i++){
|
||||
test(argv[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue