geogram icon indicating copy to clipboard operation
geogram copied to clipboard

getting "Emergency exit in Delaunayize_new_edges()" when try to do boolean operations

Open kasunJKD opened this issue 1 year ago • 2 comments
trafficstars

For simple meshes im running this code which works perfectly fine

    std::string output_filename =
        filenames.size() >= 3 ? filenames[2] : std::string("outnew.stl");

    Logger::div("Data I/O");

    Logger::out("I/O") << "Output = " << output_filename << std::endl;

Mesh A;
Mesh B;

if(!mesh_load(A_filename,A)) {
    return 1;
}

if(!mesh_load(B_filename,B)) {
    return 1;
}

Mesh result;

if(CmdLine::get_arg_bool("pre")) {
    Logger::div("Pre-processing");
    fix_mesh_for_boolean_ops(A);
    fix_mesh_for_boolean_ops(B);	    
}

compute_normals(A);

   //offsetting
vector<vec3> N(A.vertices.nb());
for (index_t v : A.vertices) {
	N[v] = 0.5 * normalize(
		Geom::mesh_vertex_normal(A, v)
	);
}
for (index_t v : A.vertices) {
	double* p = A.vertices.point_ptr(v);
	p[0] += N[v].x;
	p[1] += N[v].y;
	p[2] += N[v].z;
}
MeshSurfaceIntersection I(A);
I.set_radial_sort(true);
I.intersect();
I.remove_internal_shells();

{
	mesh_difference(result, B, A);
    
}


if(CmdLine::get_arg_bool("post")) {
    Logger::div("Post-processing");		    
    fix_mesh_for_boolean_ops(result);	    
}

    Logger::div("Data I/O");

    if(output_filename != "none") {
    mesh_save(result, output_filename);
}

but for some meshes im getting CDT2d"Emergency exit in Delaunayize_new_edges()", cant seem to find whats the issue is. i tried removing mesh fixing functions too , if i dont do that boolean operations does not happen

kasunJKD avatar Dec 13 '23 11:12 kasunJKD

Hi, a couple of days ago I fixed a horrible bug that probably solves this, Would you share input meshes so that I can double check ? Thanks !

BrunoLevy avatar Dec 13 '23 12:12 BrunoLevy

Hi, yes i can , ive added the 2 input files into this google drive https://drive.google.com/drive/folders/17QAC3YOl2A_wS-asjGNc5KtWjf7p9rPf?usp=sharing

Thanks

kasunJKD avatar Dec 13 '23 12:12 kasunJKD

Found out ! (took me some time), The supports have tiny differences in coordinates, it is not a closed boundary that defines a volume. I could fix it by snapping the coordinates to the nearest floating point. Then I was able to compute the union between the support and the dragon: image image

TL;DR: for it to work, you need to make sure that the same point has exactly the same coordinates in the file. In the support, that looks like a grid "seen from above" (see figure), there were tiny difference in the grid corner's coordinates. image

BrunoLevy avatar Jun 17 '24 09:06 BrunoLevy