Skip to content

Instantly share code, notes, and snippets.

@nschloe
Created August 21, 2016 14:07
Show Gist options
  • Save nschloe/640e280f5e54f12266f1b5ef9aca95ee to your computer and use it in GitHub Desktop.
Save nschloe/640e280f5e54f12266f1b5ef9aca95ee to your computer and use it in GitHub Desktop.
CGAL Function_vector example
cmake_minimum_required(VERSION 3.0)
project(mytest)
FIND_PACKAGE(CGAL REQUIRED)
find_package(Boost COMPONENTS thread REQUIRED)
ADD_EXECUTABLE(main test.cpp)
TARGET_LINK_LIBRARIES(
main
${CGAL_LIBRARY}
${GMP_LIBRARIES}
${MPFR_LIBRARIES}
${Boost_LIBRARIES}
)
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Implicit_to_labeling_function_wrapper.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
class Function: public std::unary_function<K::Point_3, K::FT>
{
public:
typedef K::Point_3 Point; // necessary
virtual K::FT operator()(K::Point_3 p) const {
return 0.0;
}
};
class MySphere: public Function
{
public:
virtual K::FT operator()(K::Point_3 p) const
{
return 3.14;
}
};
typedef CGAL::Implicit_multi_domain_to_labeling_function_wrapper<Function> Function_wrapper;
typedef Function_wrapper::Function_vector Function_vector;
int main()
{
MySphere f1;
Function_vector v;
v.push_back(f1);
std::cout << f1(CGAL::ORIGIN) << std::endl;
std::cout << v[0](CGAL::ORIGIN) << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment