Based on this example (Remeshing a Polyhedral Domain with Surfaces in the 3D Mesh Generation Manual), I want to mesh a cube-shaped domain with its midplane protected (see the code below). However, make_mesh_3
throws an assertion violation:
CGAL ERROR: assertion violation!
Expr: minimal_size_ > 0 || sq_d > 0
Nevermind the triviality of the example, it's just to show the problem. Based on this discussion, I think the issue is that detect_features
creates polylines that intersect each other (perimeter of the midplane intersects the cube edges, and both are added as features).
Are intersecting polyhedra not allowed in the meshdomain? If so, is there a way to access and manipulate the results of detect_features
to process conflicting features? I'm trying to figure out how polylines are stored in the mesh domain, but I'm getting nowhere.
Cube with Midplane
// --- External Includes ---
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_polyhedron_3.h>
#include <CGAL/Polyhedral_mesh_domain_with_features_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/make_mesh_3.h>
// CGAL types
namespace cgal {
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using ConcurrencyTag = CGAL::Sequential_tag;
using PolyhedronSurface = CGAL::Mesh_polyhedron_3<Kernel>::type;
using MeshDomain = CGAL::Polyhedral_mesh_domain_with_features_3<Kernel>;
using Tr = CGAL::Mesh_triangulation_3<MeshDomain,CGAL::Default,ConcurrencyTag>::type;
using Triangulation = CGAL::Mesh_complex_3_in_triangulation_3<Tr>;
using MeshCriteria = CGAL::Mesh_criteria_3<Tr>;
using Point = cgal::MeshDomain::Point_3;
}
int main()
{
// Define points for the cube and midPlane
std::vector<cgal::Point> points =
{
cgal::Point( 1.0, 0.0, 0.0),
cgal::Point( 1.0, 1.0, 0.0),
cgal::Point( 0.0, 1.0, 0.0),
cgal::Point( 0.0, 0.0, 0.0),
cgal::Point( 1.0, 0.0, 1.0),
cgal::Point( 1.0, 1.0, 1.0),
cgal::Point( 0.0, 1.0, 1.0),
cgal::Point( 0.0, 0.0, 1.0),
cgal::Point( 1.0, 0.0, 0.5),
cgal::Point( 1.0, 1.0, 0.5),
cgal::Point( 0.0, 1.0, 0.5),
cgal::Point( 0.0, 0.0, 0.5)
};
// Create polyhedra
cgal::PolyhedronSurface cube, midPlane;
cube.make_triangle( points[0], points[3], points[1]);
cube.make_triangle( points[1], points[3], points[2]);
cube.make_triangle( points[4], points[5], points[7]);
cube.make_triangle( points[5], points[6], points[7]);
cube.make_triangle( points[0], points[4], points[3]);
cube.make_triangle( points[3], points[4], points[7]);
cube.make_triangle( points[1], points[2], points[5]);
cube.make_triangle( points[2], points[6], points[5]);
cube.make_triangle( points[2], points[3], points[6]);
cube.make_triangle( points[3], points[7], points[6]);
cube.make_triangle( points[0], points[1], points[5]);
cube.make_triangle( points[0], points[5], points[4]);
midPlane.make_triangle( points[8], points[9], points[10]);
midPlane.make_triangle( points[8], points[10], points[11]);
// Triangulation
cgal::MeshDomain meshDomain( midPlane, cube );
meshDomain.detect_features();
cgal::MeshCriteria meshCriteria( CGAL::parameters::facet_angle = 30,
CGAL::parameters::edge_size = 0.2 );
auto triangulation = CGAL::make_mesh_3<cgal::Triangulation>( meshDomain,
meshCriteria );
return 0;
}