CGAL

From arccwiki
Jump to: navigation, search

CGAL: CGAL is a software project that provides easy access to efficient and reliable geometric algorithms in the form of a C++ library. CGAL is used in various areas needing geometric computation, such as geographic information systems, computer aided design, molecular biology, medical imaging, computer graphics, and robotics. The library offers data structures and algorithms like triangulations, Voronoi diagrams, Boolean operations on polygons and polyhedra, point set processing, arrangements of curves, surface and volume mesh generation, geometry processing, alpha shapes, convex hull algorithms, shape reconstruction, AABB and KD trees...
Manual 4.6.3

Module: Example

[salexan5@tlog2 cgal]$ module spider cgal
----------------------
  cgal: cgal/4.6.3
----------------------
    You will need to load all module(s) on any one of the lines below before the "cgal/4.6.3" module is available to load.
      swset/2018.05  gcc/7.3.0
 
    Help:
      The Computational Geometry Algorithms Library (CGAL) is a C++ library
      that aims to provide easy access to efficient and reliable algorithms in
      computational geometry. CGAL is used in various areas needing geometric
      computation, such as geographic information systems, computer aided
      design, molecular biology, medical imaging, computer graphics, and
      robotics.
module load gcc/7.3.0
module load cgal/4.6.3

Using:

The documentation recommends using CMake when building code that uses the CGAL library: Configuring and Building Programs Using CGAL and provides some helper scripts to create the make file.

Below is just one (of probably a number of) way of build an application that uses the CGAL library.

[]$ mkdir ~/software/cgal
[]$ cd  ~/software/cgal

[]$ wget https://github.com/CGAL/cgal/archive/releases/CGAL-4.6.3.zip 
[]$ unzip CGAL-4.6.3.zip

[]$ module load cmake/3.13.4

[]$ ~/software/cgal/cgal-releases-CGAL-4.6.3/Scripts/scripts/cgal_create_CMakeLists 
CGAL_COMPONENTS: 
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.

project( test )

cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
  if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
    cmake_policy(VERSION 2.8.4)
  else()
    cmake_policy(VERSION 2.6)
  endif()
endif()

set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
 
if ( COMMAND cmake_policy )
  cmake_policy( SET CMP0003 NEW )  
endif()

# CGAL and its components
find_package( CGAL QUIET COMPONENTS  )

if ( NOT CGAL_FOUND )
  message(STATUS "This project requires the CGAL library, and will not be compiled.")
  return()  
endif()

# include helper file
include( ${CGAL_USE_FILE} )

# Boost and its components
find_package( Boost REQUIRED )

if ( NOT Boost_FOUND )
  message(STATUS "This project requires the Boost library, and will not be compiled.")
  return()  
endif()

# include for local directory
# include for local package

# Creating entries for all .cpp/.C files with "main" routine
# ##########################################################

include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "points_and_segment.cpp" )

created CMakeLists.txt in /home/home-directory/software/cgal/test ...

[]$ ls
CMakeLists.txt  points_and_segment.cpp

[]$ cmake .
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /apps/u/gcc/4.8.5/gcc/7.3.0-xegsmw4/bin/gcc
-- Check for working C compiler: /apps/u/gcc/4.8.5/gcc/7.3.0-xegsmw4/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /apps/u/gcc/4.8.5/gcc/7.3.0-xegsmw4/bin/g++
-- Check for working CXX compiler: /apps/u/gcc/4.8.5/gcc/7.3.0-xegsmw4/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build type: Release
-- USING CXXFLAGS = ' -frounding-math -O3 -DNDEBUG'
-- USING EXEFLAGS = ' '
-- Targetting Unix Makefiles
-- Using /apps/u/gcc/4.8.5/gcc/7.3.0-xegsmw4/bin/g++ compiler.
CMake Warning (dev) at /apps/u/gcc/7.3.0/cgal/4.6.3-ehuzhkp/lib/CGAL/CGAL_TweakFindBoost.cmake:44 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'CGAL_Boost_USE_STATIC_LIBS'.
Call Stack (most recent call first):
  /apps/u/gcc/7.3.0/cgal/4.6.3-ehuzhkp/lib/CGAL/UseCGAL.cmake:20 (include)
  CMakeLists.txt:35 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Requested component: MPFR
-- Requested component: GMP
-- Boost version: 1.68.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/salexan5/software/cgal/test

[]$ make
Scanning dependencies of target points_and_segment
[ 50%] Building CXX object CMakeFiles/points_and_segment.dir/points_and_segment.cpp.o
[100%] Linking CXX executable points_and_segment
[100%] Built target points_and_segment

[]$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  CMakeLists.txt  Makefile  points_and_segment  points_and_segment.cpp

[]$ ./points_and_segment 
p = 1 1
q = 10 10
sqdist(p,q) = 162
m = 5 9
sqdist(Segment_2(p,q), m) = 8
p, q, and m make a left turn
 midpoint(p,q) = 5.5 5.5


Back to HPC Installed Software