Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Meshing of polyhedron persistently fails

Subject: CGAL users discussion list

List archive

[cgal-discuss] Meshing of polyhedron persistently fails


Chronological Thread 
  • From: "Garth N. Wells" <>
  • To:
  • Subject: [cgal-discuss] Meshing of polyhedron persistently fails
  • Date: Thu, 17 Oct 2013 17:57:50 +0100

I'm trying to create a volume mesh of a polyhedron with many faces, but I keep getting the error:

construct initial points:
8/8 initial point(s) found...
Start surface scan...end scan. [Bad facets:12]

Refining Surface...
Legende of the following line: (#vertices,#steps,#facets to refine,#tets to refine)
(3286,3277,0,0) (2847.9 vertices/s))))
Total refining surface time: 1.15069s

Start volume scan...end scan. [Bad tets:9713]

Refining...
Legende of the following line: (#vertices,#steps,#facets to refine,#tets to refine)
(7617,4330,0,37339) (11173.1 vertices/s)terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: !r_tr_.is_infinite(*cell_it)
File: /usr/include/CGAL/Mesh_3/Refine_cells_3.h
Line: 385


What I'm doing is surface meshing a sphere, converting the surface mesh to a polyhedron, and trying to generate a volume mesh of the polyhedron (the motivation is to add/subtract polyhedra to create more complicated domains). The code that reproduces the error (using CGAL 4.2 and GCC 4.8) is attached. The code is basically a concatenation of the demos in sections 48.3.1 and 51.3.2. Any suggestions to get this working?

Garth
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/Complex_2_in_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>

#include <CGAL/IO/output_surface_facets_to_polyhedron.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>

#include <CGAL/Polyhedral_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/refine_mesh_3.h>

typedef CGAL::Surface_mesh_default_triangulation_3 Tr;
typedef CGAL::Complex_2_in_triangulation_3<Tr> C2t3;

typedef Tr::Geom_traits GT;
typedef GT::Sphere_3 Sphere_3;
typedef GT::Point_3 Point_3;
typedef GT::FT FT;

typedef GT::Kernel K;

typedef FT (*Function)(Point_3);

typedef CGAL::Implicit_surface_3<GT, Function> Surface_3;

FT sphere_function (Point_3 p) {
  const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z();
  return x2+y2+z2-1;
}

typedef CGAL::Polyhedron_3<K> Polyhedron;

// 3D mesh typedefs
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, K> Mesh_domain;
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr3;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr3> C3t3;
typedef CGAL::Mesh_criteria_3<Tr3> Mesh_criteria;

using namespace CGAL::parameters;

int main() {
  Tr tr;
  C2t3 c2t3 (tr);

  // defining the surface
  Surface_3 surface(sphere_function,             // pointer to function
                    Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere

  // defining meshing criteria
  CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30.,  // angular bound
                                                     0.1,  // radius bound
                                                     0.1); // distance bound
  // Mesh surface
  CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());

  // Copy surface mesh to polyhedron
  Polyhedron polyhedron;
  CGAL::output_surface_facets_to_polyhedron(c2t3, polyhedron);

  // --- Mesh 'polyhedralised' sphere

  // Create domain
  Mesh_domain domain(polyhedron);

  Mesh_criteria criteria3(facet_angle=30,
                          facet_size=0.05,
                          facet_distance=0.15,
                          cell_radius_edge_ratio=2,
                          cell_size=0.05);

  // Mesh generation
  std::cout << "Build 3D mesh" << std::endl;
  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria3,
                                      no_perturb(), no_exude());
}



Archive powered by MHonArc 2.6.18.

Top of Page