Replies: 13 comments 23 replies
-
Wait... writing the off files has rounded the vertices up to 4 digits, and this works with the rounded vertices! I get a pretty polyhedra for the intersection. Do you know why the rounding solves the issue? |
Beta Was this translation helpful? Give feedback.
-
Also, that's nice if the rounding is a solution, but I'd like to prevent the crash. |
Beta Was this translation helpful? Give feedback.
-
Attached are the off files with the unrounded vertices. |
Beta Was this translation helpful? Give feedback.
-
You're using an Exact_predicates_inexact_constructions_kernel corefine_and_compute_intersection may produce self-intersecting results with this type of kernel. Try using an Exact_predicates_exact_constructions_kernel if you want to reprocess the results as above. |
Beta Was this translation helpful? Give feedback.
-
Can you please give more context. I tried it with the master branch as well as with 5.4 with Visual C++ and boost 1_66_0 and I cannot reproduce your problem yet. |
Beta Was this translation helpful? Give feedback.
-
I tried with a newer version of g++ and now this crashes even for two tetrahedra with rounded vertices. I'm trying on Linux now, via a Github action. That does not smell good: the action is running for 30 minutes, while it took 25 minutes before. |
Beta Was this translation helpful? Give feedback.
-
I tested with Windows on another machine, including a DEBUG option, and I get this error:
|
Beta Was this translation helpful? Give feedback.
-
I am sorry but you must be more precise. You finally do it with which kernel, and with which data set. What does "with Windows" mean, that is in case it is VC++ which version? What do you mean with "including a DEBUG option"? Also what does "4.2" in the line starting with "File: C:/" refer to ? Is that the release number of CGAL you use? |
Beta Was this translation helpful? Give feedback.
-
Wait... it has worked on another Windows machine using the vertex coordinates rounded up to 11 digits. And I see in my latest OFF files that the coordinates are rounded up to 11 digits. I'm going to prepare a code with totally unrounded coordinates this time, hoping someone will try it. |
Beta Was this translation helpful? Give feedback.
-
This time this is maximally unrounded. Please anyone, could you try? #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Surface_mesh.h>
#include <math.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[]) {
double phi = (1.0 + sqrt(5.0)) / 2.0;
double a = 1.0 / sqrt(3.0);
double b = a / phi;
double c = a * phi;
Mesh mesh1, mesh2, mesh3, mesh4, mesh5;
Mesh::Vertex_index v0 = mesh1.add_vertex(Point_3(0, b, c));
Mesh::Vertex_index v1 = mesh1.add_vertex(Point_3(b, -c, 0));
Mesh::Vertex_index v2 = mesh1.add_vertex(Point_3(a, a, -a));
Mesh::Vertex_index v3 = mesh1.add_vertex(Point_3(-c, 0, b));
Mesh::Vertex_index v4 = mesh2.add_vertex(Point_3(a, -a, -a));
Mesh::Vertex_index v5 = mesh2.add_vertex(Point_3(a, a, a));
Mesh::Vertex_index v6 = mesh2.add_vertex(Point_3(-a, -a, a));
Mesh::Vertex_index v7 = mesh2.add_vertex(Point_3(-a, a, -a));
Mesh::Vertex_index v8 = mesh3.add_vertex(Point_3(c, 0, b));
Mesh::Vertex_index v9 = mesh3.add_vertex(Point_3(-a, a, a));
Mesh::Vertex_index v10 = mesh3.add_vertex(Point_3(-b, -c, 0));
Mesh::Vertex_index v11 = mesh3.add_vertex(Point_3(0, b, -c));
Mesh::Vertex_index v12 = mesh4.add_vertex(Point_3(a, -a, a));
Mesh::Vertex_index v13 = mesh4.add_vertex(Point_3(b, c, 0));
Mesh::Vertex_index v14 = mesh4.add_vertex(Point_3(-c, 0, b));
Mesh::Vertex_index v15 = mesh4.add_vertex(Point_3(0, -b, -c));
Mesh::Vertex_index v16 = mesh5.add_vertex(Point_3(-a, -a, -a));
Mesh::Vertex_index v17 = mesh5.add_vertex(Point_3(-b, c, 0));
Mesh::Vertex_index v18 = mesh5.add_vertex(Point_3(c, 0, -b));
Mesh::Vertex_index v19 = mesh5.add_vertex(Point_3(0, -b, c));
mesh1.add_face(v0, v1, v2);
mesh1.add_face(v2, v1, v3);
mesh1.add_face(v3, v1, v0);
mesh1.add_face(v0, v2, v3);
mesh2.add_face(v4, v5, v6);
mesh2.add_face(v6, v5, v7);
mesh2.add_face(v7, v5, v4);
mesh2.add_face(v4, v6, v7);
mesh3.add_face(v8, v9, v10);
mesh3.add_face(v10, v9, v11);
mesh3.add_face(v11, v9, v8);
mesh3.add_face(v8, v10, v11);
mesh4.add_face(v12, v13, v14);
mesh4.add_face(v14, v13, v15);
mesh4.add_face(v15, v13, v12);
mesh4.add_face(v12, v14, v15);
mesh5.add_face(v16, v17, v18);
mesh5.add_face(v18, v17, v19);
mesh5.add_face(v19, v17, v16);
mesh5.add_face(v16, v18, v19);
Mesh inter12;
if(PMP::corefine_and_compute_intersection(mesh1, mesh2, inter12)) {
std::cout << "Intersection th1-th2 successfully computed.\n";
if(PMP::does_self_intersect(inter12)) {
std::cout << "Intersection th1-th2 self-intersects.\n";
return 0;
}
if(!PMP::does_bound_a_volume(inter12)) {
std::cout << "Intersection th1-th2 does not bound a volume.\n";
return 0;
}
Mesh inter34;
if(PMP::corefine_and_compute_intersection(mesh3, mesh4, inter34)) {
std::cout << "Intersection th3-th4 successfully computed.\n";
if(PMP::does_self_intersect(inter34)) {
std::cout << "Intersection th3-th4 self-intersects.\n";
return 0;
}
if(!PMP::does_bound_a_volume(inter34)) {
std::cout << "Intersection th3-th4 does not bound a volume.\n";
return 0;
}
Mesh inter1234;
if(PMP::corefine_and_compute_intersection(inter12, inter34, inter1234)) {
std::cout << "Intersection th1-th2-th3-th4 successfully computed.\n";
if(PMP::does_self_intersect(inter1234)) {
std::cout << "Intersection th1-th2-th3-th4 self-intersects.\n";
return 0;
}
if(!PMP::does_bound_a_volume(inter1234)) {
std::cout
<< "Intersection th1-th2-th3-th4 does not bound a volume.\n";
return 0;
}
Mesh inter12345;
if(PMP::corefine_and_compute_intersection(inter1234, mesh5,
inter12345)) {
std::cout << "Final intersection successfully computed.\n";
CGAL::IO::write_polygon_mesh("inter_tetrahedra.off", inter12345,
CGAL::parameters::stream_precision(17));
return 0;
} else {
std::cout << "Final intersection failed.\n";
return 1;
}
} else {
std::cout << "Intersection th1-th2-th3-th4 failed.\n";
return 1;
}
} else {
std::cout << "Intersection th3-th4 failed.\n";
return 1;
}
} else {
std::cout << "Intersection th1-th2 failed.\n";
return 1;
}
} |
Beta Was this translation helpful? Give feedback.
-
And please put the code on gist.github.com |
Beta Was this translation helpful? Give feedback.
-
Failure confirmed: darikg/seagullmesh#1 |
Beta Was this translation helpful? Give feedback.
-
Blog post: https://laustep.github.io/stlahblog/posts/BooleanOpsOnMeshes.html |
Beta Was this translation helpful? Give feedback.
-
Hello,
Here is the compound of five tetrahedra:
These are five tetrahedra centered at the origin. I didn't manage to compute their intersection. I can get the intersection of four of them, but not of the five ones. I use CGAL via R and the computation crashes the R session, without informative error messages.
I would be grateful if someone tries. Attached are the off files and below is the (untested) code.
If you try and this works, that would perhaps mean there's a problem in my R/C++ code. I also tried with nef polyhedras but this was worst.
ths_offFiles.zip
Beta Was this translation helpful? Give feedback.
All reactions