CGAL from scratch

So, you need computational geometry. It could be you need some nice Voronoi division of some domain. Or you need to mesh a surface. Whatever your needs, you may know there is this CGAL project that has these things implemented in a very professional manner.

Here is a list of steps in order to get these routines working for you.

  1. Basic programming, in any language:
    1. variables, statements, loops, and so on
  2. Basic c/c++ programming:
    1. ¡passing by reference! (c++)
  3. Object-oriented c++
    1. classes and structs
    2. creators
    3. ¡¡templates!!
    4. inheritance (just the basics)
  4. The c++ STL:
    1. vectors
    2. ¡lists! (life without indices)
  5. Download CGAL libs and compile them with cmake.
  6. In order to create your new project, create an new directory, then
    1. (for convenience) export CGAL_DIR=~/Software/CGAL-3.8 (or whereever CGAL libs are)
    2. run $CGAL_DIR/scripts/cgal_create_cmake_script demo
    3. run cmake -DCGAL_DIR=$CGAL_DIR . (notice the period at the end!)
    4. if you  get errors regarding the Qt libs, edit the CMakeLists.txt file and remove all references to them
    5. run make
    6. for additional compiling options, run cmake -DCGAL_DIR=CGAL_DIR  -DCMAKE_CXX_FLAGS="-g" .
    7. If you need extra libs in your code, such as the GSL, run pkg-config --libs lib_name to see the options you need. For example, pkg-config --libs gsl returns -lgsl -lgslcblas -lm. This shortcut should also work (actually, it quite does not for me):cmake -DCGAL_DIR=CGAL_DIR/CGAL-3.8 -DCMAKE_CXX_FLAGS=`pkg-config --libs gsl` .
    8. run your project!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s