Closed TLCZhaoxi closed 1 year ago
I tried to use VTK to calculate the BooleanOperationUnion of the two meshes and got a result. But the results has a lot of errors. The error result is here: union.zip
Your meshes have some self-intersections and boundary edges:
A simple call to stitch_borders()
on each mesh before the operations is enough to fix those issues. Most likely it is a problem in the generation algorithm.
Out of curiosity, what are those meshes? Trajectories?
These two meshes was generated based on VTK TubeFilter, which is two wires of an expanded flow diverter. The flow diverter is an device implant into the neuro-aneurysm's parent artery to stop the blood flow flushing onto the wall of aneurysm.
Anyway, I will check the mesh again, and do as what you said. Thanks.
@sloriot I check the two meshes again, but I didnot found any border edges. Here is my meshes in both off and stl format. Desktop.zip Could you help to check them again? And I will check the borders and call stitch_boarders() before the boolean union. I will submit the result soon.
@sloriot Thanks a lot, I checked my meshes with code. They do have some border edges. And the stitch_borders() do solve the problem. Although the results seems not so good, but that is another problem. Thanks a lot!
I guess you called some remeshing after the boolop
@sloriot Yes, I do call some remeshing. I want to optimize the angle of triangles around the intersected area of boolean operation. But that change the shape of the model.
You need to also protect sharp features. You can do it locally but globally (more expensive though) should be fine too. https://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__detect__features__grp.html#gadd3d18c0a9773463cd57902f85d0b23d
@sloriot I am trying to optimize the triangles after boolean operation like this:
typedef boost::property_map<SurfaceMesh, CGAL::edge_is_feature_t>::type EIFMap;
EIFMap eif = get(CGAL::edge_is_feature, unionMesh);
PMP::detect_sharp_edges(unionMesh, 10.0, eif);
PMP::isotropic_remeshing(unionMesh.faces(), constrainedRemeshSize, unionMesh,
CGAL::parameters::edge_is_constrained_map(eif).protect_constraints(true));
This code really do something, but maybe too much edges are protected. That lead the optimization is not enough.
There are a lot of sharp angles still.
Can you try to add the named property relax_constraints
.
I did just like what you said, It is better. But maybe still not perfect.
Try adding more iterations?
I make the remesh after boolen union locally with a smaller size. The sharp edges was set to be constrained(collapse false, relax true). The iteration number was set to be 20. It seems better. Maybe it can be better?
And I do find some edges collapse, as shown below Even the collapse was set to be false.
The collapse edge is because of I did not expand the local selected faces, after I did that, Everythind seems much better now!
Everything is good, but the mesh data is quite large right now....
And the generation time is also quite long.
You can try to reduce the number of iterations now that you've set up options according to your needs. Also sharp edge detection could be reduced to the selection and target edge could be adapted.
Issue Details
I tried to calculate the boolen operation Union of two meshes with default parameters. In Debug Mode, CGAL::Assertion_exception was throwed, which indicated that some nodes are duplicated. As follow:
terminate called after throwing an instance of 'CGAL::Assertion_exception' what(): CGAL ERROR: assertion violation! Expr: enodes.size() == std::set<typename Exact_kernel::Point_3>(enodes.begin(), enodes.end()).size() File: /opt/install/CProjX/Hemodynamics_Library/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h Line: 316
In Release Mode, The function of 'corefine_and_compute_union' return false;Meshes are uploaded here: Meshes.zip
Source Code
SurfaceMesh::Property_map<edge_descriptor, bool> is_constrained_map = unionMesh.add_property_map<edge_descriptor, bool>("e:is_constrained", false).first; bool isValid = PMP::corefine_and_compute_union(msh1, msh2, unionMesh, CGAL::parameters::default_values(), CGAL::parameters::default_values(), CGAL::parameters::edge_is_constrained_map(is_constrained_map)); if (!isValid) { std::cerr << "Mesh Union Failed" << std::endl; return false; }
Environment