7.6 KiB
Executable File
7.6 KiB
Executable File
CGAL dabbling
- CGAL is one of the most insanely cryptic and impenetrable libraries I have found.
-
Where I am stuck now:
- I can use 1D features in Mesh_3/mesh_two_implicit_spheres_with_balls.cpp but this is the wrong sort of data (it's a 3D mesh, yes, but not a surface mesh) and "medit" and "vtu" are all it can write. How do I extract a surface mesh to get a Polyhedron_3 so that I can write an OBJ?
- Or: Is there any way to use 1D features with a surface mesh?
- Even if I manage to put this Mesh_3 into the right form I have no guarantees that it is a good surface mesh. It uses a different algorithm than for the surface mesh - I'm simply trying to take the surface of the result. I should also expect this algorithm to be something more like O(N^3) with mesh resolution because it must fill the volume with tetrahedrons, and I then just throw away all of these.
- This is based around the source for mesh_implicit_sphere.cpp from CGAL: 3D Mesh Generation.
- Why am I not using facets_in_complex_3_to_triangle_mesh()?
-
Mesh_3/mesh_two_implicit_spheres_with_balls.cpp shows the use of Mesh_domain_with_polyline_features_3 to explicitly give features to preserve
- This uses the
make_mesh_3call while I'm usingmake_surface_mesh… - I can only call
CGAL::print_polyhedron_wavefrontif I have aPolyhedronand I cannot figure out how to get one from aC3t3. So, perhaps I am stuck with this "medit" mesh format, or else VTU. - I think the terminology is trying to tell me: this isn't a surface mesh, it's a 3D mesh made of tetrahedra. It sounds like the type of data from a Delaunay triangulation is inherently rather different from a surface mesh.
- https://doc.cgal.org/latest/Mesh_3/index.html#title24 does the opposite direction of what I need
- This uses the
- There are Feature Detection Functions, but
detect_featuresis in Polyhedral_complex_mesh_domain_3 and Polyhedral_mesh_domain_with_features_3 -
Domains:
- MeshDomain_3 concept
- MeshDomainWithFeatures_3 concept
- Why make_surface_mesh, Implicit_surface_3, Complex_2_in_triangulation_3 vs. make_mesh_3, Implicit_mesh_domain_3, Mesh_complex_3_in_triangulation_3?
-
parameters::features() - can do 1-dimensional features
- now how do I use it?
-
make_surface_mesh args:
SurfaceMeshC2T3& c2t3- must be a model of concept SurfaceMeshComplex_2InTriangulation_3SurfaceMeshTraits::Surface_3 surface- must be a model of concept Surface_3SurfaceMeshTraits traits- must be a model of concept SurfaceMeshTraits_3FacetsCriteria criteria- must be a model of concept SurfaceMeshFacetsCriteria_3Tag
- "This algorithm of CGAL::make_surface_mesh is designed for smooth implicit surfaces. If your implicit surface is not smooth, then the sharp features of the surface will not be meshed correctly."
(setq org-confirm-babel-evaluate nil)
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(org-version)
9.1.9
gcc --version
Apple LLVM version 9.1.0 (clang-902.0.39.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
#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/make_mesh_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_3 Point;
typedef FT (Function)(const Point&);
typedef CGAL::Implicit_mesh_domain_3<Function,K> Mesh_domain;
#ifdef CGAL_CONCURRENT_MESH_3
typedef CGAL::Parallel_tag Concurrency_tag;
#else
typedef CGAL::Sequential_tag Concurrency_tag;
#endif
typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
FT sphere_function (const Point& p) {
return CGAL::squared_distance(p, Point(CGAL::ORIGIN))-1;
}
<<includes>>
using namespace CGAL::parameters;
<<typesDomain>>
<<typesTriangulation>>
<<typesCriteria>>
<<sphereFunction>>
int main()
{
// Domain (Warning: Sphere_3 constructor uses squared radius !)
Mesh_domain domain(sphere_function,
K::Sphere_3(CGAL::ORIGIN, 2.));
// Mesh criteria
Mesh_criteria criteria(facet_angle=30, facet_size=0.1, facet_distance=0.025,
cell_radius_edge_ratio=2, cell_size=0.1);
std::cout << "Generating..." << std::endl;
// Mesh generation
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// Output
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file);
std::cout << "Done" << std::endl;
return 0;
}
| Generating… |
| Done |