Created
August 25, 2016 16:12
-
-
Save nschloe/55f42e924a6de0eb258ba19410367c07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.0) | |
project(mytest) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
FIND_PACKAGE(CGAL REQUIRED) | |
find_package(Boost COMPONENTS thread REQUIRED) | |
add_executable(mytest main.cpp) | |
target_link_libraries(mytest | |
${CGAL_LIBRARY} | |
${GMP_LIBRARIES} | |
${MPFR_LIBRARIES} | |
${Boost_LIBRARIES} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | |
#include <CGAL/Mesh_triangulation_3.h> | |
#include <CGAL/Mesh_complex_3_in_triangulation_3.h> | |
#include <CGAL/Mesh_criteria_3.h> | |
#include <CGAL/Implicit_mesh_domain_3.h> | |
#include <CGAL/Mesh_domain_with_polyline_features_3.h> | |
#include <CGAL/make_mesh_3.h> | |
#include <memory> | |
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; | |
// Function | |
K::FT sphere_function1 (const K::Point_3& p) { | |
return CGAL::squared_distance(p, K::Point_3(CGAL::ORIGIN)) - 1; | |
} | |
class sphere_class { | |
public: | |
K::FT eval(const K::Point_3& p) { | |
return CGAL::squared_distance(p, K::Point_3(CGAL::ORIGIN)) - 1; | |
} | |
}; | |
typedef K::FT (Function)(const K::Point_3&); | |
typedef CGAL::Mesh_domain_with_polyline_features_3< | |
CGAL::Implicit_mesh_domain_3<sphere_class,K> | |
> | |
Mesh_domain; | |
// Triangulation | |
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr; | |
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3; | |
// Mesh Criteria | |
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; | |
typedef Mesh_criteria::Facet_criteria Facet_criteria; | |
typedef Mesh_criteria::Cell_criteria Cell_criteria; | |
int main() { | |
// // works: | |
// Mesh_domain domain( | |
// sphere_function1, | |
// K::Sphere_3(CGAL::ORIGIN, 5*5), | |
// 1.0e-4 | |
// ); | |
// // error: reference to non-static member function must be called | |
// sphere_class s; | |
// Mesh_domain domain( | |
// s.eval, | |
// K::Sphere_3(CGAL::ORIGIN, 5*5), | |
// 1.0e-4 | |
// ); | |
// /usr/include/CGAL/Implicit_to_labeling_function_wrapper.h:75:15: error: type 'const sphere_class' does not provide a call operator | |
// return ( (r_f_(p)<0) ? 1 : 0 ); | |
// ^~~~ | |
sphere_class s; | |
Mesh_domain domain( | |
s, | |
K::Sphere_3(CGAL::ORIGIN, 5*5), | |
1.0e-4 | |
); | |
// Set mesh criteria | |
Facet_criteria facet_criteria(30, 0.1, 0.1); | |
Cell_criteria cell_criteria(2.0, 0.1); | |
Mesh_criteria criteria(facet_criteria, cell_criteria); | |
// Mesh generation | |
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria); | |
// Output | |
std::ofstream medit_file("out.mesh"); | |
c3t3.output_to_medit(medit_file); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment