mirror of https://github.com/CGAL/cgal
Preliminary testsuite
This commit is contained in:
parent
bb18b38b0a
commit
2342b037b2
|
|
@ -0,0 +1,28 @@
|
|||
# Created by the script cgal_create_cmake_script
|
||||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
|
||||
project( Hyperbolic_triangulation_2_tests )
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.10)
|
||||
|
||||
find_package(CGAL QUIET COMPONENTS Core )
|
||||
|
||||
if ( CGAL_FOUND )
|
||||
|
||||
include( ${CGAL_USE_FILE} )
|
||||
|
||||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
create_single_source_cgal_program( "ht2_test_clear.cpp" )
|
||||
create_single_source_cgal_program( "ht2_test_remove.cpp" )
|
||||
create_single_source_cgal_program( "ht2_test_swap.cpp" )
|
||||
create_single_source_cgal_program( "ht2_test_copy.cpp" )
|
||||
#create_single_source_cgal_program( "ht2_test_equality.cpp" )
|
||||
|
||||
else()
|
||||
|
||||
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
||||
|
||||
endif()
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<> Traits;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Traits> HDTriangulation;
|
||||
typedef HDTriangulation::Point Point;
|
||||
|
||||
typedef CGAL::Random_points_in_square_2<
|
||||
Point,
|
||||
CGAL::Creator_uniform_2< double, Point > > Point_generator;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
|
||||
Point_generator gen(1.);
|
||||
std::vector<Point> pts;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
pts.push_back(*(++gen));
|
||||
|
||||
HDTriangulation tri;
|
||||
tri.insert(pts.begin(), pts.end());
|
||||
|
||||
int nv = tri.number_of_vertices();
|
||||
int nf = tri.number_of_hyperbolic_faces();
|
||||
|
||||
std::cout << " -------- inserting --------" << std::endl;
|
||||
std::cout << "Vertices in triangulation: " << nv << std::endl;
|
||||
std::cout << "Faces in triangulation: " << nf << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri.dimension() << std::endl;
|
||||
assert(tri.dimension() == 2);
|
||||
|
||||
tri.clear();
|
||||
std::cout << " -------- clearing --------" << std::endl;
|
||||
std::cout << "Vertices in triangulation: " << tri.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in triangulation: " << tri.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri.dimension() << std::endl;
|
||||
assert(tri.number_of_vertices() == 0);
|
||||
assert(tri.number_of_hyperbolic_faces() == 0);
|
||||
assert(tri.dimension() < 2);
|
||||
|
||||
tri.insert(pts.begin(), pts.end());
|
||||
std::cout << " -------- re-inserting --------" << std::endl;
|
||||
std::cout << "Vertices in triangulation: " << tri.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in triangulation: " << tri.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri.dimension() << std::endl;
|
||||
assert(tri.number_of_hyperbolic_faces() == nf);
|
||||
assert(tri.number_of_vertices() == nv);
|
||||
assert(tri.dimension() == 2);
|
||||
|
||||
assert(tri.is_valid());
|
||||
|
||||
std::cout << " -------- SUCCESS --------" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<> Traits;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Traits> HDTriangulation;
|
||||
typedef HDTriangulation::Point Point;
|
||||
typedef HDTriangulation::Vertex_handle Vertex_handle;
|
||||
|
||||
typedef CGAL::Random_points_in_disc_2<
|
||||
Point,
|
||||
CGAL::Creator_uniform_2< double, Point > > Point_generator;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
|
||||
Point_generator gen(0.95);
|
||||
std::vector<Point> pts1;
|
||||
for (int i = 0; i < 75; ++i)
|
||||
pts1.push_back(*(++gen));
|
||||
|
||||
std::vector<Point> pts2;
|
||||
for (int i = 0; i < 150; ++i)
|
||||
pts2.push_back(*(++gen));
|
||||
|
||||
HDTriangulation tri1;
|
||||
tri1.insert(pts1.begin(), pts1.end());
|
||||
std::cout << "Vertices in tri1: " << tri1.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri1: " << tri1.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
HDTriangulation tri2;
|
||||
tri2 = tri1;
|
||||
std::cout << "Vertices in tri2: " << tri2.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri2: " << tri2.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
assert(tri1.is_valid());
|
||||
assert(tri2.is_valid());
|
||||
assert(tri1.number_of_vertices() == tri2.number_of_vertices());
|
||||
assert(tri1.number_of_hyperbolic_faces() == tri2.number_of_hyperbolic_faces());
|
||||
|
||||
std::cout << " -------- SUCCESS --------" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<> Traits;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Traits> HDTriangulation;
|
||||
typedef HDTriangulation::Point Point;
|
||||
typedef HDTriangulation::Vertex_handle Vertex_handle;
|
||||
|
||||
typedef CGAL::Random_points_in_square_2<
|
||||
Point,
|
||||
CGAL::Creator_uniform_2< double, Point > > Point_generator;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
|
||||
Point_generator gen(1.);
|
||||
std::vector<Point> pts;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
pts.push_back(*(++gen));
|
||||
|
||||
HDTriangulation tri;
|
||||
std::vector<Vertex_handle> verts;
|
||||
for (int i = 0; i < pts.size(); ++i)
|
||||
verts.push_back(tri.insert(pts[i]));
|
||||
|
||||
int nv = tri.number_of_vertices();
|
||||
int nf = tri.number_of_hyperbolic_faces();
|
||||
|
||||
std::cout << " -------- inserting --------" << std::endl;
|
||||
std::cout << "Vertices in triangulation: " << nv << std::endl;
|
||||
std::cout << "Faces in triangulation: " << nf << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri.dimension() << std::endl;
|
||||
assert(tri.dimension() == 2);
|
||||
|
||||
std::cout << " -------- removing --------" << std::endl;
|
||||
for (int i = 0; i < verts.size(); ++i)
|
||||
{
|
||||
tri.remove(verts[i]);
|
||||
}
|
||||
|
||||
std::cout << "Vertices in triangulation: " << tri.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in triangulation: " << tri.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri.dimension() << std::endl;
|
||||
|
||||
assert(tri.is_valid());
|
||||
|
||||
std::cout << " -------- SUCCESS --------" << std::endl;
|
||||
|
||||
HDTriangulation tri2;
|
||||
verts.clear();
|
||||
for (int i = 0; i < pts.size(); ++i)
|
||||
verts.push_back(tri2.insert(pts[i]));
|
||||
std::cout << " -------- inserting --------" << std::endl;
|
||||
std::cout << "Vertices in triangulation: " << tri2.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in triangulation: " << tri2.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri2.dimension() << std::endl;
|
||||
assert(tri2.dimension() == 2);
|
||||
|
||||
tri2.remove(verts.begin(), verts.end());
|
||||
|
||||
std::cout << "Vertices in triangulation: " << tri2.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in triangulation: " << tri2.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "Dimension of triangulation: " << tri2.dimension() << std::endl;
|
||||
|
||||
assert(tri2.is_valid());
|
||||
|
||||
std::cout << " -------- SUCCESS --------" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<> Traits;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Traits> HDTriangulation;
|
||||
typedef HDTriangulation::Point Point;
|
||||
typedef HDTriangulation::Vertex_handle Vertex_handle;
|
||||
|
||||
typedef CGAL::Random_points_in_disc_2<
|
||||
Point,
|
||||
CGAL::Creator_uniform_2< double, Point > > Point_generator;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
|
||||
Point_generator gen(0.95);
|
||||
std::vector<Point> pts1;
|
||||
for (int i = 0; i < 75; ++i)
|
||||
pts1.push_back(*(++gen));
|
||||
|
||||
std::vector<Point> pts2;
|
||||
for (int i = 0; i < 150; ++i)
|
||||
pts2.push_back(*(++gen));
|
||||
|
||||
HDTriangulation tri1;
|
||||
tri1.insert(pts1.begin(), pts1.end());
|
||||
std::cout << "Vertices in tri1: " << tri1.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri1: " << tri1.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
HDTriangulation tri2;
|
||||
tri2.insert(pts2.begin(), pts2.end());
|
||||
std::cout << "Vertices in tri2: " << tri2.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri2: " << tri2.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
assert(tri1.is_valid());
|
||||
assert(tri2.is_valid());
|
||||
|
||||
tri1.swap(tri2);
|
||||
|
||||
std::cout << " -------- AFTER SWAP --------" << std::endl;
|
||||
|
||||
std::cout << "Vertices in tri1: " << tri1.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri1: " << tri1.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
std::cout << "Vertices in tri2: " << tri2.number_of_vertices() << std::endl;
|
||||
std::cout << "Faces in tri2: " << tri2.number_of_hyperbolic_faces() << std::endl;
|
||||
|
||||
assert(tri1.is_valid());
|
||||
assert(tri2.is_valid());
|
||||
|
||||
std::cout << " -------- SUCCESS --------" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue