adiguz91 / CVT2D

A Lloyd algorithm implementation constructing Centroidal Voronoi Diagram in 2D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CVT2D

A Lloyd algorithm implementation constructing Centroidal Voronoi Diagram in 2D. It uses the Voronoi_diagram_2 and Nef_Polyhedron_2 package in CGAL and works on arbitrary boundary contraints (i.e. whether it is convex or concave, connected or multi-connected, genus-0 or multi-genuses).

This is a new branch that use Matlab to deal with non-constant density function.

Prerequisites

This program uses the following tools:

  1. CGAL 4.6, which is used to generate Voronoi diagram and execute intersection between Voronoi cells and boundaries;
  2. Matlab, which is used to calculate the value of the energy function of CVT, and the cetroid of each Voronoi cell. For the const density case, a straight forward way is also used to accelerate the calculatino speed of the above two;
  3. MS-MPI, which is used to parallelize the updating procedure of the generators.

Example


Figure 1. Results.

Figure 2. Results on a shrimp-shaped constraint with 10, 20, 50 and 100 generators.

Parallel

Since the Nef_polyhedron_2 class in CGAL is currently not thread-safe, it is hard to use OpenMP directly to parallelly compute CVT. Here MPI is used to parallelly process the updating of centroids.

The performance on the disk boundary (approximated by 100 segments) with 1,000 generators and 100 iterations varing along with the number of processes is shown in the following:

# of process time (sec.)
1 3843.4
2 2128.7
4 1120.6
8 595.3
16 314.4
32 180.1
64 169.3

About

A Lloyd algorithm implementation constructing Centroidal Voronoi Diagram in 2D


Languages

Language:C++ 98.2%Language:C 1.8%