Code snippets‎ > ‎C++‎ > ‎CGAL‎ > ‎

Alpha shapes

Alpha shapes for astronomical data

We study the topology of the Megaparsec Cosmic Web on the basis of the Alpha Shapes of the galaxy distribution. The simplicial complexes of the alpha shapes are used to determine the set of Betti numbers, which represent a complete characterization of the topology of a manifold.

The application reads the data from a file, computes the alpha shape and writes the data in the OFF format that can be viewed with GeomView. The CGAL library is used for the computation of the Alpha Shape.

The outline of the main function is:

int main(int argc, char *argv[]) {
  std::vector<Point> data;
  read_astro_data(argv[1], data);
  // Optionally select a slice
  // Creating Delaunay triangulation
  Delaunay dt;
  dt.insert(data.begin(), data.end());
  // Creating Alpha shape
  Alpha_shape alpha_shape(dt);
  // Write to off if an alpha value was given
  if (argc == 3) {
    write_off("", alpha_shape);
  // Starting geomview
  // '+'/'-': step alpha value
  // '['/']': increase / decrease alpha value by 10%
  return 0;

For the application you need:
It uses CMake for building the application and assumes that CGAL can be found (which means that you have to point the CGAL_DIR environment variable to the right directory). GeomView should be installed to visualize the result.

To build the application you should take the following steps:

  • extract the sources:
    tar czvf astro_alpha.tgz
  • create the build directory
    mkdir astro_alpha_build
  • goto the build directory
    cd astro_alpha_build
  • initialize using CMake
    cmake ../astro_alpha
  • build
  • run
    astro_alpha_to_geomview <data_file> <alpha_value>
Nico Kruithof,
Aug 2, 2011, 4:22 AM