Using CGAL
From SOFAWiki
Contents |
Using CGAL
CGAL is a C++ library specialized on geometric computations.
Compiling CGAL
CGAL is a big project, therefore it is not included natively into SOFA extlibs' directory. Here is the way to compile it for SOFA.
Dependencies
(http://www.cgal.org/Manual/3.6/doc_html/installation_manual/Chapter_installation_manual.html)
Before you compile CGAL, you need additional dependencies/tools :
- CMake
- Boost
- GMP/MPFR
- Qt
- METIS/TAUCS
- BLAS/LAPACKS
Windows : Use installers from software's site for CMake, Boost. As for GMP/MPFR, the most easy way is to get CGAL binaries package, and get precompiled libs and includes of GMP/MPFR. Then add into the INCLUDE environment variable the directory where these files are located.
Linux : Use your distribution's package system to install those libraries
MacOS X : Use MacPorts to install cmake, boost, gmp, mpfr and add the installation path into your sofa-local.cfg, by default it is the following:
macx { INCLUDEPATH += /opt/local/include LIBS += -L/opt/local/lib }
Note also that there is a bug with the installation of Boost on Snow Leopard in 32 bit using MacPorts (http://trac.macports.org/ticket/23796). Install Boost 1.42 manually and add the path into your sofa-local.cfg.
And finally, enable TAUCS and MENTIS in Sofa.cfg (and compile sofa with those).
Compilation
<SOFA_DIR> is the directory where Sofa is installed.
- Download CGAL on its Gforge files' part : https://gforge.inria.fr/frs/?group_id=52
- Extract into <SOFA_DIR>/extlibs
- Do a symbolic link (or rename) "CGAL-<Version>" for "CGAL" (you should have <SOFA_DIR>/extlibs/CGAL)
- Change dir into it
Examples and Demos (Linux Only)
Type:
SOFA_DIR="/media/data/Sofa/" cmake . -DWITH_examples=ON -DWITH_demos=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$SOFA_DIR/extlibs/ -DTAUCS_INCLUDE_DIR=$SOFA_DIR/extlibs/taucs/src/ \ -DTAUCS_LIBRARIES=$SOFA_DIR/lib/linux/libtaucs.so -DMETIS_LIBRARIES=$SOFA_DIR/lib/linux/libmetis.so -DCMAKE_CXX_FLAGS="-I $SOFA_DIR/extlibs/taucs/build/linux/"
(Change the cmake variable CMAKE_BUILD_TYPE for Debug if you want to compile in debug mode)
If everything is correct (no error), type after that :
make make examples make demos
Libraries only
In order to compile CGAL, type the following instructions from <SOFA_DIR>/extlibs/CGAL:
cmake .
If everything is correct (no error), then type:
for Linux/MacOS X:
makeor for Windows:
nmake
Exception
If you want to compile CGAL in 32 bit on Snow Leopard type:
cmake . -DCGAL_CXX_FLAGS=-m32 -DCGAL_MODULE_LINKER_FLAGS=-m32 -DCGAL_SHARED_LINKER_FLAGS=-m32 -DCGAL_EXE_LINKER_FLAGS=-m32
then
makeInstall libs in Sofa
When the compilation has finished without any problem, copy the libs into Sofa's lib directory
Linux
cp lib/libCGAL* <SOFA_DIR>/lib/linux/
MacOS X
cp lib/libCGAL* <SOFA_DIR>/lib/macx/
Windows
cp lib/libCGAL* <SOFA_DIR>/lib/win32/
Compile CGALPlugin in Sofa
The last step is to uncomment the following line in your sofa-local.cfg:
DEFINES += SOFA_HAVE_CGAL
Then regenerate your Makefiles (using the provided script for your OS) and compile SOFA.
Note about Boost library
1. If you are using Boost 1.40 and earlier versions, the following default line in sofa.cfg is correct and CGALPlugin should compile.
SOFA_EXT_LIBS *= -lgmp -lmpfr -lboost_thread-mt
2. However, if you are using Boost 1.41 or 1.42, name convention has changed. Please modify the line above to:
SOFA_EXT_LIBS *= -lgmp -lmpfr -lboost_thread
3. Boost 1.43 has not been tested with SOFA (4th of June 2010).
